diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 13e8ca3e3..17b21b0e6 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -98,8 +98,7 @@ async function fetch(data) { } function reset() { - state.set($props.model, originalData.value); - watch(formData.value, () => (hasChanges.value = true)); + fetch(originalData.value); hasChanges.value = false; } // eslint-disable-next-line vue/no-dupe-keys @@ -317,7 +316,7 @@ function isEmpty(obj) { diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 28a3759b8..540c37d01 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -89,7 +89,11 @@ async function save() { function reset() { state.set($props.model, originalData.value); + originalData.value = JSON.parse(JSON.stringify(originalData.value)); + watch(formData.value, () => (hasChanges.value = true)); + + emit('onFetch', state.get($props.model)); hasChanges.value = false; } // eslint-disable-next-line vue/no-dupe-keys @@ -123,7 +127,7 @@ watch(formUrl, async () => {
- + { :disable="!hasChanges" :title="t('globals.save')" /> - +
diff --git a/src/components/common/VnSelectFilter.vue b/src/components/common/VnSelectFilter.vue index 2fc8ce4ad..95150cadc 100644 --- a/src/components/common/VnSelectFilter.vue +++ b/src/components/common/VnSelectFilter.vue @@ -1,5 +1,5 @@