diff --git a/src/views/qms/basicDataManage/selectedProject/index.vue b/src/views/qms/basicDataManage/selectedProject/index.vue index fa6f2f0be..9ab2bce19 100644 --- a/src/views/qms/basicDataManage/selectedProject/index.vue +++ b/src/views/qms/basicDataManage/selectedProject/index.vue @@ -99,9 +99,9 @@ const { getList, setSearchParams } = tableMethods // 列表头部按钮 const HeadButttondata = [ - defaultButtons.defaultAddBtn({hasPermi:'wms:selectedProject:create'}), // 新增 - defaultButtons.defaultImportBtn({hasPermi:'wms:selectedProject:import'}), // 导入 - defaultButtons.defaultExportBtn({hasPermi:'wms:selectedProject:export'}), // 导出 + defaultButtons.defaultAddBtn({hasPermi:'qms:selectedProject:create'}), // 新增 + defaultButtons.defaultImportBtn({hasPermi:'qms:selectedProject:import'}), // 导入 + defaultButtons.defaultExportBtn({hasPermi:'qms:selectedProject:export'}), // 导出 defaultButtons.defaultFreshBtn(null), // 刷新 defaultButtons.defaultFilterBtn(null), // 筛选 defaultButtons.defaultSetBtn(null), // 设置 @@ -133,8 +133,8 @@ const buttonBaseClick = (val, item) => { // 列表-操作按钮 const butttondata = [ - defaultButtons.mainListEditBtn({hasPermi:'wms:selectedProject:update'}), // 编辑 - defaultButtons.mainListDeleteBtn({hasPermi:'wms:selectedProject:delete'}), // 删除 + defaultButtons.mainListEditBtn({hasPermi:'qms:selectedProject:update'}), // 编辑 + defaultButtons.mainListDeleteBtn({hasPermi:'qms:selectedProject:delete'}), // 删除 ] // 列表-操作按钮事件 diff --git a/src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts b/src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts index ac8af2650..875da6e3d 100644 --- a/src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts +++ b/src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts @@ -2,20 +2,12 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as DictTypeApi from '@/api/system/dict/dict.type' -const optionsList = await DictTypeApi.getDictTypeAndData('inspection') -optionsList.forEach(element => { - element.options = element.dictDataRespVOList.map(item => { - return { - value: element.type + "-%%%-" + item.value, - label: element.name + "-" + item.label - } - }) -}) + // 表单校验 export const SelectedProjectRules = reactive({ code: [required], - dictionaryTypeAndCode: [required], + // dictionaryTypeAndCode: [required], estimateCode: [required], defectLevel: [required], }) @@ -36,59 +28,14 @@ export const SelectedProject = useCrudSchemas(reactive([ } }, { - label: '字典及字典项', - field: 'dictionaryTypeAndCode', + label: '选定集', + field: 'dictionaryValue', sort: 'custom', - formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => { - return optionsList.find(item => item.options.some(option => option.value === cellValue))?.options.find(option => option.value === cellValue)?.label - }, - isSearch: false, - isDetail: false, + isSearch: true, + isTableForm: true, + isDetail: true, isTable: true, isForm: true, - tableForm: { - type: 'SelectGroup', - initOptions: optionsList, - filterable: true, - }, - form: { - component: 'Select', - componentProps: { - options: optionsList, - filterable: true, - } - }, - - }, - { - label: '字典', - field: 'dictionaryCode', - sort: 'custom', - isSearch: false, - isTableForm: false, - isDetail: false, - isTable: false, - isForm: false, - }, - { - label: '字典项', - field: 'dictionaryValue', - sort: 'custom', - isSearch: false, - isTableForm: false, - isDetail: false, - isTable: false, - isForm: false, - }, - { - label: '字典名称', - field: 'dictionaryLabel', - sort: 'custom', - isSearch: false, - isTableForm: false, - isDetail: false, - isTable: false, - isForm: false, }, { label: '评估代码', @@ -104,20 +51,20 @@ export const SelectedProject = useCrudSchemas(reactive([ component: 'Select', } }, - { - label: '缺陷级别', - field: 'defectLevel', - sort: 'custom', - isSearch: true, - dictType: DICT_TYPE.DEFECT_LEVEL, - dictClass: 'string', - tableForm: { - type: 'Select', - }, - form: { - component: 'Select', - } - }, + // { + // label: '缺陷级别', + // field: 'defectLevel', + // sort: 'custom', + // isSearch: true, + // dictType: DICT_TYPE.DEFECT_LEVEL, + // dictClass: 'string', + // tableForm: { + // type: 'Select', + // }, + // form: { + // component: 'Select', + // } + // }, { label: '操作', field: 'action', diff --git a/src/views/qms/basicDataManage/selectedSet/index.vue b/src/views/qms/basicDataManage/selectedSet/index.vue index 32dbc8100..9047a67c1 100644 --- a/src/views/qms/basicDataManage/selectedSet/index.vue +++ b/src/views/qms/basicDataManage/selectedSet/index.vue @@ -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() })