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

380 lines
9.6 KiB

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