song-ui-u
Version:
vue3 + js的PC前端组件库
40 lines (37 loc) • 1 kB
JavaScript
import { getCurrentInstance } from 'vue';
import { types } from '../../../../utils/types.mjs';
import 'song-ui-pro-icon';
function useModalEvent({ props, visible, isLoading }) {
const { emit } = getCurrentInstance();
const useBeforeCancel = () => {
useClose("cancel");
emit("cancel");
};
const useBeforeChange = () => {
const isFunction = types().isFunction(props.beforeChange);
if (isFunction) {
isLoading.value = true;
props.beforeChange().then(() => {
isLoading.value = false;
emit("ok");
}).catch(() => {
isLoading.value = false;
});
return;
}
emit("ok");
useClose("confirm");
};
const useClose = (action = "cancel") => {
const isFunction = types().isFunction(props.callback);
isFunction && props.callback({ action });
visible.value = false;
};
return {
useBeforeCancel,
useBeforeChange,
useClose
};
}
export { useModalEvent };
//# sourceMappingURL=use-modal-event.mjs.map