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

342 lines
9.5 KiB

1 month ago
2 months ago
3 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months 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
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 { useHomeStore } from '@/stores/homeStore'
  6. import { useLiquidStore } from '@/stores/liquidStore'
  7. import { useSealStore } from '@/stores/sealStore'
  8. import { useSystemStore } from '@/stores/systemStore'
  9. import { subscribeEvent, syncSendCmd } from 'apis/system'
  10. import homeFinish from 'assets/images/home/home-finish.svg'
  11. import homeStart from 'assets/images/home/home-start.svg'
  12. import SoftKeyboard from 'components/common/SoftKeyboard/index.vue'
  13. import LiquidLevel from 'components/liquid/LiquidLevel.vue'
  14. import { ElMessage } from 'element-plus'
  15. import { roundNumber } from 'libs/utils'
  16. import { computed, onMounted, ref, watchEffect } from 'vue'
  17. const liquidStore = useLiquidStore()
  18. const homeStore = useHomeStore()
  19. const sealStore = useSealStore()
  20. const systemStore = useSystemStore()
  21. const stopatg = ref()
  22. const inputValue = ref('')
  23. const keyboardVisible = ref(false)
  24. const keyboardType = ref<'text' | 'number'>('number')
  25. const softKeyboardRef = ref()
  26. const liquidStateData = ref(liquidStore.liquidStateData)
  27. const addWorkState = ref(liquidStore.liquidStateData)// 加液状态
  28. const drainWorkState = ref(liquidStore.liquidStateData)// 排液状态
  29. const liquidTotoal = ref(liquidStore.liquidTotal)// 总容量
  30. const disinfectionState = ref(homeStore.disinfectionState)
  31. const sealInfo = ref(sealStore.sealInfo)
  32. const loading = ref(false)
  33. const btnStyle = {
  34. width: '25vw',
  35. height: '7vh',
  36. textSize: '24px',
  37. borderRadius: '12px',
  38. textColor: '#FFFFFF',
  39. }
  40. onMounted(() => {
  41. systemStore.subscribeAddLiquidEvent()
  42. systemStore.subscribeDrainLiquidEvent()
  43. subScribeLiquid()
  44. })
  45. watchEffect(() => {
  46. stopatg.value = inputValue.value
  47. addWorkState.value = liquidStore.liquidAddWorkState
  48. drainWorkState.value = liquidStore.liquidDrainWorkState
  49. liquidTotoal.value = liquidStore.liquidTotal
  50. liquidStateData.value = liquidStore.liquidStateData
  51. disinfectionState.value = homeStore.disinfectionState
  52. sealInfo.value = sealStore.sealInfo
  53. loading.value = systemStore.loading
  54. })
  55. const subScribeLiquid = () => { // 事件订阅
  56. subscribeEvent('stateUpdate', (data: Socket.WebSocketResponse<Liquid.LiquidData>) => {
  57. if (data.fromClass === 'AddLiquidService') {
  58. liquidStore.updateAddLiquidWorkState(data.rely)
  59. }
  60. if (data.fromClass === 'DrainLiquidService') {
  61. liquidStore.updateDrainLiquidWorkState(data.rely)
  62. }
  63. })
  64. }
  65. const openKeyboard = () => {
  66. keyboardVisible.value = true
  67. }
  68. const nowLiquid = computed(() => {
  69. return roundNumber(liquidStateData.value.nowLiquid, 0)
  70. })
  71. const handleConfirm = (value: string) => {
  72. console.log('确认输入:', value)
  73. }
  74. const onStartAddLiquid = async () => {
  75. const statusName = getDeviceStatus()
  76. if (statusName) {
  77. FtMessageBox.error(statusName)
  78. return
  79. }
  80. if (!stopatg.value || stopatg.value < 0) {
  81. FtMessage.warning('请输入加液容量')
  82. return
  83. }
  84. if (stopatg.value > liquidTotoal.value) {
  85. FtMessage.warning('加液容量不能大于总容量')
  86. return
  87. }
  88. const params = {
  89. className: 'AddLiquidService',
  90. fnName: 'start',
  91. params: {
  92. stopatg: Number(stopatg.value),
  93. },
  94. }
  95. loading.value = true
  96. syncSendCmd(params).finally(() => {
  97. loading.value = false
  98. })
  99. }
  100. const onStopAddLiquid = async () => {
  101. const params = {
  102. className: 'AddLiquidService',
  103. fnName: 'stop',
  104. }
  105. loading.value = true
  106. syncSendCmd(params).finally(() => {
  107. loading.value = false
  108. })
  109. }
  110. // 开始排液
  111. const onStartDrainLiquid = async () => {
  112. const statusName = getDeviceStatus()
  113. if (statusName) {
  114. FtMessageBox.error(statusName)
  115. return
  116. }
  117. const params = {
  118. className: 'DrainLiquidService',
  119. fnName: 'start',
  120. }
  121. loading.value = true
  122. syncSendCmd(params).finally(() => {
  123. loading.value = false
  124. })
  125. }
  126. const onStopDrainLiquid = async () => {
  127. if (drainWorkState.value.workState === 'idle') {
  128. ElMessage.warning('正在加液中,不可进行排液操作')
  129. return
  130. }
  131. const params = {
  132. className: 'DrainLiquidService',
  133. fnName: 'stop',
  134. }
  135. loading.value = true
  136. syncSendCmd(params).finally(() => {
  137. loading.value = false
  138. })
  139. }
  140. </script>
  141. <template>
  142. <div v-loading="loading">
  143. <main class="main-content">
  144. <div class="liquid-left">
  145. <LiquidLevel />
  146. </div>
  147. <div class="liquid-right">
  148. <!-- 当前液位 -->
  149. <div class="liquid-surplus-title">
  150. <div>当前液位</div>
  151. <div class="liquid-title-g">
  152. {{ nowLiquid }}g
  153. </div>
  154. </div>
  155. <!-- 输入加液/排液量 -->
  156. <div class="liquid-input">
  157. <el-input
  158. v-model="stopatg"
  159. v-prevent-keyboard
  160. class="input"
  161. name="nowLiquid"
  162. placeholder="请输入"
  163. style="height: 4rem"
  164. @focus="openKeyboard"
  165. >
  166. <template #append>
  167. <bt-button
  168. type="primary"
  169. :button-text="`${liquidTotoal}g`"
  170. bg-color="#2892F3"
  171. text-color="#ffffff"
  172. height="4rem"
  173. text-size="24px"
  174. />
  175. </template>
  176. </el-input>
  177. </div>
  178. <!-- 操作区 -->
  179. <div class="liquid-opt">
  180. <div>
  181. <div class="liquid-add-btn">
  182. <bt-button
  183. v-if="addWorkState.workState === 'idle'"
  184. button-text="开始加液"
  185. bg-color="#31CB7A"
  186. :text-color="btnStyle.textColor"
  187. :width="btnStyle.width"
  188. :height="btnStyle.height"
  189. :text-size="btnStyle.textSize"
  190. :border-radius="btnStyle.borderRadius"
  191. @click="onStartAddLiquid"
  192. >
  193. <template #icon>
  194. <img :src="homeStart" alt="">
  195. </template>
  196. </bt-button>
  197. <bt-button
  198. v-else
  199. :button-text="addWorkState.workState === 'emptyLineLiquid' ? '排空管路中' : '停止加液'"
  200. bg-color="#FF6767"
  201. :text-color="btnStyle.textColor"
  202. :width="btnStyle.width"
  203. :height="btnStyle.height"
  204. :text-size="btnStyle.textSize"
  205. :border-radius="btnStyle.borderRadius"
  206. :disabled="addWorkState.workState === 'emptyLineLiquid'"
  207. @click="onStopAddLiquid"
  208. >
  209. <template #icon>
  210. <img :src="homeFinish" alt="">
  211. </template>
  212. </bt-button>
  213. </div>
  214. <div class="liquid-drain">
  215. <bt-button
  216. v-if="drainWorkState.workState === 'idle'"
  217. button-text="开始排液"
  218. bg-color="#2892F3"
  219. :text-color="btnStyle.textColor"
  220. :width="btnStyle.width"
  221. :height="btnStyle.height"
  222. :text-size="btnStyle.textSize"
  223. :border-radius="btnStyle.borderRadius"
  224. @click="onStartDrainLiquid"
  225. >
  226. <template #icon>
  227. <img :src="homeStart" alt="">
  228. </template>
  229. </bt-button>
  230. <bt-button
  231. v-else
  232. button-text="停止排液"
  233. bg-color="#FF6767"
  234. :text-color="btnStyle.textColor"
  235. :width="btnStyle.width"
  236. :height="btnStyle.height"
  237. :text-size="btnStyle.textSize"
  238. :border-radius="btnStyle.borderRadius"
  239. @click="onStopDrainLiquid"
  240. >
  241. <template #icon>
  242. <img :src="homeFinish" alt="">
  243. </template>
  244. </bt-button>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </main>
  250. <SoftKeyboard
  251. ref="softKeyboardRef"
  252. v-model="inputValue"
  253. :is-visible="keyboardVisible"
  254. :keyboard-type="keyboardType"
  255. @update-keyboard-visible="(visible) => keyboardVisible = visible"
  256. @confirm="handleConfirm"
  257. @close="keyboardVisible = false"
  258. />
  259. </div>
  260. </template>
  261. <style lang="scss" scoped>
  262. .main-content{
  263. display: grid;
  264. grid-template-columns: repeat(3,1fr);
  265. height: $main-container-height;
  266. gap: 10px;
  267. overflow: hidden;
  268. .liquid-left{
  269. background: #FFFFFF;
  270. grid-column: 1 / 3;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. box-shadow: 0px 1px 5px 0px rgba(9, 39, 62, 0.15);
  275. background: $gradient-color;
  276. }
  277. .liquid-right{
  278. background:#FFFFFF;
  279. box-shadow: 0px 1px 5px 0px rgba(9, 39, 62, 0.15);
  280. padding-top: 15vh;
  281. width: 100%;
  282. background: $gradient-color;
  283. .liquid-surplus-title{
  284. height: 10vh;
  285. display: flex;
  286. padding-left: 2.5rem;
  287. align-items: center;
  288. font-size: 24px;
  289. font-weight: 400;
  290. .liquid-title-g{
  291. color: #2892F3;
  292. font-weight: bold;
  293. }
  294. }
  295. .liquid-input{
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. .input{
  300. width: 25vw;
  301. }
  302. }
  303. .liquid-opt{
  304. display: flex;
  305. justify-content: center;
  306. margin-top: 5vh;
  307. }
  308. .liquid-add-btn{
  309. width: 25vw;
  310. height: 8vh;
  311. border-radius: 12px;
  312. color: #FFFFFF;
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. font-size: 24px;
  317. gap: 10px;
  318. }
  319. .liquid-drain{
  320. margin-top: 1.5rem;
  321. }
  322. }
  323. }
  324. </style>