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

540 lines
13 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
  1. <template>
  2. <div class="seal_test_container">
  3. <div class="left_container">
  4. <div class="title_wrap">
  5. <img class="icon" :src="SealPng" alt="" />
  6. <div class="title">实时压力表</div>
  7. </div>
  8. <div class="echarts_box" id="seal_echarts"></div>
  9. <div class="oper_box">
  10. <div class="air_box">
  11. <p class="box"></p>
  12. <p class="tit">测试前气压</p>
  13. <p class="num">
  14. {{
  15. sealStore.oldAirPressure != null
  16. ? sealStore.oldAirPressure
  17. : '--'
  18. }}KPa
  19. </p>
  20. </div>
  21. <img
  22. class="air_img"
  23. :src="DisStart"
  24. alt=""
  25. v-if="sealStore.isStartTest"
  26. />
  27. <img
  28. class="air_img"
  29. v-if="!sealStore.isStartTest && !testStore.airCompressor"
  30. @click="changeAirStatus(2)"
  31. :src="StartAir"
  32. alt=""
  33. />
  34. <img
  35. class="air_img"
  36. @click="changeAirStatus(1)"
  37. v-if="!sealStore.isStartTest && testStore.airCompressor"
  38. :src="StopAir"
  39. alt=""
  40. />
  41. </div>
  42. </div>
  43. <div class="right_container">
  44. <div class="header">
  45. <div class="left">
  46. <img :src="TestIcon" class="icon" alt="" />
  47. <p class="title">密封测试</p>
  48. </div>
  49. <p class="en">SEAL</p>
  50. </div>
  51. <div class="oper_box">
  52. <div class="emp_box">
  53. <div class="title">测试时间</div>
  54. <div class="num">
  55. {{ resultTime ? resultTime : '未开始' }}
  56. </div>
  57. </div>
  58. <div class="emp_box">
  59. <div class="title">气压差值</div>
  60. <div class="num">
  61. {{
  62. sealStore.differenceValue != null
  63. ? `${sealStore.differenceValue}KPa`
  64. : '未开始'
  65. }}
  66. </div>
  67. </div>
  68. <img
  69. :src="StartTest"
  70. v-if="!sealStore.isStartTest"
  71. class="test_png"
  72. @click="handleStartTest('1')"
  73. alt=""
  74. />
  75. <img
  76. @click="handleStartTest('2')"
  77. :src="StopTest"
  78. v-else
  79. class="test_png"
  80. alt=""
  81. />
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script setup>
  87. import * as echarts from 'echarts'
  88. import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
  89. import SealPng from '@/assets/img/seal/seal.png'
  90. import StartAir from '@/assets/img/seal/start.png'
  91. import DisStart from '@/assets/img/seal/dis_start.png'
  92. import TestIcon from '@/assets/img/seal/test.png'
  93. import StartTest from '@/assets/img/seal/starttest.png'
  94. import StopTest from '@/assets/img/seal/stoptest.png'
  95. import StopAir from '@/assets/img/seal/stop.png'
  96. import { someAirSwitchJSON } from '@/mock/command'
  97. import { useSealStore, useTestStore, useWebSocketStore } from '@/store'
  98. const sealStore = useSealStore()
  99. const testStore = useTestStore()
  100. const websocketStore = useWebSocketStore()
  101. const sealCharts = ref(null)
  102. const sealOptions = ref({
  103. series: [
  104. {
  105. type: 'gauge',
  106. min: 0,
  107. max: 800,
  108. progress: {
  109. show: true,
  110. width: 18,
  111. itemStyle: {
  112. color: '#3442aa',
  113. },
  114. },
  115. pointer: {
  116. itemStyle: {
  117. color: '#3442aa',
  118. },
  119. },
  120. axisLine: {
  121. lineStyle: {
  122. width: 18,
  123. },
  124. },
  125. axisTick: {
  126. show: false,
  127. },
  128. splitLine: {
  129. length: 15,
  130. lineStyle: {
  131. width: 2,
  132. color: '#999',
  133. },
  134. },
  135. axisLabel: {
  136. distance: 25,
  137. color: '#999',
  138. fontSize: 20,
  139. },
  140. anchor: {
  141. show: true,
  142. showAbove: true,
  143. size: 25,
  144. itemStyle: {
  145. borderWidth: 10,
  146. borderColor: '#3442aa',
  147. },
  148. },
  149. title: {
  150. show: false,
  151. },
  152. detail: {
  153. valueAnimation: true,
  154. fontSize: 40,
  155. color: '#3442aa',
  156. formatter: '{value} KPa',
  157. offsetCenter: [0, '70%'],
  158. },
  159. data: [
  160. {
  161. value: sealStore.currentAirPressure,
  162. },
  163. ],
  164. },
  165. ],
  166. })
  167. const n_sec = ref(0) // 秒
  168. const n_min = ref(0) // 分
  169. const n_hour = ref(0) // 时
  170. const resultTime = ref('')
  171. const timerStart = ref(null)
  172. const timerReal = () => {
  173. var str_sec = n_sec.value
  174. var str_min = n_min.value
  175. var str_hour = n_hour.value
  176. if (n_sec.value < 10) {
  177. str_sec = '0' + n_sec.value
  178. }
  179. if (n_min.value < 10) {
  180. str_min = '0' + n_min.value
  181. }
  182. if (n_hour.value < 10) {
  183. str_hour = '0' + n_hour.value
  184. }
  185. resultTime.value = str_hour + ':' + str_min + ':' + str_sec
  186. n_sec.value = n_sec.value + 1
  187. if (n_sec.value > 59) {
  188. n_sec.value = 0
  189. n_min.value = n_min.value + 1
  190. }
  191. if (n_min.value > 59) {
  192. n_min.value = 0
  193. n_hour.value = n_hour.value + 1
  194. }
  195. }
  196. watch(
  197. () => sealStore.isStartTest,
  198. (newValue, oldValue) => {
  199. if (!newValue) {
  200. stopTimer()
  201. }
  202. },
  203. )
  204. const stopTimer = () => {
  205. // 改变测试前oldAirPressure为null
  206. sealStore.updateOldAirPressure(null)
  207. // 结束测试时将时间重置null
  208. clearInterval(timerStart.value)
  209. timerStart.value = null
  210. resultTime.value = null
  211. n_sec.value = 0
  212. n_min.value = 0
  213. n_hour.value = 0
  214. sealStore.updateIsStartTest(false)
  215. }
  216. const timerFunc = () => {
  217. timerReal()
  218. timerStart.value = setInterval(() => {
  219. timerReal()
  220. }, 1000)
  221. }
  222. const changeAirStatus = flag => {
  223. if (flag == 1) {
  224. if (!testStore.airCompressor) {
  225. websocketStore.sendCommandMsg(someAirSwitchJSON(0, 1))
  226. websocketStore.sendCommandMsg(someAirSwitchJSON(1, 1))
  227. testStore.updateAirCompressor(true)
  228. }
  229. } else {
  230. if (testStore.airCompressor) {
  231. websocketStore.sendCommandMsg(someAirSwitchJSON(0, 0))
  232. websocketStore.sendCommandMsg(someAirSwitchJSON(1, 0))
  233. testStore.updateAirCompressor(false)
  234. }
  235. }
  236. }
  237. const handleStartTest = flag => {
  238. if (flag == '1') {
  239. // 改变测试前oldAirPressure为测试前气压值
  240. // 也就是将getState中获取的当前值currentAirPressure赋予
  241. // 开始测试需要记录时间
  242. timerFunc()
  243. // 开始测试时关闭空压机
  244. // 关闭一个阀门
  245. // websocketStore.sendCommandMsg(someAirSwitchJSON(0, 0))
  246. // websocketStore.sendCommandMsg(someAirSwitchJSON(1, 0))
  247. // testStore.updateAirCompressor(false)
  248. sealStore.updateOldAirPressure(sealStore.currentAirPressure)
  249. sealStore.updateIsStartTest(true)
  250. }
  251. if (flag == '2') {
  252. stopTimer()
  253. }
  254. }
  255. const timer = ref(null)
  256. onBeforeUnmount(() => {
  257. timer.value = null
  258. timerStart.value = null
  259. clearInterval(timer.value)
  260. clearInterval(timerStart.value)
  261. })
  262. onMounted(() => {
  263. sealCharts.value = echarts.init(document.getElementById('seal_echarts'))
  264. sealCharts.value.setOption(sealOptions.value)
  265. timer.value = setInterval(() => {
  266. sealCharts.value.setOption({
  267. series: [
  268. {
  269. type: 'gauge',
  270. min: 0,
  271. max: 800,
  272. progress: {
  273. show: true,
  274. width: 18,
  275. itemStyle: {
  276. color: '#3442aa',
  277. },
  278. },
  279. pointer: {
  280. itemStyle: {
  281. color: '#3442aa',
  282. },
  283. },
  284. axisLine: {
  285. lineStyle: {
  286. width: 18,
  287. },
  288. },
  289. axisTick: {
  290. show: false,
  291. },
  292. splitLine: {
  293. length: 15,
  294. lineStyle: {
  295. width: 2,
  296. color: '#999',
  297. },
  298. },
  299. axisLabel: {
  300. distance: 25,
  301. color: '#999',
  302. fontSize: 20,
  303. },
  304. anchor: {
  305. show: true,
  306. showAbove: true,
  307. size: 25,
  308. itemStyle: {
  309. borderWidth: 10,
  310. borderColor: '#3442aa',
  311. },
  312. },
  313. title: {
  314. show: false,
  315. },
  316. detail: {
  317. valueAnimation: true,
  318. fontSize: 40,
  319. color: '#3442aa',
  320. formatter: '{value} KPa',
  321. offsetCenter: [0, '70%'],
  322. },
  323. data: [
  324. {
  325. value: sealStore.currentAirPressure,
  326. },
  327. ],
  328. },
  329. ],
  330. })
  331. }, 1000)
  332. })
  333. </script>
  334. <style lang="scss" scoped>
  335. .seal_test_container {
  336. margin-bottom: 19px;
  337. height: 580px;
  338. box-sizing: border-box;
  339. border-radius: 16px;
  340. display: flex;
  341. align-items: center;
  342. .left_container {
  343. margin-right: 30px;
  344. width: 766px;
  345. height: 580px;
  346. box-sizing: border-box;
  347. border-radius: 16px;
  348. background: #ffffff;
  349. position: relative;
  350. .title_wrap {
  351. position: absolute;
  352. left: 28px;
  353. top: 28px;
  354. width: 141px;
  355. height: 31px;
  356. box-sizing: border-box;
  357. display: flex;
  358. align-items: center;
  359. .title {
  360. font-family: 思源黑体;
  361. font-size: 20px;
  362. font-weight: bold;
  363. line-height: normal;
  364. letter-spacing: 0.02em;
  365. font-feature-settings: 'kern' on;
  366. color: #000000;
  367. margin-left: 9px;
  368. }
  369. .icon {
  370. width: 30px;
  371. height: 30px;
  372. }
  373. }
  374. .oper_box {
  375. position: absolute;
  376. left: 28px;
  377. bottom: 28px;
  378. width: 710px;
  379. height: 110px;
  380. display: flex;
  381. align-items: center;
  382. justify-content: space-between;
  383. .air_img {
  384. width: 341px;
  385. height: 110px;
  386. }
  387. .air_box {
  388. width: 341px;
  389. height: 110px;
  390. border-radius: 16px;
  391. background: #f6f6f6;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. .box {
  396. width: 16px;
  397. height: 16px;
  398. background: #4359b9;
  399. margin-right: 6px;
  400. }
  401. .tit {
  402. font-family: 思源黑体;
  403. font-size: 20px;
  404. font-weight: normal;
  405. line-height: normal;
  406. letter-spacing: 0.06em;
  407. font-feature-settings: 'kern' on;
  408. color: #3d3d3d;
  409. margin-right: 8px;
  410. }
  411. .num {
  412. font-family: Source Han Sans;
  413. font-size: 30px;
  414. font-weight: bold;
  415. line-height: normal;
  416. letter-spacing: 0.06em;
  417. font-feature-settings: 'kern' on;
  418. color: #4359b9;
  419. }
  420. }
  421. }
  422. .echarts_box {
  423. height: 580px;
  424. position: absolute;
  425. left: 0;
  426. top: -36px;
  427. width: 100%;
  428. }
  429. }
  430. .right_container {
  431. height: 580px;
  432. box-sizing: border-box;
  433. border-radius: 16px;
  434. background: #ffffff;
  435. flex: 1;
  436. padding: 32px 42px;
  437. .header {
  438. display: flex;
  439. align-items: center;
  440. justify-content: space-between;
  441. box-sizing: border-box;
  442. width: 340px;
  443. height: 45px;
  444. border-radius: 245px;
  445. background: #06518b;
  446. padding-left: 17px;
  447. padding-right: 24px;
  448. margin-bottom: 20px;
  449. .left {
  450. display: flex;
  451. align-items: center;
  452. .icon {
  453. width: 16px;
  454. height: 16px;
  455. }
  456. .title {
  457. font-family: 思源黑体;
  458. font-size: 14px;
  459. font-weight: normal;
  460. line-height: normal;
  461. letter-spacing: 0.1em;
  462. margin-left: 9px;
  463. color: #ffffff;
  464. }
  465. }
  466. .en {
  467. font-family: 思源黑体;
  468. font-size: 12px;
  469. font-weight: normal;
  470. line-height: normal;
  471. letter-spacing: 0.1em;
  472. color: #ffffff;
  473. }
  474. }
  475. .oper_box {
  476. width: 340px;
  477. height: 455px;
  478. border-radius: 16px;
  479. background: #f6f6f6;
  480. box-sizing: border-box;
  481. padding: 20px;
  482. .emp_box {
  483. width: 300px;
  484. height: 162px;
  485. border-radius: 12px;
  486. background: #fff;
  487. margin-bottom: 20px;
  488. box-sizing: border-box;
  489. padding-top: 16px;
  490. padding-left: 27px;
  491. padding-right: 27px;
  492. padding-bottom: 20px;
  493. display: flex;
  494. flex-direction: column;
  495. .title {
  496. font-family: Source Han Sans;
  497. font-size: 16px;
  498. font-weight: 500;
  499. line-height: normal;
  500. letter-spacing: 0.06em;
  501. font-feature-settings: 'kern' on;
  502. color: #06518b;
  503. }
  504. .num {
  505. flex: 1;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. font-family: 思源黑体;
  510. font-size: 30px;
  511. font-weight: bold;
  512. line-height: normal;
  513. letter-spacing: 0.1em;
  514. color: #000000;
  515. border-radius: 12px;
  516. background: #fafafa;
  517. box-sizing: border-box;
  518. }
  519. }
  520. .test_png {
  521. width: 300px;
  522. height: 50px;
  523. }
  524. }
  525. }
  526. }
  527. </style>