123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- import { createStore } from 'vuex'
- export default createStore({
- state: {
- siteId: 1,//公共api请求参数->siteId
- Time_Data: [],//公共api请求参数->Time_Data
- queryType: '',//监控设备->数据报表api请求参数->queryType
- table_list: [
- {
- name: "电流",
- list: [
- { name: "A相电流", value: "Ia" },
- { name: "B相电流", value: "Ib" },
- { name: "C相电流", value: "Ic" },
- ],
- },
- {
- name: "功率",
- list: [
- { name: "A相有功功率 kW", value: "Pa" },
- { name: "A相无功功率 kVar", value: "Qa" },
- { name: "B相有功功率 kW", value: "Pb" },
- { name: "B相无功功率 kVar", value: "Qb" },
- { name: "C相有功功率 kW", value: "Pc" },
- { name: "C相无功功率 kVar", value: "Qc" },
- { name: "总有功功率 kW", value: "P" },
- { name: "总无功功率 kW", value: "Q" },
- { name: "实时需量 kW", value: "Demand" },
- ],
- },
- {
- name: "电度",
- list: [
- { name: "正有功电度 kWh", value: "Epp" },
- { name: "负有功电度 kWh", value: "Epn" },
- { name: "正无功电度 kvarh", value: "Eqp" },
- { name: "负无功电度 kvarh", value: "Eqn" },
- ],
- },
- {
- name: "电压",
- list: [
- { name: "A相电压 kV", value: "Ua" },
- { name: "B相电压 kV", value: "Ub" },
- { name: "C相电压 kV", value: "Uc" },
- { name: "回路电压 V", value: "Ul" },
- { name: "AB线电压 V", value: "Uab" },
- { name: "BC线电压 V", value: "Ubc" },
- { name: "CA线电压 V", value: "Uca" },
- ],
- },
- {
- name: "温度 ℃",
- list: [
- { name: "外接温度1", value: "T1" },
- { name: "外接温度2", value: "T2" },
- { name: "外接温度3", value: "T3" },
- { name: "外接温度4", value: "T4" },
- { name: "环境温度", value: "DeviceTemp" },
- ],
- },
- {
- name: "频率 Hz",
- list: [{ name: "频率", value: "F" }],
- },
- {
- name: "功率因数",
- list: [
- { name: "A相功率因数", value: "COSa" },
- { name: "B相功率因数", value: "COSb" },
- { name: "C相功率因数", value: "COSc" },
- { name: "功率因数", value: "COS" },
- ],
- },
- {
- name: "谐波电流有效值 A",
- list: [
- { name: "Ia总谐波电流", value: "IHa" },
- { name: "Ib总谐波电流", value: "IHa" },
- { name: "Ic总谐波电流", value: "IHc" },
- ],
- },
- {
- name: "通讯参数",
- list: [{ name: "设备信号强度", value: "SignalIntensity" }],
- },
- {
- name: "电压突变 次",
- list: [
- { name: "电压暂升次数", value: "Upt" },
- { name: "电压暂降次数", value: "Udt" },
- { name: "电压中断次数", value: "Ust" },
- ],
- },
- ],//数据报表->默认tabs数据
- se_tabs: [
- { label: '电流', name: "I" },
- { label: '功率', name: "P" },
- { label: '电度', name: "KWh" },
- { label: '电压', name: "V" },
- { label: '温度', name: "C" },
- { label: '频率', name: "HZ" },
- { label: '功率因数', name: "PS" },
- { label: '谐波电流有效值', name: "RMS" },
- { label: '通讯参数', name: "DDB" },
- { label: '电压突变', name: "VT" },
- ],
- run_off_Status: null,//运行状态统计->echarts->OFF次数分布和运行状态曲线图表 api信息存储
- timearr: [],//公共处理开始时间和结束时间中的时间段天数 值存储
- HistoricalCurve:null,//历史趋势->echarts->曲线图表 api信息存储
- },
- mutations: {
- /**
- * @公共api请求参数siteId
- * @param {*}} state
- * @param {*} val
- */
- increment(state, val) {
- state.siteId = val
- },
- /**
- * @数据报表 —> 多选按钮数据处理
- * @param {*} state
- * @param {*} checked_list
- */
- checkedCities_all(state, checked_list) {
- state.queryType = ''
- var checked = ''
- for (let i in checked_list) {
- checked_list[i] === "电流"
- ? checked = "I"
- : checked_list[i] === "功率"
- ? checked = "P"
- : checked_list[i] === "电度"
- ? checked = "KWh"
- : checked_list[i] === "电压"
- ? checked = "V"
- : checked_list[i] === "温度"
- ? checked = "C"
- : checked_list[i] === "频率"
- ? checked = "HZ"
- : checked_list[i] === "功率因数"
- ? checked = "PS"
- : checked_list[i] === "谐波电流有效值"
- ? checked = "RMS"
- : checked_list[i] === "通讯参数"
- ? checked = "DDB"
- : checked_list[i] === "电压突变"
- ? checked = "VT"
- : ""
- state.queryType += checked_list.length > 1 ? checked + "," : checked;
- }
- state.queryType = checked_list.length > 1 ? state.queryType.slice(0, state.queryType.length - 1) : state.queryType
- },
- /**
- * @历史趋势 -> echarts ->曲线图表 api信息存储
- */
- HistoricalCurve(state,data){
- state.HistoricalCurve = data
- },
- /**
- * @运行状态统计 -> echarts -> OFF次数分布和运行状态曲线图表 api信息存储
- */
- run_off_Status(state, data) {
- state.run_off_Status = data
- },
- /**
- * @公共处理时区方法
- */
- TimeAll_function(state, time) {
- state.Time_Data = []
- for (let i in time) {
- var Y = time[i].getFullYear() < 10 ? '0' + time[i].getFullYear() : time[i].getFullYear()
- var M = (time[i].getMonth() + 1) < 10 ? '0' + (time[i].getMonth() + 1) : (time[i].getMonth() + 1)
- var D = time[i].getDate() < 10 ? '0' + time[i].getDate() : time[i].getDate()
- var HH = time[i].getHours() < 10 ? '0' + time[i].getHours() : time[i].getHours()
- var MM = time[i].getMinutes() < 10 ? '0' + time[i].getMinutes() : time[i].getMinutes()
- var SS = time[i].getSeconds() < 10 ? '0' + time[i].getSeconds() : time[i].getSeconds()
- // console.log(Y + '-' + M + '-' + D + ' ' + HH + ':' + MM + ':' + SS)
- state.Time_Data.push(Y + '-' + M + '-' + D + ' ' + HH + ':' + MM + ':' + SS)
- }
- },
- /**
- * @公共处理开始时间和结束时间中的时间段天数
- * @param {*} state
- * @param {*} begin 开始时间和结束时间
- */
- getAll(state, begin) {
- let arr1 = begin[0].split("-");
- let arr2 = begin[1].split("-");
- let arr1_ = new Date();
- let arrTime = [];
- arr1_.setUTCFullYear(arr1[0], arr1[1] - 1, arr1[2]);
- let arr2_ = new Date();
- arr2_.setUTCFullYear(arr2[0], arr2[1] - 1, arr2[2]);
- let unixDb = arr1_.getTime();
- let unixDe = arr2_.getTime();
- for (let k = unixDb; k <= unixDe;) {
- arrTime.push(datetimeparse(k, "YY-MM-DD"));
- k = k + 24 * 60 * 60 * 1000;
- }
- state.timearr = arrTime
- // return arrTime;
- // 时间格式处理
- function datetimeparse(timestamp, format, prefix) {
- if (typeof timestamp == "string") {
- timestamp = Number(timestamp);
- }
- //转换时区
- let currentZoneTime = new Date(timestamp);
- let currentTimestamp = currentZoneTime.getTime();
- let offsetZone = currentZoneTime.getTimezoneOffset() / 60; //如果offsetZone>0是西区,西区晚
- let offset = null;
- //客户端时间与服务器时间保持一致,固定北京时间东八区。
- offset = offsetZone + 8;
- currentTimestamp = currentTimestamp + offset * 3600 * 1000;
- let newtimestamp = null;
- if (currentTimestamp) {
- if (currentTimestamp.toString().length === 13) {
- newtimestamp = currentTimestamp.toString();
- } else if (currentTimestamp.toString().length === 10) {
- newtimestamp = currentTimestamp + "000";
- } else {
- newtimestamp = null;
- }
- } else {
- newtimestamp = null;
- }
- let dateobj = newtimestamp
- ? new Date(parseInt(newtimestamp))
- : new Date();
- let YYYY = dateobj.getFullYear();
- let MM =
- dateobj.getMonth() > 8
- ? dateobj.getMonth() + 1
- : "0" + (dateobj.getMonth() + 1);
- let DD =
- dateobj.getDate() > 9 ? dateobj.getDate() : "0" + dateobj.getDate();
- let HH =
- dateobj.getHours() > 9 ? dateobj.getHours() : "0" + dateobj.getHours();
- let mm =
- dateobj.getMinutes() > 9
- ? dateobj.getMinutes()
- : "0" + dateobj.getMinutes();
- let ss =
- dateobj.getSeconds() > 9
- ? dateobj.getSeconds()
- : "0" + dateobj.getSeconds();
- let output = "";
- let separator = "/";
- if (format) {
- separator = format.match(/-/) ? "-" : "/";
- output += format.match(/yy/i) ? YYYY : "";
- output += format.match(/MM/)
- ? (output.length ? separator : "") + MM
- : "";
- output += format.match(/dd/i)
- ? (output.length ? separator : "") + DD
- : "";
- output += format.match(/hh/i) ? (output.length ? " " : "") + HH : "";
- output += format.match(/mm/) ? (output.length ? ":" : "") + mm : "";
- output += format.match(/ss/i) ? (output.length ? ":" : "") + ss : "";
- } else {
- output += YYYY + separator + MM + separator + DD;
- }
- output = prefix ? prefix + output : output;
- return newtimestamp ? output : "";
- }
- },
- }
- })
|