From f9a196e7e9340ae7a9530a3b15c8a49dcaecfe49 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 13 Feb 2023 14:08:18 +0100 Subject: [PATCH] Added dataKey for cache identifier & search redirect --- src/App.vue | 4 +- src/components/PaginateData.vue | 45 ++++++----- src/components/ui/VnFilterPanel.vue | 75 +++++++++++++------ src/components/ui/VnSearchbar.vue | 46 ++++++++++-- src/composables/useArrayData.js | 9 ++- src/pages/Customer/Card/CustomerBasicData.vue | 19 ++++- src/pages/Customer/CustomerList.vue | 36 ++++----- src/pages/Customer/CustomerMain.vue | 60 +-------------- 8 files changed, 162 insertions(+), 132 deletions(-) diff --git a/src/App.vue b/src/App.vue index 2ef0843bd..4f1394559 100644 --- a/src/App.vue +++ b/src/App.vue @@ -30,12 +30,12 @@ quasar.iconMapFn = (iconName) => { const name = iconName.substring(3); return { - cls: `icon-${name}`, + cls: `icon-${name} notranslate`, }; } return { - cls: 'material-symbols-outlined', + cls: 'material-symbols-outlined notranslate', content: iconName, }; }; diff --git a/src/components/PaginateData.vue b/src/components/PaginateData.vue index c9b67e9e3..fb0549f38 100644 --- a/src/components/PaginateData.vue +++ b/src/components/PaginateData.vue @@ -5,7 +5,11 @@ import { useArrayData } from 'composables/useArrayData'; const { t } = useI18n(); -const $props = defineProps({ +const props = defineProps({ + dataKey: { + type: String, + required: true, + }, autoLoad: { type: Boolean, default: false, @@ -43,46 +47,46 @@ const $props = defineProps({ const emit = defineEmits(['onFetch', 'onPaginate']); const isLoading = ref(false); const pagination = ref({ - sortBy: $props.order, - rowsPerPage: $props.limit, + sortBy: props.order, + rowsPerPage: props.limit, page: 1, }); -const arrayData = useArrayData('customers', { - url: $props.url, - filter: $props.filter, - where: $props.where, - limit: $props.limit, - order: $props.order, +const arrayData = useArrayData(props.dataKey, { + url: props.url, + filter: props.filter, + where: props.where, + limit: props.limit, + order: props.order, }); const store = arrayData.store; onMounted(() => { - if ($props.autoLoad) paginate(); + if (props.autoLoad) paginate(); }); watch( - () => $props.data, + () => props.data, () => { - store.data = $props.data; + store.data = props.data; } ); async function paginate() { const { page, rowsPerPage, sortBy, descending } = pagination.value; - if (!$props.url) return; + if (!props.url) return; // const filter = { // limit: rowsPerPage, // skip: rowsPerPage * (page - 1), // }; - // Object.assign(filter, $props.filter); + // Object.assign(filter, props.filter); - // if ($props.where) filter.where = $props.where; - // if ($props.sortBy) filter.order = $props.sortBy; - // if ($props.limit) filter.limit = $props.limit; + // if (props.where) filter.where = props.where; + // if (props.sortBy) filter.order = props.sortBy; + // if (props.limit) filter.limit = props.limit; // if (sortBy) filter.order = sortBy; @@ -107,7 +111,7 @@ async function paginate() { async function onLoad(...params) { const done = params[1]; - if (!store.data || store.data.length === 0 || !$props.url) return done(false); + if (!store.data || store.data.length === 0 || !props.url) return done(false); pagination.value.page = pagination.value.page + 1; @@ -122,7 +126,10 @@ async function onLoad(...params) {
-
+
{{ t('components.smartCard.noData') }}
diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 4d08be135..557a07f3b 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -1,33 +1,52 @@ diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 94c34414b..ab484015b 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -1,16 +1,46 @@ @@ -18,8 +48,8 @@ async function search() { { + const query = route.query; + if (query.params) { + store.userParams = JSON.parse(query.params); + } + }); + onUnmounted(() => { if (arrayDataStore.get(key)) { arrayDataStore.clear(key); diff --git a/src/pages/Customer/Card/CustomerBasicData.vue b/src/pages/Customer/Card/CustomerBasicData.vue index d6841527e..a65f17e83 100644 --- a/src/pages/Customer/Card/CustomerBasicData.vue +++ b/src/pages/Customer/Card/CustomerBasicData.vue @@ -48,8 +48,16 @@ const filterOptions = { @on-fetch="setWorkers" auto-load /> - - + +
@@ -125,11 +133,14 @@ const filterOptions = { :label="t('customer.basicData.salesPerson')" map-options use-input - @filter="(value, update) => filter(value, update, filterOptions)" + @filter=" + (value, update) => + filter(value, update, filterOptions) + " :rules="validate('client.salesPersonFk')" :input-debounce="0" > -