|
|
|
|
@ -151,8 +151,8 @@
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button link type="primary" @click="handleDetail(scope.row)"
|
|
|
|
|
v-hasPermi="['mes:recipeInfo:query']">配方明细</el-button>
|
|
|
|
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
|
|
|
|
v-hasPermi="['mes:recipeInfo:edit']">修改</el-button>
|
|
|
|
|
<!-- <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
|
|
|
|
v-hasPermi="['mes:recipeInfo:edit']">修改</el-button> -->
|
|
|
|
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
|
|
|
|
v-hasPermi="['mes:recipeInfo:remove']">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
@ -292,7 +292,7 @@
|
|
|
|
|
|
|
|
|
|
<script setup name="RecipeInfo" lang="ts">
|
|
|
|
|
import type { ElTree } from 'element-plus';
|
|
|
|
|
import { listRecipeInfo, getRecipeInfo, delRecipeInfo, addRecipeInfo, updateRecipeInfo } from '@/api/mes/recipeInfo';
|
|
|
|
|
import { listRecipeInfo, getRecipeInfo, delRecipeInfo, addRecipeInfo, updateRecipeInfo, getRecipeTree } from '@/api/mes/recipeInfo';
|
|
|
|
|
import { RecipeInfoVO, RecipeInfoQuery, RecipeInfoForm } from '@/api/mes/recipeInfo/types';
|
|
|
|
|
import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo';
|
|
|
|
|
import { getBaseMaterialInfoList } from '@/api/mes/baseMaterialInfo';
|
|
|
|
|
@ -515,29 +515,15 @@ watch(treeFilterText, (val) => {
|
|
|
|
|
treeRef.value?.filter(val);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 从列表构建树:根为胶料名称,子节点为配方
|
|
|
|
|
function buildTreeFromList(list: RecipeInfoVO[]) {
|
|
|
|
|
const codeSet = new Set<string>();
|
|
|
|
|
const children: any[] = [];
|
|
|
|
|
list.forEach((row) => {
|
|
|
|
|
const code = row.recipeCode || String(row.materialId) || '未命名';
|
|
|
|
|
if (!codeSet.has(code)) {
|
|
|
|
|
codeSet.add(code);
|
|
|
|
|
children.push({
|
|
|
|
|
id: row.recipeId + '_' + code,
|
|
|
|
|
label: `${code}[${code}]`,
|
|
|
|
|
recipeCode: code,
|
|
|
|
|
recipeId: row.recipeId,
|
|
|
|
|
data: row
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const rootCode = queryParams.value.recipeCode || '配方列表';
|
|
|
|
|
return [{
|
|
|
|
|
id: 'root',
|
|
|
|
|
label: rootCode,
|
|
|
|
|
children: children.length ? children : [{ id: 'empty', label: '暂无数据', disabled: true }]
|
|
|
|
|
}];
|
|
|
|
|
/** 加载树数据(父级:配方代号,子级:称量物料名称) */
|
|
|
|
|
async function loadTreeData() {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getRecipeTree(queryParams.value as any);
|
|
|
|
|
const list = res.data || [];
|
|
|
|
|
treeData.value = list.length ? list : [{ id: 'empty', label: '暂无数据', disabled: true }];
|
|
|
|
|
} catch {
|
|
|
|
|
treeData.value = [{ id: 'empty', label: '暂无数据', disabled: true }];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
|
@ -547,7 +533,7 @@ const getList = async () => {
|
|
|
|
|
const res = await listRecipeInfo(queryParams.value);
|
|
|
|
|
recipeInfoList.value = res.rows || [];
|
|
|
|
|
total.value = res.total || 0;
|
|
|
|
|
treeData.value = buildTreeFromList(recipeInfoList.value);
|
|
|
|
|
await loadTreeData();
|
|
|
|
|
if (recipeInfoList.value.length && !currentTableRow.value) {
|
|
|
|
|
currentTableRow.value = recipeInfoList.value[0];
|
|
|
|
|
detailForm.value = { ...currentTableRow.value };
|
|
|
|
|
@ -557,14 +543,21 @@ const getList = async () => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 树节点点击 */
|
|
|
|
|
/** 树节点点击(父级配方代号 / 子级物料名称 均关联到对应配方) */
|
|
|
|
|
function handleTreeNodeClick(node: any) {
|
|
|
|
|
if (node.id === 'empty' || node.disabled) return;
|
|
|
|
|
selectedTreeNode.value = node;
|
|
|
|
|
selectedTreeLabel.value = node.label?.split('[')[0] || node.recipeCode || '';
|
|
|
|
|
selectedTreeLabel.value = node.label || node.recipeCode || '';
|
|
|
|
|
const recipeId = node.recipeId;
|
|
|
|
|
if (node.data) {
|
|
|
|
|
currentTableRow.value = node.data;
|
|
|
|
|
detailForm.value = { ...node.data };
|
|
|
|
|
} else if (recipeId && recipeInfoList.value.length) {
|
|
|
|
|
const row = recipeInfoList.value.find((r) => r.recipeId === recipeId);
|
|
|
|
|
if (row) {
|
|
|
|
|
currentTableRow.value = row;
|
|
|
|
|
detailForm.value = { ...row };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|