|
|
@ -338,19 +338,6 @@ const submitForm = async (formType, data) => { |
|
|
|
return |
|
|
|
} |
|
|
|
data.selectedProjectDOList = tableData.value// 拼接子表数据参数 |
|
|
|
data.selectedProjectDOList = data.selectedProjectDOList.map(item => { |
|
|
|
// 按照 '-%%%-'' 拆分 dictionaryCode |
|
|
|
const [dictionaryCode, dictionaryValue] = item.dictionaryTypeAndCode.split('-%%%-'); |
|
|
|
const dictionary = optionsList.value.find(temp => temp.options.some(option => option.value === item.dictionaryTypeAndCode)) |
|
|
|
const dictionaryLabel = dictionary?.options.find(option => option.value === item.dictionaryTypeAndCode)?.label |
|
|
|
// 返回一个新对象,包含拆分后的 dictionaryCode 和 dictionaryValue,以及原始项中的其他属性 |
|
|
|
return { |
|
|
|
...item, |
|
|
|
dictionaryCode, |
|
|
|
dictionaryValue, |
|
|
|
dictionaryLabel |
|
|
|
}; |
|
|
|
}); |
|
|
|
try { |
|
|
|
if (formType === 'create') { |
|
|
|
await SelectedSetApi.createSelectedSet(data) |
|
|
@ -373,43 +360,10 @@ const validateDetailEmpty = (data) => { |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
const updateSelections = async (masterId,row) => { |
|
|
|
let param = { masterId: masterId }; |
|
|
|
SelectedProjectApi.getSelectedProjectNoPage(param).then(res => { |
|
|
|
DictTypeApi.getDictTypeAndData('inspection').then(originalResponse => { |
|
|
|
// 首先对每个element进行映射和过滤 |
|
|
|
const response = originalResponse.map(element => { |
|
|
|
const options = element.dictDataRespVOList.map(item => { |
|
|
|
return { |
|
|
|
value: element.type + "-%%%-" + item.value, |
|
|
|
label: element.name + "-" + item.label |
|
|
|
}; |
|
|
|
}).filter(option => { |
|
|
|
// 过滤掉与res中任何dictionaryTypeAndCode相等的option |
|
|
|
return !res.some(resItem => { |
|
|
|
if(row != null){ |
|
|
|
return option.value === resItem.dictionaryTypeAndCode && option.value != row.dictionaryTypeAndCode |
|
|
|
}else{ |
|
|
|
return option.value === resItem.dictionaryTypeAndCode |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
return { ...element, options }; // 返回新的element,包含过滤后的options |
|
|
|
}).filter(element => element.options.length > 0); // 再次过滤,移除options为空的element |
|
|
|
|
|
|
|
// 更新对应字段的options |
|
|
|
const formSchemaItem = SelectedProject.allSchemas.formSchema.find(item => item.field === 'dictionaryTypeAndCode'); |
|
|
|
if (formSchemaItem) { |
|
|
|
formSchemaItem.componentProps.options = response; |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const validateNotRepetition = (data) => { |
|
|
|
// 提取所有的 dictionaryTypeAndCode 值 |
|
|
|
const codes = data.map(item => item.dictionaryTypeAndCode); |
|
|
|
const codes = data.map(item => item.dictionaryValue); |
|
|
|
|
|
|
|
// 创建一个 Set 来存储唯一的 dictionaryTypeAndCode 值 |
|
|
|
const uniqueCodes = new Set(codes); |
|
|
@ -430,9 +384,7 @@ const detailValidate = (data) => { |
|
|
|
|
|
|
|
const detailOpenForm = (type, row, masterParmas) => { |
|
|
|
if(type == 'create'){ |
|
|
|
updateSelections(masterParmas.masterId,row) |
|
|
|
}else if('update'){ |
|
|
|
updateSelections(masterParmas.masterId,row) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -440,42 +392,15 @@ const detailOpenForm = (type, row, masterParmas) => { |
|
|
|
|
|
|
|
|
|
|
|
const detailBasiFormOnChange = (field,val,detailFormRef) => { |
|
|
|
if(field == 'dictionaryTypeAndCode'){ |
|
|
|
// 按照 '-%%%-'' 拆分 dictionaryCode |
|
|
|
const [dictionaryCode, dictionaryValue] = val.split('-%%%-'); |
|
|
|
const dictionary = optionsList.value.find(temp => temp.options.some(option => option.value === val)) |
|
|
|
const dictionaryLabel = dictionary?.options.find(option => option.value === val)?.label |
|
|
|
const setV = {} |
|
|
|
setV['dictionaryLabel'] = dictionaryLabel |
|
|
|
setV['dictionaryCode'] = dictionaryCode |
|
|
|
setV['dictionaryValue'] = dictionaryValue |
|
|
|
nextTick(() => { |
|
|
|
detailFormRef.setValues(setV) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const formSelectChange = (a,b,c,d) => { |
|
|
|
} |
|
|
|
|
|
|
|
const getDicDetails = ()=>{ |
|
|
|
DictTypeApi.getDictTypeAndData('inspection').then(res=>{ |
|
|
|
res.forEach(element => { |
|
|
|
element.options = element.dictDataRespVOList.map(item => { |
|
|
|
return { |
|
|
|
value: element.type + "-%%%-" + item.value, |
|
|
|
label: element.name + "-" + item.label |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
optionsList.value = res |
|
|
|
}) |
|
|
|
const formSelectChange = (a,b,c,d) => { |
|
|
|
} |
|
|
|
|
|
|
|
/** 初始化 **/ |
|
|
|
onMounted(async () => { |
|
|
|
getList() |
|
|
|
getDicDetails() |
|
|
|
importTemplateData.templateUrl = await SelectedSetApi.importTemplate() |
|
|
|
}) |
|
|
|
|
|
|
|