index.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. import { createStore } from 'vuex'
  2. export default createStore({
  3. state: {
  4. query: null,
  5. siteId: 1, //公共api请求参数->siteId
  6. Time_Data: [], //公共api请求参数->Time_Data
  7. timearr: [], //公共处理开始时间和结束时间中的时间段天数 值存储
  8. itemStyle: [{
  9. normal: {
  10. borderColor: "rgba(0,244,253,1)",
  11. borderWidth: 2,
  12. color: "rgba(6, 68, 83, 1)",
  13. lineStyle: {
  14. width: 2, //折线宽度
  15. color: "rgba(0,244,253,1)",
  16. },
  17. },
  18. },
  19. {
  20. normal: {
  21. borderColor: "rgba(253,143,0,1)",
  22. borderWidth: 2,
  23. color: "rgba(6, 68, 83, 1)",
  24. lineStyle: {
  25. width: 2, //折线宽度
  26. color: "rgba(253,143,0,1)",
  27. },
  28. },
  29. },
  30. {
  31. normal: {
  32. borderColor: "rgba(0,255,18,1)",
  33. borderWidth: 2,
  34. color: "rgba(6, 68, 83, 1)",
  35. lineStyle: {
  36. width: 2, //折线宽度
  37. color: "rgba(0,255,18,1)",
  38. },
  39. },
  40. },
  41. {
  42. normal: {
  43. borderColor: "rgba(0,255,230,1)",
  44. borderWidth: 2,
  45. color: "rgba(6, 68, 83, 1)",
  46. lineStyle: {
  47. width: 2, //折线宽度
  48. color: "rgba(0,255,230,1)",
  49. },
  50. },
  51. },
  52. {
  53. normal: {
  54. borderColor: "rgba(142,51,255,1)",
  55. borderWidth: 2,
  56. color: "rgba(6, 68, 83, 1)",
  57. lineStyle: {
  58. width: 2, //折线宽度
  59. color: "rgba(142,51,255,1)",
  60. },
  61. },
  62. },
  63. {
  64. normal: {
  65. borderColor: "rgba(77,200,120,1)",
  66. borderWidth: 2,
  67. color: "rgba(6, 68, 83, 1)",
  68. lineStyle: {
  69. width: 2, //折线宽度
  70. color: "rgba(77,200,120,1)",
  71. },
  72. },
  73. },
  74. {
  75. normal: {
  76. borderColor: "rgba(255,47,47,1)",
  77. borderWidth: 2,
  78. color: "rgba(6, 68, 83, 1)",
  79. lineStyle: {
  80. width: 2, //折线宽度
  81. color: "rgba(255,47,47,1)",
  82. },
  83. },
  84. },
  85. {
  86. normal: {
  87. borderColor: "rgba(70,100,255,1)",
  88. borderWidth: 2,
  89. color: "rgba(6, 68, 83, 1)",
  90. lineStyle: {
  91. width: 2, //折线宽度
  92. color: "rgba(70,100,255,1)",
  93. },
  94. },
  95. },
  96. {
  97. normal: {
  98. borderColor: "rgba(255,143,53,1)",
  99. borderWidth: 2,
  100. color: "rgba(6, 68, 83, 1)",
  101. lineStyle: {
  102. width: 2, //折线宽度
  103. color: "rgba(255,143,53,1)",
  104. },
  105. },
  106. },
  107. {
  108. normal: {
  109. borderColor: "rgba(150,150,50,1)",
  110. borderWidth: 2,
  111. color: "rgba(6, 68, 83, 1)",
  112. lineStyle: {
  113. width: 2, //折线宽度
  114. color: "rgba(150,150,50,1)",
  115. },
  116. },
  117. },
  118. {
  119. normal: {
  120. borderColor: "rgba(70,192,255,1)",
  121. borderWidth: 2,
  122. color: "rgba(6, 68, 83, 1)",
  123. lineStyle: {
  124. width: 2, //折线宽度
  125. color: "rgba(70,192,255,1)",
  126. },
  127. },
  128. },
  129. {
  130. normal: {
  131. borderColor: "rgba(20,99,100,1)",
  132. borderWidth: 2,
  133. color: "rgba(6, 68, 83, 1)",
  134. lineStyle: {
  135. width: 2, //折线宽度
  136. color: "rgba(20,99,100,1)",
  137. },
  138. },
  139. },
  140. ], //公共echarts图表样式
  141. Time_All: [], //公共时间 返回数组 -> 年月日时分秒 时间戳
  142. queryType: '', //设备监控--->数据报表api请求参数->queryType
  143. run_off_Status: null, //设备监控--->运行状态统计->echarts->OFF次数分布和运行状态曲线图表 api信息存储
  144. HistoricalCurve: null, //设备监控--->历史趋势->echarts->曲线图表 api信息存储
  145. se_defaultTime: [], //设备监控--->历史趋势时间选择器v-model
  146. th_defaultTime: [], //设备监控--->数据报表时间选择器v-model
  147. fh_defaultTime: [], //设备监控--->运行状态统计时间选择器v-model
  148. table_list: [{
  149. name: "电流",
  150. list: [
  151. { name: "A相电流", value: "Ia" },
  152. { name: "B相电流", value: "Ib" },
  153. { name: "C相电流", value: "Ic" },
  154. ],
  155. },
  156. {
  157. name: "功率",
  158. list: [
  159. { name: "A相有功功率 kW", value: "Pa" },
  160. { name: "A相无功功率 kVar", value: "Qa" },
  161. { name: "B相有功功率 kW", value: "Pb" },
  162. { name: "B相无功功率 kVar", value: "Qb" },
  163. { name: "C相有功功率 kW", value: "Pc" },
  164. { name: "C相无功功率 kVar", value: "Qc" },
  165. { name: "总有功功率 kW", value: "P" },
  166. { name: "总无功功率 kW", value: "Q" },
  167. { name: "实时需量 kW", value: "Demand" },
  168. ],
  169. },
  170. {
  171. name: "电度",
  172. list: [
  173. { name: "正有功电度 kWh", value: "Epp" },
  174. { name: "负有功电度 kWh", value: "Epn" },
  175. { name: "正无功电度 kvarh", value: "Eqp" },
  176. { name: "负无功电度 kvarh", value: "Eqn" },
  177. ],
  178. },
  179. {
  180. name: "电压",
  181. list: [
  182. { name: "A相电压 kV", value: "Ua" },
  183. { name: "B相电压 kV", value: "Ub" },
  184. { name: "C相电压 kV", value: "Uc" },
  185. { name: "回路电压 V", value: "Ul" },
  186. { name: "AB线电压 V", value: "Uab" },
  187. { name: "BC线电压 V", value: "Ubc" },
  188. { name: "CA线电压 V", value: "Uca" },
  189. ],
  190. },
  191. {
  192. name: "温度 ℃",
  193. list: [
  194. { name: "外接温度1", value: "T1" },
  195. { name: "外接温度2", value: "T2" },
  196. { name: "外接温度3", value: "T3" },
  197. { name: "外接温度4", value: "T4" },
  198. { name: "环境温度", value: "DeviceTemp" },
  199. ],
  200. },
  201. {
  202. name: "频率 Hz",
  203. list: [{ name: "频率", value: "F" }],
  204. },
  205. {
  206. name: "功率因数",
  207. list: [
  208. { name: "A相功率因数", value: "COSa" },
  209. { name: "B相功率因数", value: "COSb" },
  210. { name: "C相功率因数", value: "COSc" },
  211. { name: "功率因数", value: "COS" },
  212. ],
  213. },
  214. {
  215. name: "谐波电流有效值 A",
  216. list: [
  217. { name: "Ia总谐波电流", value: "IHa" },
  218. { name: "Ib总谐波电流", value: "IHa" },
  219. { name: "Ic总谐波电流", value: "IHc" },
  220. ],
  221. },
  222. {
  223. name: "通讯参数",
  224. list: [{ name: "设备信号强度", value: "SignalIntensity" }],
  225. },
  226. {
  227. name: "电压突变 次",
  228. list: [
  229. { name: "电压暂升次数", value: "Upt" },
  230. { name: "电压暂降次数", value: "Udt" },
  231. { name: "电压中断次数", value: "Ust" },
  232. ],
  233. },
  234. ], //设备监控--->数据报表->默认tabs数据
  235. se_tabs: [
  236. { label: '电流', name: "I" },
  237. { label: '功率', name: "P" },
  238. { label: '电度', name: "KWh" },
  239. { label: '电压', name: "V" },
  240. { label: '温度', name: "C" },
  241. { label: '频率', name: "HZ" },
  242. { label: '功率因数', name: "PS" },
  243. { label: '谐波电流有效值', name: "RMS" },
  244. { label: '通讯参数', name: "DDB" },
  245. { label: '电压突变', name: "VT" },
  246. ], //设备监控--->历史趋势->默认tabs数据
  247. trendIco: null, //事件告警--->事件告警统计->echarts->柱状图 api信息存储
  248. trendIco_state: null, //事件告警--->事件告警统计->select状态api信息存储
  249. trendIco_table: [
  250. { label: '发生时间', porp: 'soeTime' },
  251. { label: '告警描述', porp: 'measName' },
  252. { label: '设备', porp: 'deviceCode' },
  253. { label: '告警类型', porp: 'alarmName' },
  254. { label: '状态', porp: 'handlingStatus' },
  255. { label: '处理人', porp: 'handler' },
  256. { label: '处理时间', porp: 'handlingTime' },
  257. ], //事件告警--->事件告警统计->表格默认值存储
  258. trendIcoCount: null,
  259. },
  260. mutations: {
  261. /**
  262. * @公共api请求参数siteId
  263. * @param {*}} state
  264. * @param {*} val
  265. */
  266. increment(state, val) {
  267. state.siteId = val
  268. },
  269. /**
  270. * @数据报表 —> 多选按钮数据处理
  271. * @param {*} state
  272. * @param {*} checked_list
  273. */
  274. checkedCities_all(state, checked_list) {
  275. state.queryType = ''
  276. var checked = ''
  277. for (let i in checked_list) {
  278. checked_list[i] === "电流" ?
  279. checked = "I" :
  280. checked_list[i] === "功率" ?
  281. checked = "P" :
  282. checked_list[i] === "电度" ?
  283. checked = "KWh" :
  284. checked_list[i] === "电压" ?
  285. checked = "V" :
  286. checked_list[i] === "温度" ?
  287. checked = "C" :
  288. checked_list[i] === "频率" ?
  289. checked = "HZ" :
  290. checked_list[i] === "功率因数" ?
  291. checked = "PS" :
  292. checked_list[i] === "谐波电流有效值" ?
  293. checked = "RMS" :
  294. checked_list[i] === "通讯参数" ?
  295. checked = "DDB" :
  296. checked_list[i] === "电压突变" ?
  297. checked = "VT" :
  298. ""
  299. state.queryType += checked_list.length > 1 ? checked + "," : checked;
  300. }
  301. state.queryType = checked_list.length > 1 ? state.queryType.slice(0, state.queryType.length - 1) : state.queryType
  302. },
  303. /**
  304. * @历史趋势 -> echarts ->曲线图表 api信息存储
  305. */
  306. HistoricalCurve(state, data) {
  307. state.HistoricalCurve = data
  308. },
  309. /**
  310. * @公共处理时区方法
  311. */
  312. TimeAll_function(state, time) {
  313. state.Time_Data = []
  314. for (let i in time) {
  315. var Y = time[i].getFullYear() < 10 ? '0' + time[i].getFullYear() : time[i].getFullYear()
  316. var M = (time[i].getMonth() + 1) < 10 ? '0' + (time[i].getMonth() + 1) : (time[i].getMonth() + 1)
  317. var D = time[i].getDate() < 10 ? '0' + time[i].getDate() : time[i].getDate()
  318. var HH = time[i].getHours() < 10 ? '0' + time[i].getHours() : time[i].getHours()
  319. var MM = time[i].getMinutes() < 10 ? '0' + time[i].getMinutes() : time[i].getMinutes()
  320. var SS = time[i].getSeconds() < 10 ? '0' + time[i].getSeconds() : time[i].getSeconds()
  321. // console.log(Y + '-' + M + '-' + D + ' ' + HH + ':' + MM + ':' + SS)
  322. state.Time_Data.push(Y + '-' + M + '-' + D + ' ' + HH + ':' + MM + ':' + SS)
  323. }
  324. },
  325. /**
  326. * @公共处理开始时间和结束时间中的时间段天数
  327. * @param {*} state
  328. * @param {*} begin 开始时间和结束时间
  329. */
  330. getAll(state, begin) {
  331. let arr1 = begin[0].split("-");
  332. let arr2 = begin[1].split("-");
  333. let arr1_ = new Date();
  334. let arrTime = [];
  335. arr1_.setUTCFullYear(arr1[0], arr1[1] - 1, arr1[2]);
  336. let arr2_ = new Date();
  337. arr2_.setUTCFullYear(arr2[0], arr2[1] - 1, arr2[2]);
  338. let unixDb = arr1_.getTime();
  339. let unixDe = arr2_.getTime();
  340. for (let k = unixDb; k <= unixDe;) {
  341. arrTime.push(datetimeparse(k, "YY-MM-DD"));
  342. k = k + 24 * 60 * 60 * 1000;
  343. }
  344. state.timearr = arrTime
  345. // return arrTime;
  346. // 时间格式处理
  347. function datetimeparse(timestamp, format, prefix) {
  348. if (typeof timestamp == "string") {
  349. timestamp = Number(timestamp);
  350. }
  351. //转换时区
  352. let currentZoneTime = new Date(timestamp);
  353. let currentTimestamp = currentZoneTime.getTime();
  354. let offsetZone = currentZoneTime.getTimezoneOffset() / 60; //如果offsetZone>0是西区,西区晚
  355. let offset = null;
  356. //客户端时间与服务器时间保持一致,固定北京时间东八区。
  357. offset = offsetZone + 8;
  358. currentTimestamp = currentTimestamp + offset * 3600 * 1000;
  359. let newtimestamp = null;
  360. if (currentTimestamp) {
  361. if (currentTimestamp.toString().length === 13) {
  362. newtimestamp = currentTimestamp.toString();
  363. } else if (currentTimestamp.toString().length === 10) {
  364. newtimestamp = currentTimestamp + "000";
  365. } else {
  366. newtimestamp = null;
  367. }
  368. } else {
  369. newtimestamp = null;
  370. }
  371. let dateobj = newtimestamp ?
  372. new Date(parseInt(newtimestamp)) :
  373. new Date();
  374. let YYYY = dateobj.getFullYear();
  375. let MM =
  376. dateobj.getMonth() > 8 ?
  377. dateobj.getMonth() + 1 :
  378. "0" + (dateobj.getMonth() + 1);
  379. let DD =
  380. dateobj.getDate() > 9 ? dateobj.getDate() : "0" + dateobj.getDate();
  381. let HH =
  382. dateobj.getHours() > 9 ? dateobj.getHours() : "0" + dateobj.getHours();
  383. let mm =
  384. dateobj.getMinutes() > 9 ?
  385. dateobj.getMinutes() :
  386. "0" + dateobj.getMinutes();
  387. let ss =
  388. dateobj.getSeconds() > 9 ?
  389. dateobj.getSeconds() :
  390. "0" + dateobj.getSeconds();
  391. let output = "";
  392. let separator = "/";
  393. if (format) {
  394. separator = format.match(/-/) ? "-" : "/";
  395. output += format.match(/yy/i) ? YYYY : "";
  396. output += format.match(/MM/) ?
  397. (output.length ? separator : "") + MM :
  398. "";
  399. output += format.match(/dd/i) ?
  400. (output.length ? separator : "") + DD :
  401. "";
  402. output += format.match(/hh/i) ? (output.length ? " " : "") + HH : "";
  403. output += format.match(/mm/) ? (output.length ? ":" : "") + mm : "";
  404. output += format.match(/ss/i) ? (output.length ? ":" : "") + ss : "";
  405. } else {
  406. output += YYYY + separator + MM + separator + DD;
  407. }
  408. output = prefix ? prefix + output : output;
  409. return newtimestamp ? output : "";
  410. }
  411. },
  412. /**
  413. * @公共echarts图表下载
  414. */
  415. getConnectedDataURL(state, refs) {
  416. state || refs
  417. var url = refs[0].getConnectedDataURL({
  418. pixelRatio: 15,
  419. backgroundColor: "black",
  420. excludeComponents: ["toolbox"],
  421. type: "png",
  422. });
  423. var $a = document.createElement("a");
  424. var type = "png";
  425. //图片名称
  426. $a.download = refs[1] + "." + type;
  427. $a.target = "_blank";
  428. $a.href = url;
  429. if (typeof MouseEvent === "function") {
  430. var evt = new MouseEvent("click", {
  431. view: window,
  432. bubbles: true,
  433. cancelable: false,
  434. });
  435. $a.dispatchEvent(evt);
  436. }
  437. },
  438. /**
  439. * @公共时间 返回数组 -> 年月日时分秒 时间戳
  440. */
  441. getTimeAll(state) {
  442. const time = new Date();
  443. const Y = time.getFullYear(); //年
  444. const M = time.getMonth(); //月
  445. const D = time.getDate(); //日
  446. const HH = time.getHours(); //时,
  447. const MM = time.getMinutes(); //分
  448. const SS = time.getSeconds(); //秒
  449. const timestamp = new Date().getTime(); //时间戳
  450. state.Time_All = [Y, M, D, HH, MM, SS, timestamp]
  451. state.se_defaultTime = [new Date(Y, M, D, 0, 0, 0), new Date()] //设备监控--->历史趋势时间选择器v-model
  452. state.th_defaultTime = [new Date(Y, M, D, 0, 0, 0), new Date()] //设备监控--->数据报表时间选择器v-model
  453. state.fh_defaultTime = [new Date(Y, M, 1, 0, 0, 0), new Date()] //设备监控--->运行状态统计时间选择器v-model //概览 -> 告警统计折线图
  454. },
  455. }
  456. })