2024-06-07 11:58:27 +07:00
|
|
|
<script setup lang="ts">
|
2024-07-01 13:30:21 +07:00
|
|
|
import { ref, onMounted, watch } from 'vue';
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
import useCustomerStore from 'src/stores/customer';
|
2024-07-03 17:55:12 +07:00
|
|
|
import useFlowStore from 'src/stores/flow';
|
2024-07-05 17:35:40 +07:00
|
|
|
import useOptionStore from 'src/stores/options';
|
2024-07-03 17:55:12 +07:00
|
|
|
|
|
|
|
|
import { Status } from 'src/stores/types';
|
2024-06-12 15:36:36 +07:00
|
|
|
import { CustomerBranch, CustomerType } from 'src/stores/customer/types';
|
2024-07-01 13:30:21 +07:00
|
|
|
|
|
|
|
|
import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue';
|
|
|
|
|
import PaginationComponent from 'src/components/PaginationComponent.vue';
|
|
|
|
|
import NoData from 'components/NoData.vue';
|
2024-06-07 14:16:38 +07:00
|
|
|
|
2024-07-03 17:55:12 +07:00
|
|
|
const flowStore = useFlowStore();
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
const userCustomer = useCustomerStore();
|
2024-07-03 17:55:12 +07:00
|
|
|
const { fetchListCustomeBranch } = userCustomer;
|
2024-06-07 11:58:27 +07:00
|
|
|
|
|
|
|
|
const inputSearch = ref<string>('');
|
|
|
|
|
|
2024-06-10 12:00:16 +07:00
|
|
|
const branch = defineModel<CustomerBranch[]>('branch');
|
|
|
|
|
const currentCustomerName = defineModel<string>('currentCustomerName');
|
2024-06-07 15:05:22 +07:00
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
const currentCustomerUrlImage = defineModel<string | null>(
|
|
|
|
|
'currentCustomerUrlImage',
|
|
|
|
|
);
|
|
|
|
|
|
2024-06-14 13:03:20 +07:00
|
|
|
const currentStatus = ref<Status | 'All'>('All');
|
2024-07-01 13:30:21 +07:00
|
|
|
const totalBranch = ref(0);
|
2024-06-14 13:03:20 +07:00
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
const currentPageBranch = ref<number>(1);
|
|
|
|
|
const maxPageBranch = ref<number>(1);
|
|
|
|
|
const pageSizeBranch = ref<number>(30);
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
const prop = withDefaults(
|
2024-06-07 11:58:27 +07:00
|
|
|
defineProps<{
|
2024-06-07 14:19:35 +07:00
|
|
|
color?: 'purple' | 'green';
|
2024-07-01 13:30:21 +07:00
|
|
|
|
2024-06-07 14:40:18 +07:00
|
|
|
customerId: string;
|
2024-06-11 11:23:56 +07:00
|
|
|
customerType: CustomerType;
|
2024-06-07 11:58:27 +07:00
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
color: 'green',
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-06-07 14:16:38 +07:00
|
|
|
|
2024-07-05 17:35:40 +07:00
|
|
|
defineEmits<{
|
2024-06-10 12:00:16 +07:00
|
|
|
(e: 'back'): void;
|
2024-07-05 15:13:23 +07:00
|
|
|
(e: 'viewDetail', branch: CustomerBranch, index: number): void;
|
2024-06-10 12:00:16 +07:00
|
|
|
(e: 'dialog'): void;
|
|
|
|
|
}>();
|
|
|
|
|
|
2024-06-07 14:16:38 +07:00
|
|
|
onMounted(async () => {
|
2024-06-14 13:03:20 +07:00
|
|
|
await fetchList();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
async function fetchList() {
|
2024-07-03 17:55:12 +07:00
|
|
|
const result = await fetchListCustomeBranch({
|
2024-06-11 11:23:56 +07:00
|
|
|
customerId: prop.customerId,
|
2024-07-01 13:30:21 +07:00
|
|
|
query: !!inputSearch.value ? inputSearch.value : undefined,
|
|
|
|
|
page: currentPageBranch.value,
|
2024-06-11 11:23:56 +07:00
|
|
|
pageSize: pageSizeBranch.value,
|
2024-06-12 16:21:55 +07:00
|
|
|
includeCustomer: true,
|
2024-06-14 13:03:20 +07:00
|
|
|
status:
|
|
|
|
|
currentStatus.value === 'All'
|
|
|
|
|
? undefined
|
|
|
|
|
: currentStatus.value === 'ACTIVE'
|
|
|
|
|
? 'ACTIVE'
|
|
|
|
|
: 'INACTIVE',
|
2024-06-11 11:23:56 +07:00
|
|
|
});
|
2024-06-07 15:05:22 +07:00
|
|
|
if (result) {
|
2024-07-01 13:30:21 +07:00
|
|
|
totalBranch.value = result.total;
|
2024-06-12 15:36:36 +07:00
|
|
|
maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value);
|
2024-06-11 11:23:56 +07:00
|
|
|
branch.value = result.result;
|
|
|
|
|
}
|
2024-06-14 13:03:20 +07:00
|
|
|
}
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-07-01 13:30:21 +07:00
|
|
|
watch(inputSearch, async () => {
|
|
|
|
|
await fetchList();
|
2024-06-07 14:16:38 +07:00
|
|
|
});
|
2024-06-14 13:03:20 +07:00
|
|
|
|
|
|
|
|
watch(currentStatus, async () => {
|
|
|
|
|
await fetchList();
|
|
|
|
|
});
|
2024-06-07 11:58:27 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-07-18 09:11:41 +00:00
|
|
|
<div
|
2024-07-24 02:04:47 +00:00
|
|
|
class="bordered surface-1 col column surface-2 rounded no-wrap"
|
2024-07-18 09:11:41 +00:00
|
|
|
style="overflow: hidden"
|
|
|
|
|
>
|
2024-07-24 02:04:47 +00:00
|
|
|
<div
|
|
|
|
|
class="row justify-between bordered-b surface-3 full-width no-wrap"
|
|
|
|
|
style="z-index: 1"
|
|
|
|
|
>
|
2024-07-18 09:11:41 +00:00
|
|
|
<div class="row items-center col-12 col-sm">
|
2024-06-07 11:58:27 +07:00
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
icon="mdi-arrow-left"
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
@click="$emit('back')"
|
|
|
|
|
class="q-mr-md"
|
|
|
|
|
/>
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-06-07 11:58:27 +07:00
|
|
|
<q-card-section
|
2024-06-11 11:23:23 +07:00
|
|
|
class="q-pa-sm q-pt-md q-mr-md q-mb-sm"
|
|
|
|
|
:class="{
|
|
|
|
|
color__purple: customerType === 'CORP',
|
|
|
|
|
color__green: customerType === 'PERS',
|
|
|
|
|
}"
|
2024-06-07 13:59:36 +07:00
|
|
|
style="border-radius: 0 0 40px 40px; position: relative"
|
2024-06-07 11:58:27 +07:00
|
|
|
>
|
|
|
|
|
<q-avatar no-padding size="50px">
|
2024-06-11 15:15:24 +07:00
|
|
|
<img :src="currentCustomerUrlImage ?? '/no-profile.png'" />
|
2024-06-07 11:58:27 +07:00
|
|
|
</q-avatar>
|
|
|
|
|
</q-card-section>
|
|
|
|
|
<div>
|
2024-06-07 15:05:22 +07:00
|
|
|
<div>{{ currentCustomerName }}</div>
|
2024-06-07 13:59:36 +07:00
|
|
|
<div class="row items-center">
|
2024-06-07 11:58:27 +07:00
|
|
|
<i
|
|
|
|
|
class="isax isax-frame5"
|
|
|
|
|
style="font-size: 1rem; color: var(--stone-6)"
|
|
|
|
|
/>
|
2024-06-07 13:59:36 +07:00
|
|
|
<div class="q-px-sm">
|
|
|
|
|
{{ '10' }}
|
|
|
|
|
</div>
|
2024-06-07 11:58:27 +07:00
|
|
|
<q-icon name="mdi-home" size="16px" style="color: var(--stone-6)" />
|
2024-06-07 13:59:36 +07:00
|
|
|
<div class="q-px-sm">
|
|
|
|
|
{{ '2' }}
|
|
|
|
|
</div>
|
2024-06-07 11:58:27 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-18 09:11:41 +00:00
|
|
|
|
2024-07-24 11:34:05 +07:00
|
|
|
<div
|
|
|
|
|
class="row items-center justify-end q-px-md col-12 col-sm q-py-sm no-wrap"
|
|
|
|
|
>
|
2024-06-07 11:58:27 +07:00
|
|
|
<q-input
|
2024-07-26 11:05:07 +07:00
|
|
|
lazy-rules="ondemand"
|
2024-06-07 11:58:27 +07:00
|
|
|
outlined
|
|
|
|
|
dense
|
2024-07-24 11:34:05 +07:00
|
|
|
class="col-6"
|
2024-06-07 13:59:36 +07:00
|
|
|
:label="$t('search')"
|
2024-06-07 11:58:27 +07:00
|
|
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
v-model="inputSearch"
|
|
|
|
|
debounce="500"
|
2024-07-17 07:38:44 +00:00
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="mdi-magnify" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
2024-06-07 11:58:27 +07:00
|
|
|
<q-btn
|
2024-07-17 07:38:44 +00:00
|
|
|
padding="10px 16px"
|
2024-06-07 11:58:27 +07:00
|
|
|
icon="mdi-tune-vertical-variant"
|
|
|
|
|
size="sm"
|
2024-06-07 13:59:36 +07:00
|
|
|
:color="$q.dark.isActive ? 'dark' : 'white'"
|
|
|
|
|
:text-color="$q.dark.isActive ? 'white' : 'dark'"
|
2024-07-24 11:34:05 +07:00
|
|
|
class="bordered rounded q-ml-sm col-1"
|
2024-06-07 11:58:27 +07:00
|
|
|
unelevated
|
|
|
|
|
>
|
|
|
|
|
<q-menu class="bordered">
|
|
|
|
|
<q-list v-close-popup dense>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
2024-06-14 13:03:20 +07:00
|
|
|
@click="currentStatus = 'All'"
|
2024-06-07 11:58:27 +07:00
|
|
|
>
|
|
|
|
|
{{ $t('all') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
2024-06-14 13:03:20 +07:00
|
|
|
@click="currentStatus = 'ACTIVE'"
|
2024-06-07 11:58:27 +07:00
|
|
|
>
|
|
|
|
|
{{ $t('statusACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item
|
|
|
|
|
clickable
|
|
|
|
|
class="flex items-center"
|
2024-06-14 13:03:20 +07:00
|
|
|
@click="currentStatus = 'INACTIVE'"
|
2024-06-07 11:58:27 +07:00
|
|
|
>
|
|
|
|
|
{{ $t('statusINACTIVE') }}
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-01 13:30:21 +07:00
|
|
|
<div
|
2024-07-24 02:04:47 +00:00
|
|
|
class="row q-pa-md q-col-gutter-md col scroll"
|
2024-07-15 07:39:06 +00:00
|
|
|
:class="{
|
|
|
|
|
'justify-center': totalBranch === 0,
|
|
|
|
|
'items-center': totalBranch === 0,
|
|
|
|
|
}"
|
2024-07-01 13:30:21 +07:00
|
|
|
>
|
|
|
|
|
<NoData v-if="totalBranch === 0" :not-found="!!inputSearch" />
|
|
|
|
|
|
2024-07-18 09:11:41 +00:00
|
|
|
<div v-for="(br, i) in branch" :key="i" class="col-md-6 col-12">
|
2024-06-10 15:57:12 +07:00
|
|
|
<BranchCardCustomer
|
2024-07-17 07:38:44 +00:00
|
|
|
class="surface-1"
|
2024-06-19 16:21:14 +07:00
|
|
|
:inactive="br.status === 'INACTIVE'"
|
2024-07-05 17:35:40 +07:00
|
|
|
:color="customerType === 'CORP' ? 'corp' : 'pers'"
|
2024-06-11 12:54:46 +07:00
|
|
|
:badgeField="['status']"
|
|
|
|
|
:data="{
|
|
|
|
|
customerBranchFormTab: br.branchNo,
|
|
|
|
|
branchName: br.name,
|
2024-07-05 17:35:40 +07:00
|
|
|
address:
|
|
|
|
|
$i18n.locale === 'en-US'
|
|
|
|
|
? `${br.addressEN || ''} ${br.subDistrict?.nameEN || ''} ${br.district?.nameEN || ''} ${br.province?.nameEN || ''}`
|
|
|
|
|
: `${br.address || ''} ${br.subDistrict?.name || ''} ${br.district?.name || ''} ${br.province?.name || ''}`,
|
2024-06-11 12:54:46 +07:00
|
|
|
telephone: br.telephoneNo,
|
2024-07-05 17:35:40 +07:00
|
|
|
businessTypePure: useOptionStore().mapOption(br.bussinessType),
|
2024-06-12 16:21:55 +07:00
|
|
|
totalEmployee: br._count?.employee,
|
2024-06-11 12:54:46 +07:00
|
|
|
}"
|
2024-07-05 17:35:40 +07:00
|
|
|
@view-detail="$emit('viewDetail', br, i)"
|
2024-06-10 15:57:12 +07:00
|
|
|
/>
|
2024-06-07 11:58:27 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-11 11:23:56 +07:00
|
|
|
|
2024-07-18 09:11:41 +00:00
|
|
|
<div class="row justify-between items-center q-px-md q-py-sm">
|
|
|
|
|
<div class="app-text-muted col offset-md-4">
|
2024-07-01 13:30:21 +07:00
|
|
|
{{
|
|
|
|
|
$t('recordsPage', {
|
|
|
|
|
resultcurrentPage: branch?.length,
|
|
|
|
|
total: totalBranch,
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
</div>
|
2024-07-15 07:39:06 +00:00
|
|
|
<div class="col-4 flex justify-end">
|
|
|
|
|
<PaginationComponent
|
|
|
|
|
v-model:current-page="currentPageBranch"
|
|
|
|
|
v-model:max-page="maxPageBranch"
|
|
|
|
|
:fetch-data="
|
|
|
|
|
async () => {
|
|
|
|
|
await fetchList();
|
|
|
|
|
flowStore.rotate();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-06-11 11:23:56 +07:00
|
|
|
</div>
|
2024-07-15 07:39:06 +00:00
|
|
|
</div>
|
2024-06-07 11:58:27 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-06-11 11:23:56 +07:00
|
|
|
<style scoped>
|
|
|
|
|
.color__purple {
|
|
|
|
|
background: hsl(var(--purple-11-hsl));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.color__green {
|
|
|
|
|
background: hsl(var(--teal-9-hsl));
|
|
|
|
|
}
|
|
|
|
|
</style>
|