Browse Source

选择集代码

master_hella_20240701
ljlong_2630 8 months ago
parent
commit
d234c5fa1d
  1. 10
      src/api/system/dict/dict.type.ts
  2. 3
      src/components/Detail/src/DetailQmsCode.vue
  3. 33
      src/components/TableForm/src/TableForm.vue
  4. 1
      src/utils/dict.ts
  5. 85
      src/views/qms/basicDataManage/selectedProject/selectedProject.data.ts
  6. 59
      src/views/qms/basicDataManage/selectedSet/index.vue
  7. 15
      src/views/qms/basicDataManage/selectedSet/selectedSet.data.ts
  8. 18
      src/views/system/dict/DictTypeForm.vue
  9. 11
      src/views/system/dict/index.vue

10
src/api/system/dict/dict.type.ts

@ -42,3 +42,13 @@ export const deleteDictType = (id: number) => {
export const exportDictType = (params) => { export const exportDictType = (params) => {
return request.get({ url: '/system/dict-type/export', params }) return request.get({ url: '/system/dict-type/export', params })
} }
// 查询字典列表
export const getDictTypeAndData = (classes: string | null) => {
let url = '/system/dict-type/list-all-data-all';
if (classes !== null) {
url += `?classes=${classes}`;
}
return request.get({ url });
}

3
src/components/Detail/src/DetailQmsCode.vue

@ -699,6 +699,7 @@ const openForm = async (type: string, row?: number) => {
} }
// form // form
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
debugger
try { try {
// detailValidate // detailValidate
const rs = (await props.detailValidate) ? await props.detailValidate(data) : true const rs = (await props.detailValidate) ? await props.detailValidate(data) : true
@ -797,7 +798,7 @@ const openImage=(item)=>{
* @param cur 改变后值 * @param cur 改变后值
*/ */
const detailBasicFormOnChange = (field, cur) => { const detailBasicFormOnChange = (field, cur) => {
emit('detailBasicFormOnChange', field, cur) emit('detailBasicFormOnChange', field, cur,formRef.value.formRef)
} }
/** /**

33
src/components/TableForm/src/TableForm.vue

@ -126,6 +126,39 @@
:key="op.value" /> :key="op.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 下拉框 -->
<el-form-item
v-if="headerItem?.tableForm?.type == 'SelectGroup'"
:prop="headerItem.field">
<el-select
v-model="row[headerItem.field]"
:clearable="headerItem?.tableForm.clearable || true"
:multiple="headerItem?.tableForm.multiple"
:size="headerItem?.tableForm.size"
:collapse-tags ="headerItem?.tableForm.collapseTags"
:collapse-tags-tooltip ="headerItem?.tableForm.collapseTagsTooltip"
:multiple-limit ="headerItem?.tableForm.multipleLimit"
:disabled="itemIsDisabled(headerItem, row)"
:filterable="headerItem?.tableForm.filterable"
:allow-create="headerItem?.tableForm.allowCreate"
style="width: 100%"
:placeholder="headerItem?.tableForm?.placeholder || '请选择' + headerItem.label"
@change="formSelectChange(headerItem.field, $event,row)"
@blur="tableFormSelectOnBlur(headerItem.field, $event,row, $index)">
<el-option-group
v-for="group in initSelectOptions(headerItem)"
:key="group.type"
:label="group.name"
>
<el-option
v-for="item in group.options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-option-group>
</el-select>
</el-form-item>
<!-- 时间选择器 --> <!-- 时间选择器 -->
<el-form-item <el-form-item
v-if="headerItem?.tableForm?.type == 'FormTime'" v-if="headerItem?.tableForm?.type == 'FormTime'"

1
src/utils/dict.ts

@ -300,7 +300,6 @@ export enum DICT_TYPE {
DEFECT_LEVEL = "defect_level", // 缺陷级别 DEFECT_LEVEL = "defect_level", // 缺陷级别
DICTIONARY_CLASS = "dictionary_class", // 字典分类 DICTIONARY_CLASS = "dictionary_class", // 字典分类
USAGE_DECISION = "usage_decision", // 使用决策 USAGE_DECISION = "usage_decision", // 使用决策
// ========== 业务 - mes -gaojs ========== // ========== 业务 - mes -gaojs ==========
QUALIFY_STATUS = 'qualify_status',//质检状态 QUALIFY_STATUS = 'qualify_status',//质检状态
QUALIFY_ITEM_DATA_TYPE='qualify_item_data_type',//质检项目数据类型 QUALIFY_ITEM_DATA_TYPE='qualify_item_data_type',//质检项目数据类型

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

@ -1,21 +1,23 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as DictTypeApi from '@/api/system/dict/dict.type' import * as DictTypeApi from '@/api/system/dict/dict.type'
const dictTypeList = await DictTypeApi.getSimpleDictTypeList()
const dictTypeListData = dictTypeList.map(item => { const optionsList = await DictTypeApi.getDictTypeAndData('inspection')
optionsList.forEach(element => {
element.options = element.dictDataRespVOList.map(item => {
return { return {
label: item.name, value: element.type + "-%%%-" + item.value,
value: item.type label: element.name + "-" + item.label
} }
})
}) })
// 表单校验 // 表单校验
export const SelectedProjectRules = reactive({ export const SelectedProjectRules = reactive({
code: [required], code: [required],
dictionaryCode: [required], dictionaryTypeAndCode: [required],
dictionaryValue: [required], estimateCode: [required],
available: [required], defectLevel: [required],
concurrencyStamp: [required]
}) })
export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([ export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([
@ -28,51 +30,64 @@ export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([
isSearch: true isSearch: true
}, },
{ {
label: '字典', label: '字典及字典项',
field: 'dictionaryCode', field: 'dictionaryTypeAndCode',
sort: 'custom', sort: 'custom',
isSearch: true, 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,
isTable: true,
isForm: true,
tableForm: { tableForm: {
type: 'Select', type: 'SelectGroup',
initOptions: dictTypeListData, initOptions: optionsList
}, },
form: { form: {
component: 'Select', component: 'Select',
api: dictTypeListData,
componentProps: { componentProps: {
options: dictTypeListData, options: optionsList
optionsAlias: {
labelField: 'label',
valueField: 'value'
}
}
} }
}, },
},
{
label: '字典',
field: 'dictionaryCode',
sort: 'custom',
isSearch: false,
isTableForm: false,
isDetail: false,
isTable: false,
isForm: false,
},
{ {
label: '字典项值', label: '字典项',
field: 'dictionaryValue', field: 'dictionaryValue',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: false,
tableForm: { isTableForm: false,
type: 'Select', isDetail: false,
isTable: false,
isForm: false,
}, },
form: { {
component: 'Select', label: '字典名称',
componentProps: { field: 'dictionaryLabel',
options: dictTypeListData, sort: 'custom',
optionsAlias: { isSearch: false,
labelField: 'label', isTableForm: false,
valueField: 'value' isDetail: false,
} isTable: false,
} isForm: false,
}
}, },
{ {
label: '评估代码', label: '评估代码',
field: 'estimateCode', field: 'estimateCode',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
dictType: DICT_TYPE.DICTIONARY_CLASS, dictType: DICT_TYPE.EVALUATION_CODE,
dictClass: 'string', dictClass: 'string',
tableForm: { tableForm: {
type: 'Select', type: 'Select',

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

@ -50,7 +50,7 @@
:apiUpdate="SelectedSetApi.updateSelectedSet" :apiUpdate="SelectedSetApi.updateSelectedSet"
:apiCreate="SelectedSetApi.createSelectedSet" :apiCreate="SelectedSetApi.createSelectedSet"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :isBusiness="true"
@onChange="onChange" @onChange="onChange"
@handleAddTable="handleAddTable" @handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable" @handleDeleteTable="handleDeleteTable"
@ -92,6 +92,7 @@ import { SelectedProject,SelectedProjectRules } from '../selectedProject/selecte
import * as SelectedProjectApi from '@/api/qms/selectedProject' import * as SelectedProjectApi from '@/api/qms/selectedProject'
import * as DictDataApi from '@/api/system/dict/dict.data' import * as DictDataApi from '@/api/system/dict/dict.data'
import component from 'virtual:svg-icons-register' import component from 'virtual:svg-icons-register'
import * as DictTypeApi from '@/api/system/dict/dict.type'
// 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'
@ -105,9 +106,11 @@ const route = useRoute() // 路由信息
const tableData = ref([]) const tableData = ref([])
const routeName = ref() const routeName = ref()
const selectDictType = ref() const selectDictType = ref()
const optionsList = ref()
routeName.value = route.name 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(() => {
@ -287,7 +290,21 @@ const handleDeleteTable = (item, index) => {
// //
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
data.selectedProjectDOList = tableData.value// 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
};
});
console.log(data.subList) console.log(data.subList)
try { try {
if (formType === 'create') { if (formType === 'create') {
@ -321,19 +338,20 @@ const detailOpenForm = (type, row, masterParmas) => {
const detailBasiFormOnChange = (field,val) => { const detailBasiFormOnChange = (field,val,detailFormRef) => {
console.log(field) console.log(field)
console.log(val) console.log(33,detailFormRef)
if(field == 'dictionaryCode'){ if(field == 'dictionaryTypeAndCode'){
DictDataApi.queryByDictType(val).then(res => { // '-%%%-'' dictionaryCode
SelectedProject.allSchemas.formSchema.find(item => { const [dictionaryCode, dictionaryValue] = val.split('-%%%-');
return item.field == 'dictionaryValue' const dictionary = optionsList.value.find(temp => temp.options.some(option => option.value === val))
}).componentProps.options = res.map(item=>{ const dictionaryLabel = dictionary?.options.find(option => option.value === val)?.label
return { const setV = {}
value: item.value, setV['dictionaryLabel'] = dictionaryLabel
label: item.label setV['dictionaryCode'] = dictionaryCode
} setV['dictionaryValue'] = dictionaryValue
}) nextTick(() => {
detailFormRef.setValues(setV)
}) })
} }
} }
@ -342,9 +360,24 @@ const formSelectChange = (a,b,c,d) => {
console.log(111) console.log(111)
} }
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
})
}
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList() getList()
getDicDetails()
importTemplateData.templateUrl = await SelectedSetApi.importTemplate() importTemplateData.templateUrl = await SelectedSetApi.importTemplate()
}) })

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

@ -25,17 +25,6 @@ export const SelectedSet = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
isSearch: true isSearch: true
}, },
{
label: '分类',
field: 'classification',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.EVALUATION_CODE,
dictClass: 'string',
tableForm: {
type: 'Select',
}
},
{ {
label: '操作', label: '操作',
field: 'action', field: 'action',
@ -43,6 +32,8 @@ export const SelectedSet = useCrudSchemas(reactive<CrudSchema[]>([
table: { table: {
width: 150, width: 150,
fixed: 'right' fixed: 'right'
} },
isTableForm: false,
isDetail: false
} }
])) ]))

18
src/views/system/dict/DictTypeForm.vue

@ -17,6 +17,19 @@
placeholder="请输入参数名称" placeholder="请输入参数名称"
/> />
</el-form-item> </el-form-item>
<el-form-item label="字典分类" prop="classes">
<el-select
v-model="formData.classes"
placeholder="请选择字典分类"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.DICTIONARY_CLASS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio <el-radio
@ -39,7 +52,7 @@
</Dialog> </Dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import * as DictTypeApi from '@/api/system/dict/dict.type' import * as DictTypeApi from '@/api/system/dict/dict.type'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
@ -56,6 +69,7 @@ const formData = ref({
id: undefined, id: undefined,
name: '', name: '',
type: '', type: '',
classes: '',
status: CommonStatusEnum.ENABLE, status: CommonStatusEnum.ENABLE,
remark: '' remark: ''
}) })
@ -72,6 +86,7 @@ const open = async (type: string, id?: number) => {
dialogTitle.value = t('action.' + type) dialogTitle.value = t('action.' + type)
formType.value = type formType.value = type
resetForm() resetForm()
formData.value.classes = 'system'
// //
if (id) { if (id) {
formLoading.value = true formLoading.value = true
@ -116,6 +131,7 @@ const resetForm = () => {
id: undefined, id: undefined,
type: '', type: '',
name: '', name: '',
classes: '',
status: CommonStatusEnum.ENABLE, status: CommonStatusEnum.ENABLE,
remark: '' remark: ''
} }

11
src/views/system/dict/index.vue

@ -10,6 +10,12 @@
<el-input v-model="queryParams.type" class="!w-240px" clearable placeholder="请输入字典类型" <el-input v-model="queryParams.type" class="!w-240px" clearable placeholder="请输入字典类型"
@keyup.enter="handleQuery" /> @keyup.enter="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="字典分类" prop="classes">
<el-select v-model="queryParams.classes" class="!w-240px" clearable placeholder="请选择字典分类">
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.DICTIONARY_CLASS)" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择字典状态"> <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择字典状态">
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" :key="dict.value" :label="dict.label" <el-option v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" :key="dict.value" :label="dict.label"
@ -48,6 +54,11 @@
<el-table-column align="center" label="字典编号" prop="id" /> <el-table-column align="center" label="字典编号" prop="id" />
<el-table-column align="center" label="字典名称" prop="name" show-overflow-tooltip /> <el-table-column align="center" label="字典名称" prop="name" show-overflow-tooltip />
<el-table-column align="center" label="字典类型" prop="type" width="300" /> <el-table-column align="center" label="字典类型" prop="type" width="300" />
<el-table-column align="center" label="字典分类" prop="classes" width="300" >
<template #default="scope">
<dict-tag :type="DICT_TYPE.DICTIONARY_CLASS" :value="scope.row.classes" />
</template>
</el-table-column>
<el-table-column align="center" label="状态" prop="status"> <el-table-column align="center" label="状态" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />

Loading…
Cancel
Save