6 天以前 533353dbeb19b3fa45817e9f65874db4e2ce6f9e
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
<template>
  <HomePanel title="质量统计" :loading="loading">
    <template #extra>
      <el-radio-group v-model="range" size="small" @change="refresh">
        <el-radio-button :value="1">周</el-radio-button>
        <el-radio-button :value="2">月</el-radio-button>
        <el-radio-button :value="3">季度</el-radio-button>
      </el-radio-group>
    </template>
 
    <div class="quality__cards">
      <div class="quality__mini">
        <span class="quality__mini-label">原材料已检测</span>
        <span class="quality__mini-value app-num">{{ total.supplierNum }}<i>件</i></span>
      </div>
      <div class="quality__mini">
        <span class="quality__mini-label">过程检验</span>
        <span class="quality__mini-value app-num">{{ total.processNum }}<i>件</i></span>
      </div>
      <div class="quality__mini">
        <span class="quality__mini-label">出厂已检</span>
        <span class="quality__mini-value app-num">{{ total.factoryNum }}<i>件</i></span>
      </div>
    </div>
 
    <Echarts
      :chartStyle="{ width: '100%', height: '230px' }"
      :grid="grid"
      :legend="legend"
      :series="series"
      :tooltip="tooltip"
      :xAxis="xAxis"
      :yAxis="yAxis"
      style="height: 230px"
    />
  </HomePanel>
</template>
 
<script setup>
import { ref, reactive, onMounted } from 'vue'
import Echarts from '@/components/Echarts/echarts.vue'
import HomePanel from '../HomePanel.vue'
import { qualityInspectionStatistics } from '@/api/viewIndex'
 
const loading = ref(true)
const range = ref(1)
const total = reactive({ supplierNum: 0, processNum: 0, factoryNum: 0 })
 
const legend = { show: true, top: 0, right: 0, itemWidth: 10, itemHeight: 10, data: ['原材料不合格数', '过程不合格数', '出厂不合格数'] }
const grid = { left: '3%', right: '4%', bottom: '3%', top: 34, containLabel: true }
const tooltip = { trigger: 'axis', axisPointer: { type: 'shadow' } }
const xAxis = ref([{ type: 'category', axisTick: { show: false }, data: [] }])
const yAxis = [{ type: 'value' }]
 
const series = ref([
  { name: '原材料不合格数', type: 'bar', barGap: 0, barWidth: 10, itemStyle: { color: '#2C51D9', borderRadius: [3, 3, 0, 0] }, emphasis: { focus: 'series' }, data: [] },
  { name: '过程不合格数', type: 'bar', barWidth: 10, itemStyle: { color: '#D97706', borderRadius: [3, 3, 0, 0] }, emphasis: { focus: 'series' }, data: [] },
  { name: '出厂不合格数', type: 'bar', barWidth: 10, itemStyle: { color: '#0F9960', borderRadius: [3, 3, 0, 0] }, emphasis: { focus: 'series' }, data: [] }
])
 
const refresh = () => {
  return qualityInspectionStatistics({ type: range.value }).then((res) => {
    const d = res.data || {}
    xAxis.value[0].data = []
    series.value.forEach((s) => { s.data = [] })
    ;(d.item || []).forEach((item) => {
      xAxis.value[0].data.push(item.date)
      series.value[0].data.push(item.supplierNum)
      series.value[1].data.push(item.processNum)
      series.value[2].data.push(item.factoryNum)
    })
    total.supplierNum = d.supplierNum || 0
    total.processNum = d.processNum || 0
    total.factoryNum = d.factoryNum || 0
  })
}
 
onMounted(() => {
  Promise.all([refresh()]).finally(() => { loading.value = false })
})
</script>
 
<style scoped>
.quality__cards {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
 
.quality__mini {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--app-radius-sm);
  background: var(--app-surface-hover);
}
 
.quality__mini-label {
  font-size: 12px;
  color: var(--app-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.quality__mini-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--app-text);
}
 
.quality__mini-value i {
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
  color: var(--app-text-tertiary);
  margin-left: 3px;
}
</style>