diff --git a/src/modules/14_KPI/components/Tab/Dialog/DialogEvalute.vue b/src/modules/14_KPI/components/Tab/Dialog/DialogEvalute.vue index 34ad06b95..da9473b55 100644 --- a/src/modules/14_KPI/components/Tab/Dialog/DialogEvalute.vue +++ b/src/modules/14_KPI/components/Tab/Dialog/DialogEvalute.vue @@ -10,7 +10,7 @@ import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue"; import type { DataOption, typeOp, - ResponsePreson, + NewPagination, tableType, FormData, } from "@/modules/14_KPI/interface/index/Main"; @@ -22,10 +22,10 @@ const personId = ref(""); const modalPersonal = ref(false); const searchRef = ref(null); const rows = ref([]); -const type = ref("idcard"); +const type = ref("citizenId"); const search = ref(""); const typeOps = ref([ - { id: "idcard", name: "เลขประจำตัวประชาชน" }, + { id: "citizenId", name: "เลขประจำตัวประชาชน" }, { id: "firstname", name: "ชื่อ" }, { id: "lastname", name: "นามสกุล" }, ]); @@ -96,9 +96,8 @@ function onCloseDialog() { formRound.commanderHighId = ""; selected.value = []; search.value = ""; - type.value = "idcard"; + type.value = "citizenId"; } - /** หัวข้อที่เเสดงในตารางผู้ถูกร้องเรียน */ const visibleColumnsRespondent = ref([ "no", @@ -112,13 +111,18 @@ const visibleColumnsRespondent = ref([ "organization", ]); +const query = reactive({ + page: 1, + pageSize: 10, +}); const columnsRespondent = ref([ { name: "no", align: "left", label: "ลำดับ", sortable: false, - field: "no", + field: (row) => + (query.page - 1) * query.pageSize + rows.value.indexOf(row) + 1, headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -223,6 +227,9 @@ function checkClosed() { isRoundClose.value = formRound.kpiPeriodId.isClosed; } +const total = ref(0); +const maxPage = ref(1); + async function searchInput(check: boolean) { if (check) { searchRules.value = check; @@ -234,13 +241,21 @@ async function searchInput(check: boolean) { keyword: search.value, }; await http - .post(config.API.orgSearchPersonal(), body) + .post( + config.API.orgSearchPersonal() + + `?page=${query.page}&pageSize=${query.pageSize}`, + body + ) .then((res) => { const data = res.data.result; + maxPage.value = Math.ceil(data.total / query.pageSize); + total.value = data.total; - rows.value = data; + rows.value = data.data; + }) + .catch((err) => { + messageError($q, err); }) - .catch((err) => {}) .finally(() => { hideLoader(); }); @@ -263,15 +278,21 @@ function getOrgOp() { const data = res.data.result; evaluatorIdMainOp.value = data.caregiver.map((i: any) => ({ id: i.id, - name: `${i.prefix ? i.prefix :''}${i.firstName ? i.firstName : ''} ${i.lastName ? i.lastName:''}`, + name: `${i.prefix ? i.prefix : ""}${i.firstName ? i.firstName : ""} ${ + i.lastName ? i.lastName : "" + }`, })); commanderIdMainOp.value = data.commander.map((i: any) => ({ id: i.id, - name: `${i.prefix ? i.prefix :''}${i.firstName ? i.firstName : ''} ${i.lastName ? i.lastName:''}`, + name: `${i.prefix ? i.prefix : ""}${i.firstName ? i.firstName : ""} ${ + i.lastName ? i.lastName : "" + }`, })); commanderHighMainOp.value = data.chairman.map((i: any) => ({ id: i.id, - name: `${i.prefix ? i.prefix :''}${i.firstName ? i.firstName : ''} ${i.lastName ? i.lastName:''}`, + name: `${i.prefix ? i.prefix : ""}${i.firstName ? i.firstName : ""} ${ + i.lastName ? i.lastName : "" + }`, })); }) .catch((e) => { @@ -329,6 +350,22 @@ watch( } } ); + +/** + * function อัปเดท paging + * @param initialPagination ข้อมูล pagination + */ +async function updatePagination(initialPagination: NewPagination) { + query.page = 1; + query.pageSize = initialPagination.rowsPerPage; +} + +watch( + () => query.pageSize, + () => { + searchInput(true); + } +); @@ -389,11 +426,12 @@ watch( flat bordered selection="single" + :rows-per-page-options="[10, 25, 50, 100]" v-model:selected="selected" :paging="true" dense - class="custom-header-table" :visible-columns="visibleColumnsRespondent" + @update:pagination="updatePagination" > +