fire-detail-ckq.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <view class="fire-detail-ckq">
  3. <view class="top-area">
  4. <view class="top-card">
  5. <view class="card-box" v-for="(item, index) in cardList" :key="index">
  6. <view class="box-item">
  7. <view class="item-icon">
  8. <image class="icon-img" :src="item.icon" mode="aspectFit"></image>
  9. </view>
  10. <view class="item-info">
  11. <view
  12. class="box-val"
  13. :class="{ 'is-normal': item.value == '正常' }"
  14. >{{ item.value }}</view
  15. >
  16. <view class="box-name">{{ item.name }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="center-area">
  23. <view class="bot-title">
  24. <view style="font-weight: bold">光纤测温系统温度实时监测</view>
  25. </view>
  26. <view class="echartBox">
  27. <LineChart
  28. type="area"
  29. :chartData="option"
  30. :chartOpts="areaOpts"
  31. :style="{ width: '100%' }"
  32. ></LineChart>
  33. </view>
  34. </view>
  35. <view class="bot-area">
  36. <view class="bot-title">
  37. <view style="font-weight: bold">束管系统监测</view>
  38. </view>
  39. <view
  40. class="bot-content"
  41. v-for="(item, index) in botContentList"
  42. :key="index"
  43. >
  44. <view class="content-title"
  45. >{{ item.title }}{{ item.dw ? " (" + item.dw + ")" : "" }}</view
  46. >
  47. <view class="content-item-box">
  48. <view class="content-item">
  49. <view class="item-l">
  50. <view class="item-icon">
  51. <image
  52. class="icon-img"
  53. :src="item.icon"
  54. mode="aspectFit"
  55. ></image>
  56. </view>
  57. <view class="item-info">
  58. <view class="item-value">{{ item.value }}</view>
  59. <view class="item-label">浓度</view>
  60. </view>
  61. </view>
  62. <view class="item-r">
  63. <view class="item-icon">
  64. <image
  65. class="icon-img"
  66. src="/static/warndata/shijian.svg"
  67. mode="aspectFit"
  68. ></image>
  69. </view>
  70. <view class="item-info">
  71. <view class="item-value">{{ item.time }}</view>
  72. <view class="item-label">时间</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="echartbox1">
  78. <LineChart
  79. v-if="item.title == 'O₂'"
  80. type="area"
  81. :chartData="option1"
  82. :chartOpts="areaOpts"
  83. :style="{
  84. width: '100%',
  85. }"
  86. />
  87. <LineChart
  88. v-if="item.title == 'C₂H₄'"
  89. type="area"
  90. :chartData="option2"
  91. :chartOpts="areaOpts"
  92. :style="{ width: '100%' }"
  93. />
  94. <LineChart
  95. v-if="item.title == 'CO'"
  96. type="area"
  97. :chartData="option3"
  98. :chartOpts="areaOpts"
  99. :style="{ width: '100%' }"
  100. />
  101. <LineChart
  102. v-if="item.title == 'CH₄'"
  103. type="area"
  104. :chartData="option4"
  105. :chartOpts="areaOpts"
  106. :style="{ width: '100%' }"
  107. />
  108. <LineChart
  109. v-if="item.title == 'CO₂'"
  110. type="area"
  111. :chartData="option5"
  112. :chartOpts="areaOpts"
  113. :style="{ width: '100%' }"
  114. />
  115. <LineChart
  116. v-if="item.title == 'C₂H₂'"
  117. type="area"
  118. :chartData="option6"
  119. :chartOpts="areaOpts"
  120. :style="{ width: '100%' }"
  121. />
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </template>
  127. <script>
  128. import api from "@/api/api";
  129. export default {
  130. name: "fireDetailCkq",
  131. props: {
  132. detailCkq: {
  133. type: Object,
  134. default: () => {
  135. return {};
  136. },
  137. },
  138. },
  139. data() {
  140. return {
  141. option: {},
  142. option1: {},
  143. option2: {},
  144. option3: {},
  145. option4: {},
  146. option5: {},
  147. option6: {},
  148. historyData: [],
  149. myChart: null,
  150. xData: [],
  151. yData: [],
  152. cardList: [
  153. {
  154. name: "最高温度(℃)",
  155. value: 0,
  156. icon: "/static/warndata/zuigao-wendu.svg",
  157. },
  158. {
  159. name: "最低温度(℃)",
  160. value: 0,
  161. icon: "/static/warndata/zuidi-wendu.svg",
  162. },
  163. {
  164. name: "平均温度(℃)",
  165. value: 0,
  166. icon: "/static/warndata/pingjun-wendu.svg",
  167. },
  168. {
  169. name: "状态",
  170. value: "",
  171. icon: "/static/warndata/zhuangtai.svg",
  172. },
  173. {
  174. name: "回风隅角-O₂",
  175. value: 0,
  176. icon: "/static/warndata/O₂.svg",
  177. },
  178. {
  179. name: "回风隅角-CO",
  180. value: 0,
  181. icon: "/static/warndata/CO.svg",
  182. },
  183. ],
  184. myChartH: null,
  185. legendName: "",
  186. axisDw: "",
  187. xDataH: [],
  188. yDataH: [],
  189. botContentList: [
  190. {
  191. title: "O₂",
  192. value: 0,
  193. time: "",
  194. address: "",
  195. dw: "%",
  196. icon: "/static/warndata/O₂.svg",
  197. },
  198. {
  199. title: "C₂H₄",
  200. value: 0,
  201. time: "",
  202. address: "",
  203. dw: "ppm",
  204. icon: "/static/warndata/C2H4.svg",
  205. },
  206. {
  207. title: "CO",
  208. value: 0,
  209. time: "",
  210. address: "",
  211. dw: "ppm",
  212. icon: "/static/warndata/CO.svg",
  213. },
  214. {
  215. title: "CH₄",
  216. value: 0,
  217. time: "",
  218. address: "",
  219. dw: "ppm",
  220. icon: "/static/warndata/CH4.svg",
  221. },
  222. {
  223. title: "CO₂",
  224. value: 0,
  225. time: "",
  226. address: "",
  227. dw: "%",
  228. icon: "/static/warndata/CO2.svg",
  229. },
  230. {
  231. title: "C₂H₂",
  232. value: 0,
  233. time: "",
  234. address: "",
  235. dw: "ppm",
  236. icon: "/static/warndata/zhibiao.svg",
  237. },
  238. ],
  239. };
  240. },
  241. watch: {
  242. detailCkq: {
  243. handler(newC, oldC) {
  244. console.log(newC, "newC--------------");
  245. let that = this;
  246. that.xData = [];
  247. that.yData = [];
  248. if (JSON.stringify(newC) != "{}") {
  249. if (newC.fiber.length != 0) {
  250. that.cardList[0].value = newC.fiber[0].readData.fmax;
  251. that.cardList[1].value = newC.fiber[0].readData.fmin;
  252. that.cardList[2].value = newC.fiber[0].readData.favg;
  253. that.cardList[3].value = newC.fiber[0].warnFlag ? "报警" : "正常";
  254. JSON.parse(newC.fiber[0].readData.fibreTemperature).forEach(
  255. (el) => {
  256. that.xData.push(el.pos);
  257. that.yData.push(el.value);
  258. }
  259. );
  260. that.initChart();
  261. } else {
  262. that.cardList[0].value = "--";
  263. that.cardList[1].value = "--";
  264. that.cardList[2].value = "--";
  265. that.cardList[3].value = "正常";
  266. that.initChart();
  267. }
  268. if (newC.bundletube.length != 0) {
  269. that.botContentList[0].value = newC.bundletube[0].readData.o2val;
  270. that.botContentList[1].value = newC.bundletube[0].readData.ch2val;
  271. that.botContentList[2].value = newC.bundletube[0].readData.coval;
  272. that.botContentList[3].value = newC.bundletube[0].readData.chval;
  273. that.botContentList[4].value = newC.bundletube[0].readData.co2val;
  274. that.botContentList[5].value = newC.bundletube[0].readData.gasval;
  275. this.historyData = newC.bundletube[0].history || [];
  276. that.botContentList.forEach((el, index) => {
  277. el.time = newC.bundletube[0].readTime;
  278. if (el.title == "O₂") {
  279. that.xDataH = newC.bundletube[0].history.map((x) =>
  280. that.formatAxisTime(x.time)
  281. );
  282. that.yDataH = newC.bundletube[0].history.map((y) => y.o2val);
  283. that.legendName = "O₂";
  284. that.axisDw = "%";
  285. } else if (el.title == "C₂H₄") {
  286. that.xDataH = newC.bundletube[0].history.map((x) =>
  287. that.formatAxisTime(x.time)
  288. );
  289. that.yDataH = newC.bundletube[0].history.map((y) => y.ch2val);
  290. that.legendName = "C₂H₄";
  291. that.axisDw = "ppm";
  292. } else if (el.title == "CO") {
  293. that.xDataH = newC.bundletube[0].history.map((x) =>
  294. that.formatAxisTime(x.time)
  295. );
  296. that.yDataH = newC.bundletube[0].history.map((y) => y.coval);
  297. that.legendName = "CO";
  298. that.axisDw = "ppm";
  299. } else if (el.title == "CH₄") {
  300. that.xDataH = newC.bundletube[0].history.map((x) =>
  301. that.formatAxisTime(x.time)
  302. );
  303. that.yDataH = newC.bundletube[0].history.map((y) => y.chval);
  304. that.legendName = "CH₄";
  305. that.axisDw = "ppm";
  306. } else if (el.title == "CO₂") {
  307. that.xDataH = newC.bundletube[0].history.map((x) =>
  308. that.formatAxisTime(x.time)
  309. );
  310. that.yDataH = newC.bundletube[0].history.map((y) => y.co2val);
  311. that.legendName = "CO₂";
  312. that.axisDw = "%";
  313. } else if (el.title == "C₂H₂") {
  314. that.xDataH = newC.bundletube[0].history.map((x) =>
  315. that.formatAxisTime(x.time)
  316. );
  317. that.yDataH = newC.bundletube[0].history.map((y) => y.gasval);
  318. that.legendName = "C₂H₂";
  319. that.axisDw = "ppm";
  320. }
  321. this.initChartH(el);
  322. });
  323. } else {
  324. that.botContentList[0].value = "--";
  325. that.botContentList[1].value = "--";
  326. that.botContentList[2].value = "--";
  327. that.botContentList[3].value = "--";
  328. that.botContentList[4].value = "--";
  329. that.botContentList[5].value = "--";
  330. that.botContentList.forEach((el) => {
  331. el.time = "--";
  332. that.xData = [];
  333. that.yData = [];
  334. this.initChartH(el);
  335. });
  336. }
  337. }
  338. },
  339. immediate: true,
  340. deep: true,
  341. },
  342. },
  343. mounted() {},
  344. methods: {
  345. //横轴时间格式化,避免标签太长叠在一起
  346. formatAxisTime(time) {
  347. if (typeof time != "string") {
  348. return time;
  349. }
  350. //2024-03-11 17:58:11 -> 03-11 17:58
  351. return time.length > 16 ? time.slice(5, 16) : time;
  352. },
  353. //初始化echarts实例
  354. initChart() {
  355. this.option = {
  356. categories: this.xData.slice(-10) || [],
  357. series: [
  358. {
  359. name: "当前温度",
  360. data: this.yData.slice(-10) || [],
  361. },
  362. ],
  363. };
  364. },
  365. initChartH(el) {
  366. switch (el.title) {
  367. case "O₂":
  368. return (this.option1 = {
  369. categories: this.xDataH.slice(-3) || [],
  370. series: [
  371. {
  372. name: el.title,
  373. data: this.yDataH.slice(-3) || [],
  374. },
  375. ],
  376. });
  377. case "C₂H₄":
  378. return (this.option2 = {
  379. categories: this.xDataH.slice(-3) || [],
  380. series: [
  381. {
  382. name: el.title,
  383. data: this.yDataH.slice(-3) || [],
  384. },
  385. ],
  386. });
  387. case "CO":
  388. return (this.option3 = {
  389. categories: this.xDataH.slice(-3) || [],
  390. series: [
  391. {
  392. name: el.title,
  393. data: this.yDataH.slice(-3) || [],
  394. },
  395. ],
  396. });
  397. case "CH₄":
  398. return (this.option4 = {
  399. categories: this.xDataH.slice(-3) || [],
  400. series: [
  401. {
  402. name: el.title,
  403. data: this.yDataH.slice(-3) || [],
  404. },
  405. ],
  406. });
  407. case "CO₂":
  408. return (this.option5 = {
  409. categories: this.xDataH.slice(-3) || [],
  410. series: [
  411. {
  412. name: el.title,
  413. data: this.yDataH.slice(-3) || [],
  414. },
  415. ],
  416. });
  417. case "C₂H₂":
  418. return (this.option6 = {
  419. categories: this.xDataH.slice(-3) || [],
  420. series: [
  421. {
  422. name: el.title,
  423. data: this.yDataH.slice(-3) || [],
  424. },
  425. ],
  426. });
  427. }
  428. },
  429. },
  430. computed: {
  431. //曲线通用配置:曲线下方渐变填充 + 横轴标签抽稀
  432. areaOpts() {
  433. return {
  434. xAxis: {
  435. disableGrid: true,
  436. labelCount: 3,
  437. fontSize: 10,
  438. },
  439. extra: {
  440. area: {
  441. type: "curve",
  442. opacity: 0.35,
  443. addLine: true,
  444. width: 2,
  445. gradient: true,
  446. activeType: "hollow",
  447. },
  448. },
  449. };
  450. },
  451. },
  452. };
  453. </script>
  454. <style lang="scss" scoped>
  455. .fire-detail-ckq {
  456. width: 100%;
  457. height: 100%;
  458. // box-sizing: border-box;
  459. // overflow-y: auto;
  460. .top-area {
  461. width: 100%;
  462. padding: 10px;
  463. background-color: #f9f9fb;
  464. border: 1px solid #fff;
  465. margin-bottom: 12px;
  466. box-sizing: border-box;
  467. .top-card {
  468. width: 100%;
  469. display: flex;
  470. justify-content: space-between;
  471. align-items: flex-start;
  472. flex-wrap: wrap;
  473. .card-box {
  474. width: calc((100% - 20px) / 3);
  475. height: 62px;
  476. border-radius: 10px;
  477. background: linear-gradient(
  478. to bottom,
  479. rgba(175, 195, 252, 0.6) 0%,
  480. rgba(175, 195, 252, 0.1) 100%
  481. );
  482. &:nth-child(1),
  483. &:nth-child(2),
  484. &:nth-child(3) {
  485. margin-bottom: 10px;
  486. }
  487. .box-item {
  488. width: 100%;
  489. height: 100%;
  490. padding: 0px 8px;
  491. box-sizing: border-box;
  492. display: flex;
  493. align-items: center;
  494. .item-icon {
  495. position: relative;
  496. flex-shrink: 0;
  497. width: 32px;
  498. height: 32px;
  499. border-radius: 8px;
  500. display: flex;
  501. align-items: center;
  502. justify-content: center;
  503. background: linear-gradient(135deg, #80b4ff, #347df3);
  504. .icon-img {
  505. position: relative;
  506. width: 16px;
  507. height: 16px;
  508. filter: brightness(0) invert(1);
  509. }
  510. }
  511. .item-info {
  512. flex: 1;
  513. min-width: 0px;
  514. padding-left: 8px;
  515. display: flex;
  516. flex-direction: column;
  517. justify-content: center;
  518. }
  519. }
  520. }
  521. }
  522. .box-item .box-val {
  523. font-size: 15px;
  524. font-weight: bold;
  525. line-height: 18px;
  526. color: #2b7cff;
  527. }
  528. .box-item .box-val.is-normal {
  529. color: #39b54a;
  530. }
  531. .box-item .box-name {
  532. margin-top: 2px;
  533. font-size: 11px;
  534. line-height: 14px;
  535. color: #000;
  536. }
  537. }
  538. .center-area {
  539. width: 100%;
  540. padding: 10px;
  541. background-color: #f9f9fb;
  542. border: 1px solid #fff;
  543. margin-bottom: 12px;
  544. box-sizing: border-box;
  545. .bot-title {
  546. height: 28px;
  547. margin-bottom: 5px;
  548. display: flex;
  549. justify-content: space-between;
  550. align-items: center;
  551. }
  552. .echartBox {
  553. width: 100%;
  554. height: 220px;
  555. }
  556. }
  557. .bot-area {
  558. width: 100%;
  559. padding: 0px 10px;
  560. background-color: #f9f9fb;
  561. border: 1px solid #fff;
  562. margin-bottom: 2px;
  563. box-sizing: border-box;
  564. .bot-title {
  565. height: 28px;
  566. margin-bottom: 5px;
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. }
  571. .bot-content {
  572. margin-bottom: 15px;
  573. .content-title {
  574. height: 26px;
  575. line-height: 26px;
  576. padding: 0px 20px;
  577. font-size: 13px;
  578. font-weight: 600;
  579. color: #000;
  580. background: url("/static/warndata/1-1.png") no-repeat;
  581. background-size: 100% 100%;
  582. }
  583. .content-item-box {
  584. padding: 5px 0px;
  585. .content-item {
  586. height: 56px;
  587. display: flex;
  588. justify-content: space-between;
  589. align-items: center;
  590. margin-bottom: 5px;
  591. .item-l,
  592. .item-r {
  593. width: calc(50% - 5px);
  594. height: 100%;
  595. box-sizing: border-box;
  596. display: flex;
  597. align-items: center;
  598. padding: 0px 6px;
  599. border-radius: 10px;
  600. background: linear-gradient(
  601. to bottom,
  602. rgba(175, 195, 252, 0.6) 0%,
  603. rgba(175, 195, 252, 0.1) 100%
  604. );
  605. .item-icon {
  606. position: relative;
  607. flex-shrink: 0;
  608. width: 28px;
  609. height: 28px;
  610. border-radius: 8px;
  611. display: flex;
  612. align-items: center;
  613. justify-content: center;
  614. background: linear-gradient(135deg, #80b4ff, #347df3);
  615. .icon-img {
  616. position: relative;
  617. width: 15px;
  618. height: 15px;
  619. filter: brightness(0) invert(1);
  620. }
  621. }
  622. .item-info {
  623. flex: 1;
  624. min-width: 0px;
  625. padding-left: 6px;
  626. display: flex;
  627. flex-direction: column;
  628. justify-content: center;
  629. }
  630. }
  631. .item-value {
  632. font-size: 11px;
  633. font-weight: bold;
  634. line-height: 16px;
  635. color: #2b7cff;
  636. word-break: break-all;
  637. }
  638. //时间不换行,保证一行显示
  639. .item-r .item-value {
  640. white-space: nowrap;
  641. }
  642. .item-label {
  643. margin-top: 2px;
  644. font-size: 12px;
  645. line-height: 15px;
  646. color: #000;
  647. }
  648. }
  649. }
  650. .echartbox1 {
  651. width: 100%;
  652. height: 220px;
  653. margin-bottom: 10px;
  654. }
  655. }
  656. }
  657. }
  658. </style>