feat: filter ทั้งหมด สาขาใหญ่ สาขา

This commit is contained in:
Net 2024-04-17 11:33:41 +07:00
parent 5442477e7d
commit c0008e1c18

View file

@ -60,7 +60,7 @@ onMounted(async () => {
watch(locale, () => { watch(locale, () => {
console.log(locale.value); console.log(locale.value);
}); });
const fieldBranch = ref(['all', 'branchHQLabel', 'branchLabel']);
const fieldDisplay = ref([ const fieldDisplay = ref([
'branchLabelName', 'branchLabelName',
'branchLabelTel', 'branchLabelTel',
@ -69,6 +69,14 @@ const fieldDisplay = ref([
'branchLabelStatus', 'branchLabelStatus',
]); ]);
const fieldSelected = ref<string[]>(fieldDisplay.value); const fieldSelected = ref<string[]>(fieldDisplay.value);
const fieldSelectedBranch = ref<{
label: string;
value: string;
}>({
label: 'ทั้งหมด',
value: 'all',
});
const stats = ref<{ count: number; label: string }[]>([]); const stats = ref<{ count: number; label: string }[]>([]);
const defaultFormData = { const defaultFormData = {
@ -155,16 +163,12 @@ function clearData() {
<div class="q-mb-md flex" style="gap: var(--size-4)"> <div class="q-mb-md flex" style="gap: var(--size-4)">
<div style="flex-grow: 1"> <div style="flex-grow: 1">
<q-select <q-select
:options="
fieldDisplay.map((v) => ({ label: $t(v), value: v }))
"
v-model="fieldSelected"
option-label="label"
option-value="value"
map-options
emit-value
outlined outlined
multiple v-model="fieldSelectedBranch"
:options="
fieldBranch.map((v) => ({ label: $t(v), value: v }))
"
:label="$t('select')"
dense dense
/> />
</div> </div>
@ -186,11 +190,13 @@ function clearData() {
</div> </div>
<div class="branch-container"> <div class="branch-container">
<BranchCard <BranchCard
v-for="item in branchData.result.map((v) => ({ v-for="item in branchData.result
.map((v) => ({
id: v.id, id: v.id,
hq: v.isHeadOffice, hq: v.isHeadOffice,
branchLabelCode: v.code, branchLabelCode: v.code,
branchLabelName: $i18n.locale === 'en-US' ? v.nameEN : v.name, branchLabelName:
$i18n.locale === 'en-US' ? v.nameEN : v.name,
branchLabelTel: v.telephoneNo, branchLabelTel: v.telephoneNo,
branchLabelAddress: branchLabelAddress:
$i18n.locale === 'en-US' $i18n.locale === 'en-US'
@ -200,7 +206,15 @@ function clearData() {
v.isHeadOffice ? 'branchHQLabel' : 'branchLabel', v.isHeadOffice ? 'branchHQLabel' : 'branchLabel',
), ),
branchLabelStatus: v.status, branchLabelStatus: v.status,
}))" }))
.filter(
(b) =>
fieldSelectedBranch.value === 'all' ||
b.hq ===
(fieldSelectedBranch.value === 'branchHQLabel'
? true
: false),
)"
:key="item.id" :key="item.id"
:data="item" :data="item"
:field-selected="fieldSelected" :field-selected="fieldSelected"