From 4c01e5aa0d191c070fea27d1feb6652a71efe12c Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 23 May 2024 16:34:10 +0700 Subject: [PATCH 1/2] fixing submit receive module change send name --- .../components/Receive/AddEmployee/Main.vue | 46 ++++++------------- .../components/Receive/receiveDetail2.vue | 44 +++++++++--------- 2 files changed, 38 insertions(+), 52 deletions(-) diff --git a/src/modules/05_placement/components/Receive/AddEmployee/Main.vue b/src/modules/05_placement/components/Receive/AddEmployee/Main.vue index 276996b98..634ac32be 100644 --- a/src/modules/05_placement/components/Receive/AddEmployee/Main.vue +++ b/src/modules/05_placement/components/Receive/AddEmployee/Main.vue @@ -114,12 +114,11 @@ const fetchPerson = async () => { OpsFilter.value.genderOps = optiongenders; let optionprefixs: DataOption[] = []; - data.prefixs.map((r: DataOptioninfo) => { - optionprefixs.push({ - id: r.id.toString(), - name: r.name.toString(), - }); - }); + optionprefixs = data.prefixs.map((v: any) => ({ + id: v.id, + name: v.name, + })); + Ops.value.prefixOps = optionprefixs; OpsFilter.value.prefixOps = optionprefixs; @@ -302,22 +301,22 @@ const onSubmit = async () => { if (informaData.value.lastName != undefined) formData.append("lastName", informaData.value.lastName); if (informaData.value.genderId != undefined) - formData.append("genderId", informaData.value.genderId); + formData.append("gender", informaData.value.genderId); if (informaData.value.nationality != undefined) formData.append("nationality", informaData.value.nationality); if (informaData.value.ethnicity != undefined) formData.append("race", informaData.value.ethnicity); if (informaData.value.religionId != undefined) - formData.append("religionId", informaData.value.religionId); + formData.append("religion", informaData.value.religionId); if (informaData.value.birthDate != undefined) formData.append( "birthDate", dateToISO(informaData.value.birthDate) ?? dateToISO(new Date()) ); if (informaData.value.bloodId != undefined) - formData.append("bloodGroupId", informaData.value.bloodId); + formData.append("bloodGroup", informaData.value.bloodId); if (informaData.value.statusId != undefined) - formData.append("relationshipId", informaData.value.statusId); + formData.append("relationship", informaData.value.statusId); if (informaData.value.tel != undefined) formData.append("telephoneNumber", informaData.value.tel); if (informaData.value.employeeType != undefined) @@ -348,20 +347,6 @@ const clickBack = () => { router.push("/receive"); }; -function fetchPrefix() { - http - .get(config.API.orgPrefix) - .then((res) => { - prefixOps.value = res.data.result.map((v: any) => ({ - id: v.name, - name: v.name, - })); - }) - .catch((err) => { - messageError($q, err); - }); -} - function calculateAge(birthDate: Date | null) { if (!birthDate) return null; const birthDateTimeStamp = new Date(birthDate).getTime(); @@ -394,7 +379,6 @@ watch( onMounted(async () => { await fetchPerson(); - await fetchPrefix(); }); @@ -749,9 +733,9 @@ onMounted(async () => { dense lazy-rules class="inputgreen" - :options="prefixOps" + :options="Ops.prefixOps" option-label="name" - option-value="id" + option-value="name" map-options hide-bottom-space :rules="[ @@ -857,7 +841,7 @@ onMounted(async () => { hide-bottom-space input-debounce="0" option-label="name" - option-value="id" + option-value="name" v-model="informaData.genderId" class="inputgreen" :options="Ops.genderOps" @@ -877,7 +861,7 @@ onMounted(async () => { emit-value map-options hide-bottom-space - option-value="id" + option-value="name" option-label="name" input-debounce="0" class="inputgreen" @@ -921,7 +905,7 @@ onMounted(async () => { emit-value map-options hide-bottom-space - option-value="id" + option-value="name" option-label="name" input-debounce="0" v-model="informaData.religionId" @@ -943,7 +927,7 @@ onMounted(async () => { emit-value map-options hide-bottom-space - option-value="id" + option-value="name" option-label="name" input-debounce="0" v-model="informaData.bloodId" diff --git a/src/modules/05_placement/components/Receive/receiveDetail2.vue b/src/modules/05_placement/components/Receive/receiveDetail2.vue index 92a2b8d55..92f2fe93f 100644 --- a/src/modules/05_placement/components/Receive/receiveDetail2.vue +++ b/src/modules/05_placement/components/Receive/receiveDetail2.vue @@ -41,8 +41,8 @@ const { dialogConfirm, } = mixin; -const profileStore = useProfileDataStore(); -const { changeRetireText } = profileStore; +// const profileStore = useProfileDataStore(); +// const { changeRetireText } = profileStore; const title = ref({ fullname: "", @@ -132,10 +132,11 @@ const OpsFilter = ref({ ], }); +/*** get รายการข้อมูลเกี่ยวกับบุคคล (dropdown list) */ const fetchPerson = async () => { showLoader(); await http - .get(config.API.person) + .get(config.API.profileNewMetaMain) .then((res) => { const data = res.data.result; let optionbloodGroups: DataOption[] = []; @@ -159,12 +160,11 @@ const fetchPerson = async () => { OpsFilter.value.genderOps = optiongenders; let optionprefixs: DataOption[] = []; - data.prefixs.map((r: DataOptioninfo) => { - optionprefixs.push({ - id: r.id.toString(), - name: r.name.toString(), - }); - }); + optionprefixs = data.prefixs.map((v: any) => ({ + id: v.id, + name: v.name, + })); + Ops.value.prefixOps = optionprefixs; OpsFilter.value.prefixOps = optionprefixs; @@ -189,7 +189,9 @@ const fetchPerson = async () => { OpsFilter.value.religionOps = optionreligions; }) .catch((e: any) => {}) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }; const getData = async () => { @@ -391,14 +393,14 @@ const calRetire = async (birth: Date) => { .then((res: any) => { const data = res.data.result; informaData.value.age = data.age; - changeRetireText(data.retireDate); + // changeRetireText(data.retireDate); dateBefore.value = birth; }) .catch((e: any) => { messageError($q, e); const retire = new Date(`${birth.getFullYear() + 60}-09-30`); informaData.value.birthDate = dateBefore.value; - changeRetireText(date2Thai(retire)); + // changeRetireText(date2Thai(retire)); }) .finally(() => { hideLoader(); @@ -419,12 +421,12 @@ function saveData() { informaData.value.birthDate !== null ? dateToISO(informaData.value.birthDate) : null, - genderId: informaData.value.genderId, + gender: informaData.value.genderId, nationality: informaData.value.nationality, race: informaData.value.ethnicity, - religionId: informaData.value.religionId, - bloodGroupId: informaData.value.bloodId, - relationshipId: informaData.value.statusId, + religion: informaData.value.religionId, + bloodGroup: informaData.value.bloodId, + relationship: informaData.value.statusId, telephoneNumber: informaData.value.tel, reason: reason.value, educationOld: educationOld.value, @@ -564,7 +566,7 @@ onMounted(async () => { map-options option-label="name" :options="Ops.prefixOps" - option-value="id" + option-value="name" :label="`${'คำนำหน้าชื่อ'}`" use-input input-debounce="0" @@ -673,7 +675,7 @@ onMounted(async () => { map-options option-label="name" :options="Ops.genderOps" - option-value="id" + option-value="name" :label="`${'เพศ'}`" use-input input-debounce="0" @@ -695,7 +697,7 @@ onMounted(async () => { map-options option-label="name" :options="Ops.statusOps" - option-value="id" + option-value="name" :label="`${'สถานภาพ'}`" use-input input-debounce="0" @@ -743,7 +745,7 @@ onMounted(async () => { map-options option-label="name" :options="Ops.religionOps" - option-value="id" + option-value="name" :label="`${'ศาสนา'}`" use-input input-debounce="0" @@ -767,7 +769,7 @@ onMounted(async () => { map-options option-label="name" :options="Ops.bloodOps" - option-value="id" + option-value="name" :label="`${'หมู่เลือด'}`" use-input input-debounce="0" From 3b90a9d69c63c42740f14a1e7872fbc52ce3d17d Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 23 May 2024 16:34:22 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2=E0=B8=AD=E0=B8=AD=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/06_retirement/api.retirement.ts | 19 +- .../components/resign/ResignByid.vue | 757 +++++++++--------- .../06_retirement/interface/response/Main.ts | 27 +- 3 files changed, 415 insertions(+), 388 deletions(-) diff --git a/src/api/06_retirement/api.retirement.ts b/src/api/06_retirement/api.retirement.ts index 7d1b8731d..756927995 100644 --- a/src/api/06_retirement/api.retirement.ts +++ b/src/api/06_retirement/api.retirement.ts @@ -27,14 +27,20 @@ export default { listResign: () => `${retirement}/resign`, resignReport: `${retirement}/resign/report`, resingByid: (id: string) => `${retirement}/resign/${id}`, - resignConfirm: (role: String, id: string) => `${retirement}/resign/${role}/confirm/${id}`, - resignReject: (role: String, id: string) => `${retirement}/resign/${role}/reject/${id}`, + resignConfirm: (role: String, id: string) => + `${retirement}/resign/${role}/confirm/${id}`, + resignReject: (role: String, id: string) => + `${retirement}/resign/${role}/reject/${id}`, listExitInterview: () => `${retirement}/resign/questionnaire`, - commentExitInterview: (id:string) => `${retirement}/resign/questionnaire/comment/${id}`, + commentExitInterview: (id: string) => + `${retirement}/resign/questionnaire/comment/${id}`, questionExitInterview: () => `${retirement}/resign/questionnaire/question`, ExitInterviewByid: (id: string) => `${retirement}/resign/questionnaire/${id}`, ExitInterviewReport: `${retirement}/resign/questionnaire/report`, - AppointInterview: (id: string) => `${retirement}/resign/questionnaire/appoint/${id}`, + AppointInterview: (id: string) => + `${retirement}/resign/questionnaire/appoint/${id}`, + resignConditions: (id: string) => `${retirement}/resign/debt/${id}`, + // ปลดออก retirementDischarge, listDischarge: () => `${retirement}/discharge`, @@ -58,8 +64,5 @@ export default { editDetail: (retireId: string) => `${retirement}/detail/${retireId}`, // ตำถาม Exit interview - questionnaireList: () => `${retirement}/resign/questionnaire/question` - - - + questionnaireList: () => `${retirement}/resign/questionnaire/question`, }; diff --git a/src/modules/06_retirement/components/resign/ResignByid.vue b/src/modules/06_retirement/components/resign/ResignByid.vue index 1b0720fdc..46cfa8e53 100644 --- a/src/modules/06_retirement/components/resign/ResignByid.vue +++ b/src/modules/06_retirement/components/resign/ResignByid.vue @@ -9,6 +9,8 @@ import { useRetirementDataStore } from "@/modules/06_retirement/store"; import CurrencyInput from "@/components/CurruncyInput.vue"; import http from "@/plugins/http"; import config from "@/app.config"; +import axios from "axios"; + import keycloak from "@/plugins/keycloak"; import type { TypeFile, @@ -23,7 +25,6 @@ import type { DataProfile } from "@/modules/05_placement/interface/index/Main"; /** importComponents*/ import CardProfile from "@/components/CardProfile.vue"; -const avatar = ref(""); const modalPersonal = ref(false); const personId = ref(""); /** Use */ @@ -38,7 +39,7 @@ const { showLoader, hideLoader, success, - dialogMessage, + dialogConfirm, dialogRemove, } = mixin; @@ -133,16 +134,21 @@ const checkboxGroup = ref([]); const checkboxOp = ref([ { label: "ไม่เป็นหนี้สหกรณ์", value: "debt" }, ]); + /** Hook */ onMounted(async () => { fetchData(id.value); + fetchFile(); if (keycloak.tokenParsed !== undefined) { const commander = await keycloak.tokenParsed.role.includes("commander"); const oligarch = await keycloak.tokenParsed.role.includes("oligarch"); + const officer = await keycloak.tokenParsed.role.includes("officer"); if (commander) { roleUser.value = "commander"; } else if (oligarch) { roleUser.value = "oligarch"; + } else if (officer) { + roleUser.value = "officer"; } else { roleUser.value = "admin"; } @@ -154,7 +160,6 @@ const diffDate = () => { const time = dateLeave.value.getTime() - date.value.getTime(); //วันที่ขอลาออกจากราชการ - วันที่ยื่นขอลาออกจากราชการ const day = time / (1000 * 3600 * 24); - if (day < 30) { return true; } @@ -163,9 +168,7 @@ const diffDate = () => { return false; }; -/** - * นำข้อมูลมาจาก API - */ +/** นำข้อมูลมาจาก API*/ const fetchData = async (id: string) => { showLoader(); await http @@ -196,7 +199,6 @@ const fetchData = async (id: string) => { location.value = data.location ?? ""; status.value = data.status ?? ""; remarkHorizontal.value = data.remarkHorizontal ?? "-"; - // getAvatar(data.profileId); }) .catch((e) => { messageError($q, e); @@ -206,30 +208,6 @@ const fetchData = async (id: string) => { }); }; -// function getAvatar(id: string) { -// if (id) { -// http -// .get(config.API.profileAvaId(id)) -// .then((res) => { -// console.log(res); -// const dataList = res.data.result; -// avatar.value = dataList.avatar; -// }) -// .catch((e) => {}) -// .finally(() => {}); -// } -// } - -// const downloadFile = (response: any, filename: string) => { -// const link = document.createElement("a"); -// var fileName = filename; -// link.href = window.URL.createObjectURL(new Blob([response.data])); -// link.setAttribute("download", fileName); -// document.body.appendChild(link); -// link.click(); -// document.body.removeChild(link); -// }; - /**Pop up */ const popUp = (action: "pass" | "passNot") => { reasonReign.value = ""; @@ -237,6 +215,7 @@ const popUp = (action: "pass" | "passNot") => { actionPass.value = action === "pass"; openModal(); }; + //เงื่อนไขpop up const conditionPopup = () => { if (myFormConfirm.value !== null) { @@ -311,6 +290,7 @@ const rejectpopUp = async () => { const clickCancel = async () => { await fetchData(id.value); edit.value = false; + myForm.value?.resetValidation(); }; /** * กดยกเลิก @@ -320,86 +300,60 @@ const clickCancelConditions = async () => { conditions.value = false; }; -const saveConditions = () => { - if (myForm.value !== null) { - myForm.value.validate().then((success) => { - if (success) { - dialogConfirm($q, () => { - dataSave(); - }); - // dialogMessage( - // $q, - // "ต้องการแก้ไขข้อมูลหรือไม่?", - // "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย", - // "mdi-help-circle-outline", - // "ตกลง", - // "public", - // async () => await dataSave(), - // undefined - // ); - } - }); - } +/** Function บันทึก รายการตรวจสอบเงื่อนไขต่าง ๆ*/ +const onSubmitConditions = () => { + dialogConfirm($q, () => { + showLoader(); + http + .put(config.API.resignConditions(id.value), { + IsNoDebt: checkboxGroup.value[0] ? true : false, + }) + .then(() => { + fetchData(id.value); + success($q, "บันทึกเงื่อนไขต่าง ๆ สำเร็จ"); + conditions.value = false; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + }); }; -//Save จาก Api -const dataSave = async () => {}; - -/** - * Functionบันทึก - */ -const conditionSave = () => { - if (myForm.value !== null) { - myForm.value.validate().then((success) => { - if (success) { - dialogConfirm($q, () => { - saveData(); - }); - // dialogMessage( - // $q, - // "ต้องการแก้ไขข้อมูลหรือไม่?", - // "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย", - // "mdi-help-circle-outline", - // "ตกลง", - // "public", - // async () => , - // undefined - // ); - } - }); - } -}; - -//Save จาก Api -const saveData = async () => { - const formData = new FormData(); - const send = date.value !== null ? new Date(date.value).toUTCString() : ""; - const activeDate = - dateLeave.value !== null ? new Date(dateLeave.value).toUTCString() : ""; - formData.append("Location", location.value); - formData.append("SendDate", send); - formData.append("ActiveDate", activeDate); - formData.append("Reason", reason.value); - formData.append("OrganizationPositionOld", organizationPositionOld.value); - formData.append("PositionTypeOld", positionTypeOld.value); - formData.append("PositionLevelOld", positionLevelOld.value); - formData.append("PositionNumberOld", posNo.value); - formData.append("AmountOld", salary.value.toString()); - formData.append("remarkHorizontal", remarkHorizontal.value); - showLoader(); - await http - .put(config.API.resingByid(id.value), formData) - .then(() => { - success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ"); - edit.value = false; - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await fetchData(id.value); - hideLoader(); - }); +/** Function บันทึก ,แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ +const onSubmitAttached = () => { + dialogConfirm($q, () => { + const formData = new FormData(); + const send = date.value !== null ? new Date(date.value).toUTCString() : ""; + const activeDate = + dateLeave.value !== null ? new Date(dateLeave.value).toUTCString() : ""; + formData.append("Location", location.value); + formData.append("SendDate", send); + formData.append("ActiveDate", activeDate); + formData.append("Reason", reason.value); + formData.append("OrganizationPositionOld", organizationPositionOld.value); + formData.append("PositionTypeOld", positionTypeOld.value); + formData.append("PositionLevelOld", positionLevelOld.value); + formData.append("PositionNumberOld", posNo.value); + formData.append("AmountOld", salary.value.toString()); + formData.append("remarkHorizontal", remarkHorizontal.value); + showLoader(); + http + .put(config.API.resingByid(id.value), formData) + .then(() => { + edit.value = false; + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await fetchData(id.value); + await hideLoader(); + }); + }); }; /** @@ -464,52 +418,117 @@ function updatemodalPersonal(modal: boolean) { modalPersonal.value = modal; } +async function fetchFile() { + showLoader(); + await http + .get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value)) + .then((res) => { + fileList.value = res.data; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + function uploadFiles() { + showLoader(); + http + .post(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value), { + replace: true, + fileList: [ + { + fileName: file.value.name, + }, + ], + }) + .then(async (res) => { + const foundKey: string | undefined = Object.keys(res.data).find( + (key) => + res.data[key]?.fileName !== undefined && + res.data[key]?.fileName !== "" + ); + foundKey && uploadFileURL(res.data[foundKey]?.uploadUrl); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +async function uploadFileURL(uploadUrl: string) { const Data = new FormData(); Data.append("file", file.value); showLoader(); - http - .put(config.API.investigateRelevantUploadFile(id.value), Data) + await axios + .put(uploadUrl, file.value, { + headers: { + "Content-Type": file.value.type, + }, + }) .then(() => { success($q, "อัปโหลดไฟล์สำเร็จ"); + fetchFile(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + file.value = null; + }); +} + +function downloadFiles(fileName: string) { + showLoader(); + http + .get( + config.API.fileByFile("พ้นจากราชการ", "หลักฐานลาออก", id.value, fileName) + ) + .then((res) => { + const data = res.data.downloadUrl; + window.open(data, "_blank"); }) .catch((e) => { messageError($q, e); }) .finally(async () => { hideLoader(); - file.value = null; }); } -function downloadFiles(link: string) { - window.open(link, "_blank"); -} - /** * ลบไฟล์ * @param id id file */ -function removeFile(id: string) { - dialogRemove($q, () => confirmRemove(id)); -} - -/** - * ยืนยัน ลบ ไฟล์ - * @param id id file - */ -function confirmRemove(fileId: string) { - showLoader(); - http - .delete(config.API.investigateRelevantFileDelete(id.value, fileId)) - .then((res) => { - success($q, `ลบไฟล์สำเร็จ`); - fetchData(id.value); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => {}); +function removeFile(fileName: string) { + dialogRemove($q, () => { + showLoader(); + http + .delete( + config.API.fileByFile( + "พ้นจากราชการ", + "หลักฐานลาออก", + id.value, + fileName + ) + ) + .then(() => { + success($q, `ลบไฟล์สำเร็จ`); + setTimeout(() => { + fetchFile(); + hideLoader(); + }, 1000); + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }); + }); }