From 96152ed134ccec3bdb8cbb00b927b5bb840e4390 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Mon, 5 Aug 2024 13:15:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20`ReDialog`=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E6=8F=90=E4=BE=9B=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=8C=89=E9=92=AE=E5=8A=A8=E7=94=BB`closeLoading`?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReDialog/index.vue | 7 +++++-- src/components/ReDialog/type.ts | 15 +++++++++------ src/views/components/dialog/index.vue | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/ReDialog/index.vue b/src/components/ReDialog/index.vue index df86143cc..23a0106e3 100644 --- a/src/components/ReDialog/index.vue +++ b/src/components/ReDialog/index.vue @@ -53,14 +53,17 @@ const footerButtons = computed(() => { } ); } - const done = () => { + const closeLoading = () => { if (options?.sureBtnLoading) { sureBtnMap.value[index].loading = false; } + }; + const done = () => { + closeLoading(); closeDialog(options, index, { command: "sure" }); }; if (options?.beforeSure && isFunction(options?.beforeSure)) { - options.beforeSure(done, { options, index }); + options.beforeSure(done, { options, index, closeLoading }); } else { done(); } diff --git a/src/components/ReDialog/type.ts b/src/components/ReDialog/type.ts index 7ea8f71fb..7efbe2018 100644 --- a/src/components/ReDialog/type.ts +++ b/src/components/ReDialog/type.ts @@ -69,11 +69,11 @@ type DialogProps = { type Popconfirm = { /** 标题 */ title?: string; - /** 确认按钮文字 */ + /** 确定按钮文字 */ confirmButtonText?: string; /** 取消按钮文字 */ cancelButtonText?: string; - /** 确认按钮类型,默认 `primary` */ + /** 确定按钮类型,默认 `primary` */ confirmButtonType?: ButtonType; /** 取消按钮类型,默认 `text` */ cancelButtonType?: ButtonType; @@ -121,7 +121,7 @@ type ButtonProps = { round?: boolean; /** 是否为圆形按钮,默认 `false` */ circle?: boolean; - /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */ + /** 确定按钮的 `Popconfirm` 气泡确认框相关配置 */ popconfirm?: Popconfirm; /** 是否为加载中状态,默认 `false` */ loading?: boolean; @@ -160,9 +160,9 @@ interface DialogOptions extends DialogProps { props?: any; /** 是否隐藏 `Dialog` 按钮操作区的内容 */ hideFooter?: boolean; - /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */ + /** 确定按钮的 `Popconfirm` 气泡确认框相关配置 */ popconfirm?: Popconfirm; - /** 点击确认按钮后是否开启 `loading` 加载动画 */ + /** 点击确定按钮后是否开启 `loading` 加载动画 */ sureBtnLoading?: boolean; /** * @description 自定义对话框标题的内容渲染器 @@ -261,10 +261,13 @@ interface DialogOptions extends DialogProps { done: Function, { options, - index + index, + closeLoading }: { options: DialogOptions; index: number; + /** 关闭确定按钮的 `loading` 加载动画 */ + closeLoading: Function; } ) => void; } diff --git a/src/views/components/dialog/index.vue b/src/views/components/dialog/index.vue index 8f46e04c0..8f045da78 100644 --- a/src/views/components/dialog/index.vue +++ b/src/views/components/dialog/index.vue @@ -456,7 +456,9 @@ function onSureBtnLoading() { sureBtnLoading: true, title: "点击底部确定按钮可开启按钮动画", contentRenderer: () =>
弹框内容-点击底部确定按钮可开启按钮动画
, - beforeSure: done => { + beforeSure: (done, { closeLoading }) => { + // closeLoading() // 关闭确定按钮动画,不关闭弹框 + // done() // 关闭确定按钮动画并关闭弹框 setTimeout(() => done(), 800); } });