vent-detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <view class="vent-detail">
  3. <u-tabs
  4. class="devic-box-tab"
  5. :current="PageCur"
  6. :list="tabList"
  7. @click="NavChange"
  8. ></u-tabs>
  9. <view class="vent-content">
  10. <view class="top-area">
  11. <view class="top-title">
  12. <view style="font-weight: bold">{{ mainTitle || "--" }}</view>
  13. <view class="title-icon">
  14. <image
  15. src="/static/model/alarmTrue.svg"
  16. alt=""
  17. class="icon-style"
  18. />
  19. <text class="icon-text">低风险</text>
  20. </view>
  21. </view>
  22. <view class="top-card">
  23. <view class="card-box" v-for="(item, index) in cardList" :key="index">
  24. <view class="box-item">
  25. <view class="box-val">{{ item.value }}</view>
  26. <view class="box-name">{{ item.name }}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="center-area">
  32. <view class="top-title">
  33. <view style="font-weight: bold">通风信息状态监测</view>
  34. </view>
  35. <view class="echartBox">
  36. <!-- <canvas
  37. id="myChart"
  38. :style="{ width: '100%', height: '180px' }"
  39. ></canvas> -->
  40. <LineChart
  41. :chartData="option"
  42. :style="{ width: '100%', height: '180px' }"
  43. ></LineChart>
  44. </view>
  45. </view>
  46. <view class="bot-area">
  47. <view class="top-title">
  48. <view style="font-weight: bold">通风监控测点信息</view>
  49. </view>
  50. <view class="bot-content">
  51. <view class="card-b" v-for="(item, index) in cardListTf" :key="index">
  52. <div class="item-l">
  53. <div class="label-l">{{ item.label }}</div>
  54. <div class="value-l">{{ item.value }}</div>
  55. </div>
  56. <div class="item-r">
  57. <div
  58. class="content-r"
  59. v-for="(items, ind) in item.listR"
  60. :key="ind"
  61. >
  62. <span>{{ `${items.label} : ` }}</span>
  63. <span
  64. :class="{
  65. 'status-f': items.value == 1,
  66. 'status-l': items.value == 0,
  67. }"
  68. >{{ `${items.value}${items.dw}` }}</span
  69. >
  70. </div>
  71. </div>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import api from "@/api/api";
  80. export default {
  81. name: "ventDetail",
  82. props: {},
  83. watch: {},
  84. data() {
  85. return {
  86. mainTitle: "",
  87. timer: "",
  88. PageCur: "0",
  89. tabList: [],
  90. cardList: [
  91. { name: "进风量(m³/min)", value: 0 },
  92. { name: "回风量(m³/min)", value: 0 },
  93. { name: "需风量(m³/min)", value: 0 },
  94. ],
  95. //echarts图表数据
  96. maxY: 0,
  97. xData: [],
  98. yDataJ: [],
  99. yDataH: [],
  100. yDataX: [],
  101. cardListTf: [],
  102. option: {},
  103. };
  104. },
  105. mounted() {
  106. this.getTabList();
  107. this.getWindDeviceList();
  108. // than.initChart();
  109. },
  110. beforeDestroy() {
  111. this.timer = null;
  112. clearTimeout(this.timer);
  113. },
  114. methods: {
  115. NavChange: function (item) {
  116. clearTimeout(this.timer);
  117. this.PageCur = item.index;
  118. this.mainTitle = this.tabList[this.PageCur].name;
  119. this.getMonitor(this.tabList[this.PageCur].deviceID, true);
  120. },
  121. getMonitor(deviceID, flag) {
  122. let than = this;
  123. than.timer = setTimeout(
  124. async () => {
  125. await than.getSysWarnList(deviceID, "vent");
  126. if (than.timer) {
  127. than.timer = null;
  128. }
  129. than.getMonitor(deviceID);
  130. },
  131. flag ? 0 : 3000
  132. );
  133. },
  134. //获取顶部tab选项数据
  135. async getTabList() {
  136. try {
  137. await new Promise((resolve, reject) => {
  138. api
  139. .sysTypeWarn({ type: "vent" })
  140. .then((response) => {
  141. if (
  142. response.data.code == 200 &&
  143. response.data.result.length != 0
  144. ) {
  145. let result = response.data.result;
  146. this.tabList = result.map((el) => {
  147. //lxh
  148. return {
  149. name: el.deviceName,
  150. warn: "低风险",
  151. deviceID: el.deviceID,
  152. strtype: el.deviceType,
  153. };
  154. });
  155. this.mainTitle = this.tabList[0].name;
  156. this.getMonitor(this.tabList[0].deviceID, true);
  157. } else {
  158. reject(response);
  159. }
  160. })
  161. .catch((error) => {
  162. console.log("catch===>response", response);
  163. reject(error);
  164. });
  165. });
  166. } catch (error) {
  167. console.error("数据加载失败:", error);
  168. }
  169. },
  170. formatRoundNum(num) {
  171. let interger = Math.ceil(num);
  172. let leng = String(interger).length;
  173. return (
  174. Math.ceil(interger / Math.pow(10, leng - 1)) * Math.pow(10, leng - 1)
  175. );
  176. },
  177. //获取选项详情数据
  178. getSysWarnList(id, type) {
  179. return new Promise((resolve, reject) => {
  180. api
  181. .sysWarn({ sysid: id, type: type })
  182. .then((response) => {
  183. if (response.data.code == 200) {
  184. this.xData = [];
  185. this.yDataH = [];
  186. this.yDataJ = [];
  187. this.yDataX = [];
  188. let data = response.data.result;
  189. this.cardList[0].value = data.jin || "--";
  190. this.cardList[1].value = data.hui || "--";
  191. this.cardList[2].value = data.xufengliang || "--";
  192. if (data.history.length != 0) {
  193. data.history.forEach((v) => {
  194. //lxh
  195. this.yDataJ.push(parseFloat(v.jin));
  196. this.yDataH.push(parseFloat(v.hui));
  197. if (
  198. this.cardList[2].value &&
  199. this.cardList[2].value != "--"
  200. ) {
  201. this.yDataX.push(this.cardList[2].value);
  202. } else {
  203. this.yDataX.push(0);
  204. }
  205. this.xData.push(v.time);
  206. });
  207. }
  208. // let max1 = this.yDataJ.reduce((acr, cur) => {
  209. // return acr > cur ? acr : cur;
  210. // });
  211. // let max2 = this.yDataH.reduce((acr1, cur1) => {
  212. // return acr1 > cur1 ? acr1 : cur1;
  213. // });
  214. // this.maxY =
  215. // max1 >= max2
  216. // ? this.formatRoundNum(max1 * 1.5)
  217. // : this.formatRoundNum(max2 * 1.5);
  218. this.option = {
  219. categories: this.xData.slice(-3) || [],
  220. series: [
  221. {
  222. name: "进风量",
  223. data: this.yDataJ.slice(-3) || [],
  224. },
  225. {
  226. name: "回风量",
  227. data: this.yDataH.slice(-3) || [],
  228. },
  229. {
  230. name: "需风量",
  231. data: this.yDataX.slice(-3) || [],
  232. },
  233. ],
  234. };
  235. // this.initChart();
  236. } else {
  237. reject(response);
  238. }
  239. })
  240. .catch((error) => {
  241. console.log("catch===>response", response);
  242. reject(error);
  243. });
  244. });
  245. },
  246. //获取通风监控测点信息
  247. async getWindDeviceList() {
  248. try {
  249. await new Promise((resolve, reject) => {
  250. api
  251. .getDeviceVent({ devicetype: "windrect", pagetype: "normal" })
  252. .then((response) => {
  253. if (response.data.code == 200) {
  254. let data = response.data.result;
  255. if (data.msgTxt[0].datalist.length != 0) {
  256. let list = data.msgTxt[0].datalist;
  257. if (list.length > 0) {
  258. this.cardListTf = list.map((el) => {
  259. //lxh
  260. const readData = el.readData;
  261. el = Object.assign(el, readData);
  262. return {
  263. label: "通信状态",
  264. value: el.netStatus == "0" ? "断开" : "连接",
  265. listR: [
  266. {
  267. id: 0,
  268. label: "安装位置",
  269. dw: "",
  270. value: el.strinstallpos,
  271. },
  272. {
  273. id: 1,
  274. label: "风量",
  275. dw: "(m³/min)",
  276. value: el.m3,
  277. },
  278. { id: 2, label: "风速", dw: "(m/s)", value: el.va },
  279. { id: 4, label: "时间", dw: "", value: el.readTime },
  280. {
  281. id: 3,
  282. label: "是否报警",
  283. dw: "",
  284. value:
  285. el.warnFlag == "0"
  286. ? "正常"
  287. : el.warnFlag == 1
  288. ? "报警"
  289. : el.warnFlag == 2
  290. ? "断开"
  291. : "未监测",
  292. },
  293. ],
  294. };
  295. });
  296. }
  297. }
  298. } else {
  299. reject(response);
  300. }
  301. })
  302. .catch((error) => {
  303. console.log("catch===>response", response);
  304. reject(error);
  305. });
  306. });
  307. } catch (error) {
  308. console.error("数据加载失败:", error);
  309. }
  310. },
  311. },
  312. computed: {},
  313. };
  314. </script>
  315. <style lang="scss" scoped>
  316. .vent-detail {
  317. position: relative;
  318. box-sizing: border-box;
  319. .devic-box-tab {
  320. padding: 0px 10px !important;
  321. }
  322. .vent-content {
  323. height: 704px;
  324. box-sizing: border-box;
  325. overflow-y: auto;
  326. .top-area {
  327. width: 100%;
  328. padding: 10px;
  329. box-sizing: border-box;
  330. background-color: #fff;
  331. margin-bottom: 2px;
  332. .top-card {
  333. width: 100%;
  334. height: 60px;
  335. margin-bottom: 10px;
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. .card-box {
  340. width: 32%;
  341. height: 100%;
  342. border-radius: 5px;
  343. background: linear-gradient(
  344. to right,
  345. rgba(55, 135, 254, 0.08),
  346. rgba(4, 184, 255, 0.08),
  347. rgba(60, 161, 237, 0.08)
  348. );
  349. }
  350. .card-box:nth-child(1) .box-item {
  351. display: flex;
  352. flex-direction: column;
  353. justify-content: center;
  354. align-items: flex-start;
  355. width: 100%;
  356. height: 100%;
  357. padding: 0px 15px;
  358. background: url("/static/jinfeng.png") no-repeat center;
  359. background-size: 75% 70%;
  360. }
  361. .card-box:nth-child(2) .box-item {
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: center;
  365. align-items: flex-start;
  366. width: 100%;
  367. height: 100%;
  368. padding: 0px 15px;
  369. background: url("/static/huifeng.png") no-repeat center;
  370. background-size: 75% 70%;
  371. }
  372. .card-box:nth-child(3) .box-item {
  373. display: flex;
  374. flex-direction: column;
  375. justify-content: center;
  376. align-items: flex-start;
  377. width: 100%;
  378. height: 100%;
  379. padding: 0px 15px;
  380. background: url("/static/xufeng.png") no-repeat center;
  381. background-size: 75% 70%;
  382. }
  383. }
  384. .top-card1 {
  385. width: 100%;
  386. height: 60px;
  387. display: flex;
  388. justify-content: space-between;
  389. align-items: center;
  390. .card-box {
  391. width: 49%;
  392. height: 100%;
  393. border-radius: 5px;
  394. background: linear-gradient(
  395. to right,
  396. rgba(55, 135, 254, 0.08),
  397. rgba(4, 184, 255, 0.08),
  398. rgba(60, 161, 237, 0.08)
  399. );
  400. }
  401. .card-box:nth-child(1) .box-item {
  402. display: flex;
  403. flex-direction: column;
  404. justify-content: center;
  405. align-items: flex-start;
  406. width: 100%;
  407. height: 100%;
  408. padding: 0px 15px;
  409. background: url("/static/O₂.png") no-repeat right;
  410. background-size: 40% 80%;
  411. }
  412. .card-box:nth-child(2) .box-item {
  413. display: flex;
  414. flex-direction: column;
  415. justify-content: center;
  416. align-items: flex-start;
  417. width: 100%;
  418. height: 100%;
  419. padding: 0px 15px;
  420. background: url("/static/CO.png") no-repeat right;
  421. background-size: 40% 80%;
  422. }
  423. }
  424. }
  425. .center-area {
  426. width: 100%;
  427. height: 220px;
  428. padding: 0px 10px;
  429. box-sizing: border-box;
  430. background-color: #fff;
  431. margin-bottom: 2px;
  432. }
  433. .bot-area {
  434. width: 100%;
  435. padding: 0px 10px;
  436. box-sizing: border-box;
  437. background-color: #fff;
  438. margin-bottom: 2px;
  439. .bot-content {
  440. overflow-y: auto;
  441. .card-b {
  442. width: 100%;
  443. height: 100px;
  444. display: flex;
  445. justify-content: space-between;
  446. padding: 5px;
  447. margin-bottom: 5px;
  448. background: linear-gradient(
  449. to right,
  450. rgba(55, 135, 254, 0.08),
  451. rgba(4, 184, 255, 0.08),
  452. rgba(60, 161, 237, 0.08)
  453. );
  454. .item-l {
  455. position: relative;
  456. width: 80px;
  457. height: 100%;
  458. background: url("/static/bot-area.png") no-repeat center;
  459. background-size: 100% 100%;
  460. .label-l {
  461. width: 100%;
  462. position: absolute;
  463. top: 7px;
  464. font-size: 12px;
  465. text-align: center;
  466. }
  467. .value-l {
  468. width: 100%;
  469. position: absolute;
  470. top: 50px;
  471. color: #0eb4fc;
  472. text-align: center;
  473. }
  474. }
  475. .item-r {
  476. width: calc(100% - 100px);
  477. height: 100%;
  478. display: flex;
  479. flex-direction: column;
  480. justify-content: space-around;
  481. .content-r {
  482. display: flex;
  483. span {
  484. font-size: 12px;
  485. &:first-child {
  486. display: inline-block;
  487. width: 68px;
  488. }
  489. &:last-child {
  490. display: inline-block;
  491. width: calc(100% - 68px);
  492. overflow: hidden;
  493. white-space: nowrap;
  494. /* 不换行 */
  495. /* 超出部分隐藏 */
  496. text-overflow: ellipsis;
  497. /* 使用省略符号 */
  498. }
  499. }
  500. .status-f {
  501. color: #ff0000;
  502. }
  503. .status-l {
  504. color: #3df6ff;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. .top-title {
  512. height: 28px;
  513. margin-bottom: 10px;
  514. display: flex;
  515. justify-content: space-between;
  516. align-items: center;
  517. .title-icon {
  518. display: flex;
  519. justify-content: space-between;
  520. align-items: center;
  521. width: 90px;
  522. height: 28px;
  523. padding: 0px 10px;
  524. border-radius: 5px;
  525. background: #d4ecff;
  526. .icon-text {
  527. font-size: 12px;
  528. font-weight: bold;
  529. color: #0eb4fc;
  530. }
  531. }
  532. }
  533. .box-item .box-val {
  534. height: 28px;
  535. line-height: 28px;
  536. color: #0eb4fc;
  537. font-weight: bold;
  538. }
  539. .box-item .box-name {
  540. font-size: 12px;
  541. }
  542. .icon-style {
  543. width: 14px;
  544. height: 14px;
  545. }
  546. }
  547. }
  548. </style>