refactor: เป้าหมาย

This commit is contained in:
oat_dev 2024-04-10 10:37:46 +07:00
parent ec36ffe6ba
commit 0dfe2f5e13
3 changed files with 65 additions and 25 deletions

View file

@ -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<boolean>(false);
const modalRelate = ref<boolean>(false);
const isTarget = ref<string>("");
const formGroupTarget = reactive<FormGroupTarget>({
const formGroupTarget = reactive<FormGroupTargetPlannedGoal>({
groupTarget: "",
groupTargetSub: "",
position: "",
@ -159,6 +160,18 @@ const formGroupTarget = reactive<FormGroupTarget>({
level: "",
type: "",
amount: null,
// positions: {
// position: "",
// posTypePlannedId: "",
// posLevelPlannedId: "",
// },
positions: [
{
position: "",
posTypePlannedId: "",
posLevelPlannedId: "",
},
],
});
const formGroupRelate = reactive<FormGroupRelate>({
@ -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(() => {
</q-btn>
</div>
<div
v-for="(items, index) in groupTargetData.targetData"
v-for="(items, index) in formGroupTarget.positions"
class="col-12 row q-col-gutter-md"
>
<div
@ -979,7 +991,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"

View file

@ -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
};

View file

@ -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;
}