diff --git a/src/modules/04_registry/components/PopupHistory.vue b/src/modules/04_registry/components/PopupHistory.vue index 73ef17ba7..4d0c622dc 100644 --- a/src/modules/04_registry/components/PopupHistory.vue +++ b/src/modules/04_registry/components/PopupHistory.vue @@ -9,7 +9,7 @@ import { useQuasar } from "quasar"; const myForm = ref(); const mixin = useCounterMixin(); -const { showLoader, hideLoader, messageError, date2Thai } = mixin; +const { showLoader, hideLoader, messageError, date2Thai, notifyError } = mixin; const $q = useQuasar(); const modal = ref(false); @@ -144,14 +144,18 @@ const clickSearch = async (type: string) => { .post(config.API.profileHistory(type), body) .then((res) => { let data = res.data.result; - rows.value = data.map((e: any) => ({ - id: e.id, - citizenId: e.citizenId, - name: e.firstName + " " + e.lastName, - posNo: e.posNo, - position: e.position, - date: date2Thai(e.date), - })); + if (data.length !== 0) { + rows.value = data.map((e: any) => ({ + id: e.id, + citizenId: e.citizenId, + name: e.firstName + " " + e.lastName, + posNo: e.posNo, + position: e.position, + date: date2Thai(e.date), + })); + } else { + notifyError($q, "ไม่มีข้อมูลที่ต้องการค้นหา"); + } }) .catch((err) => { messageError($q, err); @@ -164,17 +168,20 @@ const clickSearch = async (type: string) => { }); }; const options = ref([]); -// const filterFn = (val: string) => { -// options.value = positionOps.value; -// console.log(options.value); -// if (val !== "") { -// options.value = positionOps.value.filter( -// (e: any) => e.name.search(val) !== -1 -// ); -// console.log(options.value); - -// } -// }; +const filterFn = (val: string, update: any) => { + if (val === "") { + update(() => { + options.value = positionOps.value; + }); + return; + } else { + update(() => { + options.value = positionOps.value.filter( + (e) => e.name.search(val) !== -1 + ); + }); + } +}; const paging = ref(true); const pagination = ref({ @@ -290,7 +297,17 @@ const paginationLabel = (start: number, end: number, total: number) => { :label="`${' เลือกตำแหน่ง'}`" use-input input-debounce="0" - /> + @filter="filterFn" + behavior="menu" + > +