update 配方信息明细维护

master
yinq 3 days ago
parent a662bfa16d
commit e0bcd07b89

@ -60,9 +60,9 @@ export interface RecipeWeightVO {
unitId: string | number; unitId: string | number;
/** /**
* * ID
*/ */
childCode: string; childCode: number;
/** /**
* 使 * 使
@ -138,9 +138,9 @@ export interface RecipeWeightForm extends BaseEntity {
unitId?: string | number; unitId?: string | number;
/** /**
* * ID
*/ */
childCode?: string; childCode?: number;
/** /**
* 使 * 使
@ -217,9 +217,9 @@ export interface RecipeWeightQuery extends PageQuery {
unitId?: string | number; unitId?: string | number;
/** /**
* * ID
*/ */
childCode?: string; childCode?: number;
/** /**
* 使 * 使

@ -3,12 +3,8 @@
<div class="page-header"> <div class="page-header">
<span class="page-title">配方明细信息</span> <span class="page-title">配方明细信息</span>
<div class="header-actions"> <div class="header-actions">
<el-button type="primary" :icon="isEdit ? 'Select' : 'Edit'" @click="toggleEdit"> <el-button @click="goBack"></el-button>
{{ isEdit ? '取消编辑' : '编辑' }} <el-button type="primary" :loading="saveLoading" @click="handleSave"></el-button>
</el-button>
<el-button type="success" icon="Select" :loading="saveLoading" :disabled="!isEdit" @click="handleSave">
保存
</el-button>
</div> </div>
</div> </div>
@ -16,7 +12,7 @@
<el-tab-pane label="基本信息" name="basic"> <el-tab-pane label="基本信息" name="basic">
<el-card shadow="never" class="mb-4"> <el-card shadow="never" class="mb-4">
<template #header>配方基本信息</template> <template #header>配方基本信息</template>
<el-form ref="basicFormRef" :model="recipeInfo" :disabled="!isEdit" label-width="140px" class="form-grid"> <el-form ref="basicFormRef" :model="recipeInfo" label-width="140px" class="form-grid">
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="配方代码" prop="recipeCode"> <el-form-item label="配方代码" prop="recipeCode">
@ -36,8 +32,18 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="物料名称" prop="recipeCode"> <el-form-item label="物料" prop="materialId">
<el-input v-model="recipeInfo.recipeCode" placeholder="物料名称" /> <el-input
:model-value="recipeMaterialDisplay"
placeholder="请选择物料"
readonly
style="width: 100%"
@click="openMaterialSelect"
>
<template #append>
<el-button :icon="'Search'" @click.stop="openMaterialSelect">选择</el-button>
</template>
</el-input>
</el-form-item> </el-form-item>
<el-form-item label="超温温度(℃)" prop="overtempTemp"> <el-form-item label="超温温度(℃)" prop="overtempTemp">
<el-input-number v-model="recipeInfo.overtempTemp" :min="0" controls-position="right" style="width: 100%" /> <el-input-number v-model="recipeInfo.overtempTemp" :min="0" controls-position="right" style="width: 100%" />
@ -74,47 +80,70 @@
<el-tab-pane label="称量信息" name="weight"> <el-tab-pane label="称量信息" name="weight">
<div class="tab-toolbar mb-3"> <div class="tab-toolbar mb-3">
<el-button type="primary" size="small" @click="calcWeight"></el-button> <el-button type="primary" size="small" @click="addWeightRowEnd"></el-button>
<el-button size="small" @click="refreshWeight"></el-button> <el-button size="small" @click="refreshWeight"></el-button>
</div> </div>
<el-card shadow="never" class="mb-3"> <el-card shadow="never" class="mb-3">
<template #header>称量明细</template> <template #header>称量明细</template>
<el-table :data="weightList" border> <el-table :data="weightList" border>
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="物料名称/炭黑名称" prop="childCode" min-width="120"> <el-table-column label="称量类型" prop="weightType" width="100" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="isEdit" v-model="row.childCode" size="small" placeholder="物料编码" /> <el-select v-model="row.weightType" size="small" placeholder="类型" clearable style="width: 100%">
<span v-else>{{ row.childCode || '-' }}</span> <el-option v-for="d in weight_type" :key="d.value" :label="d.label" :value="d.value" />
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="物料编码" prop="fatherCode" min-width="100"> <el-table-column label="物料名称" prop="childCode" min-width="160">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="isEdit" v-model="row.fatherCode" size="small" /> <el-select
<span v-else>{{ row.fatherCode || '-' }}</span> v-model="row.childCode"
size="small"
placeholder="请选择物料"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="m in materialOptions"
:key="m.materialId"
:label="`${m.materialName || ''} (${m.materialCode || ''})`"
:value="Number(m.materialId)"
/>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="称量动作" prop="actCode" width="100"> <el-table-column label="动作" prop="actCode" width="120" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="isEdit" v-model="row.actCode" size="small" /> <el-select
<span v-else>{{ row.actCode || '-' }}</span> v-model="row.actCode"
size="small"
placeholder="请选择动作"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="d in actCodeOptions"
:key="d.dataDetailCode"
:label="d.dataDetailName"
:value="d.dataDetailCode"
/>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设定重量(千克)" prop="setWeight" width="140"> <el-table-column label="设定重量" prop="setWeight" width="120" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setWeight" :min="0" :precision="3" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.setWeight" :min="0" :precision="3" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setWeight ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="允许误差(千克)" prop="errorAllow" width="140"> <el-table-column label="误差允许" prop="errorAllow" width="120" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.errorAllow" :min="0" :precision="3" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.errorAllow" :min="0" :precision="3" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.errorAllow ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="isEdit" label="操作" width="180" fixed="right" align="center"> <el-table-column label="操作" width="80" fixed="right" align="center">
<template #default="{ $index }"> <template #default="{ $index }">
<el-button link type="primary" size="small" @click="addWeightRow($index)"></el-button>
<el-button link type="primary" size="small" @click="insertWeightRow($index)"></el-button>
<el-button link type="danger" size="small" @click="removeWeightRow($index)"></el-button> <el-button link type="danger" size="small" @click="removeWeightRow($index)"></el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -127,63 +156,93 @@
<el-tab-pane label="混炼信息" name="mixing"> <el-tab-pane label="混炼信息" name="mixing">
<div class="tab-toolbar mb-3"> <div class="tab-toolbar mb-3">
<el-button type="primary" size="small" @click="refreshMixing"></el-button> <el-button type="primary" size="small" @click="addMixingRowEnd"></el-button>
<el-button size="small" @click="refreshMixing"></el-button> <el-button size="small" @click="refreshMixing"></el-button>
</div> </div>
<el-card shadow="never"> <el-card shadow="never">
<template #header>混炼信息</template>
<el-table :data="mixingList" border> <el-table :data="mixingList" border>
<el-table-column type="index" label="步骤" width="70" align="center" /> <el-table-column type="index" label="步骤" width="70" align="center" />
<el-table-column label="动作" prop="actCode" min-width="120"> <el-table-column label="动作" prop="actCode" width="140" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="isEdit" v-model="row.actCode" size="small" /> <el-select
<span v-else>{{ row.actCode || '-' }}</span> v-model="row.actCode"
size="small"
placeholder="请选择动作"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="d in actCodeOptions"
:key="d.dataDetailCode"
:label="d.dataDetailName"
:value="d.dataDetailCode"
/>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="条件" prop="condCode" width="100"> <el-table-column label="条件" prop="condCode" width="140" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="isEdit" v-model="row.condCode" size="small" /> <el-select
<span v-else>{{ row.condCode || '-' }}</span> v-model="row.condCode"
size="small"
placeholder="请选择条件"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="d in condCodeOptions"
:key="d.dataDetailCode"
:label="d.dataDetailName"
:value="d.dataDetailCode"
/>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="时间(s)" prop="setTime" width="90"> <el-table-column label="设定时间(s)" prop="setTime" width="100" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setTime" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.setTime" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setTime ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="温度(°C)" prop="setTemp" width="90"> <el-table-column label="设定温度(°C)" prop="setTemp" width="110" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setTemp" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.setTemp" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setTemp ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="能量(kw/h)" prop="setEnergy" width="100"> <el-table-column label="混炼时间" prop="mixingTime" width="90" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setEnergy" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.mixingTime" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setEnergy ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="功率(kw)" prop="setPower" width="90"> <el-table-column label="混炼温度" prop="mixingTemp" width="90" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setPower" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.mixingTemp" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setPower ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="压力" prop="setPres" width="80"> <el-table-column label="设定能量" prop="setEnergy" width="95" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setPres" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.setEnergy" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setPres ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="转速(rpm)" prop="setRota" width="100"> <el-table-column label="设定功率" prop="setPower" width="95" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number v-if="isEdit" v-model="row.setRota" :min="0" size="small" controls-position="right" style="width: 100%" /> <el-input-number v-model="row.setPower" :min="0" size="small" controls-position="right" style="width: 100%" />
<span v-else>{{ row.setRota ?? '-' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="isEdit" label="操作" width="120" fixed="right" align="center"> <el-table-column label="设定压力" prop="setPres" width="95" align="center">
<template #default="{ row }">
<el-input-number v-model="row.setPres" :min="0" size="small" controls-position="right" style="width: 100%" />
</template>
</el-table-column>
<el-table-column label="设定转速" prop="setRota" width="95" align="center">
<template #default="{ row }">
<el-input-number v-model="row.setRota" :min="0" size="small" controls-position="right" style="width: 100%" />
</template>
</el-table-column>
<el-table-column label="操作" width="80" fixed="right" align="center">
<template #default="{ $index }"> <template #default="{ $index }">
<el-button link type="primary" size="small" @click="insertMixingRow($index)"></el-button>
<el-button link type="danger" size="small" @click="removeMixingRow($index)"></el-button> <el-button link type="danger" size="small" @click="removeMixingRow($index)"></el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -192,6 +251,15 @@
</el-card> </el-card>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<!-- 选择物料对话框 -->
<el-dialog title="选择物料" v-model="materialSelectVisible" width="700px" append-to-body>
<MaterialSelect ref="materialSelectRef" v-if="materialSelectVisible" />
<template #footer>
<el-button type="primary" @click="confirmMaterialSelect"> </el-button>
<el-button @click="materialSelectVisible = false"> </el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
@ -200,19 +268,23 @@ import { getRecipeInfo, saveRecipeDetail } from '@/api/mes/recipeInfo';
import { listRecipeWeight } from '@/api/mes/recipeWeight'; import { listRecipeWeight } from '@/api/mes/recipeWeight';
import { listRecipeMixing } from '@/api/mes/recipeMixing'; import { listRecipeMixing } from '@/api/mes/recipeMixing';
import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo'; import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo';
import { getBaseMaterialInfoList } from '@/api/mes/baseMaterialInfo';
import type { RecipeInfoForm } from '@/api/mes/recipeInfo/types'; import type { RecipeInfoForm } from '@/api/mes/recipeInfo/types';
import type { RecipeWeightForm } from '@/api/mes/recipeWeight/types'; import type { RecipeWeightForm } from '@/api/mes/recipeWeight/types';
import type { RecipeMixingForm } from '@/api/mes/recipeMixing/types'; import type { RecipeMixingForm } from '@/api/mes/recipeMixing/types';
import type { ProdBaseMachineInfoVO } from '@/api/mes/prodBaseMachineInfo/types'; import type { ProdBaseMachineInfoVO } from '@/api/mes/prodBaseMachineInfo/types';
import type { BaseMaterialInfoVO } from '@/api/mes/baseMaterialInfo/types';
import { listMasterDataDetail } from '@/api/system/masterDataDetail';
import type { MasterDataDetailVO } from '@/api/system/masterDataDetail/types';
import MaterialSelect from './components/MaterialSelect.vue';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { recipe_state } = toRefs<any>(proxy?.useDict('recipe_state')); const { recipe_state, weight_type } = toRefs<any>(proxy?.useDict('recipe_state', 'weight_type'));
const recipeId = computed(() => route.query.recipeId as string || ''); const recipeId = computed(() => route.query.recipeId as string || '');
const activeTab = ref('basic'); const activeTab = ref('basic');
const isEdit = ref(false);
const saveLoading = ref(false); const saveLoading = ref(false);
const basicFormRef = ref<ElFormInstance>(); const basicFormRef = ref<ElFormInstance>();
@ -220,6 +292,24 @@ const recipeInfo = ref<RecipeInfoForm>({});
const weightList = ref<RecipeWeightForm[]>([]); const weightList = ref<RecipeWeightForm[]>([]);
const mixingList = ref<RecipeMixingForm[]>([]); const mixingList = ref<RecipeMixingForm[]>([]);
const machineOptions = ref<ProdBaseMachineInfoVO[]>([]); const machineOptions = ref<ProdBaseMachineInfoVO[]>([]);
const materialOptions = ref<BaseMaterialInfoVO[]>([]);
const materialSelectVisible = ref(false);
const materialSelectRef = ref<InstanceType<typeof MaterialSelect>>();
const selectedMaterial = ref<BaseMaterialInfoVO | null>(null);
const actCodeOptions = ref<MasterDataDetailVO[]>([]);
const condCodeOptions = ref<MasterDataDetailVO[]>([]);
const recipeMaterialDisplay = computed(() => {
const id = recipeInfo.value.materialId;
if (id == null || id === '') return '';
const fromOptions = materialOptions.value.find((m) => Number(m.materialId) === Number(id));
if (fromOptions) return `${fromOptions.materialName || ''} (${fromOptions.materialCode || ''})`.trim() || String(id);
if (selectedMaterial.value && Number(selectedMaterial.value.materialId) === Number(id)) {
const m = selectedMaterial.value;
return `${m.materialName || ''} (${m.materialCode || ''})`.trim() || String(id);
}
return String(id);
});
const weightTotalWeight = computed(() => const weightTotalWeight = computed(() =>
weightList.value.reduce((s, r) => s + (Number(r.setWeight) || 0), 0).toFixed(3) weightList.value.reduce((s, r) => s + (Number(r.setWeight) || 0), 0).toFixed(3)
@ -228,8 +318,23 @@ const weightTotalError = computed(() =>
weightList.value.reduce((s, r) => s + (Number(r.errorAllow) || 0), 0).toFixed(3) weightList.value.reduce((s, r) => s + (Number(r.errorAllow) || 0), 0).toFixed(3)
); );
function toggleEdit() { function goBack() {
isEdit.value = !isEdit.value; router.back();
}
function openMaterialSelect() {
materialSelectVisible.value = true;
}
function confirmMaterialSelect() {
const row = materialSelectRef.value?.getSelected();
if (!row) {
proxy?.$modal.msgWarning('请先选择一条物料');
return;
}
recipeInfo.value.materialId = row.materialId;
selectedMaterial.value = row;
materialSelectVisible.value = false;
} }
async function loadData() { async function loadData() {
@ -245,9 +350,20 @@ async function loadData() {
]); ]);
const infoData = (infoRes as any).data ?? infoRes; const infoData = (infoRes as any).data ?? infoRes;
recipeInfo.value = { ...infoData }; recipeInfo.value = { ...infoData };
weightList.value = (weightRes.rows || []).map((r: any) => ({ ...r })); const wData = (weightRes as any).data ?? weightRes;
const mixRows = mixingRes.rows || []; const wRows = wData?.rows ?? (Array.isArray(wData) ? wData : []);
mixingList.value = mixRows.map((r: any) => ({ ...r })); weightList.value = wRows.map((r: any) => ({
...r,
childCode: r.childCode != null && r.childCode !== '' ? Number(r.childCode) : undefined,
actCode: r.actCode != null && r.actCode !== '' ? String(r.actCode) : ''
}));
const mData = (mixingRes as any).data ?? mixingRes;
const mRows = mData?.rows ?? (Array.isArray(mData) ? mData : []);
mixingList.value = mRows.map((r: any) => ({
...r,
condCode: r.condCode != null && r.condCode !== '' ? String(r.condCode) : '',
actCode: r.actCode != null && r.actCode !== '' ? String(r.actCode) : ''
}));
} catch (e) { } catch (e) {
proxy?.$modal.msgError('加载失败'); proxy?.$modal.msgError('加载失败');
} }
@ -262,57 +378,73 @@ async function loadMachines() {
} }
} }
function addWeightRow(index: number) { async function loadMaterials() {
const base = weightList.value[index] || {}; try {
weightList.value.splice(index + 1, 0, { const res = await getBaseMaterialInfoList({ pageNum: 1, pageSize: 9999 });
recipeId: recipeId.value, const list = (res as any).data ?? (res as any).rows ?? [];
machineId: recipeInfo.value.machineId, materialOptions.value = Array.isArray(list) ? list : [];
edtCode: recipeInfo.value.edtCode, } catch {
weightSeq: (weightList.value.length + 1) as any, materialOptions.value = [];
weightType: base.weightType || '', }
scaleCode: base.scaleCode,
actCode: base.actCode || '称量',
setWeight: undefined,
errorAllow: undefined,
fatherCode: '',
unitId: undefined,
childCode: '',
ifUseBat: '',
maxRate: ''
} as RecipeWeightForm);
} }
function insertWeightRow(index: number) { /** 加载动作选项(称量/混炼动作masterDataId: 10009 */
const base = weightList.value[index] || {}; async function loadActCodeOptions() {
weightList.value.splice(index, 0, { try {
recipeId: recipeId.value, const res = await listMasterDataDetail({
machineId: recipeInfo.value.machineId, masterDataId: 10009,
edtCode: recipeInfo.value.edtCode, pageNum: 1,
weightSeq: (index + 1) as any, pageSize: 9999
weightType: base.weightType || '', });
scaleCode: base.scaleCode, const list = (res as any).rows ?? (res as any).data ?? [];
actCode: base.actCode || '称量', actCodeOptions.value = Array.isArray(list) ? list : [];
setWeight: undefined, } catch {
errorAllow: undefined, actCodeOptions.value = [];
fatherCode: '', }
unitId: undefined, }
childCode: '',
ifUseBat: '', /** 加载条件选项混炼条件masterDataId: 10010 */
maxRate: '' async function loadCondCodeOptions() {
} as RecipeWeightForm); try {
const res = await listMasterDataDetail({
masterDataId: 10010,
pageNum: 1,
pageSize: 9999
});
const list = (res as any).rows ?? (res as any).data ?? [];
condCodeOptions.value = Array.isArray(list) ? list : [];
} catch {
condCodeOptions.value = [];
}
}
function addWeightRowEnd() {
const idx = weightList.value.length - 1;
const base = weightList.value[idx] || {};
weightList.value.push({
recipeId: recipeId.value,
machineId: recipeInfo.value.machineId,
edtCode: recipeInfo.value.edtCode,
weightSeq: (weightList.value.length + 1) as any,
weightType: base.weightType || '',
actCode: base.actCode ?? '',
setWeight: undefined,
errorAllow: undefined,
childCode: undefined
} as RecipeWeightForm);
} }
function removeWeightRow(index: number) { function removeWeightRow(index: number) {
weightList.value.splice(index, 1); weightList.value.splice(index, 1);
} }
function insertMixingRow(index: number) { function addMixingRowEnd() {
const base = mixingList.value[index] || {}; const base = mixingList.value[mixingList.value.length - 1] || {};
mixingList.value.splice(index, 0, { mixingList.value.push({
recipeId: recipeId.value, recipeId: recipeId.value,
machineId: recipeInfo.value.machineId, machineId: recipeInfo.value.machineId,
edtCode: recipeInfo.value.edtCode, edtCode: recipeInfo.value.edtCode,
mixId: index + 1, mixId: mixingList.value.length + 1,
condCode: base.condCode || '', condCode: base.condCode || '',
actCode: base.actCode || '', actCode: base.actCode || '',
setTime: undefined, setTime: undefined,
@ -321,9 +453,15 @@ function insertMixingRow(index: number) {
setPower: undefined, setPower: undefined,
setPres: undefined, setPres: undefined,
setRota: undefined, setRota: undefined,
fatherCode: '', mixingTime: undefined,
childCode: '', mixingTemp: undefined,
termCode: '' mixingEnergy: undefined,
mixingPower: undefined,
mixingPress: undefined,
mixingSpeed: undefined,
fatherCode: base.fatherCode || '',
childCode: base.childCode || '',
termCode: base.termCode || ''
} as RecipeMixingForm); } as RecipeMixingForm);
} }
@ -331,10 +469,6 @@ function removeMixingRow(index: number) {
mixingList.value.splice(index, 1); mixingList.value.splice(index, 1);
} }
function calcWeight() {
proxy?.$modal.msg('计算重量功能可按业务规则扩展');
}
async function refreshWeight() { async function refreshWeight() {
await loadData(); await loadData();
activeTab.value = 'weight'; activeTab.value = 'weight';
@ -346,29 +480,37 @@ async function refreshMixing() {
} }
async function handleSave() { async function handleSave() {
if (!recipeId.value) return; if (!recipeId.value) {
proxy?.$modal.msgWarning('缺少配方ID');
return;
}
saveLoading.value = true; saveLoading.value = true;
try { try {
const payload = { const recipeIdVal = recipeId.value;
recipeInfo: { ...recipeInfo.value, recipeId: recipeId.value }, const recipe = { ...recipeInfo.value, recipeId: recipeIdVal };
weightList: weightList.value.map((w, i) => ({ const weights = weightList.value.map((w, i) => ({
...w, ...w,
recipeId: recipeId.value, recipeId: recipeIdVal,
machineId: recipeInfo.value.machineId ?? w.machineId, machineId: recipeInfo.value.machineId ?? w.machineId,
edtCode: recipeInfo.value.edtCode ?? w.edtCode, edtCode: recipeInfo.value.edtCode ?? w.edtCode,
weightSeq: (w.weightSeq ?? i + 1) as number weightSeq: (w.weightSeq ?? i + 1) as number,
})), actCode: w.actCode ?? ''
mixingList: mixingList.value.map((m, i) => ({ }));
...m, const mixings = mixingList.value.map((m, i) => ({
recipeId: recipeId.value, ...m,
machineId: recipeInfo.value.machineId ?? m.machineId, recipeId: recipeIdVal,
edtCode: recipeInfo.value.edtCode ?? m.edtCode, machineId: recipeInfo.value.machineId ?? m.machineId,
mixId: (m.mixId ?? i + 1) as number edtCode: recipeInfo.value.edtCode ?? m.edtCode,
})) mixId: (m.mixId ?? i + 1) as number,
}; actCode: m.actCode ?? '',
await saveRecipeDetail(payload); condCode: m.condCode ?? ''
}));
await saveRecipeDetail({
recipeInfo: recipe,
weightList: weights,
mixingList: mixings
});
proxy?.$modal.msgSuccess('保存成功'); proxy?.$modal.msgSuccess('保存成功');
isEdit.value = false;
await loadData(); await loadData();
} catch (e) { } catch (e) {
proxy?.$modal.msgError('保存失败'); proxy?.$modal.msgError('保存失败');
@ -377,9 +519,10 @@ async function handleSave() {
} }
} }
onMounted(() => { onMounted(async () => {
loadMachines(); await loadMaterials();
loadData(); await Promise.all([loadActCodeOptions(), loadCondCodeOptions()]);
await Promise.all([loadMachines(), loadData()]);
}); });
</script> </script>

Loading…
Cancel
Save