diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 063b61d8e..3e642aa5a 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -94,5 +94,8 @@ export default { orgCheckAvatar: (id: string) => `${orgProfile}/avatar/profileId/${id}`, changePosition: `${organization}/placement/change-position`, + changePositionById: `${organization}/placement/change-position/profile-all`, + changePositionByIdProfile: `${organization}/placement/change-position/profile`, + orgProfileReport: `${orgProfile}-employee/report`, }; diff --git a/src/components/Dialogs/AddPersonal.vue b/src/components/Dialogs/AddPersonal.vue index 1613ddf08..2f2a0903e 100644 --- a/src/components/Dialogs/AddPersonal.vue +++ b/src/components/Dialogs/AddPersonal.vue @@ -10,10 +10,20 @@ import { useDisciplineMainStore } from "@/modules/11_discipline/store/main"; const mainStore = useDisciplineMainStore(); +const total = ref(0); +const totalList = ref(1); + const $q = useQuasar(); const mixin = useCounterMixin(); const { dialogMessageNotify, showLoader, hideLoader } = mixin; +const pagination = ref({ + sortBy: "createdAt", + descending: true, + page: 1, + rowsPerPage: 10, +}); + interface typeOp { id: string; name: string; @@ -33,12 +43,12 @@ interface tableType { } const rows = ref([]); -const type = ref("idcard"); +const type = ref("citizenId"); const search = ref(""); const selected = ref([]); const typeOps = ref([ - { id: "idcard", name: "เลขประจำตัวประชาชน" }, + { id: "citizenId", name: "เลขประจำตัวประชาชน" }, { id: "firstname", name: "ชื่อ" }, { id: "lastname", name: "นามสกุล" }, ]); @@ -112,62 +122,73 @@ const searchRef = ref(null); async function searchInput() { searchRef.value.validate(); if (!searchRef.value.hasError) { - showLoader(); - const body = { - fieldName: type.value, - keyword: search.value, - }; - await http - .post(config.API.orgSearchPersonal(), body) - .then((res) => { - const data = res.data.result; - const list = data.map((e: any) => ({ - personId: e.id, - idcard: e.idcard, - prefix: e.prefix, - firstName: e.firstName, - lastName: e.lastName, - name: `${e.prefix}${e.firstName} ${e.lastName}`, - posNo: e.posNo ?? "-", - position: e.position ?? "-", - positionLevel: e.positionLevelName ?? "-", - salary: e.salary ?? "-", - organization: e.organization ?? "-", - phone: e.phone ?? "-", - email: e.email ?? "-", - root: e.root, - rootId: e.rootId, - rootShortName: e.rootShortName, - child1: e.child1, - child1Id: e.child1Id, - child1ShortName: e.child1ShortName, - child2: e.child2, - child2Id: e.child2Id, - child2ShortName: e.child2ShortName, - child3: e.child3, - child3Id: e.child3Id, - child3ShortName: e.child3ShortName, - child4: e.child4, - child4Id: e.child4Id, - child4ShortName: e.child4ShortName, - posMasterNo: e.posMasterNo, - posTypeId: e.posTypeId, - posTypeName: e.posTypeName, - posLevelId: e.posLevelId, - posLevelName: e.posLevelName, - })); - - rows.value = list; - }) - .catch((err) => { - console.log(err); - }) - .finally(() => { - hideLoader(); - }); + await getSearch(); } } +async function getSearch() { + showLoader(); + const body = { + fieldName: type.value, + keyword: search.value, + }; + await http + .post( + config.API.orgSearchPersonal() + + `?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}&searchKeyword=${search.value}`, + body + ) + .then((res) => { + const data = res.data.result.data; + totalList.value = Math.ceil( + res.data.result.total / pagination.value.rowsPerPage + ); + total.value = res.data.result.total; + const list = data.map((e: any) => ({ + personId: e.id, + idcard: e.citizenId, + prefix: e.prefix, + firstName: e.firstName, + lastName: e.lastName, + name: `${e.prefix ? e.prefix :''}${e.firstName ? e.firstName :''} ${e.lastName ? e.lastName :''}`, + posNo: e.posNo ?? "-", + position: e.position ?? "-", + positionLevel: e.positionLevelName ?? "-", + salary: e.salary ?? "-", + organization: e.organization ?? "-", + phone: e.phone ?? "-", + email: e.email ?? "-", + root: e.root, + rootId: e.rootId, + rootShortName: e.rootShortName, + child1: e.child1, + child1Id: e.child1Id, + child1ShortName: e.child1ShortName, + child2: e.child2, + child2Id: e.child2Id, + child2ShortName: e.child2ShortName, + child3: e.child3, + child3Id: e.child3Id, + child3ShortName: e.child3ShortName, + child4: e.child4, + child4Id: e.child4Id, + child4ShortName: e.child4ShortName, + posMasterNo: e.posMasterNo, + posTypeId: e.posTypeId, + posTypeName: e.posTypeName, + posLevelId: e.posLevelId, + posLevelName: e.posLevelName, + })); + + rows.value = list; + }) + .catch((err) => { + console.log(err); + }) + .finally(() => { + hideLoader(); + }); +} /** update เมื่อเปลี่ยน option */ function updateSelect() { search.value = ""; @@ -180,6 +201,19 @@ watch( } } ); + +function updatePagination(newPagination: any) { + pagination.value.page = 1; + pagination.value.rowsPerPage = newPagination.rowsPerPage; + +} + +watch( + () => pagination.value.rowsPerPage, + async () => { + await getSearch(); + } +);