From cd4daddf4d78f3317710bea2454e0aa8486c47b9 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Mon, 12 May 2025 10:34:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/home.ts | 1 + src/assets/styles/element.scss | 2 +- src/components/home/AddLiquid/index.vue | 22 ++++++++-- src/components/home/Tube/index.vue | 44 +++++++++++++++++--- src/stores/systemStore.ts | 17 ++++---- src/types/home.d.ts | 8 ++++ src/types/system.d.ts | 20 ++++----- src/views/home/index.vue | 73 ++++++++++++++++++++++++++------- 8 files changed, 144 insertions(+), 43 deletions(-) diff --git a/src/apis/home.ts b/src/apis/home.ts index 64e029d..1ac3c2b 100644 --- a/src/apis/home.ts +++ b/src/apis/home.ts @@ -3,3 +3,4 @@ import http from 'libs/http' export const setTargetTemperature = (params: Home.SetTargetTemperatureParams): Promise => http.post('/heat/target-temperature', params) export const trayIn = (): Promise => http.post('/tray/in') export const trayOut = (): Promise => http.post('/tray/out') +export const trayTube = (params: Home.TrayTubeParams): Promise => http.post('/tray/out', params) diff --git a/src/assets/styles/element.scss b/src/assets/styles/element.scss index 1c69120..443acf6 100644 --- a/src/assets/styles/element.scss +++ b/src/assets/styles/element.scss @@ -4,7 +4,7 @@ - --el-color-primary: #26509C; + --el-color-primary: #1989fa; //--el-button-active-bg-color: linear-gradient(90deg, #0657C0 24%, #096AE0 101%); --text-color-primary: #17213c; //--el-color-success: rgba(88, 162, 95, 1); diff --git a/src/components/home/AddLiquid/index.vue b/src/components/home/AddLiquid/index.vue index 4f88a9b..aee54a2 100644 --- a/src/components/home/AddLiquid/index.vue +++ b/src/components/home/AddLiquid/index.vue @@ -2,17 +2,32 @@ import { getSolsList } from 'apis/solution' import emptyIcon from 'assets/images/empty.svg' import { FtMessage } from 'libs/message' +import { socket } from 'libs/socket' import { useHomeStore } from 'stores/homeStore' -import { onMounted, ref } from 'vue' +import { useSystemStore } from 'stores/systemStore' +import { onMounted, onUnmounted, ref } from 'vue' const emits = defineEmits(['ok', 'cancel']) const homeStore = useHomeStore() +const systemStore = useSystemStore() onMounted(() => { getSols() + socket.init(receiveMessage, 'cmd_debug') + socket.init(receiveMessage, 'cmd_response') }) +onUnmounted(() => { + socket.unregisterCallback(receiveMessage, 'cmd_debug') + socket.unregisterCallback(receiveMessage, 'cmd_response') +}) + +let currentCommandId = '' +const receiveMessage = (data: Socket.cmdData) => { + data.commandId === currentCommandId && systemStore.pushSystemList(data) +} + const form = ref<{ tubeNum: number solutionId: number @@ -77,16 +92,15 @@ const okHandle = async () => { return } console.log(mergeAddList()) - + currentCommandId = Date.now().toString() const params = { - commandId: Date.now().toString(), + commandId: currentCommandId, command: 'solution_add', params: { dataList: mergeAddList(), }, } await homeStore.sendControl(params) - // await debugStore.sendControl(params) emits('ok') } const cancel = () => { diff --git a/src/components/home/Tube/index.vue b/src/components/home/Tube/index.vue index e4716c7..eab4a60 100644 --- a/src/components/home/Tube/index.vue +++ b/src/components/home/Tube/index.vue @@ -1,5 +1,6 @@