Browse Source

最小最大

master
maochaoying 2 years ago
parent
commit
c26d2be95f
  1. 117
      src/components/Setting/components/Device.vue
  2. 4
      src/components/Test.vue
  3. 3
      src/store/modules/websocket.js

117
src/components/Setting/components/Device.vue

@ -7,8 +7,8 @@
type="number"
v-model="addLiquidConfigVal"
:clickable="true"
:formatter="formatter2"
:maxlength="3"
:formatter="formatter6"
:maxlength="4"
readonly
@touchstart.stop="addLiquidConfigValShow = true"
/>
@ -22,8 +22,8 @@
type="number"
v-model="sprayLiquidConfigVal"
:clickable="true"
:formatter="formatter2"
:maxlength="3"
:formatter="formatter7"
:maxlength="4"
readonly
@touchstart.stop="sprayLiquidConfigValShow = true"
/>
@ -37,7 +37,7 @@
type="number"
v-model="stoped_gs"
:clickable="true"
:formatter="formatter3"
:formatter="formatter1"
:maxlength="4"
readonly
@touchstart.stop="stoped_gsShow = true"
@ -53,7 +53,7 @@
v-model="continued_gs"
:clickable="true"
:maxlength="4"
:formatter="formatter3"
:formatter="formatter2"
readonly
@touchstart.stop="continued_gsShow = true"
/>
@ -65,7 +65,7 @@
<p class="num">
<van-field
type="number"
:formatter="formatter1"
:formatter="formatter3"
v-model="stoped_satur"
:clickable="true"
:maxlength="3"
@ -80,7 +80,7 @@
<p class="num">
<van-field
type="number"
:formatter="formatter1"
:formatter="formatter4"
v-model="continued_satur"
:clickable="true"
:maxlength="3"
@ -94,7 +94,7 @@
<p class="title">允许消毒最大湿度(%RH)</p>
<p class="num">
<van-field
:formatter="formatter1"
:formatter="formatter5"
type="number"
v-model="max_humidity"
:clickable="true"
@ -108,13 +108,13 @@
<van-number-keyboard
v-model="addLiquidConfigVal"
:show="addLiquidConfigValShow"
:maxlength="3"
:maxlength="4"
@blur="addLiquidConfigValShow = false"
/>
<van-number-keyboard
v-model="sprayLiquidConfigVal"
:show="sprayLiquidConfigValShow"
:maxlength="3"
:maxlength="4"
@blur="sprayLiquidConfigValShow = false"
/>
<van-number-keyboard
@ -167,6 +167,7 @@ const {
stoped_gs,
addLiquidConfigVal,
sprayLiquidConfigVal,
allSettingList,
} = storeToRefs(settingStore)
const addLiquidConfigValShow = ref(false)
@ -178,22 +179,104 @@ const continued_saturShow = ref(false)
const max_humidityShow = ref(false)
const formatter1 = value => {
if (parseInt(value) > 100) {
return '100'
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
}
const formatter2 = value => {
if (parseInt(value) > 500) {
return '500'
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
}
const formatter3 = value => {
if (parseInt(value) > 1000) {
return '1000'
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
}
const formatter4 = value => {
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
}
const formatter5 = value => {
let arr = settingStore.allSettingList.filter(
item => item.name == 'max_humidity',
)
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
}
const formatter6 = value => {
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
}
const formatter7 = value => {
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
}

4
src/components/Test.vue

@ -56,7 +56,7 @@
</div>
<div class="common_set switch_wrap">
<p class="title">风机</p>
<p class="num">{{ testStore?.airBlowerObj?.currentVal }} RPM</p>
<p class="num">{{ testStore?.airBlowerObj?.currentVal }} A</p>
<div class="btn_wrap">
<div
:class="testStore.draughtFan ? 'close' : 'open'"
@ -74,7 +74,7 @@
</div>
<div class="common_set switch_wrap">
<p class="title">加热片</p>
<p class="num">{{ testStore?.heatingStripObj?.currentVal }} </p>
<p class="num">{{ testStore?.heatingStripObj?.currentVal }} A</p>
<div class="btn_wrap">
<div
:class="testStore.heatingStrip ? 'close' : 'open'"

3
src/store/modules/websocket.js

@ -34,7 +34,7 @@ export const useWebSocketStore = defineStore({
init.connect()
init.ws.onmessage = function (ev) {
const { ackcode, messageId } = JSON.parse(ev.data)
console.log(JSON.parse(ev.data))
// console.log(JSON.parse(ev.data))
switch (messageId) {
case 'getState':
// 初始化完毕
@ -130,6 +130,7 @@ export const useWebSocketStore = defineStore({
break
case 'getAllSetting':
const { dbval: allSetting } = JSON.parse(ev.data)
console.log(JSON.parse(ev.data))
settingStore.updateAllSettingList(allSetting)
break
default:

Loading…
Cancel
Save