Merge branch 'dev/net' into develop
This commit is contained in:
commit
eb0b09cb84
5 changed files with 130 additions and 88 deletions
|
|
@ -18,7 +18,7 @@ defineProps<{
|
||||||
class="text-h6 color-card-text-code"
|
class="text-h6 color-card-text-code"
|
||||||
:class="{ dark: $q.dark.isActive }"
|
:class="{ dark: $q.dark.isActive }"
|
||||||
>
|
>
|
||||||
Httw
|
{{ data?.code }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="q-pa-sm"
|
class="q-pa-sm"
|
||||||
|
|
@ -106,7 +106,7 @@ defineProps<{
|
||||||
|
|
||||||
<div class="row card-details-row-height">
|
<div class="row card-details-row-height">
|
||||||
<div class="col-3 color-text-static">Zip code</div>
|
<div class="col-3 color-text-static">Zip code</div>
|
||||||
<div class="col-2">{{ data?.code }}</div>
|
<div class="col-2">{{ data?.zipCode }}</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ const open = defineModel('open', { type: Boolean, default: false });
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
:width="500"
|
:width="500"
|
||||||
:breakpoint="500"
|
:breakpoint="500"
|
||||||
:model-value="true"
|
|
||||||
v-model="open"
|
v-model="open"
|
||||||
>
|
>
|
||||||
<q-toolbar class="q-mb-md q-pa-none">
|
<q-toolbar class="q-mb-md q-pa-none">
|
||||||
|
|
@ -32,7 +31,7 @@ const open = defineModel('open', { type: Boolean, default: false });
|
||||||
dense
|
dense
|
||||||
icon="mdi-close"
|
icon="mdi-close"
|
||||||
color="red"
|
color="red"
|
||||||
@click="() => $emit('open')"
|
@click="open = false"
|
||||||
id="fileFormIconClose"
|
id="fileFormIconClose"
|
||||||
/>
|
/>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Icon } from '@iconify/vue';
|
||||||
import { QTableProps } from 'quasar';
|
import { QTableProps } from 'quasar';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
|
@ -10,9 +11,9 @@ const props = defineProps<{
|
||||||
name: string;
|
name: string;
|
||||||
branchName: string;
|
branchName: string;
|
||||||
address: string;
|
address: string;
|
||||||
phonNumber: string;
|
telephoneNo: string;
|
||||||
Headquarters: string;
|
code: string;
|
||||||
type: string;
|
type: boolean;
|
||||||
status: string;
|
status: string;
|
||||||
}[];
|
}[];
|
||||||
}>();
|
}>();
|
||||||
|
|
@ -35,8 +36,8 @@ const columns = [
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{ name: 'address', label: 'ที่อยู่', field: 'address', sortable: true },
|
{ name: 'address', label: 'ที่อยู่', field: 'address', sortable: true },
|
||||||
{ name: 'phonNumber', label: 'เบอร์โทร', field: 'phonNumber' },
|
{ name: 'telephoneNo', label: 'เบอร์โทร', field: 'telephoneNo' },
|
||||||
{ name: 'Headquarters', label: 'สำนักงานใหญ่', field: 'Headquarters' },
|
{ name: 'code', label: 'สำนักงานใหญ่', field: 'code' },
|
||||||
{ name: 'type', label: 'ประเภท', field: 'type' },
|
{ name: 'type', label: 'ประเภท', field: 'type' },
|
||||||
{ name: 'status', label: 'สถานะ', field: 'status' },
|
{ name: 'status', label: 'สถานะ', field: 'status' },
|
||||||
] satisfies QTableProps['columns'];
|
] satisfies QTableProps['columns'];
|
||||||
|
|
@ -58,7 +59,7 @@ const filter = ref('');
|
||||||
hide-header
|
hide-header
|
||||||
>
|
>
|
||||||
<template v-slot:item="prop">
|
<template v-slot:item="prop">
|
||||||
<div class="q-pr-sm">
|
<div class="q-pr-sm q-pb-md">
|
||||||
<q-card class="bordered" style="width: 340px">
|
<q-card class="bordered" style="width: 340px">
|
||||||
<q-item
|
<q-item
|
||||||
class="bordered"
|
class="bordered"
|
||||||
|
|
@ -77,14 +78,31 @@ const filter = ref('');
|
||||||
|
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ v }}
|
<div v-if="k !== 'type'">
|
||||||
|
{{ v }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-if="v">สำนักงานใหญ่</div>
|
||||||
|
<div v-else>สาขา</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<q-space />
|
<q-space />
|
||||||
|
|
||||||
<iconify-icon
|
<q-space />
|
||||||
class="cursor-pointer"
|
|
||||||
v-if="i === 0"
|
<Icon
|
||||||
width="20px"
|
|
||||||
icon="mdi:navigate-next"
|
icon="mdi:navigate-next"
|
||||||
|
class="cursor-pointer"
|
||||||
|
v-if="i === 0 && !subBranch"
|
||||||
|
width="20px"
|
||||||
|
@click="$emit('navigate', prop.row)"
|
||||||
|
/>
|
||||||
|
<Icon
|
||||||
|
icon="mdi:navigate-next"
|
||||||
|
class="cursor-pointer"
|
||||||
|
v-if="i === 0 && subBranch"
|
||||||
|
width="20px"
|
||||||
|
@click="$emit('showCard', prop.row)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
|
|
@ -52,21 +52,31 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchById(
|
async function fetchById<T extends Branch>(
|
||||||
id: string,
|
id: string,
|
||||||
|
opts?: { includeSubBranch?: boolean },
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
refTransactionId: string;
|
refTransactionId: string;
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const res = await api.get<Branch>(`/branch/${id}`, {
|
const params = new URLSearchParams();
|
||||||
headers: {
|
|
||||||
'X-Session-Id': flow?.sessionId,
|
if (opts?.includeSubBranch) params.append('includeSubBranch', 'true');
|
||||||
'X-Rtid': flow?.refTransactionId,
|
|
||||||
'X-Tid': flow?.transactionId,
|
const query = params.toString();
|
||||||
|
|
||||||
|
const res = await api.get<T>(
|
||||||
|
`/branch/${id}${(params && '?'.concat(query)) || ''}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
'X-Rtid': flow?.refTransactionId,
|
||||||
|
'X-Tid': flow?.transactionId,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (res.status === 200) return res.data;
|
if (res.status === 200) return res.data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue