refactor: useBeforeCloseDiff逻辑更新
This commit is contained in:
parent
53e02d46c2
commit
88316d7498
@ -47,6 +47,11 @@ export function useBeforeCloseDiff(props: BeforeCloseDiffProps) {
|
||||
isInitialized.value = true;
|
||||
}
|
||||
|
||||
function resetInitialized() {
|
||||
initialized.value = '';
|
||||
isInitialized.value = false;
|
||||
}
|
||||
|
||||
function setSubmitted() {
|
||||
isSubmitted.value = true;
|
||||
}
|
||||
@ -101,6 +106,7 @@ export function useBeforeCloseDiff(props: BeforeCloseDiffProps) {
|
||||
onBeforeClose,
|
||||
updateInitialized,
|
||||
setSubmitted,
|
||||
resetInitialized,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,11 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const { onBeforeClose, updateInitialized, setSubmitted } = useBeforeCloseDiff({
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
});
|
||||
const { onBeforeClose, updateInitialized, setSubmitted, resetInitialized } =
|
||||
useBeforeCloseDiff({
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
});
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
@ -40,22 +41,18 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
modalApi.lock(true);
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await configInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await updateInitialized();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
if (isUpdate.value && id) {
|
||||
const record = await configInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await updateInitialized();
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
});
|
||||
|
||||
@ -80,6 +77,7 @@ async function handleConfirm() {
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user