【解决todo】role 角色表单,规则改为 formRules

pull/477/MERGE
cherishsince 2024-07-10 09:12:11 +08:00
parent 6550983413
commit 21ade9b9ac
1 changed files with 10 additions and 16 deletions

View File

@ -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 @fantitle type title // TODO @fantitle 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) {