Browse Source

解决选定集项重复问题

master_hella_20240701
ljlong_2630 8 months ago
parent
commit
b0c9cdeeda
  1. 6
      src/api/qms/selectedProject/index.ts
  2. 3
      src/views/qms/basicDataManage/counter/counter.data.ts
  3. 1
      src/views/qms/basicDataManage/dynamicRule/dynamicRule.data.ts
  4. 6
      src/views/qms/basicDataManage/selectedProject/index.vue
  5. 3
      src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts
  6. 58
      src/views/qms/basicDataManage/selectedSet/index.vue
  7. 3
      src/views/qms/basicDataManage/selectedSet/selectedSet.data.ts

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

@ -54,4 +54,10 @@ export const exportSelectedProject = async (params) => {
// 下载用户导入模板 // 下载用户导入模板
export const importTemplate = () => { export const importTemplate = () => {
return request.download({ url: '/qms/selected-project/get-import-template' }) return request.download({ url: '/qms/selected-project/get-import-template' })
}
// 查询选定集项目列表
export const getSelectedProjectNoPage = async (params) => {
return await request.get({ url: `/qms/selected-project/noPage`, params })
} }

3
src/views/qms/basicDataManage/counter/counter.data.ts

@ -18,7 +18,8 @@ export const Counter = useCrudSchemas(reactive<CrudSchema[]>([
label: '物料编码', label: '物料编码',
field: 'itemCode', field: 'itemCode',
sort: 'custom', sort: 'custom',
isSearch: true isSearch: true,
fixed: 'left'
}, },
{ {
label: '检验类型编码', label: '检验类型编码',

1
src/views/qms/basicDataManage/dynamicRule/dynamicRule.data.ts

@ -25,6 +25,7 @@ export const DynamicRule = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
isForm: false, isForm: false,
fixed: 'left'
}, },
{ {
label: '描述', label: '描述',

6
src/views/qms/basicDataManage/selectedProject/index.vue

@ -62,9 +62,9 @@ import download from '@/utils/download'
import { SelectedProject,SelectedProjectRules } from './selectedProject.data' import { SelectedProject,SelectedProjectRules } from './selectedProject.data'
import * as SelectedProjectApi from '@/api/qms/selectedProject' import * as SelectedProjectApi from '@/api/qms/selectedProject'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue' // import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' // import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue' // import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'SelectedProject' }) defineOptions({ name: 'SelectedProject' })

3
src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts

@ -27,7 +27,8 @@ export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([
field: 'code', field: 'code',
sort: 'custom', sort: 'custom',
isTableForm: false, isTableForm: false,
isSearch: true isSearch: true,
fixed: 'left'
}, },
{ {
label: '字典及字典项', label: '字典及字典项',

58
src/views/qms/basicDataManage/selectedSet/index.vue

@ -111,6 +111,8 @@ routeName.value = route.name
const tableColumns = ref(SelectedSet.allSchemas.tableColumns) const tableColumns = ref(SelectedSet.allSchemas.tableColumns)
// //
const searchTableSuccess = (formField, searchField, val, formRef) => { const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => { nextTick(() => {
@ -290,7 +292,11 @@ const handleDeleteTable = (item, index) => {
// //
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
if(!validateNotRepetition(tableData.value)){
message.alertWarning('选定集名称不能重复')
basicFormRef.value.formLoading = false
return
}
data.selectedProjectDOList = tableData.value// data.selectedProjectDOList = tableData.value//
data.selectedProjectDOList = data.selectedProjectDOList.map(item => { data.selectedProjectDOList = data.selectedProjectDOList.map(item => {
// '-%%%-'' dictionaryCode // '-%%%-'' dictionaryCode
@ -322,18 +328,56 @@ const submitForm = async (formType, data) => {
} }
} }
const updateSelections = async (masterId) => {
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 => {
// resdictionaryTypeAndCodeoption
return !res.some(resItem => option.value === resItem.dictionaryTypeAndCode);
});
return { ...element, options }; // elementoptions
}).filter(element => element.options.length > 0); // optionselement
// 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);
// Set dictionaryTypeAndCode
const uniqueCodes = new Set(codes);
// Set
if (codes.length > uniqueCodes.size) {
return false; // false
}
return true; // true
};
const detailValidate = (data) => { const detailValidate = (data) => {
let tag = true; let tag = true;
return tag return tag
} }
const detailOpenForm = (type, row, masterParmas) => { const detailOpenForm = (type, row, masterParmas) => {
// if(selectDictType.value){ updateSelections(masterParmas.masterId)
// }
if(type='create'){
}
} }

3
src/views/qms/basicDataManage/selectedSet/selectedSet.data.ts

@ -17,7 +17,8 @@ export const SelectedSet = useCrudSchemas(reactive<CrudSchema[]>([
field: 'code', field: 'code',
sort: 'custom', sort: 'custom',
isForm: false, isForm: false,
isSearch: true isSearch: true,
fixed: 'left'
}, },
{ {
label: '描述', label: '描述',

Loading…
Cancel
Save