warndata.vue 16 KB

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