diff --git a/src/modules/05_placement/components/AppointEmployee/Main.vue b/src/modules/05_placement/components/AppointEmployee/Main.vue index aab94518c..6cf5ccf4c 100644 --- a/src/modules/05_placement/components/AppointEmployee/Main.vue +++ b/src/modules/05_placement/components/AppointEmployee/Main.vue @@ -7,6 +7,7 @@ import { useCounterMixin } from "@/stores/mixin"; import { useTransferDataStore } from "@/modules/05_placement/store"; import Dialogbody from "@/modules/05_placement/components/AppointEmployee/Dialogbody.vue"; import DialogOrgTree from "@/modules/05_placement/components/AppointEmployee/Modal.vue"; +import DialogHeader from "@/modules/05_placement/components/AppointMent/DialogHeader.vue"; import type { listAppointType, resData, @@ -28,12 +29,15 @@ const { messageError, date2Thai, dialogRemove, + dialogConfirm, + dialogMessageNotify } = mixin; - +const rowsPosition = ref([]); const router = useRouter(); const rows = ref([]); const rows2 = ref([]); const modalTree = ref(false); +const ModalEmployee = ref(false) const personal = ref([]); const personalId = ref(""); const filterKeyword = ref(""); @@ -42,7 +46,7 @@ const filterRef = ref(null); const listRecevice = ref([]); const optionsType = ref([]); const type = ref(""); - + const selectedPosition = ref([]); const visibleColumns = ref([ "no", "citizenId", @@ -52,12 +56,124 @@ const visibleColumns = ref([ "createdAt", "status", ]); +const visibleColumnsPosition = ref([ + "organizationOrganizationName", + "organizationAgencyName", + "organizationGovernmentAgencyName", + "organizationShortNameName", + "organizationTypeName", + "organizationLevelName", + "positionEmployeeLineName", + "positionEmployeePositionName", + "posNo", +]); const pagination = ref({ sortBy: "createdAt", descending: true, page: 1, rowsPerPage: 10, }); +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 columns = ref([ { name: "no", @@ -201,10 +317,79 @@ const fecthTypeOption = async () => { }); }; // เปิดโครงสร้าง -const openModalTree = (id: string) => { +const openModalEmployee = async(id: string) => { personalId.value = id; - personal.value = listRecevice.value.filter((e) => e.id === id); - modalTree.value = true; + + await getPosition(id) +}; +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: r.id, + agency: r.agency, + conditionNote: r.conditionNote, + department: r.department, + government: r.government, + isActive: r.isActive, + isCondition: r.isCondition, + isDirector: r.isDirector, + organizationUserNote: r.organizationUserNote, + qualification: r.qualification, + pile: r.pile, + posNo: r.posNo, + positionCondition: r.positionCondition, + positionMasterUserNote: r.positionMasterUserNote, + organizationOrder: r.organizationOrder, + organizationFaxId: r.organizationFaxId, + organizationLevelId: r.organizationLevelId, + organizationOrganizationId: r.organizationOrganizationId, + organizationTelExternalId: r.organizationTelExternalId, + organizationTelInternalId: r.organizationTelInternalId, + organizationTypeId: r.organizationTypeId, + positionEmployeeStatusId: r.positionEmployeeStatusId, + positionEmployeeLineId: r.positionEmployeeLineId, + positionEmployeePositionId: r.positionEmployeePositionId, + organizationAgencyId: r.organizationAgencyId, + organizationGovernmentAgencyId: r.organizationGovernmentAgencyId, + organizationShortNameId: r.organizationShortNameId, + organizationFaxName: r.organizationFaxName, + organizationLevelName: r.organizationLevelName, + organizationOrganizationName: r.organizationOrganizationName, + organizationTelExternalName: r.organizationTelExternalName, + organizationTelInternalName: r.organizationTelInternalName, + organizationTypeName: r.organizationTypeName, + positionEmployeeStatusName: r.positionEmployeeStatusName, + positionEmployeeLineName: r.positionEmployeeLineName, + positionEmployeePositionName: r.positionEmployeePositionName, + organizationAgencyName: r.organizationAgencyName, + organizationGovernmentAgencyName: r.organizationGovernmentAgencyName, + organizationShortNameName: 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; + ModalEmployee.value = true; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); }; //เเจ้งเตือนลบข้อมูล const clickDelete = (id: string) => { @@ -247,6 +432,7 @@ const resetFilter = () => { //ปิด modal const clickClose = () => { modal.value = false; + ModalEmployee.value = false; }; //เปิด modal const popup = () => { @@ -254,6 +440,51 @@ const popup = () => { filterKeyword2.value = ""; fecthTypeOption(); }; + +const checkSave = () => { + dialogConfirm($q, async () => await saveData()); +}; + +// เช็คข้อมูลก่อนบันทึกการกำหนดตำแหน่ง +const saveData = async () => { + if (selectedPosition.value.length == 0) { + dialogMessageNotify($q, "ไม่สามารถบันทึกข้อมูลได้ กรุณาเลือกตำแหน่ง"); + return; + } else { + await savePosition(); + } +}; + +// บันทึกการกำหนดตำแหน่ง +const savePosition = async () => { + clickClose(); + // 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(); + // clickClose(); + // }); +}; + +// // ปิด dialog กำหนดตำแหน่ง +// const modalOpenClose = () => { +// modal.value = !modal.value; +// if (!modal.value) { +// selectedPosition.value = []; +// rowsPosition.value = []; +// id.value = ""; +// } +// };