From 1a4163e76ac2d374a720ef217ffb5e062160b178 Mon Sep 17 00:00:00 2001 From: Thanit Konmek Date: Mon, 24 Jul 2023 14:41:52 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=87=20popup=20=E0=B8=81=E0=B8=B3=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B8=94=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.treelist.ts | 10 +- .../views/MainTreeEmployee.vue | 8 +- .../08_registryEmployee/response/Main.ts | 51 ++- .../08_registryEmployee/views/Main.vue | 315 +++++++++++++++++- src/stores/mixin.ts | 2 + 5 files changed, 366 insertions(+), 20 deletions(-) diff --git a/src/api/02_organizational/api.treelist.ts b/src/api/02_organizational/api.treelist.ts index afb16eee1..215036604 100644 --- a/src/api/02_organizational/api.treelist.ts +++ b/src/api/02_organizational/api.treelist.ts @@ -10,7 +10,7 @@ import env from "../index"; const organizationPath = `${env.API_URI_ORG_SERVICE}/Organization/`; const postionMasterPath = `${env.API_URI_ORG_SERVICE}/PositionMaster`; const organizationPosition = `${env.API_URI_ORG_SERVICE}/OrganizationPosition/`; -const organizationEmployeePosition = `${env.API_URI_ORG_EMPLOYEE_SERVICE}/organization-employee/`; +const organizationEmployee = `${env.API_URI_ORG_EMPLOYEE_SERVICE}/organization-employee/`; const report = `${env.API_URI}/report/organization/`; @@ -84,7 +84,9 @@ export default { getPositionNumberIdByOcId: (OcId: string) => `${postionMasterPath}/position-number/Oc/${OcId}`, - organizationEmployeePosition: `${organizationEmployeePosition}`, - organizationEmployeePositionId: (id: string) => - `${organizationEmployeePosition}${id}`, + organizationEmployee: `${organizationEmployee}`, + organizationEmployeeId: (id: string) => `${organizationEmployee}${id}`, + + organizationEmployeePositionId: (profileId: string) => + `${organizationEmployee}position/${profileId}`, }; diff --git a/src/modules/02_organizational/views/MainTreeEmployee.vue b/src/modules/02_organizational/views/MainTreeEmployee.vue index b14061eff..dd56b1aa5 100644 --- a/src/modules/02_organizational/views/MainTreeEmployee.vue +++ b/src/modules/02_organizational/views/MainTreeEmployee.vue @@ -908,7 +908,7 @@ onMounted(async () => { const fetchData = async () => { loaderPage(true); await http - .get(config.API.organizationEmployeePosition) + .get(config.API.organizationEmployee) .then((res) => { let data = res.data.result; rows.value = []; @@ -1311,7 +1311,7 @@ const saveData = async () => { modal.value = false; loaderPage(true); await http - .post(config.API.organizationEmployeePosition, { + .post(config.API.organizationEmployee, { organizationOrganizationId: organizationOrganizationId.value, organizationShortNameId: organizationGovernmentCode.value, organizationTypeId: organizationTypeId.value, @@ -1363,7 +1363,7 @@ const editData = async () => { modal.value = false; loaderPage(true); await http - .put(config.API.organizationEmployeePositionId(id.value), { + .put(config.API.organizationEmployeeId(id.value), { organizationOrganizationId: organizationOrganizationId.value, organizationShortNameId: organizationGovernmentCode.value, organizationTypeId: organizationTypeId.value, @@ -1428,7 +1428,7 @@ const clickDelete = (id: string) => { const deleteData = async (id: string) => { loaderPage(true); await http - .delete(config.API.organizationEmployeePositionId(id)) + .delete(config.API.organizationEmployeeId(id)) .then((res) => { success($q, "ลบข้อมูลสำเร็จ"); }) diff --git a/src/modules/08_registryEmployee/response/Main.ts b/src/modules/08_registryEmployee/response/Main.ts index e4ea7770c..272bbb5e5 100644 --- a/src/modules/08_registryEmployee/response/Main.ts +++ b/src/modules/08_registryEmployee/response/Main.ts @@ -1 +1,50 @@ -export type {}; +interface ObjectNameId { + id: string; + name: string; +} +interface employeePosition { + id: string; + agency: string; + conditionNote: string; + department: string; + government: string; + isActive: boolean; + isCondition: boolean; + isDirector: boolean; + organizationUserNote: string; + qualification: string; + pile: string; + posNo: string; + positionCondition: string; + positionMasterUserNote: string; + organizationOrder: string; + organizationFaxId: string; + organizationLevelId: string; + organizationOrganizationId: string; + organizationTelExternalId: string; + organizationTelInternalId: string; + organizationTypeId: string; + positionEmployeeStatusId: string; + positionEmployeeLineId: string; + positionEmployeePositionId: string; + organizationAgencyId: string; + organizationGovernmentAgencyId: string; + organizationShortNameId: string; + organizationFaxName: string; + organizationLevelName: string; + organizationOrganizationName: string; + organizationTelExternalName: string; + organizationTelInternalName: string; + organizationTypeName: string; + positionEmployeeStatusName: string; + positionEmployeeLineName: string; + positionEmployeePositionName: string; + organizationAgencyName: string; + organizationGovernmentAgencyName: string; + organizationShortNameName: string; + positionEmployeeLevels: ObjectNameId[]; + positionEmployeePositionSides: ObjectNameId[]; + use: boolean; +} + +export type { employeePosition }; diff --git a/src/modules/08_registryEmployee/views/Main.vue b/src/modules/08_registryEmployee/views/Main.vue index 06b09aefa..8235acbe0 100644 --- a/src/modules/08_registryEmployee/views/Main.vue +++ b/src/modules/08_registryEmployee/views/Main.vue @@ -195,7 +195,42 @@ - + + + + + + + + + + + + + + @@ -212,7 +247,7 @@ import { FormRegistryEmployee, ResponseEmployeeTemp, } from "@/modules/08_registryEmployee/request/Main.ts"; -import { useDataStore } from "@/stores/data"; +import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue"; const props = defineProps({ next: { @@ -227,16 +262,23 @@ const props = defineProps({ const $q = useQuasar(); const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง -const { typeRetire, success, messageError, showLoader, hideLoader, date2Thai } = - mixin; -const dataStore = useDataStore(); -const { loaderPage } = dataStore; +const { + typeRetire, + success, + messageError, + showLoader, + hideLoader, + date2Thai, + dialogMessage, +} = mixin; + const router = useRouter(); const myForm = ref(); const filterRef = ref(); const filter = ref(""); const selected = ref(""); const modal = ref(false); +const id = ref(""); const visibleColumnsModal = ref(["no", "positionNum", "name"]); const columnsModal = [ { name: "no", align: "left", label: "ลำดับ", field: "no", sortable: true }, @@ -529,10 +571,258 @@ const columns = ref([ }, ]); const rows = ref([]); + +const selectedPosition = ref([]); +const visibleColumnsPosition = ref([ + "organizationOrganizationName", + "organizationAgencyName", + "organizationGovernmentAgencyName", + "organizationShortNameName", + "organizationTypeName", + "organizationLevelName", + "positionEmployeeLineName", + "positionEmployeePositionName", + "posNo", +]); + +const columnsPosition = ref([ + { + name: "organizationOrganizationName", + align: "left", + label: "หน่วยงาน", + sortable: true, + field: "organizationOrganizationName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "organizationAgencyName", + align: "left", + label: "รหัสหน่วยงาน", + sortable: true, + field: "organizationAgencyName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "organizationGovernmentAgencyName", + align: "left", + label: "รหัสส่วนราชการ", + sortable: true, + field: "organizationGovernmentAgencyName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "organizationShortNameName", + align: "left", + label: "ชื่อย่อหน่วยงาน", + sortable: true, + field: "organizationShortNameName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "organizationTypeName", + align: "left", + label: "ประเภทหน่วยงาน", + sortable: true, + field: "organizationTypeName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "organizationLevelName", + align: "left", + label: "ระดับหน่วยงาน", + sortable: true, + field: "organizationLevelName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "positionEmployeeLineName", + align: "left", + label: "สายงาน", + sortable: true, + field: "positionEmployeeLineName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "positionEmployeePositionName", + align: "left", + label: "ตำแหน่ง", + sortable: true, + field: "positionEmployeePositionName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, + { + name: "posNo", + align: "left", + label: "เลขที่ตำแหน่ง", + sortable: true, + field: "posNo", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + sort: (a: string, b: string) => + a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), + }, +]); +const rowsPosition = ref([]); + onMounted(async () => { await nodeTree(); }); +const checkNull = (text: string) => + text == null + ? "" + : text == "00000000-0000-0000-0000-000000000000" + ? "" + : text; + +const getPosition = async (id: string) => { + showLoader(); + await http + .get(config.API.organizationEmployeePositionId(id)) + .then((res) => { + const { result } = res.data; + let data: any[] = []; + result.map((r: any) => { + data.push({ + id: checkNull(r.id), + agency: checkNull(r.agency), + conditionNote: checkNull(r.conditionNote), + department: checkNull(r.department), + government: checkNull(r.government), + isActive: r.isActive, + isCondition: r.isCondition, + isDirector: r.isDirector, + organizationUserNote: checkNull(r.organizationUserNote), + qualification: checkNull(r.qualification), + pile: checkNull(r.pile), + posNo: checkNull(r.posNo), + positionCondition: checkNull(r.positionCondition), + positionMasterUserNote: checkNull(r.positionMasterUserNote), + organizationOrder: checkNull(r.organizationOrder), + organizationFaxId: checkNull(r.organizationFaxId), + organizationLevelId: checkNull(r.organizationLevelId), + organizationOrganizationId: checkNull(r.organizationOrganizationId), + organizationTelExternalId: checkNull(r.organizationTelExternalId), + organizationTelInternalId: checkNull(r.organizationTelInternalId), + organizationTypeId: checkNull(r.organizationTypeId), + positionEmployeeStatusId: checkNull(r.positionEmployeeStatusId), + positionEmployeeLineId: checkNull(r.positionEmployeeLineId), + positionEmployeePositionId: checkNull(r.positionEmployeePositionId), + organizationAgencyId: checkNull(r.organizationAgencyId), + organizationGovernmentAgencyId: checkNull( + r.organizationGovernmentAgencyId + ), + organizationShortNameId: checkNull(r.organizationShortNameId), + organizationFaxName: checkNull(r.organizationFaxName), + organizationLevelName: checkNull(r.organizationLevelName), + organizationOrganizationName: checkNull( + r.organizationOrganizationName + ), + organizationTelExternalName: checkNull(r.organizationTelExternalName), + organizationTelInternalName: checkNull(r.organizationTelInternalName), + organizationTypeName: checkNull(r.organizationTypeName), + positionEmployeeStatusName: checkNull(r.positionEmployeeStatusName), + positionEmployeeLineName: checkNull(r.positionEmployeeLineName), + positionEmployeePositionName: checkNull( + r.positionEmployeePositionName + ), + organizationAgencyName: checkNull(r.organizationAgencyName), + organizationGovernmentAgencyName: checkNull( + r.organizationGovernmentAgencyName + ), + organizationShortNameName: checkNull(r.organizationShortNameName), + positionEmployeeLevels: r.positionEmployeeLevels, + positionEmployeePositionSides: r.positionEmployeePositionSides, + use: r.use, + }); + }); + + const index = data.findIndex((r: any) => r.use == true); + if (index >= 0) { + selectedPosition.value = [data[index]]; + } + + rowsPosition.value = data; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +}; + +const checkSave = async () => { + if (selectedPosition.value.length == 0) { + dialogMessage( + $q, + "ไม่สามารถบันทึกข้อมูลได้", + "กรุณาเลือกตำแหน่ง", + "warning", + undefined, + "orange", + undefined, + undefined, + true + ); + return; + } else { + await savePosition(); + } +}; + +const savePosition = async () => { + showLoader(); + const data = { + organizationEmployeeId: selectedPosition.value[0].id, + }; + await http + .put(config.API.organizationEmployeePositionId(id.value), data) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await nodeTree(); + modalOpenClose(); + }); +}; + +const modalOpenClose = () => { + modal.value = !modal.value; + if (!modal.value) { + selectedPosition.value = []; + rowsPosition.value = []; + id.value = ""; + } +}; + const next = (id: string) => { router.push(`/registryEmployee/${id}`); }; @@ -583,7 +873,10 @@ const clickAdd = () => { // router.push(`/placement/detail`); }; -const editDetail = (id: string) => { +const editDetail = async (row: any) => { + await getPosition(row.id); + console.log(row); + id.value = row.id; modal.value = true; }; @@ -598,7 +891,7 @@ const clickDelete = (id: string) => { persistent: true, }) .onOk(async () => { - loaderPage(true); + showLoader(); await http .delete(config.API.profileInforId(id)) .then((res) => { @@ -609,7 +902,7 @@ const clickDelete = (id: string) => { messageError($q, e); }) .finally(() => { - loaderPage(false); + hideLoader(); }); }) .onCancel(() => {}) @@ -649,7 +942,7 @@ const showEmployeeTemp = async () => { }); if (selected.value == null || selected.value == "") return; - loaderPage(true); + showLoader(); await http .post(config.API.searchProfileByOcId(selected.value, "all"), { criterias: cirteria, @@ -691,7 +984,7 @@ const showEmployeeTemp = async () => { messageError($q, e); }) .finally(() => { - loaderPage(false); + hideLoader(); }); }; diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 3ac73c26c..2ae149e62 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -312,6 +312,8 @@ export const useCounterMixin = defineStore("mixin", () => { } const messageError = (q: any, e: any = "") => { + // q.dialog.hide(); + console.log("e.response", e.response); if (e.response !== undefined) { if (e.response.data.status !== undefined) { if (e.response.data.status == 401) {