From df481043b1dcba90ca06527f4614d92df0b0bdcd Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 16 Aug 2024 10:26:09 +0700 Subject: [PATCH 1/7] fix bug --- .../components/DialogAddPosition.vue | 41 +++++++------ .../components/DialogFormAgency.vue | 41 ++++++++----- .../components/DialogFormPosition.vue | 58 ++++++++++++------- .../components/DialogMovePos.vue | 6 +- .../components/DialogNewStructure.vue | 12 ++-- .../components/DialogSuccession.vue | 2 - .../02_organization/components/TreeMain.vue | 10 ++-- .../02_organization/components/TreeTable.vue | 49 +++++++++------- src/modules/17_acting/views/main.vue | 10 ++++ 9 files changed, 138 insertions(+), 91 deletions(-) diff --git a/src/modules/02_organization/components/DialogAddPosition.vue b/src/modules/02_organization/components/DialogAddPosition.vue index 9fa0e35da..162f71512 100644 --- a/src/modules/02_organization/components/DialogAddPosition.vue +++ b/src/modules/02_organization/components/DialogAddPosition.vue @@ -133,10 +133,9 @@ function saveSelectEdit() { }; await http .put(url, body) - .then(() => { - success($q, "เพิ่มข้อมูลสำเร็จ"); - - props.getData?.(); + .then(async () => { + await props.getData?.(); + await success($q, "เพิ่มข้อมูลสำเร็จ"); close(); }) .catch((err) => { @@ -192,10 +191,12 @@ function onSubmitSelectEdit() { await http .post(url, body) - .then(() => { - success($q, "เพิ่มข้อมูลสำเร็จ"); - - props.emitSearch?.(formPositionSelect.positionName, "positionName"); + .then(async () => { + await props.emitSearch?.( + formPositionSelect.positionName, + "positionName" + ); + await success($q, "เพิ่มข้อมูลสำเร็จ"); close(); }) .catch((err) => { @@ -241,7 +242,12 @@ function inputEdit(val: boolean) { }; } +/** + * function เลือกประเภทตำแหน่ง + * @param val id ประเภทตำแหน่ง + */ function updateSelectType(val: string) { + // หาระดับตำแหน่ง const listLevel = dataLevel.value.find((e: any) => e.id === val); levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({ id: e.id, @@ -257,8 +263,7 @@ function close() { } async function fetchType() { - showLoader(); - await http + http .get(config.API.orgPosType) .then((res) => { dataLevel.value = res.data.result; @@ -270,16 +275,12 @@ async function fetchType() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } /** function เรียกรายการตำแหน่งทางการบริหาร */ -async function fetchExecutive() { - showLoader(); - await http +function fetchExecutive() { + http .get(config.API.orgPosExecutive) .then((res) => { executiveOpsMain.value = res.data.result.map((e: OptionExecutive) => ({ @@ -290,9 +291,6 @@ async function fetchExecutive() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } @@ -300,8 +298,9 @@ watch( () => modal.value, async () => { if (modal.value === true) { - await fetchType(); - await fetchExecutive(); + showLoader(); + await Promise.all([fetchType(), fetchExecutive()]); + hideLoader(); if (props.data) { const dataList = props.data; diff --git a/src/modules/02_organization/components/DialogFormAgency.vue b/src/modules/02_organization/components/DialogFormAgency.vue index e6142d868..611bd8b37 100644 --- a/src/modules/02_organization/components/DialogFormAgency.vue +++ b/src/modules/02_organization/components/DialogFormAgency.vue @@ -149,13 +149,14 @@ function onSubmit() { formData.responsibility != null ? formData.responsibility : "", }; + //เพิ่มข้อมูล if (actionType.value === "ADD") { await http .post(config.API.createOrgLevel(type.toLocaleLowerCase()), body) - .then(() => { - props.fetchDataTree(store.draftId); - success($q, "บันทึกข้อมูลสำเร็จ"); - closeClear(); + .then(async () => { + await props.fetchDataTree(store.draftId); + await success($q, "บันทึกข้อมูลสำเร็จ"); + await closeClear(); }) .catch((err) => { messageError($q, err); @@ -164,6 +165,7 @@ function onSubmit() { hideLoader(); }); } else { + // แก่้ไขข้อมูล props.dataNode && (await http .put( @@ -173,32 +175,35 @@ function onSubmit() { ), body ) - .then(() => { - props.fetchDataTree(store.draftId); - props.edit?.( + .then(async () => { + await props.fetchDataTree(store.draftId); + await props.edit?.( props.dataNode?.orgTreeId, type, body, props.dataNode?.orgRootCode ); - closeClear(); - props.fetchDataTable( + await props.fetchDataTable( props?.dataNode?.orgTreeId, props?.dataNode?.orgLevel, false ); - success($q, "บันทึกข้อมูลสำเร็จ"); + await success($q, "บันทึกข้อมูลสำเร็จ"); + await closeClear(); }) .catch((err) => { messageError($q, err); }) - .finally(async () => { + .finally(() => { hideLoader(); })); } }); } +/** + * function เช็ต formdata กลับไปค่าว่าง และปิด popup + */ function closeClear() { formData.orgName = ""; formData.orgShortName = ""; @@ -211,14 +216,14 @@ function closeClear() { props.close?.(); } +/** + * callback function ทำงานเมื่อมีการเปิด popup + */ watch( () => props.modal, () => { if (props.modal === true) { if (actionType.value === "ADD") { - // console.log(props.dataNode); - // console.log(level.value); - if (props.dataNode) { formData.orgCode = props?.dataNode?.orgLevel !== 0 @@ -261,6 +266,9 @@ watch( } ); +/** + * title ของ popup + */ const tittleName = computed(() => { let name = ""; if (actionType.value === "ADD") { @@ -272,6 +280,11 @@ const tittleName = computed(() => { return name; }); +/** + * function เลือกระดับของส่วนราชการ + * @param val + * @param status + */ function selectOrgLevele(val: string, status: boolean = true) { formData.orgLevelSub = status ? "" : formData.orgLevelSub; switch (val) { diff --git a/src/modules/02_organization/components/DialogFormPosition.vue b/src/modules/02_organization/components/DialogFormPosition.vue index c51991cd6..f0197b7fe 100644 --- a/src/modules/02_organization/components/DialogFormPosition.vue +++ b/src/modules/02_organization/components/DialogFormPosition.vue @@ -1,7 +1,6 @@ diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue index 713d4a05c..62ed821ed 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue @@ -495,18 +495,26 @@ const historyVisibleColumns = ref([ "lastUpdatedAt", ]); -async function onSubmit() { +/** + * function ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * function ค้นหา คำใน option + * @param val คำค้นหา + * @param update function + * @param refData type select + */ function filterSelector(val: string, update: Function, refData: string) { switch (refData) { case "educationOption": @@ -528,6 +536,9 @@ function filterSelector(val: string, update: Function, refData: string) { } } +/** + * function เคลียร์ formData + */ function clearForm() { isDate.value = "false"; educationData.educationLevel = ""; @@ -549,6 +560,10 @@ function clearForm() { educationData.note = ""; } +/** + * function แก้ไขข้อมูลประวัติการศึกษา + * @param row ข้อมูลประวัติการศึกษา + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -579,19 +594,30 @@ function editForm(row: any) { dialog.value = true; } +/** + * function ปิด popup มูลประวัติการศึกษา + */ function closeDialog() { clearForm(); dialog.value = false; } + +/** + * funcitob ปิด popup ประวัติการศึกษา + */ function closeHistoryDialog() { historyDialog.value = false; } -async function fetchData(id: string) { +/** + * function fetch ข้อมูลประวัตืการศึกษา + * @param id บุคคล + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewEducationByProfileId(id, empType.value)) - .then(async (res) => { + .then((res) => { rows.value = res.data.result; }) .catch((err) => { @@ -602,9 +628,11 @@ async function fetchData(id: string) { }); } -async function fetchEducationLevel() { - showLoader(); - await http +/** + * function fetch ข้อมูลระดับการศึกษา + */ +function fetchEducationLevel() { + http .get(config.API.orgEducationLevel) .then(async (res) => { res.data.result.map((r: any) => { @@ -617,15 +645,16 @@ async function fetchEducationLevel() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } -async function fetchHistoryData(id: string) { +/** + * function fetch ประวัติการแก้ไขประวัติการศึกษา + * @param id ประวัติการศึกษา + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewEducationHisByEducationId(id, empType.value)) .then(async (res) => { historyRows.value = res.data.result; @@ -638,8 +667,12 @@ async function fetchHistoryData(id: string) { }); } -async function addData() { - await http +/** + * function เพิ่มข้อมูลประวัติการศึกษา + */ +function addData() { + showLoader(); + http .post(config.API.profileNewEducation(empType.value), { ...educationData, startYear: undefined, @@ -648,9 +681,10 @@ async function addData() { profileId: empType.value === "" ? id.value : undefined, profileEmployeeId: empType.value !== "" ? id.value : undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -660,9 +694,12 @@ async function addData() { }); } +/** + * function บันทึกการแก้ไขข้อมูล + * @param idData ประวัติการศึกษา + */ function editData(idData: string) { - console.log(educationData); - + showLoader(); http .patch(config.API.profileNewEducationByEducationId(idData, empType.value), { ...educationData, @@ -673,9 +710,10 @@ function editData(idData: string) { durationYear: educationData.durationYear === "" ? null : educationData.durationYear, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -685,23 +723,6 @@ function editData(idData: string) { }); } -// function deleteData(idData: string) { -// dialogRemove($q, () => -// http -// .delete(config.API.profileNewEducationByEducationId(idData)) -// .then(() => { -// fetchData(id.value); -// success($q, "ลบข้อมูลสำเร็จ"); -// }) -// .catch((err) => { -// messageError($q, err); -// }) -// .finally(() => { -// hideLoader(); -// }) -// ); -// } - onMounted(async () => { await fetchData(id.value); fetchEducationLevel(); diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue index 19eaf688c..aa7b12d1e 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue @@ -15,7 +15,6 @@ const mixin = useCounterMixin(); const $q = useQuasar(); const mode = ref("table"); const { - dialogRemove, dialogConfirm, showLoader, hideLoader, @@ -189,6 +188,7 @@ const historyVisibleColumns = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); + function closeDialog() { dialog.value = false; } @@ -197,18 +197,23 @@ function closeHistoryDialog() { historyDialog.value = false; } -async function onSubmit() { +/** + * function ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * function เคลียร์ formData + */ function clearForm() { specialSkill.detail = ""; specialSkill.field = ""; @@ -216,6 +221,10 @@ function clearForm() { specialSkill.remark = ""; } +/** + * function + * @param row ข้อมูลความสามารถพิเศษ + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -226,11 +235,14 @@ function editForm(row: any) { dialog.value = true; } -async function fetchData(id: string) { +/** + * function fetch ข้อมูลความสามรรถพิเศษ + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewAbilityByProfileId(id, empType.value)) - .then(async (res) => { + .then((res) => { rows.value = res.data.result; }) .catch((err) => { @@ -241,11 +253,15 @@ async function fetchData(id: string) { }); } -async function fetchHistoryData(id: string) { +/** + * function fetch ประวัติการแก้ไขความสามรรถพิเศษ + * @param id ความสามรรถพิเศษ + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewAbilityHisByAbilityId(id, empType.value)) - .then(async (res) => { + .then((res) => { historyRows.value = res.data.result; }) .catch((err) => { @@ -256,8 +272,12 @@ async function fetchHistoryData(id: string) { }); } -async function addData() { - await http +/** + * function เพิ่มข้อมูลความสามรรถพิเศษ + */ +function addData() { + showLoader(); + http .post(config.API.profileNewAbility(empType.value), { ...specialSkill, dateStart: null, @@ -265,9 +285,10 @@ async function addData() { profileId: empType.value === "" ? id.value : undefined, profileEmployeeId: empType.value !== "" ? id.value : undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -277,17 +298,23 @@ async function addData() { }); } -async function editData(idData: string) { - await http +/** + * function บันทึกการแก้ไขข้อมูล + * @param idData ความสามรรถพิเศษ + */ +function editData(idData: string) { + showLoader(); + http .patch(config.API.profileNewAbilityByAbilityId(idData, empType.value), { ...specialSkill, dateStart: null, dateEnd: null, profileId: undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -297,25 +324,8 @@ async function editData(idData: string) { }); } -async function deleteData(idData: string) { - dialogRemove($q, () => - http - .delete(config.API.profileNewAbilityByAbilityId(idData, empType.value)) - .then(() => { - fetchData(id.value); - success($q, "ลบข้อมูลสำเร็จ"); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }) - ); -} - -onMounted(async () => { - await fetchData(id.value); +onMounted(() => { + fetchData(id.value); });