Browse Source

fix:工艺编辑浅拷贝的问题

master
guoapeng 2 months ago
parent
commit
6ac1f20bf9
  1. 2
      src/apis/crafts.ts
  2. 190
      src/components/craft/AddCraft/index.vue
  3. 3
      src/components/home/CheckCraft/index.vue

2
src/apis/crafts.ts

@ -30,5 +30,5 @@ export const craftstatus = (): Promise<CraftTypes.CraftState[]> => http.get(`/mo
export const craftstatusByHeatId = (heatId: string): Promise<CraftTypes.CraftState> => http.get(`/monitor/crafts/status/${heatId}`)
export const craftList = (): Promise<any> => http.get(`/crafts/monitor/list`)
export const craftRestart = (monitorId: string): Promise<CraftTypes.CraftState> => http.post(`/crafts/restart`, { monitorId })
export const craftRestore = (isRestore: boolean): Promise<null> => http.get(`/crafts/restore${isRestore}`)
export const craftRestore = (isRestore: boolean): Promise<null> => http.get(`/crafts/restore/${isRestore}`)
export const craftRemove = (monitorId: string): Promise<CraftTypes.CraftState> => http.delete(`/crafts/remove`, { params: { monitorId } })

190
src/components/craft/AddCraft/index.vue

@ -5,6 +5,7 @@ import { getSolsList } from 'apis/solution'
import emptyIcon from 'assets/images/empty.svg'
import { FtMessage } from 'libs/message'
import { allPropertiesDefined } from 'libs/utils'
import { cloneDeep } from 'lodash'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
@ -41,9 +42,7 @@ const form = ref({
const formRef = ref()
const rules = {
name: [
{ required: true, trigger: 'blur', message: '请输入预设名称' },
],
name: [{ required: true, trigger: 'blur', message: '请输入预设名称' }],
}
const okHandle = async () => {
@ -53,41 +52,38 @@ const okHandle = async () => {
return
}
//
const invalidStepIndex = form.value.stepList.findIndex(
(step: any, index) => {
if (['heat', 'dry', 'anneal'].includes(step.method)) {
if (step.params.minutes || step.params.seconds) {
step.params.time = (step.params.minutes || 0) * 60 + (step.params.seconds || 0) || undefined
}
const invalidStepIndex = form.value.stepList.findIndex((step: any, index) => {
if (['heat', 'dry', 'anneal'].includes(step.method)) {
if (step.params.minutes || step.params.seconds) {
step.params.time = (step.params.minutes || 0) * 60 + (step.params.seconds || 0) || undefined
}
step.params.description = `${index}.`
switch (step.method) {
case 'clean':
step.params.description += `针头高度${step.params.height}mm, 加${step.params.volume}ml水清洗${step.params.cycle}`
break
case 'addLiquid':
step.params.description += `添加${solutionList.value.find(s => s.id === containerList.value.find(c => c.id === step.params.containerId)?.solutionId)?.name}-${step.params.volume}ml`
break
case 'reduceLiquid':
step.params.description += `针头高度${step.params.height}mm抽取液体`
break
case 'preHeat':
step.params.description += `预热到${step.params.temperature}`
break
case 'heat':
step.params.description += `加热: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
case 'dry':
step.params.description += `烘干: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
case 'anneal':
step.params.description += `退火: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
}
return !allPropertiesDefined(step.params, ['minutes', 'seconds', 'description'])
},
)
}
step.params.description = `${index}.`
switch (step.method) {
case 'clean':
step.params.description += `针头高度${step.params.height}mm, 加${step.params.volume}ml水清洗${step.params.cycle}`
break
case 'addLiquid':
step.params.description += `添加${solutionList.value.find(s => s.id === containerList.value.find(c => c.id === step.params.containerId)?.solutionId)?.name}-${step.params.volume}ml`
break
case 'reduceLiquid':
step.params.description += `针头高度${step.params.height}mm抽取液体`
break
case 'preHeat':
step.params.description += `预热到${step.params.temperature}`
break
case 'heat':
step.params.description += `加热: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
case 'dry':
step.params.description += `烘干: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
case 'anneal':
step.params.description += `退火: ${step.params.temperature}度, 保持${step.params.minutes || 0}${step.params.seconds || 0}`
break
}
return !allPropertiesDefined(step.params, ['minutes', 'seconds', 'description'])
})
console.log(form.value)
if (invalidStepIndex !== -1) {
@ -116,16 +112,43 @@ const cancel = () => {
const stepMap = {
preHeat: { name: '预热', method: 'preHeat', params: { temperature: undefined, description: undefined } },
addLiquid: { name: '加液', method: 'addLiquid', params: { volume: undefined, containerId: undefined, description: undefined } },
heat: { name: '加热', method: 'heat', params: { temperature: undefined, time: undefined, description: undefined, minutes: undefined, seconds: undefined } },
addLiquid: {
name: '加液',
method: 'addLiquid',
params: { volume: undefined, containerId: undefined, description: undefined },
},
heat: {
name: '加热',
method: 'heat',
params: { temperature: undefined, time: undefined, description: undefined, minutes: undefined, seconds: undefined },
},
reduceLiquid: { name: '抽液', method: 'reduceLiquid', params: { height: undefined, description: undefined } },
clean: { name: '清洗', method: 'clean', params: { cycle: undefined, height: undefined, volume: 2, description: undefined } },
dry: { name: '烘干', method: 'dry', params: { temperature: undefined, time: undefined, description: undefined, minutes: undefined, seconds: undefined } },
anneal: { name: '退火', method: 'anneal', params: { temperature: undefined, feedTemperature: undefined, time: undefined, description: undefined, minutes: undefined, seconds: undefined } },
clean: {
name: '清洗',
method: 'clean',
params: { cycle: undefined, height: undefined, volume: 2, description: undefined },
},
dry: {
name: '烘干',
method: 'dry',
params: { temperature: undefined, time: undefined, description: undefined, minutes: undefined, seconds: undefined },
},
anneal: {
name: '退火',
method: 'anneal',
params: {
temperature: undefined,
feedTemperature: undefined,
time: undefined,
description: undefined,
minutes: undefined,
seconds: undefined,
},
},
}
const addStep = (data: any) => {
form.value.stepList.push(data)
form.value.stepList.push(cloneDeep(data))
}
</script>
@ -140,9 +163,9 @@ const addStep = (data: any) => {
<el-form-item label="步骤列表">
<div class="button-content">
<el-tag v-for="item in stepMap" :key="item" size="large" @click="() => addStep(item)">
<div style="display: flex;align-items: center;justify-content: space-around;width: 100%;">
<div style="display: flex; align-items: center; justify-content: space-around; width: 100%">
<el-icon><Plus /></el-icon>
<span> {{ item.name }}</span>
<span> {{ item.name }}</span>
</div>
</el-tag>
</div>
@ -158,7 +181,13 @@ const addStep = (data: any) => {
mm
</template>
</el-input>
<el-input v-model.number="item.params.volume" style="width: 100px" type="number" size="small" placeholder="请输入加水量">
<el-input
v-model.number="item.params.volume"
style="width: 100px"
type="number"
size="small"
placeholder="请输入加水量"
>
<template #append>
ml
</template>
@ -171,7 +200,12 @@ const addStep = (data: any) => {
</template>
<template v-else-if="item.method === 'addLiquid'">
<el-select v-model="item.params.containerId" size="small" placeholder="请选择溶液">
<el-option v-for="c in containerList" :key="c.id" :label="solutionList.find(s => s.id === c.solutionId)?.name" :value="c.id" />
<el-option
v-for="c in containerList"
:key="c.id"
:label="solutionList.find(s => s.id === c.solutionId)?.name"
:value="c.id"
/>
</el-select>
<el-input v-model.number="item.params.volume" type="number" size="small" placeholder="请输入容量">
<template #append>
@ -187,7 +221,12 @@ const addStep = (data: any) => {
</el-input>
</template>
<template v-else-if="item.method === 'preHeat'">
<el-input v-model.number="item.params.temperature" type="number" size="small" placeholder="请输入温度">
<el-input
v-model.number="item.params.temperature"
type="number"
size="small"
placeholder="请输入温度"
>
<template #append>
</template>
@ -199,40 +238,74 @@ const addStep = (data: any) => {
</template>
</el-input>
<el-select v-model="item.params.minutes" style="width: 70px" clearable size="small" placeholder="请选择">
<el-select
v-model="item.params.minutes"
style="width: 70px"
clearable
size="small"
placeholder="请选择"
>
<el-option v-for="i in 60" :key="i" :label="i" :value="i" />
</el-select>
<span class="unit-text"></span>
<el-select v-model="item.params.seconds" style="width: 70px" clearable size="small" placeholder="请选择">
<el-select
v-model="item.params.seconds"
style="width: 70px"
clearable
size="small"
placeholder="请选择"
>
<el-option v-for="i in 60" :key="i" :label="i" :value="i" />
</el-select>
<span class="unit-text"></span>
</template>
<div v-else-if="['anneal'].includes(item.method)" class="info-box">
<div>
<el-input v-model.number="item.params.temperature" type="number" size="small" placeholder="退火温度">
<el-input
v-model.number="item.params.temperature"
type="number"
size="small"
placeholder="退火温度"
>
<template #append>
</template>
</el-input>
<el-input v-model.number="item.params.feedTemperature" type="number" size="small" placeholder="下料温度">
<el-input
v-model.number="item.params.feedTemperature"
type="number"
size="small"
placeholder="下料温度"
>
<template #append>
</template>
</el-input>
</div>
<div>
<el-select v-model="item.params.minutes" style="width: 70px" clearable size="small" placeholder="请选择">
<el-select
v-model="item.params.minutes"
style="width: 70px"
clearable
size="small"
placeholder="请选择"
>
<el-option v-for="i in 60" :key="i" :label="i" :value="i" />
</el-select>
<span class="unit-text"></span>
<el-select v-model="item.params.seconds" style="width: 70px" clearable size="small" placeholder="请选择">
<el-select
v-model="item.params.seconds"
style="width: 70px"
clearable
size="small"
placeholder="请选择"
>
<el-option v-for="i in 60" :key="i" :label="i" :value="i" />
</el-select>
<span class="unit-text"></span>
</div>
</div>
<el-icon style="margin-left: auto;" @click="() => form.stepList.splice(index, 1)">
<el-icon style="margin-left: auto" @click="() => form.stepList.splice(index, 1)">
<Close />
</el-icon>
</el-form-item>
@ -269,7 +342,7 @@ const addStep = (data: any) => {
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr); /* 创建3列等宽轨道 */
grid-template-rows: repeat(4, auto); /* 创建2行自动高度 */
grid-template-rows: repeat(4, auto); /* 创建2行自动高度 */
gap: 20px;
}
:deep(.el-tag__content) {
@ -296,12 +369,13 @@ const addStep = (data: any) => {
height: 25px;
line-height: 25px;
}
:deep(.el-form-item__content) {
:deep(.el-form-item__content) {
width: 100%;
display: flex;
align-items: center;
.el-input, .el-select {
.el-input,
.el-select {
width: 120px;
margin: 0 5px;
}

3
src/components/home/CheckCraft/index.vue

@ -1,5 +1,6 @@
<script setup lang="ts">
import { craftList, craftRemove, craftRestart } from 'apis/crafts'
import { FtMessage } from 'libs/message'
import { onMounted, ref } from 'vue'
const emits = defineEmits(['close'])
@ -15,10 +16,12 @@ const tableData = ref<any[]>([])
const resumeCraftHandle = async (monitorId: string) => {
await craftRestart(monitorId)
FtMessage.success('恢复成功')
}
const stopCraftHandle = async (monitorId: string) => {
await craftRemove(monitorId)
FtMessage.success('删除成功')
}
const cancel = () => {

Loading…
Cancel
Save