diff --git a/src/modules/05_leave/components/Table.vue b/src/modules/05_leave/components/Table.vue index b71361e..ca9c997 100644 --- a/src/modules/05_leave/components/Table.vue +++ b/src/modules/05_leave/components/Table.vue @@ -67,13 +67,18 @@ function updateVisible(value: []) { /** filter */ const year = ref(new Date().getFullYear()); -const type = ref("00000000-0000-0000-0000-000000000000"); -const status = ref("ALL"); + const filter = ref(""); /** function updateFilter*/ function filterTable() { - emit("update:filter", year.value, type.value, status.value, filter.value); + emit( + "update:filter", + year.value, + leaveStore.type, + leaveStore.status, + filter.value + ); } /** function updatePagination*/ @@ -134,7 +139,7 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => { currentPage.value, () => pagination.value.rowsPerPage], () => { @filter="(inputValue:any, doneFn:Function) => filterOption(inputValue, doneFn,'LeaveTypeOption' ) " + typeOptionsMain > + + currentPage.value, () => pagination.value.rowsPerPage], () => { ไม่มีข้อมูล - + + @@ -209,7 +238,6 @@ watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => { ref="table" flat bordered - v-bind="attrs" virtual-scroll :virtual-scroll-sticky-size-start="48" diff --git a/src/modules/05_leave/store.ts b/src/modules/05_leave/store.ts index 01ab30d..8ee99f6 100644 --- a/src/modules/05_leave/store.ts +++ b/src/modules/05_leave/store.ts @@ -12,7 +12,8 @@ import { useCounterMixin } from "@/stores/mixin" const mixin = useCounterMixin() const { date2Thai, messageError } = mixin const $q = useQuasar() - +const type = ref("00000000-0000-0000-0000-000000000000"); +const status = ref("ALL"); export const useLeaveStore = defineStore("Leave", () => { const tabValue = ref("calendar") const typeLeave = ref("") @@ -113,11 +114,13 @@ export const useLeaveStore = defineStore("Leave", () => { function filterOption(val: any, update: Function, refData: string) { switch (refData) { case "LeaveTypeOption": + type.value = '' update(() => { typeOptions.value = typeOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1) }) break case "LeaveStatusOption": + status.value = '' update(() => { statusOptions.value = statusOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1) }) @@ -389,5 +392,9 @@ export const useLeaveStore = defineStore("Leave", () => { convertStatud, resetForm2, fetchProfileOld, + type, + typeOptionsMain, + status, + statusOptionsMain } }) diff --git a/src/modules/05_leave/views/AddPage.vue b/src/modules/05_leave/views/AddPage.vue index 41bee0c..683e389 100644 --- a/src/modules/05_leave/views/AddPage.vue +++ b/src/modules/05_leave/views/AddPage.vue @@ -79,6 +79,20 @@ function onSubmit(postData: FormData, isLeave: boolean = true) { } } +const option = ref(dataStore.options); +/** + * function ค้นหาข้อมูลใน option + * @param val คำค้นหา + * @param update function + */ +function filterOptionFn(val: string, update: Function) { + update(() => { + option.value = dataStore.options.filter( + (e: any) => e.name.search(val) !== -1 + ); + }); +} + onMounted(async () => { if (dataStore.options.length == 0) { await fectOptionType(); @@ -103,7 +117,7 @@ onMounted(async () => {
สร้างใบลา
- +
@@ -124,7 +138,7 @@ onMounted(async () => { class="col-12 col-sm-6 col-md-4 inputgreen" outlined v-model="model" - :options="dataStore.options" + :options="option" option-value="code" option-label="name" emit-value @@ -135,7 +149,16 @@ onMounted(async () => { (modelSpecific = ''), dataStore.fetchProfile() " - /> + use-input + @filter="filterOptionFn" + > +