fire-detail-mb.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <!-- 内因火灾-密闭监测 -->
  3. <view class="fire-detail-mb">
  4. <view class="top-area">
  5. <view class="top-card">
  6. <view class="card-box" v-for="(item, index) in cardList" :key="index">
  7. <view class="box-item">
  8. <view class="box-val">{{ item.value }}</view>
  9. <view class="box-name">{{ item.name }}</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="top-card1">
  14. <view class="card-box" v-for="(item, index) in cardList1" :key="index">
  15. <view class="box-item">
  16. <view class="box-val">{{ item.value }}</view>
  17. <view class="box-name">{{ item.name }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="bot-area">
  23. <view class="bot-title">
  24. <view style="font-weight: bold;">采空区密闭参数</view>
  25. </view>
  26. <view class="bot-content" v-for="(item, index) in botContentList" :key="index">
  27. <view class="content-title">{{ item.title }}</view>
  28. <view class="content-item-box">
  29. <view class="content-item">
  30. <view class="item-l">
  31. <view class="item-value">{{ item.nd }}</view>
  32. <view class="item-label">浓度</view>
  33. </view>
  34. <view class="item-line"></view>
  35. <view class="item-c">
  36. <view class="item-value">{{ item.time }}</view>
  37. <view class="item-label">时间</view>
  38. </view>
  39. <view class="item-line"></view>
  40. <view class="item-r">
  41. <view class="item-value">{{ item.address }}</view>
  42. <view class="item-label">位置</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="echartbox1">
  47. <canvas :id="`myChart${index}`" :style="{ width: '100%', height: '220px' }"></canvas>
  48. </view>
  49. <view class="echartbox2">
  50. <warnZb :resetIndex="index" :widthV="widthV" :heightV="heightV" :coordDw="coordDw" :widthCanvas="widthCanvas"
  51. :heightCanvas="heightCanvas" :warnLevel="warnLevel"></warnZb>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import api from "@/api/api";
  59. import warnZb from './warn-zb.vue'
  60. export default {
  61. name: 'fireDetailMb',
  62. components: {
  63. warnZb
  64. },
  65. props: {
  66. detailMb: {
  67. type: Object,
  68. default: () => {
  69. return {}
  70. }
  71. }
  72. },
  73. data() {
  74. return {
  75. widthV: '85%',
  76. heightV: '85%',
  77. coordDw: [16, 42],
  78. widthCanvas: '302px',
  79. heightCanvas: '194px',
  80. myChart: null,
  81. xData: [],
  82. yData: [],
  83. legendName: '',
  84. axisDw: '',
  85. cardList: [
  86. { name: '平均温度()', value: 0 },
  87. { name: '位置', value: '' },
  88. { name: '时间', value: '' },
  89. ],
  90. cardList1: [
  91. { name: '煤自燃阶段', value: '' },
  92. { name: '预警等级', value: '' },
  93. ],
  94. botContentList: [
  95. { title: 'O₂', value: 0, time: '', address: '' },
  96. { title: 'C₂H₄', value: 0, time: '', address: '' },
  97. { title: 'CO', value: 0, time: '', address: '' },
  98. { title: 'CH₄', value: 0, time: '', address: '' },
  99. { title: 'CO₂', value: 0, time: '', address: '' },
  100. { title: 'C₂H₂', value: 0, time: '', address: '' },
  101. ]
  102. };
  103. },
  104. computed: {
  105. warnLevel: function () {
  106. return this.cardList1[1].value
  107. }
  108. },
  109. watch: {
  110. detailMb: {
  111. handler(newM, oldM) {
  112. console.log(newM, 'newM--------------')
  113. let that = this
  114. that.xData = []
  115. that.yData = []
  116. if (JSON.stringify(newM) != '{}') {
  117. if (newM.bundletube.length != 0) {
  118. that.cardList[0].value = newM.temperature[0] ? newM.temperature[0].readData.temperature : '--';
  119. that.cardList[1].value = newM.bundletube[0].strinstallpos || '--';
  120. that.cardList[2].value = newM.bundletube[0].readTime || '--';
  121. that.cardList1[0].value = newM.bundletube[0].syswarnLevel_des
  122. that.cardList1[1].value = newM.bundletube[0].syswarnLevel_str
  123. that.botContentList[0].value = newM.bundletube[0].readData.o2val;
  124. that.botContentList[1].value = newM.bundletube[0].readData.ch2val;
  125. that.botContentList[2].value = newM.bundletube[0].readData.coval;
  126. that.botContentList[3].value = newM.bundletube[0].readData.chval;
  127. that.botContentList[4].value = newM.bundletube[0].readData.co2val;
  128. that.botContentList[5].value = newM.bundletube[0].readData.gasval;
  129. that.botContentList.forEach((el, index) => {
  130. el.time = newM.bundletube[0].readTime;
  131. el.address = newM.bundletube[0].strinstallpos;
  132. if (el.title == 'O₂') {
  133. that.xData = newM.bundletube[0].history.map(x => x.time)
  134. that.yData = newM.bundletube[0].history.map(y => y.o2val)
  135. that.legendName = 'O₂'
  136. that.axisDw = '%'
  137. } else if (el.title == 'C₂H₄') {
  138. that.xData = newM.bundletube[0].history.map(x => x.time)
  139. that.yData = newM.bundletube[0].history.map(y => y.ch2val)
  140. that.legendName = 'C₂H₄'
  141. that.axisDw = 'ppm'
  142. } else if (el.title == 'CO') {
  143. that.xData = newM.bundletube[0].history.map(x => x.time)
  144. that.yData = newM.bundletube[0].history.map(y => y.coval)
  145. that.legendName = 'CO'
  146. that.axisDw = 'ppm'
  147. } else if (el.title == 'CH₄') {
  148. that.xData = newM.bundletube[0].history.map(x => x.time)
  149. that.yData = newM.bundletube[0].history.map(y => y.chval)
  150. that.legendName = 'CH₄'
  151. that.axisDw = 'ppm'
  152. } else if (el.title == 'CO₂') {
  153. that.xData = newM.bundletube[0].history.map(x => x.time)
  154. that.yData = newM.bundletube[0].history.map(y => y.co2val)
  155. that.legendName = 'CO₂'
  156. that.axisDw = '%'
  157. } else if (el.title == 'C₂H₂') {
  158. that.xData = newM.bundletube[0].history.map(x => x.time)
  159. that.yData = newM.bundletube[0].history.map(y => y.gasval)
  160. that.legendName = 'C₂H₂'
  161. that.axisDw = 'ppm'
  162. }
  163. that.initChart(index)
  164. })
  165. } else {
  166. that.cardList[0].value = 0;
  167. that.cardList[1].value = '--';
  168. that.cardList[2].value = '--';
  169. that.cardList1[0].value = '--'
  170. that.cardList1[1].value = '--'
  171. that.botContentList[0].value = '--';
  172. that.botContentList[1].value = '--';
  173. that.botContentList[2].value = '--';
  174. that.botContentList[3].value = '--';
  175. that.botContentList[4].value = '--';
  176. that.botContentList[5].value = '--';
  177. }
  178. }
  179. },
  180. immediate: true,
  181. deep: true
  182. }
  183. },
  184. mounted() {
  185. },
  186. methods: {
  187. initChart(ind) {
  188. let canvas = document.getElementById(`myChart${ind}`);
  189. this.myChart = this.$echarts.init(canvas)
  190. let option = {
  191. grid: {
  192. top: '20%',
  193. left: '4%',
  194. bottom: '4%',
  195. right: '2%',
  196. containLabel: true,
  197. },
  198. tooltip: {
  199. trigger: 'item',
  200. backgroundColor: 'rgba(0, 0, 0, .6)',
  201. textStyle: {
  202. color: '#fff',
  203. fontSize: 12,
  204. },
  205. },
  206. legend: {
  207. // align: 'center',
  208. right: 'center',
  209. top: '0%',
  210. type: 'plain',
  211. textStyle: {
  212. color: '#0eb4fc',
  213. fontSize: 12,
  214. },
  215. // icon:'rect',
  216. itemGap: 25,
  217. itemWidth: 20,
  218. icon: 'path://M0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z',
  219. data: [
  220. {
  221. name: this.legendName || '',
  222. },
  223. ],
  224. },
  225. xAxis: [
  226. {
  227. type: 'category',
  228. boundaryGap: false,
  229. axisLabel: {
  230. // formatter: '{value}',
  231. fontSize: 12,
  232. margin: 10,
  233. textStyle: {
  234. color: '#b3b8cc',
  235. },
  236. formatter: function (params) {
  237. let newParamsName = '' // 最终拼接成的字符串
  238. let paramsNameNumber = params.length // 实际标签的个数
  239. let provideNumber = 10 // 每行能显示的字的个数
  240. let rowNumber = Math.ceil(paramsNameNumber / provideNumber) // 换行的话,需要显示几行,向上取整
  241. /**
  242. * 判断标签的个数是否大于规定的个数, 如果大于,则进行换行处理 如果不大于,即等于或小于,就返回原标签
  243. */
  244. // 条件等同于rowNumber>1
  245. if (paramsNameNumber > provideNumber) {
  246. /** 循环每一行,p表示行 */
  247. for (var p = 0; p < rowNumber; p++) {
  248. var tempStr = '' // 表示每一次截取的字符串
  249. var start = p * provideNumber // 开始截取的位置
  250. var end = start + provideNumber // 结束截取的位置
  251. // 此处特殊处理最后一行的索引值
  252. if (p == rowNumber - 1) {
  253. // 最后一次不换行
  254. tempStr = params.substring(start, paramsNameNumber)
  255. } else {
  256. // 每一次拼接字符串并换行
  257. tempStr = params.substring(start, end) + '\n'
  258. }
  259. newParamsName += tempStr // 最终拼成的字符串
  260. }
  261. } else {
  262. // 将旧标签的值赋给新标签
  263. newParamsName = params
  264. }
  265. //将最终的字符串返回
  266. return newParamsName
  267. }
  268. },
  269. axisLine: {
  270. lineStyle: {
  271. color: '#f1f5f6',
  272. },
  273. },
  274. axisTick: {
  275. show: false,
  276. },
  277. data: this.xData || [],
  278. },
  279. ],
  280. yAxis: [
  281. {
  282. boundaryGap: false,
  283. type: 'value',
  284. max: 50,
  285. axisLabel: {
  286. textStyle: {
  287. color: '#b3b8cc',
  288. },
  289. formatter: '{value}'
  290. },
  291. name: `(${this.axisDw})`,
  292. nameTextStyle: {
  293. color: '#b3b8cc',
  294. fontSize: 12,
  295. lineHeight: 0,
  296. },
  297. splitLine: {
  298. lineStyle: {
  299. color: '#f1f5f6',
  300. },
  301. },
  302. axisLine: {
  303. show: true,
  304. lineStyle: {
  305. color: '#f1f5f6',
  306. },
  307. },
  308. axisTick: {
  309. show: false,
  310. },
  311. },
  312. {
  313. boundaryGap: false,
  314. type: 'value',
  315. max: 50,
  316. axisLabel: {
  317. textStyle: {
  318. color: '#b3b8cc',
  319. },
  320. formatter: '{value}'
  321. },
  322. name: `(${this.axisDw})`,
  323. nameTextStyle: {
  324. color: '#fff',
  325. fontSize: 12,
  326. lineHeight: 10,
  327. },
  328. splitLine: {
  329. lineStyle: {
  330. color: '#f1f5f6',
  331. },
  332. },
  333. axisLine: {
  334. show: true,
  335. lineStyle: {
  336. color: '#f1f5f6',
  337. },
  338. },
  339. axisTick: {
  340. show: false,
  341. },
  342. },
  343. ],
  344. series: [
  345. {
  346. name: this.legendName || '',
  347. type: 'line',
  348. smooth: true,
  349. showSymbol: true,
  350. symbolSize: 8,
  351. zlevel: 3,
  352. itemStyle: {
  353. color: '#19a3df',
  354. borderColor: '#a3c8d8',
  355. },
  356. lineStyle: {
  357. normal: {
  358. width: 2,
  359. color: '#19a3df',
  360. },
  361. },
  362. data: this.yData || [],
  363. },
  364. ],
  365. };
  366. this.myChart.setOption(option)
  367. window.addEventListener('resize', () => {
  368. this.myChart.resize()
  369. })
  370. },
  371. },
  372. };
  373. </script>
  374. <style lang="scss" scoped>
  375. .fire-detail-mb {
  376. width: 100%;
  377. height: 100%;
  378. // box-sizing: border-box;
  379. // overflow-y: auto;
  380. .top-area {
  381. width: 100%;
  382. padding: 10px;
  383. background-color: #FFF;
  384. margin-bottom: 2px;
  385. box-sizing: border-box;
  386. .top-card {
  387. width: 100%;
  388. height: 70px;
  389. margin-bottom: 10px;
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: center;
  393. .card-box {
  394. width: 32%;
  395. height: 100%;
  396. border-radius: 5px;
  397. background: linear-gradient(to right, rgba(55, 135, 254, 0.08), rgba(4, 184, 255, 0.08), rgba(60, 161, 237, 0.08));
  398. }
  399. .card-box:nth-child(1) .box-item {
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: center;
  403. align-items: flex-start;
  404. width: 100%;
  405. height: 100%;
  406. padding: 0px 15px;
  407. background: url('/static/address.png') no-repeat right;
  408. background-size: 40% 80%;
  409. }
  410. .card-box:nth-child(2) .box-item {
  411. display: flex;
  412. flex-direction: column;
  413. justify-content: center;
  414. align-items: flex-start;
  415. width: 100%;
  416. height: 100%;
  417. padding: 0px 15px;
  418. background: url('/static/pjwd.png') no-repeat right;
  419. background-size: 40% 80%;
  420. }
  421. .card-box:nth-child(3) .box-item {
  422. display: flex;
  423. flex-direction: column;
  424. justify-content: center;
  425. align-items: flex-start;
  426. width: 100%;
  427. height: 100%;
  428. padding: 0px 15px;
  429. background: url('/static/yjdj.png') no-repeat right;
  430. background-size: 40% 80%;
  431. }
  432. }
  433. .top-card1 {
  434. width: 100%;
  435. height: 70px;
  436. display: flex;
  437. justify-content: space-between;
  438. align-items: center;
  439. .card-box {
  440. width: 49%;
  441. height: 100%;
  442. border-radius: 5px;
  443. background: linear-gradient(to right, rgba(55, 135, 254, 0.08), rgba(4, 184, 255, 0.08), rgba(60, 161, 237, 0.08));
  444. }
  445. .card-box:nth-child(1) .box-item {
  446. display: flex;
  447. flex-direction: column;
  448. justify-content: center;
  449. align-items: flex-start;
  450. width: 100%;
  451. height: 100%;
  452. padding: 0px 15px;
  453. background: url('/static/mzrjd.png') no-repeat right;
  454. background-size: 40% 80%;
  455. }
  456. .card-box:nth-child(2) .box-item {
  457. display: flex;
  458. flex-direction: column;
  459. justify-content: center;
  460. align-items: flex-start;
  461. width: 100%;
  462. height: 100%;
  463. padding: 0px 15px;
  464. background: url('/static/time.png') no-repeat right;
  465. background-size: 40% 80%;
  466. }
  467. }
  468. .box-item .box-val {
  469. // height: 28px;
  470. // line-height: 28px;
  471. color: #0eb4fc;
  472. font-weight: bold;
  473. margin-bottom: 5px;
  474. }
  475. .box-item .box-name {
  476. font-size: 12px;
  477. }
  478. }
  479. .bot-area {
  480. width: 100%;
  481. padding: 0px 10px;
  482. background-color: #FFF;
  483. margin-bottom: 2px;
  484. box-sizing: border-box;
  485. .bot-title {
  486. height: 28px;
  487. margin-bottom: 5px;
  488. display: flex;
  489. justify-content: space-between;
  490. align-items: center;
  491. }
  492. .bot-content {
  493. margin-bottom: 15px;
  494. .content-title {
  495. height: 26px;
  496. line-height: 26px;
  497. padding: 0px 20px;
  498. font-size: 12px;
  499. background: url('/static/warndata/title.png') no-repeat;
  500. background-size: 100% 100%;
  501. }
  502. .content-item-box {
  503. padding: 5px 0px;
  504. .content-item {
  505. height: 50px;
  506. display: flex;
  507. justify-content: space-between;
  508. align-items: center;
  509. background: linear-gradient(to right, rgba(55, 135, 254, 0.08), rgba(4, 184, 255, 0.08), rgba(60, 161, 237, 0.08));
  510. border-radius: 10px;
  511. margin-bottom: 5px;
  512. .item-l {
  513. width: calc(25% - 2px);
  514. height: 100%;
  515. display: flex;
  516. flex-direction: column;
  517. justify-content: center;
  518. align-items: center;
  519. }
  520. .item-c {
  521. width: calc(50% - 4px);
  522. height: 100%;
  523. display: flex;
  524. flex-direction: column;
  525. justify-content: center;
  526. align-items: center;
  527. }
  528. .item-line {
  529. width: 4px;
  530. height: 70%;
  531. border-left: 2px solid;
  532. border-image: linear-gradient(to bottom, transparent, rgba(140, 203, 254, 1), transparent) 1 1 1;
  533. }
  534. .item-r {
  535. width: calc(25% - 2px);
  536. height: 100%;
  537. display: flex;
  538. flex-direction: column;
  539. justify-content: center;
  540. align-items: center;
  541. }
  542. .item-value {
  543. height: 20px;
  544. line-height: 20px;
  545. color: #0eb4fc;
  546. font-weight: bold;
  547. }
  548. .item-label {
  549. font-size: 12px;
  550. }
  551. }
  552. }
  553. .echartbox1 {
  554. width: 100%;
  555. height: 220px;
  556. margin-bottom: 10px;
  557. }
  558. .echartbox2 {
  559. width: 100%;
  560. height: 240px;
  561. }
  562. }
  563. }
  564. }
  565. </style>