feat: add `confirmDisabled` for `Dialog` (#4959)

pull/53/MERGE
Netfan 2024-11-27 11:28:49 +08:00 committed by GitHub
parent f85badf482
commit dedba18553
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 3 deletions

View File

@ -93,13 +93,14 @@ const [Modal, modalApi] = useVbenModal({
| modal | 显示遮罩 | `boolean` | `true` | | modal | 显示遮罩 | `boolean` | `true` |
| header | 显示header | `boolean` | `true` | | header | 显示header | `boolean` | `true` |
| footer | 显示footer | `boolean\|slot` | `true` | | footer | 显示footer | `boolean\|slot` | `true` |
| confirmDisabled | 禁用确认按钮 | `boolean` | `false` |
| confirmLoading | 确认按钮loading状态 | `boolean` | `false` | | confirmLoading | 确认按钮loading状态 | `boolean` | `false` |
| closeOnClickModal | 点击遮罩关闭弹窗 | `boolean` | `true` | | closeOnClickModal | 点击遮罩关闭弹窗 | `boolean` | `true` |
| closeOnPressEscape | esc 关闭弹窗 | `boolean` | `true` | | closeOnPressEscape | esc 关闭弹窗 | `boolean` | `true` |
| confirmText | 确认按钮文本 | `string\|slot` | `确认` | | confirmText | 确认按钮文本 | `string\|slot` | `确认` |
| cancelText | 取消按钮文本 | `string\|slot` | `取消` | | cancelText | 取消按钮文本 | `string\|slot` | `取消` |
| showCancelButton | 显示取消按钮 | `boolean` | `true` | | showCancelButton | 显示取消按钮 | `boolean` | `true` |
| showConfirmButton | 显示确认按钮文本 | `boolean` | `true` | | showConfirmButton | 显示确认按钮 | `boolean` | `true` |
| class | modal的class宽度通过这个配置 | `string` | - | | class | modal的class宽度通过这个配置 | `string` | - |
| contentClass | modal内容区域的class | `string` | - | | contentClass | modal内容区域的class | `string` | - |
| footerClass | modal底部区域的class | `string` | - | | footerClass | modal底部区域的class | `string` | - |

View File

@ -41,6 +41,7 @@ export class ModalApi {
class: '', class: '',
closeOnClickModal: true, closeOnClickModal: true,
closeOnPressEscape: true, closeOnPressEscape: true,
confirmDisabled: false,
confirmLoading: false, confirmLoading: false,
contentClass: '', contentClass: '',
draggable: false, draggable: false,

View File

@ -35,6 +35,10 @@ export interface ModalProps {
* @default true * @default true
*/ */
closeOnPressEscape?: boolean; closeOnPressEscape?: boolean;
/**
*
*/
confirmDisabled?: boolean;
/** /**
* loading * loading
* @default false * @default false

View File

@ -59,6 +59,7 @@ const {
closable, closable,
closeOnClickModal, closeOnClickModal,
closeOnPressEscape, closeOnPressEscape,
confirmDisabled,
confirmLoading, confirmLoading,
confirmText, confirmText,
contentClass, contentClass,
@ -285,6 +286,7 @@ function handleFocusOutside(e: Event) {
<component <component
:is="components.PrimaryButton || VbenButton" :is="components.PrimaryButton || VbenButton"
v-if="showConfirmButton" v-if="showConfirmButton"
:disabled="confirmDisabled"
:loading="confirmLoading" :loading="confirmLoading"
@click="() => modalApi?.onConfirm()" @click="() => modalApi?.onConfirm()"
> >

View File

@ -22,10 +22,10 @@ const [Modal, modalApi] = useVbenModal({
}); });
function handleUpdate(len: number) { function handleUpdate(len: number) {
modalApi.setState({ loading: true }); modalApi.setState({ confirmDisabled: true, loading: true });
setTimeout(() => { setTimeout(() => {
list.value = Array.from({ length: len }, (_v, k) => k + 1); list.value = Array.from({ length: len }, (_v, k) => k + 1);
modalApi.setState({ loading: false }); modalApi.setState({ confirmDisabled: false, loading: false });
}, 2000); }, 2000);
} }
</script> </script>