【解决todo】role 角色表单,规则改为 formRules
parent
6550983413
commit
21ade9b9ac
|
@ -69,6 +69,7 @@ import { getIntDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import { ChatRoleApi, ChatRoleVO } from '@/api/ai/model/chatRole'
|
import { ChatRoleApi, ChatRoleVO } from '@/api/ai/model/chatRole'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
||||||
|
import {FormRules} from "element-plus";
|
||||||
|
|
||||||
/** AI 聊天角色 表单 */
|
/** AI 聊天角色 表单 */
|
||||||
defineOptions({ name: 'ChatRoleForm' })
|
defineOptions({ name: 'ChatRoleForm' })
|
||||||
|
@ -92,7 +93,6 @@ const formData = ref({
|
||||||
publicStatus: true,
|
publicStatus: true,
|
||||||
status: CommonStatusEnum.ENABLE
|
status: CommonStatusEnum.ENABLE
|
||||||
})
|
})
|
||||||
const formRules = ref() // reactive(formRulesObj)
|
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
const chatModelList = ref([] as ChatModelVO[]) // 聊天模型列表
|
const chatModelList = ref([] as ChatModelVO[]) // 聊天模型列表
|
||||||
|
|
||||||
|
@ -101,20 +101,15 @@ const isUser = computed(() => {
|
||||||
return formType.value === 'my-create' || formType.value === 'my-update'
|
return formType.value === 'my-create' || formType.value === 'my-update'
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO @fan:直接使用 formRules;只要隐藏掉的字段,它是不会校验的哈;
|
const formRules = reactive<FormRules>({
|
||||||
const getFormRules = async (type: string) => {
|
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
|
||||||
let formRulesObj = {
|
avatar: [{ required: true, message: '角色头像不能为空', trigger: 'blur' }],
|
||||||
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
|
category: [{ required: true, message: '角色类别不能为空', trigger: 'blur' }],
|
||||||
avatar: [{ required: true, message: '角色头像不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '角色排序不能为空', trigger: 'blur' }],
|
||||||
category: [{ required: true, message: '角色类别不能为空', trigger: 'blur' }],
|
description: [{ required: true, message: '角色描述不能为空', trigger: 'blur' }],
|
||||||
sort: [{ required: true, message: '角色排序不能为空', trigger: 'blur' }],
|
systemMessage: [{ required: true, message: '角色设定不能为空', trigger: 'blur' }],
|
||||||
description: [{ required: true, message: '角色描述不能为空', trigger: 'blur' }],
|
publicStatus: [{ required: true, message: '是否公开不能为空', trigger: 'blur' }]
|
||||||
systemMessage: [{ required: true, message: '角色设定不能为空', trigger: 'blur' }],
|
})
|
||||||
publicStatus: [{ required: true, message: '是否公开不能为空', trigger: 'blur' }]
|
|
||||||
}
|
|
||||||
|
|
||||||
formRules.value = reactive(formRulesObj)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
// TODO @fan:title 是不是收敛到 type 判断生成 title,会更合理
|
// TODO @fan:title 是不是收敛到 type 判断生成 title,会更合理
|
||||||
|
@ -122,7 +117,6 @@ const open = async (type: string, id?: number, title?: string) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = title || t('action.' + type)
|
dialogTitle.value = title || t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
getFormRules(type)
|
|
||||||
resetForm()
|
resetForm()
|
||||||
// 修改时,设置数据
|
// 修改时,设置数据
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
Loading…
Reference in New Issue