Browse Source

动态修改规则重复问题解决

master_hella_20240701
ljlong_2630 8 months ago
parent
commit
4eaea07345
  1. 2
      src/components/Detail/src/DetailQmsCode.vue
  2. 16
      src/views/qms/basicDataManage/dynamicRule/index.vue

2
src/components/Detail/src/DetailQmsCode.vue

@ -701,7 +701,7 @@ const openForm = async (type: string, row?: number) => {
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
try { try {
// detailValidate // detailValidate
const rs = (await props.detailValidate) ? await props.detailValidate(data) : true const rs = (await props.detailValidate) ? await props.detailValidate(formType,data) : true
if (!rs) return if (!rs) return
if (formType === 'create') { if (formType === 'create') {
await props.apiCreate(data) await props.apiCreate(data)

16
src/views/qms/basicDataManage/dynamicRule/index.vue

@ -289,7 +289,8 @@ const handleDeleteTable = (item, index) => {
// //
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
if(!validateNotRepetition(tableData.value)){ const flag = validateNotRepetition(tableData.value);
if(!flag){
message.alertWarning('动态规则阶段不能重复') message.alertWarning('动态规则阶段不能重复')
basicFormRef.value.formLoading = false basicFormRef.value.formLoading = false
return return
@ -312,9 +313,9 @@ const submitForm = async (formType, data) => {
} }
} }
const detailValidate = (data) => { const detailValidate = (type,data) => {
let tag = true; let tag = true;
if(!validateIfRepeat(data)){ if(!validateIfRepeat(type,data)){
tag = false tag = false
message.alertWarning('动态规则阶段不能重复') message.alertWarning('动态规则阶段不能重复')
} }
@ -325,8 +326,13 @@ const detailOpenForm = (type, row, masterParmas) => {
} }
const validateIfRepeat = (data) => { const validateIfRepeat = (type,data) => {
const mergedArray = [data, ...detailList.value]; let mergedArray: any[] = [];
if(type == 'create'){
mergedArray = [data, ...detailList.value];
}else if(type == 'update'){
mergedArray = [...detailList.value];
}
const stageSet = new Set(mergedArray.map(item => item.stage)); const stageSet = new Set(mergedArray.map(item => item.stage));
return stageSet.size === mergedArray.length; return stageSet.size === mergedArray.length;
} }

Loading…
Cancel
Save