Showing
5 changed files
with
99 additions
and
26 deletions
src/assets/images/product.png
0 → 100644
3.99 KB
@@ -137,10 +137,14 @@ | @@ -137,10 +137,14 @@ | ||
137 | <div class="mr-4"> | 137 | <div class="mr-4"> |
138 | <img | 138 | <img |
139 | v-if="!isAdmin(role)" | 139 | v-if="!isAdmin(role)" |
140 | - src="/src/assets/images/msg-count.png" | 140 | + src="/src/assets/images/product.png" |
141 | + style="width: 5.625rem; height: 5.625rem" | ||
142 | + /> | ||
143 | + <img | ||
144 | + v-else | ||
145 | + src="/src/assets/images/product.png" | ||
141 | style="width: 5.625rem; height: 5.625rem" | 146 | style="width: 5.625rem; height: 5.625rem" |
142 | /> | 147 | /> |
143 | - <img v-else src="/src/assets/images/kf.png" style="width: 5.625rem; height: 5.625rem" /> | ||
144 | </div> | 148 | </div> |
145 | <div class="flex-auto"> | 149 | <div class="flex-auto"> |
146 | <div class="flex justify-between" style="align-items: center"> | 150 | <div class="flex justify-between" style="align-items: center"> |
1 | <template> | 1 | <template> |
2 | - <div ref="chartRef" :style="{ height, width }"></div> | 2 | + <div v-show="dataSeries.length" ref="chartRef" :style="{ height, width }"></div> |
3 | + <div v-show="!dataSeries.length"><Empty :image="Empty.PRESENTED_IMAGE_SIMPLE" /></div> | ||
3 | </template> | 4 | </template> |
4 | <script lang="ts"> | 5 | <script lang="ts"> |
5 | import { defineComponent, PropType, ref, Ref, onMounted, toRefs } from 'vue'; | 6 | import { defineComponent, PropType, ref, Ref, onMounted, toRefs } from 'vue'; |
6 | import { useECharts } from '/@/hooks/web/useECharts'; | 7 | import { useECharts } from '/@/hooks/web/useECharts'; |
8 | + import { Empty } from 'ant-design-vue'; | ||
7 | 9 | ||
8 | export default defineComponent({ | 10 | export default defineComponent({ |
11 | + components: { Empty }, | ||
9 | props: { | 12 | props: { |
10 | width: { | 13 | width: { |
11 | type: String as PropType<string>, | 14 | type: String as PropType<string>, |
@@ -65,7 +68,7 @@ | @@ -65,7 +68,7 @@ | ||
65 | //自适应 | 68 | //自适应 |
66 | window.addEventListener('resize', () => resize()); | 69 | window.addEventListener('resize', () => resize()); |
67 | }); | 70 | }); |
68 | - return { chartRef }; | 71 | + return { chartRef, Empty, dataSeries }; |
69 | }, | 72 | }, |
70 | }); | 73 | }); |
71 | </script> | 74 | </script> |
@@ -23,15 +23,14 @@ | @@ -23,15 +23,14 @@ | ||
23 | /> | 23 | /> |
24 | </div> | 24 | </div> |
25 | </template> | 25 | </template> |
26 | - <div v-if="activeKey === '1'"> | ||
27 | - <!-- 折线图 --> | 26 | + <!-- <div v-if="activeKey === '1'"> |
28 | <CustomerAlarmMessage | 27 | <CustomerAlarmMessage |
29 | v-if="role === 'CUSTOMER_USER'" | 28 | v-if="role === 'CUSTOMER_USER'" |
30 | type="CUSTOMER_ALARM_STATISTICAL" | 29 | type="CUSTOMER_ALARM_STATISTICAL" |
31 | :customerList="customerAlarmList" | 30 | :customerList="customerAlarmList" |
32 | /> | 31 | /> |
33 | <VisitAnalysis v-else :alarmList="state.alarmList" /> | 32 | <VisitAnalysis v-else :alarmList="state.alarmList" /> |
34 | - </div> | 33 | + </div> --> |
35 | <div v-if="activeKey === '2'"> | 34 | <div v-if="activeKey === '2'"> |
36 | <!-- 柱形图 --> | 35 | <!-- 柱形图 --> |
37 | <CustomerAlarmMessage | 36 | <CustomerAlarmMessage |
@@ -100,7 +99,7 @@ | @@ -100,7 +99,7 @@ | ||
100 | <script lang="ts" setup> | 99 | <script lang="ts" setup> |
101 | import { ref, reactive } from 'vue'; | 100 | import { ref, reactive } from 'vue'; |
102 | import { Card, DatePicker } from 'ant-design-vue'; | 101 | import { Card, DatePicker } from 'ant-design-vue'; |
103 | - import VisitAnalysis from './VisitAnalysis.vue'; | 102 | + // import VisitAnalysis from './VisitAnalysis.vue'; |
104 | import VisitAnalysisBar from './VisitAnalysisBar.vue'; | 103 | import VisitAnalysisBar from './VisitAnalysisBar.vue'; |
105 | import { isAdmin } from '/@/enums/roleEnum'; | 104 | import { isAdmin } from '/@/enums/roleEnum'; |
106 | import { useWebSocket } from '@vueuse/core'; | 105 | import { useWebSocket } from '@vueuse/core'; |
@@ -197,7 +196,11 @@ | @@ -197,7 +196,11 @@ | ||
197 | latestValues: [ | 196 | latestValues: [ |
198 | { | 197 | { |
199 | type: 'TIME_SERIES', | 198 | type: 'TIME_SERIES', |
200 | - key: 'createdAlarmsCountHourly', | 199 | + key: 'transportMsgCountHourly', |
200 | + }, | ||
201 | + { | ||
202 | + type: 'TIME_SERIES', | ||
203 | + key: 'transportDataPointsCountHourly', | ||
201 | }, | 204 | }, |
202 | ], | 205 | ], |
203 | }, | 206 | }, |
@@ -210,7 +213,7 @@ | @@ -210,7 +213,7 @@ | ||
210 | { | 213 | { |
211 | cmdId: activeKey.value, | 214 | cmdId: activeKey.value, |
212 | historyCmd: { | 215 | historyCmd: { |
213 | - keys: ['createdAlarmsCountHourly'], | 216 | + keys: ['transportMsgCountHourly', 'transportDataPointsCountHourly'], |
214 | startTs: Date.now() - 2592000000, | 217 | startTs: Date.now() - 2592000000, |
215 | endTs: Date.now(), | 218 | endTs: Date.now(), |
216 | interval: 86400000, | 219 | interval: 86400000, |
@@ -240,21 +243,26 @@ | @@ -240,21 +243,26 @@ | ||
240 | } | 243 | } |
241 | } else { | 244 | } else { |
242 | if (data) { | 245 | if (data) { |
243 | - const { transportDataPointsCountHourly, transportMsgCountHourly } = | ||
244 | - data.data[0].latest.TIME_SERIES; | ||
245 | - state.dataPoint = [ | ||
246 | - transportDataPointsCountHourly.ts, | ||
247 | - transportDataPointsCountHourly.value, | ||
248 | - ]; | ||
249 | - state.MsgCount = [ | ||
250 | - transportDataPointsCountHourly.ts, | ||
251 | - transportDataPointsCountHourly.value, | ||
252 | - ]; | ||
253 | - state.dataPointList.push([ | ||
254 | - transportDataPointsCountHourly.ts, | ||
255 | - transportDataPointsCountHourly.value, | ||
256 | - ]); | ||
257 | - state.messageList.push([transportMsgCountHourly.ts, transportMsgCountHourly.value]); | 246 | + console.log('消息数', data); |
247 | + if (data) { | ||
248 | + const { transportDataPointsCountHourly, transportMsgCountHourly } = | ||
249 | + data.data[0].latest.TIME_SERIES; | ||
250 | + state.dataPoint = [ | ||
251 | + transportDataPointsCountHourly?.ts, | ||
252 | + transportDataPointsCountHourly?.value, | ||
253 | + ]; | ||
254 | + state.MsgCount = [ | ||
255 | + transportDataPointsCountHourly?.ts, | ||
256 | + transportDataPointsCountHourly?.value, | ||
257 | + ]; | ||
258 | + state.dataPointList.push([ | ||
259 | + transportDataPointsCountHourly?.ts, | ||
260 | + transportDataPointsCountHourly?.value, | ||
261 | + ]); | ||
262 | + console.log('state.dataPointList', state.dataPointList); | ||
263 | + state.messageList.push([transportMsgCountHourly?.ts, transportMsgCountHourly?.value]); | ||
264 | + console.log('state.messageList', state.messageList); | ||
265 | + } | ||
258 | } | 266 | } |
259 | if (update) { | 267 | if (update) { |
260 | const { transportDataPointsCountHourly, transportMsgCountHourly } = update[0].timeseries; | 268 | const { transportDataPointsCountHourly, transportMsgCountHourly } = update[0].timeseries; |
@@ -268,6 +276,8 @@ | @@ -268,6 +276,8 @@ | ||
268 | } | 276 | } |
269 | state.dataPointList = newArray; | 277 | state.dataPointList = newArray; |
270 | state.messageList = newArray1; | 278 | state.messageList = newArray1; |
279 | + console.log('newArray', state.dataPointList); | ||
280 | + console.log('newArray1', state.messageList); | ||
271 | } | 281 | } |
272 | } | 282 | } |
273 | }, | 283 | }, |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | </div> | 5 | </div> |
6 | </template> | 6 | </template> |
7 | <script lang="ts" setup> | 7 | <script lang="ts" setup> |
8 | - import { ref, Ref, watch, withDefaults } from 'vue'; | 8 | + import { ref, Ref, watch, withDefaults, onMounted } from 'vue'; |
9 | import { useECharts } from '/@/hooks/web/useECharts'; | 9 | import { useECharts } from '/@/hooks/web/useECharts'; |
10 | import { Empty } from 'ant-design-vue'; | 10 | import { Empty } from 'ant-design-vue'; |
11 | type DataItem = [number, string]; | 11 | type DataItem = [number, string]; |
@@ -23,6 +23,62 @@ | @@ -23,6 +23,62 @@ | ||
23 | }); | 23 | }); |
24 | const chartRef = ref<HTMLDivElement | null>(null); | 24 | const chartRef = ref<HTMLDivElement | null>(null); |
25 | const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); | 25 | const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); |
26 | + onMounted(() => { | ||
27 | + // 计算总量 | ||
28 | + let dataPointTotal = 0; | ||
29 | + let messageTotal = 0; | ||
30 | + for (const item of props.dataPointList) { | ||
31 | + dataPointTotal += Number(item[1]); | ||
32 | + } | ||
33 | + for (const item of props.messageList) { | ||
34 | + messageTotal += Number(item[1]); | ||
35 | + } | ||
36 | + setOptions({ | ||
37 | + tooltip: { | ||
38 | + trigger: 'axis', | ||
39 | + axisPointer: { | ||
40 | + type: 'shadow', | ||
41 | + }, | ||
42 | + }, | ||
43 | + xAxis: { | ||
44 | + type: 'time', | ||
45 | + }, | ||
46 | + legend: { | ||
47 | + data: ['传输数据点', '传输消息量'], | ||
48 | + left: 'center', | ||
49 | + formatter: (name) => { | ||
50 | + return name === '传输数据点' ? `${name} ${dataPointTotal}` : `${name} ${messageTotal}`; | ||
51 | + }, | ||
52 | + }, | ||
53 | + | ||
54 | + yAxis: {}, | ||
55 | + grid: { | ||
56 | + left: '3%', | ||
57 | + right: '4%', | ||
58 | + bottom: '3%', | ||
59 | + containLabel: true, | ||
60 | + }, | ||
61 | + series: [ | ||
62 | + { | ||
63 | + name: '传输数据点', | ||
64 | + type: 'line', | ||
65 | + stack: 'total', | ||
66 | + data: props.dataPointList, | ||
67 | + // barWidth: '10%', | ||
68 | + color: '#5AEEED', | ||
69 | + }, | ||
70 | + { | ||
71 | + name: '传输消息量', | ||
72 | + type: 'line', | ||
73 | + stack: 'total', | ||
74 | + // barWidth: '10%', | ||
75 | + data: props.messageList, | ||
76 | + color: '#3C78FF', | ||
77 | + }, | ||
78 | + ], | ||
79 | + }); | ||
80 | + }); | ||
81 | + | ||
26 | watch( | 82 | watch( |
27 | () => [props.dataPointList, props.messageList], | 83 | () => [props.dataPointList, props.messageList], |
28 | ([newValue, newValue1]) => { | 84 | ([newValue, newValue1]) => { |