feat: 函数式弹框ReDialog添加点击确认按钮后是否开启loading加载动画功能

This commit is contained in:
xiaoxian521
2024-07-30 14:56:47 +08:00
parent 0706f37254
commit 6d7e92fed1
3 changed files with 32 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ defineOptions({
name: "ReDialog"
});
const sureBtnMap = ref({});
const fullscreen = ref(false);
const footerButtons = computed(() => {
@@ -43,8 +44,21 @@ const footerButtons = computed(() => {
bg: true,
popconfirm: options?.popconfirm,
btnClick: ({ dialog: { options, index } }) => {
const done = () =>
if (options?.sureBtnLoading) {
sureBtnMap.value[index] = Object.assign(
{},
sureBtnMap.value[index],
{
loading: true
}
);
}
const done = () => {
if (options?.sureBtnLoading) {
sureBtnMap.value[index].loading = false;
}
closeDialog(options, index, { command: "sure" });
};
if (options?.beforeSure && isFunction(options?.beforeSure)) {
options.beforeSure(done, { options, index });
} else {
@@ -172,6 +186,7 @@ function handleClose(
<el-button
v-else
v-bind="btn"
:loading="key === 1 && sureBtnMap[index]?.loading"
@click="
btn.btnClick({
dialog: { options, index },