fix: 解决表单字段验证始终不通过问题

This commit is contained in:
JiangQiming 2023-01-17 11:47:46 +08:00
parent 9e3857302b
commit 5d5bdb4f52
3 changed files with 98 additions and 48 deletions

View File

@ -313,7 +313,6 @@ const formData = ref<ConfigFormData>({
configuration: {
appKey: '',
appSecret: '',
url: '',
},
description: '',
name: '',
@ -325,13 +324,20 @@ const formData = ref<ConfigFormData>({
watch(
() => formData.value.type,
(val) => {
formData.value.configuration = CONFIG_FIELD_MAP[val];
// formData.value.configuration = Object.values<any>(CONFIG_FIELD_MAP[val])[0];
msgType.value = MSG_TYPE[val];
formData.value.provider = msgType.value[0].value;
},
);
computed(() =>
Object.assign(
formData.value.configuration,
CONFIG_FIELD_MAP[formData.value.type][formData.value.provider],
),
);
//
const formRules = ref({
type: [{ required: true, message: '请选择通知方式' }],

View File

@ -3,8 +3,7 @@ export interface IHeaders {
key: string;
value: string;
}
export type ConfigFormData = {
configuration: {
export interface IConfiguration {
// 钉钉
appKey?: string;
appSecret?: string;
@ -30,7 +29,36 @@ export type ConfigFormData = {
// webhook
// url?: string;
headers?: IHeaders[];
};
}
export type ConfigFormData = {
configuration: IConfiguration;
// configuration: {
// // 钉钉
// appKey?: string;
// appSecret?: string;
// url?: string;
// // 微信
// corpId?: string;
// corpSecret?: string;
// // 邮件
// host?: string;
// port?: number;
// ssl?: boolean;
// sender?: string;
// username?: string;
// password?: string;
// // 语音
// regionId?: string;
// accessKeyId?: string;
// secret?: string;
// // 短信
// regionId?: string;
// accessKeyId?: string;
// secret?: string;
// // webhook
// // url?: string;
// headers?: IHeaders[];
// };
description: string;
name: string;
provider: string;

View File

@ -93,36 +93,52 @@ export const MSG_TYPE = {
// 配置
export const CONFIG_FIELD_MAP = {
dingTalk: {
appKey: undefined,
appSecret: undefined,
url: undefined,
dingTalkMessage: {
appKey: '',
appSecret: '',
},
dingTalkRobotWebHook: {
url: '',
}
},
weixin: {
corpId: undefined,
corpSecret: undefined,
corpMessage: {
corpId: '',
corpSecret: '',
},
// officialMessage: {},
},
email: {
host: undefined,
embedded: {
host: '',
port: 25,
ssl: false,
sender: undefined,
username: undefined,
password: undefined,
sender: '',
username: '',
password: '',
}
},
voice: {
regionId: undefined,
accessKeyId: undefined,
secret: undefined,
aliyun: {
regionId: '',
accessKeyId: '',
secret: '',
}
},
sms: {
regionId: undefined,
accessKeyId: undefined,
secret: undefined,
aliyunSms: {
regionId: '',
accessKeyId: '',
secret: '',
}
},
webhook: {
http: {
url: undefined,
headers: [],
}
},
};
// 模板