feat: filter สถานะ
This commit is contained in:
parent
728bcf94d8
commit
d049782e36
2 changed files with 39 additions and 8 deletions
|
|
@ -6,6 +6,7 @@ import { onMounted } from 'vue';
|
||||||
import useCustomerStore from 'src/stores/customer';
|
import useCustomerStore from 'src/stores/customer';
|
||||||
import { CustomerBranch, CustomerType } from 'src/stores/customer/types';
|
import { CustomerBranch, CustomerType } from 'src/stores/customer/types';
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
import { Status } from 'src/stores/types';
|
||||||
|
|
||||||
const userCustomer = useCustomerStore();
|
const userCustomer = useCustomerStore();
|
||||||
const { fetchListBranch } = userCustomer;
|
const { fetchListBranch } = userCustomer;
|
||||||
|
|
@ -19,6 +20,8 @@ const currentCustomerUrlImage = defineModel<string | null>(
|
||||||
'currentCustomerUrlImage',
|
'currentCustomerUrlImage',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const currentStatus = ref<Status | 'All'>('All');
|
||||||
|
|
||||||
const currentPageBranch = ref<number>(1);
|
const currentPageBranch = ref<number>(1);
|
||||||
const maxPageBranch = ref<number>(1);
|
const maxPageBranch = ref<number>(1);
|
||||||
const pageSizeBranch = ref<number>(30);
|
const pageSizeBranch = ref<number>(30);
|
||||||
|
|
@ -52,18 +55,28 @@ async function searchBranch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
await fetchList();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function fetchList() {
|
||||||
const result = await fetchListBranch({
|
const result = await fetchListBranch({
|
||||||
customerId: prop.customerId,
|
customerId: prop.customerId,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: pageSizeBranch.value,
|
pageSize: pageSizeBranch.value,
|
||||||
includeCustomer: true,
|
includeCustomer: true,
|
||||||
|
status:
|
||||||
|
currentStatus.value === 'All'
|
||||||
|
? undefined
|
||||||
|
: currentStatus.value === 'ACTIVE'
|
||||||
|
? 'ACTIVE'
|
||||||
|
: 'INACTIVE',
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
currentCustomerName.value = result.result[0].customer?.customerName;
|
currentCustomerName.value = result.result[0].customer?.customerName ?? '';
|
||||||
maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value);
|
maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value);
|
||||||
branch.value = result.result;
|
branch.value = result.result;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
watch(currentPageBranch, async () => {
|
watch(currentPageBranch, async () => {
|
||||||
const resultList = await fetchListBranch({
|
const resultList = await fetchListBranch({
|
||||||
|
|
@ -79,6 +92,10 @@ watch(currentPageBranch, async () => {
|
||||||
branch.value = resultList.result;
|
branch.value = resultList.result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(currentStatus, async () => {
|
||||||
|
await fetchList();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -158,21 +175,21 @@ watch(currentPageBranch, async () => {
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'All'"
|
||||||
>
|
>
|
||||||
{{ $t('all') }}
|
{{ $t('all') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'ACTIVE'"
|
||||||
>
|
>
|
||||||
{{ $t('statusACTIVE') }}
|
{{ $t('statusACTIVE') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'INACTIVE'"
|
||||||
>
|
>
|
||||||
{{ $t('statusINACTIVE') }}
|
{{ $t('statusINACTIVE') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,8 @@ const currentCustomerName = ref<string>('');
|
||||||
const currentCustomerUrlImage = ref<string | null>(null);
|
const currentCustomerUrlImage = ref<string | null>(null);
|
||||||
const genderselector = ref<string>('');
|
const genderselector = ref<string>('');
|
||||||
|
|
||||||
|
const currentStatus = ref<Status | 'All'>('All');
|
||||||
|
|
||||||
const inputFile = (() => {
|
const inputFile = (() => {
|
||||||
const element = document.createElement('input');
|
const element = document.createElement('input');
|
||||||
element.type = 'file';
|
element.type = 'file';
|
||||||
|
|
@ -680,6 +682,12 @@ async function fetchListCustomer() {
|
||||||
includeBranch: true,
|
includeBranch: true,
|
||||||
page: currentPageCustomer.value,
|
page: currentPageCustomer.value,
|
||||||
pageSize: pageSizeCustomer.value,
|
pageSize: pageSizeCustomer.value,
|
||||||
|
status:
|
||||||
|
currentStatus.value === 'All'
|
||||||
|
? undefined
|
||||||
|
: currentStatus.value === 'ACTIVE'
|
||||||
|
? 'ACTIVE'
|
||||||
|
: 'INACTIVE',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (resultList) {
|
if (resultList) {
|
||||||
|
|
@ -1133,6 +1141,12 @@ watch(
|
||||||
watch(genderselector, async (gender) => {
|
watch(genderselector, async (gender) => {
|
||||||
await fetchListEmployee({ gender: gender });
|
await fetchListEmployee({ gender: gender });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(currentStatus, async () => {
|
||||||
|
if (selectorLabel.value === 'EMPLOYER') {
|
||||||
|
await fetchListCustomer();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -1329,21 +1343,21 @@ watch(genderselector, async (gender) => {
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'All'"
|
||||||
>
|
>
|
||||||
{{ $t('all') }}
|
{{ $t('all') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'ACTIVE'"
|
||||||
>
|
>
|
||||||
{{ $t('statusACTIVE') }}
|
{{ $t('statusACTIVE') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
@click="console.log('test')"
|
@click="currentStatus = 'INACTIVE'"
|
||||||
>
|
>
|
||||||
{{ $t('statusINACTIVE') }}
|
{{ $t('statusINACTIVE') }}
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue