Commit 945455de by 齐伟伦

质检方案上增加个产品分类字段,来料质检单上的产品和该方案上的产品对比进行自动匹配。

parent bb29051d
...@@ -287,4 +287,3 @@ ...@@ -287,4 +287,3 @@
}); });
</script> </script>
\ No newline at end of file
...@@ -77,6 +77,53 @@ ...@@ -77,6 +77,53 @@
}, },
); );
watch(
() => formModel.value.cp,
async (newCpflId, oldCpflId) => {
if (newCpflId && newCpflId !== oldCpflId) {
await handleCpflChange(newCpflId);
}
},
);
// 产品名称变化:根据产品分类ID查询对应的质检方案
async function handleCpflChange(cpflId: string) {
try {
const response = await axios.get(
import.meta.env.VITE_GLOB_API_URL + '/magic-api/zlgl/zjjcsj/getZjfaByCpfl',
{
params: { id: cpflId },
},
);
const zjfaData = (response as any)?.data?.data;
console.log(zjfaData);
// return;
if (zjfaData) {
// 回填质检方案字段
formModel.value.zjfa = zjfaData[0].mc;
// 手动触发一次质检方案变化的处理,带出质检明细
// 由于watch是异步的,直接赋值会触发上面的zjfa监听
// 但为了确保立即执行,可以手动调用
await handleZjfaChange(zjfaData[0].id);
notification.success({ message: '已自动匹配质检方案' });
} else {
// 如果没有找到对应的质检方案,清空质检方案和相关明细
formModel.value.zjfa = '';
formModel.value.mesQualityInspectionDetailList = [];
notification.info({ message: '该产品分类未配置质检方案' });
}
} catch (error) {
formModel.value.zjfa = '';
formModel.value.mesQualityInspectionDetailList = [];
console.error('获取产品对应的质检方案失败:', error);
notification.error({ message: '获取质检方案失败' });
}
}
// 质检方案变化:根据方案id从接口获取明细,并整体替换当前明细列表 // 质检方案变化:根据方案id从接口获取明细,并整体替换当前明细列表
let zjfaReqSeq = 0; let zjfaReqSeq = 0;
async function handleZjfaChange(zjfaId: string) { async function handleZjfaChange(zjfaId: string) {
......
...@@ -415,6 +415,62 @@ export const formProps: FormProps = { ...@@ -415,6 +415,62 @@ export const formProps: FormProps = {
style: { width: '100%' }, style: { width: '100%' },
}, },
}, },
{
key: '2c05765e50b44fa8be4aec443066f781',
field: 'cpfl',
label: '产品分类',
type: 'cascader',
component: 'ApiCascader',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: 7,
placeholder: '请选择产品类别',
showFormat: 'all',
separator: '/',
selectedConfig: 'any',
disabled: false,
allowClear: false,
showLabel: true,
apiConfig: {
path: '/jcxx/cplx/getAllCPLXTree_zujian',
method: 'GET',
apiId: 'copy1770283483454d34933',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'code',
value: null,
description: null,
required: false,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: '',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql = ""\r\n + "select id,"\r\n + " pid as \'parentId\', "\r\n + " id as \'value\', "\r\n + " cm as \'label\' "\r\n + "from mes_base_cplx "\r\n + "where delete_mark = 0 "\r\n + "order by pid, id";\r\nvar list = db.select(sql);\r\n\r\nif (list == null || list.size() == 0) {\r\n return [];\r\n}\r\nvar map = new HashMap();\r\nvar idx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n itemNode.children = [];\r\n map.put(itemNode.id, itemNode);\r\n idx = idx + 1;\r\n}\r\nvar dataList = [];\r\nidx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n if (itemNode.parentId == null || itemNode.parentId == \'0\' || itemNode.parentId == \'\') {\r\n dataList.add(itemNode);\r\n } else {\r\n var pid = null;\r\n if (itemNode.parentId.contains(",")){\r\n var arr = itemNode.parentId.split(",");\r\n pid=arr[arr.length-1]\r\n }else{\r\n pid=itemNode.parentId;\r\n }\r\n var parentNode = map.get(pid);\r\n if (parentNode != null) {\r\n parentNode.children.add(itemNode);\r\n } else {\r\n dataList.add(itemNode);\r\n }\r\n }\r\n idx = idx + 1;\r\n}\r\nreturn dataList\r\n',
},
required: false,
rules: [],
events: {},
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
], ],
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment