diff --git a/src/services/globalCmd/globalCmd.ts b/src/services/globalCmd/globalCmd.ts index 4e0f693..6df5edf 100644 --- a/src/services/globalCmd/globalCmd.ts +++ b/src/services/globalCmd/globalCmd.ts @@ -1,17 +1,88 @@ import httpRequest, { type BaseResponse } from "../httpRequest"; import { addTxnRecord } from "../txn"; -export type StepCmd = - | "upTray" - | "downTray" - | "addLiquid" - | "moveToSol" - | "moveToHeater" - | "shaking" - | "startHeating" - | "stopHeating" - | "takePhoto" - | "delay"; +type UpTrayStepStruct = { + method: "upTray"; + params: { + heaterId: number; + }; +}; +type DownTrayStepStruct = { + method: "downTray"; + params: { + heaterId: number; + }; +}; +export type TubeSolStruct = { + tubeNum: number; + addLiquidList: Array<{ + solId: number; + volume: number; + }>; +}; +type AddLiquidStepStruct = { + method: "addLiquid"; + params: { + solId: number; + volume: number; + tubeSolList?: TubeSolStruct[]; + }; +}; +type MoveToSolStepStruct = { + method: "moveToSol"; + params: { + heaterId: number; + }; +}; +type MoveToHeaterStepStruct = { + method: "moveToHeater"; + params: { + heaterId: number; + }; +}; +type ShakingStepStruct = { + method: "shaking"; + params: { + second: number; + }; +}; + +type StartHeatingStepStruct = { + method: "startHeating"; + params: { + heaterId: number; + temperature: number; + }; +}; +type StopHeatingStepStruct = { + method: "stopHeating"; + params: { + heaterId: number; + }; +}; +type TakePhotoStepStruct = { + method: "takePhoto"; +}; +type DelayStepStruct = { + method: "delay"; + params: { + second: number; + }; +}; + +export type StepStruct = + | UpTrayStepStruct + | DownTrayStepStruct + | AddLiquidStepStruct + | MoveToSolStepStruct + | MoveToHeaterStepStruct + | ShakingStepStruct + | StartHeatingStepStruct + | StopHeatingStepStruct + | TakePhotoStepStruct + | DelayStepStruct; + +export type StepCmd = StepStruct["method"]; export const StepCmdDescMap: { [k in StepCmd]: string } = { upTray: "抬起托盘", @@ -26,12 +97,6 @@ export const StepCmdDescMap: { [k in StepCmd]: string } = { delay: "等待", }; -export type StepCmdParam = "areaId" | "liquidId" | "amount" | "temperature" | "time"; - -export type StepStruct = { - [p in StepCmdParam]?: any; -} & { code: StepCmd }; - export const CmdDescMap: { [k in OperationCmd]: string } = { upTray: "抬起托盘", downTray: "降下托盘", diff --git a/src/views/oreManage/components/CraftConfig.vue b/src/views/oreManage/components/CraftConfig.vue index 145ae21..0c91fda 100644 --- a/src/views/oreManage/components/CraftConfig.vue +++ b/src/views/oreManage/components/CraftConfig.vue @@ -39,7 +39,7 @@ import type { Craft } from "@/services/ore/oreManage"; import StepButton from "./StepButton.vue"; import StepItemEx from "./StepItemEx.vue"; import { ref } from "vue"; -import { StepCmdDescMap, type StepCmd, type StepStruct } from "@/services/globalCmd/globalCmd"; +import { StepCmdDescMap, type StepCmd, type StepStruct, type TubeSolStruct } from "@/services/globalCmd/globalCmd"; import { showToast } from "vant"; const stepCmds: StepCmd[] = [ @@ -65,14 +65,49 @@ const emit = defineEmits<{ }>(); function addStep(step: StepCmd) { - const st: StepStruct = { - code: step, - }; - st.amount = 10; - st.areaId = 2; - st.liquidId = 1; - st.temperature = 100; - st.time = 3; + let st: StepStruct; + if (step === "upTray" || step === "downTray" || step === "moveToSol" || step === "moveToHeater" || step === "stopHeating") { + st = { + method: step, + params: { + heaterId: 2, + }, + }; + } else if (step === "addLiquid") { + st = { + method: step, + params: { + solId: 1, + volume: 10, + }, + }; + } else if (step === "startHeating") { + st = { + method: step, + params: { + heaterId: 2, + temperature: 100, + }, + }; + } else if (step === "delay") { + st = { + method: step, + params: { + second: 10, + }, + }; + } else if (step === "shaking") { + st = { + method: step, + params: { + second: 30, + }, + }; + } else { + st = { + method: step, + }; + } stepStructs.value = [...stepStructs.value, st]; } @@ -85,6 +120,19 @@ function onConfirm() { showToast("请输入工艺名称"); return; } + for (const step of stepStructs.value) { + if (step.method === "addLiquid") { + let tubeSolList: TubeSolStruct[] = []; + for (let index = 0; index < 16; index++) { + tubeSolList.push({ + tubeNum: index + 1, + addLiquidList: [{ solId: step.params.solId, volume: step.params.volume }], + }); + } + step.params.tubeSolList = tubeSolList; + } + } + craftObj.value.steps = JSON.stringify(stepStructs.value); emit("ok", craftObj.value); } diff --git a/src/views/oreManage/components/StepItemEx.vue b/src/views/oreManage/components/StepItemEx.vue index f695a60..b65c6d1 100644 --- a/src/views/oreManage/components/StepItemEx.vue +++ b/src/views/oreManage/components/StepItemEx.vue @@ -2,39 +2,39 @@