diff --git a/src/pages/04_property-managment/MainPage.vue b/src/pages/04_property-managment/MainPage.vue index 7bc13852..ddd413c2 100644 --- a/src/pages/04_property-managment/MainPage.vue +++ b/src/pages/04_property-managment/MainPage.vue @@ -4,7 +4,13 @@ import { onMounted, reactive, ref } from 'vue'; import { QSelect, QTableProps } from 'quasar'; import { useNavigator } from 'src/stores/navigator'; import { useProperty } from 'src/stores/property'; +import { useQuasar } from 'quasar'; +import StatCardComponent from 'src/components/StatCardComponent.vue'; +import NoData from 'src/components/NoData.vue'; +import { watch } from 'vue'; +import KebabAction from 'src/components/shared/KebabAction.vue'; +const $q = useQuasar(); const navigatorStore = useNavigator(); const propertyStore = useProperty(); const { @@ -16,24 +22,16 @@ const { const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all'); const refFilter = ref>(); -const fieldSelected = ref<('order' | 'name' | 'step')[]>([ - 'order', - 'name', - 'step', -]); +const fieldSelected = ref<('name' | 'type')[]>(['name', 'type']); const fieldSelectedOption = ref<{ label: string; value: string }[]>([ { - label: 'general.order', - value: 'order', + label: 'property.table.name', + value: 'name', }, { - label: 'general.name', - value: 'name', - }, - { - label: 'flow.processStep', - value: 'step', + label: 'property.table.type', + value: 'type', }, ]); @@ -44,12 +42,7 @@ const columns = [ label: 'property.table.name', field: 'order', }, - { - name: 'nameEn', - align: 'center', - label: 'property.table.nameEn', - field: 'nameEn', - }, + { name: 'type', align: 'center', @@ -70,9 +63,51 @@ const pageState = reactive({ isDrawerEdit: true, }); +async function fetchPropertyList(mobileFetch?: boolean) { + const res = await propertyStore.getPropertyList({ + page: mobileFetch ? 1 : propertyPage.value, + pageSize: mobileFetch + ? propertyData.value.length + + (pageState.total === propertyData.value.length ? 1 : 0) + : propertyPageSize.value, + query: pageState.inputSearch, + status: + statusFilter.value === 'all' + ? undefined + : statusFilter.value === 'statusACTIVE' + ? 'ACTIVE' + : 'INACTIVE', + }); + if (res) { + propertyData.value = + $q.screen.xs && !mobileFetch + ? [...propertyData.value, ...res.result] + : res.result; + + propertyPageMax.value = Math.ceil(res.total / propertyPageSize.value); + if (pageState.inputSearch || statusFilter.value !== 'all') return; + pageState.total = res.total; + } +} + onMounted(async () => { navigatorStore.current.title = 'property.title'; navigatorStore.current.path = [{ text: 'property.caption', i18n: true }]; + await fetchPropertyList(); +}); + +watch( + () => statusFilter.value, + () => { + propertyData.value = []; + propertyPage.value = 1; + fetchPropertyList(); + }, +); +watch([() => pageState.inputSearch, propertyPageSize], () => { + propertyData.value = []; + propertyPage.value = 1; + fetchPropertyList(); });