dust-detail.vue 21 KB

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