dust-detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <view class="dust-detail">
  3. <u-tabs class="devic-box-tab" :current="PageCur" :list="tabList" @click="NavChange"></u-tabs>
  4. <view class="dust-content">
  5. <view class="top-area" v-for="(item, index) in topList" :key="index">
  6. <view class="top-title">
  7. <view style="font-weight: bold;">{{ item.label }}</view>
  8. </view>
  9. <view class="top-card">
  10. <view class="card-item card-item1">
  11. <view class="item-box item-box1">
  12. <view class="box-val">{{ item.temperature || '--' }}</view>
  13. <view class="box-name">温度(℃)</view>
  14. </view>
  15. </view>
  16. <view class="card-item card-item1">
  17. <view class="item-box item-box2">
  18. <view class="box-val">{{ item.dustval || '--' }}</view>
  19. <view class="box-name">粉尘浓度(mg/m³)</view>
  20. </view>
  21. </view>
  22. <view class="card-item">
  23. <view class="item-box item-box3">
  24. <view class="box-val">{{ item.waterPressure || '--' }}</view>
  25. <view class="box-name">喷雾水压(MPa)</view>
  26. </view>
  27. </view>
  28. <view class="card-item">
  29. <view class="item-box item-box4">
  30. <view class="box-val">{{ item.atomizingState || '--' }}</view>
  31. <view class="box-name">喷雾状态</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="top-echart">
  36. <canvas :id="`myChart${index}`" :style="{ width: '100%', height: '220px' }"></canvas>
  37. </view>
  38. </view>
  39. <view class="bot-area">
  40. <view class="bot-title">
  41. <view style="font-weight: bold;">粉尘监控测点信息</view>
  42. </view>
  43. <view class="bot-content">
  44. <view class="card-b" v-for="(item, index) in cardListDust" :key="index">
  45. <div class="item-l">
  46. <div class="label-l">{{ item.label || '--' }}</div>
  47. <div class="value-l">{{ item.value || '--' }}</div>
  48. </div>
  49. <div class="item-r">
  50. <div class="content-r" v-for="(items, ind) in item.listR" :key="ind">
  51. <span>{{ `${items.label} : ` }}</span>
  52. <span :class="{
  53. 'status-f': items.value == 1,
  54. 'status-l': items.value == 0,
  55. }">{{ `${items.value}${items.dw}` || '--' }}</span>
  56. </div>
  57. </div>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import api from "@/api/api";
  66. export default {
  67. name: 'dustDetail',
  68. props: {},
  69. watch: {},
  70. data() {
  71. return {
  72. timer: '',
  73. PageCur: "0",
  74. tabList: [],
  75. //喷粉选项数据
  76. topList: [],
  77. flag: true,
  78. echartNow: [],
  79. echartYc: [],
  80. xData: [],
  81. yDataN: [],
  82. yDataY: [],
  83. yDataS: [],
  84. maxY: 0,
  85. cardListDust: []
  86. };
  87. },
  88. beforeDestroy() {
  89. this.myChart.clear()
  90. this.myChart.dispose()
  91. this.timer = null
  92. clearTimeout(this.timer)
  93. },
  94. mounted() {
  95. this.getTabList()
  96. this.getWindDeviceList()
  97. },
  98. methods: {
  99. NavChange: function (item) {
  100. clearTimeout(this.timer)
  101. this.PageCur = item.index;
  102. this.getMonitor(this.tabList[this.PageCur].deviceID, true);
  103. },
  104. getMonitor(deviceID, flag) {
  105. let than = this
  106. than.timer = setTimeout(
  107. async () => {
  108. await than.getSysWarnList(deviceID, 'dust');
  109. if (than.timer) {
  110. than.timer = null;
  111. }
  112. than.getMonitor(deviceID);
  113. },
  114. flag ? 0 : 3000
  115. );
  116. },
  117. //获取顶部tab选项数据
  118. getTabList() {
  119. this.tabList = []
  120. new Promise((resolve, reject) => {
  121. api
  122. .sysTypeWarn({ type: 'dust' })
  123. .then((response) => {
  124. if (response.data.code == 200 && response.data.result.length != 0) {
  125. let result = response.data.result
  126. console.log(result, '粉尘菜单---------')
  127. result.forEach((el) => {
  128. this.tabList.push({
  129. name: el.systemname,
  130. warn: '低风险',
  131. deviceID: el.id,
  132. strtype: el.strtype,
  133. });
  134. });
  135. this.getMonitor(this.tabList[0].deviceID, true);
  136. } else {
  137. reject(response);
  138. }
  139. })
  140. .catch((error) => {
  141. console.log("catch===>response", response);
  142. reject(error);
  143. });
  144. });
  145. },
  146. //获取喷粉选项数据
  147. getSysWarnList(id, type) {
  148. let that = this
  149. new Promise((resolve, reject) => {
  150. api
  151. .sysWarn({ sysid: id, type: type })
  152. .then((response) => {
  153. if (response.data.code == 200) {
  154. console.log(response.data, '喷粉选项数据---------')
  155. let data = response.data.result.dust
  156. if (data.length != 0) {
  157. that.topList = data.map(el => {
  158. return { label: el.strinstallpos, temperature: el.readData.temperature, dustval: el.readData.dustval, waterPressure: el.readData.waterPressure, atomizingState: el.readData.atomizingState }
  159. })
  160. data.forEach((v, index) => {
  161. if (that.flag) {
  162. that.echartNow = JSON.parse(v.readData.expectInfo)['list']
  163. that.flag = false
  164. }
  165. that.echartYc.push({ time: JSON.parse(v.readData.expectInfo)['nowTime'], value: JSON.parse(v.readData.expectInfo)['nowVal'] })
  166. let setData = [...that.echartNow, ...that.echartYc].sort((a, b) => Date.parse(new Date(a.time)) - Date.parse(new Date(b.time)))
  167. that.xData = []
  168. that.yDataS = []
  169. that.yDataY = []
  170. that.yDataN = []
  171. setData.forEach(el => {
  172. if (el.value && el.value != '0') {
  173. that.xData.push(el.time);
  174. that.yDataS.push(el.value);
  175. that.yDataY.push(JSON.parse(v.readData.expectInfo)['aveVal']);
  176. that.yDataN.push(JSON.parse(v.readData.expectInfo)['fmin'] ? JSON.parse(v.readData.expectInfo)['fmin'] : 0);
  177. }
  178. })
  179. let max = that.yDataS.reduce((acr, cur) => {
  180. return acr > cur ? acr : cur;
  181. });
  182. that.maxY = that.formatRoundNum(max * 1.5);
  183. // console.log(that.xData, that.yDataS, that.yDataY, that.yDataN, '000')
  184. that.initChart(index)
  185. })
  186. }
  187. } else {
  188. reject(response);
  189. }
  190. })
  191. .catch((error) => {
  192. console.log("catch===>response", response);
  193. reject(error);
  194. });
  195. });
  196. },
  197. //获取粉尘监控测点信息
  198. getWindDeviceList() {
  199. new Promise((resolve, reject) => {
  200. api
  201. .getDeviceVent({ devicetype: 'dusting', pagetype: 'normal' })
  202. .then((response) => {
  203. if (response.data.code == 200) {
  204. let data = response.data.result
  205. if (data.msgTxt[0].datalist.length != 0) {
  206. let list = data.msgTxt[0].datalist;
  207. if (list.length > 0) {
  208. this.cardListDust = list.map((el) => {//lxh
  209. const readData = el.readData;
  210. el = Object.assign(el, readData);
  211. return {
  212. label: '通信状态',
  213. value: el.netStatus == '0' ? '断开' : '连接',
  214. listR: [
  215. { id: 0, label: '安装位置', dw: '', value: el.strinstallpos },
  216. { id: 1, label: '粉尘浓度', dw: '(mg/m³)', value: el.dustval },
  217. { id: 2, label: '巷道湿度', dw: '(RH)', value: el.humidity },
  218. { id: 4, label: '巷道温度', dw: '(℃)', value: el.temperature },
  219. { id: 3, label: '是否报警', dw: '', value: el.warnFlag == '0' ? '正常' : el.warnFlag == 1 ? '报警' : el.warnFlag == 2 ? '断开' : '未监测' },
  220. ],
  221. }
  222. });
  223. }
  224. }
  225. } else {
  226. reject(response);
  227. }
  228. })
  229. .catch((error) => {
  230. console.log("catch===>response", response);
  231. reject(error);
  232. });
  233. });
  234. },
  235. formatRoundNum(num) {
  236. let interger = Math.ceil(num);
  237. let leng = String(interger).length;
  238. return Math.ceil(interger / Math.pow(10, leng - 1)) * Math.pow(10, leng - 1);
  239. },
  240. //初始化echarts实例
  241. initChart(index) {
  242. let canvas = document.getElementById(`myChart${index}`);
  243. this.myChart = this.$echarts.init(canvas)
  244. let option = {
  245. grid: {
  246. top: '20%',
  247. left: '2%',
  248. bottom: '4%',
  249. right: '2%',
  250. containLabel: true,
  251. },
  252. tooltip: {
  253. trigger: 'item',
  254. backgroundColor: 'rgba(0, 0, 0, .6)',
  255. textStyle: {
  256. color: '#fff',
  257. fontSize: 12,
  258. },
  259. },
  260. legend: {
  261. // align: 'center',
  262. right: '0%',
  263. top: '0%',
  264. type: 'plain',
  265. textStyle: {
  266. color: '#0eb4fc',
  267. fontSize: 12,
  268. },
  269. // icon:'rect',
  270. itemGap: 25,
  271. itemWidth: 20,
  272. 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',
  273. data: [
  274. {
  275. name: '实时值',
  276. },
  277. {
  278. name: '预测值',
  279. },
  280. {
  281. name: '最新值'
  282. }
  283. ],
  284. },
  285. xAxis: [
  286. {
  287. type: 'category',
  288. boundaryGap: false,
  289. axisLabel: {
  290. // formatter: '{value}',
  291. fontSize: 12,
  292. margin: 10,
  293. textStyle: {
  294. color: '#b3b8cc',
  295. },
  296. formatter: function (params) {
  297. let newParamsName = '' // 最终拼接成的字符串
  298. let paramsNameNumber = params.length // 实际标签的个数
  299. let provideNumber = 10 // 每行能显示的字的个数
  300. let rowNumber = Math.ceil(paramsNameNumber / provideNumber) // 换行的话,需要显示几行,向上取整
  301. /**
  302. * 判断标签的个数是否大于规定的个数, 如果大于,则进行换行处理 如果不大于,即等于或小于,就返回原标签
  303. */
  304. // 条件等同于rowNumber>1
  305. if (paramsNameNumber > provideNumber) {
  306. /** 循环每一行,p表示行 */
  307. for (var p = 0; p < rowNumber; p++) {
  308. var tempStr = '' // 表示每一次截取的字符串
  309. var start = p * provideNumber // 开始截取的位置
  310. var end = start + provideNumber // 结束截取的位置
  311. // 此处特殊处理最后一行的索引值
  312. if (p == rowNumber - 1) {
  313. // 最后一次不换行
  314. tempStr = params.substring(start, paramsNameNumber)
  315. } else {
  316. // 每一次拼接字符串并换行
  317. tempStr = params.substring(start, end) + '\n'
  318. }
  319. newParamsName += tempStr // 最终拼成的字符串
  320. }
  321. } else {
  322. // 将旧标签的值赋给新标签
  323. newParamsName = params
  324. }
  325. //将最终的字符串返回
  326. return newParamsName
  327. }
  328. },
  329. axisLine: {
  330. lineStyle: {
  331. color: '#f1f5f6',
  332. },
  333. },
  334. axisTick: {
  335. show: false,
  336. },
  337. data: this.xData || [],
  338. },
  339. ],
  340. yAxis: [
  341. {
  342. boundaryGap: false,
  343. type: 'value',
  344. max: this.maxY,
  345. axisLabel: {
  346. textStyle: {
  347. color: '#b3b8cc',
  348. },
  349. formatter: '{value}'
  350. },
  351. name: '(m³/min)',
  352. nameTextStyle: {
  353. color: '#b3b8cc',
  354. fontSize: 12,
  355. lineHeight: 0,
  356. },
  357. splitLine: {
  358. lineStyle: {
  359. color: '#f1f5f6',
  360. },
  361. },
  362. axisLine: {
  363. show: true,
  364. lineStyle: {
  365. color: '#f1f5f6',
  366. },
  367. },
  368. axisTick: {
  369. show: false,
  370. },
  371. },
  372. {
  373. boundaryGap: false,
  374. type: 'value',
  375. max: this.maxY,
  376. axisLabel: {
  377. textStyle: {
  378. color: '#b3b8cc',
  379. },
  380. formatter: '{value}'
  381. },
  382. name: '(m³/min)',
  383. nameTextStyle: {
  384. color: '#fff',
  385. fontSize: 12,
  386. lineHeight: 10,
  387. },
  388. splitLine: {
  389. lineStyle: {
  390. color: '#f1f5f6',
  391. },
  392. },
  393. axisLine: {
  394. show: true,
  395. lineStyle: {
  396. color: '#f1f5f6',
  397. },
  398. },
  399. axisTick: {
  400. show: false,
  401. },
  402. },
  403. ],
  404. series: [
  405. {
  406. name: '实时值',
  407. type: 'line',
  408. smooth: true,
  409. showSymbol: true,
  410. symbolSize: 8,
  411. zlevel: 3,
  412. itemStyle: {
  413. color: '#19a3df',
  414. borderColor: '#a3c8d8',
  415. },
  416. lineStyle: {
  417. normal: {
  418. width: 2,
  419. color: '#19a3df',
  420. },
  421. },
  422. data: this.yDataS || [],
  423. },
  424. {
  425. name: '预测值',
  426. type: 'line',
  427. smooth: true,
  428. showSymbol: true,
  429. symbolSize: 8,
  430. zlevel: 3,
  431. itemStyle: {
  432. color: '#4fffad',
  433. borderColor: '#a3c8d8',
  434. },
  435. lineStyle: {
  436. normal: {
  437. width: 2,
  438. color: '#4fffad',
  439. },
  440. },
  441. data: this.yDataY || [],
  442. },
  443. {
  444. name: '最新值',
  445. type: 'line',
  446. smooth: true,
  447. showSymbol: true,
  448. symbolSize: 8,
  449. zlevel: 3,
  450. itemStyle: {
  451. color: '#fc8452',
  452. borderColor: '#a3c8d8',
  453. },
  454. lineStyle: {
  455. normal: {
  456. width: 2,
  457. color: '#fc8452',
  458. },
  459. },
  460. data: this.yDataN || [],
  461. },
  462. ],
  463. };
  464. this.myChart.setOption(option)
  465. window.addEventListener('resize', () => {
  466. this.myChart.resize()
  467. })
  468. },
  469. },
  470. computed: {
  471. },
  472. };
  473. </script>
  474. <style lang="scss" scoped>
  475. .dust-detail {
  476. position: relative;
  477. // padding: 0px 10px;
  478. box-sizing: border-box;
  479. .devic-box-tab {
  480. padding: 0px 10px !important;
  481. }
  482. .dust-content {
  483. // height: 704px;
  484. // padding: 0px 10px;
  485. // box-sizing: border-box;
  486. // overflow-y: auto;
  487. height: 704px;
  488. box-sizing: border-box;
  489. overflow-y: auto;
  490. .top-area {
  491. width: 100%;
  492. padding: 10px;
  493. box-sizing: border-box;
  494. background-color: #FFF;
  495. margin-bottom: 2px;
  496. .top-title {
  497. height: 28px;
  498. margin-bottom: 10px;
  499. display: flex;
  500. justify-content: space-between;
  501. align-items: center;
  502. }
  503. .top-card {
  504. display: flex;
  505. justify-content: space-between;
  506. align-items: flex-start;
  507. flex-wrap: wrap;
  508. width: 100%;
  509. margin-bottom: 10px;
  510. .card-item {
  511. width: calc(50% - 5px);
  512. height: 60px;
  513. border-radius: 5px;
  514. background: linear-gradient(to right, rgba(55, 135, 254, 0.08), rgba(4, 184, 255, 0.08), rgba(60, 161, 237, 0.08));
  515. .item-box {
  516. display: flex;
  517. flex-direction: column;
  518. justify-content: center;
  519. align-items: flex-start;
  520. width: 100%;
  521. height: 100%;
  522. padding: 0px 15px;
  523. .box-val {
  524. height: 28px;
  525. line-height: 28px;
  526. color: #0eb4fc;
  527. font-weight: bold;
  528. }
  529. .box-name {
  530. font-size: 12px;
  531. }
  532. }
  533. .item-box1 {
  534. background: url('/static/wd.png') no-repeat right;
  535. background-size: 30% 80%;
  536. }
  537. .item-box2 {
  538. background: url('/static/dust.png') no-repeat right;
  539. background-size: 30% 80%;
  540. }
  541. .item-box3 {
  542. background: url('/static/pwsy.png') no-repeat right;
  543. background-size: 30% 80%;
  544. }
  545. .item-box4 {
  546. background: url('/static/pwzt.png') no-repeat right;
  547. background-size: 30% 80%;
  548. }
  549. }
  550. .card-item1 {
  551. margin-bottom: 10px;
  552. }
  553. }
  554. .top-echart {
  555. height: 220px;
  556. }
  557. }
  558. .bot-area {
  559. width: 100%;
  560. padding: 10px;
  561. box-sizing: border-box;
  562. background-color: #FFF;
  563. margin-bottom: 2px;
  564. .bot-title {
  565. height: 28px;
  566. margin-bottom: 10px;
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. }
  571. .bot-content {
  572. // height: calc(100% - 38px);
  573. overflow-y: auto;
  574. .card-b {
  575. width: 100%;
  576. height: 100px;
  577. display: flex;
  578. justify-content: space-between;
  579. padding: 5px;
  580. margin-bottom: 5px;
  581. background: linear-gradient(to right, rgba(55, 135, 254, 0.08), rgba(4, 184, 255, 0.08), rgba(60, 161, 237, 0.08));
  582. .item-l {
  583. position: relative;
  584. width: 80px;
  585. height: 100%;
  586. background: url('/static/bot-area.png') no-repeat center;
  587. background-size: 100% 100%;
  588. .label-l {
  589. width: 100%;
  590. position: absolute;
  591. top: 7px;
  592. font-size: 12px;
  593. text-align: center;
  594. }
  595. .value-l {
  596. width: 100%;
  597. position: absolute;
  598. top: 50px;
  599. color: #0eb4fc;
  600. text-align: center;
  601. }
  602. }
  603. .item-r {
  604. width: calc(100% - 100px);
  605. height: 100%;
  606. display: flex;
  607. flex-direction: column;
  608. justify-content: space-around;
  609. .content-r {
  610. display: flex;
  611. span {
  612. font-size: 12px;
  613. &:first-child {
  614. display: inline-block;
  615. width: 68px;
  616. }
  617. &:last-child {
  618. display: inline-block;
  619. width: calc(100% - 68px);
  620. overflow: hidden;
  621. white-space: nowrap;
  622. /* 不换行 */
  623. /* 超出部分隐藏 */
  624. text-overflow: ellipsis;
  625. /* 使用省略符号 */
  626. }
  627. }
  628. .status-f {
  629. color: #ff0000;
  630. }
  631. .status-l {
  632. color: #3df6ff;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. }
  639. }
  640. }
  641. </style>