diff --git a/src/api/mes/recipeWeight/types.ts b/src/api/mes/recipeWeight/types.ts
index 9d6fc4d..06a81e8 100644
--- a/src/api/mes/recipeWeight/types.ts
+++ b/src/api/mes/recipeWeight/types.ts
@@ -60,9 +60,9 @@ export interface RecipeWeightVO {
unitId: string | number;
/**
- * 子级编码
+ * 子级编码(物料ID)
*/
- childCode: string;
+ childCode: number;
/**
* 是否使用批次
@@ -138,9 +138,9 @@ export interface RecipeWeightForm extends BaseEntity {
unitId?: string | number;
/**
- * 子级编码
+ * 子级编码(物料ID)
*/
- childCode?: string;
+ childCode?: number;
/**
* 是否使用批次
@@ -217,9 +217,9 @@ export interface RecipeWeightQuery extends PageQuery {
unitId?: string | number;
/**
- * 子级编码
+ * 子级编码(物料ID)
*/
- childCode?: string;
+ childCode?: number;
/**
* 是否使用批次
diff --git a/src/views/mes/recipeInfo/detail.vue b/src/views/mes/recipeInfo/detail.vue
index c36569c..7992389 100644
--- a/src/views/mes/recipeInfo/detail.vue
+++ b/src/views/mes/recipeInfo/detail.vue
@@ -3,12 +3,8 @@
@@ -16,7 +12,7 @@
配方基本信息
-
+
@@ -36,8 +32,18 @@
-
-
+
+
+
+ 选择
+
+
@@ -74,47 +80,70 @@
- 计算重量
+ 添加
刷新称量信息
称量明细
-
+
-
- {{ row.childCode || '-' }}
+
+
+
-
+
-
- {{ row.fatherCode || '-' }}
+
+
+
-
+
-
- {{ row.actCode || '-' }}
+
+
+
-
+
-
- {{ row.setWeight ?? '-' }}
+
-
+
-
- {{ row.errorAllow ?? '-' }}
+
-
+
- 添加
- 插入
删除
@@ -127,63 +156,93 @@
- 调用混炼信息
+ 添加
刷新混炼信息
+ 混炼信息
-
+
-
- {{ row.actCode || '-' }}
+
+
+
-
+
-
- {{ row.condCode || '-' }}
+
+
+
-
+
-
- {{ row.setTime ?? '-' }}
+
-
+
-
- {{ row.setTemp ?? '-' }}
+
-
+
-
- {{ row.setEnergy ?? '-' }}
+
-
+
-
- {{ row.setPower ?? '-' }}
+
-
+
-
- {{ row.setPres ?? '-' }}
+
-
+
-
- {{ row.setRota ?? '-' }}
+
-
+
+
+
+
+
+
+
+
+
+
+
- 插入
删除
@@ -192,6 +251,15 @@
+
+
+
+
+
+ 确 定
+ 取 消
+
+
@@ -200,19 +268,23 @@ import { getRecipeInfo, saveRecipeDetail } from '@/api/mes/recipeInfo';
import { listRecipeWeight } from '@/api/mes/recipeWeight';
import { listRecipeMixing } from '@/api/mes/recipeMixing';
import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo';
+import { getBaseMaterialInfoList } from '@/api/mes/baseMaterialInfo';
import type { RecipeInfoForm } from '@/api/mes/recipeInfo/types';
import type { RecipeWeightForm } from '@/api/mes/recipeWeight/types';
import type { RecipeMixingForm } from '@/api/mes/recipeMixing/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 router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-const { recipe_state } = toRefs(proxy?.useDict('recipe_state'));
+const { recipe_state, weight_type } = toRefs(proxy?.useDict('recipe_state', 'weight_type'));
const recipeId = computed(() => route.query.recipeId as string || '');
const activeTab = ref('basic');
-const isEdit = ref(false);
const saveLoading = ref(false);
const basicFormRef = ref();
@@ -220,6 +292,24 @@ const recipeInfo = ref({});
const weightList = ref([]);
const mixingList = ref([]);
const machineOptions = ref([]);
+const materialOptions = ref([]);
+const materialSelectVisible = ref(false);
+const materialSelectRef = ref>();
+const selectedMaterial = ref(null);
+const actCodeOptions = ref([]);
+const condCodeOptions = ref([]);
+
+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(() =>
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)
);
-function toggleEdit() {
- isEdit.value = !isEdit.value;
+function goBack() {
+ 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() {
@@ -245,9 +350,20 @@ async function loadData() {
]);
const infoData = (infoRes as any).data ?? infoRes;
recipeInfo.value = { ...infoData };
- weightList.value = (weightRes.rows || []).map((r: any) => ({ ...r }));
- const mixRows = mixingRes.rows || [];
- mixingList.value = mixRows.map((r: any) => ({ ...r }));
+ const wData = (weightRes as any).data ?? weightRes;
+ const wRows = wData?.rows ?? (Array.isArray(wData) ? wData : []);
+ 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) {
proxy?.$modal.msgError('加载失败');
}
@@ -262,57 +378,73 @@ async function loadMachines() {
}
}
-function addWeightRow(index: number) {
- const base = weightList.value[index] || {};
- weightList.value.splice(index + 1, 0, {
- recipeId: recipeId.value,
- machineId: recipeInfo.value.machineId,
- edtCode: recipeInfo.value.edtCode,
- weightSeq: (weightList.value.length + 1) as any,
- weightType: base.weightType || '',
- scaleCode: base.scaleCode,
- actCode: base.actCode || '称量',
- setWeight: undefined,
- errorAllow: undefined,
- fatherCode: '',
- unitId: undefined,
- childCode: '',
- ifUseBat: '',
- maxRate: ''
- } as RecipeWeightForm);
+async function loadMaterials() {
+ try {
+ const res = await getBaseMaterialInfoList({ pageNum: 1, pageSize: 9999 });
+ const list = (res as any).data ?? (res as any).rows ?? [];
+ materialOptions.value = Array.isArray(list) ? list : [];
+ } catch {
+ materialOptions.value = [];
+ }
}
-function insertWeightRow(index: number) {
- const base = weightList.value[index] || {};
- weightList.value.splice(index, 0, {
- recipeId: recipeId.value,
- machineId: recipeInfo.value.machineId,
- edtCode: recipeInfo.value.edtCode,
- weightSeq: (index + 1) as any,
- weightType: base.weightType || '',
- scaleCode: base.scaleCode,
- actCode: base.actCode || '称量',
- setWeight: undefined,
- errorAllow: undefined,
- fatherCode: '',
- unitId: undefined,
- childCode: '',
- ifUseBat: '',
- maxRate: ''
- } as RecipeWeightForm);
+/** 加载动作选项(称量/混炼动作,masterDataId: 10009) */
+async function loadActCodeOptions() {
+ try {
+ const res = await listMasterDataDetail({
+ masterDataId: 10009,
+ pageNum: 1,
+ pageSize: 9999
+ });
+ const list = (res as any).rows ?? (res as any).data ?? [];
+ actCodeOptions.value = Array.isArray(list) ? list : [];
+ } catch {
+ actCodeOptions.value = [];
+ }
+}
+
+/** 加载条件选项(混炼条件,masterDataId: 10010) */
+async function loadCondCodeOptions() {
+ 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) {
weightList.value.splice(index, 1);
}
-function insertMixingRow(index: number) {
- const base = mixingList.value[index] || {};
- mixingList.value.splice(index, 0, {
+function addMixingRowEnd() {
+ const base = mixingList.value[mixingList.value.length - 1] || {};
+ mixingList.value.push({
recipeId: recipeId.value,
machineId: recipeInfo.value.machineId,
edtCode: recipeInfo.value.edtCode,
- mixId: index + 1,
+ mixId: mixingList.value.length + 1,
condCode: base.condCode || '',
actCode: base.actCode || '',
setTime: undefined,
@@ -321,9 +453,15 @@ function insertMixingRow(index: number) {
setPower: undefined,
setPres: undefined,
setRota: undefined,
- fatherCode: '',
- childCode: '',
- termCode: ''
+ mixingTime: undefined,
+ mixingTemp: undefined,
+ mixingEnergy: undefined,
+ mixingPower: undefined,
+ mixingPress: undefined,
+ mixingSpeed: undefined,
+ fatherCode: base.fatherCode || '',
+ childCode: base.childCode || '',
+ termCode: base.termCode || ''
} as RecipeMixingForm);
}
@@ -331,10 +469,6 @@ function removeMixingRow(index: number) {
mixingList.value.splice(index, 1);
}
-function calcWeight() {
- proxy?.$modal.msg('计算重量功能可按业务规则扩展');
-}
-
async function refreshWeight() {
await loadData();
activeTab.value = 'weight';
@@ -346,29 +480,37 @@ async function refreshMixing() {
}
async function handleSave() {
- if (!recipeId.value) return;
+ if (!recipeId.value) {
+ proxy?.$modal.msgWarning('缺少配方ID');
+ return;
+ }
saveLoading.value = true;
try {
- const payload = {
- recipeInfo: { ...recipeInfo.value, recipeId: recipeId.value },
- weightList: weightList.value.map((w, i) => ({
- ...w,
- recipeId: recipeId.value,
- machineId: recipeInfo.value.machineId ?? w.machineId,
- edtCode: recipeInfo.value.edtCode ?? w.edtCode,
- weightSeq: (w.weightSeq ?? i + 1) as number
- })),
- mixingList: mixingList.value.map((m, i) => ({
- ...m,
- recipeId: recipeId.value,
- machineId: recipeInfo.value.machineId ?? m.machineId,
- edtCode: recipeInfo.value.edtCode ?? m.edtCode,
- mixId: (m.mixId ?? i + 1) as number
- }))
- };
- await saveRecipeDetail(payload);
+ const recipeIdVal = recipeId.value;
+ const recipe = { ...recipeInfo.value, recipeId: recipeIdVal };
+ const weights = weightList.value.map((w, i) => ({
+ ...w,
+ recipeId: recipeIdVal,
+ machineId: recipeInfo.value.machineId ?? w.machineId,
+ edtCode: recipeInfo.value.edtCode ?? w.edtCode,
+ weightSeq: (w.weightSeq ?? i + 1) as number,
+ actCode: w.actCode ?? ''
+ }));
+ const mixings = mixingList.value.map((m, i) => ({
+ ...m,
+ recipeId: recipeIdVal,
+ machineId: recipeInfo.value.machineId ?? m.machineId,
+ edtCode: recipeInfo.value.edtCode ?? m.edtCode,
+ mixId: (m.mixId ?? i + 1) as number,
+ actCode: m.actCode ?? '',
+ condCode: m.condCode ?? ''
+ }));
+ await saveRecipeDetail({
+ recipeInfo: recipe,
+ weightList: weights,
+ mixingList: mixings
+ });
proxy?.$modal.msgSuccess('保存成功');
- isEdit.value = false;
await loadData();
} catch (e) {
proxy?.$modal.msgError('保存失败');
@@ -377,9 +519,10 @@ async function handleSave() {
}
}
-onMounted(() => {
- loadMachines();
- loadData();
+onMounted(async () => {
+ await loadMaterials();
+ await Promise.all([loadActCodeOptions(), loadCondCodeOptions()]);
+ await Promise.all([loadMachines(), loadData()]);
});