diff --git a/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue b/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue index ef7844714..06e79e126 100644 --- a/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue +++ b/src/modules/05_placement/components/PersonalList/DialogSelectOrg.vue @@ -62,6 +62,7 @@ const positionId = ref(""); const seletcId = ref(""); const selectedPos = ref([]); const datePos = ref(new Date()); +const posMasterMain = ref([]); /** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/ async function fetchOrganizationActive() { @@ -140,6 +141,7 @@ async function fetchDataTable(id: string, level: number = 0) { .post(config.API.orgPosPlacement, body) .then((res) => { const dataMain: PositionMaim[] = []; + posMasterMain.value = res.data.result.data; res.data.result.data.forEach((e: PositionNo) => { const p = e.positions; if (p.length !== 0) { @@ -149,6 +151,7 @@ async function fetchDataTable(id: string, level: number = 0) { dataMain.push(data); } }); + positionNo.value = store.fetchPosNo(dataMain); }) .catch((err) => { @@ -190,7 +193,12 @@ async function fetchPosFind(level: number, id: string) { } /** function บันทึกข้อมูลตำแหน่ง*/ -function onClickSubmit() { +async function onClickSubmit() { + const dataPosMaster = await posMasterMain.value?.find( + (e: any) => e.id === positionId.value + ); + const dataNode = await filterNodeFn(nodes.value, nodeId.value); + if (selectedPos.value.length === 0) { dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง"); } else { @@ -203,7 +211,12 @@ function onClickSubmit() { posmasterId: positionId.value, positionId: selectedPos.value[0].id, reportingDate: datePos.value, + organizationName: dataNode.orgTreeName, //ชื่อหน่วยงาน + orgTreeShortName: dataNode.orgTreeShortName, //ชื่อย่อ + posPath: selectedPos.value[0].positionName, //ชื่อตำแหน่ง + posNumber: dataPosMaster.posMasterNo, //เลขที่ตำแหน่ง(เลขอย่่างเดียว) }; + await http .post(config.API.placementPass(), body) .then(() => { @@ -261,6 +274,20 @@ function filterItemsTaps(data: TreeMain[]) { itemTaps.value = orgTreeIds; return orgTreeIds; } + +function filterNodeFn(data: any, id: string) { + for (const child of data) { + if (child.orgTreeId === id) { + return child; + } else if (child.children) { + const result: any = filterNodeFn(child.children, id); + if (result !== null) { + return result; + } + } + } + return null; +}