Browse Source

运行时config

master
maochaoying 2 years ago
parent
commit
8640a4b3a5
  1. 4
      src/components/DisinfectionSetting.vue
  2. 598
      src/components/Setting/components/RunInfectionSetting.vue
  3. 1
      src/components/UpdatePreSetting.vue
  4. 4
      src/components/dialogs/ClearAuditModal.vue
  5. 4
      src/components/dialogs/ClearRecordModal.vue
  6. 9
      src/mock/command.js
  7. 2
      src/pages/Home.vue
  8. 2
      src/store/index.js
  9. 30
      src/store/modules/running.js
  10. 7
      src/store/modules/websocket.js

4
src/components/DisinfectionSetting.vue

@ -1,11 +1,11 @@
<template>
<div class="disinfection_setting_container">
<Device :runInfection="true" />
<RunInfectionSetting :runInfection="true" />
</div>
</template>
<script setup>
import Device from 'cpns/Setting/components/Device'
import RunInfectionSetting from 'cpns/Setting/components/RunInfectionSetting'
</script>
<style lang="scss" scoped>

598
src/components/Setting/components/RunInfectionSetting.vue

@ -0,0 +1,598 @@
<template>
<div class="device_container">
<div class="row_wrap">
<p class="title">注射蠕动泵速率(g/min)</p>
<p class="num">
<van-field
type="number"
v-model="sprayLiquidConfigVal"
:clickable="true"
:formatter="formatter7"
readonly
@click.stop="hideClickKey(2)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒停止过氧化氢浓度(ppm)</p>
<p class="num">
<van-field
type="number"
v-model="stoped_gs"
:clickable="true"
:formatter="formatter1"
readonly
@click.stop="hideClickKey(3)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒继续过氧化氢浓度(ppm)</p>
<p class="num">
<van-field
type="number"
v-model="continued_gs"
:clickable="true"
:formatter="formatter2"
readonly
@click.stop="hideClickKey(4)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒停止相对湿度(%RH)</p>
<p class="num">
<van-field
type="number"
v-model="stoped_humi"
:clickable="true"
:formatter="formatter9"
readonly
@click.stop="hideClickKey(9)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒继续相对湿度(%RH)</p>
<p class="num">
<van-field
type="number"
v-model="continued_humi"
:clickable="true"
:formatter="formatter10"
readonly
@click.stop="hideClickKey(10)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒停止过氧化氢相对饱和度(%RS)</p>
<p class="num">
<van-field
type="number"
:formatter="formatter3"
v-model="stoped_satur"
:clickable="true"
readonly
@click.stop="hideClickKey(5)"
/>
</p>
</div>
<div class="row_wrap">
<p class="title">消毒继续过氧化氢相对饱和度(%RS)</p>
<p class="num">
<van-field
type="number"
:formatter="formatter4"
v-model="continued_satur"
:clickable="true"
readonly
@click.stop="hideClickKey(6)"
/>
</p>
</div>
<van-number-keyboard
v-model="sprayLiquidConfigVal"
@input="val => handleInput(val, 2)"
:title="sprayLiquidConfigVal"
:show="sprayLiquidConfigValShow"
theme="custom"
@close="setSprayLiquidVal"
close-button-text="配置"
@blur="sprayLiquidConfigValShow = false"
/>
<van-number-keyboard
v-model="stoped_gs"
@input="val => handleInput(val, 3)"
:title="stoped_gs"
:show="stoped_gsShow"
theme="custom"
@close="setStopedGsVal"
close-button-text="配置"
@blur="stoped_gsShow = false"
/>
<van-number-keyboard
v-model="continued_gs"
@input="val => handleInput(val, 4)"
:title="continued_gs"
@close="setcontinuedGsVal"
:show="continued_gsShow"
theme="custom"
close-button-text="配置"
@blur="continued_gsShow = false"
/>
<van-number-keyboard
v-model="stoped_satur"
@input="val => handleInput(val, 5)"
:title="stoped_satur"
@close="setstopedSaturVal"
:show="stoped_saturShow"
theme="custom"
close-button-text="配置"
@blur="stoped_saturShow = false"
/>
<van-number-keyboard
v-model="continued_satur"
@input="val => handleInput(val, 6)"
:title="continued_satur"
@close="setContinuedSaturVal"
:show="continued_saturShow"
theme="custom"
close-button-text="配置"
@blur="continued_saturShow = false"
/>
<van-number-keyboard
@input="val => handleInput(val, 9)"
theme="custom"
close-button-text="配置"
@close="setstoped_humiVal"
v-model="stoped_humi"
:title="stoped_humi"
:show="stoped_humiShow"
@blur="stoped_humiShow = false"
/>
<van-number-keyboard
theme="custom"
@input="val => handleInput(val, 10)"
close-button-text="配置"
@close="setcontinued_humiVal"
v-model="continued_humi"
:title="continued_humi"
:show="continued_humiShow"
@blur="continued_humiShow = false"
/>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { showSuccessToast, showFailToast } from 'vant'
import {
useSettingStore,
useWebSocketStore,
useOperatorStore,
useRunningStore,
} from '@/store'
import { storeToRefs } from 'pinia'
import {
setSettingValJSON,
changeDisinfectionParameterJSON,
updateSettingInRunInfectionJSON,
} from '@/mock/command'
const settingStore = useSettingStore()
const webSocketStore = useWebSocketStore()
const operatorStore = useOperatorStore()
const runningStore = useRunningStore()
const {
sprayLiquidConfigVal,
stoped_humi,
continued_humi,
continued_satur,
stoped_satur,
continued_gs,
stoped_gs,
} = storeToRefs(runningStore)
const props = defineProps({
runInfection: {
type: Boolean,
},
})
const sprayLiquidConfigValShow = ref(false)
const stoped_gsShow = ref(false)
const continued_gsShow = ref(false)
const stoped_saturShow = ref(false)
const continued_saturShow = ref(false)
const stoped_humiShow = ref(false)
const continued_humiShow = ref(false)
const isFirstClick = ref(true)
const hideClickKey = flag => {
isFirstClick.value = true
stoped_humiShow.value = false
continued_humiShow.value = false
sprayLiquidConfigValShow.value = false
stoped_gsShow.value = false
continued_gsShow.value = false
stoped_saturShow.value = false
continued_saturShow.value = false
if (flag == 2) {
sprayLiquidConfigValShow.value = true
}
if (flag == 3) {
stoped_gsShow.value = true
}
if (flag == 4) {
continued_gsShow.value = true
}
if (flag == 5) {
stoped_saturShow.value = true
}
if (flag == 6) {
continued_saturShow.value = true
}
if (flag == 9) {
stoped_humiShow.value = true
}
if (flag == 10) {
continued_humiShow.value = true
}
}
const handleInput = (value, index) => {
if (isFirstClick.value) {
if (index == 2) {
setTimeout(() => {
sprayLiquidConfigVal.value = value + ''
})
}
if (index == 3) {
setTimeout(() => {
stoped_gs.value = value + ''
})
}
if (index == 4) {
setTimeout(() => {
continued_gs.value = value + ''
})
}
if (index == 5) {
setTimeout(() => {
stoped_satur.value = value + ''
})
}
if (index == 6) {
setTimeout(() => {
continued_satur.value = value + ''
})
}
if (index == 9) {
setTimeout(() => {
stoped_humi.value = value + ''
})
}
if (index == 10) {
setTimeout(() => {
continued_humi.value = value + ''
})
}
isFirstClick.value = false
}
}
const formatter1 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(item => item.name == 'stoped_gs')
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter2 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_gs',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter3 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'stoped_satur',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter4 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_satur',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter6 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'drainage_pump_speed',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter7 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'injection_pump_speed',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter9 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'stoped_humi',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const formatter10 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_humi',
)
if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) {
return arr[0].val_upper_limit + ''
}
if (parseInt(value) < arr[0].val_lower_limit) {
return arr[0].val_lower_limit + ''
}
}
return value.replace(/^0+/gi, '')
}
const setStopedGsVal = () => {
const val = parseInt(stoped_gs.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('stoped_gs', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_gs', val))
}
showSuccessToast('设置成功')
}
const setcontinuedGsVal = () => {
const val = parseInt(continued_gs.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('continued_gs', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('continued_gs', val))
}
showSuccessToast('设置成功')
}
const setstopedSaturVal = () => {
const val = parseInt(stoped_satur.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('stoped_satur', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_satur', val))
}
showSuccessToast('设置成功')
}
const setContinuedSaturVal = () => {
const val = parseInt(continued_satur.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('continued_satur', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('continued_satur', val))
}
showSuccessToast('设置成功')
}
const setstoped_humiVal = () => {
const val = parseInt(stoped_humi.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('stoped_humi', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_humi', val))
}
showSuccessToast('设置成功')
}
const setcontinued_humiVal = () => {
const val = parseInt(continued_humi.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('continued_humi', val),
)
} else {
webSocketStore.sendCommandMsg(setSettingValJSON('continued_humi', val))
}
showSuccessToast('设置成功')
}
const setSprayLiquidVal = () => {
const val = parseInt(sprayLiquidConfigVal.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
if (props.runInfection) {
webSocketStore.sendCommandMsg(
updateSettingInRunInfectionJSON('injection_pump_speed', val),
)
} else {
settingStore.changeSprayLiquidConfigVal(val)
webSocketStore.sendCommandMsg(
setSettingValJSON('injection_pump_speed', val),
)
}
showSuccessToast('设置成功')
}
</script>
<style lang="scss" scoped>
.device_container {
box-sizing: border-box;
width: 100%;
height: 580px;
padding: 20px;
display: grid;
overflow: scroll;
grid-template-columns: repeat(1, 1fr);
row-gap: 20px;
padding-bottom: 20px;
.row_wrap {
// width: 726px;
height: 80px;
border-radius: 14px;
background: #f6f6f6;
box-sizing: border-box;
padding: 0 18px 0 40px;
display: flex;
align-items: center;
justify-content: space-between;
.title {
font-family: Zona Pro;
font-size: 20px;
font-weight: normal;
letter-spacing: 0.06em;
color: #000000;
}
.num {
font-family: Source Han Sans CN;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.1em;
color: #000000;
display: flex;
align-items: center;
}
.btn {
width: 87px;
height: 45px;
border-radius: 23px;
background: #06518b;
font-family: Source Han Sans CN;
font-size: 14px;
font-weight: normal;
letter-spacing: 0.1em;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
}
</style>

1
src/components/UpdatePreSetting.vue

@ -734,7 +734,6 @@ onMounted(() => {
document.addEventListener('click', e => {
let box = document.getElementById('keyboard_formula')
let room = document.getElementById('id_formula')
let fontBox = document.getElementsByClassName('hg-candidate-box')
if (!box?.contains(e.target) && e.target != room) {
showkeyboard.value = false
}

4
src/components/dialogs/ClearAuditModal.vue

@ -31,7 +31,7 @@
<script setup>
import { useWebSocketStore } from '@/store'
import { cleanDisinfectionRecordJSON } from '@/mock/command'
import { cleanUserBehaviorRecordJSON } from '@/mock/command'
const webSocketStore = useWebSocketStore()
@ -46,7 +46,7 @@ const handleCancel = () => {
}
const handleStart = () => {
webSocketStore.sendCommandMsg(cleanDisinfectionRecordJSON)
webSocketStore.sendCommandMsg(cleanUserBehaviorRecordJSON)
props.hideAuditModal()
}
</script>

4
src/components/dialogs/ClearRecordModal.vue

@ -31,7 +31,7 @@
<script setup>
import { useWebSocketStore } from '@/store'
import { cleanUserBehaviorRecordJSON } from '@/mock/command'
import { cleanDisinfectionRecordJSON } from '@/mock/command'
const webSocketStore = useWebSocketStore()
@ -46,7 +46,7 @@ const handleCancel = () => {
}
const handleStart = () => {
webSocketStore.sendCommandMsg(cleanUserBehaviorRecordJSON)
webSocketStore.sendCommandMsg(cleanDisinfectionRecordJSON)
props.hideRecordModal()
}
</script>

9
src/mock/command.js

@ -284,9 +284,14 @@ export const startFormulaJSON = id => {
export const updateSettingInRunInfectionJSON = (column, val) => {
return {
command: 'updateFormula',
messageId: 'updateFormula',
command: 'changeDisinfectionParameter',
messageId: 'changeDisinfectionParameter',
column,
val,
}
}
export const getDisinfectionConfigJSON = {
command: 'getDisinfectionConfig',
messageId: 'getDisinfectionConfig',
}

2
src/pages/Home.vue

@ -339,6 +339,7 @@ import {
getStateJSON,
getAllSettingJSON,
getAllUserJSON,
getDisinfectionConfigJSON,
} from '@/mock/command'
import { useRouter } from 'vue-router'
@ -386,6 +387,7 @@ const onChange = a => {
const changeTab = index => {
if (index == 5) {
//
webSocketStore.sendCommandMsg(getDisinfectionConfigJSON)
if (userStore.loginUserPermission == 3) {
//
//

2
src/store/index.js

@ -9,6 +9,7 @@ import { useEchartsStore } from './modules/echarts'
import { usePreStore } from './modules/preinstall'
import { useAuditStore } from './modules/audit'
import { useFormulaStore } from './modules/formula'
import { useRunningStore } from './modules/running'
const store = createPinia()
export default store
@ -16,6 +17,7 @@ export {
useTestStore,
useFormulaStore,
useAuditStore,
useRunningStore,
useSettingStore,
useOperatorStore,
useWebSocketStore,

30
src/store/modules/running.js

@ -0,0 +1,30 @@
import { defineStore } from 'pinia'
export const useRunningStore = defineStore({
id: 'running', // id必填,且需要唯一
// state
state: () => {
return {
sprayLiquidConfigVal: '0',
stoped_humi: '0',
continued_humi: '0',
continued_satur: '0',
stoped_satur: '0',
continued_gs: '0',
stoped_gs: '0',
disinfectionConfig: {},
}
},
// actions
actions: {
updateDisinfectionConfig(disinfectionConfig) {
this.sprayLiquidConfigVal = disinfectionConfig.injection_pump_speed + ''
this.stoped_humi = disinfectionConfig.stoped_humi + ''
this.continued_humi = disinfectionConfig.continued_humi + ''
this.continued_satur = disinfectionConfig.continued_satur + ''
this.stoped_satur = disinfectionConfig.stoped_satur + ''
this.continued_gs = disinfectionConfig.continued_gs + ''
this.stoped_gs = disinfectionConfig.stoped_gs + ''
this.disinfectionConfig = disinfectionConfig
},
},
})

7
src/store/modules/websocket.js

@ -9,6 +9,7 @@ import { useTestStore } from './test'
import { useAuditStore } from './audit'
import { useFormulaStore } from './formula'
import { useEchartsStore } from './echarts'
import { useRunningStore } from './running'
import { showSuccessToast, showFailToast } from 'vant'
import { saveEchartsDataToLocal } from '@/utils'
@ -36,6 +37,7 @@ export const useWebSocketStore = defineStore({
const echartsStore = useEchartsStore()
const auditStore = useAuditStore()
const formulaStore = useFormulaStore()
const runningStore = useRunningStore()
init.connect()
init.ws.onmessage = function (ev) {
const { ackcode, messageId, timeStamp } = JSON.parse(ev.data)
@ -85,6 +87,7 @@ export const useWebSocketStore = defineStore({
sprinklerPumpGPM,
} = sensor_data
const { nowlog } = disinfectionState || {}
deviceStore.updateNowLog(nowlog)
if ([1, 2, 3, 4].includes(disinfectionWorkState)) {
operatorStore.updateShowStartReady(false)
@ -194,6 +197,10 @@ export const useWebSocketStore = defineStore({
auditStore.updateTotal(total)
auditStore.updatePage(page)
break
case 'getDisinfectionConfig':
const { disinfectionConfig } = JSON.parse(ev.data)
runningStore.updateDisinfectionConfig(disinfectionConfig)
break
case 'login':
// if (ackcode == 0) {
// window.location.href = 'http://127.0.0.1/'

Loading…
Cancel
Save