refactor: เพิ่ม ของ list

This commit is contained in:
Net 2024-07-05 13:08:07 +07:00
parent a934f6cd83
commit 52f37e168d
2 changed files with 53 additions and 13 deletions

View file

@ -12,6 +12,7 @@ defineProps<{
metadata?: unknown; metadata?: unknown;
badgeField?: string[]; badgeField?: string[];
fieldSelected?: ( fieldSelected?: (
| 'branchLabelName'
| 'branchLabelAddress' | 'branchLabelAddress'
| 'branchLabelTel' | 'branchLabelTel'
| 'branchLabelType' | 'branchLabelType'

View file

@ -34,27 +34,27 @@ const labelBtnStatus = ref<string>(t('all'));
const columns = [ const columns = [
{ {
name: 'name', name: 'branchLabelName',
align: 'left', align: 'left',
label: 'office', label: 'office',
field: 'name', field: 'name',
sortable: true, sortable: true,
}, },
{ {
name: 'address', name: 'branchLabelAddress',
align: 'left', align: 'left',
label: 'address', label: 'address',
field: 'address', field: 'address',
sortable: true, sortable: true,
}, },
{ {
name: 'telephoneNo', name: 'branchLabelTel',
align: 'left', align: 'left',
label: 'formDialogInputTelephone', label: 'formDialogInputTelephone',
field: 'telephoneNo', field: 'telephoneNo',
}, },
{ {
name: 'isHeadOffice', name: 'branchLabelType',
align: 'left', align: 'left',
label: 'type', label: 'type',
field: 'isHeadOffice', field: 'isHeadOffice',
@ -169,10 +169,25 @@ const beforeBranch = ref<{ id: string; code: string }>({
const inputSearch = ref<string>(''); const inputSearch = ref<string>('');
const fieldBranch = ref(['all', 'branchHQLabel', 'branchLabel']); const fieldBranch = ref(['all', 'branchHQLabel', 'branchLabel']);
const fieldDisplay = ref< const fieldDisplay = ref<
('branchLabelAddress' | 'branchLabelTel' | 'branchLabelType')[] (
>(['branchLabelTel', 'branchLabelAddress', 'branchLabelType']); | 'branchLabelName'
| 'branchLabelAddress'
| 'branchLabelTel'
| 'branchLabelType'
)[]
>([
'branchLabelName',
'branchLabelTel',
'branchLabelAddress',
'branchLabelType',
]);
const fieldSelected = ref< const fieldSelected = ref<
('branchLabelAddress' | 'branchLabelTel' | 'branchLabelType')[] (
| 'branchLabelName'
| 'branchLabelAddress'
| 'branchLabelTel'
| 'branchLabelType'
)[]
>(fieldDisplay.value); >(fieldDisplay.value);
const fieldSelectedBranch = ref<{ const fieldSelectedBranch = ref<{
label: string; label: string;
@ -807,7 +822,24 @@ watch(locale, () => {
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
<q-btn <q-select
id="select-field"
for="select-field"
:options="
fieldDisplay.map((v) => ({ label: $t(v), value: v }))
"
:display-value="$t('displayField')"
v-model="fieldSelected"
option-label="label"
option-value="value"
map-options
emit-value
outlined
multiple
dense
/>
<!-- <q-btn
id="btn-filter" id="btn-filter"
icon="mdi-tune-vertical-variant" icon="mdi-tune-vertical-variant"
size="sm" size="sm"
@ -853,7 +885,7 @@ watch(locale, () => {
</q-item> </q-item>
</q-list> </q-list>
</q-menu> </q-menu>
</q-btn> </q-btn> -->
<q-btn-toggle <q-btn-toggle
v-model="modeView" v-model="modeView"
@ -953,6 +985,7 @@ watch(locale, () => {
card-container-class="row q-col-gutter-md" card-container-class="row q-col-gutter-md"
row-key="name" row-key="name"
hide-pagination hide-pagination
:visible-columns="fieldSelected"
> >
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr class="surface-2" :props="props"> <q-tr class="surface-2" :props="props">
@ -990,7 +1023,9 @@ watch(locale, () => {
} }
" "
> >
<q-td> <q-td
v-if="fieldSelected.includes('branchLabelName')"
>
<div class="row items-center"> <div class="row items-center">
<div <div
:class="{ :class="{
@ -1023,13 +1058,17 @@ watch(locale, () => {
</div> </div>
</div> </div>
</q-td> </q-td>
<q-td> <q-td
v-if="fieldSelected.includes('branchLabelAddress')"
>
{{ props.row.address }} {{ props.row.address }}
</q-td> </q-td>
<q-td> <q-td v-if="fieldSelected.includes('branchLabelTel')">
{{ props.row.contact[0].telephoneNo }} {{ props.row.contact[0].telephoneNo }}
</q-td> </q-td>
<q-td> <q-td
v-if="fieldSelected.includes('branchLabelType')"
>
{{ {{
props.row.isHeadOffice props.row.isHeadOffice
? $t('branchHQLabel') ? $t('branchHQLabel')