diff --git a/src/api/appeal/api.appeal.ts b/src/api/appeal/api.appeal.ts index 7fb0a1f..daa4886 100644 --- a/src/api/appeal/api.appeal.ts +++ b/src/api/appeal/api.appeal.ts @@ -7,15 +7,7 @@ export default { profileBykeycloak: () => `${profile}`, // positionBykeycloak: () => `${env.API_URI}/org/profile/keycloak/position`, - appealMainList: ( - status: string, - type: string, - year: number, - page: number, - pageSize: number, - keyword: string - ) => - `${appeal}/user?status=${status}&type=${type}&year=${year}&page=${page}&pageSize=${pageSize}&keyword=${keyword}`, + appealMainList: () => `${appeal}/user`, appealAdd: () => `${appeal}`, appealByID: (id: string) => `${appeal}/${id}`, diff --git a/src/components/TableD.vue b/src/components/TableD.vue index a669956..691aef7 100644 --- a/src/components/TableD.vue +++ b/src/components/TableD.vue @@ -138,9 +138,9 @@ function onRequest(requestProp: any) { ...newPagination, }; - if (isPageChange) { - emit("request", requestProp); - } + // if (isPageChange) { + emit("request", requestProp); + // } } function handlePageChange(newPage: number) { diff --git a/src/components/Workflow/DialogSelectPerson.vue b/src/components/Workflow/DialogSelectPerson.vue index 9dfae70..d2fc964 100644 --- a/src/components/Workflow/DialogSelectPerson.vue +++ b/src/components/Workflow/DialogSelectPerson.vue @@ -7,9 +7,9 @@ import http from "@/plugins/http"; import config from "@/app.config"; import type { QTableProps } from "quasar"; -import type { Pagination } from "@/components/Workflow/interface/index/Main"; import type { DataQuery } from "@/components/Workflow/interface/request/Main"; import type { DataCommander } from "@/components/Workflow/interface/response/Main"; +import type { PropsTable } from "@/interface/PropsTable"; import DialogHeader from "@/components/DialogHeader.vue"; @@ -76,17 +76,19 @@ const columns = ref([ style: "font-size: 14px", }, ]); - -const total = ref(0); -const totalList = ref(1); +const pagination = ref({ + sortBy: "", + descending: true, + page: 1, + rowsPerPage: 10, + rowsNumber: 0, +}); const isAcceptSetting = ref(false); const isApproveSetting = ref(false); const isReasonSetting = ref(false); const formDataQuery = reactive({ - page: 1, - pageSize: 10, isAct: false, keyword: "", }); @@ -97,12 +99,11 @@ async function fetchLists() { .put(config.API.workflow + `commander/${props.type}`, { ...formDataQuery, keycloakId: props.keycloakId, + page: pagination.value.page, + pageSize: pagination.value.rowsPerPage, }) .then(async (res) => { - totalList.value = Math.ceil( - res.data.result.total / formDataQuery.pageSize - ); - total.value = res.data.result.total; + pagination.value.rowsNumber = res.data.result.total; rows.value = res.data.result.data; }) .catch((err) => { @@ -139,7 +140,7 @@ function onSubmit() { } function onSearchData() { - formDataQuery.page = 1; + pagination.value.page = 1; fetchLists(); } @@ -150,32 +151,25 @@ function onCloseModal() { isAcceptSetting.value = false; isApproveSetting.value = false; isReasonSetting.value = false; - formDataQuery.page = 1; - formDataQuery.pageSize = 10; formDataQuery.isAct = false; formDataQuery.keyword = ""; } +/** + * ฟังก์ชันรับ request จากตาราง เมื่อมีการเปลี่ยน pagination + * @param requestProps ข้อมูลการร้องขอจากตาราง + */ +function onTableRequest(requestProps: PropsTable.RequestProps) { + const newPagination = requestProps?.pagination || requestProps; + if (!newPagination?.page || !newPagination?.rowsPerPage) return; + pagination.value = { ...newPagination }; +} + watch(modal, (val) => { if (val) { fetchLists(); } }); - -// watch( -// () => [formDataQuery.isAct, formDataQuery.pageSize], -// () => { -// onSearchData(); -// } -// ); - -/** - * function updatePagination - * @param newPagination ข้อมูล Pagination ใหม่ - */ -function updatePagination(newPagination: Pagination) { - formDataQuery.pageSize = newPagination.rowsPerPage; -}