ฟิลเตอร์ วินัย/การลา

This commit is contained in:
STW_TTTY\stwtt 2024-07-10 15:11:22 +07:00
parent f48b559686
commit fba93a9fc7
10 changed files with 289 additions and 45 deletions

View file

@ -265,6 +265,31 @@ function resetFilter() {
filterKeyword.value = "";
getData();
}
const option = ref<any[]>(dataStore.statusOptions);
const optionType = ref<any[]>(type.value);
/**
* function นหาขอมลใน option
* @param val คำคนหา
* @param update function
*/
function filterOptionFn(val: string, update: Function) {
update(() => {
option.value = dataStore.statusOptions.filter(
(e: any) => e.name.search(val) !== -1
);
});
}
/**
* function นหาขอมลใน option
* @param val คำคนหา
* @param update function
*/
function filterOptionFnType(val: string, update: Function) {
update(() => {
optionType.value = type.value.filter((e: any) => e.name.search(val) !== -1);
});
}
/** เรียกใช้งาน ฟังชั่น ตอนเริ่มโหลดหน้า */
onMounted(async () => {
@ -390,16 +415,27 @@ onMounted(async () => {
map-options
option-label="name"
option-value="id"
:options="type"
:options="optionType"
@update:model-value="dataUpdate"
use-input
@filter="filterOptionFnType"
>
<template v-if="formData.type !== 'ALL'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="(formData.type = 'ALL'), dataUpdate()"
@click.stop.prevent="
(optionType = type),((formData.type = 'ALL')), dataUpdate()
"
class="cursor-pointer"
/>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-3">
@ -412,17 +448,30 @@ onMounted(async () => {
map-options
option-label="name"
option-value="id"
:options="dataStore.statusOptions"
:options="option"
@update:model-value="dataUpdate"
class="select_ellipsis2"
use-input
@filter="filterOptionFn"
>
<template v-if="formData.status !== 'ALL'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="(formData.status = 'ALL'), dataUpdate()"
@click.stop.prevent="
(option = dataStore.statusOptions),
(formData.status = 'ALL'),
dataUpdate()
"
class="cursor-pointer"
/> </template
></q-select>
/>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
</div>
</q-card>