diff --git a/src/modules/09_leave/components/05_Leave/Tab1.vue b/src/modules/09_leave/components/05_Leave/Tab1.vue index 36777d5c4..61fd3cae1 100644 --- a/src/modules/09_leave/components/05_Leave/Tab1.vue +++ b/src/modules/09_leave/components/05_Leave/Tab1.vue @@ -17,7 +17,7 @@ import CalendarView from "@/modules/09_leave/components/05_Leave/Calendar.vue"; const $q = useQuasar(); //ใช้ noti quasar const mixin = useCounterMixin(); const leaveStore = useLeavelistDataStore(); -const dataToobar = ref([]); + const { showLoader, hideLoader, messageError } = mixin; const total = ref(0); @@ -29,14 +29,16 @@ const querySting = reactive({ status: leaveStore.filter.status, //*สถานะการของลา page: 1, //*สถานะการของลา pageSize: 10, //*สถานะการของลา + sortBy: "dateSendLeave", + descending: true, keyword: leaveStore.filter.keyword, //keyword ค้นหา - profileType: 'ALL', //profileType + profileType: "ALL", //profileType }); //** เรียกข้อมูลจาก API*/ async function fecthLeaveList() { leaveStore.rows = []; - querySting.keyword = querySting.keyword.trim() + querySting.keyword = querySting.keyword.trim(); querySting.status = await (querySting.status == null ? "ALL" : querySting.status); @@ -67,14 +69,16 @@ async function fecthLeaveList() { /** function เรียกข้อมูลสถานะ*/ async function fetchOption() { - await http - .get(config.API.leaveType()) - .then((res) => { - dataToobar.value = res.data.result; - }) - .catch((err) => { - messageError($q, err); - }); + if (leaveStore.dataToobar.length == 0) { + await http + .get(config.API.leaveType()) + .then((res) => { + leaveStore.leaveTypeOption(res.data.result); + }) + .catch((err) => { + messageError($q, err); + }); + } } function getSearch() { @@ -142,7 +146,7 @@ onMounted(async () => {
{ v-model:total="total" v-model:total-list="totalList" v-model:pagination="querySting" - :dataToobar="dataToobar" + :dataToobar="leaveStore.dataToobar" :getList="fecthLeaveList" />
diff --git a/src/modules/09_leave/components/05_Leave/Tab2.vue b/src/modules/09_leave/components/05_Leave/Tab2.vue index f86aec023..d4181f01c 100644 --- a/src/modules/09_leave/components/05_Leave/Tab2.vue +++ b/src/modules/09_leave/components/05_Leave/Tab2.vue @@ -20,7 +20,6 @@ const mixin = useCounterMixin(); const leaveStore = useLeavelistDataStore(); const { showLoader, hideLoader, messageError } = mixin; const { fetchListLeaveReject } = leaveStore; -const dataToobar = ref([]); const $q = useQuasar(); //ใช้ noti quasar const total = ref(0); @@ -32,13 +31,15 @@ const querySting = reactive({ status: leaveStore.filter.status, //*สถานะการของลา page: 1, //*สถานะการของลา pageSize: 10, //*สถานะการของลา + sortBy: "dateSendLeave", + descending: true, keyword: leaveStore.filter.keyword, //keyword ค้นหา - profileType: 'ALL', //profileType + profileType: "ALL", //profileType }); //** เรียกข้อมูลจาก API*/ async function fecthLeaveList() { leaveStore.rows = []; - querySting.keyword = querySting.keyword.trim() + querySting.keyword = querySting.keyword.trim(); querySting.status = await (querySting.status == null ? "ALL" : querySting.status); @@ -69,14 +70,16 @@ async function fecthLeaveList() { /** function เรียกข้อมูลสถานะ*/ async function fetchOption() { - await http - .get(config.API.leaveType()) - .then((res) => { - dataToobar.value = res.data.result; - }) - .catch((err) => { - messageError($q, err); - }); + if (leaveStore.dataToobar.length == 0) { + await http + .get(config.API.leaveType()) + .then((res) => { + leaveStore.leaveTypeOption(res.data.result); + }) + .catch((err) => { + messageError($q, err); + }); + } } function getSearch() { @@ -97,7 +100,7 @@ onMounted(async () => { diff --git a/src/modules/09_leave/components/05_Leave/TableList.vue b/src/modules/09_leave/components/05_Leave/TableList.vue index 8ae79f261..f75cdd5e7 100644 --- a/src/modules/09_leave/components/05_Leave/TableList.vue +++ b/src/modules/09_leave/components/05_Leave/TableList.vue @@ -280,6 +280,7 @@ onMounted(() => { :paging="true" dense class="custom-header-table" + v-model:pagination="pagination" :visible-columns="leaveStore.visibleColumns" :rows-per-page-options="[10, 25, 50, 100]" @update:pagination="updatePagination" diff --git a/src/modules/09_leave/components/05_Leave/ToolBarLeave.vue b/src/modules/09_leave/components/05_Leave/ToolBarLeave.vue index 6526523bd..ffffa266b 100644 --- a/src/modules/09_leave/components/05_Leave/ToolBarLeave.vue +++ b/src/modules/09_leave/components/05_Leave/ToolBarLeave.vue @@ -86,7 +86,8 @@ function filterOption(val: string, update: any, name: string) { update(() => { const needle = val.toLowerCase(); if (name === "type") { - optionType.value = optionTypeMain.value.filter( + const dataOp = leaveStore.dataToobar; + optionType.value = dataOp.filter( (v: any) => v.name.toLowerCase().indexOf(needle) > -1 ); } else if (name === "status") { @@ -108,27 +109,6 @@ function filterOptionFn(val: string, update: Function) { roleOp.value = data.filter((e: any) => e.name.search(val) !== -1); }); } - -watch( - async () => props.dataToobar, - () => { - if (props.dataToobar) { - const data = props.dataToobar; - leaveStore.leaveType = data; - optionTypeMain.value = [ - { id: "00000000-0000-0000-0000-000000000000", name: "ทั้งหมด" }, - ]; - - const option = data.map((e: any) => ({ - id: e.id, - name: e.name, - })); - - optionTypeMain.value.push(...option); - optionType.value = optionTypeMain.value; - } - } -);