|
@ -31,10 +31,11 @@ export const useWebSocketStore = defineStore({ |
|
|
const testStore = useTestStore() |
|
|
const testStore = useTestStore() |
|
|
const deviceStore = useDeviceStore() |
|
|
const deviceStore = useDeviceStore() |
|
|
const operatorStore = useOperatorStore() |
|
|
const operatorStore = useOperatorStore() |
|
|
|
|
|
const echartsStore = useEchartsStore() |
|
|
init.connect() |
|
|
init.connect() |
|
|
init.ws.onmessage = function (ev) { |
|
|
init.ws.onmessage = function (ev) { |
|
|
const { ackcode, messageId } = JSON.parse(ev.data) |
|
|
|
|
|
// console.log(JSON.parse(ev.data))
|
|
|
|
|
|
|
|
|
const { ackcode, messageId, timeStamp } = JSON.parse(ev.data) |
|
|
|
|
|
console.log(JSON.parse(ev.data)) |
|
|
switch (messageId) { |
|
|
switch (messageId) { |
|
|
case 'getState': |
|
|
case 'getState': |
|
|
// 初始化完毕
|
|
|
// 初始化完毕
|
|
@ -106,13 +107,31 @@ export const useWebSocketStore = defineStore({ |
|
|
operatorStore.updateEstimatedRemainingTimeS(estimatedRemainingTimeS) |
|
|
operatorStore.updateEstimatedRemainingTimeS(estimatedRemainingTimeS) |
|
|
operatorStore.updateDisinfectionId(disinfection_id) |
|
|
operatorStore.updateDisinfectionId(disinfection_id) |
|
|
// 将sensor_data中的数据更新到store中
|
|
|
// 将sensor_data中的数据更新到store中
|
|
|
|
|
|
|
|
|
|
|
|
if (operatorStore.disinfectStatus == 1) { |
|
|
|
|
|
saveEchartsDataToLocal( |
|
|
|
|
|
moment(timeStamp).format('HH:mm'), |
|
|
|
|
|
[temp_1, humid_1, h2o2_1], |
|
|
|
|
|
[temp_2, humid_2, h2o2_2], |
|
|
|
|
|
[temp_3, humid_3, h2o2_3], |
|
|
|
|
|
) |
|
|
|
|
|
echartsStore.updateBinCharts( |
|
|
|
|
|
JSON.parse(localStorage.getItem('bin')), |
|
|
|
|
|
) |
|
|
|
|
|
echartsStore.updateEnvir1Charts( |
|
|
|
|
|
JSON.parse(localStorage.getItem('envir1')), |
|
|
|
|
|
) |
|
|
|
|
|
echartsStore.updateEnvir2Charts( |
|
|
|
|
|
JSON.parse(localStorage.getItem('envir2')), |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
break |
|
|
break |
|
|
case 'getAllUser': |
|
|
case 'getAllUser': |
|
|
const { dbval } = JSON.parse(ev.data) |
|
|
const { dbval } = JSON.parse(ev.data) |
|
|
|
|
|
console.log(dbval, 'dbva;') |
|
|
userStore.updateUserList(dbval) |
|
|
userStore.updateUserList(dbval) |
|
|
break |
|
|
break |
|
|
case 'chpasswd': |
|
|
case 'chpasswd': |
|
|
console.log(JSON.parse(ev.data)) |
|
|
|
|
|
if (ackcode != 0) { |
|
|
if (ackcode != 0) { |
|
|
// 修改失败
|
|
|
// 修改失败
|
|
|
showFailToast('修改失败') |
|
|
showFailToast('修改失败') |
|
@ -120,11 +139,22 @@ export const useWebSocketStore = defineStore({ |
|
|
showSuccessToast('修改成功') |
|
|
showSuccessToast('修改成功') |
|
|
} |
|
|
} |
|
|
break |
|
|
break |
|
|
|
|
|
case 'startReplenishingFluids': |
|
|
|
|
|
if (ackcode == 0) { |
|
|
|
|
|
operatorStore.updateReplenishingFluidsWorkState(1) |
|
|
|
|
|
} |
|
|
|
|
|
case 'startDraining': |
|
|
|
|
|
if (ackcode == 0) { |
|
|
|
|
|
operatorStore.updateDrainingWorkState(1) |
|
|
|
|
|
} |
|
|
case 'startDisinfection': |
|
|
case 'startDisinfection': |
|
|
break |
|
|
break |
|
|
case 'stopDisinfection': |
|
|
case 'stopDisinfection': |
|
|
break |
|
|
break |
|
|
case 'login': |
|
|
case 'login': |
|
|
|
|
|
if (ackcode == 0) { |
|
|
|
|
|
window.location.href = 'http://127.0.0.1/' |
|
|
|
|
|
} |
|
|
break |
|
|
break |
|
|
case 'getAllRecords': |
|
|
case 'getAllRecords': |
|
|
break |
|
|
break |
|
@ -201,8 +231,6 @@ export const useWebSocketStore = defineStore({ |
|
|
deviceStore.updateEnvirHP2(h2o2_3) |
|
|
deviceStore.updateEnvirHP2(h2o2_3) |
|
|
|
|
|
|
|
|
// 对数据进行处理 并存入到localstorage中
|
|
|
// 对数据进行处理 并存入到localstorage中
|
|
|
// console.log(moment(timeStamp).format('HH:mm:ss'))
|
|
|
|
|
|
// console.log(localStorage)
|
|
|
|
|
|
if (operatorStore.disinfectStatus) { |
|
|
if (operatorStore.disinfectStatus) { |
|
|
saveEchartsDataToLocal( |
|
|
saveEchartsDataToLocal( |
|
|
moment(timeStamp).format('HH:mm'), |
|
|
moment(timeStamp).format('HH:mm'), |
|
|