allBoosterStation.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. <template>
  2. <div class="bodyy">
  3. <div
  4. type="border-card"
  5. style="width: 100%; height: 100%;"
  6. >
  7. <div
  8. class="syzDetailsPaneItem"
  9. v-for="(item, index) in syzArray"
  10. :key="index"
  11. :name="item.id"
  12. >
  13. <template>
  14. <span v-if="pageshowMode % 2">
  15. <el-badge is-dot v-if="item.isWarning === '1'">
  16. <span>{{ item.name }}</span>
  17. </el-badge>
  18. <span v-else>{{ item.name }}</span>
  19. </span>
  20. <span v-else>
  21. <el-badge is-dot v-if="item.isWarning === '1'">
  22. <span>{{ item.name }}</span>
  23. </el-badge>
  24. <span v-else>{{ item.name }}</span>
  25. </span>
  26. </template>
  27. <div class="buttonGroup" v-if="item.id === 'all'">
  28. <el-button-group>
  29. <el-button type="plain" size="small" @click="changeHeight('D')"
  30. :class="allHeight === 'D' ? 'showSty' : ''">大图标
  31. </el-button>
  32. <el-button type="plain" size="small" @click="changeHeight('Z')"
  33. :class="allHeight === 'Z' ? 'showSty' : ''">中图标
  34. </el-button>
  35. <el-button type="plain" size="small" @click="changeHeight('X')"
  36. :class="allHeight === 'X' ? 'showSty' : ''">小图标
  37. </el-button>
  38. </el-button-group>
  39. </div>
  40. <div v-if="item.id === 'all'" :style="allpageHeight"
  41. style="width: 100%;display: inline-block;overflow-y:auto">
  42. <div v-for="(item, index) in allSvgMsgData" :key="index" :style="getStyle(allHeight)">
  43. <div class="showAllSvgMsg" @dblclick="dblgetSvgDataFn(item.wpsid)" :class="getWarnstyle(item)">
  44. <div class="showAllSvgMsg_top" v-html="item.msg"></div>
  45. <div class="showAllSvgMsg_bot">
  46. <span>{{ item.name }}</span>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. import api from "@api/stateMonitor/index.js";
  57. export default {
  58. props: {
  59. activeTabStation: {
  60. type: String,
  61. default: "",
  62. },
  63. },
  64. components: {
  65. },
  66. data() {
  67. return {
  68. activeTab: this.$store.state.activeTab,
  69. svgVisible: true,
  70. audio: null,
  71. timmer: null,
  72. syzArray: [],
  73. pageshowMode: 0,
  74. svgMsg: '',
  75. loading: false,
  76. allTagidArr: [],
  77. starTimer: null,
  78. allTagsMS: {},
  79. allrefreshData: {},
  80. allConditions: {},
  81. onlytag: {},
  82. allSvgMsgData: [],
  83. allHeight: 'D',
  84. allWarnData: [],
  85. starTimerWarn: null,
  86. numm: 0,
  87. stationSort: []
  88. };
  89. },
  90. computed: {
  91. pageHeight() {
  92. return {
  93. 'height': document.documentElement.clientHeight - 60 + 'px'
  94. }
  95. },
  96. allpageHeight() {
  97. return {
  98. 'height': document.documentElement.clientHeight - 200 + 'px'
  99. }
  100. },
  101. },
  102. created() {
  103. this.opened()
  104. },
  105. updated() {
  106. },
  107. methods: {
  108. // 获取升压站报警数据
  109. getSyzWarnData() {
  110. api.alarmFault().then((res) => {
  111. if (res && res.data) {
  112. let datas = res.data
  113. let arr = []
  114. datas.forEach(it => {
  115. if (it.rank === '5' && it.category1 === 'SYZ') {
  116. arr.push(it.category2)
  117. }
  118. })
  119. this.allWarnData = this.unique(arr)
  120. }
  121. })
  122. },
  123. unique(arr) {
  124. let newArr = []
  125. for (let i = 0; i < arr.length; i++) {
  126. if (newArr.indexOf(arr[i]) === -1) {
  127. newArr.push(arr[i])
  128. }
  129. }
  130. return newArr
  131. },
  132. getWarnstyle(item) {
  133. let showWarn = ''
  134. this.allWarnData.forEach(it => {
  135. if (it === item.id) {
  136. showWarn = 'warningMaskNew'
  137. }
  138. })
  139. return showWarn
  140. },
  141. getStyle(type) {
  142. let num = null
  143. let num1 = null
  144. let num2 = null
  145. if (type === 'D') {
  146. return {
  147. 'width': '33.3%',
  148. 'float': 'left',
  149. 'height': '400px'
  150. }
  151. } else if (type === 'Z') {
  152. num = parseInt(this.allSvgMsgData.length / 4)
  153. num1 = this.allSvgMsgData.length % 4
  154. num2 = num1 > 0 ? num + 1 : num
  155. return {
  156. 'width': '25%',
  157. 'float': 'left',
  158. 'height': (document.documentElement.clientHeight - 200) / num2 + 'px'
  159. }
  160. } else {
  161. num = parseInt(this.allSvgMsgData.length / 5)
  162. num1 = this.allSvgMsgData.length % 5
  163. num2 = num1 > 0 ? num + 1 : num
  164. return {
  165. 'width': '20%',
  166. 'float': 'left',
  167. 'height': (document.documentElement.clientHeight - 200) / num2 + 'px'
  168. }
  169. }
  170. },
  171. changeHeight(type) {
  172. this.allHeight = type
  173. },
  174. getAllStationtab() {
  175. let obj = {
  176. id: 'all',
  177. name: '全部'
  178. }
  179. api.getAllStationTab().then((res) => {
  180. if (res && res.data) {
  181. res.data.unshift(obj)
  182. this.syzArray = res.data
  183. this.activeTab = res.data[0].id
  184. if (this.activeTab === 'all') {
  185. let allMsg = res.data
  186. this.allSvgMsgData = []
  187. this.stationSort = []
  188. allMsg.forEach(it => {
  189. if (it.id !== 'all') {
  190. this.stationSort.push(it.name)
  191. this.getallSvgDataFn(it.id, it.name,it.windpowerstationId)
  192. }
  193. })
  194. // window.sessionStorage.setItem('allSvgData', [])
  195. console.log('allSvgMsgData', this.allSvgMsgData)
  196. // console.log('stationSort', this.stationSort)
  197. // console.log('allMsg', allMsg)
  198. }
  199. }
  200. })
  201. },
  202. // 获取所有升压站数据
  203. getallSvgDataFn(id, name,wpsid) {
  204. let params = {
  205. id: id
  206. }
  207. api.getSvgData(params).then((res) => {
  208. let str = ''
  209. // str = res.data.substring(res.data.indexOf('<svg'))
  210. str = res
  211. str = str.replace('<svg', '<svg viewBox="0 -100 1900 1260"')
  212. let obj = {
  213. id: id,
  214. name: name,
  215. wpsid: wpsid,
  216. msg: str
  217. }
  218. this.allSvgMsgData.push(obj)
  219. if (this.allSvgMsgData.length === this.stationSort.length) {
  220. let sortArr = []
  221. this.stationSort.forEach(itc => {
  222. this.allSvgMsgData.forEach(itb => {
  223. if (itc === itb.name) {
  224. sortArr.push(itb)
  225. }
  226. })
  227. })
  228. this.allSvgMsgData = sortArr
  229. }
  230. })
  231. },
  232. // 获取升压站数据
  233. getSvgDataFn(val) {
  234. this.svgMsg = ''
  235. this.loading = true
  236. let params = {
  237. id: val
  238. }
  239. api.getSvgData(params).then((res) => {
  240. if (res && res.data) {
  241. let str = ''
  242. str = res.data.substring(res.data.indexOf('<svg'))
  243. str = str.replace('<svg', '<svg viewBox="0 0 1900 1260"')
  244. this.svgMsg = str
  245. let html = document.getElementById('svg')
  246. let svg1 = document.getElementsByTagName('svg')
  247. this.$nextTick(() => {
  248. if (svg1) {
  249. let allTags = []
  250. let allTagsxc = []
  251. let status = ['g', 'text', 'rect', 'line', 'polyline', 'circle', 'ellipse', 'polygon']
  252. status.forEach(it => {
  253. let allgs = []
  254. allgs = document.querySelectorAll(it);
  255. allTags.push(allgs)
  256. })
  257. allTags = [...allTags[0], ...allTags[1], ...allTags[2], ...allTags[3], ...allTags[4], ...allTags[5], ...allTags[6], ...allTags[7]]
  258. allTags.forEach((it) => {
  259. if (it.getAttribute("tagid")) {
  260. allTagsxc.push(it);
  261. }
  262. });
  263. console.log('allTags222=>', allTagsxc)
  264. this.allTagidArr = allTagsxc
  265. this.getSvgInfo()
  266. }
  267. console.log('html111=>', html)
  268. })
  269. this.loading = false
  270. }
  271. })
  272. },
  273. // 获取触发器
  274. getSvgInfo() {
  275. let params = {
  276. id: this.activeTab
  277. }
  278. api.getAllStationSvgInfo(params).then((res) => {
  279. if (res && res.data) {
  280. if (res.data.tags) {
  281. let strarr = []
  282. let str = ''
  283. for (let i in res.data.tags) {
  284. strarr.push(res.data.tags[i].tag)
  285. }
  286. str = strarr.join(',')
  287. this.allTagsMS = res.data.tags
  288. this.allConditions = res.data.conditions
  289. // this.getrefreshData(str)
  290. this.starTimer = setInterval(() => {
  291. this.getrefreshData(str)
  292. }, 1000)
  293. }
  294. console.log('SvgInfo333=>', res)
  295. }
  296. })
  297. },
  298. // 获取根盾数据
  299. getrefreshData(val) {
  300. api.refreshData(val).then((res) => {
  301. if (res && res.data) {
  302. this.allrefreshData = res.data
  303. this.refreshDataFn(this.allTagsMS)
  304. }
  305. console.log('refreshData444=>', res)
  306. })
  307. },
  308. // 刷新数据
  309. refreshDataFn(datas) {
  310. for (let it in datas) {
  311. let tagId = datas[it];
  312. this.toRefreshFn(it, tagId);
  313. }
  314. },
  315. // 刷新自定义组件
  316. toRefreshFn(val, data) {
  317. var tag = this.allrefreshData[data.tag];
  318. if (!tag) return;
  319. this.allTagidArr.forEach(it => {
  320. this.onlytag = {}
  321. if (it.attributes.tagid) {
  322. if (val === it.attributes.tagid.value) {
  323. this.onlytag = it
  324. if (it.nodeName === 'polyline') {
  325. console.log('onlyTag666', this.onlytag)
  326. }
  327. if (it.nodeName !== 'text') {
  328. if (this.onlytag.attributes.csid) {
  329. let csid = this.onlytag.attributes.csid.value.split(';')
  330. csid.forEach(ic => {
  331. if (ic) {
  332. if (!this.allConditions[ic].isBinding) {
  333. let num = parseInt(this.allConditions[ic].value) === 0 ? '0' : parseInt(this.allConditions[ic].value)
  334. if (num) {
  335. let num2 = tag.value === 0 ? '0' : tag.value
  336. if (num === num2) {
  337. this.onlytag.setAttribute(this.allConditions[ic].property, this.allConditions[ic].propertyValue)
  338. return
  339. }
  340. }
  341. } else {
  342. this.onlytag.setAttribute(this.allConditions[ic].property, this.allConditions[ic].propertyValue)
  343. }
  344. }
  345. })
  346. }
  347. } else {
  348. this.onlytag.textContent = tag.value.toFixed(2)
  349. }
  350. }
  351. }
  352. })
  353. },
  354. // '全部'界面双击事件
  355. dblgetSvgDataFn(name) {
  356. this.activeTab = name
  357. this.getSvgDataFn(name)
  358. this.$emit(
  359. "refData",
  360. name
  361. );
  362. },
  363. // 初始化第一次报警并判断是否播放声音
  364. initAlarm() {
  365. let syzAlarmArray = this.$store.getters.syzAlarmArray;
  366. const firstAlarmItem = syzAlarmArray.find((ele) => {
  367. return !ele.isConfirm && ele.rank === this.$store.state.syzAlarmRank;
  368. });
  369. firstAlarmItem &&
  370. this.audioPlay(this.getSound(firstAlarmItem.soundSource));
  371. firstAlarmItem &&
  372. this.$store.getters.syzAlarmArray.forEach((ele) => {
  373. if (ele.stationId === firstAlarmItem.stationId) {
  374. ele.isConfirm = true;
  375. }
  376. });
  377. this.activeTab =
  378. this.activeTabStation ||
  379. firstAlarmItem?.stationId ||
  380. syzAlarmArray.find((ele) => {
  381. return ele.rank === this.$store.state.syzAlarmRank;
  382. })?.stationId ||
  383. this.$store.getters.syzArray[0].id;
  384. syzAlarmArray.forEach((ele) => {
  385. if (ele.stationId === firstAlarmItem?.stationId) {
  386. ele.isConfirm = true;
  387. this.clearWarningTag(ele.stationId);
  388. } else if (
  389. !ele.isConfirm &&
  390. ele.stationId !== firstAlarmItem?.stationId
  391. ) {
  392. this.renderWarningTag(ele.stationId);
  393. }
  394. });
  395. this.$store.commit("syzAlarmArray", syzAlarmArray);
  396. },
  397. // 定时器循环数据判断小红点渲染及是否播放声音
  398. renderAlarm(stationId = "", playSound = true) {
  399. let syzAlarmArray = this.$store.getters.syzAlarmArray;
  400. syzAlarmArray.forEach((ele) => {
  401. if (ele.stationId === stationId) {
  402. ele.isConfirm = true;
  403. this.clearWarningTag(ele.stationId);
  404. } else if (!ele.isConfirm && ele.stationId !== stationId) {
  405. this.renderWarningTag(ele.stationId);
  406. }
  407. });
  408. const res = syzAlarmArray.find((ele) => {
  409. return !ele.isConfirm;
  410. });
  411. if (playSound) {
  412. // this.audioPlay("./static/sound/syz.mp3");
  413. }
  414. this.$store.commit("syzAlarmArray", syzAlarmArray);
  415. },
  416. // 返回音频文件路径
  417. getSound(fileName) {
  418. return `./static/sound/${fileName}.mp3`;
  419. },
  420. // 播放音频
  421. audioPlay(audioPath) {
  422. let soundMuteSelf = [];
  423. let soundMuteOther = [];
  424. this.$store.getters.syzAlarmArray.forEach((ele) => {
  425. if (ele.stationId === this.activeTab) {
  426. soundMuteSelf.push(ele);
  427. } else {
  428. soundMuteOther.push(ele);
  429. }
  430. });
  431. let alarmSelfLock = soundMuteSelf.some((ele) => {
  432. return !ele.isConfirm;
  433. });
  434. let alarmOtherLock = soundMuteOther.some((ele) => {
  435. return !ele.isConfirm;
  436. });
  437. if (alarmOtherLock) {
  438. this.audio = new Audio(audioPath);
  439. this.audio.play();
  440. } else if (alarmSelfLock) {
  441. this.$store.getters.syzArray.forEach((ele) => {
  442. if (ele.stationId === this.activeTab) {
  443. ele.isMute = false;
  444. this.audio = new Audio(audioPath);
  445. this.audio.play();
  446. }
  447. });
  448. } else if (!alarmSelfLock) {
  449. this.$store.getters.syzArray.forEach((ele) => {
  450. if (ele.stationId === this.activeTab) {
  451. if (!ele.isMute) {
  452. this.audio = new Audio(audioPath);
  453. this.audio.play();
  454. }
  455. }
  456. });
  457. }
  458. },
  459. // 显示某个小红点
  460. renderWarningTag(stationId = "") {
  461. this.$store.getters.syzArray.forEach((ele) => {
  462. if (ele.id === stationId) {
  463. ele.isWarning = "1";
  464. }
  465. });
  466. this.pageshowMode++;
  467. },
  468. // 清除某个小红点
  469. clearWarningTag(stationId = "") {
  470. this.$store.getters.syzArray.forEach((ele) => {
  471. if (ele.id === stationId) {
  472. ele.isWarning = "0";
  473. }
  474. });
  475. this.pageshowMode++;
  476. },
  477. // 切换报警声音开关
  478. switchAlarmSound(index) {
  479. this.$store.getters.syzArray[index].isMute =
  480. !this.$store.getters.syzArray[index].isMute;
  481. },
  482. opened() {
  483. this.getAllStationtab()
  484. },
  485. closed() {
  486. clearInterval(this.starTimer);
  487. clearInterval(this.starTimerWarn);
  488. clearInterval(this.timmer);
  489. this.starTimer = null
  490. this.starTimerWarn = null
  491. this.timmer = null;
  492. this.$store.commit("activeTab", "");
  493. this.$store.commit("syzDialogShow", false);
  494. },
  495. tabClick(res) {
  496. clearInterval(this.starTimer);
  497. this.starTimer = null;
  498. this.$store.commit("activeTab", res.props.name);
  499. this.renderAlarm(res.props.name, false);
  500. if (res.props.name !== 'all') {
  501. this.debounce(this.getSvgDataFn(res.props.name), 200)
  502. }
  503. },
  504. debounce(fn, delay) {
  505. var delay = delay || 200;
  506. var timer;
  507. return function () {
  508. var th = this;
  509. var args = arguments;
  510. if (timer) {
  511. clearTimeout(timer);
  512. }
  513. timer = setTimeout(function () {
  514. timer = null;
  515. fn.apply(th, args);
  516. }, delay);
  517. };
  518. },
  519. throttle(fn, interval) {
  520. var last;
  521. var timer;
  522. var interval = interval || 200;
  523. return function () {
  524. var th = this;
  525. var args = arguments;
  526. var now = +new Date();
  527. if (last && now - last < interval) {
  528. clearTimeout(timer);
  529. timer = setTimeout(function () {
  530. last = now;
  531. fn.apply(th, args);
  532. }, interval);
  533. } else {
  534. last = now;
  535. fn.apply(th, args);
  536. }
  537. }
  538. }
  539. },
  540. watch: {
  541. "$store.state.syzArray"(res) {
  542. this.syzArray = res;
  543. },
  544. },
  545. };
  546. </script>
  547. <style lang="less" scoped>
  548. .bodyy {
  549. display: flex;
  550. flex-direction: row;
  551. background-color: black;
  552. width: 98%;
  553. //margin-top: -30px;
  554. height: 100vh;
  555. position: relative;
  556. overflow: hidden;
  557. margin-left: 44px;
  558. .syzDetailsPaneItem {
  559. position: relative;
  560. height: 100%;
  561. .buttonGroup {
  562. margin-bottom: 10px;
  563. display: flex;
  564. float: right;
  565. .el-button-group {
  566. .el-button {
  567. min-height: 30px !important;
  568. }
  569. .showSty {
  570. color: #409eff;
  571. border-color: #c6e2ff;
  572. background-color: #ecf5ff;
  573. outline: 0;
  574. }
  575. }
  576. }
  577. .warningMaskNew {
  578. background-color: rgba(186, 50, 55, 0.5);
  579. animation: fade 2000ms infinite;
  580. -webkit-animation: fade 2000ms infinite;
  581. }
  582. @keyframes fade {
  583. from {
  584. opacity: 0.7;
  585. }
  586. 50% {
  587. opacity: 0.3;
  588. }
  589. to {
  590. opacity: 0.7;
  591. }
  592. }
  593. @-webkit-keyframes fade {
  594. from {
  595. opacity: 0.7;
  596. }
  597. 50% {
  598. opacity: 0.3;
  599. }
  600. to {
  601. opacity: 0.7;
  602. }
  603. }
  604. .showAllSvgMsg {
  605. width: calc(100% - 15px);
  606. height: calc(100% - 15px);
  607. border: 3px solid #646464;
  608. border-radius: 10px;
  609. .showAllSvgMsg_top {
  610. border-radius: 10px 10px 0 0;
  611. height: calc(100% - 40px);
  612. width: 100%;
  613. }
  614. .showAllSvgMsg_bot {
  615. background: #3a3a3a;
  616. border-radius: 0 0 8px 8px;
  617. height: 40px;
  618. text-align: center;
  619. span {
  620. position: relative;
  621. top: 10px;
  622. font-weight: bold;
  623. color: #fff;
  624. }
  625. }
  626. }
  627. .alarmIconBox {
  628. position: absolute;
  629. right: 0;
  630. top: 0;
  631. cursor: pointer;
  632. i {
  633. font-size: 20px;
  634. }
  635. }
  636. }
  637. }
  638. </style>
  639. <style lang="less">
  640. .bodyy {
  641. .pop-up-main,
  642. .paln-box {
  643. width: 100%;
  644. height: 90vh;
  645. overflow: hidden;
  646. position: relative;
  647. }
  648. .movableItem {
  649. .svg {
  650. margin-left: 0;
  651. margin-top: 8%;
  652. }
  653. }
  654. .el-badge__content.is-fixed.is-dot {
  655. right: 0;
  656. top: 10px;
  657. background: #f25656;
  658. animation: twinkle 0.75s infinite;
  659. border-color: transparent;
  660. }
  661. @keyframes twinkle {
  662. 0% {
  663. opacity: 0;
  664. }
  665. 50% {
  666. opacity: 1;
  667. }
  668. 100% {
  669. opacity: 0;
  670. }
  671. }
  672. }
  673. .currentShowTitles {
  674. width: 100%;
  675. position: relative;
  676. .alarIcon {
  677. position: absolute;
  678. right: 50px;
  679. top: 5;
  680. font-size: 20px;
  681. cursor: pointer;
  682. }
  683. }
  684. </style>