From 94c7ee3ae3afa39043c8e058695043c4a756a47f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 14 Nov 2024 10:36:42 +0100 Subject: [PATCH 01/26] fix: arrayData store shared --- src/components/CrudModel.vue | 2 +- src/components/VnTable/VnFilter.vue | 2 +- src/components/VnTable/VnOrder.vue | 2 +- src/components/ui/VnFilterPanel.vue | 2 +- src/components/ui/VnPaginate.vue | 9 ++++++--- src/components/ui/VnSearchbar.vue | 2 +- src/composables/useArrayData.js | 2 +- src/pages/Account/AccountList.vue | 6 +++--- src/pages/Account/Role/AccountRoles.vue | 4 ++-- src/pages/Account/Role/Card/RoleCard.vue | 2 +- src/pages/Claim/ClaimFilter.vue | 2 +- src/pages/Customer/CustomerFilter.vue | 2 +- src/pages/Customer/CustomerList.vue | 6 +++--- src/pages/InvoiceIn/InvoiceInList.vue | 2 +- src/pages/InvoiceOut/InvoiceOutList.vue | 6 +++--- src/pages/Ticket/Card/TicketDescriptorMenu.vue | 1 - src/pages/Ticket/TicketFilter.vue | 2 +- src/pages/Ticket/TicketList.vue | 6 +++--- src/pages/Travel/TravelFilter.vue | 2 +- src/pages/Worker/Card/WorkerCard.vue | 1 + src/pages/Worker/WorkerList.vue | 6 +++--- src/pages/Zone/Card/ZoneSearchbar.vue | 2 +- src/pages/Zone/ZoneFilterPanel.vue | 1 - src/pages/Zone/ZoneList.vue | 4 ++-- src/stores/useArrayDataStore.js | 2 +- 25 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index a4cb55a2c..0de5d3aa2 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -77,7 +77,7 @@ const isLoading = ref(false); const hasChanges = ref(false); const originalData = ref(); const vnPaginateRef = ref(); -const formData = ref(); +const formData = ref([]); const saveButtonRef = ref(null); const watchChanges = ref(); const formUrl = computed(() => $props.url); diff --git a/src/components/VnTable/VnFilter.vue b/src/components/VnTable/VnFilter.vue index 9da0b26a4..86802ee92 100644 --- a/src/components/VnTable/VnFilter.vue +++ b/src/components/VnTable/VnFilter.vue @@ -25,7 +25,7 @@ const $props = defineProps({ }, searchUrl: { type: String, - default: 'params', + default: 'table', }, }); diff --git a/src/components/VnTable/VnOrder.vue b/src/components/VnTable/VnOrder.vue index 7fdd23b78..8ffdfe2bc 100644 --- a/src/components/VnTable/VnOrder.vue +++ b/src/components/VnTable/VnOrder.vue @@ -17,7 +17,7 @@ const $props = defineProps({ }, searchUrl: { type: String, - default: 'params', + default: 'table', }, vertical: { type: Boolean, diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 43d634ad9..1ed1194ea 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -49,7 +49,7 @@ const $props = defineProps({ }, searchUrl: { type: String, - default: 'params', + default: 'table', }, redirect: { type: Boolean, diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index 80c607214..f5519eb01 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -44,7 +44,7 @@ const props = defineProps({ }, limit: { type: Number, - default: 10, + default: 20, }, userParams: { type: Object, @@ -100,7 +100,7 @@ const arrayData = useArrayData(props.dataKey, { const store = arrayData.store; onMounted(async () => { - if (props.autoLoad) await fetch(); + if (props.autoLoad && !store.data?.length) await fetch(); mounted.value = true; }); @@ -115,7 +115,10 @@ watch( watch( () => store.data, - (data) => emit('onChange', data) + (data) => { + emit('onChange', data); + }, + { immediate: true } ); watch( diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index dc6d4751c..da2d370fe 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -45,7 +45,7 @@ const props = defineProps({ }, limit: { type: Number, - default: 10, + default: 20, }, userParams: { type: Object, diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 30bcac66b..7fa494349 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -269,7 +269,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { const pushUrl = { path: to }; if (to.endsWith('/list') || to.endsWith('/')) pushUrl.query = newUrl.query; - destroy(); + else destroy(); return router.push(pushUrl); } } diff --git a/src/pages/Account/AccountList.vue b/src/pages/Account/AccountList.vue index 72c445fa9..9e750e1cb 100644 --- a/src/pages/Account/AccountList.vue +++ b/src/pages/Account/AccountList.vue @@ -104,7 +104,7 @@ const exprBuilder = (param, value) => {