新型管道消毒机前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

710 lines
15 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="progress_container">
  3. <div class="header_wrap">
  4. <div class="left_progress">
  5. <div class="left_time_tag">剩余时间</div>
  6. <p class="time">
  7. {{
  8. operatorStore.estimatedRemainingTimeS == 0
  9. ? '已结束'
  10. : `${time_To_hhmmss(operatorStore.estimatedRemainingTimeS)}`
  11. }}
  12. </p>
  13. <!-- <div class="progress_bg">
  14. <div
  15. class="pro"
  16. :style="{
  17. '--width': '325px',
  18. }"
  19. ></div>
  20. </div> -->
  21. </div>
  22. <div class="right_btns">
  23. <div
  24. :class="
  25. [1, 2].includes(operatorStore.disinfectStatus)
  26. ? 'btn active'
  27. : 'btn'
  28. "
  29. v-if="[1, 2].includes(operatorStore.disinfectStatus)"
  30. @click="stopDisinfect"
  31. >
  32. 停止消毒
  33. </div>
  34. <div
  35. :class="
  36. [0].includes(operatorStore.disinfectStatus) ? 'btn active' : 'btn'
  37. "
  38. v-if="operatorStore.disinfectStatus == 0"
  39. @click="showDetail"
  40. >
  41. 返回
  42. </div>
  43. <!-- <div
  44. :class="
  45. operatorStore.disinfectStatus == 1 ? 'btn active ml' : 'btn ml'
  46. "
  47. @click="pauseDisinfect"
  48. >
  49. 暂停消毒
  50. </div>
  51. <div
  52. :class="operatorStore.disinfectStatus == 2 ? 'btn active' : 'btn'"
  53. @click="continueDisinfect"
  54. >
  55. 继续消毒
  56. </div> -->
  57. </div>
  58. </div>
  59. <div class="echarts_wrap">
  60. <div class="single_wrap">
  61. <p class="title">设备温度/湿度/过氧化氢浓度</p>
  62. <div
  63. class="echarts_box"
  64. id="bin"
  65. v-if="operatorStore.disinfectStatus != 0 || binLocal"
  66. ></div>
  67. </div>
  68. <div class="single_wrap">
  69. <p class="title">环境1/湿度/过氧化氢浓度</p>
  70. <div
  71. class="echarts_box"
  72. id="envir1"
  73. v-if="operatorStore.disinfectStatus != 0 || envir1Local"
  74. ></div>
  75. </div>
  76. <div class="single_wrap">
  77. <p class="title">环境2/湿度/过氧化氢浓度</p>
  78. <div
  79. class="echarts_box"
  80. id="envir2"
  81. v-if="operatorStore.disinfectStatus != 0 || envir2Local"
  82. ></div>
  83. </div>
  84. </div>
  85. <div class="detail_wrap">
  86. <div class="detail" @click="showDetail">详情</div>
  87. </div>
  88. </div>
  89. </template>
  90. <script setup>
  91. import { useOperatorStore, useWebSocketStore, useEchartsStore } from '@/store'
  92. import { time_To_hhmmss } from '@/utils'
  93. import {
  94. stopDisinfectionJSON,
  95. getStateJSON,
  96. continueDisinfectionJSON,
  97. pauseDisinfectionJSON,
  98. } from '@/mock/command'
  99. import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
  100. import * as echarts from 'echarts'
  101. import { storeToRefs } from 'pinia'
  102. const echartsStore = useEchartsStore()
  103. const binLocal = computed(() => {
  104. return echartsStore?.binCharts || localStorage.getItem('bin')
  105. })
  106. const envir1Local = computed(() => {
  107. return echartsStore?.envir1Charts || localStorage.getItem('envir1')
  108. })
  109. const envir2Local = computed(() => {
  110. return echartsStore?.envir2Charts || localStorage.getItem('envir2')
  111. })
  112. const binOption = ref({
  113. tooltip: {
  114. trigger: 'axis',
  115. },
  116. legend: {
  117. data: ['温度', '湿度', '过氧化氢浓度'],
  118. },
  119. grid: {
  120. left: '3%',
  121. right: '4%',
  122. bottom: '3%',
  123. containLabel: true,
  124. },
  125. xAxis: {
  126. type: 'category',
  127. boundaryGap: false,
  128. data: Object.keys(echartsStore.binCharts),
  129. },
  130. yAxis: {
  131. type: 'value',
  132. },
  133. series: [
  134. {
  135. name: '温度',
  136. type: 'line',
  137. stack: 'Total',
  138. data: echartsStore.binTemp,
  139. },
  140. {
  141. name: '湿度',
  142. type: 'line',
  143. stack: 'Total',
  144. data: echartsStore.binHumidity,
  145. },
  146. {
  147. name: '过氧化氢浓度',
  148. type: 'line',
  149. stack: 'Total',
  150. data: echartsStore.binHP,
  151. },
  152. ],
  153. })
  154. const envir1Option = ref({
  155. tooltip: {
  156. trigger: 'axis',
  157. },
  158. legend: {
  159. data: ['温度', '湿度', '过氧化氢浓度'],
  160. },
  161. grid: {
  162. left: '3%',
  163. right: '4%',
  164. bottom: '3%',
  165. containLabel: true,
  166. },
  167. xAxis: {
  168. type: 'category',
  169. boundaryGap: false,
  170. data: Object.keys(echartsStore.envir1Charts),
  171. },
  172. yAxis: {
  173. type: 'value',
  174. },
  175. series: [
  176. {
  177. name: '温度',
  178. type: 'line',
  179. stack: 'Total',
  180. data: [],
  181. },
  182. {
  183. name: '湿度',
  184. type: 'line',
  185. stack: 'Total',
  186. data: [],
  187. },
  188. {
  189. name: '过氧化氢浓度',
  190. type: 'line',
  191. stack: 'Total',
  192. data: [],
  193. },
  194. ],
  195. })
  196. const envir2Option = ref({
  197. tooltip: {
  198. trigger: 'axis',
  199. },
  200. legend: {
  201. data: ['温度', '湿度', '过氧化氢浓度'],
  202. },
  203. grid: {
  204. left: '3%',
  205. right: '4%',
  206. bottom: '3%',
  207. containLabel: true,
  208. },
  209. xAxis: {
  210. type: 'category',
  211. boundaryGap: false,
  212. data: Object.keys(echartsStore.envir2Charts),
  213. },
  214. yAxis: {
  215. type: 'value',
  216. },
  217. series: [
  218. {
  219. name: '温度',
  220. type: 'line',
  221. stack: 'Total',
  222. data: [],
  223. },
  224. {
  225. name: '湿度',
  226. type: 'line',
  227. stack: 'Total',
  228. data: [],
  229. },
  230. {
  231. name: '过氧化氢浓度',
  232. type: 'line',
  233. stack: 'Total',
  234. data: [],
  235. },
  236. ],
  237. })
  238. const operatorStore = useOperatorStore()
  239. const webSocketStore = useWebSocketStore()
  240. const props = defineProps({
  241. changeShowOperator: {
  242. type: Function,
  243. },
  244. })
  245. const showDetail = () => {
  246. props.changeShowOperator(true)
  247. }
  248. const timer = ref(null)
  249. const binCharts = ref(null)
  250. const envir1Charts = ref(null)
  251. const envir2Charts = ref(null)
  252. const time1 = ref(null)
  253. const time2 = ref(null)
  254. onMounted(() => {
  255. timer.value = setInterval(() => {
  256. webSocketStore.sendCommandMsg(getStateJSON)
  257. }, 1000)
  258. let a = echarts.getInstanceByDom(document.getElementById('bin'))
  259. if (a == undefined) {
  260. binCharts.value = echarts.init(document.getElementById('bin'))
  261. binCharts.value.setOption(binOption.value)
  262. }
  263. let b = echarts.getInstanceByDom(document.getElementById('envir1'))
  264. if (b == undefined) {
  265. envir1Charts.value = echarts.init(document.getElementById('envir1'))
  266. envir1Charts.value.setOption(envir1Option.value)
  267. }
  268. let c = echarts.getInstanceByDom(document.getElementById('envir2'))
  269. if (c == undefined) {
  270. envir2Charts.value = echarts.init(document.getElementById('envir2'))
  271. envir2Charts.value.setOption(envir2Option.value)
  272. }
  273. time1.value = setInterval(() => {
  274. binCharts.value?.setOption({
  275. tooltip: {
  276. trigger: 'axis',
  277. },
  278. legend: {
  279. data: ['温度', '湿度', '过氧化氢浓度'],
  280. },
  281. grid: {
  282. left: '3%',
  283. right: '4%',
  284. bottom: '3%',
  285. containLabel: true,
  286. },
  287. xAxis: {
  288. type: 'category',
  289. boundaryGap: false,
  290. data: Object.keys(echartsStore.binCharts),
  291. },
  292. yAxis: {
  293. type: 'value',
  294. },
  295. series: [
  296. {
  297. name: '温度',
  298. type: 'line',
  299. stack: 'Total',
  300. data: echartsStore.binTemp,
  301. },
  302. {
  303. name: '湿度',
  304. type: 'line',
  305. stack: 'Total',
  306. data: echartsStore.binHumidity,
  307. },
  308. {
  309. name: '过氧化氢浓度',
  310. type: 'line',
  311. stack: 'Total',
  312. data: echartsStore.binHP,
  313. },
  314. ],
  315. })
  316. envir1Charts.value?.setOption({
  317. tooltip: {
  318. trigger: 'axis',
  319. },
  320. legend: {
  321. data: ['温度', '湿度', '过氧化氢浓度'],
  322. },
  323. grid: {
  324. left: '3%',
  325. right: '4%',
  326. bottom: '3%',
  327. containLabel: true,
  328. },
  329. xAxis: {
  330. type: 'category',
  331. boundaryGap: false,
  332. data: Object.keys(echartsStore.envir1Charts),
  333. },
  334. yAxis: {
  335. type: 'value',
  336. },
  337. series: [
  338. {
  339. name: '温度',
  340. type: 'line',
  341. stack: 'Total',
  342. data: [],
  343. },
  344. {
  345. name: '湿度',
  346. type: 'line',
  347. stack: 'Total',
  348. data: [],
  349. },
  350. {
  351. name: '过氧化氢浓度',
  352. type: 'line',
  353. stack: 'Total',
  354. data: [],
  355. },
  356. ],
  357. })
  358. envir2Charts.value?.setOption({
  359. tooltip: {
  360. trigger: 'axis',
  361. },
  362. legend: {
  363. data: ['温度', '湿度', '过氧化氢浓度'],
  364. },
  365. grid: {
  366. left: '3%',
  367. right: '4%',
  368. bottom: '3%',
  369. containLabel: true,
  370. },
  371. xAxis: {
  372. type: 'category',
  373. boundaryGap: false,
  374. data: Object.keys(echartsStore.envir2Charts),
  375. },
  376. yAxis: {
  377. type: 'value',
  378. },
  379. series: [
  380. {
  381. name: '温度',
  382. type: 'line',
  383. stack: 'Total',
  384. data: [],
  385. },
  386. {
  387. name: '湿度',
  388. type: 'line',
  389. stack: 'Total',
  390. data: [],
  391. },
  392. {
  393. name: '过氧化氢浓度',
  394. type: 'line',
  395. stack: 'Total',
  396. data: [],
  397. },
  398. ],
  399. })
  400. }, 1000 * 20)
  401. time1.value = setInterval(() => {
  402. binCharts.value?.setOption({
  403. tooltip: {
  404. trigger: 'axis',
  405. },
  406. legend: {
  407. data: ['温度', '湿度', '过氧化氢浓度'],
  408. },
  409. grid: {
  410. left: '3%',
  411. right: '4%',
  412. bottom: '3%',
  413. containLabel: true,
  414. },
  415. xAxis: {
  416. type: 'category',
  417. boundaryGap: false,
  418. data: Object.keys(echartsStore.binCharts),
  419. },
  420. yAxis: {
  421. type: 'value',
  422. },
  423. series: [
  424. {
  425. name: '温度',
  426. type: 'line',
  427. stack: 'Total',
  428. data: echartsStore.binTemp,
  429. },
  430. {
  431. name: '湿度',
  432. type: 'line',
  433. stack: 'Total',
  434. data: echartsStore.binHumidity,
  435. },
  436. {
  437. name: '过氧化氢浓度',
  438. type: 'line',
  439. stack: 'Total',
  440. data: echartsStore.binHP,
  441. },
  442. ],
  443. })
  444. envir1Charts.value?.setOption({
  445. tooltip: {
  446. trigger: 'axis',
  447. },
  448. legend: {
  449. data: ['温度', '湿度', '过氧化氢浓度'],
  450. },
  451. grid: {
  452. left: '3%',
  453. right: '4%',
  454. bottom: '3%',
  455. containLabel: true,
  456. },
  457. xAxis: {
  458. type: 'category',
  459. boundaryGap: false,
  460. data: Object.keys(echartsStore.envir1Charts),
  461. },
  462. yAxis: {
  463. type: 'value',
  464. },
  465. series: [
  466. {
  467. name: '温度',
  468. type: 'line',
  469. stack: 'Total',
  470. data: [],
  471. },
  472. {
  473. name: '湿度',
  474. type: 'line',
  475. stack: 'Total',
  476. data: [],
  477. },
  478. {
  479. name: '过氧化氢浓度',
  480. type: 'line',
  481. stack: 'Total',
  482. data: [],
  483. },
  484. ],
  485. })
  486. envir2Charts.value?.setOption({
  487. tooltip: {
  488. trigger: 'axis',
  489. },
  490. legend: {
  491. data: ['温度', '湿度', '过氧化氢浓度'],
  492. },
  493. grid: {
  494. left: '3%',
  495. right: '4%',
  496. bottom: '3%',
  497. containLabel: true,
  498. },
  499. xAxis: {
  500. type: 'category',
  501. boundaryGap: false,
  502. data: Object.keys(echartsStore.envir2Charts),
  503. },
  504. yAxis: {
  505. type: 'value',
  506. },
  507. series: [
  508. {
  509. name: '温度',
  510. type: 'line',
  511. stack: 'Total',
  512. data: [],
  513. },
  514. {
  515. name: '湿度',
  516. type: 'line',
  517. stack: 'Total',
  518. data: [],
  519. },
  520. {
  521. name: '过氧化氢浓度',
  522. type: 'line',
  523. stack: 'Total',
  524. data: [],
  525. },
  526. ],
  527. })
  528. }, 1000)
  529. })
  530. // 监听到store中的数据变化动态更改options
  531. onUnmounted(() => {
  532. timer.value = null
  533. time1.value = null
  534. time2.value = null
  535. })
  536. const pauseDisinfect = () => {
  537. if (operatorStore.disinfectStatus == 1) {
  538. webSocketStore.sendCommandMsg(pauseDisinfectionJSON)
  539. }
  540. }
  541. const stopDisinfect = () => {
  542. if ([1, 2].includes(operatorStore.disinfectStatus)) {
  543. webSocketStore.sendCommandMsg(stopDisinfectionJSON)
  544. }
  545. }
  546. const continueDisinfect = () => {
  547. if (operatorStore.disinfectStatus == 2) {
  548. webSocketStore.sendCommandMsg(continueDisinfectionJSON)
  549. }
  550. }
  551. </script>
  552. <style lang="scss" scoped>
  553. .progress_container {
  554. margin-bottom: 30px;
  555. height: 580px;
  556. box-sizing: border-box;
  557. background: #ffffff;
  558. border-radius: 16px;
  559. padding: 20px;
  560. padding-bottom: 30px;
  561. .header_wrap {
  562. display: flex;
  563. align-items: center;
  564. margin-bottom: 49px;
  565. .left_progress {
  566. // width: 860px;
  567. flex: 1;
  568. height: 80px;
  569. border-radius: 14px;
  570. background: #f6f6f6;
  571. box-sizing: border-box;
  572. padding: 0 23px;
  573. display: flex;
  574. align-items: center;
  575. .left_time_tag {
  576. width: 158.66px;
  577. height: 45px;
  578. border-radius: 23px;
  579. opacity: 1;
  580. background: #06518b;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. font-family: Source Han Sans CN;
  585. font-size: 14px;
  586. font-weight: normal;
  587. letter-spacing: 0.1em;
  588. color: #ffffff;
  589. }
  590. .time {
  591. // width: 90px;
  592. flex: 1;
  593. height: 20px;
  594. font-family: Source Han Sans CN;
  595. font-size: 14px;
  596. font-weight: 500;
  597. letter-spacing: 0.1em;
  598. color: #000000;
  599. display: flex;
  600. align-items: center;
  601. justify-content: center;
  602. }
  603. .progress_bg {
  604. width: 396px;
  605. height: 14px;
  606. border-radius: 7px;
  607. background: #ffffff;
  608. position: relative;
  609. overflow: hidden;
  610. .pro {
  611. position: absolute;
  612. left: 0;
  613. top: 0;
  614. height: 14px;
  615. border-radius: 7px;
  616. background: #06518b;
  617. width: var(--width);
  618. }
  619. }
  620. }
  621. .right_btns {
  622. display: flex;
  623. align-items: center;
  624. box-sizing: border-box;
  625. margin-left: 20px;
  626. .btn {
  627. width: 140px;
  628. height: 45px;
  629. border-radius: 23px;
  630. background: #f6f6f6;
  631. display: flex;
  632. align-items: center;
  633. justify-content: center;
  634. font-family: Source Han Sans CN;
  635. font-size: 14px;
  636. font-weight: normal;
  637. letter-spacing: 0.1em;
  638. color: #d8d8d8;
  639. }
  640. .active {
  641. color: #ffffff;
  642. background: #06518b;
  643. }
  644. .ml {
  645. margin: 0 20px;
  646. }
  647. }
  648. }
  649. .echarts_wrap {
  650. height: 351px;
  651. display: flex;
  652. align-items: center;
  653. margin-bottom: 19px;
  654. .single_wrap {
  655. flex: 1;
  656. height: 351px;
  657. .title {
  658. font-family: Source Han Sans CN;
  659. font-size: 14px;
  660. font-weight: 500;
  661. letter-spacing: 0.1em;
  662. color: #000000;
  663. margin-bottom: 24px;
  664. padding-left: 11px;
  665. }
  666. .echarts_box {
  667. width: 380px;
  668. height: 308px;
  669. }
  670. }
  671. }
  672. .detail_wrap {
  673. display: flex;
  674. align-items: center;
  675. justify-content: flex-end;
  676. padding-right: 16px;
  677. .detail {
  678. width: 105px;
  679. height: 31px;
  680. border-radius: 16px;
  681. background: #06518b;
  682. display: flex;
  683. align-items: center;
  684. justify-content: center;
  685. font-family: Source Han Sans CN;
  686. font-size: 12px;
  687. font-weight: normal;
  688. letter-spacing: 0.1em;
  689. color: #ffffff;
  690. }
  691. }
  692. }
  693. </style>