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) => {
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
const submitForm = async (formType, data) => {
debugger
try {
// detailValidate
const rs = (await props.detailValidate) ? await props.detailValidate(data) : true
@ -797,7 +798,7 @@ const openImage=(item)=>{
* @param 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" />
</el-select>
</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
v-if="headerItem?.tableForm?.type == 'FormTime'"

1
src/utils/dict.ts

@ -300,7 +300,6 @@ export enum DICT_TYPE {
DEFECT_LEVEL = "defect_level", // 缺陷级别
DICTIONARY_CLASS = "dictionary_class", // 字典分类
USAGE_DECISION = "usage_decision", // 使用决策
// ========== 业务 - mes -gaojs ==========
QUALIFY_STATUS = 'qualify_status',//质检状态
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 { dateFormatter } from '@/utils/formatTime'
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 {
label: item.name,
value: item.type
value: element.type + "-%%%-" + item.value,
label: element.name + "-" + item.label
}
})
})
// 表单校验
export const SelectedProjectRules = reactive({
code: [required],
dictionaryCode: [required],
dictionaryValue: [required],
available: [required],
concurrencyStamp: [required]
dictionaryTypeAndCode: [required],
estimateCode: [required],
defectLevel: [required],
})
export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([
@ -28,51 +30,64 @@ export const SelectedProject = useCrudSchemas(reactive<CrudSchema[]>([
isSearch: true
},
{
label: '字典',
field: 'dictionaryCode',
label: '字典及字典项',
field: 'dictionaryTypeAndCode',
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: {
type: 'Select',
initOptions: dictTypeListData,
type: 'SelectGroup',
initOptions: optionsList
},
form: {
component: 'Select',
api: dictTypeListData,
componentProps: {
options: dictTypeListData,
optionsAlias: {
labelField: 'label',
valueField: 'value'
}
}
options: optionsList
}
},
},
{
label: '字典项值',
label: '字典',
field: 'dictionaryCode',
sort: 'custom',
isSearch: false,
isTableForm: false,
isDetail: false,
isTable: false,
isForm: false,
},
{
label: '字典项',
field: 'dictionaryValue',
sort: 'custom',
isSearch: true,
tableForm: {
type: 'Select',
isSearch: false,
isTableForm: false,
isDetail: false,
isTable: false,
isForm: false,
},
form: {
component: 'Select',
componentProps: {
options: dictTypeListData,
optionsAlias: {
labelField: 'label',
valueField: 'value'
}
}
}
{
label: '字典名称',
field: 'dictionaryLabel',
sort: 'custom',
isSearch: false,
isTableForm: false,
isDetail: false,
isTable: false,
isForm: false,
},
{
label: '评估代码',
field: 'estimateCode',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.DICTIONARY_CLASS,
dictType: DICT_TYPE.EVALUATION_CODE,
dictClass: 'string',
tableForm: {
type: 'Select',

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

@ -50,7 +50,7 @@
:apiUpdate="SelectedSetApi.updateSelectedSet"
:apiCreate="SelectedSetApi.createSelectedSet"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
:isBusiness="true"
@onChange="onChange"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@ -92,6 +92,7 @@ import { SelectedProject,SelectedProjectRules } from '../selectedProject/selecte
import * as SelectedProjectApi from '@/api/qms/selectedProject'
import * as DictDataApi from '@/api/system/dict/dict.data'
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 ImportForm from '@/components/ImportForm/src/ImportForm.vue'
// import Detail from '@/components/Detail/src/Detail.vue'
@ -105,9 +106,11 @@ const route = useRoute() // 路由信息
const tableData = ref([])
const routeName = ref()
const selectDictType = ref()
const optionsList = ref()
routeName.value = route.name
const tableColumns = ref(SelectedSet.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
@ -287,7 +290,21 @@ const handleDeleteTable = (item, index) => {
//
const submitForm = async (formType, data) => {
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)
try {
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(val)
if(field == 'dictionaryCode'){
DictDataApi.queryByDictType(val).then(res => {
SelectedProject.allSchemas.formSchema.find(item => {
return item.field == 'dictionaryValue'
}).componentProps.options = res.map(item=>{
return {
value: item.value,
label: item.label
}
})
console.log(33,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)
})
}
}
@ -342,9 +360,24 @@ const formSelectChange = (a,b,c,d) => {
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 () => {
getList()
getDicDetails()
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',
isSearch: true
},
{
label: '分类',
field: 'classification',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.EVALUATION_CODE,
dictClass: 'string',
tableForm: {
type: 'Select',
}
},
{
label: '操作',
field: 'action',
@ -43,6 +32,8 @@ export const SelectedSet = useCrudSchemas(reactive<CrudSchema[]>([
table: {
width: 150,
fixed: 'right'
}
},
isTableForm: false,
isDetail: false
}
]))

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

@ -17,6 +17,19 @@
placeholder="请输入参数名称"
/>
</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-radio-group v-model="formData.status">
<el-radio
@ -39,7 +52,7 @@
</Dialog>
</template>
<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 { CommonStatusEnum } from '@/utils/constants'
@ -56,6 +69,7 @@ const formData = ref({
id: undefined,
name: '',
type: '',
classes: '',
status: CommonStatusEnum.ENABLE,
remark: ''
})
@ -72,6 +86,7 @@ const open = async (type: string, id?: number) => {
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
formData.value.classes = 'system'
//
if (id) {
formLoading.value = true
@ -116,6 +131,7 @@ const resetForm = () => {
id: undefined,
type: '',
name: '',
classes: '',
status: CommonStatusEnum.ENABLE,
remark: ''
}

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

@ -10,6 +10,12 @@
<el-input v-model="queryParams.type" class="!w-240px" clearable placeholder="请输入字典类型"
@keyup.enter="handleQuery" />
</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-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"
@ -48,6 +54,11 @@
<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="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">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />

Loading…
Cancel
Save