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