Browse Source

fix: 首页loading问题

master
guoapeng 1 week ago
parent
commit
cc8c4f4482
  1. 24
      src/components/home/HomeOperation.vue

24
src/components/home/HomeOperation.vue

@ -2,8 +2,8 @@
import { sendCmd } from 'apis/system'
import homeFinish from 'assets/images/home/home-finish.svg'
import homeStart from 'assets/images/home/home-start.svg'
import { ElLoading } from 'element-plus'
import { startTimer, stopTimer } from 'libs/countdownTimer'
import { deviceStateMap } from 'libs/utils'
import { computed, ref, watchEffect } from 'vue'
import { getDeviceStatus } from '@/libs/deviceComm'
@ -77,14 +77,18 @@ const doStartDisinfect = async () => {
return
}
systemStore.updateLoading(true)
const loading = ElLoading.service({
lock: true,
text: '准备开始消毒',
background: 'rgba(255, 255, 255, 0.8)',
})
try {
// 使
if (formulaStore.selectedFormulaInfo && formulaStore.selectedFormulaInfo.formula_id) {
await formulaStore.startDisinfectFormula(formulaStore.selectedFormulaInfo)
const poll = setInterval(() => {
if (!operationState.value) {
systemStore.updateLoading(false)
loading.close()
clearInterval(poll)
}
}, 100)
@ -98,7 +102,7 @@ const doStartDisinfect = async () => {
await sendCmd(startParams)
const poll = setInterval(() => {
if (!operationState.value) {
systemStore.updateLoading(false)
loading.close()
clearInterval(poll)
}
}, 100)
@ -106,7 +110,7 @@ const doStartDisinfect = async () => {
}
catch (e) {
console.log(e)
systemStore.updateLoading(false)
loading.close()
}
}
@ -124,7 +128,11 @@ const onFinishDisinfect = () => {
const doStopDisinfect = async () => {
stopTimer() //
systemStore.updateLoading(true)
const loading = ElLoading.service({
lock: true,
text: '正在停止消毒',
background: 'rgba(255, 255, 255, 0.8)',
})
try {
const stopParams = {
className: 'DisinfectionCtrlServiceExt',
@ -134,14 +142,14 @@ const doStopDisinfect = async () => {
await sendCmd(stopParams)
const poll = setInterval(() => {
if (operationState.value) {
systemStore.updateLoading(false)
loading.close()
clearInterval(poll)
}
}, 100)
}
catch (e) {
console.log(e)
systemStore.updateLoading(false)
loading.close()
}
}

Loading…
Cancel
Save