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

349 lines
9.5 KiB

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