Browse Source

参数格式化

master
maochaoying 2 years ago
parent
commit
bdeb3b6018
  1. 90
      src/components/Setting/components/Device.vue
  2. 20
      src/store/modules/setting.js

90
src/components/Setting/components/Device.vue

@ -304,6 +304,9 @@ const hideClickKey = flag => {
} }
const formatter1 = value => { const formatter1 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter(item => item.name == 'stoped_gs') let arr = settingStore.allSettingList.filter(item => item.name == 'stoped_gs')
if (arr && arr.length > 0) { if (arr && arr.length > 0) {
if (parseInt(value) > arr[0].val_upper_limit) { if (parseInt(value) > arr[0].val_upper_limit) {
@ -313,10 +316,13 @@ const formatter1 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter2 = value => { const formatter2 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_gs', item => item.name == 'continued_gs',
) )
@ -328,10 +334,13 @@ const formatter2 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter3 = value => { const formatter3 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'stoped_satur', item => item.name == 'stoped_satur',
) )
@ -343,10 +352,13 @@ const formatter3 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter4 = value => { const formatter4 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_satur', item => item.name == 'continued_satur',
) )
@ -358,10 +370,13 @@ const formatter4 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter5 = value => { const formatter5 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'max_humidity', item => item.name == 'max_humidity',
) )
@ -373,10 +388,13 @@ const formatter5 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter6 = value => { const formatter6 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'drainage_pump_speed', item => item.name == 'drainage_pump_speed',
) )
@ -388,10 +406,13 @@ const formatter6 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter7 = value => { const formatter7 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'injection_pump_speed', item => item.name == 'injection_pump_speed',
) )
@ -403,10 +424,13 @@ const formatter7 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter8 = value => { const formatter8 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'pre_heat_time_s', item => item.name == 'pre_heat_time_s',
) )
@ -418,10 +442,13 @@ const formatter8 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter9 = value => { const formatter9 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'stoped_humi', item => item.name == 'stoped_humi',
) )
@ -433,10 +460,13 @@ const formatter9 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const formatter10 = value => { const formatter10 = value => {
if (parseInt(value) == 0) {
return '0'
}
let arr = settingStore.allSettingList.filter( let arr = settingStore.allSettingList.filter(
item => item.name == 'continued_humi', item => item.name == 'continued_humi',
) )
@ -448,11 +478,15 @@ const formatter10 = value => {
return arr[0].val_lower_limit + '' return arr[0].val_lower_limit + ''
} }
} }
return value
return value.replace(/^0+/gi, '')
} }
const setAddliquidVal = () => { const setAddliquidVal = () => {
const val = parseInt(addLiquidConfigVal.value) const val = parseInt(addLiquidConfigVal.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.changeAddLiquidConfigVal(val) settingStore.changeAddLiquidConfigVal(val)
webSocketStore.sendCommandMsg(setSettingValJSON('drainage_pump_speed', val)) webSocketStore.sendCommandMsg(setSettingValJSON('drainage_pump_speed', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -460,6 +494,10 @@ const setAddliquidVal = () => {
const setStopedGsVal = () => { const setStopedGsVal = () => {
const val = parseInt(stoped_gs.value) const val = parseInt(stoped_gs.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateStopedGs(val) settingStore.updateStopedGs(val)
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_gs', val)) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_gs', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -467,6 +505,10 @@ const setStopedGsVal = () => {
const setcontinuedGsVal = () => { const setcontinuedGsVal = () => {
const val = parseInt(continued_gs.value) const val = parseInt(continued_gs.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateContinuedGs(val) settingStore.updateContinuedGs(val)
webSocketStore.sendCommandMsg(setSettingValJSON('continued_gs', val)) webSocketStore.sendCommandMsg(setSettingValJSON('continued_gs', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -474,6 +516,10 @@ const setcontinuedGsVal = () => {
const setstopedSaturVal = () => { const setstopedSaturVal = () => {
const val = parseInt(stoped_satur.value) const val = parseInt(stoped_satur.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateStopedSatur(val) settingStore.updateStopedSatur(val)
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_satur', val)) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_satur', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -481,6 +527,10 @@ const setstopedSaturVal = () => {
const setContinuedSaturVal = () => { const setContinuedSaturVal = () => {
const val = parseInt(continued_satur.value) const val = parseInt(continued_satur.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateContinuedSatur(val) settingStore.updateContinuedSatur(val)
webSocketStore.sendCommandMsg(setSettingValJSON('continued_satur', val)) webSocketStore.sendCommandMsg(setSettingValJSON('continued_satur', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -488,6 +538,10 @@ const setContinuedSaturVal = () => {
const setMaxHumidityVal = () => { const setMaxHumidityVal = () => {
const val = parseInt(max_humidity.value) const val = parseInt(max_humidity.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateMaxHumidity(val) settingStore.updateMaxHumidity(val)
webSocketStore.sendCommandMsg(setSettingValJSON('max_humidity', val)) webSocketStore.sendCommandMsg(setSettingValJSON('max_humidity', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -495,6 +549,10 @@ const setMaxHumidityVal = () => {
const setHeat_timeVal = () => { const setHeat_timeVal = () => {
const val = parseInt(pre_heat_time_s.value) const val = parseInt(pre_heat_time_s.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updatePre_heat_time_s(val) settingStore.updatePre_heat_time_s(val)
webSocketStore.sendCommandMsg(setSettingValJSON('pre_heat_time_s', val)) webSocketStore.sendCommandMsg(setSettingValJSON('pre_heat_time_s', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -502,6 +560,10 @@ const setHeat_timeVal = () => {
const setstoped_humiVal = () => { const setstoped_humiVal = () => {
const val = parseInt(stoped_humi.value) const val = parseInt(stoped_humi.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateStopedHumi(val) settingStore.updateStopedHumi(val)
webSocketStore.sendCommandMsg(setSettingValJSON('stoped_humi', val)) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_humi', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -509,6 +571,10 @@ const setstoped_humiVal = () => {
const setcontinued_humiVal = () => { const setcontinued_humiVal = () => {
const val = parseInt(continued_humi.value) const val = parseInt(continued_humi.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.updateContinuedHumi(val) settingStore.updateContinuedHumi(val)
webSocketStore.sendCommandMsg(setSettingValJSON('continued_humi', val)) webSocketStore.sendCommandMsg(setSettingValJSON('continued_humi', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')
@ -516,6 +582,10 @@ const setcontinued_humiVal = () => {
const setSprayLiquidVal = () => { const setSprayLiquidVal = () => {
const val = parseInt(sprayLiquidConfigVal.value) const val = parseInt(sprayLiquidConfigVal.value)
if (isNaN(val)) {
showFailToast('设置失败,请填写正确参数')
return
}
settingStore.changeSprayLiquidConfigVal(val) settingStore.changeSprayLiquidConfigVal(val)
webSocketStore.sendCommandMsg(setSettingValJSON('injection_pump_speed', val)) webSocketStore.sendCommandMsg(setSettingValJSON('injection_pump_speed', val))
showSuccessToast('设置成功') showSuccessToast('设置成功')

20
src/store/modules/setting.js

@ -10,19 +10,19 @@ export const useSettingStore = defineStore({
// 设置当前时间 // 设置当前时间
currentTime: moment().utcOffset(8).format('HH:mm').split(':'), currentTime: moment().utcOffset(8).format('HH:mm').split(':'),
// 设置加液泵的参数 // 设置加液泵的参数
addLiquidConfigVal: 0,
addLiquidConfigVal: '0',
// 设置喷液泵的参数 // 设置喷液泵的参数
sprayLiquidConfigVal: 0,
max_humidity: 0,
continued_satur: 0,
stoped_satur: 0,
pre_heat_time_s: 0,
continued_gs: 0,
stoped_gs: 0,
sprayLiquidConfigVal: '0',
max_humidity: '0',
continued_satur: '0',
stoped_satur: '0',
pre_heat_time_s: '0',
continued_gs: '0',
stoped_gs: '0',
// 消毒停止相对湿度 // 消毒停止相对湿度
stoped_humi: 0,
stoped_humi: '0',
// 消毒继续相对湿度 // 消毒继续相对湿度
continued_humi: 0,
continued_humi: '0',
// 首屏初始化 // 首屏初始化
initLoading: true, initLoading: true,
// 所有setting的对象数据 // 所有setting的对象数据

Loading…
Cancel
Save