新型管道消毒机前端代码
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.

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