diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 1032d4024..07992f616 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -314,7 +314,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { show-if-above > - + diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index 52dd6ef79..ed3cadc6b 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -297,7 +297,7 @@ defineExpose({ ref="dmsRef" :data-key="$props.model" :url="$props.model" - :filter="dmsFilter" + :user-filter="dmsFilter" :order="['dmsFk DESC']" :auto-load="true" @on-fetch="setData" diff --git a/src/components/common/VnModule.vue b/src/components/common/VnModule.vue index 4757587f9..038ee1d60 100644 --- a/src/components/common/VnModule.vue +++ b/src/components/common/VnModule.vue @@ -20,16 +20,15 @@ const hasContent = ref(); let observer; onMounted(() => { - if (teleportRef.value) { - const checkContent = () => { - hasContent.value = teleportRef?.value?.innerHTML?.trim() !== ''; - }; + if (!teleportRef.value) return; + const checkContent = () => { + hasContent.value = teleportRef.value?.innerHTML?.trim() !== ''; + }; - observer = new MutationObserver(checkContent); - observer.observe(teleportRef.value, { childList: true, subtree: true }); + observer = new MutationObserver(checkContent); + observer.observe(teleportRef.value, { childList: true, subtree: true }); - checkContent(); - } + checkContent(); }); diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index e69e586b5..edd8d3dfa 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -4,11 +4,12 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue'; import { onBeforeMount, computed } from 'vue'; import { useArrayData } from 'src/composables/useArrayData'; +import { useRoute } from 'vue-router'; const $props = defineProps({ section: { type: String, - required: true, + default: null, }, dataKey: { type: String, @@ -38,14 +39,28 @@ const $props = defineProps({ type: Boolean, default: true, }, + keepData: { + type: Boolean, + default: true, + }, }); -const sectionValue = computed(() => $props.section ?? $props.dataKey); +const route = useRoute(); let arrayData; +const sectionValue = computed(() => $props.section ?? $props.dataKey); +const isMainSection = computed(() => { + const isSame = sectionValue.value == route.name; + if (!isSame && arrayData) { + arrayData.reset(['userParams', 'userFilter']); + } + return isSame; +}); + onBeforeMount(() => { if ($props.dataKey) arrayData = useArrayData($props.dataKey, { searchUrl: 'table', + keepData: $props.keepData, ...$props.arrayDataProps, navigate: $props.redirect, }); @@ -74,6 +89,6 @@ onBeforeMount(() => { - + diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index a2ccd5d92..0111366f5 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -111,6 +111,7 @@ onMounted(async () => { }); onBeforeUnmount(() => { + if (!store.keepData) arrayData.reset(['data']); arrayData.resetPagination(); }); diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 4e284d8e4..a2d3b9ee1 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -126,6 +126,7 @@ async function search() { delete filter.params.search; } await arrayData.applyFilter(filter); + searchText.value = undefined; } diff --git a/src/pages/Order/Card/OrderSummary.vue b/src/pages/Order/Card/OrderSummary.vue index b8016abac..ad06dfe43 100644 --- a/src/pages/Order/Card/OrderSummary.vue +++ b/src/pages/Order/Card/OrderSummary.vue @@ -221,7 +221,7 @@ async function handleConfirm() { - + {{ props.row.quantity }} diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index 2a5d290ef..e4a1774fe 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -17,6 +17,7 @@ import VnInputTime from 'src/components/common/VnInputTime.vue'; import RightMenu from 'src/components/common/RightMenu.vue'; import ZoneFilterPanel from './ZoneFilterPanel.vue'; import ZoneSearchbar from './Card/ZoneSearchbar.vue'; +import FetchData from 'src/components/FetchData.vue'; const { t } = useI18n(); const router = useRouter(); @@ -25,6 +26,7 @@ const { viewSummary } = useSummaryDialog(); const { openConfirmationModal } = useVnConfirm(); const tableRef = ref(); const warehouseOptions = ref([]); +const validAddresses = ref([]); const tableFilter = { include: [ @@ -34,6 +36,32 @@ const tableFilter = { fields: ['id', 'name'], }, }, + { + relation: 'address', + scope: { + fields: ['id', 'nickname', 'provinceFk', 'postalCode'], + include: [ + { + relation: 'province', + scope: { + fields: ['id', 'name'], + }, + }, + { + relation: 'postcode', + scope: { + fields: ['code', 'townFk'], + include: { + relation: 'town', + scope: { + fields: ['id', 'name'], + }, + }, + }, + }, + ], + }, + }, ], }; @@ -95,7 +123,14 @@ const columns = computed(() => [ label: t('list.close'), cardVisible: true, format: (row) => toTimeFormat(row.hour), - hidden: true, + columnFilter: false, + }, + { + align: 'left', + name: 'addressFk', + label: t('list.addressFk'), + cardVisible: true, + columnFilter: false, }, { align: 'right', @@ -129,9 +164,27 @@ const handleClone = (id) => { () => clone(id) ); }; + +function showValidAddresses(row) { + if (row.addressFk) { + const isValid = validAddresses.value.some( + (address) => address.addressFk === row.addressFk + ); + if (isValid) + return `${row.address?.nickname}, + ${row.address?.postcode?.town?.name} (${row.address?.province?.name})`; + else return '-'; + } + return '-'; +}