|
|
|
|
@ -736,9 +736,25 @@ const handleUpdate = async (row?: QcInspectionTemplateVO) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 新增检测项 */
|
|
|
|
|
const handleAddTemplateItem = () => {
|
|
|
|
|
const handleAddTemplateItem = async () => {
|
|
|
|
|
resetTemplateItem();
|
|
|
|
|
templateItemForm.value.templateId = selectedTemplateId.value;
|
|
|
|
|
|
|
|
|
|
// 确保 selectedTypeId 已设置
|
|
|
|
|
if (selectedTypeId.value === null && selectedTemplateId.value) {
|
|
|
|
|
const template = qcInspectionTemplateList.value.find(item => item.templateId === selectedTemplateId.value);
|
|
|
|
|
if (template) {
|
|
|
|
|
selectedTypeId.value = template.typeId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据检测类型加载对应的检测项列表
|
|
|
|
|
if (selectedTypeId.value) {
|
|
|
|
|
await getInspectionItemList(selectedTypeId.value);
|
|
|
|
|
} else {
|
|
|
|
|
await getInspectionItemList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templateItemDialog.visible = true;
|
|
|
|
|
templateItemDialog.title = "添加检测项";
|
|
|
|
|
}
|
|
|
|
|
@ -934,9 +950,10 @@ const getInspectionTypeList = async () => {
|
|
|
|
|
|
|
|
|
|
//获取检测项列表(不分页,获取全部)
|
|
|
|
|
let qcInspectionItemList = ref([]);
|
|
|
|
|
const getInspectionItemList = async () => {
|
|
|
|
|
const res = await getQcInspectionItemList(null);
|
|
|
|
|
qcInspectionItemList.value = res.data;
|
|
|
|
|
const getInspectionItemList = async (inspectionType?: string | number) => {
|
|
|
|
|
const params = inspectionType ? { inspectionType } : null;
|
|
|
|
|
const res = await getQcInspectionItemList(params);
|
|
|
|
|
qcInspectionItemList.value = res.data || [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -986,10 +1003,23 @@ const submitMaterialForm = () => {
|
|
|
|
|
materialOpen.value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 添加 computed
|
|
|
|
|
// 添加 computed - 当 selectedTypeId 为 null 时显示所有检测项
|
|
|
|
|
const filteredQcInspectionItemList = computed(() => {
|
|
|
|
|
if (selectedTypeId.value === null) return [];
|
|
|
|
|
return qcInspectionItemList.value.filter(item => item.inspectionType === Number(selectedTypeId.value));
|
|
|
|
|
// 如果没有设置类型筛选条件,返回所有检测项
|
|
|
|
|
if (selectedTypeId.value === null || selectedTypeId.value === undefined) {
|
|
|
|
|
return qcInspectionItemList.value;
|
|
|
|
|
}
|
|
|
|
|
// 严格匹配检测类型,处理字符串和数字类型的比较
|
|
|
|
|
return qcInspectionItemList.value.filter(item => {
|
|
|
|
|
const itemType = item.inspectionType;
|
|
|
|
|
const targetType = selectedTypeId.value;
|
|
|
|
|
// 字符串类型比较
|
|
|
|
|
if (typeof itemType === 'string') {
|
|
|
|
|
return itemType === String(targetType) || itemType === targetType;
|
|
|
|
|
}
|
|
|
|
|
// 数字类型比较
|
|
|
|
|
return itemType === Number(targetType);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|