dustWarn.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <template>
  2. <customHeader :options="options" @change="getSelectRow" :optionValue="optionValue"> 粉尘监测预警 </customHeader>
  3. <div class="dustWarn">
  4. <div class="top-dust">
  5. <a-button
  6. v-if="!hasPermission('dustWarn:return')"
  7. preIcon="ant-design:rollback-outlined"
  8. type="text"
  9. size="small"
  10. style="position: absolute; left: 15px; top: 15px; color: #fff"
  11. @click="getBack"
  12. >返回</a-button
  13. >
  14. <div class="alarm-menu">
  15. <div class="card-btn">
  16. <div :class="activeIndex1 == ind ? 'btn1' : 'btn'" v-for="(item, ind) in menuList" :key="ind" @click="cardClick(ind, item)">
  17. <div class="text">{{ item.name }}</div>
  18. <div class="warn">{{ item.warn }}</div>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="dust-content">
  23. <div class="content-left">
  24. <div
  25. :class="activeIndex == index ? 'content-left-item' : 'content-left-item1'"
  26. v-for="(item, index) in topAreaList"
  27. :key="index"
  28. @click="topAreaClick(index)"
  29. >
  30. <div class="content-title">{{ item.title }}</div>
  31. <div class="content-items" v-for="(ite, ind) in item.content" :key="ind">
  32. <span>{{ ite.label }}</span>
  33. <span style="color: var(--vent-table-action-link)">{{ ite.value }}</span>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="content-right">
  38. <div class="title-t">
  39. <div class="text-t">粉尘信息状态监测</div>
  40. </div>
  41. <div class="echart-boxd">
  42. <echartLine :echartDataGq="echartDataFc" :maxY="maxY" :echartDw="echartDw" :gridV="gridV" />
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="bot-dust">
  48. <div class="bot-area">
  49. <MeasurePoint title="粉尘监控测点信息" :cards="cardListTf" :charts="chartListTf" />
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script setup lang="ts">
  55. import { ref, reactive, onMounted, onUnmounted } from 'vue';
  56. import { sysTypeWarnList, sysWarn, getDevice } from '../common.api';
  57. import echartLine from '../common/echartLine.vue';
  58. import { useSystemSelect } from '/@/hooks/vent/useSystemSelect';
  59. import { useRouter } from 'vue-router';
  60. import CustomHeader from '/@/components/vent/customHeader.vue';
  61. import { usePermission } from '/@/hooks/web/usePermission';
  62. import MeasurePoint from '../common/measurePoint.vue';
  63. import moment from 'moment';
  64. const { hasPermission } = usePermission();
  65. const { options, optionValue, getSelectRow, getSysDataSource } = useSystemSelect('sys_surface_caimei'); // 参数为场景类型(设备类型管理中可以查询到)
  66. //左侧数据列表
  67. let menuList = reactive<any[]>([]);
  68. //当前左侧激活菜单的索引
  69. let activeIndex1 = ref(0);
  70. //顶部区域激活选项
  71. let activeIndex = ref(0);
  72. //顶部区域数据
  73. let topAreaList = reactive<any[]>([]);
  74. let choiceData = reactive<any[]>([]);
  75. //粉尘图表数据
  76. let echartDataFc = reactive({
  77. maxData: {
  78. lengedData: '实时值(mg/m³)',
  79. data: [],
  80. },
  81. minData: {
  82. lengedData: '预测值(mg/m³)',
  83. data: [],
  84. },
  85. aveValue: {
  86. lengedData: '预警值(mg/m³)',
  87. data: [],
  88. },
  89. xData: [],
  90. });
  91. let maxY = ref<any>(0);
  92. let echartDw = ref('(mg/m³)');
  93. let gridV = reactive({
  94. top: '12%',
  95. left: '1%',
  96. bottom: '5%',
  97. right: '5%',
  98. containLabel: true,
  99. });
  100. const cardListTf = reactive<any[]>([]);
  101. const chartListTf = reactive<any[]>([]);
  102. let router = useRouter();
  103. let echartNow = ref<any[]>([]);
  104. let echartYc = reactive<any[]>([]);
  105. let flag = ref(true);
  106. // https获取监测数据
  107. let timer: null | NodeJS.Timeout = null;
  108. function getMonitor(deviceID, flag?) {
  109. timer = setTimeout(
  110. async () => {
  111. await getSysWarnList(deviceID, 'dust');
  112. if (timer) {
  113. timer = null;
  114. }
  115. getMonitor(deviceID);
  116. },
  117. flag ? 0 : 3000
  118. );
  119. }
  120. //返回首页
  121. function getBack() {
  122. router.push('/monitorChannel/monitor-alarm-home');
  123. }
  124. //菜单选项切换
  125. function cardClick(ind, item) {
  126. activeIndex1.value = ind;
  127. clearTimeout(timer);
  128. getMonitor(item.deviceID, true);
  129. }
  130. //顶部区域选项切换
  131. function topAreaClick(index) {
  132. activeIndex.value = index;
  133. echartDataFc.maxData.data.length = 0;
  134. echartDataFc.minData.data.length = 0;
  135. echartDataFc.aveValue.data.length = 0;
  136. echartDataFc.xData.length = 0;
  137. echartYc.length = 0;
  138. flag.value = true;
  139. if (flag.value) {
  140. echartNow.value = JSON.parse(choiceData[index].readData.expectInfo)['list'];
  141. flag.value = false;
  142. }
  143. echartYc.push({
  144. time: JSON.parse(choiceData[index].readData.expectInfo)['nowTime'],
  145. value: JSON.parse(choiceData[index].readData.expectInfo)['nowVal'],
  146. });
  147. let setData = [...echartNow.value, ...echartYc].sort((a, b) => Date.parse(new Date(a.time)) - Date.parse(new Date(b.time)));
  148. setData.forEach((el) => {
  149. if (el.value && el.value != '0') {
  150. echartDataFc.xData.push(el.time);
  151. echartDataFc.maxData.data.push(el.value);
  152. echartDataFc.minData.data.push(JSON.parse(choiceData[index].readData.expectInfo)['aveVal']);
  153. echartDataFc.aveValue.data.push(
  154. JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  155. ? JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  156. : 0
  157. );
  158. }
  159. });
  160. }
  161. //获取左侧菜单列表
  162. async function getMenuList() {
  163. let res = await sysTypeWarnList({ type: 'dust' });
  164. if (res.length != 0) {
  165. menuList.length = 0;
  166. res.forEach((el) => {
  167. menuList.push({
  168. name: el.systemname,
  169. warn: '低风险',
  170. deviceID: el.id,
  171. strtype: el.strtype,
  172. });
  173. });
  174. getMonitor(menuList[0].deviceID, true);
  175. }
  176. }
  177. //获取预警详情弹窗右侧数据
  178. function getSysWarnList(id, type) {
  179. sysWarn({ sysid: id, type: type }).then((res) => {
  180. // listData.common = res;
  181. topAreaList.length = 0;
  182. chartListTf.length = 0;
  183. if (JSON.stringify(res) != '{}') {
  184. res.dust.forEach((el) => {
  185. topAreaList.push({
  186. title: el.strinstallpos,
  187. content: [
  188. { ids: 0, label: '温度(°C)', value: el.readData.temperature || '--' },
  189. { ids: 1, label: '粉尘浓度(mg/m³)', value: el.readData.dustval || '--' },
  190. { ids: 2, label: '喷雾水压(MPa)', value: el.readData.waterPressure || '--' },
  191. { ids: 3, label: '喷雾状态', value: el.readData.atomizingState || '--' },
  192. ],
  193. });
  194. // 初始化预测曲线配置,分别为x轴时间、平均、最大、最小、实时
  195. const avgParams = el.avgParam || {
  196. avg_dusting_value: 0,
  197. max_dusting_value: 0,
  198. min_dusting_value: 0,
  199. };
  200. chartListTf.push({
  201. label: el.strinstallpos,
  202. time: new Date(),
  203. data: [avgParams.avg_dusting_value, avgParams.max_dusting_value, avgParams.min_dusting_value, el.readData.dustval],
  204. });
  205. });
  206. choiceData = res.dust;
  207. if (choiceData[activeIndex.value]) {
  208. if (flag.value) {
  209. echartNow.value = JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['list'];
  210. flag.value = false;
  211. }
  212. echartYc.push({
  213. time: JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['nowTime'],
  214. value: JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['nowVal'],
  215. });
  216. let setData = [...echartNow.value, ...echartYc].sort((a, b) => Date.parse(new Date(a.time)) - Date.parse(new Date(b.time)));
  217. echartDataFc.maxData.data.length = 0;
  218. echartDataFc.minData.data.length = 0;
  219. echartDataFc.aveValue.data.length = 0;
  220. echartDataFc.xData.length = 0;
  221. setData.forEach((el) => {
  222. if (el.value && el.value != '0') {
  223. echartDataFc.xData.push(el.time);
  224. echartDataFc.maxData.data.push(el.value);
  225. echartDataFc.minData.data.push(JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['aveVal']);
  226. echartDataFc.aveValue.data.push(
  227. JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  228. ? JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  229. : 0
  230. );
  231. }
  232. });
  233. maxY.value = echartDataFc.maxData.data.reduce((acr, cur) => {
  234. return acr > cur ? acr : cur;
  235. });
  236. maxY.value =
  237. maxY.value.toString().indexOf('.') == -1 ? maxY.value.toString() : maxY.value.toString().substring(0, maxY.value.toString().indexOf('.'));
  238. if (maxY.value.length < 2 && Number(maxY.value) < 1) {
  239. maxY.value = 1;
  240. } else if (maxY.value.length < 2 && Number(maxY.value) >= 1) {
  241. maxY.value = 10;
  242. } else if (maxY.value.length < 3) {
  243. maxY.value = (Number(maxY.value[0]) + 1) * 10;
  244. } else if (maxY.value.length < 4) {
  245. maxY.value = (Number(maxY.value[0]) + 1) * 100;
  246. } else if (maxY.value.length < 5) {
  247. maxY.value = (Number(maxY.value[0]) + 1) * 1000;
  248. } else if (maxY.value.length < 6) {
  249. maxY.value = (Number(maxY.value[0]) + 1) * 10000;
  250. }
  251. } else {
  252. activeIndex.value = 0;
  253. if (flag.value) {
  254. echartNow.value = JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['list'];
  255. flag.value = false;
  256. }
  257. echartYc.push({
  258. time: JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['nowTime'],
  259. value: JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['nowVal'],
  260. });
  261. let setData = [...echartNow.value, ...echartYc].sort((a, b) => Date.parse(new Date(a.time)) - Date.parse(new Date(b.time)));
  262. echartDataFc.maxData.data.length = 0;
  263. echartDataFc.minData.data.length = 0;
  264. echartDataFc.aveValue.data.length = 0;
  265. echartDataFc.xData.length = 0;
  266. setData.forEach((el) => {
  267. if (el.value && el.value != '0') {
  268. echartDataFc.xData.push(el.time);
  269. echartDataFc.maxData.data.push(el.value);
  270. echartDataFc.minData.data.push(JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['aveVal']);
  271. echartDataFc.aveValue.data.push(
  272. JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  273. ? JSON.parse(choiceData[activeIndex.value].readData.expectInfo)['fmin']
  274. : 0
  275. );
  276. }
  277. });
  278. maxY.value = echartDataFc.maxData.data.reduce((acr, cur) => {
  279. return acr > cur ? acr : cur;
  280. });
  281. maxY.value =
  282. maxY.value.toString().indexOf('.') == -1 ? maxY.value.toString() : maxY.value.toString().substring(0, maxY.value.toString().indexOf('.'));
  283. if (maxY.value.length < 2) {
  284. maxY.value = 10;
  285. } else if (maxY.value.length < 3) {
  286. maxY.value = (Number(maxY.value[0]) + 1) * 10;
  287. } else if (maxY.value.length < 4) {
  288. maxY.value = (Number(maxY.value[0]) + 1) * 100;
  289. } else if (maxY.value.length < 5) {
  290. maxY.value = (Number(maxY.value[0]) + 1) * 1000;
  291. } else if (maxY.value.length < 6) {
  292. maxY.value = (Number(maxY.value[0]) + 1) * 10000;
  293. }
  294. }
  295. }
  296. });
  297. }
  298. //获取粉尘监控测点信息
  299. async function getWindDeviceList() {
  300. cardListTf.length = 0;
  301. let res = await getDevice({ devicetype: 'dusting', pagetype: 'normal' });
  302. if (res && res.msgTxt[0]) {
  303. let list = res.msgTxt[0].datalist || [];
  304. if (list.length > 0) {
  305. list.forEach((el: any) => {
  306. const readData = el.readData;
  307. el = Object.assign(el, readData);
  308. cardListTf.push({
  309. label: '通信状态',
  310. value: el.netStatus == '0' ? '断开' : '连接',
  311. listR: [
  312. { id: 0, label: '安装位置', dw: '', value: el.strinstallpos || '-' },
  313. { id: 1, label: '粉尘浓度', dw: '(mg/m³)', value: el.dustval || '-' },
  314. {
  315. id: 2,
  316. label: '巷道湿度',
  317. dw: el.humidity && Number(el.humidity) < 1 ? '(RH)' : el.humidity && Number(el.humidity) > 1 ? '(%RH)' : '',
  318. value: el.humidity || '-',
  319. },
  320. { id: 4, label: '巷道温度', dw: el.humidity ? '(℃)' : '', value: el.temperature || '-' },
  321. {
  322. id: 3,
  323. label: '是否报警',
  324. dw: '',
  325. value: el.warnFlag == '0' ? '正常' : el.warnFlag == 1 ? '报警' : el.warnFlag == 2 ? '断开' : '未监测',
  326. },
  327. ],
  328. });
  329. });
  330. }
  331. }
  332. }
  333. onMounted(() => {
  334. getMenuList();
  335. getWindDeviceList();
  336. });
  337. onUnmounted(() => {
  338. if (timer) {
  339. clearTimeout(timer);
  340. timer = undefined;
  341. }
  342. });
  343. </script>
  344. <style lang="less" scoped>
  345. @import '/@/design/theme.less';
  346. @{theme-deepblue} {
  347. .dustWarn {
  348. --image-border: url('/@/assets/images/themify/deepblue/fire/border.png');
  349. --image-no-choice: url('/@/assets/images/themify/deepblue/fire/no-choice.png');
  350. --image-choice: url('/@/assets/images/themify/deepblue/fire/choice.png');
  351. --image-dust-choice: url('/@/assets/images/themify/deepblue/fire/dust-choice.png');
  352. --image-dust-content: url('/@/assets/images/themify/deepblue/fire/dust-content.png');
  353. --image-dust-choice1: url('/@/assets/images/themify/deepblue/fire/dust-choice1.png');
  354. --image-dust-content: url('/@/assets/images/themify/deepblue/fire/dust-content.png');
  355. --image-bj1: url('/@/assets/images/themify/deepblue/fire/bj1.png');
  356. }
  357. }
  358. .dustWarn {
  359. --image-border: url('/@/assets/images/fire/border.png');
  360. --image-no-choice: url('/@/assets/images/fire/no-choice.png');
  361. --image-choice: url('/@/assets/images/fire/choice.png');
  362. --image-dust-choice: url('/@/assets/images/fire/dust-choice.png');
  363. --image-dust-content: url('/@/assets/images/fire/dust-content.png');
  364. --image-dust-choice1: url('/@/assets/images/fire/dust-choice1.png');
  365. --image-dust-content: url('/@/assets/images/fire/dust-content.png');
  366. --image-bj1: url('/@/assets/images/fire/bj1.png');
  367. width: 100%;
  368. height: 100%;
  369. padding: 80px 10px 15px 10px;
  370. box-sizing: border-box;
  371. .top-dust {
  372. display: flex;
  373. justify-content: space-between;
  374. height: 50%;
  375. margin-bottom: 15px;
  376. background: var(--image-border) no-repeat center;
  377. background-size: 100% 100%;
  378. .alarm-menu {
  379. height: 100%;
  380. width: 15%;
  381. padding: 10px;
  382. box-sizing: border-box;
  383. .card-btn {
  384. width: 100%;
  385. height: 100%;
  386. overflow-y: auto;
  387. .btn {
  388. position: relative;
  389. width: 81%;
  390. height: 24%;
  391. margin-bottom: 6%;
  392. font-family: 'douyuFont';
  393. background: var(--image-no-choice) no-repeat;
  394. background-size: 100% 100%;
  395. cursor: pointer;
  396. .text {
  397. width: 80%;
  398. position: absolute;
  399. left: 50%;
  400. top: 28px;
  401. font-size: 14px;
  402. color: var(--vent-table-action-link);
  403. text-align: center;
  404. transform: translate(-50%, 0);
  405. }
  406. .warn {
  407. width: 100%;
  408. position: absolute;
  409. left: 50%;
  410. bottom: 11px;
  411. font-size: 12px;
  412. color: #fff;
  413. text-align: center;
  414. transform: translate(-50%, 0);
  415. }
  416. }
  417. .btn1 {
  418. position: relative;
  419. width: 100%;
  420. height: 24%;
  421. margin-bottom: 6%;
  422. font-family: 'douyuFont';
  423. background: var(--image-choice) no-repeat;
  424. background-size: 100% 100%;
  425. cursor: pointer;
  426. .text {
  427. width: 80%;
  428. position: absolute;
  429. left: 50%;
  430. top: 28px;
  431. font-size: 14px;
  432. color: var(--vent-table-action-link);
  433. text-align: center;
  434. transform: translate(-62%, 0);
  435. }
  436. .warn {
  437. width: 100%;
  438. position: absolute;
  439. left: 50%;
  440. bottom: 11px;
  441. font-size: 14px;
  442. color: #fff;
  443. text-align: center;
  444. transform: translate(-60%, 0);
  445. }
  446. }
  447. }
  448. }
  449. .dust-content {
  450. display: flex;
  451. justify-content: space-between;
  452. height: 100%;
  453. width: 85%;
  454. padding: 10px 0px;
  455. box-sizing: border-box;
  456. .content-left {
  457. width: 280px;
  458. height: 100%;
  459. display: flex;
  460. flex-direction: column;
  461. // justify-content: space-around;
  462. align-items: flex-start;
  463. overflow-y: auto;
  464. overflow-x: hidden;
  465. .content-left-item {
  466. position: relative;
  467. width: 272px;
  468. height: 173px;
  469. flex-shrink: 0;
  470. background: var(--image-dust-choice) no-repeat center;
  471. background-size: 100% 100%;
  472. margin: 5px 0px;
  473. .content-title {
  474. width: 85%;
  475. position: absolute;
  476. top: 2px;
  477. left: 50%;
  478. transform: translate(-55%, 0);
  479. font-size: 14px;
  480. color: #fff;
  481. text-align: center;
  482. }
  483. .content-items {
  484. position: absolute;
  485. left: 50%;
  486. transform: translate(-54%, 0);
  487. display: flex;
  488. justify-content: space-between;
  489. align-items: center;
  490. width: 240px;
  491. height: 26px;
  492. color: #fff;
  493. font-size: 14px;
  494. padding: 0px 5px;
  495. box-sizing: border-box;
  496. background: var(--image-dust-content) no-repeat center;
  497. background-size: 100% 100%;
  498. &:nth-child(2) {
  499. top: 32px;
  500. }
  501. &:nth-child(3) {
  502. top: 67px;
  503. }
  504. &:nth-child(4) {
  505. top: 102px;
  506. }
  507. &:nth-child(5) {
  508. top: 136px;
  509. }
  510. }
  511. }
  512. .content-left-item1 {
  513. position: relative;
  514. width: 250px;
  515. height: 173px;
  516. flex-shrink: 0;
  517. background: var(--image-dust-choice1) no-repeat center;
  518. background-size: 100% 100%;
  519. margin: 5px 0px;
  520. .content-title {
  521. width: 85%;
  522. position: absolute;
  523. top: 2px;
  524. left: 50%;
  525. transform: translate(-50%, 0);
  526. font-size: 14px;
  527. color: #fff;
  528. text-align: center;
  529. }
  530. .content-items {
  531. position: absolute;
  532. left: 50%;
  533. transform: translate(-54%, 0);
  534. display: flex;
  535. justify-content: space-between;
  536. align-items: center;
  537. width: 215px;
  538. height: 26px;
  539. color: #fff;
  540. font-size: 14px;
  541. padding: 0px 5px;
  542. box-sizing: border-box;
  543. background: var(--image-dust-content) no-repeat center;
  544. background-size: 100% 100%;
  545. &:nth-child(2) {
  546. top: 32px;
  547. }
  548. &:nth-child(3) {
  549. top: 67px;
  550. }
  551. &:nth-child(4) {
  552. top: 102px;
  553. }
  554. &:nth-child(5) {
  555. top: 136px;
  556. }
  557. }
  558. }
  559. }
  560. .content-right {
  561. width: calc(100% - 280px);
  562. height: 100%;
  563. .title-t {
  564. height: 30px;
  565. margin-bottom: 10px;
  566. display: flex;
  567. justify-content: space-between;
  568. align-items: center;
  569. .text-t {
  570. font-family: 'douyuFont';
  571. font-size: 14px;
  572. color: #fff;
  573. }
  574. }
  575. .echart-boxd {
  576. width: 100%;
  577. height: calc(100% - 40px);
  578. }
  579. }
  580. }
  581. }
  582. .bot-dust {
  583. height: calc(50% - 15px);
  584. background: var(--image-border) no-repeat center;
  585. background-size: 100% 100%;
  586. padding: 10px;
  587. box-sizing: border-box;
  588. .bot-area {
  589. height: 100%;
  590. padding: 10px;
  591. background: var(--image-bj1) no-repeat center;
  592. background-size: 100% 100%;
  593. box-sizing: border-box;
  594. }
  595. }
  596. }
  597. </style>