Browse Source

处理动态规则阶段重复问题

master_hella_20240701
ljlong_2630 7 months ago
parent
commit
1929609fcd
  1. 6
      src/api/qms/inspectionStage/index.ts
  2. 35
      src/views/qms/basicDataManage/dynamicRule/index.vue
  3. 6
      src/views/qms/basicDataManage/inspectionStage/inspectionStage.data.ts

6
src/api/qms/inspectionStage/index.ts

@ -61,3 +61,9 @@ export const exportInspectionStage = async (params) => {
export const importTemplate = () => {
return request.download({ url: '/qms/inspection-stage/get-import-template' })
}
// 查询检验阶段列表
export const getInspectionStageNoPage = async (params) => {
return await request.get({ url: `/qms/inspection-stage/noPage`, params })
}

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

@ -105,6 +105,8 @@ const routeName = ref()
const tableData = ref([])
routeName.value = route.name
const tableColumns = ref(DynamicRule.allSchemas.tableColumns)
const detailMasterId = ref()
const detailList = ref([])
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
@ -210,6 +212,10 @@ const formsSuccess = async (formType,data) => {
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailMasterId.value = row.id
InspectionStageApi.getInspectionStageNoPage({masterId:row.id}).then(res=>{
detailList.value = res
})
detailRef.value.openDetail(row, titleName, titleValue, 'basicDynamicRule')
}
@ -283,6 +289,11 @@ const handleDeleteTable = (item, index) => {
//
const submitForm = async (formType, data) => {
if(!validateNotRepetition(tableData.value)){
message.alertWarning('动态规则阶段不能重复')
basicFormRef.value.formLoading = false
return
}
data.inspectionStageDOList = tableData.value//
console.log(data.subList)
try {
@ -303,15 +314,35 @@ const submitForm = async (formType, data) => {
const detailValidate = (data) => {
let tag = true;
if(!validateIfRepeat(data)){
tag = false
message.alertWarning('动态规则阶段不能重复')
}
return tag
}
const detailOpenForm = (type, row, masterParmas) => {
if(type='create'){
}
}
const validateIfRepeat = (data) => {
const mergedArray = [data, ...detailList.value];
const stageSet = new Set(mergedArray.map(item => item.stage));
return stageSet.size === mergedArray.length;
}
const validateNotRepetition = (data) => {
// dictionaryTypeAndCode
const codes = data.map(item => item.stage);
// Set dictionaryTypeAndCode
const uniqueCodes = new Set(codes);
// Set
if (codes.length > uniqueCodes.size) {
return false; // false
}
return true; // true
};
/** 初始化 **/
onMounted(async () => {
getList()

6
src/views/qms/basicDataManage/inspectionStage/inspectionStage.data.ts

@ -11,8 +11,10 @@ const trueFalse = [{
// 表单校验
export const InspectionStageRules = reactive({
description: [required],
dynamicModifyCode: [required],
description: [
required,
{ max: 1024, message: '不得超过1024个字符', trigger: 'blur' },
],
okTimes: [required],
okTimeStage: [required],
noOkTimes: [required],

Loading…
Cancel
Save