diff --git a/src/modules/02_transfer/views/Main.vue b/src/modules/02_transfer/views/Main.vue index 42624d7..80ad70d 100644 --- a/src/modules/02_transfer/views/Main.vue +++ b/src/modules/02_transfer/views/Main.vue @@ -20,7 +20,8 @@ const mixin = useCounterMixin(); const transferData = useTransferDataStore(); const { statusText } = transferData; -const { date2Thai, messageError, showLoader, hideLoader } = mixin; +const { date2Thai, messageError, showLoader, hideLoader, onSearchDataTable } = + mixin; const pagination = ref({ sortBy: "desc", @@ -30,6 +31,7 @@ const pagination = ref({ }); const rows = ref([]); +const rowsData = ref([]); const filter = ref(""); const visibleColumns = ref([ "no", @@ -123,7 +125,7 @@ async function fecthListTransfer() { .get(config.API.listUserTransfer()) .then((res) => { let data = res.data.result; - rows.value = data.map((e: TransferList) => ({ + const listData = data.map((e: TransferList) => ({ id: e.id, date: date2Thai(e.createdAt), status: e.status, @@ -135,6 +137,8 @@ async function fecthListTransfer() { salary: e.salary, transfer: e.organization, })); + rows.value = listData; + rowsData.value = listData; }) .catch((e: any) => { messageError($q, e); @@ -158,6 +162,14 @@ function clickBack() { router.push(`/`); } +function onSearch() { + rows.value = onSearchDataTable( + filter.value, + rowsData.value, + columns.value ? columns.value : [] + ); +} + /** * เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้ */ @@ -207,15 +219,10 @@ onMounted(async () => { debounce="300" placeholder="ค้นหา" style="max-width: 200px" + @keydown.enter="onSearch" > @@ -251,7 +258,6 @@ onMounted(async () => { :visible-columns="visibleColumns" :rows-per-page-options="[10, 25, 50, 100]" v-model:pagination="pagination" - :filter="filter" >