/*
* @FilePath: \wwwd:\code\screenFront\src\store\module\InPlantProducts.ts
* @Author: 王路平
* @文件版本: V1.0.0
* @Date: 2023-02-27 16:44:35
* @Description:
*
* 版权信息 : 2023 by ${再登软件}, All Rights Reserved.
*/
import { defineStore } from "pinia";
import { Names } from "@/store/storeName";
export const useInPlantProductsStore = defineStore(Names.InPlantProducts, {
// 使用方式
// const Index= useIndexStore()
// 1、Index.{数据}++
// 2、Index.$patch({数据:??})
// 3、Index.$patch((state)=>{ state.数据=??})
// 4、通过action修改
state: () => {
return {
DeviceSensorinfo:null,
DeviceInfo:null,
PublicData:{
rackNumber:''
},
gatewayOfCorps:null,
devlist:null,
newPageData:null
};
},
//computed 修改一些值
//需要使用return将数据抛出
//getters内可相互使用计算结果
//使用时可直接放入标签内
Index.方法()
getters: {},
//methods 可同步/异步,提交state
//actions内获取state数据使用this
// 使用方式
// 1、Index.方法()
//异步方法需要添加async和await
actions: {
changePublicData(name:string,value:any){
this.PublicData[name]=value
},
changegatewayOfCorps(val:any){
this.gatewayOfCorps=val
},
setDevList(val:any){
this.devlist=val
},
changeDevList(val:any){
// this.devlist=val
if(!this.devlist)return
val.forEach(res=>{
this.devlist.forEach(ele=>{
if(res.id==ele.id){
ele.deviceStatus =res.deviceStatus
ele.manualProgress =res.manualProgress
}
})
})
},
setnewPageData(val:any){
this.newPageData={}
this.newPageData.devInfo=val.devInfo
this.newPageData.devDetail=val.devDetail
this.newPageData.imgTip=val.imgTip
this.newPageData.axleList=val.axleList
this.newPageData.LedList=val.LedList
// console.log(this.newPageData.devDetail);
// this.newPageData.devinfo.unshift({name:'设备名称',value:val.productName})
}
},
});