From 381a9c6d1d82d3d0c82e88ab674fc53ac5eeaabb Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 27 Jun 2024 13:56:20 +0200 Subject: [PATCH] feat: remake vnInputDate and fix: FormModel has changes when error --- src/components/FormModel.vue | 10 +- src/components/common/VnInputDate.vue | 150 +++++++++++++------------- 2 files changed, 78 insertions(+), 82 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index f10dee61a..ab9fa921a 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -90,7 +90,7 @@ const $props = defineProps({ }); const emit = defineEmits(['onFetch', 'onDataSaved']); const modelValue = computed( - () => $props.model ?? `formModel_${route?.meta?.title ?? route.name}` + () => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`, ).value; const componentIsRendered = ref(false); const arrayData = useArrayData(modelValue); @@ -137,7 +137,7 @@ onMounted(async () => { JSON.stringify(newVal) !== JSON.stringify(originalData.value); isResetting.value = false; }, - { deep: true } + { deep: true }, ); } }); @@ -145,7 +145,7 @@ onMounted(async () => { if (!$props.url) watch( () => arrayData.store.data, - (val) => updateAndEmit('onFetch', val) + (val) => updateAndEmit('onFetch', val), ); watch(formUrl, async () => { @@ -206,11 +206,11 @@ async function save() { updateAndEmit('onDataSaved', formData.value, response?.data); if ($props.reload) await arrayData.fetch({}); + hasChanges.value = false; } catch (err) { console.error(err); notify('errors.writeRequest', 'negative'); } finally { - hasChanges.value = false; isLoading.value = false; } } @@ -239,7 +239,7 @@ function filter(value, update, filterOptions) { (ref) => { ref.setOptionIndex(-1); ref.moveOptionSelection(1, true); - } + }, ); } diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue index 77ab2692d..f2c6cbe60 100644 --- a/src/components/common/VnInputDate.vue +++ b/src/components/common/VnInputDate.vue @@ -1,13 +1,10 @@