From 4df385c0d12fb95b3101f750a6b7a2d41c70e29d Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Mon, 14 Aug 2023 23:42:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Setting/components/Device.vue | 51 +++++++++++++++++++++++++--- src/store/modules/setting.js | 41 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/components/Setting/components/Device.vue b/src/components/Setting/components/Device.vue index f562e6e..43d0c1f 100644 --- a/src/components/Setting/components/Device.vue +++ b/src/components/Setting/components/Device.vue @@ -139,15 +139,56 @@ const setAddliquidVal = () => { showSuccessToast('设置成功') } -const setStopedGsVal = () => {} +const setStopedGsVal = () => { + const val = parseInt(stoped_gs.value.substring(0, stoped_gs.value.length - 2)) + settingStore.updateStopedGs(val) + webSocketStore.sendCommandMsg(setSettingValJSON('stoped_gs', stoped_gs.value)) + showSuccessToast('设置成功') +} -const setcontinuedGsVal = () => {} +const setcontinuedGsVal = () => { + const val = parseInt( + continued_gs.value.substring(0, continued_gs.value.length - 2), + ) + settingStore.updateContinuedGs(val) + webSocketStore.sendCommandMsg( + setSettingValJSON('continued_gs', continued_gs.value), + ) + showSuccessToast('设置成功') +} -const setstopedSaturVal = () => {} +const setstopedSaturVal = () => { + const val = parseInt( + stoped_satur.value.substring(0, stoped_satur.value.length - 2), + ) + settingStore.updateStopedSatur(val) + webSocketStore.sendCommandMsg( + setSettingValJSON('stoped_satur', stoped_satur.value), + ) + showSuccessToast('设置成功') +} -const setContinuedSaturVal = () => {} +const setContinuedSaturVal = () => { + const val = parseInt( + continued_satur.value.substring(0, continued_satur.value.length - 2), + ) + settingStore.updateContinuedSatur(val) + webSocketStore.sendCommandMsg( + setSettingValJSON('continued_satur', continued_satur.value), + ) + showSuccessToast('设置成功') +} -const setMaxHumidityVal = () => {} +const setMaxHumidityVal = () => { + const val = parseInt( + max_humidity.value.substring(0, max_humidity.value.length - 2), + ) + settingStore.updateMaxHumidity(val) + webSocketStore.sendCommandMsg( + setSettingValJSON('max_humidity', max_humidity.value), + ) + showSuccessToast('设置成功') +} const setSprayLiquidVal = () => { const val = parseInt( diff --git a/src/store/modules/setting.js b/src/store/modules/setting.js index 15c3535..2d4156b 100644 --- a/src/store/modules/setting.js +++ b/src/store/modules/setting.js @@ -12,6 +12,11 @@ export const useSettingStore = defineStore({ addLiquidConfigVal: 0, // 设置喷液泵的参数 sprayLiquidConfigVal: 0, + max_humidity: 0, + continued_satur: 0, + stoped_satur: 0, + continued_gs: 0, + stoped_gs: 0, // 首屏初始化 initLoading: true, // 所有setting的对象数据 @@ -20,7 +25,42 @@ export const useSettingStore = defineStore({ }, // actions actions: { + updateMaxHumidity(max_humidity) { + this.max_humidity = max_humidity + }, + updateContinuedSatur(continued_satur) { + this.continued_satur = continued_satur + }, + updateStopedSatur(stoped_satur) { + this.stoped_satur = stoped_satur + }, + updateContinuedGs(continued_gs) { + this.continued_gs = continued_gs + }, + updateStopedGs(stoped_gs) { + this.stoped_gs = stoped_gs + }, updateAllSettingList(allSettingList) { + const stoped_gsObj = allSettingList.filter( + item => item.name == 'stoped_gs', + )[0] + const continued_gsObj = allSettingList.filter( + item => item.name == 'continued_gs', + )[0] + const stoped_saturObj = allSettingList.filter( + item => item.name == 'stoped_satur', + )[0] + const continued_saturObj = allSettingList.filter( + item => item.name == 'continued_satur', + )[0] + const max_humidityObj = allSettingList.filter( + item => item.name == 'max_humidity', + )[0] + this.max_humidity = max_humidityObj.val + this.continued_satur = continued_saturObj.val + this.stoped_satur = stoped_saturObj.val + this.continued_gs = continued_gsObj.val + this.stoped_gs = stoped_gsObj.val // 对当前数组进行处理 赋予给泵参数 const addLiquid = allSettingList.filter( item => item.name == 'drainage_pump_speed', @@ -28,6 +68,7 @@ export const useSettingStore = defineStore({ const sprayLiquid = allSettingList.filter( item => item.name == 'injection_pump_speed', )[0] + this.addLiquidConfigVal = addLiquid.val this.sprayLiquidConfigVal = sprayLiquid.val this.allSettingList = allSettingList