消毒机设备
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.

344 lines
8.9 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 weeks ago
2 months ago
2 months ago
2 months ago
3 weeks ago
2 months ago
3 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
  1. <script lang="ts" setup>
  2. import { sendCmd, syncSendCmd } from 'apis/system'
  3. import homeFinish from 'assets/images/home/home-finish.svg'
  4. import homeStart from 'assets/images/home/home-start.svg'
  5. import SealInstrumentSvg from 'assets/images/seal/seal-instrument.svg'
  6. import SoftKeyboard from 'components/common/SoftKeyboard/index.vue'
  7. import DashboardChart from 'components/seal/DashboardChart.vue'
  8. import { roundNumber } from 'libs/utils'
  9. import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
  10. import { getDeviceStatus } from '@/libs/deviceComm'
  11. import { FtMessage } from '@/libs/message'
  12. import { FtMessageBox } from '@/libs/messageBox'
  13. import { useSealStore } from '@/stores/sealStore'
  14. defineOptions({ name: 'Seal' })
  15. const sealStore = useSealStore()
  16. const initialPressure = ref<string>('0')
  17. const sealInfo = computed(() => sealStore.sealInfo)
  18. const leakRemainingTime = computed(() => sealStore.leakRemainingTime)
  19. const currentPressure = computed(() => sealStore.currentPressure)
  20. const diffPressure = computed<number>(() => {
  21. if (sealInfo.value.workState === 'leakTesting') {
  22. return Math.abs(Number(currentPressure.value) - Number(initialPressure.value))
  23. }
  24. return 0
  25. })
  26. const inputValue = ref('')
  27. const keyboardVisible = ref(false)
  28. const keyboardType = ref<'text' | 'number'>('number')
  29. const softKeyboardRef = ref()
  30. const inflationTime = ref<number>()
  31. const loading = ref(false)
  32. watch(
  33. () => sealInfo.value.workState,
  34. (newState, oldState) => {
  35. if (oldState === 'stabilizingPressure' && newState === 'leakTesting') {
  36. initialPressure.value = sealInfo.value.pressure
  37. }
  38. },
  39. )
  40. onMounted(async () => {
  41. const res = await sendCmd({
  42. className: 'AirLeakDetectTest',
  43. fnName: 'getServiceConfig',
  44. params: { inflationTimeMs: 0.3 },
  45. })
  46. inflationTime.value = res.inflationTimeMs
  47. poll = setInterval(() => {
  48. if (sealInfo.value.workState === 'leakTesting') {
  49. sealStore.startLeakTimer()
  50. clearInterval(poll)
  51. }
  52. }, 100)
  53. })
  54. onUnmounted(() => {
  55. clearInterval(poll)
  56. })
  57. const stopText = computed(() => (sealInfo.value.workState === 'stopping' ? '停止中...' : '停止测试'))
  58. const stopDisabled = computed(() => sealInfo.value.workState === 'stopping' || sealInfo.value.workState === 'idle')
  59. let poll: any = 0
  60. function onStartTest() {
  61. const statusName = getDeviceStatus()
  62. if (statusName) {
  63. FtMessageBox.error(statusName)
  64. return
  65. }
  66. loading.value = true
  67. syncSendCmd({ className: 'AirLeakDetectTest', fnName: 'start', params: { inflationTimeMs: 0 } })
  68. .then((res) => {
  69. if (res.ackcode === 0) {
  70. poll = setInterval(() => {
  71. if (sealInfo.value.workState === 'leakTesting') {
  72. sealStore.startLeakTimer()
  73. clearInterval(poll)
  74. }
  75. }, 100)
  76. FtMessage.success('开始执行密封测试')
  77. }
  78. else {
  79. FtMessage.error('指令发送失败,请稍候再试')
  80. }
  81. })
  82. .finally(() => {
  83. loading.value = false
  84. })
  85. }
  86. function onFinishTest() {
  87. loading.value = true
  88. syncSendCmd({ className: 'AirLeakDetectTest', fnName: 'stop', params: {} })
  89. .then((res) => {
  90. if (res.ackcode === 0) {
  91. sealStore.stopLeakTimer()
  92. FtMessage.success('测试已停止')
  93. }
  94. })
  95. .finally(() => {
  96. loading.value = false
  97. })
  98. }
  99. function handleConfirm(value: string) {
  100. console.log('确认输入:', value)
  101. }
  102. </script>
  103. <template>
  104. <div class="dashboard-container">
  105. <main class="main-content">
  106. <div class="seal-left">
  107. <!-- 仪表盘 -->
  108. <div class="seal-chart">
  109. <div class="chart-ml">
  110. <DashboardChart />
  111. </div>
  112. <div class="seal-opt">
  113. <div class="seal-status">
  114. <div class="seal-time-text">
  115. 测试时间
  116. </div>
  117. <div v-if="sealInfo.workState !== 'leakTesting'" class="seal-time-statue seal-time-text">
  118. 未开始
  119. </div>
  120. <div v-else class="seal-test-time">
  121. {{ leakRemainingTime }}
  122. </div>
  123. </div>
  124. <div class="seal-status">
  125. <div class="seal-diff-text">
  126. 测试前气压
  127. </div>
  128. <div v-if="sealInfo.workState === 'inflating'" class="seal-diff-statue seal-diff-text">
  129. 打压中
  130. </div>
  131. <div v-else-if="sealInfo.workState === 'stabilizingPressure'" class="seal-diff-statue seal-diff-text">
  132. 稳压中
  133. </div>
  134. <div v-else-if="sealInfo.workState === 'stopping'" class="seal-diff-statue seal-diff-text">
  135. 停止中
  136. </div>
  137. <!-- 捡漏中 -->
  138. <div v-else-if="sealInfo.workState === 'leakTesting'" class="seal-test-time">
  139. {{ initialPressure }}Kpa
  140. </div>
  141. <div v-else class="seal-diff-statue seal-diff-text">
  142. 未开始
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="seal-right">
  149. <div class="title-text-test">
  150. <img :src="SealInstrumentSvg" alt="仪表盘">
  151. <div class="title-text">
  152. 气压差值
  153. </div>
  154. <div class="title-text title-text-kpa">
  155. <span>{{ roundNumber(diffPressure, 2) }}</span>
  156. <span class="title-kpa-pl">Kpa</span>
  157. </div>
  158. </div>
  159. <bt-button
  160. button-text="启动测试"
  161. bg-color="#31CB7A"
  162. text-color="#FFFFFF"
  163. width="27vw"
  164. height="7vh"
  165. text-size="24px"
  166. border-radius="12px"
  167. :disabled="sealInfo.workState !== 'idle'"
  168. min-height="4rem"
  169. @click="onStartTest"
  170. >
  171. <template #icon>
  172. <img :src="homeStart" alt="">
  173. </template>
  174. </bt-button>
  175. <bt-button
  176. style="margin: 0"
  177. :button-text="stopText"
  178. bg-color="#FF6767"
  179. text-color="#FFFFFF"
  180. width="27vw"
  181. height="7vh"
  182. text-size="24px"
  183. border-radius="12px"
  184. :disabled="stopDisabled"
  185. min-height="4rem"
  186. @click="onFinishTest"
  187. >
  188. <template #icon>
  189. <img :src="homeFinish" alt="">
  190. </template>
  191. </bt-button>
  192. </div>
  193. </main>
  194. <SoftKeyboard
  195. ref="softKeyboardRef"
  196. v-model="inputValue"
  197. :is-visible="keyboardVisible"
  198. :keyboard-type="keyboardType"
  199. @update-keyboard-visible="(visible: boolean) => (keyboardVisible = visible)"
  200. @confirm="handleConfirm"
  201. @close="keyboardVisible = false"
  202. />
  203. </div>
  204. </template>
  205. <style lang="scss" scoped>
  206. .main-content {
  207. display: grid;
  208. grid-template-columns: repeat(3, 1fr);
  209. height: $main-container-height;
  210. gap: 10px;
  211. .seal-left {
  212. background: #ffffff;
  213. grid-column: 1 / 3;
  214. box-shadow: 0px 1px 5px 0px rgba(9, 39, 62, 0.15);
  215. background: $gradient-color;
  216. .seal-chart {
  217. }
  218. .chart-ml {
  219. margin: 2rem;
  220. height: 32rem;
  221. }
  222. }
  223. }
  224. .seal-opt {
  225. display: flex;
  226. gap: 2rem;
  227. margin-left: 9rem;
  228. margin-top: -2rem;
  229. .seal-status {
  230. display: flex;
  231. justify-content: center;
  232. align-items: center;
  233. background: #f6fafe;
  234. //width: 16rem;
  235. height: 5rem;
  236. border-radius: 15px;
  237. padding: 0 20px;
  238. }
  239. .seal-time-text {
  240. font-size: 1.5rem;
  241. font-weight: 500;
  242. padding-left: 0.5rem;
  243. }
  244. .seal-test-time {
  245. font-size: 24px;
  246. color: #2892f3;
  247. }
  248. .seal-time-statue {
  249. height: 3rem;
  250. width: 5rem;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. font-weight: 600;
  255. }
  256. .seal-diff-text {
  257. font-size: 1.5rem;
  258. font-weight: 500;
  259. padding-left: 0.5rem;
  260. }
  261. .seal-diff-statue {
  262. height: 3rem;
  263. width: 5rem;
  264. display: flex;
  265. justify-content: center;
  266. align-items: center;
  267. font-weight: 600;
  268. }
  269. }
  270. .seal-right {
  271. background: $gradient-color;
  272. display: flex;
  273. flex-direction: column;
  274. justify-content: center;
  275. align-items: center;
  276. gap: 30px;
  277. .title-text-test {
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. gap: 5px;
  282. height: 50px;
  283. img {
  284. height: 50%;
  285. }
  286. .title-text {
  287. font-size: 20px;
  288. }
  289. .title-text-kpa {
  290. color: #409eff;
  291. }
  292. .title-kpa-pl {
  293. padding-left: 5px;
  294. font-weight: bold;
  295. }
  296. }
  297. .seal-right-btn {
  298. //height: 30vh;
  299. grid-row: 2 / 4;
  300. margin-top: -6rem;
  301. display: flex;
  302. justify-content: center;
  303. .seal-input {
  304. padding-left: 2rem;
  305. height: 8rem;
  306. font-size: 2.143vw;
  307. font-weight: 400;
  308. .inflation-time {
  309. height: 4rem;
  310. }
  311. .seal-diff-text {
  312. height: 4rem;
  313. }
  314. .input {
  315. width: 25vw;
  316. }
  317. }
  318. .seal-add-btn {
  319. width: 25vw;
  320. height: 12vh;
  321. border-radius: 12px;
  322. color: #ffffff;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. font-size: 24px;
  327. gap: 10px;
  328. }
  329. }
  330. }
  331. </style>