diff --git a/src/modules/06_retirement/components/ListRetirement/TableList.vue b/src/modules/06_retirement/components/ListRetirement/TableList.vue index 05c396491..35c25c205 100644 --- a/src/modules/06_retirement/components/ListRetirement/TableList.vue +++ b/src/modules/06_retirement/components/ListRetirement/TableList.vue @@ -16,8 +16,6 @@ import DialogPopupReason from "@/components/Dialogs/PopupReason.vue"; import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue"; import AddList from "../ListRetirement/AddList.vue"; -const modalPersonal = ref(false); -const personId = ref(""); /** Use */ const route = useRoute(); const checkRoutePermisson = ref(route.name == "retirementidDetail"); @@ -38,10 +36,12 @@ const myForm = ref(null); /** ตัวแปร */ const retireld_params = route.params.retirementId; +const retireld = ref(retireld_params.toString()); +const modalPersonal = ref(false); +const personId = ref(""); const modalNote = ref(false); const note = ref(""); const retireProfileId = ref(""); -const retireld = ref(retireld_params.toString()); const profileId = ref(""); const filter = ref(""); const statusUpload = ref(); @@ -56,7 +56,69 @@ const statusReport = ref(); const dataProfile = ref([]); /** คอลัมน์ที่แสดง */ -const columns = ref([]); +const columns = ref([ + { + name: "order", + label: "ลำดับ", + title: "ลำดับ", + field: "order", + align: "left", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "name", + align: "left", + label: "ชื่อ-นามสกุล", + title: "ชื่อ-นามสกุล", + field: "name", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "position", + align: "left", + label: "ตำแหน่ง", + title: "ตำแหน่ง", + subtitle: employeeType.value == "OFFICER" ? "ในสายงาน" : "", + field: "position", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionType", + align: "left", + label: "ตำแหน่ง", + title: "ตำแหน่ง", + subtitle: employeeType.value == "OFFICER" ? "ประเภท" : "กลุ่มงาน", + field: "positionType", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + + { + name: "positionNumber", + align: "left", + label: "ตำแหน่ง (เลขที่) ", + title: "ตำแหน่ง", + subtitle: "เลขที่", + field: "positionNumber", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "organization", + align: "left", + label: "สังกัด", + title: "สังกัด", + field: "organization", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + format(val: any, row: any) { + return findOrgName(row); + }, + }, +]); const rows = ref([]); const visibleColumns = ref([ "order", @@ -79,118 +141,58 @@ function closeDialog() { } // fecthlist -async function fecthlistprofile(id: string) { +async function fetchlistprofile(id: string) { showLoader(); await http .get(config.API.listRetire(id)) - .then((res) => { - dataProfile.value = res.data.result; - round.value = res.data.result.round; - statusReport.value = res.data.result.json; - typeReport.value = res.data.result.typeReport; - textReport.value = res.data.result.detail; - employeeType.value = res.data.result.type; + .then(async (res) => { + const data = await res.data.result; + + dataProfile.value = data; + round.value = data.round; + statusReport.value = data.json; + typeReport.value = data.typeReport; + textReport.value = data.detail; + employeeType.value = data.type; // รายชื่อผู้เกษียณอายุราชการ - rows.value = res.data.result.profile.map((e: any) => ({ - id: e.id, - profileId: e.profileId, - order: e.order, - prefix: e.prefix, - firstName: e.firstName, - lastName: e.lastName, - name: e.prefix + e.firstName + " " + e.lastName, - organization: e.root, - position: e.position, - positionNumber: e.posNo, - positionType: e.posTypeName, - positionLevel: e.posLevelName, - reason: e.reason, - remove: e.remove, - root: e.root, - rootId: e.rootId, - child1: e.child1, - child1Id: e.child1Id, - child2: e.child2, - child2Id: e.child2Id, - child3: e.child3, - child3Id: e.child3Id, - child4: e.child4, - child4Id: e.child4Id, - })); + if (data.profile !== null) { + rows.value = data.profile.map((e: any) => ({ + id: e.id, + profileId: e.profileId, + order: e.order, + prefix: e.prefix, + firstName: e.firstName, + lastName: e.lastName, + name: e.prefix + e.firstName + " " + e.lastName, + organization: e.root, + position: e.position, + positionNumber: e.posNo, + positionType: e.posTypeName, + positionLevel: e.posLevelName, + reason: e.reason, + remove: e.remove, + root: e.root, + rootId: e.rootId, + child1: e.child1, + child1Id: e.child1Id, + child2: e.child2, + child2Id: e.child2Id, + child3: e.child3, + child3Id: e.child3Id, + child4: e.child4, + child4Id: e.child4Id, + })); + } + if (statusReport.value == false) { - fecthCheck(retireld.value); + await fecthCheck(retireld.value); } else statusUpload.value = true; }) .catch((e) => { messageError($q, e); }) .finally(() => { - //คอลัมน์ - columns.value = [ - { - name: "order", - label: "ลำดับ", - title: "ลำดับ", - field: "order", - align: "left", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "name", - align: "left", - label: "ชื่อ-นามสกุล", - title: "ชื่อ-นามสกุล", - field: "name", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "position", - align: "left", - label: "ตำแหน่ง", - title: "ตำแหน่ง", - subtitle: employeeType.value == "OFFICER" ? "ในสายงาน" : "", - field: "position", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "positionType", - align: "left", - label: "ตำแหน่ง", - title: "ตำแหน่ง", - subtitle: employeeType.value == "OFFICER" ? "ประเภท" : "กลุ่มงาน", - field: "positionType", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - - { - name: "positionNumber", - align: "left", - label: "ตำแหน่ง (เลขที่) ", - title: "ตำแหน่ง", - subtitle: "เลขที่", - field: "positionNumber", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "organization", - align: "left", - label: "สังกัด", - title: "สังกัด", - field: "organization", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - format(val: any, row: any) { - return findOrgName(row); - }, - }, - ]; - hideLoader(); }); } @@ -212,21 +214,23 @@ function clickDelete() { dialogRemove( $q, async () => { + showLoader(); await http .post(config.API.removeProfile(), { retireProfileId: retireProfileId.value, reason: note.value, }) - .then(() => { + .then(async () => { + retireld.value = retireld_params.toString(); + await fetchlistprofile(retireld.value); + modalNote.value = false; success($q, "ลบข้อมูลสำเร็จ"); }) .catch((e) => { messageError($q, e); }) .finally(async () => { - retireld.value = retireld_params.toString(); - await fecthlistprofile(retireld.value); - modalNote.value = false; + hideLoader(); }); }, "ยืนยันการลบข้อมูล", @@ -239,21 +243,23 @@ function saveNote() { dialogConfirm( $q, async () => { + showLoader(); await http .post(config.API.createnote(), { retireProfileId: retireProfileId.value, reason: note.value, }) - .then(() => { + .then(async () => { + retireld.value = retireld_params.toString(); + await fetchlistprofile(retireld.value); + modalNote.value = false; success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((e) => { messageError($q, e); }) - .finally(async () => { - retireld.value = retireld_params.toString(); - fecthlistprofile(retireld.value); - modalNote.value = false; + .finally(() => { + hideLoader(); }); }, "ยืนยันการบันทึกข้อมูล", @@ -264,7 +270,7 @@ function saveNote() { //อัพเดท ListId function UpdateListId(retireld: string, pId: string) { profileId.value = pId; - fecthlistprofile(retireld); + fetchlistprofile(retireld); } // กลับหน้าเดิม @@ -300,18 +306,18 @@ async function uploadFile(event: any, signDate: any) { formdata ) .then(async (res) => { + await fetchlistprofile(retireld.value); + modalUpload.value = false; + success($q, "เพิ่มไฟล์สำเร็จ"); fileUpload.value = null; signDate.value = null; - modalUpload.value = false; - await fecthlistprofile(retireld.value); - await fecthCheck(retireld.value); - hideLoader(); - success($q, "เพิ่มไฟล์สำเร็จ"); }) .catch((err) => { messageError($q, err); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }, "ยืนยันการอัปโหลดเอกสาร", "ต้องการยืนยันการอัปโหลดเอกสารนี้หรือไม่ ?" @@ -333,13 +339,13 @@ async function downloadAttachment(type: string, id: string) { .then(async (res) => { const data = res.data.result; await genReport(data, `รายชื่อผู้เกษียณอายุราชการ`, type); - hideLoader(); }) .catch(async (e) => { messageError($q, JSON.parse(await e.response.data.text())); - hideLoader(); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); } // ยืนยันการแก้ไขข้อมูล @@ -349,17 +355,19 @@ function saveEdiitReport(reason: string) { dialogConfirm( $q, async () => { + showLoader(); await http .put(config.API.editDetail(retireld.value), formdata) .then(() => { + fetchlistprofile(retireld.value); + modalEdit.value = false; success($q, "แก้ไขข้อความสำเร็จ"); }) .catch((err) => { messageError($q, err); }) .finally(() => { - fecthlistprofile(retireld.value); - modalEdit.value = false; + hideLoader(); }); }, "ยืนยันการแก้ไขข้อมูล", @@ -400,9 +408,9 @@ function updatemodalPersonal(modal: boolean) { } /** Hook */ -onMounted(() => { +onMounted(async () => { retireld.value = retireld_params.toString(); - fecthlistprofile(retireld.value); + await fetchlistprofile(retireld.value); }); @@ -525,7 +533,6 @@ onMounted(() => { map-options :options="columns" option-value="name" - style="min-width: 140px" class="gt-xs q-ml-sm" >