refactor: scroll inside

This commit is contained in:
Methapon2001 2024-07-05 12:09:45 +07:00
parent 4511137cc7
commit a934f6cd83

View file

@ -498,10 +498,7 @@ watch(locale, () => {
/> />
</transition> </transition>
<div <div class="column col surface-1 rounded" :no-padding="!!branchData.total">
class="column col surface-1 rounded scroll"
:no-padding="!!branchData.total"
>
<template v-if="!branchData.total"> <template v-if="!branchData.total">
<TooltipComponent <TooltipComponent
class="self-end" class="self-end"
@ -525,7 +522,7 @@ watch(locale, () => {
style="width: 100%" style="width: 100%"
> >
<template v-slot:before> <template v-slot:before>
<div class="rounded surface-1 full-height"> <div class="rounded surface-1 scroll">
<div <div
class="row bordered-b q-pl-sm text-weight-bold surface-2 items-center" class="row bordered-b q-pl-sm text-weight-bold surface-2 items-center"
style="height: 50px" style="height: 50px"
@ -733,7 +730,7 @@ watch(locale, () => {
</template> </template>
<template v-slot:after> <template v-slot:after>
<div class="full-width"> <div class="column" style="height: 100%">
<div <div
class="row justify-between q-pl-md items-center surface-2 bordered-b q-pr-md" class="row justify-between q-pl-md items-center surface-2 bordered-b q-pr-md"
style="height: 50px" style="height: 50px"
@ -905,160 +902,77 @@ watch(locale, () => {
</q-btn-toggle> </q-btn-toggle>
</div> </div>
</div> </div>
<div class="q-pa-md"> <div style="position: relative; flex: 1">
<q-table <div
flat style="position: absolute; inset: 0"
bordered class="scroll q-pa-md"
:rows="
treeData
.flatMap((v) => [v, ...v.branch])
.filter((v) => {
if (
statusFilter === 'statusACTIVE' &&
v.status === 'INACTIVE'
) {
return false;
}
if (
statusFilter === 'statusINACTIVE' &&
v.status !== 'INACTIVE'
) {
return false;
}
const terms = `${v.code} ${$i18n.locale === 'en-US' ? v.nameEN : v.name} ${v.telephoneNo}`;
if (inputSearch && !terms.includes(inputSearch)) {
return false;
}
if (
!!currentHq.id &&
currentHq.id === v.headOfficeId
) {
return true;
}
if (fieldSelectedBranch.value === 'all') return true;
if (fieldSelectedBranch.value === 'branchHQLabel')
return v.isHeadOffice;
if (fieldSelectedBranch.value === 'branchLabel')
return !v.isHeadOffice;
return false;
})
"
:columns="columns"
:grid="modeView"
card-container-class="row q-col-gutter-md"
row-key="name"
hide-pagination
> >
<template v-slot:header="props"> <q-table
<q-tr class="surface-2" :props="props"> flat
<q-th bordered
v-for="col in props.cols" :rows="
:key="col.name" treeData
:props="props" .flatMap((v) => [v, ...v.branch])
> .filter((v) => {
{{ $t(col.label) }} if (
</q-th> statusFilter === 'statusACTIVE' &&
<q-th auto-width /> v.status === 'INACTIVE'
</q-tr> ) {
</template> return false;
}
<template v-slot:body="props"> if (
<q-tr statusFilter === 'statusINACTIVE' &&
:class="{ v.status !== 'INACTIVE'
'app-text-muted': props.row.status === 'INACTIVE', ) {
}" return false;
:props="props"
@click="
() => {
if (props.row.isHeadOffice) {
fieldSelectedBranch.value = '';
inputSearch = '';
currentHq = {
id: props.row.id,
code: props.row.code,
};
beforeBranch = {
id: '',
code: '',
};
} }
}
"
>
<q-td>
<div class="row items-center">
<div
:class="{
'status-active':
props.row.status !== 'INACTIVE',
'status-inactive':
props.row.status === 'INACTIVE',
'branch-card__hq': props.row.isHeadOffice,
'branch-card__br': !props.row.isHeadOffice,
}"
style="
width: 50px;
display: flex;
margin-bottom: var(--size-2);
"
>
<div class="branch-card__icon">
<q-icon
size="md"
style="scale: 0.8"
name="mdi-office-building-outline"
/>
</div>
</div>
<div class="col">
<div class="col">{{ props.row.name }}</div>
<div class="col app-text-muted">
{{ props.row.code }}
</div>
</div>
</div>
</q-td>
<q-td>
{{ props.row.address }}
</q-td>
<q-td>
{{ props.row.contact[0].telephoneNo }}
</q-td>
<q-td>
{{
props.row.isHeadOffice
? $t('branchHQLabel')
: $t('branchLabel')
}}
</q-td>
<q-td>
<q-btn
icon="mdi-eye"
size="sm"
dense
round
flat
@click.stop
/>
<q-btn
icon="mdi-dots-vertical"
size="sm"
dense
round
flat
@click.stop
/>
</q-td>
</q-tr>
</template>
<template v-slot:item="props"> const terms = `${v.code} ${$i18n.locale === 'en-US' ? v.nameEN : v.name} ${v.telephoneNo}`;
<div class="col-6"> if (inputSearch && !terms.includes(inputSearch)) {
<BranchCard return false;
:id="`branch-card-${props.row.name}`" }
if (
!!currentHq.id &&
currentHq.id === v.headOfficeId
) {
return true;
}
if (fieldSelectedBranch.value === 'all')
return true;
if (fieldSelectedBranch.value === 'branchHQLabel')
return v.isHeadOffice;
if (fieldSelectedBranch.value === 'branchLabel')
return !v.isHeadOffice;
return false;
})
"
:columns="columns"
:grid="modeView"
card-container-class="row q-col-gutter-md"
row-key="name"
hide-pagination
>
<template v-slot:header="props">
<q-tr class="surface-2" :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
{{ $t(col.label) }}
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr
:class="{
'app-text-muted': props.row.status === 'INACTIVE',
}"
:props="props"
@click=" @click="
() => { () => {
if (props.row.isHeadOffice) { if (props.row.isHeadOffice) {
@ -1075,45 +989,134 @@ watch(locale, () => {
} }
} }
" "
:metadata="props.row" >
:color="props.row.isHeadOffice ? 'hq' : 'br'" <q-td>
:key="props.row.id" <div class="row items-center">
:data="{ <div
branchLabelCode: props.row.code, :class="{
branchLabelName: 'status-active':
$i18n.locale === 'en-US' props.row.status !== 'INACTIVE',
? props.row.nameEN 'status-inactive':
: props.row.name, props.row.status === 'INACTIVE',
branchLabelTel: props.row.contact 'branch-card__hq': props.row.isHeadOffice,
.map((c: BranchContact) => c.telephoneNo) 'branch-card__br': !props.row.isHeadOffice,
.join(','), }"
branchLabelAddress: style="
$i18n.locale === 'en-US' width: 50px;
? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}` display: flex;
: `${props.row.address || ''} ${props.row.subDistrict?.name || ''} ${props.row.district?.name || ''} ${props.row.province?.name || ''}`, margin-bottom: var(--size-2);
branchLabelType: $t( "
>
<div class="branch-card__icon">
<q-icon
size="md"
style="scale: 0.8"
name="mdi-office-building-outline"
/>
</div>
</div>
<div class="col">
<div class="col">{{ props.row.name }}</div>
<div class="col app-text-muted">
{{ props.row.code }}
</div>
</div>
</div>
</q-td>
<q-td>
{{ props.row.address }}
</q-td>
<q-td>
{{ props.row.contact[0].telephoneNo }}
</q-td>
<q-td>
{{
props.row.isHeadOffice props.row.isHeadOffice
? 'branchHQLabel' ? $t('branchHQLabel')
: 'branchLabel', : $t('branchLabel')
), }}
}" </q-td>
:field-selected="fieldSelected" <q-td>
:badge-field="['branchLabelStatus']" <q-btn
:inactive="props.row.status === 'INACTIVE'" icon="mdi-eye"
@view-detail=" size="sm"
(v) => { dense
triggerEdit( round
'drawer', flat
v.id, @click.stop
v.isHeadOffice ? 'headOffice' : 'subBranch', />
v.code, <q-btn
); icon="mdi-dots-vertical"
} size="sm"
" dense
/> round
</div> flat
</template> @click.stop
</q-table> />
</q-td>
</q-tr>
</template>
<template v-slot:item="props">
<div class="col-6">
<BranchCard
:id="`branch-card-${props.row.name}`"
@click="
() => {
if (props.row.isHeadOffice) {
fieldSelectedBranch.value = '';
inputSearch = '';
currentHq = {
id: props.row.id,
code: props.row.code,
};
beforeBranch = {
id: '',
code: '',
};
}
}
"
:metadata="props.row"
:color="props.row.isHeadOffice ? 'hq' : 'br'"
:key="props.row.id"
:data="{
branchLabelCode: props.row.code,
branchLabelName:
$i18n.locale === 'en-US'
? props.row.nameEN
: props.row.name,
branchLabelTel: props.row.contact
.map((c: BranchContact) => c.telephoneNo)
.join(','),
branchLabelAddress:
$i18n.locale === 'en-US'
? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}`
: `${props.row.address || ''} ${props.row.subDistrict?.name || ''} ${props.row.district?.name || ''} ${props.row.province?.name || ''}`,
branchLabelType: $t(
props.row.isHeadOffice
? 'branchHQLabel'
: 'branchLabel',
),
}"
:field-selected="fieldSelected"
:badge-field="['branchLabelStatus']"
:inactive="props.row.status === 'INACTIVE'"
@view-detail="
(v) => {
triggerEdit(
'drawer',
v.id,
v.isHeadOffice ? 'headOffice' : 'subBranch',
v.code,
);
}
"
/>
</div>
</template>
</q-table>
</div>
<!-- <BranchCard <!-- <BranchCard
class="col-6" class="col-6"