warndata.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <view class="container">
  3. <u-navbar
  4. :title="titleName"
  5. :bgStatusImage="backPic0"
  6. :bgImage="backPic"
  7. :safeAreaInsetTop="true"
  8. left-icon=""
  9. @leftClick="menuShow"
  10. >
  11. <view class="u-nav-slot" slot="left" v-if="!isShowDetail">
  12. <u-icon name="arrow-left" size="20"> </u-icon>
  13. </view>
  14. </u-navbar>
  15. <view>
  16. <view class="main" v-if="isShowDetail">
  17. <view class="flcard" v-if="isShow1">
  18. <view class="typeBar">
  19. <view class="icon-vent">
  20. <text class="text-style">通风监测预警</text>
  21. </view>
  22. <u-icon @click="toggleIsShow1" name="arrow-up-fill"></u-icon>
  23. </view>
  24. </view>
  25. <view class="flcard" v-else>
  26. <view class="typeBar">
  27. <text class="text-style">通风监测预警</text>
  28. <u-icon @click="toggleIsShow1" name="arrow-down-fill"></u-icon>
  29. </view>
  30. </view>
  31. <view class="flcard" @click="getDetail('vent')" v-show="isShow1">
  32. <view class="datacard demo-layout bg-purple-light">
  33. <view style="margin-top: 10rpx">
  34. <text class="text-style1">{{ windData.zongjinfeng }}</text>
  35. </view>
  36. <view style="margin-top: 10rpx">总进风量(m³/min):</view>
  37. </view>
  38. <view class="datacard demo-layout bg-purple-light">
  39. <view style="margin-top: 10rpx">
  40. <text class="text-style1">{{ windData.zonghuifeng }}</text>
  41. </view>
  42. <view style="margin-top: 10rpx">总回风量(m³/min):</view>
  43. </view>
  44. <view class="datacard demo-layout bg-purple-light">
  45. <view style="margin-top: 10rpx">
  46. <text class="text-style1">{{ xufengliang }}</text>
  47. </view>
  48. <view style="margin-top: 10rpx">总需风量(m³/min):</view>
  49. </view>
  50. </view>
  51. <view class="flcard" v-if="isShow2">
  52. <view class="typeBar">
  53. <view class="icon-vent">
  54. <text class="text-style">火灾监测预警</text>
  55. </view>
  56. <u-icon @click="toggleIsShow2" name="arrow-up-fill"></u-icon>
  57. </view>
  58. </view>
  59. <view class="flcard" v-else>
  60. <view class="typeBar">
  61. <text class="text-style">火灾监测预警</text>
  62. <u-icon @click="toggleIsShow2" name="arrow-down-fill"></u-icon>
  63. </view>
  64. </view>
  65. <view class="flcard" v-show="isShow2" @click="getDetail('fire')">
  66. <view class="firecontainer">
  67. <view class="title">
  68. <span class="firetext">内因火灾</span>
  69. </view>
  70. <view class="fire-style">
  71. <view
  72. v-for="(item, index) in internalInfo"
  73. :key="index"
  74. class="fire-item1"
  75. v-if="item && Object.keys(item).length > 0"
  76. >
  77. <view class="firecard">
  78. <text
  79. :class="
  80. item.Maxlevel > 0 ? 'red-text-style' : 'text-style1'
  81. "
  82. >{{ item.value
  83. }}{{
  84. item.code === "o2val" ||
  85. item.code === "co2val" ||
  86. item.code === "ch4val" ||
  87. item.code === "smokeval"
  88. ? "(%)"
  89. : item.code === "fmax" ||
  90. item.code === "temperature" ||
  91. item.code === "fireval"
  92. ? "(℃)"
  93. : "(ppm)"
  94. }}
  95. </text>
  96. <view style="margin-top: 10rpx">{{ item.monitorcode }}</view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="firecontainer">
  102. <view class="title">
  103. <span class="firetext">外因火灾</span>
  104. </view>
  105. <view class="fire-style">
  106. <view
  107. v-for="(item, index) in externalInfo"
  108. :key="index"
  109. class="fire-item1"
  110. >
  111. <view class="firecard">
  112. <text
  113. :class="
  114. item.Maxlevel > 0 ? 'red-text-style' : 'text-style1'
  115. "
  116. >{{ item.value
  117. }}{{
  118. item.code === "o2val" ||
  119. item.code === "co2val" ||
  120. item.code === "ch4val" ||
  121. item.code === "smokeval"
  122. ? "(%)"
  123. : item.code === "fmax" ||
  124. item.code === "temperature" ||
  125. item.code === "fireval"
  126. ? "(℃)"
  127. : "(ppm)"
  128. }}
  129. </text>
  130. <view style="margin-top: 10rpx">{{ item.monitorcode }}</view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="flcard" v-if="isShow3">
  137. <view class="typeBar">
  138. <view class="icon-vent">
  139. <text class="text-style">粉尘监测预警</text>
  140. </view>
  141. <u-icon @click="toggleIsShow3" name="arrow-up-fill"></u-icon>
  142. </view>
  143. </view>
  144. <view class="flcard" v-else>
  145. <view class="typeBar">
  146. <text class="text-style">粉尘监测预警</text>
  147. <u-icon @click="toggleIsShow3" name="arrow-down-fill"></u-icon>
  148. </view>
  149. </view>
  150. <view class="flcard" v-show="isShow3" @click="getDetail('dust')">
  151. <view class="firecard fire-style">
  152. <view v-for="(value, key) in dustData" :key="key" class="fire-item">
  153. <view style="margin-top: 20rpx">
  154. <image
  155. src="/static/warndata/alarm.svg"
  156. class="icon-style"
  157. :style="{ backgroundColor: key === 'alarm' ? 'red' : key }"
  158. ></image>
  159. <span style="margin-top: 10rpx">
  160. {{ dustMap[key] }} :{{ value }}</span
  161. >
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. <view class="flcard" v-if="isShow4">
  167. <view class="typeBar">
  168. <view class="icon-vent">
  169. <text class="text-style">瓦斯监测预警</text>
  170. </view>
  171. <u-icon @click="toggleIsShow4" name="arrow-up-fill"></u-icon>
  172. </view>
  173. </view>
  174. <view class="flcard" v-else>
  175. <view class="typeBar">
  176. <text class="text-style">瓦斯监测预警</text>
  177. <u-icon @click="toggleIsShow4" name="arrow-down-fill"></u-icon>
  178. </view>
  179. </view>
  180. <view class="flcard" v-show="isShow4" @click="getDetail('gas')">
  181. <view class="firecontainer">
  182. <view class="title">
  183. <span class="firetext" v-if="gasDevice.length > 0"
  184. >安全监测系统监测点</span
  185. >
  186. </view>
  187. <view
  188. class="gascard"
  189. v-for="(item, index) in gasDevice"
  190. :key="index"
  191. >
  192. <view style="margin-top: 20rpx">
  193. <text class="text-style1">{{ item.gasNumber }}</text>
  194. <view style="margin: 10rpx">{{ item.systemname }}</view>
  195. </view>
  196. </view>
  197. </view>
  198. <view class="firecontainer">
  199. <view class="title">
  200. <span class="firetext" v-if="gasDevice.length > 0"
  201. >瓦斯抽采系统监测点</span
  202. >
  203. </view>
  204. <view class="gascontainer">
  205. <view
  206. class="gascard"
  207. v-for="(item, index) in gasDevice"
  208. :key="index"
  209. >
  210. <view style="margin-top: 20rpx">
  211. <text class="text-style1">{{ item.pumpNumber }}</text>
  212. <view style="margin: 10rpx">{{ item.systemname }}</view>
  213. </view>
  214. </view>
  215. </view>
  216. </view>
  217. </view>
  218. <view class="flcard" v-if="isShow5">
  219. <view class="typeBar">
  220. <view class="icon-vent">
  221. <text class="text-style">设备监测预警</text>
  222. </view>
  223. <u-icon @click="toggleIsShow5" name="arrow-up-fill"></u-icon>
  224. </view>
  225. </view>
  226. <view class="flcard" v-else>
  227. <view class="typeBar">
  228. <text class="text-style">设备监测预警</text>
  229. <u-icon @click="toggleIsShow5" name="arrow-down-fill"></u-icon>
  230. </view>
  231. </view>
  232. <view
  233. class="flcard demo-layout bg-purple-light"
  234. v-show="isShow5"
  235. @click="getDetail('device')"
  236. >
  237. <view class="deviceCard">
  238. <view
  239. class="item-container"
  240. v-for="(item, index) in devicekindData"
  241. :key="index"
  242. :style="{ backgroundImage: itemBackground(item) }"
  243. >
  244. <view class="item">
  245. <text style="margin-right: 10px">{{ item.name }}</text>
  246. <text>{{ item.status }}</text>
  247. </view>
  248. </view>
  249. </view>
  250. </view>
  251. </view>
  252. <view class="main" v-else>
  253. <ventDetail v-if="Type == 'vent'"></ventDetail>
  254. <deviceDetail v-if="Type == 'device'"></deviceDetail>
  255. <fireDetail v-if="Type == 'fire'"></fireDetail>
  256. <dustDetail v-if="Type == 'dust'"></dustDetail>
  257. <gasDetail v-if="Type == 'gas'"></gasDetail>
  258. </view>
  259. </view>
  260. </view>
  261. </template>
  262. <script>
  263. import api from "@/api/api";
  264. import ventDetail from "./components/vent-detail.vue";
  265. import deviceDetail from "./components/device-detail.vue";
  266. import fireDetail from "./components/fire-detail.vue";
  267. import dustDetail from "./components/dust-detail.vue";
  268. import gasDetail from "./components/gas-detail.vue";
  269. export default {
  270. props: {},
  271. watch: {},
  272. data() {
  273. return {
  274. backPic0: "url(/static/topnavbar0.png)",
  275. backPic: "url(../../static/topnavbar.png)",
  276. titleName: "预警分析",
  277. isShowDetail: true,
  278. detailComponent: null,
  279. windData: {},
  280. devicekindData: [],
  281. fireData: [],
  282. gasData: [],
  283. dustData: [],
  284. gasDevice: [],
  285. externalInfo: [],
  286. internalInfo: [],
  287. xufengliang: "", //总需风量
  288. imageMap: {
  289. atomizing: "atomizing.png",
  290. ballvalve: "ballvalve.png",
  291. dedustefan: "dedustefan.png",
  292. drilling: "drilling.png",
  293. dustdev: "dustdev.png",
  294. fanlocal: "fanlocal.png",
  295. fanmain: "fanmain.png",
  296. forcFan: "forcFan.png",
  297. gasmonitor: "gasmonitor.png",
  298. gate: "gate.png",
  299. location: "location.png",
  300. nitrogen: "nitrogen.png",
  301. pulping: "pulping.png",
  302. pump: "pump.png",
  303. rebroadcast: "rebroadcast.png",
  304. safetymonitor: "safetymonitor.png",
  305. spary: "spary.png",
  306. unit: "unit.png",
  307. window: "window.png",
  308. windrect: "windrect.png",
  309. wintest: "wintest.png",
  310. },
  311. dustMap: {
  312. alarm: "报警",
  313. blue: "低风险",
  314. orange: "重大风险",
  315. red: "较大风险",
  316. yellow: "一般风险",
  317. },
  318. isShow1: true,
  319. isShow2: true,
  320. isShow3: false,
  321. isShow4: false,
  322. isShow5: false,
  323. Type: "", // 当前点击的类型
  324. };
  325. },
  326. mounted() {
  327. this.$nextTick(() => {
  328. this.getWarnInfo();
  329. });
  330. },
  331. components: {
  332. ventDetail,
  333. deviceDetail,
  334. fireDetail,
  335. dustDetail,
  336. gasDetail,
  337. },
  338. methods: {
  339. //获取预警信息
  340. getWarnInfo() {
  341. return new Promise((resolve, reject) => {
  342. api
  343. .getWarnInfo()
  344. .then((response) => {
  345. if (response.data.code == 200) {
  346. this.windData = response.data.result.ventInfo;
  347. this.devicekindData = response.data.result.info.devicekindInfo;
  348. this.fireData = response.data.result.info.sysInfo.fireS;
  349. const externalInfo1 = this.fireData.summaryInfo.external;
  350. const internalInfo1 = this.fireData.summaryInfo.internal;
  351. for (let key in externalInfo1) {
  352. if (!externalInfo1.hasOwnProperty(key)) continue;
  353. const item = externalInfo1[key];
  354. // 跳过空对象(如 ch4val: {})
  355. if (Object.keys(item).length === 0) continue;
  356. if (item.code == "coval") {
  357. item.monitorcode = "一氧化碳";
  358. } else if (item.code == "ch4val") {
  359. item.monitorcode = "甲烷";
  360. } else if (item.code == "o2val") {
  361. item.monitorcode = "氧气";
  362. } else if (item.code == "co2val") {
  363. item.monitorcode = "二氧化碳";
  364. } else if (item.code == "fmax") {
  365. item.monitorcode = "温度";
  366. } else if (item.code == "chval") {
  367. item.monitorcode = "乙炔";
  368. } else if (item.code == "ch2val") {
  369. item.monitorcode = "乙烯";
  370. } else if (item.code == "temperature") {
  371. item.monitorcode = "温度";
  372. } else if (item.code == "gasval") {
  373. item.monitorcode = "瓦斯";
  374. } else if (item.code == "fireval") {
  375. item.monitorcode = "温度";
  376. } else if (item.code == "smokeval") {
  377. item.monitorcode = "烟雾";
  378. }
  379. }
  380. for (let key in internalInfo1) {
  381. if (!internalInfo1.hasOwnProperty(key)) continue;
  382. const item = internalInfo1[key];
  383. // 跳过空对象(如 ch4val: {})
  384. if (Object.keys(item).length === 0) continue;
  385. if (item.code == "coval") {
  386. item.monitorcode = "一氧化碳";
  387. } else if (item.code == "ch4val") {
  388. item.monitorcode = "甲烷";
  389. } else if (item.code == "o2val") {
  390. item.monitorcode = "氧气";
  391. } else if (item.code == "co2val") {
  392. item.monitorcode = "二氧化碳";
  393. } else if (item.code == "chval") {
  394. item.monitorcode = "乙炔";
  395. } else if (item.code == "ch2val") {
  396. item.monitorcode = "乙烯";
  397. } else if (item.code == "fmax") {
  398. item.monitorcode = "温度";
  399. } else if (item.code == "temperature") {
  400. item.monitorcode = "温度";
  401. } else if (item.code == "gasval") {
  402. item.monitorcode = "瓦斯";
  403. } else if (item.code == "fireval") {
  404. item.monitorcode = "温度";
  405. } else if (item.code == "smokeval") {
  406. item.monitorcode = "烟雾";
  407. }
  408. }
  409. this.externalInfo = externalInfo1;
  410. this.internalInfo = internalInfo1;
  411. this.gasData = response.data.result.info.sysInfo.gasS;
  412. this.gasDevice = this.gasData.devices;
  413. this.xufengliang = this.windData.sysdata.xufengliang;
  414. this.dustData = response.data.result.info.sysInfo.dustS.levels;
  415. } else {
  416. reject(response);
  417. }
  418. })
  419. .catch((error) => {
  420. console.log("catch===>response", response);
  421. reject(error);
  422. });
  423. });
  424. },
  425. //返回监测首页
  426. menuShow() {
  427. this.isShowDetail = true;
  428. },
  429. //跳转监测详情
  430. getDetail(data) {
  431. this.isShowDetail = false;
  432. this.Type = data; // 将当前点击的类型存储到 Type 中
  433. },
  434. toggleIsShow1() {
  435. this.isShow1 = !this.isShow1; // 切换 isShow 的值
  436. },
  437. toggleIsShow2() {
  438. this.isShow2 = !this.isShow2; // 切换 isShow 的值
  439. },
  440. toggleIsShow3() {
  441. this.isShow3 = !this.isShow3; // 切换 isShow 的值
  442. },
  443. toggleIsShow4() {
  444. this.isShow4 = !this.isShow4; // 切换 isShow 的值
  445. },
  446. toggleIsShow5() {
  447. this.isShow5 = !this.isShow5; // 切换 isShow 的值
  448. },
  449. },
  450. computed: {
  451. itemBackground() {
  452. return (item) => {
  453. const defaultImage = "unit.png";
  454. const imageName = this.imageMap[item.code] || defaultImage;
  455. return `url('/static/warndata/${imageName}')`;
  456. };
  457. },
  458. },
  459. };
  460. </script>
  461. <style lang="scss" scoped>
  462. .container {
  463. display: flex;
  464. flex-direction: column;
  465. }
  466. .main {
  467. margin-top: 80px;
  468. display: flex;
  469. flex-direction: column;
  470. flex: 1;
  471. width: 100%;
  472. margin-top: 45px;
  473. background: #f1f5f6;
  474. /* 内容区域顶部留出导航栏的高度 */
  475. }
  476. .text-style {
  477. font-weight: bold;
  478. }
  479. .flcard {
  480. padding: 20rpx;
  481. background-color: #ffffff;
  482. margin-bottom: 5rpx;
  483. }
  484. .datacard {
  485. width: 32.5%;
  486. margin: 1px;
  487. float: left;
  488. height: 100rpx;
  489. text-align: center;
  490. border-radius: 10px;
  491. background: url(/static/model/windM3.png),
  492. linear-gradient(
  493. to right,
  494. rgba(55, 135, 254, 0.08),
  495. rgba(4, 184, 255, 0.08),
  496. rgba(60, 161, 237, 0.08)
  497. );
  498. }
  499. .datacard1 {
  500. width: 100%;
  501. margin: 2px;
  502. float: left;
  503. height: 200rpx;
  504. text-align: center;
  505. border-radius: 10px;
  506. background: linear-gradient(
  507. to right,
  508. rgba(55, 135, 254, 0.08),
  509. rgba(4, 184, 255, 0.08),
  510. rgba(60, 161, 237, 0.08)
  511. );
  512. }
  513. .title {
  514. position: relative;
  515. width: 100%;
  516. height: 50rpx;
  517. background: url(/static/warndata/title.png);
  518. background-repeat: no-repeat;
  519. background-size: 100% 100%;
  520. display: flex;
  521. /* 将父级元素设置为 Flex 容器 */
  522. align-items: center;
  523. /* 垂直居中子元素 */
  524. }
  525. .firecard {
  526. width: 100%;
  527. padding: 10px;
  528. float: left;
  529. text-align: center;
  530. border-radius: 10px;
  531. background: linear-gradient(
  532. to right,
  533. rgba(55, 135, 254, 0.08),
  534. rgba(4, 184, 255, 0.08),
  535. rgba(60, 161, 237, 0.08)
  536. );
  537. background-repeat: repeat;
  538. }
  539. .deviceCard {
  540. display: grid;
  541. grid-template-columns: repeat(2, 1fr);
  542. margin-top: 10rpx;
  543. }
  544. .item-container {
  545. height: 100px;
  546. /* 设置容器高度,根据需要进行调整 */
  547. background-size: 100% 60%;
  548. /* 设置背景图片尺寸,根据需要进行调整 */
  549. background-repeat: no-repeat;
  550. /* 设置背景图片不重复,根据需要进行调整 */
  551. }
  552. .item {
  553. margin-left: 70px;
  554. margin-top: 36px;
  555. }
  556. .firetext {
  557. margin: 20px;
  558. }
  559. .text-style1 {
  560. color: #3787fe;
  561. font-weight: bold;
  562. font-size: 16px;
  563. }
  564. .red-text-style1 {
  565. color: #ff0000;
  566. font-weight: bold;
  567. font-size: 16px;
  568. }
  569. .firecontainer {
  570. margin-top: 10px;
  571. }
  572. .fire-style {
  573. display: flex;
  574. flex-wrap: wrap;
  575. }
  576. .fire-item {
  577. width: calc(33.33% - 20px);
  578. margin: 16rpx;
  579. box-sizing: border-box;
  580. }
  581. .fire-item1 {
  582. width: 45%;
  583. margin: 16rpx;
  584. box-sizing: border-box;
  585. }
  586. .gascontainer {
  587. display: flex;
  588. }
  589. .gascard {
  590. width: calc(33.33% - 20px);
  591. margin: 1px;
  592. float: left;
  593. text-align: center;
  594. border-radius: 10px;
  595. margin: 10px;
  596. background: url(/static/warndata/work.png),
  597. linear-gradient(
  598. to right,
  599. rgba(55, 135, 254, 0.08),
  600. rgba(4, 184, 255, 0.08),
  601. rgba(60, 161, 237, 0.08)
  602. );
  603. }
  604. .icon-style {
  605. margin-right: 8px;
  606. width: 13px;
  607. height: 13px;
  608. border-radius: 4px;
  609. }
  610. .typeBar {
  611. display: flex;
  612. justify-content: space-between;
  613. .icon-vent {
  614. display: flex;
  615. .u-icon--right {
  616. margin: 0px 5px;
  617. }
  618. }
  619. }
  620. </style>