diff --git a/src/components/Operator.vue b/src/components/Operator.vue
index 21bf783..bf4a4ff 100644
--- a/src/components/Operator.vue
+++ b/src/components/Operator.vue
@@ -19,7 +19,10 @@
警报信息
开始消毒
@@ -107,7 +114,7 @@ const props = defineProps({
const toDetail = () => {
// 判断当前消毒任务是否开始,如果开始时才生效 否则点击不生效
- if (operatorStore.disinfectStatus) {
+ if (operatorStore.disinfectStatus != 0) {
props.changeShowOperator(false)
}
}
@@ -127,22 +134,24 @@ const changeLogVal = val => {
const startDisinfect = () => {
// 改变开始消毒状态 如果已经开始则不可点击
- if (!operatorStore.disinfectStatus) {
+ if (![1, 2].includes(operatorStore.disinfectStatus)) {
if (roomSize.value == 0) {
showFailToast('请调整房间大小设置,不能为0')
} else {
+ localStorage.removeItem('bin')
+ localStorage.removeItem('envir1')
+ localStorage.removeItem('envir2')
localStorage.clear()
webSocketStore.sendCommandMsg(
startDisinfectionJSON(logVal.value, roomSize.value),
)
- operatorStore.updateDisinfectStatus(true)
props.changeShowOperator(false)
}
}
}
const showLogPicker = () => {
- if (!operatorStore.disinfectStatus) {
+ if (![1, 2].includes(operatorStore.disinfectStatus)) {
logVisible.value = true
}
}
diff --git a/src/components/Progress.vue b/src/components/Progress.vue
index e56ff09..4a8ff0d 100644
--- a/src/components/Progress.vue
+++ b/src/components/Progress.vue
@@ -21,19 +21,25 @@
@@ -80,41 +86,28 @@ import {
continueDisinfectionJSON,
pauseDisinfectionJSON,
} from '@/mock/command'
-import { onMounted, onUnmounted, ref, computed } from 'vue'
+import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
import * as echarts from 'echarts'
import { storeToRefs } from 'pinia'
const echartsStore = useEchartsStore()
const binLocal = computed(() => {
- return localStorage.getItem('bin')
+ return echartsStore?.binCharts || localStorage.getItem('bin')
})
const envir1Local = computed(() => {
- return localStorage.getItem('envir1')
+ return echartsStore?.envir1Charts || localStorage.getItem('envir1')
})
const envir2Local = computed(() => {
- return localStorage.getItem('envir2')
+ return echartsStore?.envir2Charts || localStorage.getItem('envir2')
})
const binOption = ref({
tooltip: {
trigger: 'axis',
},
- dataZoom: {
- show: true, // 为true 滚动条出现
- realtime: true,
- type: 'slider', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。
- height: 10, // 表示滚动条的高度,也就是粗细
- start: 40, // 表示默认展示0%~80%这一段。
- end: 100,
- backgroundColor: 'transparent',
- bottom: 10,
- textStyle: {
- color: 'transparent',
- },
- },
legend: {
data: ['温度', '湿度', '过氧化氢浓度'],
},
@@ -157,19 +150,6 @@ const envir1Option = ref({
tooltip: {
trigger: 'axis',
},
- dataZoom: {
- show: true, // 为true 滚动条出现
- realtime: true,
- type: 'slider', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。
- height: 10, // 表示滚动条的高度,也就是粗细
- start: 40, // 表示默认展示0%~80%这一段。
- end: 100,
- backgroundColor: 'transparent',
- bottom: 10,
- textStyle: {
- color: 'transparent',
- },
- },
legend: {
data: ['温度', '湿度', '过氧化氢浓度'],
},
@@ -212,19 +192,6 @@ const envir2Option = ref({
tooltip: {
trigger: 'axis',
},
- dataZoom: {
- show: true, // 为true 滚动条出现
- realtime: true,
- type: 'slider', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。
- height: 10, // 表示滚动条的高度,也就是粗细
- start: 40, // 表示默认展示0%~80%这一段。
- end: 100,
- backgroundColor: 'transparent',
- bottom: 10,
- textStyle: {
- color: 'transparent',
- },
- },
legend: {
data: ['温度', '湿度', '过氧化氢浓度'],
},
@@ -276,48 +243,180 @@ const showDetail = () => {
}
const timer = ref(null)
+
+const binCharts = ref(null)
+const envir1Charts = ref(null)
+const envir2Charts = ref(null)
onMounted(() => {
timer.value = setInterval(() => {
webSocketStore.sendCommandMsg(getStateJSON)
}, 1000)
let a = echarts.getInstanceByDom(document.getElementById('bin'))
if (a == undefined) {
- var binCharts = echarts.init(document.getElementById('bin'))
- binCharts.setOption(binOption.value)
+ binCharts.value = echarts.init(document.getElementById('bin'))
+ binCharts.value.setOption(binOption.value)
}
let b = echarts.getInstanceByDom(document.getElementById('envir1'))
if (b == undefined) {
- var envir1Charts = echarts.init(document.getElementById('envir1'))
- envir1Charts.setOption(envir1Option.value)
+ envir1Charts.value = echarts.init(document.getElementById('envir1'))
+ envir1Charts.value.setOption(envir1Option.value)
}
let c = echarts.getInstanceByDom(document.getElementById('envir2'))
if (c == undefined) {
- var envir2Charts = echarts.init(document.getElementById('envir2'))
- envir2Charts.setOption(envir2Option.value)
+ envir2Charts.value = echarts.init(document.getElementById('envir2'))
+ envir2Charts.value.setOption(envir2Option.value)
}
+
+ setInterval(() => {
+ binCharts.value?.setOption({
+ tooltip: {
+ trigger: 'axis',
+ },
+ legend: {
+ data: ['温度', '湿度', '过氧化氢浓度'],
+ },
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true,
+ },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: Object.keys(echartsStore.binCharts),
+ },
+ yAxis: {
+ type: 'value',
+ },
+ series: [
+ {
+ name: '温度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.binTemp,
+ },
+ {
+ name: '湿度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.binHumidity,
+ },
+ {
+ name: '过氧化氢浓度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.binHP,
+ },
+ ],
+ })
+ envir1Charts.value?.setOption({
+ tooltip: {
+ trigger: 'axis',
+ },
+ legend: {
+ data: ['温度', '湿度', '过氧化氢浓度'],
+ },
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true,
+ },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: Object.keys(echartsStore.envir1Charts),
+ },
+ yAxis: {
+ type: 'value',
+ },
+ series: [
+ {
+ name: '温度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir1Temp,
+ },
+ {
+ name: '湿度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir1Humidity,
+ },
+ {
+ name: '过氧化氢浓度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir1HP,
+ },
+ ],
+ })
+ envir2Charts.value?.setOption({
+ tooltip: {
+ trigger: 'axis',
+ },
+ legend: {
+ data: ['温度', '湿度', '过氧化氢浓度'],
+ },
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true,
+ },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: Object.keys(echartsStore.envir2Charts),
+ },
+ yAxis: {
+ type: 'value',
+ },
+ series: [
+ {
+ name: '温度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir2Temp,
+ },
+ {
+ name: '湿度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir2Humidity,
+ },
+ {
+ name: '过氧化氢浓度',
+ type: 'line',
+ stack: 'Total',
+ data: echartsStore.envir2HP,
+ },
+ ],
+ })
+ }, 1000 * 30)
})
+
+// 监听到store中的数据变化动态更改options
onUnmounted(() => {
timer.value = null
})
const pauseDisinfect = () => {
- if (operatorStore.disinfectStatus) {
+ if (operatorStore.disinfectStatus == 1) {
webSocketStore.sendCommandMsg(pauseDisinfectionJSON)
- operatorStore.updateDisinfectStatus(false)
}
}
const stopDisinfect = () => {
- if (operatorStore.disinfectStatus) {
+ if ([1, 2].includes(operatorStore.disinfectStatus)) {
webSocketStore.sendCommandMsg(stopDisinfectionJSON)
- operatorStore.updateDisinfectStatus(false)
}
}
const continueDisinfect = () => {
- if (!operatorStore.disinfectStatus) {
+ if (operatorStore.disinfectStatus == 2) {
webSocketStore.sendCommandMsg(continueDisinfectionJSON)
- operatorStore.updateDisinfectStatus(true)
}
}
diff --git a/src/pages/Home.vue b/src/pages/Home.vue
index 63f39c8..1c2c868 100644
--- a/src/pages/Home.vue
+++ b/src/pages/Home.vue
@@ -27,7 +27,7 @@