From 1e061649e0dd7aec7602512707558e9b274cff08 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 13 Jun 2024 18:04:47 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B9=83=E0=B8=8A=E0=B9=89?= =?UTF-8?q?=E0=B8=87=E0=B8=B2=E0=B8=99=20=3D>=20=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B1=E0=B8=B1=E0=B8=9A=20ui=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 10 +- .../components/Users/DialogAddUser.vue | 449 ++++++++++++++---- .../02_users/interface/request/Main.ts | 1 + .../02_users/interface/response/Main.ts | 29 +- 4 files changed, 385 insertions(+), 104 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 59f15364..5f4e89eb 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -20,10 +20,10 @@ export default { /** position*/ orgPosPosition: `${orgPos}/position`, orgPosPositionById: (id: string) => `${orgPos}/position/${id}`, - orgPosPositionExecutive : () => `${orgPos}/position/executive`, + orgPosPositionExecutive: () => `${orgPos}/position/executive`, orgPosExecutive: `${orgPos}/executive`, orgPosType: `${orgPos}/type`, - orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, + orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, orgPosLevel: `${orgPos}/level`, orgPosMaster: `${orgPos}/master`, orgPosMasterById: (id: string) => `${orgPos}/master/${id}`, @@ -86,7 +86,9 @@ export default { orgProfileEmp: `${orgEmployeePos}/profile`, orgSearchProfileEmp: `${orgProfile}-employee/search`, - orgProfileById:(id:string,type:string)=>`${orgProfile}${type}/${id}`, + orgProfileById: (id: string, type: string) => `${orgProfile}${type}/${id}`, - orgDeceasedProfile:`${orgPos}/profile/search` + orgDeceasedProfile: `${orgPos}/profile/search`, + + orgProfileListKeycloak: () => `${orgProfile}/search-personal-no-keycloak`, }; diff --git a/src/modules/02_users/components/Users/DialogAddUser.vue b/src/modules/02_users/components/Users/DialogAddUser.vue index 0077bf44..53a9b144 100644 --- a/src/modules/02_users/components/Users/DialogAddUser.vue +++ b/src/modules/02_users/components/Users/DialogAddUser.vue @@ -4,10 +4,16 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; +import type { QTableProps } from "quasar"; +import type { + DataOption, + Pagination, +} from "@/modules/02_users/interface/index/Main"; import type { FormUser, Roles, } from "@/modules/02_users/interface/request/Main"; +import type { Profile } from "@/modules/02_users/interface/response/Main"; /** importComponents*/ import DialogHeader from "@/components/DialogHeader.vue"; @@ -31,9 +37,80 @@ const props = defineProps({ }, }); +/** Table*/ +const rows = ref([]); +const columns = ref([ + { + name: "citizenId", + align: "left", + label: "เลขประจำตัวประชาชน", + sortable: true, + field: "citizenId", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "firstName", + align: "left", + label: "ชื่อ", + sortable: true, + field: "firstName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "lastName", + align: "left", + label: "นามสกุล", + sortable: true, + field: "lastName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "position", + align: "left", + label: "ตำแหน่ง", + sortable: true, + field: "position", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionTpye", + align: "left", + label: "ประเภทตำแหน่ง", + sortable: true, + field: "positionTpye", + format: (val, row) => { + return ( + `${row.positionTypeName ? row.positionTypeName : ""}` + + (row.positionLevelName ? `(${row.positionLevelName})` : "") + ); + }, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, +]); +const selected = ref([]); +const searchType = ref("citizenId"); +const keyword = ref(""); +const searchTypeOption = ref([ + { id: "citizenId", name: "เลขประจำตัวประชาชน" }, + { id: "firstname", name: "ชื่อ" }, + { id: "lastname", name: "นามสกุล" }, +]); +const query = reactive({ + page: 1, + pageSize: 10, +}); +const total = ref(0); +const maxPage = ref(1); + const isPwd = ref(true); const roles = ref([]); const formData = reactive({ + profileId: "", username: "", password: "", firstName: "", @@ -41,9 +118,34 @@ const formData = reactive({ email: "", roles: [], }); -const roleOptionsMain = ref([]); const roleOptions = ref([]); +function fetchListUser() { + showLoader(); + const body = { + fieldName: searchType.value ? searchType.value : "", + keyword: keyword.value ? keyword.value : "", + }; + http + .post( + config.API.orgProfileListKeycloak() + + `?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.data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** * function fetch ข้อมูลผู้ใช้งาน * @param id ผู้ใช้งาน @@ -70,7 +172,6 @@ function fetchUserDetail(id: string) { /** function fetc รายการ role*/ function fetchlistRole() { - showLoader(); http .get(config.API.managementRole) .then((res) => { @@ -84,9 +185,6 @@ function fetchlistRole() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } @@ -121,14 +219,36 @@ function onSubmit() { /** function ปิด Dialog */ function closeDialog() { modal.value = false; + formData.profileId = ""; formData.username = ""; formData.password = ""; formData.firstName = ""; formData.lastName = ""; formData.email = ""; roles.value = []; + searchType.value = "citizenId"; + keyword.value = ""; + selected.value = []; + query.page = 1; + query.pageSize = 10; } +/** + * function อัปเดท paging + * @param initialPagination ข้อมูล pagination + */ +async function updatePagination(initialPagination: Pagination) { + query.page = 1; + query.pageSize = initialPagination.rowsPerPage; +} + +watch( + () => query.pageSize, + () => { + fetchListUser(); + } +); + watch( () => modal.value, () => { @@ -136,118 +256,249 @@ watch( fetchUserDetail(userId.value); } modal.value && fetchlistRole(); + modal.value && fetchListUser(); + } +); + +watch( + () => selected.value, + () => { + if (selected.value?.length !== 0) { + const data = selected.value[0]; + formData.profileId = data.id; + formData.firstName = data.firstName; + formData.lastName = data.lastName; + formData.email = data.email; + } } );