dustWarn.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <customHeader :options="options" @change="getSelectRow" :optionValue="optionValue"> 粉尘监测预警 </customHeader>
  3. <div class="dustWarn">
  4. <a-button preIcon="ant-design:rollback-outlined" type="text" size="small"
  5. style="position: absolute;left:15px;top:15px;color: #fff;" @click="getBack">返回</a-button>
  6. <div class="alarm-menu">
  7. <div class="card-btn">
  8. <div :class="activeIndex1 == ind ? 'btn1' : 'btn'" v-for="(item, ind) in menuList" :key="ind"
  9. @click="cardClick(ind, item)">
  10. <div class="text">{{ item.name }}</div>
  11. <div class="warn">{{ item.warn }}</div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="dust-content">
  16. <div class="top-area">
  17. <div :class="activeIndex == index ? 'top-box1' : 'top-box'" v-for="(item, index) in topAreaList"
  18. :key="index" @click="topAreaClick(index)">
  19. <div class="top-title">{{ item.title }}</div>
  20. <div class="top-content">
  21. <div class="content-item" v-for="(items, ind) in item.content" :key="ind">
  22. <span class="item-label">{{ items.label }}</span>
  23. <span class="item-value">{{ items.value }}</span>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="bot-area">
  29. <div class="title-t">
  30. <div class="text-t">粉尘信息状态监测</div>
  31. </div>
  32. <div class="echart-boxd">
  33. <echartLine :echartDataGq="echartDataFc" :maxY="maxY" :echartDw="echartDw" />
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script setup lang="ts">
  40. import { ref, reactive, onMounted,onUnmounted } from 'vue'
  41. import { sysTypeWarnList, sysWarn } from '../common.api'
  42. import echartLine from '../common/echartLine.vue';
  43. import { useSystemSelect } from '/@/hooks/vent/useSystemSelect';
  44. import { useRouter } from 'vue-router';
  45. import CustomHeader from '/@/components/vent/customHeader.vue';
  46. const { options, optionValue, getSelectRow, getSysDataSource } = useSystemSelect('sys_surface_caimei'); // 参数为场景类型(设备类型管理中可以查询到)
  47. //左侧数据列表
  48. let menuList = reactive<any[]>([])
  49. //当前左侧激活菜单的索引
  50. let activeIndex1 = ref(0);
  51. //顶部区域激活选项
  52. let activeIndex = ref(0);
  53. //顶部区域数据
  54. let topAreaList = reactive<any[]>([]);
  55. let choiceData = reactive<any[]>([]);
  56. //粉尘图表数据
  57. let echartDataFc = reactive({
  58. maxData: {
  59. lengedData: '粉尘浓度(mg/m³)',
  60. data: [],
  61. },
  62. xData: [],
  63. });
  64. let maxY = ref(0);
  65. let echartDw = ref('(mg/m³)');
  66. let router = useRouter()
  67. // https获取监测数据
  68. let timer: null | NodeJS.Timeout = null;
  69. function getMonitor(deviceID, flag?) {
  70. timer = setTimeout(
  71. async () => {
  72. await getSysWarnList(deviceID, 'dust');
  73. if (timer) {
  74. timer = null;
  75. }
  76. getMonitor(deviceID);
  77. },
  78. flag ? 0 : 1000
  79. );
  80. }
  81. //返回首页
  82. function getBack() {
  83. router.push('/monitorChannel/monitor-alarm-home')
  84. }
  85. //获取左侧菜单列表
  86. async function getMenuList() {
  87. let res = await sysTypeWarnList({ type: 'dust' })
  88. if (res.length != 0) {
  89. menuList.length = 0
  90. res.forEach((el) => {
  91. menuList.push({
  92. name: el.systemname,
  93. warn: '低风险',
  94. deviceID: el.id,
  95. strtype: el.strtype,
  96. });
  97. });
  98. getMonitor(menuList[0].deviceID, true);
  99. }
  100. }
  101. //获取预警详情弹窗右侧数据
  102. function getSysWarnList(id, type) {
  103. sysWarn({ sysid: id, type: type }).then((res) => {
  104. // listData.common = res;
  105. topAreaList.length = 0;
  106. echartDataFc.maxData.data.length = 0;
  107. echartDataFc.xData.length = 0;
  108. if (JSON.stringify(res) != '{}') {
  109. res.dust.forEach((el) => {
  110. topAreaList.push({
  111. title: el.strinstallpos,
  112. content: [
  113. { ids: 0, label: '温度(°C)', value: el.readData.temperature || '--' },
  114. { ids: 1, label: '粉尘浓度(mg/m³)', value: el.readData.dustval || '--' },
  115. { ids: 2, label: '喷雾水压(MPa)', value: el.readData.waterPressure || '--' },
  116. { ids: 3, label: '喷雾状态', value: el.readData.atomizingState || '--' },
  117. ],
  118. });
  119. });
  120. choiceData = res.dust;
  121. if (choiceData[activeIndex.value]) {
  122. choiceData[activeIndex.value].history.forEach((el) => {
  123. echartDataFc.maxData.data.push(el.dustval);
  124. echartDataFc.xData.push(el.time);
  125. });
  126. let max1 = echartDataFc.maxData.data.reduce((acr, cur) => {
  127. return acr > cur ? acr : cur;
  128. });
  129. maxY.value = formatRoundNum(max1 * 1.5);
  130. } else {
  131. activeIndex.value = 0;
  132. choiceData[activeIndex.value].history.forEach((el) => {
  133. echartDataFc.maxData.data.push(el.dustval);
  134. echartDataFc.xData.push(el.time);
  135. });
  136. let max1 = echartDataFc.maxData.data.reduce((acr, cur) => {
  137. return acr > cur ? acr : cur;
  138. });
  139. maxY.value = formatRoundNum(max1 * 1.5);
  140. }
  141. }
  142. });
  143. }
  144. //菜单选项切换
  145. function cardClick(ind, item) {
  146. activeIndex1.value = ind;
  147. clearTimeout(timer);
  148. getMonitor(item.deviceID, true);
  149. }
  150. //顶部区域选项切换
  151. function topAreaClick(index) {
  152. activeIndex.value = index;
  153. echartDataFc.maxData.data.length = 0;
  154. echartDataFc.xData.length = 0;
  155. choiceData[index].history.forEach((el) => {
  156. echartDataFc.maxData.data.push(el.dustval);
  157. echartDataFc.xData.push(el.time);
  158. });
  159. }
  160. function formatRoundNum(num) {
  161. let interger = Math.ceil(num);
  162. let leng = String(interger).length;
  163. return Math.ceil(interger / Math.pow(10, leng - 1)) * Math.pow(10, leng - 1);
  164. }
  165. onMounted(() => {
  166. getMenuList()
  167. })
  168. onUnmounted(() => {
  169. if (timer) {
  170. clearTimeout(timer);
  171. timer = undefined;
  172. }
  173. });
  174. </script>
  175. <style lang="less" scoped>
  176. .dustWarn {
  177. width: 100%;
  178. height: 100%;
  179. padding: 80px 10px 15px 10px;
  180. box-sizing: border-box;
  181. display: flex;
  182. justify-content: space-between;
  183. .alarm-menu {
  184. height: 100%;
  185. width: 15%;
  186. .card-btn {
  187. width: 100%;
  188. height: 100%;
  189. overflow-y: auto;
  190. .btn {
  191. position: relative;
  192. width: 81%;
  193. height: 14%;
  194. margin-bottom: 10%;
  195. font-family: 'douyuFont';
  196. background: url('../../../../../assets/images/fire/no-choice.png') no-repeat;
  197. background-size: 100% 100%;
  198. cursor: pointer;
  199. .text {
  200. width: 80%;
  201. position: absolute;
  202. left: 50%;
  203. top: 28px;
  204. font-size: 16px;
  205. color: #01fefc;
  206. text-align: center;
  207. transform: translate(-50%, 0);
  208. }
  209. .warn {
  210. width: 100%;
  211. position: absolute;
  212. left: 50%;
  213. bottom: 14px;
  214. font-size: 14px;
  215. color: #fff;
  216. text-align: center;
  217. transform: translate(-50%, 0);
  218. }
  219. }
  220. .btn1 {
  221. position: relative;
  222. width: 100%;
  223. height: 14%;
  224. margin-bottom: 10%;
  225. font-family: 'douyuFont';
  226. background: url('../../../../../assets/images/fire/choice.png') no-repeat;
  227. background-size: 100% 100%;
  228. cursor: pointer;
  229. .text {
  230. width: 80%;
  231. position: absolute;
  232. left: 50%;
  233. top: 28px;
  234. font-size: 16px;
  235. color: #01fefc;
  236. text-align: center;
  237. transform: translate(-62%, 0);
  238. }
  239. .warn {
  240. width: 100%;
  241. position: absolute;
  242. left: 50%;
  243. bottom: 14px;
  244. font-size: 14px;
  245. color: #fff;
  246. text-align: center;
  247. transform: translate(-60%, 0);
  248. }
  249. }
  250. }
  251. }
  252. .dust-content {
  253. width: calc(85% - 10px);
  254. height: 100%;
  255. margin-left: 10px;
  256. padding: 15px;
  257. box-sizing: border-box;
  258. background: url('../../../../../assets/images/fire/border.png') no-repeat;
  259. background-size: 100% 100%;
  260. .top-area {
  261. width: 100%;
  262. height: 24%;
  263. display: flex;
  264. justify-content: flex-start;
  265. align-items: flex-end;
  266. margin-bottom: 10px;
  267. overflow-x: auto;
  268. transform: scaleY(-1);
  269. .top-box {
  270. position: relative;
  271. width: 474px;
  272. height: 88%;
  273. flex-shrink: 0;
  274. background: url('../../../../../assets/images/fire/fc-t.png') no-repeat center;
  275. background-size: 100% 100%;
  276. margin: 0px 20px;
  277. transform: scaleY(-1);
  278. .top-title {
  279. width: 80%;
  280. text-align: center;
  281. position: absolute;
  282. left: 50%;
  283. top: 8px;
  284. font-size: 14px;
  285. transform: translate(-50%, 0);
  286. color: #fff;
  287. }
  288. .top-content {
  289. position: absolute;
  290. top: 17%;
  291. left: 0;
  292. width: 100%;
  293. height: 83%;
  294. display: flex;
  295. justify-content: flex-start;
  296. align-items: flex-start;
  297. flex-wrap: wrap;
  298. cursor: pointer;
  299. .content-item {
  300. position: relative;
  301. width: 50%;
  302. height: 50%;
  303. background: url('../../../../../assets/images/fire/content-item.png') no-repeat center;
  304. background-size: 88% 50%;
  305. .item-label {
  306. position: absolute;
  307. left: 14%;
  308. top: 50%;
  309. transform: translate(0, -44%);
  310. font-size: 14px;
  311. color: #fff;
  312. // font-size: 12px;
  313. }
  314. .item-value {
  315. position: absolute;
  316. right: 14%;
  317. top: 50%;
  318. transform: translate(0, -38%);
  319. // font-size: 12px;
  320. font-size: 14px;
  321. font-family: 'douyuFont';
  322. color: #3df6ff;
  323. }
  324. }
  325. }
  326. }
  327. .top-box1 {
  328. position: relative;
  329. width: 474px;
  330. height: 100%;
  331. flex-shrink: 0;
  332. background: url('../../../../../assets/images/fire/fc-t1.png') no-repeat center;
  333. background-size: 100% 100%;
  334. margin: 0px 20px;
  335. transform: scaleY(-1);
  336. .top-title {
  337. width: 80%;
  338. text-align: center;
  339. position: absolute;
  340. left: 50%;
  341. top: 8px;
  342. font-size: 14px;
  343. transform: translate(-50%, 0);
  344. color: #fff;
  345. }
  346. .top-content {
  347. position: absolute;
  348. top: 17%;
  349. left: 0;
  350. width: 100%;
  351. height: 83%;
  352. display: flex;
  353. justify-content: flex-start;
  354. align-items: flex-start;
  355. flex-wrap: wrap;
  356. padding-bottom: 20px;
  357. box-sizing: border-box;
  358. cursor: pointer;
  359. .content-item {
  360. position: relative;
  361. width: 50%;
  362. height: 50%;
  363. background: url('../../../../../assets/images/fire/content-item.png') no-repeat center;
  364. background-size: 88% 50%;
  365. .item-label {
  366. position: absolute;
  367. left: 14%;
  368. top: 50%;
  369. transform: translate(0, -44%);
  370. color: #fff;
  371. font-size: 14px;
  372. // font-size: 12px;
  373. }
  374. .item-value {
  375. position: absolute;
  376. right: 14%;
  377. top: 50%;
  378. transform: translate(0, -38%);
  379. // font-size: 12px;
  380. font-size: 14px;
  381. font-family: 'douyuFont';
  382. color: #3df6ff;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. .bot-area {
  389. height: calc(76% - 10px);
  390. padding: 10px;
  391. background: url('../../../../../assets/images/fire/bj1.png') no-repeat center;
  392. background-size: 100% 100%;
  393. box-sizing: border-box;
  394. .title-t {
  395. height: 30px;
  396. margin-bottom: 10px;
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. .text-t {
  401. font-family: 'douyuFont';
  402. font-size: 14px;
  403. color: #fff;
  404. }
  405. }
  406. .echart-boxd {
  407. width: 100%;
  408. height: calc(100% - 40px);
  409. }
  410. }
  411. }
  412. }
  413. </style>