chore: 更改校验
This commit is contained in:
parent
8b48fb304e
commit
29d24b49e3
@ -49,12 +49,10 @@ export const drawerSchema: FormSchemaGetter = () => [
|
|||||||
addonBefore: () => (formModel.isHttps === 'Y' ? 'https://' : 'http://'),
|
addonBefore: () => (formModel.isHttps === 'Y' ? 'https://' : 'http://'),
|
||||||
}),
|
}),
|
||||||
rules: z
|
rules: z
|
||||||
.string({ message: '请输入服务地址' })
|
.string()
|
||||||
.refine(
|
.refine((domain) => domain && !/^https?:\/\/.*/.test(domain), {
|
||||||
(domain) =>
|
message: '请输入正确的域名, 不需要http(s)',
|
||||||
!(domain.startsWith('http://') || domain.startsWith('https://')),
|
}),
|
||||||
{ message: '请输入正确的域名, 不需要http(s)' },
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
@ -63,14 +61,6 @@ export const drawerSchema: FormSchemaGetter = () => [
|
|||||||
},
|
},
|
||||||
fieldName: 'domain',
|
fieldName: 'domain',
|
||||||
label: '自定义域名',
|
label: '自定义域名',
|
||||||
rules: z
|
|
||||||
.string()
|
|
||||||
.refine(
|
|
||||||
(domain) =>
|
|
||||||
!(domain.startsWith('http://') || domain.startsWith('https://')),
|
|
||||||
{ message: '请输入正确的域名, 不需要http(s)' },
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Divider',
|
component: 'Divider',
|
||||||
|
@ -53,12 +53,15 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|||||||
async function handleConfirm() {
|
async function handleConfirm() {
|
||||||
try {
|
try {
|
||||||
drawerApi.drawerLoading(true);
|
drawerApi.drawerLoading(true);
|
||||||
|
/**
|
||||||
|
* 这里解构出来的values只能获取到自定义校验参数的值
|
||||||
|
* 需要自行调用formApi.getValues()获取表单值
|
||||||
|
*/
|
||||||
const { valid } = await formApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await formApi.getValues();
|
const data = await formApi.getValues();
|
||||||
console.log(data);
|
|
||||||
await (isUpdate.value ? ossConfigUpdate(data) : ossConfigAdd(data));
|
await (isUpdate.value ? ossConfigUpdate(data) : ossConfigAdd(data));
|
||||||
emit('reload');
|
emit('reload');
|
||||||
await handleCancel();
|
await handleCancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user