From f560099626777255346f758e8f084b2bda8d02b3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 21 Feb 2024 16:04:40 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9A=E0=B8=A3=E0=B8=A3=E0=B8=88=E0=B8=B8?= =?UTF-8?q?=20=3D>=20=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B8=AA=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B9=83=E0=B8=99=E0=B8=A3=E0=B8=AD=E0=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PersonalList/DialogSelectOrg.vue | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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; +}