warndata.vue 15 KB

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