feat: 函数式弹框组件添加 beforeCancelbeforeSure回调

This commit is contained in:
xiaoxian521
2023-05-10 17:42:43 +08:00
parent b2d06d2b3b
commit 47f951312e
2 changed files with 18 additions and 2 deletions

View File

@@ -19,7 +19,13 @@ const footerButtons = computed(() => {
text: true,
bg: true,
btnClick: ({ dialog: { options, index } }) => {
closeDialog(options, index, { command: "cancel" });
const done = () =>
closeDialog(options, index, { command: "cancel" });
if (options?.beforeCancel && isFunction(options?.beforeCancel)) {
options.beforeCancel(done);
} else {
done();
}
}
},
{
@@ -28,7 +34,13 @@ const footerButtons = computed(() => {
text: true,
bg: true,
btnClick: ({ dialog: { options, index } }) => {
closeDialog(options, index, { command: "sure" });
const done = () =>
closeDialog(options, index, { command: "sure" });
if (options?.beforeSure && isFunction(options?.beforeSure)) {
options.beforeSure(done);
} else {
done();
}
}
}
] as Array<ButtonProps>);