feat: implement date range filtering in branch management
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
285b821c16
commit
03b03b4bc8
2 changed files with 53 additions and 18 deletions
|
|
@ -6,7 +6,7 @@ import { Icon } from '@iconify/vue';
|
||||||
import { BranchContact } from 'stores/branch-contact/types';
|
import { BranchContact } from 'stores/branch-contact/types';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import type { QSelect, QTableProps, QTableSlots } from 'quasar';
|
import type { QTableProps, QTableSlots } from 'quasar';
|
||||||
import { resetScrollBar } from 'src/stores/utils';
|
import { resetScrollBar } from 'src/stores/utils';
|
||||||
import useBranchStore from 'stores/branch';
|
import useBranchStore from 'stores/branch';
|
||||||
import useFlowStore from 'stores/flow';
|
import useFlowStore from 'stores/flow';
|
||||||
|
|
@ -52,6 +52,7 @@ import {
|
||||||
UndoButton,
|
UndoButton,
|
||||||
} from 'components/button';
|
} from 'components/button';
|
||||||
import { useNavigator } from 'src/stores/navigator';
|
import { useNavigator } from 'src/stores/navigator';
|
||||||
|
import AdvanceSearch from 'src/components/shared/AdvanceSearch.vue';
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
@ -72,7 +73,6 @@ const typeBranchItem = [
|
||||||
color: 'var(--blue-6-hsl)',
|
color: 'var(--blue-6-hsl)',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const refFilter = ref<InstanceType<typeof QSelect>>();
|
|
||||||
const holdDialog = ref(false);
|
const holdDialog = ref(false);
|
||||||
const isSubCreate = ref(false);
|
const isSubCreate = ref(false);
|
||||||
const columns = [
|
const columns = [
|
||||||
|
|
@ -175,6 +175,8 @@ const qrCodeDialog = ref(false);
|
||||||
const qrCodeimageUrl = ref<string>('');
|
const qrCodeimageUrl = ref<string>('');
|
||||||
const formLastSubBranch = ref<number>(0);
|
const formLastSubBranch = ref<number>(0);
|
||||||
|
|
||||||
|
const searchDate = ref<string[]>([]);
|
||||||
|
|
||||||
const branchStore = useBranchStore();
|
const branchStore = useBranchStore();
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
const { locale } = useI18n();
|
const { locale } = useI18n();
|
||||||
|
|
@ -715,12 +717,20 @@ async function fetchList(opts: {
|
||||||
tree?: boolean;
|
tree?: boolean;
|
||||||
withHead?: boolean;
|
withHead?: boolean;
|
||||||
filter?: 'head' | 'sub';
|
filter?: 'head' | 'sub';
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
}) {
|
}) {
|
||||||
await branchStore.fetchList(opts);
|
await branchStore.fetchList(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(inputSearch, () => {
|
watch([inputSearch, searchDate], () => {
|
||||||
fetchList({ tree: true, query: inputSearch.value, withHead: true });
|
fetchList({
|
||||||
|
tree: true,
|
||||||
|
query: inputSearch.value,
|
||||||
|
withHead: true,
|
||||||
|
startDate: searchDate.value[0],
|
||||||
|
endDate: searchDate.value[1],
|
||||||
|
});
|
||||||
currentSubBranch.value = undefined;
|
currentSubBranch.value = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1170,26 +1180,49 @@ watch(currentHq, () => {
|
||||||
<template v-slot:prepend>
|
<template v-slot: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 />
|
|
||||||
<q-btn
|
<AdvanceSearch
|
||||||
icon="mdi-filter-variant"
|
v-model="searchDate"
|
||||||
unelevated
|
:active="$q.screen.lt.md && statusFilter !== 'all'"
|
||||||
class="q-ml-sm"
|
>
|
||||||
padding="4px"
|
<div
|
||||||
size="sm"
|
v-if="$q.screen.lt.md"
|
||||||
rounded
|
class="q-mt-sm text-weight-medium"
|
||||||
@click="refFilter?.showPopup"
|
>
|
||||||
|
{{ $t('general.status') }}
|
||||||
|
</div>
|
||||||
|
<q-select
|
||||||
|
v-if="$q.screen.lt.md"
|
||||||
|
v-model="statusFilter"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
autocomplete="off"
|
||||||
|
option-value="value"
|
||||||
|
option-label="label"
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
:for="'field-select-status'"
|
||||||
|
:options="[
|
||||||
|
{ label: $t('general.all'), value: 'all' },
|
||||||
|
{
|
||||||
|
label: $t('status.ACTIVE'),
|
||||||
|
value: 'statusACTIVE',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('status.INACTIVE'),
|
||||||
|
value: 'statusINACTIVE',
|
||||||
|
},
|
||||||
|
]"
|
||||||
/>
|
/>
|
||||||
</span>
|
</AdvanceSearch>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<div class="row col-md-6 justify-end">
|
<div class="row col-md-6 justify-end">
|
||||||
<q-select
|
<q-select
|
||||||
v-show="$q.screen.gt.sm"
|
v-if="$q.screen.gt.sm"
|
||||||
ref="refFilter"
|
|
||||||
v-model="statusFilter"
|
v-model="statusFilter"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
withHead?: boolean;
|
withHead?: boolean;
|
||||||
activeOnly?: boolean;
|
activeOnly?: boolean;
|
||||||
headOfficeId?: string;
|
headOfficeId?: string;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
},
|
},
|
||||||
Data extends Pagination<Branch[]>,
|
Data extends Pagination<Branch[]>,
|
||||||
>(opts?: Options): Promise<Data | false> {
|
>(opts?: Options): Promise<Data | false> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue