@@ -69,6 +69,7 @@ import { getIntDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
69
69
import { ChatRoleApi , ChatRoleVO } from ' @/api/ai/model/chatRole'
70
70
import { CommonStatusEnum } from ' @/utils/constants'
71
71
import { ChatModelApi , ChatModelVO } from ' @/api/ai/model/chatModel'
72
+ import {FormRules } from " element-plus" ;
72
73
73
74
/** AI 聊天角色 表单 */
74
75
defineOptions ({ name: ' ChatRoleForm' })
@@ -92,7 +93,6 @@ const formData = ref({
92
93
publicStatus: true ,
93
94
status: CommonStatusEnum .ENABLE
94
95
})
95
- const formRules = ref () // reactive(formRulesObj)
96
96
const formRef = ref () // 表单 Ref
97
97
const chatModelList = ref ([] as ChatModelVO []) // 聊天模型列表
98
98
@@ -101,28 +101,22 @@ const isUser = computed(() => {
101
101
return formType .value === ' my-create' || formType .value === ' my-update'
102
102
})
103
103
104
- // TODO @fan:直接使用 formRules;只要隐藏掉的字段,它是不会校验的哈;
105
- const getFormRules = async (type : string ) => {
106
- let formRulesObj = {
107
- name: [{ required: true , message: ' 角色名称不能为空' , trigger: ' blur' }],
108
- avatar: [{ required: true , message: ' 角色头像不能为空' , trigger: ' blur' }],
109
- category: [{ required: true , message: ' 角色类别不能为空' , trigger: ' blur' }],
110
- sort: [{ required: true , message: ' 角色排序不能为空' , trigger: ' blur' }],
111
- description: [{ required: true , message: ' 角色描述不能为空' , trigger: ' blur' }],
112
- systemMessage: [{ required: true , message: ' 角色设定不能为空' , trigger: ' blur' }],
113
- publicStatus: [{ required: true , message: ' 是否公开不能为空' , trigger: ' blur' }]
114
- }
115
-
116
- formRules .value = reactive (formRulesObj )
117
- }
104
+ const formRules = reactive <FormRules >({
105
+ name: [{ required: true , message: ' 角色名称不能为空' , trigger: ' blur' }],
106
+ avatar: [{ required: true , message: ' 角色头像不能为空' , trigger: ' blur' }],
107
+ category: [{ required: true , message: ' 角色类别不能为空' , trigger: ' blur' }],
108
+ sort: [{ required: true , message: ' 角色排序不能为空' , trigger: ' blur' }],
109
+ description: [{ required: true , message: ' 角色描述不能为空' , trigger: ' blur' }],
110
+ systemMessage: [{ required: true , message: ' 角色设定不能为空' , trigger: ' blur' }],
111
+ publicStatus: [{ required: true , message: ' 是否公开不能为空' , trigger: ' blur' }]
112
+ })
118
113
119
114
/** 打开弹窗 */
120
115
// TODO @fan:title 是不是收敛到 type 判断生成 title,会更合理
121
116
const open = async (type : string , id ? : number , title ? : string ) => {
122
117
dialogVisible .value = true
123
118
dialogTitle .value = title || t (' action.' + type )
124
119
formType .value = type
125
- getFormRules (type )
126
120
resetForm ()
127
121
// 修改时,设置数据
128
122
if (id ) {
0 commit comments