| | |
| | | |
| | | const sureBtnMap = ref({}); |
| | | const fullscreen = ref(false); |
| | | |
| | | const isPush = (footerButtons, options) => { |
| | | let arr = [ |
| | | { |
| | | label: "取消", |
| | | text: true, |
| | | bg: true, |
| | | btnClick: ({ dialog: { options, index } }) => { |
| | | const done = () => closeDialog(options, index, { command: "cancel" }); |
| | | if (options?.beforeCancel && isFunction(options?.beforeCancel)) { |
| | | options.beforeCancel(done, { options, index }); |
| | | } else { |
| | | done(); |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | label: "确定", |
| | | type: "primary", |
| | | text: true, |
| | | bg: true, |
| | | popconfirm: options?.popconfirm, |
| | | btnClick: ({ dialog: { options, index } }) => { |
| | | 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(); |
| | | closeDialog(options, index, { command: "sure" }); |
| | | }; |
| | | if (options?.beforeSure && isFunction(options?.beforeSure)) { |
| | | options.beforeSure(done, { options, index, closeLoading }); |
| | | } else { |
| | | done(); |
| | | } |
| | | } |
| | | } |
| | | ]; |
| | | return [...footerButtons, ...arr]; |
| | | }; |
| | | const footerButtons = computed(() => { |
| | | return (options: DialogOptions) => { |
| | | return options?.footerButtons?.length > 0 |
| | | ? options.footerButtons |
| | | ? isPush(options.footerButtons, options) |
| | | : ([ |
| | | { |
| | | label: "取消", |