Explorar o código

refactor(portraitManagement): 统一精简运行数据组件代码

1. 移除三个页面中冗余的静态模拟数据和旧组件导入
2. 为deptProfile和teamProfile组件新增动态数据拉取逻辑
3. 统一组件结构,适配查询参数变化自动更新数据
huoyi hai 3 semanas
pai
achega
7a3c65c088

+ 50 - 54
src/views/portraitManagement/deptProfile/component/runData.vue

@@ -1,33 +1,6 @@
1 1
 <template>
2 2
   <div class="operation-data">
3 3
     <div class="row">
4
-      <ProfilePassRate
5
-        :chartData1="passRatePassData"
6
-        :chartData2="passRateLineData"
7
-      />
8
-    </div>
9
-
10
-    <div class="row">
11
-      <ProfileSeizedInfo :chartData1="seizedTotal" />
12
-      <ProfileSeizedDistribution :chartData1="seizedDistributionData" />
13
-    </div>
14
-
15
-    <div class="row">
16
-      <ProfileDailySeizedLine :chartData1="dailyLineData" />
17
-      <ProfileDailySeizedArea
18
-        :chartData1="dailyAreaPersonA"
19
-        :chartData2="dailyAreaPersonB"
20
-        :chartData3="dailyAreaPersonC"
21
-        :chartData4="dailyAreaPersonD"
22
-        :chartData5="dailyAreaPersonE"
23
-      />
24
-    </div>
25
-
26
-    <div class="row">
27
-      <ProfileDailySeizedBar :chartData1="dailyBarData" />
28
-    </div>
29
-
30
-    <div class="row">
31 4
       <ChannelCheckChart :chartsData="chartsData" />
32 5
     </div>
33 6
     <div class="row">
@@ -73,16 +46,17 @@
73 46
     </div>
74 47
     <div class="row">
75 48
       <div class="col">
76
-        <SupervisionDistribution :chartsData="chartsData"/>
49
+        <SupervisionDistribution :chartsData="supervisionData"/>
77 50
       </div>
78 51
       <div class="col">
79
-        <InterceptionDistribution :chartsData="chartsData" />
52
+        <InterceptionDistribution :chartsData="interceptionData" />
80 53
       </div>
81 54
     </div>
82 55
   </div>
83 56
 </template>
84 57
 
85 58
 <script setup>
59
+import { watch } from 'vue'
86 60
 import ChannelCheckChart from '../../components/ChannelCheckChart.vue';
87 61
 import SeizedInfo from '../../components/SeizedInfo.vue';
88 62
 import SeizedItems from '../../components/SeizedItems.vue';
@@ -97,32 +71,14 @@ import TestResult from '../../components/TestResult.vue';
97 71
 import TestArea from '../../components/TestArea.vue';
98 72
 import SupervisionDistribution from '../../components/SupervisionDistribution.vue';
99 73
 import InterceptionDistribution from '../../components/InterceptionDistribution.vue';
100
-import ProfilePassRate from '../../components/ProfilePassRate.vue';
101
-import ProfileSeizedInfo from '../../components/ProfileSeizedInfo.vue';
102
-import ProfileSeizedDistribution from '../../components/ProfileSeizedDistribution.vue';
103
-import ProfileDailySeizedLine from '../../components/ProfileDailySeizedLine.vue';
104
-import ProfileDailySeizedArea from '../../components/ProfileDailySeizedArea.vue';
105
-import ProfileDailySeizedBar from '../../components/ProfileDailySeizedBar.vue';
106
-
107
-
108
-const passRatePassData = ref([370, 352, 330, 387, 426, 342, 325, 384, 445, 407, 382, 401, 380, 464, 342, 443, 305, 394, 334, 430, 364, 362, 400, 420])
109
-const passRateLineData = ref([4.5, 5, 4, 6, 7, 5, 4, 6, 8, 7, 6, 7, 6, 8, 5, 7, 4, 6, 5, 7, 6, 6, 6.5, 7])
110
-
111
-const seizedTotal = ref(1658)
74
+import { realtimeInterceptionItem, supervisionProblemPosition } from '@/api/portraitManagement/portraitManagement';
112 75
 
113
-const seizedDistributionData = ref([
114
-  { value: 20, name: '打火机', itemStyle: { color: '#ff9f43' } },
115
-  { value: 30, name: '管制刀具', itemStyle: { color: '#ff6b6b' } },
116
-  { value: 50, name: '其他违禁品', itemStyle: { color: '#4da6ff' } }
117
-])
118
-
119
-const dailyLineData = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
120
-const dailyAreaPersonA = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
121
-const dailyAreaPersonB = ref([220, 182, 191, 234, 290, 330, 310, 123, 144, 210, 182, 191])
122
-const dailyAreaPersonC = ref([150, 232, 201, 154, 190, 330, 410, 201, 154, 190, 330, 410])
123
-const dailyAreaPersonD = ref([320, 332, 301, 334, 390, 330, 320, 332, 301, 334, 390, 330])
124
-const dailyAreaPersonE = ref([820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290])
125
-const dailyBarData = ref([120, 200, 150, 80, 70, 110, 130, 90, 160, 140, 180])
76
+const props = defineProps({
77
+  queryParams: {
78
+    type: Object,
79
+    default: () => ({})
80
+  }
81
+})
126 82
 
127 83
 const chartsData = ref([
128 84
   {
@@ -171,6 +127,46 @@ const chartsData = ref([
171 127
     name: '烟火'
172 128
   },
173 129
 ])
130
+
131
+const supervisionData = ref([])
132
+const interceptionData = ref([])
133
+
134
+const fetchSupervisionData = async () => {
135
+  try {
136
+    const res = await supervisionProblemPosition(props.queryParams)
137
+    if (res.code === 200 && res.data) {
138
+      supervisionData.value = res.data.map(item => ({
139
+        num: item.total,
140
+        name: item.name
141
+      }))
142
+    }
143
+  } catch (error) {
144
+    console.error('获取各岗位监察问题分布数据失败', error)
145
+  }
146
+}
147
+
148
+const fetchInterceptionData = async () => {
149
+  try {
150
+    const res = await realtimeInterceptionItem(props.queryParams)
151
+    if (res.code === 200 && res.data) {
152
+      interceptionData.value = res.data.map(item => ({
153
+        num: item.total,
154
+        name: item.name
155
+      }))
156
+    }
157
+  } catch (error) {
158
+    console.error('获取实时质控拦截物品分布数据失败', error)
159
+  }
160
+}
161
+
162
+const fetchData = () => {
163
+  fetchSupervisionData()
164
+  fetchInterceptionData()
165
+}
166
+
167
+watch(() => props.queryParams, () => {
168
+  fetchData()
169
+}, { deep: true, immediate: true })
174 170
   
175 171
 
176 172
 </script>

+ 0 - 52
src/views/portraitManagement/groupProfile/component/runData.vue

@@ -1,33 +1,6 @@
1 1
 <template>
2 2
   <div class="operation-data">
3 3
     <div class="row">
4
-      <ProfilePassRate
5
-        :chartData1="passRatePassData"
6
-        :chartData2="passRateLineData"
7
-      />
8
-    </div>
9
-
10
-    <div class="row">
11
-      <ProfileSeizedInfo :chartData1="seizedTotal" />
12
-      <ProfileSeizedDistribution :chartData1="seizedDistributionData" />
13
-    </div>
14
-
15
-    <div class="row">
16
-      <ProfileDailySeizedLine :chartData1="dailyLineData" />
17
-      <ProfileDailySeizedArea
18
-        :chartData1="dailyAreaPersonA"
19
-        :chartData2="dailyAreaPersonB"
20
-        :chartData3="dailyAreaPersonC"
21
-        :chartData4="dailyAreaPersonD"
22
-        :chartData5="dailyAreaPersonE"
23
-      />
24
-    </div>
25
-
26
-    <div class="row">
27
-      <ProfileDailySeizedBar :chartData1="dailyBarData" />
28
-    </div>
29
-
30
-    <div class="row">
31 4
       <ChannelCheckChart :chartsData="chartsData" />
32 5
     </div>
33 6
     <div class="row">
@@ -98,12 +71,6 @@ import TestResult from '../../components/TestResult.vue';
98 71
 import TestArea from '../../components/TestArea.vue';
99 72
 import SupervisionDistribution from '../../components/SupervisionDistribution.vue';
100 73
 import InterceptionDistribution from '../../components/InterceptionDistribution.vue';
101
-import ProfilePassRate from '../../components/ProfilePassRate.vue';
102
-import ProfileSeizedInfo from '../../components/ProfileSeizedInfo.vue';
103
-import ProfileSeizedDistribution from '../../components/ProfileSeizedDistribution.vue';
104
-import ProfileDailySeizedLine from '../../components/ProfileDailySeizedLine.vue';
105
-import ProfileDailySeizedArea from '../../components/ProfileDailySeizedArea.vue';
106
-import ProfileDailySeizedBar from '../../components/ProfileDailySeizedBar.vue';
107 74
 import { realtimeInterceptionItem, supervisionProblemPosition } from '@/api/portraitManagement/portraitManagement';
108 75
 
109 76
 const props = defineProps({
@@ -113,25 +80,6 @@ const props = defineProps({
113 80
   }
114 81
 })
115 82
 
116
-const passRatePassData = ref([370, 352, 330, 387, 426, 342, 325, 384, 445, 407, 382, 401, 380, 464, 342, 443, 305, 394, 334, 430, 364, 362, 400, 420])
117
-const passRateLineData = ref([4.5, 5, 4, 6, 7, 5, 4, 6, 8, 7, 6, 7, 6, 8, 5, 7, 4, 6, 5, 7, 6, 6, 6.5, 7])
118
-
119
-const seizedTotal = ref(1658)
120
-
121
-const seizedDistributionData = ref([
122
-  { value: 20, name: '打火机', itemStyle: { color: '#ff9f43' } },
123
-  { value: 30, name: '管制刀具', itemStyle: { color: '#ff6b6b' } },
124
-  { value: 50, name: '其他违禁品', itemStyle: { color: '#4da6ff' } }
125
-])
126
-
127
-const dailyLineData = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
128
-const dailyAreaPersonA = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
129
-const dailyAreaPersonB = ref([220, 182, 191, 234, 290, 330, 310, 123, 144, 210, 182, 191])
130
-const dailyAreaPersonC = ref([150, 232, 201, 154, 190, 330, 410, 201, 154, 190, 330, 410])
131
-const dailyAreaPersonD = ref([320, 332, 301, 334, 390, 330, 320, 332, 301, 334, 390, 330])
132
-const dailyAreaPersonE = ref([820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290])
133
-const dailyBarData = ref([120, 200, 150, 80, 70, 110, 130, 90, 160, 140, 180])
134
-
135 83
 const chartsData = ref([
136 84
   {
137 85
     num: 370,

+ 50 - 54
src/views/portraitManagement/teamProfile/component/runData.vue

@@ -1,33 +1,6 @@
1 1
 <template>
2 2
   <div class="operation-data">
3 3
     <div class="row">
4
-      <ProfilePassRate
5
-        :chartData1="passRatePassData"
6
-        :chartData2="passRateLineData"
7
-      />
8
-    </div>
9
-
10
-    <div class="row">
11
-      <ProfileSeizedInfo :chartData1="seizedTotal" />
12
-      <ProfileSeizedDistribution :chartData1="seizedDistributionData" />
13
-    </div>
14
-
15
-    <div class="row">
16
-      <ProfileDailySeizedLine :chartData1="dailyLineData" />
17
-      <ProfileDailySeizedArea
18
-        :chartData1="dailyAreaPersonA"
19
-        :chartData2="dailyAreaPersonB"
20
-        :chartData3="dailyAreaPersonC"
21
-        :chartData4="dailyAreaPersonD"
22
-        :chartData5="dailyAreaPersonE"
23
-      />
24
-    </div>
25
-
26
-    <div class="row">
27
-      <ProfileDailySeizedBar :chartData1="dailyBarData" />
28
-    </div>
29
-
30
-    <div class="row">
31 4
       <ChannelCheckChart :chartsData="chartsData" />
32 5
     </div>
33 6
     <div class="row">
@@ -73,16 +46,17 @@
73 46
     </div>
74 47
     <div class="row">
75 48
       <div class="col">
76
-        <SupervisionDistribution :chartsData="chartsData"/>
49
+        <SupervisionDistribution :chartsData="supervisionData"/>
77 50
       </div>
78 51
       <div class="col">
79
-        <InterceptionDistribution :chartsData="chartsData" />
52
+        <InterceptionDistribution :chartsData="interceptionData" />
80 53
       </div>
81 54
     </div>
82 55
   </div>
83 56
 </template>
84 57
 
85 58
 <script setup>
59
+import { watch } from 'vue'
86 60
 import ChannelCheckChart from '../../components/ChannelCheckChart.vue';
87 61
 import SeizedInfo from '../../components/SeizedInfo.vue';
88 62
 import SeizedItems from '../../components/SeizedItems.vue';
@@ -97,32 +71,14 @@ import TestResult from '../../components/TestResult.vue';
97 71
 import TestArea from '../../components/TestArea.vue';
98 72
 import SupervisionDistribution from '../../components/SupervisionDistribution.vue';
99 73
 import InterceptionDistribution from '../../components/InterceptionDistribution.vue';
100
-import ProfilePassRate from '../../components/ProfilePassRate.vue';
101
-import ProfileSeizedInfo from '../../components/ProfileSeizedInfo.vue';
102
-import ProfileSeizedDistribution from '../../components/ProfileSeizedDistribution.vue';
103
-import ProfileDailySeizedLine from '../../components/ProfileDailySeizedLine.vue';
104
-import ProfileDailySeizedArea from '../../components/ProfileDailySeizedArea.vue';
105
-import ProfileDailySeizedBar from '../../components/ProfileDailySeizedBar.vue';
106
-
107
-
108
-const passRatePassData = ref([370, 352, 330, 387, 426, 342, 325, 384, 445, 407, 382, 401, 380, 464, 342, 443, 305, 394, 334, 430, 364, 362, 400, 420])
109
-const passRateLineData = ref([4.5, 5, 4, 6, 7, 5, 4, 6, 8, 7, 6, 7, 6, 8, 5, 7, 4, 6, 5, 7, 6, 6, 6.5, 7])
110
-
111
-const seizedTotal = ref(1658)
74
+import { realtimeInterceptionItem, supervisionProblemPosition } from '@/api/portraitManagement/portraitManagement';
112 75
 
113
-const seizedDistributionData = ref([
114
-  { value: 20, name: '打火机', itemStyle: { color: '#ff9f43' } },
115
-  { value: 30, name: '管制刀具', itemStyle: { color: '#ff6b6b' } },
116
-  { value: 50, name: '其他违禁品', itemStyle: { color: '#4da6ff' } }
117
-])
118
-
119
-const dailyLineData = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
120
-const dailyAreaPersonA = ref([120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330])
121
-const dailyAreaPersonB = ref([220, 182, 191, 234, 290, 330, 310, 123, 144, 210, 182, 191])
122
-const dailyAreaPersonC = ref([150, 232, 201, 154, 190, 330, 410, 201, 154, 190, 330, 410])
123
-const dailyAreaPersonD = ref([320, 332, 301, 334, 390, 330, 320, 332, 301, 334, 390, 330])
124
-const dailyAreaPersonE = ref([820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290])
125
-const dailyBarData = ref([120, 200, 150, 80, 70, 110, 130, 90, 160, 140, 180])
76
+const props = defineProps({
77
+  queryParams: {
78
+    type: Object,
79
+    default: () => ({})
80
+  }
81
+})
126 82
 
127 83
 const chartsData = ref([
128 84
   {
@@ -171,6 +127,46 @@ const chartsData = ref([
171 127
     name: '烟火'
172 128
   },
173 129
 ])
130
+
131
+const supervisionData = ref([])
132
+const interceptionData = ref([])
133
+
134
+const fetchSupervisionData = async () => {
135
+  try {
136
+    const res = await supervisionProblemPosition(props.queryParams)
137
+    if (res.code === 200 && res.data) {
138
+      supervisionData.value = res.data.map(item => ({
139
+        num: item.total,
140
+        name: item.name
141
+      }))
142
+    }
143
+  } catch (error) {
144
+    console.error('获取各岗位监察问题分布数据失败', error)
145
+  }
146
+}
147
+
148
+const fetchInterceptionData = async () => {
149
+  try {
150
+    const res = await realtimeInterceptionItem(props.queryParams)
151
+    if (res.code === 200 && res.data) {
152
+      interceptionData.value = res.data.map(item => ({
153
+        num: item.total,
154
+        name: item.name
155
+      }))
156
+    }
157
+  } catch (error) {
158
+    console.error('获取实时质控拦截物品分布数据失败', error)
159
+  }
160
+}
161
+
162
+const fetchData = () => {
163
+  fetchSupervisionData()
164
+  fetchInterceptionData()
165
+}
166
+
167
+watch(() => props.queryParams, () => {
168
+  fetchData()
169
+}, { deep: true, immediate: true })
174 170
   
175 171
 
176 172
 </script>