4 天以前 10dd6590cea8f20eff21025ee71c8a614a48cdb7
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<script lang="ts" setup>
import type { MesTraceConsumerScanApi } from '#/api/mes/trace-consumer-scan';
 
import { ref, watch } from 'vue';
 
import { CountTo } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
 
import { Card, Col, Row } from 'ant-design-vue';
 
import { getTraceConsumerScanSummary } from '#/api/mes/trace-consumer-scan';
 
import { defaultSummary } from '../data';
 
defineOptions({ name: 'MesTraceConsumerScanSummaryCards' });
 
const props = defineProps<{
  startTime?: string;
  endTime?: string;
}>();
 
const summary = ref<MesTraceConsumerScanApi.Summary>(defaultSummary);
 
/** 加载汇总数据 */
async function loadData() {
  summary.value = await getTraceConsumerScanSummary(
    props.startTime,
    props.endTime,
  );
}
 
watch(
  () => [props.startTime, props.endTime],
  () => {
    loadData();
  },
  { immediate: true },
);
</script>
 
<template>
  <Row :gutter="16">
    <Col :lg="6" :md="12" :sm="12" :xl="6" :xs="24" class="mb-4">
      <Card class="kpi-card">
        <div class="flex items-center gap-4">
          <div
            class="flex size-14 flex-shrink-0 items-center justify-center rounded-xl text-white"
            style="background: linear-gradient(135deg, #409eff, #66b1ff)"
          >
            <IconifyIcon class="size-7" icon="lucide:scan-line" />
          </div>
          <div>
            <div class="text-muted-foreground mb-1 text-sm">总访问次数</div>
            <CountTo
              class="text-2xl font-bold leading-tight text-[#409eff]"
              :end-val="summary.total"
              :duration="1500"
            />
            <div class="text-muted-foreground mt-1 text-xs">全部扫码查询</div>
          </div>
        </div>
      </Card>
    </Col>
    <Col :lg="6" :md="12" :sm="12" :xl="6" :xs="24" class="mb-4">
      <Card class="kpi-card">
        <div class="flex items-center gap-4">
          <div
            class="flex size-14 flex-shrink-0 items-center justify-center rounded-xl text-white"
            style="background: linear-gradient(135deg, #67c23a, #85ce61)"
          >
            <IconifyIcon class="size-7" icon="lucide:circle-check" />
          </div>
          <div>
            <div class="text-muted-foreground mb-1 text-sm">成功查询</div>
            <CountTo
              class="text-2xl font-bold leading-tight text-[#67c23a]"
              :end-val="summary.success"
              :duration="1500"
            />
            <div class="text-muted-foreground mt-1 text-xs">
              溯源信息成功返回
            </div>
          </div>
        </div>
      </Card>
    </Col>
    <Col :lg="6" :md="12" :sm="12" :xl="6" :xs="24" class="mb-4">
      <Card class="kpi-card">
        <div class="flex items-center gap-4">
          <div
            class="flex size-14 flex-shrink-0 items-center justify-center rounded-xl text-white"
            style="background: linear-gradient(135deg, #f56c6c, #f78989)"
          >
            <IconifyIcon class="size-7" icon="lucide:circle-x" />
          </div>
          <div>
            <div class="text-muted-foreground mb-1 text-sm">失败查询</div>
            <CountTo
              class="text-2xl font-bold leading-tight text-[#f56c6c]"
              :end-val="summary.failed"
              :duration="1500"
            />
            <div class="text-muted-foreground mt-1 text-xs">码不存在或无效</div>
          </div>
        </div>
      </Card>
    </Col>
    <Col :lg="6" :md="12" :sm="12" :xl="6" :xs="24" class="mb-4">
      <Card class="kpi-card">
        <div class="flex items-center gap-4">
          <div
            class="flex size-14 flex-shrink-0 items-center justify-center rounded-xl text-white"
            style="background: linear-gradient(135deg, #7c3aed, #9461f5)"
          >
            <IconifyIcon class="size-7" icon="lucide:layers" />
          </div>
          <div>
            <div class="text-muted-foreground mb-1 text-sm">涉及批次</div>
            <CountTo
              class="text-2xl font-bold leading-tight text-[#7c3aed]"
              :end-val="summary.uniqueBatchCount"
              :duration="1500"
            />
            <div class="text-muted-foreground mt-1 text-xs">去重生产批次</div>
          </div>
        </div>
      </Card>
    </Col>
  </Row>
</template>