feat: add date range selection to customer and employee management
This commit is contained in:
parent
461dd359b1
commit
36cef7ceb6
3 changed files with 64 additions and 30 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, onMounted, computed } from 'vue';
|
import { ref, watch, onMounted, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { QSelect, useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { getUserId, getRole } from 'src/services/keycloak';
|
import { getUserId, getRole } from 'src/services/keycloak';
|
||||||
import { baseUrl, setPrefixName, waitAll } from 'src/stores/utils';
|
import { baseUrl, setPrefixName, waitAll } from 'src/stores/utils';
|
||||||
|
|
@ -86,6 +86,7 @@ import { nextTick } from 'vue';
|
||||||
import FormEmployeeVisa from 'components/03_customer-management/FormEmployeeVisa.vue';
|
import FormEmployeeVisa from 'components/03_customer-management/FormEmployeeVisa.vue';
|
||||||
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
||||||
import { AddButton } from 'components/button';
|
import { AddButton } from 'components/button';
|
||||||
|
import AdvanceSearch from 'src/components/shared/AdvanceSearch.vue';
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
@ -101,7 +102,6 @@ const employeeFormStore = useEmployeeForm();
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
const ocrStore = useOcrStore();
|
const ocrStore = useOcrStore();
|
||||||
|
|
||||||
const refFilter = ref<InstanceType<typeof QSelect>>();
|
|
||||||
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
|
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
@ -189,6 +189,7 @@ const statsCustomerType = ref<CustomerStats>({
|
||||||
});
|
});
|
||||||
|
|
||||||
// NOTE: Page State
|
// NOTE: Page State
|
||||||
|
const searchDate = ref<string[]>([]);
|
||||||
const currentTab = ref<'employer' | 'employee'>('employer');
|
const currentTab = ref<'employer' | 'employee'>('employer');
|
||||||
const inputSearch = ref('');
|
const inputSearch = ref('');
|
||||||
const currentStatus = ref<Status | 'All'>('All');
|
const currentStatus = ref<Status | 'All'>('All');
|
||||||
|
|
@ -226,8 +227,16 @@ const dialogEmployeeImageUpload = ref<InstanceType<typeof ImageUploadDialog>>();
|
||||||
const imageList = ref<{ selectedImage: string; list: string[] }>();
|
const imageList = ref<{ selectedImage: string; list: string[] }>();
|
||||||
watch(() => route.name, init);
|
watch(() => route.name, init);
|
||||||
watch(
|
watch(
|
||||||
[currentTab, currentStatus, inputSearch, customerTypeSelected, pageSize],
|
[
|
||||||
async ([tabName]) => {
|
currentTab,
|
||||||
|
currentStatus,
|
||||||
|
inputSearch,
|
||||||
|
customerTypeSelected,
|
||||||
|
pageSize,
|
||||||
|
searchDate,
|
||||||
|
],
|
||||||
|
async ([tabName], [oldTabName]) => {
|
||||||
|
if (tabName !== oldTabName) searchDate.value = [];
|
||||||
if (tabName === 'employer') {
|
if (tabName === 'employer') {
|
||||||
currentPageCustomer.value = 1;
|
currentPageCustomer.value = 1;
|
||||||
currentBtnOpen.value = [];
|
currentBtnOpen.value = [];
|
||||||
|
|
@ -317,6 +326,8 @@ async function fetchListCustomer(fetchStats = false, mobileFetch?: boolean) {
|
||||||
? 'ACTIVE'
|
? 'ACTIVE'
|
||||||
: 'INACTIVE',
|
: 'INACTIVE',
|
||||||
query: inputSearch.value,
|
query: inputSearch.value,
|
||||||
|
startDate: searchDate.value[0],
|
||||||
|
endDate: searchDate.value[1],
|
||||||
customerType: (
|
customerType: (
|
||||||
{
|
{
|
||||||
all: undefined,
|
all: undefined,
|
||||||
|
|
@ -370,6 +381,8 @@ async function fetchListEmployee(opt?: {
|
||||||
query: inputSearch.value,
|
query: inputSearch.value,
|
||||||
passport: true,
|
passport: true,
|
||||||
visa: true,
|
visa: true,
|
||||||
|
startDate: searchDate.value[0],
|
||||||
|
endDate: searchDate.value[1],
|
||||||
});
|
});
|
||||||
if (resultListEmployee) {
|
if (resultListEmployee) {
|
||||||
maxPageEmployee.value = Math.ceil(
|
maxPageEmployee.value = Math.ceil(
|
||||||
|
|
@ -775,26 +788,43 @@ const emptyCreateDialog = ref(false);
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<q-icon name="mdi-magnify" />
|
<q-icon name="mdi-magnify" />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="$q.screen.lt.md" v-slot:append>
|
<template v-slot:append>
|
||||||
<span class="row">
|
<q-separator vertical inset class="q-mr-xs" />
|
||||||
<q-separator vertical />
|
<AdvanceSearch
|
||||||
<q-btn
|
v-model="searchDate"
|
||||||
icon="mdi-filter-variant"
|
:active="$q.screen.lt.md && currentStatus !== 'All'"
|
||||||
unelevated
|
>
|
||||||
class="q-ml-sm"
|
<div
|
||||||
padding="4px"
|
v-if="$q.screen.lt.md"
|
||||||
size="sm"
|
class="q-mt-sm text-weight-medium"
|
||||||
rounded
|
>
|
||||||
@click="refFilter?.showPopup"
|
{{ $t('general.status') }}
|
||||||
|
</div>
|
||||||
|
<q-select
|
||||||
|
v-if="$q.screen.lt.md"
|
||||||
|
id="select-status"
|
||||||
|
for="select-status"
|
||||||
|
v-model="currentStatus"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
autocomplete="off"
|
||||||
|
option-value="value"
|
||||||
|
option-label="label"
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
:options="[
|
||||||
|
{ label: $t('general.all'), value: 'All' },
|
||||||
|
{ label: $t('status.ACTIVE'), value: 'ACTIVE' },
|
||||||
|
{ label: $t('status.INACTIVE'), value: 'INACTIVE' },
|
||||||
|
]"
|
||||||
/>
|
/>
|
||||||
</span>
|
</AdvanceSearch>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<div class="row col-md-5" style="white-space: nowrap">
|
<div class="row col-md-5" style="white-space: nowrap">
|
||||||
<q-select
|
<q-select
|
||||||
v-show="$q.screen.gt.sm"
|
v-if="$q.screen.gt.sm"
|
||||||
ref="refFilter"
|
|
||||||
id="select-status"
|
id="select-status"
|
||||||
for="select-status"
|
for="select-status"
|
||||||
v-model="currentStatus"
|
v-model="currentStatus"
|
||||||
|
|
@ -2154,8 +2184,8 @@ const emptyCreateDialog = ref(false);
|
||||||
id="form-basic-info-customer"
|
id="form-basic-info-customer"
|
||||||
:onCreate="customerFormState.dialogType === 'create'"
|
:onCreate="customerFormState.dialogType === 'create'"
|
||||||
@edit="
|
@edit="
|
||||||
(customerFormState.dialogType = 'edit'),
|
((customerFormState.dialogType = 'edit'),
|
||||||
(customerFormState.readonly = false)
|
(customerFormState.readonly = false))
|
||||||
"
|
"
|
||||||
@cancel="() => customerFormUndo(false)"
|
@cancel="() => customerFormUndo(false)"
|
||||||
@delete="
|
@delete="
|
||||||
|
|
@ -4231,8 +4261,8 @@ const emptyCreateDialog = ref(false);
|
||||||
id="form-basic-info-customer"
|
id="form-basic-info-customer"
|
||||||
:onCreate="customerFormState.dialogType === 'create'"
|
:onCreate="customerFormState.dialogType === 'create'"
|
||||||
@edit="
|
@edit="
|
||||||
(customerFormState.dialogType = 'edit'),
|
((customerFormState.dialogType = 'edit'),
|
||||||
(customerFormState.readonly = false)
|
(customerFormState.readonly = false))
|
||||||
"
|
"
|
||||||
@cancel="() => customerFormUndo(false)"
|
@cancel="() => customerFormUndo(false)"
|
||||||
@delete="
|
@delete="
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ const useCustomerStore = defineStore('api-customer', () => {
|
||||||
includeBranch?: boolean;
|
includeBranch?: boolean;
|
||||||
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
||||||
customerType?: CustomerType;
|
customerType?: CustomerType;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
},
|
},
|
||||||
Data extends Pagination<
|
Data extends Pagination<
|
||||||
(Customer &
|
(Customer &
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
customerId?: string;
|
customerId?: string;
|
||||||
customerBranchId?: string;
|
customerBranchId?: string;
|
||||||
activeOnly?: boolean;
|
activeOnly?: boolean;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
payload?: { passport?: string[] };
|
payload?: { passport?: string[] };
|
||||||
}) {
|
}) {
|
||||||
const { payload, ...params } = opts || {};
|
const { payload, ...params } = opts || {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue