maochaoying 2 years ago
parent
commit
fc47e0b603
  1. BIN
      src/assets/img/liquid/oper.png
  2. 14
      src/components/LiquidHandle.vue
  3. 10
      src/components/LoginForm.vue
  4. 4
      src/components/Operator.vue
  5. 50
      src/components/Progress.vue
  6. 18
      src/components/Test.vue
  7. 2
      src/components/dialogs/LogPicker.vue
  8. 6
      src/pages/Login.vue
  9. 3
      src/socket/index.js
  10. 44
      src/store/modules/device.js
  11. 36
      src/store/modules/test.js
  12. 38
      src/store/modules/websocket.js

BIN
src/assets/img/liquid/oper.png

Before

Width: 227  |  Height: 45  |  Size: 2.6 KiB

After

Width: 227  |  Height: 45  |  Size: 2.8 KiB

14
src/components/LiquidHandle.vue

@ -6,7 +6,7 @@
type="number"
v-model="addLiquidVal"
:clickable="true"
:maxlength="3"
:maxlength="4"
readonly
@touchstart.stop="numberKeyboardShow = true"
class="add_liquid_input"
@ -116,7 +116,7 @@
<van-number-keyboard
v-model="addLiquidVal"
:show="numberKeyboardShow"
:maxlength="3"
:maxlength="4"
@blur="numberKeyboardShow = false"
/>
</div>
@ -142,14 +142,14 @@ const props = defineProps({
},
})
const addLiquidVal = ref(1)
const addLiquidVal = ref(2000)
const tipModalVisible = ref(false)
const webSocketStore = useWebSocketStore()
const isPopLiquidStatus = ref(false)
const startAdd = () => {
if (!operatorStore.replenishingFluidsWorkState) {
if (!(operatorStore.replenishingFluidsWorkState == 1)) {
console.log(startReplenishingFluidsJSON(parseInt(addLiquidVal.value)))
webSocketStore.sendCommandMsg(
startReplenishingFluidsJSON(parseInt(addLiquidVal.value)),
@ -158,19 +158,19 @@ const startAdd = () => {
}
const stopAdd = () => {
if (operatorStore.replenishingFluidsWorkState) {
if (operatorStore.replenishingFluidsWorkState == 1) {
webSocketStore.sendCommandMsg(stopReplenishingFluidsJSON)
}
}
const stopPop = () => {
if (operatorStore.drainingWorkState) {
if (operatorStore.drainingWorkState == 1) {
webSocketStore.sendCommandMsg(stopDrainingJSON)
}
}
const startTabLiquid = () => {
if (!operatorStore.drainingWorkState) {
if (!(operatorStore.drainingWorkState == 1)) {
tipModalVisible.value = true
}
}

10
src/components/LoginForm.vue

@ -84,6 +84,7 @@ const handleLogin = () => {
tip.value = ''
webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value))
//
console.log(userStore.allUserList)
let flag = false
userStore.allUserList?.map(item => {
if (item.uid == username.value && password.value == item.passwd) {
@ -91,10 +92,11 @@ const handleLogin = () => {
flag = true
userStore.updatePermission(item.permission_level)
userStore.updateLoginUser(item.uid)
window.location.href = 'http://127.0.0.1/'
}
})
if (flag) {
router.push('/')
if (!flag) {
tip.value = '账号或密码错误'
}
}
</script>
@ -135,7 +137,7 @@ const handleLogin = () => {
left: 120px;
top: 142px;
font-family: Source Han Sans CN;
font-size: 12px;
font-size: 18px;
font-weight: 350;
letter-spacing: 0.06em;
}
@ -148,7 +150,7 @@ const handleLogin = () => {
left: 120px;
top: 209px;
font-family: Source Han Sans CN;
font-size: 12px;
font-size: 18px;
font-weight: 350;
letter-spacing: 0.06em;
}

4
src/components/Operator.vue

@ -121,7 +121,7 @@ const toDetail = () => {
}
const logVisible = ref(false)
const logVal = ref(1)
const logVal = ref('3')
const roomSize = ref(0)
watch(() => {
@ -148,7 +148,7 @@ const startDisinfect = () => {
localStorage.removeItem('envir2')
localStorage.clear()
webSocketStore.sendCommandMsg(
startDisinfectionJSON(logVal.value, roomSize.value),
startDisinfectionJSON(parseInt(logVal.value), parseInt(roomSize.value)),
)
props.changeShowOperator(false)
}

50
src/components/Progress.vue

@ -26,10 +26,20 @@
? 'btn active'
: 'btn'
"
v-if="[1, 2].includes(operatorStore.disinfectStatus)"
@click="stopDisinfect"
>
停止消毒
</div>
<div
:class="
[0].includes(operatorStore.disinfectStatus) ? 'btn active' : 'btn'
"
v-if="operatorStore.disinfectStatus == 0"
@click="showDetail"
>
返回
</div>
<!-- <div
:class="
operatorStore.disinfectStatus == 1 ? 'btn active ml' : 'btn ml'
@ -173,19 +183,19 @@ const envir1Option = ref({
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1HP,
data: [],
},
],
})
@ -215,19 +225,19 @@ const envir2Option = ref({
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2HP,
data: [],
},
],
})
@ -340,19 +350,19 @@ onMounted(() => {
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1HP,
data: [],
},
],
})
@ -382,25 +392,25 @@ onMounted(() => {
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2HP,
data: [],
},
],
})
}, 1000 * 20)
time2.value = setTimeout(() => {
time1.value = setInterval(() => {
binCharts.value?.setOption({
tooltip: {
trigger: 'axis',
@ -469,19 +479,19 @@ onMounted(() => {
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir1HP,
data: [],
},
],
})
@ -511,23 +521,23 @@ onMounted(() => {
name: '温度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Temp,
data: [],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2Humidity,
data: [],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: echartsStore.envir2HP,
data: [],
},
],
})
})
}, 1000)
})
// storeoptions

18
src/components/Test.vue

@ -78,7 +78,14 @@
</div>
<div class="common_set switch_wrap">
<p class="title">空压机</p>
<p class="num">{{ testStore?.airCompressorObj?.currentVal }} A</p>
<p class="num">
{{
testStore?.airCompressorObj?.currentVal > 5000
? 5000
: testStore?.airCompressorObj?.currentVal
}}
A
</p>
<div class="btn_wrap">
<div
:class="testStore.airCompressor ? 'close' : 'open'"
@ -142,7 +149,14 @@
</div>
<div class="common_set update_wrap">
<p class="title">液位</p>
<p class="num">{{ deviceStore.disinfectantCapacity }} kPa/100g</p>
<p class="num">
{{
deviceStore.disinfectantCapacity <= 0
? 0
: deviceStore.disinfectantCapacity
}}
kPa/100g
</p>
<div class="btn_wrap" @click="handleUpdate">更新读取液位状态</div>
</div>
<div class="common_set info_wrap">

2
src/components/dialogs/LogPicker.vue

@ -46,7 +46,7 @@ const chooseLog = () => {
props.changeLogVal(selectedValues.value[0])
}
const selectedValues = ref([])
const selectedValues = ref(['3'])
watch(() => {
selectedValues.value = [props.logVal]

6
src/pages/Login.vue

@ -84,6 +84,12 @@ onMounted(() => {
setTimeout(() => {
webSocketStore?.sendCommandMsg(getAllUserJSON)
}, 1000)
setTimeout(() => {
webSocketStore?.sendCommandMsg(getAllUserJSON)
}, 2000)
setTimeout(() => {
webSocketStore?.sendCommandMsg(getAllUserJSON)
}, 3000)
})
const reboot = () => {}

3
src/socket/index.js

@ -4,11 +4,12 @@ export default class Socket {
this.protocols = protocols
this.ws = null
this.reconnectTimeout = 2000
this.maxReconnectTimes = 100
this.maxReconnectTimes = 10000000
this.reconnectTimes = 0
}
connect() {
console.log(this.url)
this.ws = new WebSocket(this.url, this.protocols)
this.ws.onopen = () => {
console.log('WebSocket连接成功')

44
src/store/modules/device.js

@ -30,33 +30,77 @@ export const useDeviceStore = defineStore({
// actions
actions: {
updateDisinfectantCapacity(disinfectantCapacity) {
if (disinfectantCapacity < 0) {
this.disinfectantCapacity = 0
return
}
if (disinfectantCapacity > 5000) {
this.disinfectantCapacity = 5000
return
}
this.disinfectantCapacity = disinfectantCapacity
},
updateBinTemperature(binTemperature) {
if (binTemperature < 0) {
this.binTemperature = 0
return
}
this.binTemperature = binTemperature
},
updateBinHumidity(binHumidity) {
if (binHumidity < 0) {
this.binHumidity = 0
return
}
this.binHumidity = binHumidity
},
updateBinHP(binHP) {
if (binHP < 0) {
this.binHP = 0
return
}
this.binHP = binHP
},
updateEnvirTemperature1(envirTemperature1) {
if (envirTemperature1 < 0) {
this.envirTemperature1 = 0
return
}
this.envirTemperature1 = envirTemperature1
},
updateEnvirHumidity1(envirHumidity1) {
if (envirHumidity1 < 0) {
this.envirHumidity1 = 0
return
}
this.envirHumidity1 = envirHumidity1
},
updateEnvirHP1(envirHP1) {
if (envirHP1 < 0) {
this.envirHP1 = 0
return
}
this.envirHP1 = envirHP1
},
updateEnvirTemperature2(envirTemperature2) {
if (envirTemperature2 < 0) {
this.envirTemperature2 = 0
return
}
this.envirTemperature2 = envirTemperature2
},
updateEnvirHumidity2(envirHumidity2) {
if (envirHumidity2 < 0) {
this.envirHumidity2 = 0
return
}
this.envirHumidity2 = envirHumidity2
},
updateEnvirHP2(envirHP2) {
if (envirHP2 < 0) {
this.envirHP2 = 0
return
}
this.envirHP2 = envirHP2
},
},

36
src/store/modules/test.js

@ -32,30 +32,30 @@ export const useTestStore = defineStore({
this.waterImmersionSensor2 = waterImmersionSensor2
},
updateAirCompressorObj(airCompressorObj) {
const { io1, io2, currentVal } = airCompressorObj
if (io1 == 1 && io2 == 1) {
this.airCompressor = true
} else {
this.airCompressor = false
}
// const { io1, io2, currentVal } = airCompressorObj
// if (io1 == 1 && io2 == 1) {
// this.airCompressor = true
// } else {
// this.airCompressor = false
// }
this.airCompressorObj = airCompressorObj
},
updateAirBlowerObj(airBlowerObj) {
const { io1, io2, currentVal } = airBlowerObj
if (io1 == 1 && io2 == 1) {
this.draughtFan = true
} else {
this.draughtFan = false
}
// const { io1, io2, currentVal } = airBlowerObj
// if (io1 == 1 && io2 == 1) {
// this.draughtFan = true
// } else {
// this.draughtFan = false
// }
this.airBlowerObj = airBlowerObj
},
updateHeatingStripObj(heatingStripObj) {
const { io1, io2, currentVal } = heatingStripObj
if (io1 == 1 && io2 == 1) {
this.heatingStrip = true
} else {
this.heatingStrip = false
}
// const { io1, io2, currentVal } = heatingStripObj
// if (io1 == 1 && io2 == 1) {
// this.heatingStrip = true
// } else {
// this.heatingStrip = false
// }
this.heatingStripObj = heatingStripObj
},
updateHeatingStrip(heatingStrip) {

38
src/store/modules/websocket.js

@ -31,10 +31,11 @@ export const useWebSocketStore = defineStore({
const testStore = useTestStore()
const deviceStore = useDeviceStore()
const operatorStore = useOperatorStore()
const echartsStore = useEchartsStore()
init.connect()
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) {
case 'getState':
// 初始化完毕
@ -106,13 +107,31 @@ export const useWebSocketStore = defineStore({
operatorStore.updateEstimatedRemainingTimeS(estimatedRemainingTimeS)
operatorStore.updateDisinfectionId(disinfection_id)
// 将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
case 'getAllUser':
const { dbval } = JSON.parse(ev.data)
console.log(dbval, 'dbva;')
userStore.updateUserList(dbval)
break
case 'chpasswd':
console.log(JSON.parse(ev.data))
if (ackcode != 0) {
// 修改失败
showFailToast('修改失败')
@ -120,11 +139,22 @@ export const useWebSocketStore = defineStore({
showSuccessToast('修改成功')
}
break
case 'startReplenishingFluids':
if (ackcode == 0) {
operatorStore.updateReplenishingFluidsWorkState(1)
}
case 'startDraining':
if (ackcode == 0) {
operatorStore.updateDrainingWorkState(1)
}
case 'startDisinfection':
break
case 'stopDisinfection':
break
case 'login':
if (ackcode == 0) {
window.location.href = 'http://127.0.0.1/'
}
break
case 'getAllRecords':
break
@ -201,8 +231,6 @@ export const useWebSocketStore = defineStore({
deviceStore.updateEnvirHP2(h2o2_3)
// 对数据进行处理 并存入到localstorage中
// console.log(moment(timeStamp).format('HH:mm:ss'))
// console.log(localStorage)
if (operatorStore.disinfectStatus) {
saveEchartsDataToLocal(
moment(timeStamp).format('HH:mm'),

Loading…
Cancel
Save