4 天以前 91c82965b2d987452ca276e3a03b48c8dcda2ae9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<script lang="ts" setup>
import type { MesBagCodeHomeApi } from '#/api/mes/bag-code-home';
 
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
 
import { Page } from '@vben/common-ui';
 
import { Col, Row, message } from 'ant-design-vue';
 
import { getBagCodeHomeSummary } from '#/api/mes/bag-code-home';
 
import { defaultSummary } from './data';
import BagCodeCards from './modules/bag-code-cards.vue';
import BagCodeStatusChart from './modules/bag-code-status-chart.vue';
import BasicCards from './modules/basic-cards.vue';
import BatchStatusChart from './modules/batch-status-chart.vue';
import Shortcuts from './modules/shortcuts.vue';
import TrendChart from './modules/trend-chart.vue';
 
defineOptions({ name: 'DashboardBagCodeHome' });
 
const router = useRouter();
const summary = ref<MesBagCodeHomeApi.Summary>(defaultSummary); // 首页汇总统计
 
/** 跳转到目标页面(按路由 name,未加载时提示) */
async function handleNavigate(name: string) {
  try {
    await router.push({ name });
  } catch {
    message.warning('当前菜单尚未加载,请从左侧菜单进入对应页面');
  }
}
 
/** 加载首页汇总统计 */
async function loadSummary() {
  summary.value = await getBagCodeHomeSummary();
}
 
onMounted(() => {
  loadSummary();
});
</script>
 
<template>
  <Page>
    <!-- 第一行:基础数据卡片 -->
    <BasicCards :summary="summary" class="mb-2" @navigate="handleNavigate" />
 
    <!-- 第二行:一袋一码卡片 -->
    <BagCodeCards :summary="summary" class="mb-4" @navigate="handleNavigate" />
 
    <!-- 第三行:袋码趋势 + 批次/袋码状态分布 -->
    <Row :gutter="16" class="mb-4">
      <Col :lg="12" :md="24" :sm="24" :xl="12" :xs="24" class="mb-4">
        <TrendChart />
      </Col>
      <Col :lg="6" :md="12" :sm="24" :xl="6" :xs="24" class="mb-4">
        <BatchStatusChart :list="summary.batchStatusList" />
      </Col>
      <Col :lg="6" :md="12" :sm="24" :xl="6" :xs="24" class="mb-4">
        <BagCodeStatusChart :list="summary.bagCodeStatusList" />
      </Col>
    </Row>
 
    <!-- 第四行:快捷入口 -->
    <Shortcuts @navigate="handleNavigate" />
  </Page>
</template>