154 lines
5.6 KiB
TypeScript
154 lines
5.6 KiB
TypeScript
|
/*
|
||
|
* @FilePath: \wwwd:\code\screenFront\src\store\moduleSocketjixie.ts
|
||
|
* @Author: 王路平
|
||
|
* @文件版本: V1.0.0
|
||
|
* @Date: 2023-02-06 15:58:13
|
||
|
* @Description:
|
||
|
*
|
||
|
* 版权信息 : 2023 by ${再登软件}, All Rights Reserved.
|
||
|
*/
|
||
|
import { defineStore } from "pinia";
|
||
|
import {Names} from '@/store/storeName'
|
||
|
import {gettime,clacendTime} from "@/utils/time"
|
||
|
export const useSocketStore = defineStore(Names.socketjixiefenchang,{
|
||
|
// 使用方式
|
||
|
// const Index= useIndexStore()
|
||
|
// 1、Index.{数据}++
|
||
|
// 2、Index.$patch({数据:??})
|
||
|
// 3、Index.$patch((state)=>{ state.数据=??})
|
||
|
// 4、通过action修改
|
||
|
state:()=>{
|
||
|
return{
|
||
|
newVerticalNum: [
|
||
|
{
|
||
|
"type": "TVOC",
|
||
|
"icon": "icon-TVOC-Outlined",
|
||
|
"title": "TVOC检测",
|
||
|
"limit": "0.5",
|
||
|
"unit": "mg/m³",
|
||
|
"value": [
|
||
|
{
|
||
|
"name": "精饰车间TVOC/甲醛监测传感器",
|
||
|
"val": null,
|
||
|
"type": "TVOC_CH2O",
|
||
|
"field": "TVOC"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"type": "Smoke",
|
||
|
"icon": "icon-yanwubaojingqi",
|
||
|
"title": "烟雾检测",
|
||
|
"limit": "100",
|
||
|
"unit": null,
|
||
|
"value": [
|
||
|
{
|
||
|
"name": "精饰车间烟雾传感器",
|
||
|
"val": null,
|
||
|
"type": "Smoke",
|
||
|
"field": "Smoke_Reg"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"type": "Methane",
|
||
|
"icon": "icon-ranqi",
|
||
|
"title": "燃气检测",
|
||
|
"limit": "0",
|
||
|
"unit": null,
|
||
|
"value": [
|
||
|
{
|
||
|
"name": "精饰车间燃气监测",
|
||
|
"val": null,
|
||
|
"type": "Methane",
|
||
|
"field": "Methane_Reg"
|
||
|
},
|
||
|
{
|
||
|
"name": "食堂燃气监测",
|
||
|
"val": null,
|
||
|
"type": "Methane",
|
||
|
"field": "Methane_Reg"
|
||
|
},
|
||
|
{
|
||
|
"name": "锅炉房燃气监测",
|
||
|
"val": null,
|
||
|
"type": "Methane",
|
||
|
"field": "Methane_Reg"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"type": "CH2O",
|
||
|
"icon": "icon-app_icons--",
|
||
|
"title": "甲醛检测",
|
||
|
"limit": "0.08",
|
||
|
"unit": "mg/m³",
|
||
|
"value": [
|
||
|
{
|
||
|
"name": "精饰车间TVOC/甲醛监测传感器",
|
||
|
"val": null,
|
||
|
"type": "TVOC_CH2O",
|
||
|
"field": "CH2O"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"type": "FIRE",
|
||
|
"icon": "icon-weibiaoti1",
|
||
|
"title": "明火检测",
|
||
|
"limit": "0",
|
||
|
"unit": null,
|
||
|
"value": [
|
||
|
{
|
||
|
"name": "精饰车间火花传感器",
|
||
|
"val": null,
|
||
|
"type": "FIRE",
|
||
|
"field": "Fire_Reg"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
//computed 修改一些值
|
||
|
//需要使用return将数据抛出
|
||
|
//getters内可相互使用计算结果
|
||
|
//使用时可直接放入标签内<div>Index.方法()</div>
|
||
|
getters:{
|
||
|
|
||
|
},
|
||
|
actions:{
|
||
|
//设置新的安全检测数据
|
||
|
setNewVerticalNum(val) {
|
||
|
this.newVerticalNum = val
|
||
|
},
|
||
|
//更新 新的安全检测数据
|
||
|
changeNewVerticalNum(val) {
|
||
|
//{"type":"Smoke","data":{"name":"精饰车间烟雾传感器","val":"100"}}
|
||
|
let pIndex = this.newVerticalNum.findIndex(item => item.type == val.type)
|
||
|
let cIndex = null
|
||
|
if (pIndex != -1) {
|
||
|
cIndex = this.newVerticalNum[pIndex].value.findIndex(item => item.devId == val.data.devId)
|
||
|
}
|
||
|
if (cIndex != -1) {
|
||
|
if (val.data.val>this.newVerticalNum[pIndex].limit) {
|
||
|
|
||
|
let now = new Date().getTime()
|
||
|
if (this.newVerticalNum[pIndex].value[cIndex].date == null) {
|
||
|
this.newVerticalNum[pIndex].value[cIndex].date = gettime()
|
||
|
this.newVerticalNum[pIndex].value[cIndex].time = now
|
||
|
}
|
||
|
|
||
|
let time = this.newVerticalNum[pIndex].value[cIndex].time
|
||
|
|
||
|
this.newVerticalNum[pIndex].value[cIndex].continuous = clacendTime(now,time)
|
||
|
} else {
|
||
|
this.newVerticalNum[pIndex].value[cIndex].date = null
|
||
|
this.newVerticalNum[pIndex].value[cIndex].time = null
|
||
|
}
|
||
|
this.newVerticalNum[pIndex].value[cIndex].val = val.data.val
|
||
|
this.newVerticalNum[pIndex].value[cIndex].status = true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|