From 0dfe2f5e133d3ddf36ebc03b465e44eea6bb11b3 Mon Sep 17 00:00:00 2001 From: oat_dev Date: Wed, 10 Apr 2024 10:37:46 +0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=E0=B9=80=E0=B8=9B=E0=B9=89?= =?UTF-8?q?=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 | 40 ++++++++++++------- .../15_development/interface/request/Main.ts | 35 +++++++++++++--- .../15_development/interface/response/Main.ts | 15 ++++--- 3 files changed, 65 insertions(+), 25 deletions(-) diff --git a/src/modules/15_development/components/Target.vue b/src/modules/15_development/components/Target.vue index 0558b00c4..10ba8cfd7 100644 --- a/src/modules/15_development/components/Target.vue +++ b/src/modules/15_development/components/Target.vue @@ -9,6 +9,7 @@ import type { DataOption } from "@/modules/15_development/interface/index/Main"; import type { FormGroupTarget, FormGroupRelate, + FormGroupTargetPlannedGoal, } from "@/modules/15_development/interface/request/Main"; import type { ResGroup, @@ -151,7 +152,7 @@ const newModalGroupTarget = ref(false); const modalRelate = ref(false); const isTarget = ref(""); -const formGroupTarget = reactive({ +const formGroupTarget = reactive({ groupTarget: "", groupTargetSub: "", position: "", @@ -159,6 +160,18 @@ const formGroupTarget = reactive({ level: "", type: "", amount: null, + // positions: { + // position: "", + // posTypePlannedId: "", + // posLevelPlannedId: "", + // }, + positions: [ + { + position: "", + posTypePlannedId: "", + posLevelPlannedId: "", + }, + ], }); const formGroupRelate = reactive({ @@ -206,15 +219,14 @@ function onSubmitGroup() { if (isTarget.value === "planned") { const data = []; data.push(formGroupTarget); - const list = data.map((e: FormGroupTarget) => ({ + const list = data.map((e: FormGroupTargetPlannedGoal) => ({ groupTarget: e.groupTarget, groupTargetSub: e.groupTargetSub, - position: e.position, - posTypePlannedId: e.posType, - posLevelPlannedId: e.level, - type: e.type, + positions: e.positions, + type: e.type ? e.type : null, amount: Number(e.amount), })); + console.log(list); if (isEdit.value) { plannedGoals.value.splice(rowIndex.value, 1, ...list); } else { @@ -230,7 +242,7 @@ function onSubmitGroup() { position: e.position, posTypeActualId: e.posType, posLevelActualId: e.level, - type: e.type, + type: e.type ? e.type : null, amount: Number(e.amount), })); if (isEdit.value) { @@ -348,15 +360,15 @@ function convertTypeGoals(id: string) { } const addGroupTargetData = async () => { - groupTargetData.targetData.push({ + formGroupTarget.positions.push({ position: "", - posType: "", - level: "", + posTypePlannedId: "", + posLevelPlannedId: "", }); }; function deleteTargetData(index: any) { - groupTargetData.targetData.splice(index, 1); + formGroupTarget.positions.splice(index, 1); } onMounted(() => { @@ -949,7 +961,7 @@ onMounted(() => {
{ hide-bottom-space lazy-rules class="inputgreen" - v-model="items.posType" + v-model="items.posTypePlannedId" :options="posTypeOp" option-label="name" option-value="id" @@ -1004,7 +1016,7 @@ onMounted(() => { hide-bottom-space lazy-rules class="inputgreen" - v-model="items.level" + v-model="items.posLevelPlannedId" :options="posLevelOp" option-label="name" option-value="id" diff --git a/src/modules/15_development/interface/request/Main.ts b/src/modules/15_development/interface/request/Main.ts index 0c75adf42..fc7e6bf69 100644 --- a/src/modules/15_development/interface/request/Main.ts +++ b/src/modules/15_development/interface/request/Main.ts @@ -20,7 +20,25 @@ interface FormGroupTarget { position: string; posType: string | null; level: string | null; - type: string; + type: string | null; + amount: number | null; +} + +interface FormGroupTargetPlannedGoal { + positions:[ + { + position: string, + posTypePlannedId: string, + posLevelPlannedId: string, + } + ] + ; + groupTarget: string; + groupTargetSub: string; + position: string; + posType: string | null; + level: string | null; + type: string | null; amount: number | null; } @@ -178,17 +196,21 @@ interface actualGoals { position: string; posTypeActualId: string | null; posLevelActualId: string | null; - type: string; + type: string | null; amount: number | null; } interface PlannedGoals { groupTarget: string; groupTargetSub: string; - position: string; - posTypePlannedId: string | null; - posLevelPlannedId: string | null; - type: string; + positions:[ + { + position: string, + posTypePlannedId: string, + posLevelPlannedId: string, + } + ] + type: string | null; amount: number | null; } @@ -203,4 +225,5 @@ export type { FormAddHistory, FormAddHistoryProject, FormAddHistoryEmployee, + FormGroupTargetPlannedGoal }; diff --git a/src/modules/15_development/interface/response/Main.ts b/src/modules/15_development/interface/response/Main.ts index 44e7d1ff2..05379d249 100644 --- a/src/modules/15_development/interface/response/Main.ts +++ b/src/modules/15_development/interface/response/Main.ts @@ -81,17 +81,22 @@ interface ResActualGoals { position: string; posTypeActualId: string | null; posLevelActualId: string | null; - type: string; + type: string | null; amount: number | null; } interface ResPlannedGoals { groupTarget: string; groupTargetSub: string; - position: string; - posTypePlannedId: string | null; - posLevelPlannedId: string | null; - type: string; + positions:[ + { + position: string, + posTypePlannedId: string, + posLevelPlannedId: string, + } + ] + ; + type: string | null; amount: number | null; }