|
|
import { defineStore } from 'pinia' import moment from 'moment' export const useSettingStore = defineStore({ id: 'setting', // id必填,且需要唯一
// state
state: () => { return { // 设置当前日期
currentDate: moment().format('YYYY-MM-DD').split('-'), // 设置当前时间
currentTime: moment().utcOffset(8).format('HH:mm').split(':'), // 设置加液泵的参数
addLiquidConfigVal: '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', // 消毒继续相对湿度
continued_humi: '0', // 首屏初始化
initLoading: true, // 所有setting的对象数据
allSettingList: [], deviceIp: '127.0.0.1', chargingPumpRPM: 0, sprinklerPumpRPM: 0, sprinklerPumpGPM: 0, } }, // actions
actions: { updateSprinklerPumpGPM(sprinklerPumpGPM) { this.sprinklerPumpGPM = sprinklerPumpGPM }, updateChargingPumpRPM(chargingPumpRPM) { this.chargingPumpRPM = chargingPumpRPM }, updateSprinklerPumpRPM(sprinklerPumpRPM) { this.sprinklerPumpRPM = sprinklerPumpRPM }, updateStopedHumi(stoped_humi) { this.stoped_humi = stoped_humi }, updateContinuedHumi(continued_humi) { this.continued_humi = continued_humi }, updatePre_heat_time_s(pre_heat_time_s) { this.pre_heat_time_s = pre_heat_time_s }, updateDeviceIp(deviceIp) { this.deviceIp = deviceIp }, 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_humiObj = allSettingList.filter( item => item.name == 'stoped_humi', )[0] const continued_humiObj = allSettingList.filter( item => item.name == 'continued_humi', )[0] this.stoped_humi = stoped_humiObj.val this.continued_humi = continued_humiObj.val 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] const pre_heat_time_sOBj = allSettingList.filter( item => item.name == 'pre_heat_time_s', )[0] this.pre_heat_time_s = pre_heat_time_sOBj.val 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', )[0] const sprayLiquid = allSettingList.filter( item => item.name == 'injection_pump_speed', )[0]
this.addLiquidConfigVal = addLiquid.val this.sprayLiquidConfigVal = sprayLiquid.val this.allSettingList = allSettingList }, updateInitLoading() { this.initLoading = false }, updateCurrentDate(currentDate) { this.currentDate = currentDate }, updateCurrentTime(currentTime) { this.currentTime = currentTime }, changeAddLiquidConfigVal(val) { this.addLiquidConfigVal = val }, changeSprayLiquidConfigVal(val) { this.sprayLiquidConfigVal = val }, }, })
|