From 6fd79d3c1fe0006e208a32a002dd7606c04de224 Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Tue, 15 Aug 2023 17:55:50 +0800 Subject: [PATCH] echarts --- src/components/Progress.vue | 111 ++++++++++++++++++++++++++++++++++++++++---- src/mock/command.js | 5 ++ src/pages/Home.vue | 5 +- 3 files changed, 109 insertions(+), 12 deletions(-) diff --git a/src/components/Progress.vue b/src/components/Progress.vue index 8c4e78c..1f58ef2 100644 --- a/src/components/Progress.vue +++ b/src/components/Progress.vue @@ -16,12 +16,18 @@
+ 停止消毒 +
+
暂停消毒
继续消毒 @@ -31,15 +37,15 @@

设备温度/湿度/过氧化氢浓度

-
+

环境1/湿度/过氧化氢浓度

-
+

环境2/湿度/过氧化氢浓度

-
+
@@ -53,9 +59,80 @@ import { useOperatorStore, useWebSocketStore } from '@/store' import { stopDisinfectionJSON, getStateJSON, - getAllRecordsJSON, + pauseDisinfectionJSON, } from '@/mock/command' import { onMounted, onUnmounted, ref } from 'vue' +import * as echarts from 'echarts' + +const binOption = ref({ + legend: { + data: ['Email', 'Union Ads', 'Video Ads'], + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true, + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + }, + yAxis: { + type: 'value', + }, + series: [ + { + name: 'Email', + type: 'line', + stack: 'Total', + data: [120, 132, 101, 134, 90, 230, 210], + }, + { + name: 'Union Ads', + type: 'line', + stack: 'Total', + data: [220, 182, 191, 234, 290, 330, 310], + }, + { + name: 'Video Ads', + type: 'line', + stack: 'Total', + data: [150, 232, 201, 154, 190, 330, 410], + }, + ], +}) +const envir1Option = ref({ + xAxis: { + type: 'category', + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + }, + yAxis: { + type: 'value', + }, + series: [ + { + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + }, + ], +}) +const envir2Option = ref({ + xAxis: { + type: 'category', + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + }, + yAxis: { + type: 'value', + }, + series: [ + { + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + }, + ], +}) const operatorStore = useOperatorStore() const webSocketStore = useWebSocketStore() @@ -73,6 +150,12 @@ onMounted(() => { timer.value = setInterval(() => { webSocketStore.sendCommandMsg(getStateJSON) }, 1000) + var binCharts = echarts.init(document.getElementById('bin')) + binCharts.setOption(binOption.value) + var envir1Charts = echarts.init(document.getElementById('envir1')) + envir1Charts.setOption(envir1Option.value) + var envir2Charts = echarts.init(document.getElementById('envir2')) + envir2Charts.setOption(envir2Option.value) }) onUnmounted(() => { timer.value = null @@ -80,6 +163,13 @@ onUnmounted(() => { const pauseDisinfect = () => { if (operatorStore.disinfectStatus) { + webSocketStore.sendCommandMsg(pauseDisinfectionJSON) + operatorStore.updateDisinfectStatus(false) + } +} + +const stopDisinfect = () => { + if (operatorStore.disinfectStatus) { webSocketStore.sendCommandMsg(stopDisinfectionJSON) operatorStore.updateDisinfectStatus(false) } @@ -106,7 +196,8 @@ const continueDisinfect = () => { align-items: center; margin-bottom: 49px; .left_progress { - width: 860px; + // width: 860px; + flex: 1; height: 80px; border-radius: 14px; background: #f6f6f6; @@ -128,19 +219,19 @@ const continueDisinfect = () => { font-weight: normal; letter-spacing: 0.1em; color: #ffffff; - margin-right: 73px; } .time { - width: 90px; + // width: 90px; + flex: 1; height: 20px; font-family: Source Han Sans CN; font-size: 14px; font-weight: 500; letter-spacing: 0.1em; color: #000000; - margin-right: 85px; display: flex; align-items: center; + justify-content: center; } .progress_bg { width: 396px; @@ -184,7 +275,7 @@ const continueDisinfect = () => { background: #06518b; } .ml { - margin-left: 20px; + margin: 0 20px; } } } diff --git a/src/mock/command.js b/src/mock/command.js index ea920ac..deb93a2 100644 --- a/src/mock/command.js +++ b/src/mock/command.js @@ -47,6 +47,11 @@ export const stopDisinfectionJSON = { messageId: 'stopDisinfection', } +export const pauseDisinfectionJSON = { + command: 'pauseDisinfection', + messageId: 'pauseDisinfection', +} + // 获取当前设备的状态信息 export const getStateJSON = { command: 'getState', diff --git a/src/pages/Home.vue b/src/pages/Home.vue index e15148c..f21736a 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -120,7 +120,7 @@

设置

- + /> --> +