From 8edea9484b85f24251d44f2096b5c733814085db Mon Sep 17 00:00:00 2001 From: LiLongLong <13717757313@163.com> Date: Tue, 25 Feb 2025 18:06:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=A7=E8=A1=8C=E5=B7=A5?= =?UTF-8?q?=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 + src/assets/executing.svg | 1 + src/assets/ready.svg | 1 + src/components/OverlayModal.vue | 2 +- src/services/globalCmd/globalCmd.ts | 1 + src/services/ore/oreManage.ts | 4 + src/services/socket.ts | 9 ++ src/services/task/task.ts | 10 +- src/services/txn.ts | 16 +++- src/stores/craft.ts | 15 +++ src/views/graphite/components/AddLiquid.vue | 88 ++++++++++-------- src/views/graphite/components/HeatPosition.vue | 85 ++++++++++------- src/views/graphite/index.vue | 121 ++++++++++++++++--------- 13 files changed, 236 insertions(+), 120 deletions(-) create mode 100644 src/assets/executing.svg create mode 100644 src/assets/ready.svg create mode 100644 src/stores/craft.ts diff --git a/src/App.vue b/src/App.vue index 2963f0c..18e23cb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,6 +7,7 @@ import { getConfig, getContainerList } from "./services/sysConfig/sysConfig"; import { useSettingStore } from "./stores/setting"; import { getLiquidList } from "./services/liquid/liquidManage"; import { useStatusStore } from "./stores/status"; +import { useCraftStore } from "./stores/craft"; import { ElMessage } from "element-plus"; import { getUserList } from "./services/user/userManager"; import { useUserStore } from "./stores/user"; @@ -15,6 +16,7 @@ const router = useRouter(); const settingStore = useSettingStore(); const statusStore = useStatusStore(); const userStore = useUserStore(); +const craftStore = useCraftStore() const wsClient = createWebSocket(sharedWsUrl); wsClient.dataOb.subscribe(data => { @@ -27,6 +29,7 @@ wsClient.dataOb.subscribe(data => { }); } else if (data.type === "crafts") { console.log("crafts:", data); + craftStore.setCraftInfo(data.data); } else if (data.type === "container") { settingStore.setContainerConf(data.data.containerList); } diff --git a/src/assets/executing.svg b/src/assets/executing.svg new file mode 100644 index 0000000..ac58c36 --- /dev/null +++ b/src/assets/executing.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/ready.svg b/src/assets/ready.svg new file mode 100644 index 0000000..a26eeaf --- /dev/null +++ b/src/assets/ready.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/OverlayModal.vue b/src/components/OverlayModal.vue index 0063206..864097a 100644 --- a/src/components/OverlayModal.vue +++ b/src/components/OverlayModal.vue @@ -21,7 +21,7 @@ position: absolute; top: 0px; left: 0px; - z-index: 999 + z-index: 112 } .overlay_modal{ display: flex; diff --git a/src/services/globalCmd/globalCmd.ts b/src/services/globalCmd/globalCmd.ts index ef7d62c..c19985c 100644 --- a/src/services/globalCmd/globalCmd.ts +++ b/src/services/globalCmd/globalCmd.ts @@ -118,6 +118,7 @@ export const CmdDescMap: { [k in OperationCmd]: string } = { moveTube: "移动试管", openDoor: "开门", closeDoor: "关门", + }; export type OperationCmd = diff --git a/src/services/ore/oreManage.ts b/src/services/ore/oreManage.ts index ea8fb34..92186d0 100644 --- a/src/services/ore/oreManage.ts +++ b/src/services/ore/oreManage.ts @@ -41,3 +41,7 @@ export function getCraftList(ids: string) { export function craftStart(params:any) { return httpRequest({ url: `/api/crafts/start`, method: "POST", params }); } + +export function craftStop(params:any) { + return httpRequest({ url: `/api/crafts/stop`, method: "POST", params }); +} \ No newline at end of file diff --git a/src/services/socket.ts b/src/services/socket.ts index 8811a08..cfadabd 100644 --- a/src/services/socket.ts +++ b/src/services/socket.ts @@ -116,6 +116,15 @@ export type StatusDatagram = { }; }; +export type CraftState = { + type: "crafts" + data: { + heatId: string | number + methodIndex: string| number + status: string| number + } +} + export type ContainerDatagram = { type: "container", data: { diff --git a/src/services/task/task.ts b/src/services/task/task.ts index 5014a7f..e4cc377 100644 --- a/src/services/task/task.ts +++ b/src/services/task/task.ts @@ -1,5 +1,5 @@ import httpRequest, { type BaseResponse } from "../httpRequest"; -import { addTxnRecord } from "../txn"; +import { addTxnRecord, injectFluidsRecord } from "../txn"; import type { OperationCmd } from "../globalCmd/globalCmd"; @@ -21,5 +21,11 @@ export function getIngTask() { //批量加热 export function startHeat(params: { command: OperationCmd; params: [] }) { const commandId = addTxnRecord({ ...params, category: "task" }); - return httpRequest>({ url: "/api/cmd/startHeat", params, method: "POST" }); + return httpRequest>({ url: "/api/cmd/startHeat", params: { ...params, commandId }, method: "POST" }); +} + +//批量加液 +export function injectFluid(params:any) { + const commandId = injectFluidsRecord({ injectFluids:params.injectFluids, command:'', category: "task" }); + return httpRequest>({ url: "/api/cmd/injectFluid", params: { ...params, commandId }, method: "POST" }); } \ No newline at end of file diff --git a/src/services/txn.ts b/src/services/txn.ts index 868bd5f..cd315ce 100644 --- a/src/services/txn.ts +++ b/src/services/txn.ts @@ -24,11 +24,17 @@ type DebugCmdRecord = { type TaskCmdRecord = { category: "task"; - command: OperationCmd; + command: OperationCmd | null; params: Record; } -type TxnRecord = DebugCmdRecord | TaskCmdRecord +type TaskCmdInjectFluidsRecord = { + category: "task"; + command: '', + injectFluids: []; +} + +type TxnRecord = DebugCmdRecord | TaskCmdRecord | TaskCmdInjectFluidsRecord const txnCmdMap: Record = {}; @@ -38,6 +44,12 @@ export function addTxnRecord(val: TxnRecord) { return txn; } +export function injectFluidsRecord(val: TaskCmdInjectFluidsRecord){ + const txn = generateTxnNo().toString(); + txnCmdMap[txn] = val; + return txn; +} + export function getTxnRecord(txn: string, category: TxnRecord["category"]) { const record = txnCmdMap[txn]; // 只有属于指定category时,才返回,且返回后删除记录,节约内存 diff --git a/src/stores/craft.ts b/src/stores/craft.ts new file mode 100644 index 0000000..d58d941 --- /dev/null +++ b/src/stores/craft.ts @@ -0,0 +1,15 @@ +import { ref, computed } from "vue"; +import { defineStore } from "pinia"; +import * as R from "ramda"; +import type { CraftState } from "@/services/socket"; + +export const useCraftStore = defineStore("craft", () => { + const craftInfo = ref(); + const setCraftInfo = (data: CraftState["data"]) => { + if (!R.equals(craftInfo.value, data)) { + craftInfo.value = data; + } + }; + + return { craftInfo, setCraftInfo }; +}); diff --git a/src/views/graphite/components/AddLiquid.vue b/src/views/graphite/components/AddLiquid.vue index 065203f..bb14ea3 100644 --- a/src/views/graphite/components/AddLiquid.vue +++ b/src/views/graphite/components/AddLiquid.vue @@ -1,22 +1,29 @@