From 8876d481a95d5b1aa2682c675c37a8cc0aa8b8f1 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Thu, 26 Dec 2024 12:02:40 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?/=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81=E0=B8=AA=E0=B8=B9?= =?UTF-8?q?=E0=B8=95=E0=B8=A3=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9D=E0=B8=B6?= =?UTF-8?q?=E0=B8=81=E0=B8=AD=E0=B8=9A=E0=B8=A3=E0=B8=A1=20=E0=B9=80?= =?UTF-8?q?=E0=B8=9B=E0=B9=89=E0=B8=B2=E0=B8=AB=E0=B8=A1=E0=B8=B2=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15_development/components/Target.vue | 38 ++++++++++++------- .../15_development/interface/request/Main.ts | 13 +++---- .../15_development/interface/response/Main.ts | 17 +++++---- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/modules/15_development/components/Target.vue b/src/modules/15_development/components/Target.vue index 7a2b8790a..d861b602c 100644 --- a/src/modules/15_development/components/Target.vue +++ b/src/modules/15_development/components/Target.vue @@ -47,6 +47,7 @@ const checkRoutePermission = ref( ); const plannedGoals = ref([]); +const plannedGoalsData = ref([]); const plannedPeoples = ref([]); const actualGoals = ref([]); const actualPeoples = ref([]); @@ -253,6 +254,7 @@ async function fetchData(id: string) { actualGoals.value = data.actualGoals; actualPeoples.value = data.actualPeoples; plannedGoals.value = data.plannedGoals; + plannedGoalsData.value = data.plannedGoals; plannedPeoples.value = data.plannedPeoples; }) .catch((err) => { @@ -287,6 +289,7 @@ function onClickOpenDialog(type: string, target: string) { /** เพิ่ม/แก้ไขกลุ่มเป้าหมาย */ function onSubmitGroup() { dialogConfirm($q, async () => { + showLoader(); if (isTarget.value === "planned") { await http .put( @@ -362,6 +365,7 @@ function onSubmitGroup() { /** เพิ่มผู้เกี่ยวข้อง */ function onSubmitRelate() { dialogConfirm($q, async () => { + showLoader(); if (isTarget.value === "planned") { await http .put( @@ -487,6 +491,25 @@ function deleteTargetData(index: any) { formGroupTarget.positions.splice(index, 1); } +function onOpenDialog(data: any) { + isEdit.value = true; + isTarget.value = "planned"; + editId.value = data.id; + formGroupTarget.type = data.type; + formGroupTarget.groupTarget = data.groupTarget; + formGroupTarget.groupTargetSub = data.groupTargetSub; + formGroupTarget.amount = data.amount; + formGroupTarget.positions = ( + plannedGoalsData.value.find((item: any) => item.id === data.id)?.position || + [] + ).map((pos: any) => ({ + position: pos.position, + posTypeId: pos.posTypeId || null, + posLevelId: pos.posLevelId || null, + })); + newModalGroupTarget.value = true; +} + /** ดึงข้อมูลเมื่อคอมโพเนนต์โหลดเสร็จสมบูรณ์ */ onMounted(() => { fetchType(); @@ -542,7 +565,6 @@ onMounted(() => {
{ color="primary" icon="mdi-pencil-outline" size="14px" - @click=" - () => { - isEdit = true; - isTarget = 'planned'; - editId = props.row.id; - formGroupTarget.type = props.row.type; - formGroupTarget.groupTarget = props.row.groupTarget; - formGroupTarget.groupTargetSub = props.row.groupTargetSub; - formGroupTarget.amount = props.row.amount; - formGroupTarget.positions = props.row.position; - newModalGroupTarget = true; - } - " + @click="onOpenDialog(props.row)" > แก้ไขข้อมูล diff --git a/src/modules/15_development/interface/request/Main.ts b/src/modules/15_development/interface/request/Main.ts index de690a09d..ac990300a 100644 --- a/src/modules/15_development/interface/request/Main.ts +++ b/src/modules/15_development/interface/request/Main.ts @@ -30,13 +30,7 @@ interface FormGroupTarget { } interface FormGroupTargetPlannedGoal { - positions: [ - { - position: string; - posTypeId: string | null; - posLevelId: string | null; - } - ]; + positions: PositionsType[]; plannedGoalPositions?: [ { position: string; @@ -53,6 +47,11 @@ interface FormGroupTargetPlannedGoal { amount: number | null; } +interface PositionsType { + position: string; + posTypeId: string | null; + posLevelId: string | null; +} interface FormGroupRelate { relate: string; amount: number | null; diff --git a/src/modules/15_development/interface/response/Main.ts b/src/modules/15_development/interface/response/Main.ts index 59094feaa..c59dc686d 100644 --- a/src/modules/15_development/interface/response/Main.ts +++ b/src/modules/15_development/interface/response/Main.ts @@ -96,19 +96,21 @@ interface ResPlannedGoals { posLevelPlannedId: string; } ]; - positions?: [ - { - position: string; - posTypePlannedId: string; - posLevelPlannedId: string; - } - ]; + position: PositionsType[]; posTypePlannedId: string; posLevelPlannedId: string; type: string | null; amount: number | null; } +interface PositionsType { + id: string; + posLevel: string; + posLevelId: string; + posType: string; + posTypeId: string; + position: string; +} interface ResRecord { commandDate: Date | null; commandNumber: string | null; @@ -219,4 +221,5 @@ export type { ResHistory, ResPrefix, ResRisk, + PositionsType };