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

Loading…
Cancel
Save