diff --git a/src/components/FormPopup.vue b/src/components/FormPopup.vue index d7f744984..e1c15fcf4 100644 --- a/src/components/FormPopup.vue +++ b/src/components/FormPopup.vue @@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n'; const emit = defineEmits(['onSubmit']); -defineProps({ +const $props = defineProps({ title: { type: String, default: '', @@ -25,16 +25,21 @@ defineProps({ type: String, default: '', }, + submitOnEnter: { + type: Boolean, + default: true, + }, }); const { t } = useI18n(); - const closeButton = ref(null); const isLoading = ref(false); const onSubmit = () => { - emit('onSubmit'); - closeForm(); + if ($props.submitOnEnter) { + emit('onSubmit'); + closeForm(); + } }; const closeForm = () => { diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index b058dc642..f3f6d64f1 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -132,10 +132,24 @@ const addFilter = async (filter, params) => { async function fetch(params) { useArrayData(props.dataKey, params); - arrayData.reset(['filter.skip', 'skip']); + arrayData.reset(['filter.skip', 'skip', 'page']); await arrayData.fetch({ append: false }); - if (!store.hasMoreData) isLoading.value = false; + return emitStoreData(); +} +async function update(params) { + useArrayData(props.dataKey, params); + const { limit, skip } = store; + store.limit = limit + skip; + store.skip = 0; + await arrayData.fetch({ append: false }); + store.limit = limit; + store.skip = skip; + return emitStoreData(); +} + +function emitStoreData() { + if (!store.hasMoreData) isLoading.value = false; emit('onFetch', store.data); return store.data; } @@ -181,7 +195,7 @@ async function onLoad(index, done) { done(isDone); } -defineExpose({ fetch, addFilter, paginate }); +defineExpose({ fetch, update, addFilter, paginate });