ventilateWarn.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <customHeader :options="options" @change="getSelectRow" :optionValue="optionValue"> 通风监测预警 </customHeader>
  3. <div class="ventilateWarn">
  4. <div v-if="showToggle == 'all'" class="icon-toggle" @click="handlerToggle">
  5. <img v-if="!monitor" src="@/assets/images/vent/monitor-toggle.png" alt="" />
  6. <img v-else src="@/assets/images/vent/report-toggle.png" alt="" />
  7. </div>
  8. <div class="ventilate-top">
  9. <a-button v-if="!hasPermission('ventilateWarn:return')" preIcon="ant-design:rollback-outlined" type="text"
  10. size="small" style="position: absolute; left: 15px; top: 15px; color: var(--vent-font-color)" @click="getBack">
  11. 返回
  12. </a-button>
  13. <div class="alarm-menu">
  14. <div class="type-btn">
  15. <div :class="activeIndex == index ? 'btn1' : 'btn'" v-for="(item, index) in typeMenuListTf" :key="index"
  16. @click="btnClick(index)">
  17. {{ item.name }}
  18. </div>
  19. </div>
  20. <div class="card-btn">
  21. <div style="width: 100%; height: 100%" v-if="menuList.length">
  22. <div :class="activeIndex1 == ind ? 'btn1' : 'btn'" v-for="(item, ind) in menuList" :key="ind"
  23. @click="cardClick(ind, item)">
  24. <div class="text">{{ item.name }}</div>
  25. <div class="warn">{{ item.warn }}</div>
  26. </div>
  27. </div>
  28. <div v-else class="hd-content">
  29. <div class="hd-content-text">巷道阻变型故障预警分析</div>
  30. <div class="hd-content-val">{{ hdData.maxLevel }}</div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="ventilate-content">
  35. <a-spin :spinning="loading">
  36. <TopArea :activeIndex="activeIndex" :statusData="ventilateTopList" :echartData="echartDataFc1"
  37. :ventTunDataSource="ventTunDataSource" :maxY="maxY" :minY="minY"></TopArea>
  38. </a-spin>
  39. </div>
  40. </div>
  41. <div class="ventilate-bottom">
  42. <div class="bot-area">
  43. <MeasurePoint title="通风监控测点信息" :timeout="1000" :cards="cardListTf" :charts="chartListTf" chartWidth="420px" />
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup lang="ts">
  49. import { ref, reactive, onMounted, onUnmounted, computed } from 'vue';
  50. import { useSystemSelect } from '/@/hooks/vent/useSystemSelect';
  51. import { usePermission } from '/@/hooks/web/usePermission';
  52. import { useGlobSetting } from '/@/hooks/setting';
  53. import { useRouter } from 'vue-router';
  54. import { sysTypeWarnList, sysWarn, getDevice } from '../common.api';
  55. import { ventilateTopList, typeMenuListTf, getMaxY, getMinY } from '../common.data';
  56. import CustomHeader from '/@/components/vent/customHeader.vue';
  57. import MeasurePoint from '../common/measurePoint.vue';
  58. import { realTimeNetCal, modalParam } from '../alarm.api';
  59. import TopArea from '../common/top-area.vue';
  60. //巷道阻力分析数据
  61. let hdData = reactive({
  62. maxLevel: '',
  63. address: '',
  64. });
  65. //通风选项激活索引
  66. let activeIndex = ref(0);
  67. let monitor = ref(true);
  68. let toggleData = reactive<any>({});
  69. const { hasPermission } = usePermission();
  70. const { options, optionValue, getSelectRow, getSysDataSource } = useSystemSelect('sys_surface_caimei'); // 参数为场景类型(设备类型管理中可以查询到)
  71. let router = useRouter();
  72. //左侧数据列表
  73. let menuList = reactive<any[]>([]);
  74. const ventTunDataSource = ref([]);
  75. //当前左侧激活菜单的索引
  76. let activeIndex1 = ref(0);
  77. let maxY = ref<any>(0);
  78. let minY = ref<any>(0)
  79. const loading = ref(false);
  80. //通风图表数据
  81. const echartDataFc1 = reactive<any>({
  82. maxData: {
  83. lengedData: '进风量',
  84. data: [],
  85. },
  86. minData: {
  87. lengedData: '回风量',
  88. data: [],
  89. },
  90. aveValue: {
  91. lengedData: '需风量',
  92. data: [],
  93. },
  94. xData: [],
  95. });
  96. let cardListTf = ref<any[]>([]);
  97. const chartListTf = ref<any[]>([]);
  98. let showToggle = ref('report');
  99. //通风选项切换
  100. function btnClick(ind) {
  101. activeIndex.value = ind;
  102. switch (ind) {
  103. case 0:
  104. if (timer1) clearTimeout(timer1);
  105. activeIndex1.value = 0;
  106. getMenuList();
  107. break;
  108. case 1:
  109. if (timer) clearTimeout(timer);
  110. activeIndex1.value = 0;
  111. menuList.length = 0;
  112. getRealTimeNetData();
  113. getMonitor1();
  114. break;
  115. }
  116. }
  117. //点击切换实时\报表数据
  118. let handlerToggle = () => {
  119. monitor.value = !monitor.value;
  120. echartDataFc1.maxData.data.length = 0;
  121. echartDataFc1.minData.data.length = 0;
  122. echartDataFc1.aveValue.data.length = 0;
  123. echartDataFc1.xData.length = 0;
  124. ventilateTopList[0].value = monitor.value ? toggleData.faceIntM3 : toggleData.jin;
  125. ventilateTopList[1].value = monitor.value ? toggleData.faceRetM3 : toggleData.hui;
  126. if (monitor.value) {
  127. toggleData.history_report.forEach((v) => {
  128. echartDataFc1.maxData.data.push(parseFloat(v.faceIntM3));
  129. echartDataFc1.minData.data.push(parseFloat(v.faceRetM3));
  130. echartDataFc1.aveValue.data.push(0);
  131. echartDataFc1.xData.push(v.time);
  132. });
  133. } else {
  134. toggleData.history.forEach((v) => {
  135. echartDataFc1.maxData.data.push(parseFloat(v.jin));
  136. echartDataFc1.minData.data.push(parseFloat(v.hui));
  137. if (ventilateTopList[2].value && ventilateTopList[2].value != '--') {
  138. echartDataFc1.aveValue.data.push(ventilateTopList[2].value);
  139. } else {
  140. echartDataFc1.aveValue.data.push(0);
  141. }
  142. echartDataFc1.xData.push(v.time);
  143. });
  144. }
  145. };
  146. // https获取监测数据
  147. let timer: null | NodeJS.Timeout = null;
  148. function getMonitor(flag?) {
  149. timer = setTimeout(
  150. async () => {
  151. //获取左侧菜单数据
  152. await getMenuList();
  153. await getWindDeviceList();
  154. getMonitor(false);
  155. },
  156. flag ? 0 : 1000
  157. );
  158. }
  159. //获取巷道阻力分析数据
  160. let timer1: null | NodeJS.Timeout = null;
  161. function getMonitor1(flag?) {
  162. timer1 = setTimeout(
  163. async () => {
  164. await getRealTimeNetData();
  165. getMonitor1(false);
  166. },
  167. flag ? 0 : 30000
  168. );
  169. }
  170. //返回首页
  171. function getBack() {
  172. router.push('/monitorChannel/monitor-alarm-home');
  173. }
  174. //获取左侧数据列表
  175. async function getMenuList() {
  176. let res = await sysTypeWarnList({ type: 'vent' });
  177. if (res.length != 0) {
  178. menuList.length = 0;
  179. res.forEach((el) => {
  180. menuList.push({
  181. name: el.deviceName,
  182. warn: el.warnDes.indexOf('预警') != -1 ? '风量不足' : el.warnDes,
  183. deviceID: el.deviceID,
  184. strtype: el.deviceType,
  185. detail: el.detail
  186. });
  187. });
  188. //获取右侧详情数据
  189. getDetailList(menuList[activeIndex1.value].detail)
  190. }
  191. }
  192. //菜单选项切换
  193. function cardClick(ind, item) {
  194. if (!activeIndex.value) {
  195. clearTimeout(timer);
  196. activeIndex1.value = ind;
  197. loading.value = true;
  198. setTimeout(() => {
  199. getMonitor(true);
  200. loading.value = false;
  201. }, 1000);
  202. } else {
  203. return;
  204. }
  205. }
  206. //获取右侧详情数据
  207. function getDetailList(param) {
  208. echartDataFc1.maxData.data.length = 0;
  209. echartDataFc1.minData.data.length = 0;
  210. echartDataFc1.aveValue.data.length = 0;
  211. echartDataFc1.xData.length = 0;
  212. if (JSON.stringify(param) != '{}') {
  213. toggleData = Object.assign({}, param);
  214. ventilateTopList[2].value = param.xufengliang || '--';
  215. ventilateTopList[3].text = param.warnFlag ? param.warnDes : '正常';
  216. if (showToggle.value == 'monitor') {
  217. ventilateTopList[0].value = param.jin;
  218. ventilateTopList[1].value = param.hui;
  219. if (param.history.length != 0) {
  220. param.history.forEach((v) => {
  221. echartDataFc1.maxData.data.push(parseFloat(v.jin));
  222. echartDataFc1.minData.data.push(parseFloat(v.hui));
  223. if (ventilateTopList[2].value && ventilateTopList[2].value != '--') {
  224. echartDataFc1.aveValue.data.push(ventilateTopList[2].value);
  225. } else {
  226. echartDataFc1.aveValue.data.push(0);
  227. }
  228. echartDataFc1.xData.push(v.time);
  229. });
  230. }
  231. } else if (showToggle.value == 'report') {
  232. ventilateTopList[0].value = param.faceIntM3;
  233. ventilateTopList[1].value = param.faceRetM3;
  234. param.history_report.forEach((v) => {
  235. echartDataFc1.maxData.data.push(parseFloat(v.faceIntM3));
  236. echartDataFc1.minData.data.push(parseFloat(v.faceRetM3));
  237. echartDataFc1.aveValue.data.push(0);
  238. echartDataFc1.xData.push(v.time);
  239. });
  240. } else {
  241. ventilateTopList[0].value = monitor.value ? param.faceIntM3 : param.jin;
  242. ventilateTopList[1].value = monitor.value ? param.faceRetM3 : param.hui;
  243. if (monitor.value) {
  244. param.history_report.forEach((v) => {
  245. echartDataFc1.maxData.data.push(parseFloat(v.faceIntM3));
  246. echartDataFc1.minData.data.push(parseFloat(v.faceRetM3));
  247. echartDataFc1.aveValue.data.push(0);
  248. echartDataFc1.xData.push(v.time);
  249. });
  250. } else {
  251. param.history.forEach((v) => {
  252. echartDataFc1.maxData.data.push(parseFloat(v.jin));
  253. echartDataFc1.minData.data.push(parseFloat(v.hui));
  254. if (ventilateTopList[2].value && ventilateTopList[2].value != '--') {
  255. echartDataFc1.aveValue.data.push(ventilateTopList[2].value);
  256. } else {
  257. echartDataFc1.aveValue.data.push(0);
  258. }
  259. echartDataFc1.xData.push(v.time);
  260. });
  261. }
  262. }
  263. let echartD = [echartDataFc1.maxData.data, echartDataFc1.minData.data]
  264. maxY.value = getMaxY(echartD)
  265. minY.value = getMinY(echartD)
  266. }
  267. }
  268. //获取通风监控测点信息
  269. async function getWindDeviceList() {
  270. const cardTfList: any[] = [];
  271. const chartTfList: any[] = [];
  272. let res = await getDevice({ devicetype: 'windrect', pagetype: 'normal' });
  273. if (res && res.msgTxt[0]) {
  274. let list = res.msgTxt[0].datalist || [];
  275. if (list.length > 0) {
  276. list.forEach((el: any) => {
  277. const readData = el.readData;
  278. el = Object.assign(el, readData);
  279. cardTfList.push({
  280. label: '通信状态',
  281. value: el.netStatus == '0' ? '断开' : '连接',
  282. listR: [
  283. { id: 0, label: '安装位置', dw: '', value: el.strinstallpos },
  284. { id: 1, label: '风量', dw: 'm³/min', value: el.m3 || '--' },
  285. { id: 2, label: '风速', dw: 'm/s', value: el.va || '--' },
  286. { id: 4, label: '时间', dw: '', value: el.readTime },
  287. {
  288. id: 3,
  289. label: '是否报警',
  290. dw: '',
  291. value: el.warnFlag == '0' ? '正常' : el.warnFlag == 1 ? '报警' : el.warnFlag == 2 ? '断开' : '未监测',
  292. },
  293. ],
  294. });
  295. // 初始化预测曲线配置,分别为x轴时间、平均、最大、最小、实时
  296. const avgParam = el.avgParam || {
  297. avg_vent_value: 0,
  298. max_vent_value: 0,
  299. min_vent_value: 0,
  300. };
  301. chartTfList.push({
  302. label: el.strinstallpos,
  303. time: new Date(),
  304. data: [avgParam.avg_m3_value, avgParam.max_m3_value, avgParam.min_m3_value, el.readData.m3],
  305. });
  306. });
  307. }
  308. cardListTf.value = cardTfList;
  309. chartListTf.value = chartTfList;
  310. }
  311. }
  312. async function getRealTimeNetData() {
  313. const modalData = await modalParam({});
  314. if (modalData && modalData.param && modalData.param.records.length && modalData.param.records.length > 0) {
  315. const res = await realTimeNetCal({ modelID: modalData.param.records[0]['defaultmodelid'] });
  316. if (res && res['result']) ventTunDataSource.value = res['result']['tuns'];
  317. let data = [];
  318. ventTunDataSource.value.forEach((el) => {
  319. if (el['dHTotal'] && el['oldHTotal']) {
  320. el['leveld'] = ((el['dHTotal'] - el['oldHTotal']) / el['oldHTotal']) * 100;
  321. data.push(el['leveld']);
  322. } else {
  323. data = [];
  324. }
  325. });
  326. hdData.maxLevel = '正常';
  327. }
  328. }
  329. onMounted(async () => {
  330. const { sysOrgCode, sysDataType } = useGlobSetting();
  331. showToggle.value = sysDataType || 'report';
  332. await getMenuList();
  333. await getMonitor();
  334. });
  335. onUnmounted(() => {
  336. if (timer) {
  337. clearTimeout(timer);
  338. timer = undefined;
  339. }
  340. if (timer1) {
  341. clearTimeout(timer1);
  342. timer1 = undefined;
  343. }
  344. });
  345. </script>
  346. <style lang="less" scoped>
  347. @import '/@/design/theme.less';
  348. @{theme-deepblue} {
  349. .ventilateWarn {
  350. --image-border: url('/@/assets/images/themify/deepblue/fire/border.png');
  351. --image-no-choice: url('/@/assets/images/themify/deepblue/fire/no-choice.png');
  352. --image-choice: url('/@/assets/images/themify/deepblue/fire/choice.png');
  353. --image-bj1: url('/@/assets/images/themify/deepblue/fire/bj1.png');
  354. --image-jinfengliang: url('/@/assets/images/themify/deepblue/fire/jinfengliang.png');
  355. --image-huifengliang: url('/@/assets/images/themify/deepblue/fire/huifengliang.png');
  356. --image-xufengliang: url('/@/assets/images/themify/deepblue/fire/xufengliang.png');
  357. }
  358. }
  359. .ventilateWarn {
  360. --image-border: url('/@/assets/images/fire/border.png');
  361. --image-no-choice: url('/@/assets/images/fire/no-choice.png');
  362. --image-choice: url('/@/assets/images/fire/choice.png');
  363. --image-bj1: url('/@/assets/images/fire/bj1.png');
  364. --image-jinfengliang: url('/@/assets/images/fire/jinfengliang.png');
  365. --image-huifengliang: url('/@/assets/images/fire/huifengliang.png');
  366. --image-xufengliang: url('/@/assets/images/fire/xufengliang.png');
  367. --border-image-1: linear-gradient(to bottom, #2d74a0, #2d74a0, #2d74a0);
  368. --border-image-2: linear-gradient(to bottom, transparent, #024688, transparent);
  369. position: reactive;
  370. width: 100%;
  371. height: 100%;
  372. padding: 80px 10px 15px 10px;
  373. box-sizing: border-box;
  374. .ventilate-top {
  375. width: 100%;
  376. display: flex;
  377. justify-content: space-between;
  378. height: 50%;
  379. margin-bottom: 15px;
  380. background: var(--image-border) no-repeat center;
  381. background-size: 100% 100%;
  382. padding-right: 15px;
  383. .alarm-menu {
  384. height: 100%;
  385. width: 332px;
  386. padding: 10px;
  387. box-sizing: border-box;
  388. .type-btn {
  389. width: 100%;
  390. height: 28px;
  391. line-height: 28px;
  392. background-color: var(--vent-warn-tab-bg);
  393. border: 2px solid var(--vent-warn-tab-border);
  394. margin-bottom: 20px;
  395. border-radius: 5px;
  396. box-sizing: border-box;
  397. display: flex;
  398. justify-content: space-between;
  399. .btn {
  400. width: 50%;
  401. height: 24px;
  402. line-height: 24px;
  403. font-size: 14px;
  404. text-align: center;
  405. color: var(--vent-font-color);
  406. cursor: pointer;
  407. }
  408. .btn1 {
  409. width: 50%;
  410. height: 24px;
  411. line-height: 24px;
  412. font-size: 14px;
  413. color: var(--vent-font-color);
  414. text-align: center;
  415. border-radius: 2px;
  416. background: var(--vent-warn-tab-bg-actived);
  417. cursor: pointer;
  418. }
  419. }
  420. .card-btn {
  421. width: 100%;
  422. height: calc(100% - 50px);
  423. overflow-y: auto;
  424. .btn {
  425. position: relative;
  426. width: 81%;
  427. height: 24%;
  428. margin-bottom: 6%;
  429. font-family: 'douyuFont';
  430. background: var(--image-no-choice) no-repeat;
  431. background-size: 100% 100%;
  432. cursor: pointer;
  433. .text {
  434. width: 80%;
  435. position: absolute;
  436. left: 50%;
  437. top: 28px;
  438. font-size: 14px;
  439. color: var(--vent-table-action-link);
  440. text-align: center;
  441. transform: translate(-50%, 0);
  442. }
  443. .warn {
  444. width: 100%;
  445. position: absolute;
  446. left: 50%;
  447. bottom: 8px;
  448. font-size: 12px;
  449. color: var(--vent-font-color);
  450. text-align: center;
  451. transform: translate(-50%, 0);
  452. }
  453. }
  454. .btn1 {
  455. position: relative;
  456. width: 100%;
  457. height: 24%;
  458. margin-bottom: 6%;
  459. font-family: 'douyuFont';
  460. background: var(--image-choice) no-repeat;
  461. background-size: 100% 100%;
  462. cursor: pointer;
  463. .text {
  464. width: 80%;
  465. position: absolute;
  466. left: 50%;
  467. top: 28px;
  468. font-size: 14px;
  469. color: var(--vent-table-action-link);
  470. text-align: center;
  471. transform: translate(-62%, 0);
  472. }
  473. .warn {
  474. width: 100%;
  475. position: absolute;
  476. left: 50%;
  477. bottom: 8px;
  478. font-size: 14px;
  479. color: var(--vent-font-color);
  480. text-align: center;
  481. transform: translate(-60%, 0);
  482. }
  483. }
  484. .hd-content {
  485. position: relative;
  486. width: 100%;
  487. height: 300px;
  488. padding: 0 20px;
  489. background: var(--image-no-choice) no-repeat;
  490. background-size: 100% 100%;
  491. .hd-content-text {
  492. display: flex;
  493. width: 100%;
  494. height: 200px;
  495. align-items: center;
  496. justify-content: center;
  497. font-size: 18px;
  498. color: var(--vent-font-yellow-color);
  499. }
  500. .hd-content-val {
  501. position: absolute;
  502. width: calc(100% - 40px);
  503. display: flex;
  504. justify-content: center;
  505. font-family: 'douyuFont';
  506. bottom: 80px;
  507. font-size: 20px;
  508. color: var(--vent-table-action-link);
  509. }
  510. }
  511. }
  512. }
  513. .ventilate-content {
  514. height: 100%;
  515. width: calc(100% - 332px);
  516. padding: 10px 0px;
  517. box-sizing: border-box;
  518. margin-right: 10px;
  519. }
  520. }
  521. .tun-box {
  522. width: 600px;
  523. height: 300px;
  524. }
  525. .ventilate-bottom {
  526. height: calc(50% - 15px);
  527. background: var(--image-border) no-repeat center;
  528. background-size: 100% 100%;
  529. padding: 10px;
  530. box-sizing: border-box;
  531. .bot-area {
  532. height: 100%;
  533. padding: 10px;
  534. background: var(--image-bj1) no-repeat center;
  535. background-size: 100% 100%;
  536. box-sizing: border-box;
  537. }
  538. }
  539. .icon-toggle {
  540. position: absolute;
  541. right: 220px;
  542. top: 17px;
  543. img {
  544. width: 26px;
  545. height: 26px;
  546. cursor: pointer;
  547. }
  548. }
  549. }
  550. </style>