diff --git a/.vscode/settings.json b/.vscode/settings.json index 5026b7d3b..8f601aa77 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,5 +14,5 @@ "[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "cSpell.words": ["axios"] + "cSpell.words": ["axios", "composables"] } diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index a55bde6f2..74c4a9bc0 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -98,19 +98,17 @@ defineExpose({ }); async function fetch(data) { - if (data && Array.isArray(data)) { - let $index = 0; - data.map((d) => (d.$index = $index++)); - } - resetData(data); - emit('onFetch', data); return data; } function resetData(data) { if (!data) return; + if (data && Array.isArray(data)) { + let $index = 0; + data.map((d) => (d.$index = $index++)); + } originalData.value = JSON.parse(JSON.stringify(data)); formData.value = JSON.parse(JSON.stringify(data)); @@ -299,7 +297,7 @@ watch(formUrl, async () => { :url="url" :limit="limit" @on-fetch="fetch" - @on-change="resetData" + @on-change="fetch" :skeleton="false" ref="vnPaginateRef" v-bind="$attrs" diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index becc1c174..758ddd433 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 () => { @@ -239,7 +239,7 @@ function filter(value, update, filterOptions) { (ref) => { ref.setOptionIndex(-1); ref.moveOptionSelection(1, true); - }, + } ); } @@ -261,13 +261,7 @@ defineExpose({