|
|
import { defineStore } from 'pinia' export const useSettingStore = defineStore({ id: 'setting', // id必填,且需要唯一
// state
state: () => { return { // 设置当前日期
currentDate: [], // 设置当前时间
currentTime: [], // 设置加液泵的参数
addLiquidConfigVal: 0, // 设置喷液泵的参数
sprayLiquidConfigVal: 0, max_humidity: 0, continued_satur: 0, stoped_satur: 0, continued_gs: 0, stoped_gs: 0, // 首屏初始化
initLoading: true, // 所有setting的对象数据
allSettingList: [], } }, // 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', )[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 }, }, })
|