diff --git a/src/components/Setting/components/Device.vue b/src/components/Setting/components/Device.vue index 4e05a05..078688b 100644 --- a/src/components/Setting/components/Device.vue +++ b/src/components/Setting/components/Device.vue @@ -304,6 +304,9 @@ const hideClickKey = flag => { } 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) { @@ -313,10 +316,13 @@ const formatter1 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter2 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'continued_gs', ) @@ -328,10 +334,13 @@ const formatter2 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter3 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'stoped_satur', ) @@ -343,10 +352,13 @@ const formatter3 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter4 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'continued_satur', ) @@ -358,10 +370,13 @@ const formatter4 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter5 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'max_humidity', ) @@ -373,10 +388,13 @@ const formatter5 = value => { return arr[0].val_lower_limit + '' } } - return value + 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', ) @@ -388,10 +406,13 @@ const formatter6 = value => { return arr[0].val_lower_limit + '' } } - return value + 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', ) @@ -403,10 +424,13 @@ const formatter7 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter8 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'pre_heat_time_s', ) @@ -418,10 +442,13 @@ const formatter8 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter9 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'stoped_humi', ) @@ -433,10 +460,13 @@ const formatter9 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const formatter10 = value => { + if (parseInt(value) == 0) { + return '0' + } let arr = settingStore.allSettingList.filter( item => item.name == 'continued_humi', ) @@ -448,11 +478,15 @@ const formatter10 = value => { return arr[0].val_lower_limit + '' } } - return value + return value.replace(/^0+/gi, '') } const setAddliquidVal = () => { const val = parseInt(addLiquidConfigVal.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.changeAddLiquidConfigVal(val) webSocketStore.sendCommandMsg(setSettingValJSON('drainage_pump_speed', val)) showSuccessToast('设置成功') @@ -460,6 +494,10 @@ const setAddliquidVal = () => { const setStopedGsVal = () => { const val = parseInt(stoped_gs.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateStopedGs(val) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_gs', val)) showSuccessToast('设置成功') @@ -467,6 +505,10 @@ const setStopedGsVal = () => { const setcontinuedGsVal = () => { const val = parseInt(continued_gs.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateContinuedGs(val) webSocketStore.sendCommandMsg(setSettingValJSON('continued_gs', val)) showSuccessToast('设置成功') @@ -474,6 +516,10 @@ const setcontinuedGsVal = () => { const setstopedSaturVal = () => { const val = parseInt(stoped_satur.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateStopedSatur(val) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_satur', val)) showSuccessToast('设置成功') @@ -481,6 +527,10 @@ const setstopedSaturVal = () => { const setContinuedSaturVal = () => { const val = parseInt(continued_satur.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateContinuedSatur(val) webSocketStore.sendCommandMsg(setSettingValJSON('continued_satur', val)) showSuccessToast('设置成功') @@ -488,6 +538,10 @@ const setContinuedSaturVal = () => { const setMaxHumidityVal = () => { const val = parseInt(max_humidity.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateMaxHumidity(val) webSocketStore.sendCommandMsg(setSettingValJSON('max_humidity', val)) showSuccessToast('设置成功') @@ -495,6 +549,10 @@ const setMaxHumidityVal = () => { const setHeat_timeVal = () => { const val = parseInt(pre_heat_time_s.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updatePre_heat_time_s(val) webSocketStore.sendCommandMsg(setSettingValJSON('pre_heat_time_s', val)) showSuccessToast('设置成功') @@ -502,6 +560,10 @@ const setHeat_timeVal = () => { const setstoped_humiVal = () => { const val = parseInt(stoped_humi.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateStopedHumi(val) webSocketStore.sendCommandMsg(setSettingValJSON('stoped_humi', val)) showSuccessToast('设置成功') @@ -509,6 +571,10 @@ const setstoped_humiVal = () => { const setcontinued_humiVal = () => { const val = parseInt(continued_humi.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.updateContinuedHumi(val) webSocketStore.sendCommandMsg(setSettingValJSON('continued_humi', val)) showSuccessToast('设置成功') @@ -516,6 +582,10 @@ const setcontinued_humiVal = () => { const setSprayLiquidVal = () => { const val = parseInt(sprayLiquidConfigVal.value) + if (isNaN(val)) { + showFailToast('设置失败,请填写正确参数') + return + } settingStore.changeSprayLiquidConfigVal(val) webSocketStore.sendCommandMsg(setSettingValJSON('injection_pump_speed', val)) showSuccessToast('设置成功') diff --git a/src/store/modules/setting.js b/src/store/modules/setting.js index 29ca260..592ba26 100644 --- a/src/store/modules/setting.js +++ b/src/store/modules/setting.js @@ -10,19 +10,19 @@ export const useSettingStore = defineStore({ // 设置当前时间 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, // 所有setting的对象数据