Browse Source

工艺步骤的Json结构变化了

feature/layout_0214
zhangjiming 6 months ago
parent
commit
00d9349f6c
  1. 99
      src/services/globalCmd/globalCmd.ts
  2. 66
      src/views/oreManage/components/CraftConfig.vue
  3. 32
      src/views/oreManage/components/StepItemEx.vue
  4. 1
      src/views/oreManage/index.vue

99
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: "降下托盘",

66
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);
}

32
src/views/oreManage/components/StepItemEx.vue

@ -2,39 +2,39 @@
<div class="bg-[#fafafa] border-b border-b-[#f3f3f3]">
<section class="h-12 flex items-center text-xl px-8">
<span>{{ order }}.</span>
<span>{{ StepCmdDescMap[step.code] }}</span>
<span>{{ StepCmdDescMap[step.method] }}</span>
<span class="text-primary underline ml-auto self-stretch leading-[3rem]" @click="$emit('del', order)">删除</span>
</section>
<template v-if="step.code !== 'takePhoto'">
<section v-if="step.code === 'addLiquid'" class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<template v-if="step.method !== 'takePhoto'">
<section v-if="step.method === 'addLiquid'" class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="h-[1.875rem] rounded-sm bg-[#eaeaea] flex items-center px-3 min-w-[8.125rem]">
<span>盐酸</span>
<img class="ml-auto w-2" src="@/assets/icon_arr_s.svg" alt="arr" />
</div>
<div class="flex items-center">
<input type="number" v-model="step.amount" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<input type="number" v-model="step.params.volume" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span>ml</span>
</div>
</section>
<section
v-if="step.code === 'shaking' || step.code === 'delay'"
v-if="step.method === 'shaking' || step.method === 'delay'"
class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="flex items-center">
<input type="number" v-model="step.time" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span>分钟</span>
<input type="number" v-model="step.params.second" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span></span>
</div>
</section>
<section
v-if="
step.code === 'upTray' ||
step.code === 'downTray' ||
step.code === 'moveToSol' ||
step.code === 'moveToHeater' ||
step.code === 'stopHeating'
step.method === 'upTray' ||
step.method === 'downTray' ||
step.method === 'moveToSol' ||
step.method === 'moveToHeater' ||
step.method === 'stopHeating'
"
class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="flex items-center">
<el-select v-model="step.areaId" placeholder="Select" style="width: 120px">
<el-select v-model="step.params.heaterId" placeholder="Select" style="width: 120px">
<el-option
v-for="item in settingStore.areaOptions"
:key="item.value"
@ -44,17 +44,17 @@
</div>
</section>
<section
v-if="step.code === 'startHeating'"
v-if="step.method === 'startHeating'"
class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="flex items-center gap-3">
<el-select v-model="step.areaId" placeholder="Select" style="width: 100px">
<el-select v-model="step.params.heaterId" placeholder="Select" style="width: 100px">
<el-option
v-for="item in settingStore.areaOptions"
:key="item.value"
:label="item.label"
:value="item.value" />
</el-select>
<input type="number" v-model="step.temperature" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<input type="number" v-model="step.params.temperature" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span></span>
</div>
</section>

1
src/views/oreManage/index.vue

@ -198,6 +198,7 @@ function onDeleteOre() {
});
}
function onAddCraft() {
craftOnEdit.value = undefined;
showCraftEditDialog.value = true;
}
function onEditCraft() {

Loading…
Cancel
Save