fix: dictType edit

pull/2/head
xingyu4j 2022-11-17 11:24:51 +08:00
parent d0167b3f48
commit d4d6f667aa
1 changed files with 14 additions and 2 deletions

View File

@ -119,7 +119,14 @@
:schema="DictTypeSchemas.allSchemas.formSchema"
:rules="DictTypeSchemas.dictTypeRules"
ref="typeFormRef"
/>
>
<template #type>
<template v-if="dictTypeValue">
<el-tag>{{ dictTypeValue }}</el-tag>
</template>
<template v-else><el-input v-model="dictTypeValue" /> </template>
</template>
</Form>
<Form
v-if="['dataCreate', 'dataUpdate'].includes(actionType)"
:schema="DictDataSchemas.allSchemas.formSchema"
@ -152,6 +159,7 @@ import { ref, unref, onMounted } from 'vue'
import { DICT_TYPE } from '@/utils/dict'
import { useI18n } from '@/hooks/web/useI18n'
import { FormExpose } from '@/components/Form'
import { ElInput, ElTag } from 'element-plus'
import * as DictTypeSchemas from './dict.type'
import * as DictDataSchemas from './dict.data'
import { useTable } from '@/hooks/web/useTable'
@ -174,15 +182,17 @@ const {
setSearchParams: setTypeSearchParams,
delList: delTypeList
} = typeMethods
const dictTypeValue = ref('')
//
const handleTypeCreate = () => {
dictTypeValue.value = ''
setDialogTile('typeCreate')
}
const handleTypeUpdate = async (row: DictTypeVO) => {
setDialogTile('typeUpdate')
//
const res = await DictTypeApi.getDictTypeApi(row.id)
dictTypeValue.value = res.type
unref(typeFormRef)?.setValues(res)
}
@ -229,6 +239,7 @@ const actionLoading = ref(false) // 遮罩层
const typeFormRef = ref<FormExpose>() // Ref
const dataFormRef = ref<FormExpose>() // Ref
const actionType = ref('') //
//
const setDialogTile = (type: string) => {
dialogTitle.value = t('action.' + type)
@ -246,6 +257,7 @@ const submitTypeForm = async () => {
try {
const data = unref(typeFormRef)?.formModel as DictTypeVO
if (actionType.value === 'typeCreate') {
data.type = dictTypeValue.value
await DictTypeApi.createDictTypeApi(data)
ElMessage.success(t('common.createSuccess'))
} else if (actionType.value === 'typeUpdate') {