เพิ่ม filter ประเภทคำสั่งหน้ารายการคำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-14 14:40:08 +07:00
parent 70670f4a4a
commit df29a5b02a
3 changed files with 65 additions and 5 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { reactive, ref } from "vue";
import { onMounted, reactive, ref } from "vue";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
@ -8,7 +8,10 @@ import { useCommandListStore } from "@/modules/18_command/store/ListStore";
import http from "@/plugins/http";
import config from "@/app.config";
import type { ItemTabs } from "@/modules/18_command/interface/index/Main";
import type {
ItemTabs,
DataOption,
} from "@/modules/18_command/interface/index/Main";
import type { FormQuery } from "@/modules/18_command/interface/request/Main";
import type { ResListCommand } from "@/modules/18_command/interface/response/Main";
@ -33,7 +36,11 @@ const queryParams = reactive<FormQuery>({
pageSize: 10, //
year: new Date().getFullYear(), //
keyword: "", //
commandTypeId: "",
});
const commandOpMain = ref<DataOption[]>([]);
const commandOp = ref<DataOption[]>([]);
const modalAdd = ref<boolean>(false); //
/**
@ -58,6 +65,26 @@ async function fetchListCommand() {
hideLoader();
});
}
/**
* งกนคนหาขอมลรายการประเภทคำส
* @param val คำทองการคนหา
* @param update function จาก quasar
*/
function filterSelector(val: string, update: Function) {
update(() => {
queryParams.commandTypeId = val ? "" : queryParams.commandTypeId;
commandOp.value = commandOpMain.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
onMounted(async () => {
const data = await store.fetchCommandType();
commandOpMain.value = data ? data : [];
commandOp.value = commandOpMain.value;
});
</script>
<template>
@ -65,7 +92,7 @@ async function fetchListCommand() {
<!-- toolbar -->
<q-card>
<q-toolbar class="q-pa-sm">
<q-toolbar class="q-pa-sm q-col-gutter-sm">
<datepicker
menu-class-name="modalfix"
v-model="queryParams.year"
@ -73,7 +100,7 @@ async function fetchListCommand() {
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="fetchListCommand"
@update:model-value="(queryParams.page = 1), fetchListCommand()"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -112,6 +139,32 @@ async function fetchListCommand() {
/>
<q-space />
<q-select
clearable
@clear="queryParams.page = 1"
class="select_ellipsis3"
v-model="queryParams.commandTypeId"
:label="`${'ประเภทคำสั่ง'}`"
dense
emit-value
map-options
option-label="name"
:options="commandOp"
option-value="id"
lazy-rules
use-input
@update:model-value="(queryParams.page = 1), fetchListCommand()"
outlined
style="width: 690px"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn) "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select>
<q-input
dense
outlined