feat: ต่อ api ของ tree และ card
This commit is contained in:
parent
4867a19af5
commit
42d380b13d
1 changed files with 81 additions and 66 deletions
|
|
@ -11,6 +11,7 @@ import StatCardComponent from 'components/StatCardComponent.vue';
|
||||||
import CardDetailsComponent from 'src/components/01_branch-management/CardDetailsComponent.vue';
|
import CardDetailsComponent from 'src/components/01_branch-management/CardDetailsComponent.vue';
|
||||||
import DeatailsBranchDrawerComponent from 'src/components/01_branch-management/DeatailsBranchDrawerComponent.vue';
|
import DeatailsBranchDrawerComponent from 'src/components/01_branch-management/DeatailsBranchDrawerComponent.vue';
|
||||||
import FormDialog from 'src/components/FormDialog.vue';
|
import FormDialog from 'src/components/FormDialog.vue';
|
||||||
|
import TableCardComponent from 'src/components/01_branch-management/TableCardComponent.vue';
|
||||||
|
|
||||||
import { BranchWithChildren, Branch } from 'src/stores/branch/types';
|
import { BranchWithChildren, Branch } from 'src/stores/branch/types';
|
||||||
|
|
||||||
|
|
@ -19,10 +20,12 @@ const { data: branchData } = storeToRefs(branchStore);
|
||||||
|
|
||||||
const modal = ref<boolean>(false);
|
const modal = ref<boolean>(false);
|
||||||
|
|
||||||
const showCurrentBranch = ref<Branch | boolean | null>();
|
const showCurrentBranch = ref<Branch>();
|
||||||
|
|
||||||
const shape = ref<boolean>(false);
|
const shape = ref<boolean>(false);
|
||||||
const openBranchDrawer = ref<boolean>(true);
|
const openBranchDrawer = ref<boolean>(true);
|
||||||
|
const openCardDetails = ref<boolean>(false);
|
||||||
|
const openTableCard = ref<boolean>(true);
|
||||||
|
|
||||||
const inputSelectBranch = ref<string>('ทั้งหมด');
|
const inputSelectBranch = ref<string>('ทั้งหมด');
|
||||||
const inputFilter = ref<string>('คอลัมน์');
|
const inputFilter = ref<string>('คอลัมน์');
|
||||||
|
|
@ -43,14 +46,14 @@ const formData = ref({
|
||||||
tel: '',
|
tel: '',
|
||||||
gender: '',
|
gender: '',
|
||||||
email: '',
|
email: '',
|
||||||
addressL: {
|
addressTitle: {
|
||||||
address: '',
|
address: '',
|
||||||
province: '',
|
province: '',
|
||||||
district: '',
|
district: '',
|
||||||
subDistrict: '',
|
subDistrict: '',
|
||||||
zip: '',
|
zip: '',
|
||||||
},
|
},
|
||||||
addressEng: {
|
addressENTitle: {
|
||||||
address: '',
|
address: '',
|
||||||
province: '',
|
province: '',
|
||||||
district: '',
|
district: '',
|
||||||
|
|
@ -72,45 +75,6 @@ const inputEmailHeadOffice = ref<string>('');
|
||||||
|
|
||||||
const expanded = ref<string[]>([]);
|
const expanded = ref<string[]>([]);
|
||||||
|
|
||||||
const rows: {
|
|
||||||
name: string;
|
|
||||||
branchName: string;
|
|
||||||
address: string;
|
|
||||||
phonNumber: string;
|
|
||||||
Headquarters: string;
|
|
||||||
type: string;
|
|
||||||
status: string;
|
|
||||||
}[] = [
|
|
||||||
{
|
|
||||||
name: 'HQ0001',
|
|
||||||
branchName: 'จ็อบเวิร์ทเกอร์เซอร์วิส',
|
|
||||||
address: '192',
|
|
||||||
phonNumber: '0639195701',
|
|
||||||
Headquarters: 'HQ0001',
|
|
||||||
type: 'สำนักงานใหญ่',
|
|
||||||
status: 'เปิดใช้งาน',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'HQ0002',
|
|
||||||
branchName: 'จ็อบเวิร์ทเกอร์เซอร์วิส 2',
|
|
||||||
address: '192',
|
|
||||||
phonNumber: '0639195701',
|
|
||||||
Headquarters: 'HQ0001',
|
|
||||||
type: 'สำนักงานใหญ่',
|
|
||||||
status: 'เปิดใช้งาน',
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'HQ0002',
|
|
||||||
branchName: 'จ็อบเวิร์ทเกอร์เซอร์วิส 2',
|
|
||||||
address: '192',
|
|
||||||
phonNumber: '0639195701',
|
|
||||||
Headquarters: 'HQ0001',
|
|
||||||
type: 'สำนักงานใหญ่',
|
|
||||||
status: 'เปิดใช้งาน',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const branchStat = ref<
|
const branchStat = ref<
|
||||||
{
|
{
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|
@ -142,6 +106,19 @@ const branchStat = ref<
|
||||||
|
|
||||||
const treeData = ref<BranchWithChildren[]>([]);
|
const treeData = ref<BranchWithChildren[]>([]);
|
||||||
|
|
||||||
|
const subBranch = ref<boolean>(false);
|
||||||
|
const rowsBranch = ref<
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
branchName: string;
|
||||||
|
address: string;
|
||||||
|
telephoneNo: string;
|
||||||
|
code: string;
|
||||||
|
type: boolean;
|
||||||
|
status: string;
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
function openDialog() {
|
function openDialog() {
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
}
|
}
|
||||||
|
|
@ -150,26 +127,56 @@ async function getTree() {
|
||||||
const result = await branchStore.fetchList<BranchWithChildren>({
|
const result = await branchStore.fetchList<BranchWithChildren>({
|
||||||
tree: true,
|
tree: true,
|
||||||
});
|
});
|
||||||
if (result) treeData.value = result.result;
|
if (result) {
|
||||||
|
treeData.value = result.result;
|
||||||
|
rowsBranch.value = treeData.value
|
||||||
|
.filter((v) => v.isHeadOffice)
|
||||||
|
.map((v) => ({
|
||||||
|
name: v.id,
|
||||||
|
branchName: v.name,
|
||||||
|
address: v.address,
|
||||||
|
telephoneNo: v.telephoneNo,
|
||||||
|
code: v.code,
|
||||||
|
type: v.isHeadOffice,
|
||||||
|
status: v.status.toString(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
subBranch.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchBranch(id: string) {
|
async function fetchCard(id: string) {
|
||||||
if (typeof branchStore.fetchById(id) === 'object') {
|
const result = await branchStore.fetchById<Branch>(id);
|
||||||
showCurrentBranch.value = await branchStore.fetchById(id);
|
|
||||||
|
if (result) {
|
||||||
|
showCurrentBranch.value = result;
|
||||||
|
openCardDetails.value = true;
|
||||||
|
openTableCard.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function fetchSubBranch(id: string) {
|
||||||
|
const result = await branchStore.fetchById<BranchWithChildren>(id, {
|
||||||
|
includeSubBranch: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
rowsBranch.value = result.branch.map((v) => ({
|
||||||
|
name: v.id,
|
||||||
|
branchName: v.name,
|
||||||
|
address: v.address,
|
||||||
|
telephoneNo: v.telephoneNo,
|
||||||
|
code: v.code,
|
||||||
|
type: v.isHeadOffice,
|
||||||
|
status: v.status,
|
||||||
|
}));
|
||||||
|
subBranch.value = true;
|
||||||
|
openCardDetails.value = false;
|
||||||
|
openTableCard.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getTree();
|
getTree();
|
||||||
|
|
||||||
if (
|
|
||||||
typeof branchStore.fetchById('bfff119e-079d-4b56-9699-0466ade4b517') ===
|
|
||||||
'object'
|
|
||||||
) {
|
|
||||||
showCurrentBranch.value = await branchStore.fetchById(
|
|
||||||
'bfff119e-079d-4b56-9699-0466ade4b517',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -234,7 +241,7 @@ onMounted(async () => {
|
||||||
<AppBox class="no-padding row bordered-t" style="border-radius: 0">
|
<AppBox class="no-padding row bordered-t" style="border-radius: 0">
|
||||||
<div class="q-pa-md bg-branch-tree-box bordered-r" style="width: 21%">
|
<div class="q-pa-md bg-branch-tree-box bordered-r" style="width: 21%">
|
||||||
<div
|
<div
|
||||||
@click="() => console.log('test')"
|
@click="openDialog()"
|
||||||
class="btn-add col-2 text-weight-bold cursor-pointer color-card-branch-btn"
|
class="btn-add col-2 text-weight-bold cursor-pointer color-card-branch-btn"
|
||||||
>
|
>
|
||||||
<div class="text-h4 q-mr-md">+</div>
|
<div class="text-h4 q-mr-md">+</div>
|
||||||
|
|
@ -256,7 +263,7 @@ onMounted(async () => {
|
||||||
>
|
>
|
||||||
<template #default-header="prop">
|
<template #default-header="prop">
|
||||||
<div
|
<div
|
||||||
@click="fetchBranch(prop.node.id)"
|
@click="fetchSubBranch(prop.node.id)"
|
||||||
class="q-px-sm color-brach-tree-text"
|
class="q-px-sm color-brach-tree-text"
|
||||||
:class="{
|
:class="{
|
||||||
'color-tree-active': expanded.includes(prop.node.name),
|
'color-tree-active': expanded.includes(prop.node.name),
|
||||||
|
|
@ -346,7 +353,7 @@ onMounted(async () => {
|
||||||
</q-scroll-area>
|
</q-scroll-area>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col" style="overflow-y: auto">
|
<div v-if="openTableCard" class="col" style="overflow-y: auto">
|
||||||
<AppBox class="q-pb-none">
|
<AppBox class="q-pb-none">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
@ -379,11 +386,20 @@ onMounted(async () => {
|
||||||
</AppBox>
|
</AppBox>
|
||||||
|
|
||||||
<AppBox>
|
<AppBox>
|
||||||
<TableCardComponent :sub-branch="true" :rows="rows" />
|
<TableCardComponent
|
||||||
|
@navigate="(v) => fetchSubBranch(v.name)"
|
||||||
|
@showCard="(v) => fetchCard(v.name)"
|
||||||
|
:sub-branch="subBranch"
|
||||||
|
:rows="rowsBranch"
|
||||||
|
/>
|
||||||
</AppBox>
|
</AppBox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="false" class="col bordered" style="overflow-y: auto">
|
<div
|
||||||
|
v-if="openCardDetails"
|
||||||
|
class="col bordered"
|
||||||
|
style="overflow-y: auto"
|
||||||
|
>
|
||||||
<CardDetailsComponent
|
<CardDetailsComponent
|
||||||
:data="showCurrentBranch as Branch"
|
:data="showCurrentBranch as Branch"
|
||||||
class="q-pa-sm"
|
class="q-pa-sm"
|
||||||
|
|
@ -394,15 +410,14 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DeatailsBranchDrawerComponent
|
<DeatailsBranchDrawerComponent
|
||||||
@open="openBranchDrawer = !openBranchDrawer"
|
v-model:open="openBranchDrawer"
|
||||||
:open="openBranchDrawer"
|
|
||||||
:data="showCurrentBranch as Branch"
|
:data="showCurrentBranch as Branch"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormDialog
|
<FormDialog
|
||||||
v-model:modal="modal"
|
v-model:modal="modal"
|
||||||
v-model:addressL="formData.addressL"
|
address-title="test"
|
||||||
v-model:addressEng="formData.addressEng"
|
addressENTitle=""
|
||||||
title="เพิ่มสำนักงานใหญ่"
|
title="เพิ่มสำนักงานใหญ่"
|
||||||
addressLocaleTitle="ที่อยู่พนักงาน"
|
addressLocaleTitle="ที่อยู่พนักงาน"
|
||||||
addressEngTitle="ที่อยู่พนักงาน ENG"
|
addressEngTitle="ที่อยู่พนักงาน ENG"
|
||||||
|
|
@ -502,7 +517,7 @@ onMounted(async () => {
|
||||||
</AppBox>
|
</AppBox>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #mid-bottom>
|
<template #midBottom>
|
||||||
<div>
|
<div>
|
||||||
<div class="row full-width q-pb-md">
|
<div class="row full-width q-pb-md">
|
||||||
<div class="col q-pr-md">
|
<div class="col q-pr-md">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue