feat: modal state locked on submitting (#5401)

* feat: modal state locked on submitting

* docs: 更新modal文档
This commit is contained in:
Netfan
2025-01-15 17:00:46 +08:00
committed by GitHub
parent 13087a10b7
commit 8cc903c0e1
8 changed files with 71 additions and 25 deletions

View File

@@ -9,10 +9,6 @@ defineOptions({
name: 'FormModelDemo',
});
function onSubmit(values: Record<string, any>) {
message.info(JSON.stringify(values)); // 只会执行一次
}
const [Form, formApi] = useVbenForm({
handleSubmit: onSubmit,
schema: [
@@ -70,6 +66,23 @@ const [Modal, modalApi] = useVbenModal({
},
title: '内嵌表单示例',
});
function onSubmit(values: Record<string, any>) {
message.loading({
content: '正在提交中...',
duration: 0,
key: 'is-form-submitting',
});
modalApi.lock();
setTimeout(() => {
modalApi.close();
message.success({
content: `提交成功:${JSON.stringify(values)}`,
duration: 2,
key: 'is-form-submitting',
});
}, 3000);
}
</script>
<template>
<Modal>

View File

@@ -97,7 +97,7 @@ function openFormModal() {
formModalApi
.setData({
// 表单值
values: { field1: 'abc' },
values: { field1: 'abc', field2: '123' },
})
.open();
}