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

397 lines
10 KiB

3 weeks ago
3 weeks ago
3 weeks ago
1 month ago
3 weeks ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
1 month ago
1 month ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
2 months ago
2 months ago
2 months ago
4 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
3 weeks ago
3 weeks ago
3 weeks ago
  1. <script lang="ts" setup>
  2. import { getDeviceStatus } from '@/libs/deviceComm'
  3. import { FtMessage } from '@/libs/message'
  4. import { FtMessageBox } from '@/libs/messageBox'
  5. import { useSealStore } from '@/stores/sealStore'
  6. import { useSystemStore } from '@/stores/systemStore'
  7. import { subscribeEvent, syncSendCmd } from 'apis/system'
  8. import homeFinish from 'assets/images/home/home-finish.svg'
  9. import homeStart from 'assets/images/home/home-start.svg'
  10. import SealInstrumentSvg from 'assets/images/seal/seal-instrument.svg'
  11. import SoftKeyboard from 'components/common/SoftKeyboard/index.vue'
  12. import DashboardChart from 'components/seal/DashboardChart.vue'
  13. import { startPosityveTimer, stopPosityveTimer } from 'libs/timer'
  14. import { computed, onMounted, ref, watch, watchEffect } from 'vue'
  15. defineOptions({
  16. name: 'seal',
  17. })
  18. const sealStore = useSealStore()
  19. const systemStore = useSystemStore()
  20. const sealInfo = ref(sealStore.sealInfo)
  21. const inputValue = ref('')
  22. const keyboardVisible = ref(false)
  23. const keyboardType = ref<'text' | 'number'>('number')
  24. const softKeyboardRef = ref()
  25. const inflationTime = ref()
  26. const sealRemainTimeS = ref<string>()
  27. const currentPressure = ref(sealStore.sealInfo.pressure)
  28. const realTimePressure = ref(sealStore.sealInfo.pressure)
  29. const loading = ref(false)
  30. onMounted(() => {
  31. // initData()
  32. systemStore.subscribeSealEvent()
  33. subscribeSealState()
  34. })
  35. const getFirstPressure = () => {
  36. // 当前气压是开始测试后,状态变为leakTesting后,6秒后获取的压力值为初始值。 由赵贺确认
  37. if (sealInfo.value.workState === 'leakTesting' && !currentPressure.value) {
  38. setTimeout(() => {
  39. currentPressure.value = realTimePressure.value
  40. }, 6000)
  41. }
  42. }
  43. watchEffect(() => {
  44. sealInfo.value = sealStore.sealInfo
  45. realTimePressure.value = sealStore.sealInfo.pressure
  46. getFirstPressure()
  47. })
  48. watch(inputValue, (newVal: string | number) => {
  49. if (Number(newVal) < 1000) {
  50. inflationTime.value = newVal
  51. }
  52. // else {
  53. // inputValue.value = inflationTime.value
  54. // }
  55. })
  56. const subscribeSealState = () => {
  57. // 订阅测试状态
  58. subscribeEvent('stateUpdate', (data: Socket.WebSocketResponse<Seal.SealStateItem>) => {
  59. if (data.fromClass === 'AirLeakDetectTest') {
  60. // 更新测试状态
  61. sealStore.updateSealInfo(data.rely)
  62. }
  63. })
  64. }
  65. const stopText = computed(() => {
  66. return sealInfo.value.workState === 'stopping' ? '停止中...' : '停止测试'
  67. })
  68. const openKeyboard = () => {
  69. keyboardVisible.value = true
  70. }
  71. // const pressure = ref()
  72. const onStartTest = () => {
  73. if (!inflationTime.value) {
  74. FtMessage.warning('请输入测试时间')
  75. return
  76. }
  77. const statusName = getDeviceStatus()
  78. if (statusName) {
  79. FtMessageBox.error(statusName)
  80. return
  81. }
  82. const params = {
  83. className: 'AirLeakDetectTest',
  84. fnName: 'start',
  85. params: {
  86. inflationTimeMs: Number(inflationTime.value * 1000), // 转换为ms
  87. },
  88. }
  89. loading.value = true
  90. syncSendCmd(params).then((res) => {
  91. loading.value = false
  92. if (res.ackcode === 0) {
  93. FtMessage.success('开始执行密封测试')
  94. // 开始计时
  95. startPosityveTimer((time) => {
  96. sealRemainTimeS.value = time
  97. })
  98. }
  99. else {
  100. FtMessage.error('指令发送失败,请稍候再试')
  101. }
  102. }).catch(() => {
  103. loading.value = false
  104. FtMessage.error('指令发送失败,请稍候再试')
  105. })
  106. }
  107. const onFinishTest = () => {
  108. const stopParams = {
  109. className: 'AirLeakDetectTest',
  110. fnName: 'stop',
  111. params: {},
  112. }
  113. // 停止倒计时
  114. stopPosityveTimer()
  115. loading.value = true
  116. syncSendCmd(stopParams).then((res) => {
  117. if (res.ackcode === 0) {
  118. FtMessage.success('测试已停止')
  119. }
  120. loading.value = false
  121. }).finally(() => {
  122. loading.value = false
  123. })
  124. }
  125. const handleConfirm = (value: string) => {
  126. console.log('确认输入:', value)
  127. }
  128. const stopDisabled = computed(() => {
  129. return sealInfo.value.workState === 'stopping' || sealInfo.value.workState === 'idle'
  130. })
  131. </script>
  132. <template>
  133. <div v-loading="loading" class="dashboard-container">
  134. <main class="main-content">
  135. <div class="seal-left">
  136. <!-- 仪表盘 -->
  137. <div class="seal-chart">
  138. <div class="chart-ml">
  139. <DashboardChart />
  140. </div>
  141. <div class="seal-opt">
  142. <div class="seal-status">
  143. <div class="seal-time-text">
  144. 测试时间
  145. </div>
  146. <div v-if="sealInfo.workState === 'idle'" class="seal-time-statue seal-time-text">
  147. 未开始
  148. </div>
  149. <div v-else class="seal-test-time">
  150. {{ sealRemainTimeS }}
  151. </div>
  152. </div>
  153. <div class="seal-status">
  154. <div class="seal-diff-text">
  155. 实时值
  156. </div>
  157. <div v-if="sealInfo.workState === 'idle'" class="seal-diff-statue seal-diff-text">
  158. 未开始
  159. </div>
  160. <div v-else class="seal-test-time">
  161. {{ realTimePressure }}
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="seal-right">
  168. <div class="left-title">
  169. <div class="title-text-test">
  170. <img :src="SealInstrumentSvg" alt="仪表盘">
  171. <div class="title-text">
  172. 测试前气压
  173. </div>
  174. <div class="title-text title-text-kpa">
  175. <span>{{ currentPressure }}</span>
  176. <span class="title-kpa-pl">Kp</span>
  177. </div>
  178. </div>
  179. </div>
  180. <div class="seal-right-btn">
  181. <div class="seal-input">
  182. <div class="inflation-time">
  183. 打压时间
  184. </div>
  185. <el-input
  186. v-model="inflationTime"
  187. v-prevent-keyboard
  188. class="input"
  189. name="inflation"
  190. placeholder="请输入"
  191. style="height: 4rem"
  192. @focus="openKeyboard"
  193. >
  194. <template #append>
  195. <bt-button
  196. type="primary"
  197. button-text="秒"
  198. border-radius="0"
  199. bg-color="#2892F3"
  200. text-color="#ffffff"
  201. height="4rem"
  202. text-size="24px"
  203. min-height="4rem"
  204. />
  205. </template>
  206. </el-input>
  207. </div>
  208. <div>
  209. <div class="seal-add-btn">
  210. <bt-button
  211. button-text="启动测试"
  212. bg-color="#31CB7A"
  213. text-color="#FFFFFF"
  214. width="27vw"
  215. height="7vh"
  216. text-size="24px"
  217. border-radius="12px"
  218. :disabled="sealInfo.workState !== 'idle'"
  219. min-height="4rem"
  220. @click="onStartTest"
  221. >
  222. <template #icon>
  223. <img :src="homeStart" alt="">
  224. </template>
  225. </bt-button>
  226. </div>
  227. <div class="seal-add-btn">
  228. <bt-button
  229. :button-text="stopText"
  230. bg-color="#FF6767"
  231. text-color="#FFFFFF"
  232. width="27vw"
  233. height="7vh"
  234. text-size="24px"
  235. border-radius="12px"
  236. :disabled="stopDisabled"
  237. min-height="4rem"
  238. @click="onFinishTest"
  239. >
  240. <template #icon>
  241. <img :src="homeFinish" alt="">
  242. </template>
  243. </bt-button>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. </main>
  249. <SoftKeyboard
  250. ref="softKeyboardRef"
  251. v-model="inputValue"
  252. :is-visible="keyboardVisible"
  253. :keyboard-type="keyboardType"
  254. @update-keyboard-visible="(visible: boolean) => keyboardVisible = visible"
  255. @confirm="handleConfirm"
  256. @close="keyboardVisible = false"
  257. />
  258. </div>
  259. </template>
  260. <style lang="scss" scoped>
  261. .main-content{
  262. display: grid;
  263. grid-template-columns: repeat(3,1fr);
  264. height: $main-container-height;
  265. gap: 10px;
  266. .seal-left{
  267. background: #FFFFFF;
  268. grid-column: 1 / 3;
  269. box-shadow: 0px 1px 5px 0px rgba(9, 39, 62, 0.15);
  270. background: $gradient-color;
  271. .seal-chart{
  272. }
  273. .chart-ml{
  274. margin: 2rem;
  275. height: 32rem;
  276. }
  277. }
  278. }
  279. .seal-opt{
  280. display: flex;
  281. gap: 2rem;
  282. margin-left: 9rem;
  283. margin-top: -2rem;
  284. .seal-status{
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. background: #F6FAFE;
  289. width: 16rem;
  290. height: 5rem;
  291. border-radius: 15px;
  292. }
  293. .seal-time-text{
  294. font-size: 1.5rem;
  295. font-weight: 500;
  296. padding-left: 0.5rem;
  297. }
  298. .seal-test-time{
  299. font-size: 24px;
  300. color: #2892F3;
  301. }
  302. .seal-time-statue{
  303. height: 3rem;
  304. width: 5rem;
  305. display: flex;
  306. justify-content: center;
  307. align-items: center;
  308. font-weight: 600;
  309. }
  310. .seal-diff-text{
  311. font-size: 1.5rem;
  312. font-weight: 500;
  313. padding-left: 0.5rem;
  314. }
  315. .seal-diff-statue{
  316. height: 3rem;
  317. width: 5rem;
  318. display: flex;
  319. justify-content: center;
  320. align-items: center;
  321. font-weight: 600;
  322. }
  323. }
  324. .seal-right{
  325. background: $gradient-color;
  326. display: grid;
  327. grid-template-rows: repeat(3, 1fr);
  328. .left-title{
  329. padding-top: 3.5vw;
  330. padding-left: 2.5vw;
  331. display: flex;
  332. height: 25vh;
  333. .title-text-test{
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. gap: 1rem;
  338. .title-text{
  339. font-size: 20px;
  340. }
  341. .title-text-kpa{
  342. color: #409EFF;
  343. }
  344. .title-kpa-pl{
  345. padding-left: 5px;
  346. font-weight: bold;
  347. }
  348. }
  349. }
  350. .seal-right-btn{
  351. height: 30vh;
  352. grid-row: 2 / 4;
  353. margin-top: -4rem;
  354. .seal-input{
  355. padding-left: 2rem;
  356. height: 8rem;
  357. font-size: 2.143vw;
  358. font-weight: 400;
  359. .inflation-time{
  360. height: 4rem;
  361. }
  362. .seal-diff-text{
  363. height: 4rem;
  364. }
  365. .input{
  366. width: 25vw;
  367. }
  368. }
  369. .seal-add-btn{
  370. width: 25vw;
  371. height: 8vh;
  372. border-radius: 12px;
  373. color: #FFFFFF;
  374. display: flex;
  375. align-items: center;
  376. justify-content: center;
  377. font-size: 24px;
  378. gap: 10px;
  379. margin: 2rem;
  380. }
  381. }
  382. }
  383. </style>