diff --git a/src/components/ReDrawer/index.vue b/src/components/ReDrawer/index.vue index 1b0565b2cb..950bb046da 100644 --- a/src/components/ReDrawer/index.vue +++ b/src/components/ReDrawer/index.vue @@ -6,12 +6,14 @@ import { closeDrawer, drawerStore } from "./index"; -import { computed } from "vue"; +import { computed, ref } from "vue"; import { isFunction } from "@pureadmin/utils"; defineOptions({ name: "ReDrawer" }); +const sureBtnMap = ref({}); + const footerButtons = computed(() => { return (options: DrawerOptions) => { return options?.footerButtons?.length > 0 @@ -38,10 +40,26 @@ const footerButtons = computed(() => { bg: true, popConfirm: options?.popConfirm, btnClick: ({ drawer: { options, index } }) => { - const done = () => + if (options?.sureBtnLoading) { + sureBtnMap.value[index] = Object.assign( + {}, + sureBtnMap.value[index], + { + loading: true + } + ); + } + const closeLoading = () => { + if (options?.sureBtnLoading) { + sureBtnMap.value[index].loading = false; + } + }; + const done = () => { + closeLoading(); closeDrawer(options, index, { command: "sure" }); + }; if (options?.beforeSure && isFunction(options?.beforeSure)) { - options.beforeSure(done, { options, index }); + options.beforeSure(done, { options, index, closeLoading }); } else { done(); } @@ -131,6 +149,7 @@ function handleClose(