เป้าหมาย(ยังไม่เสร็จ)
This commit is contained in:
parent
9f01c9ac4c
commit
4d5c98fa57
2 changed files with 199 additions and 116 deletions
|
|
@ -49,7 +49,7 @@ function updateAgency(name: string) {
|
|||
async function fetchData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.developmentBasicInfoById(id))
|
||||
.get(config.API.developmentMainTab("tab1", id))
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
formData.year = data.year;
|
||||
|
|
@ -67,7 +67,7 @@ async function fetchData(id: string) {
|
|||
|
||||
async function editData(id: string) {
|
||||
await http
|
||||
.put(config.API.developmentBasicInfoById(id), {
|
||||
.put(config.API.developmentMainTab("tab1", id), {
|
||||
year: formData.year,
|
||||
reason: formData.reason,
|
||||
projectName: formData.projectName,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { onMounted, ref, reactive } from "vue";
|
|||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import { useRoute } from "vue-router";
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { DataOption } from "@/modules/15_development/interface/index/Main";
|
||||
import type {
|
||||
|
|
@ -23,10 +23,20 @@ import DialogHeader from "@/components/DialogHeader.vue";
|
|||
|
||||
import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const route = useRoute();
|
||||
const projectId = ref<string>(route.params.id.toLocaleString());
|
||||
const $q = useQuasar();
|
||||
const store = useDevelopmentDataStore();
|
||||
const { dialogRemove, success, messageError } = useCounterMixin();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogRemove,
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
messageError,
|
||||
success,
|
||||
date2Thai,
|
||||
} = mixin;
|
||||
const groupTargetData: any = reactive({
|
||||
targetData: [{}],
|
||||
});
|
||||
|
|
@ -146,7 +156,7 @@ const groupSubOp = ref<DataOption[]>([
|
|||
]);
|
||||
|
||||
const isEdit = ref<boolean>(false);
|
||||
const rowIndex = ref<number>(0);
|
||||
const editId = ref<string>("");
|
||||
const modalGroupTarget = ref<boolean>(false);
|
||||
const newModalGroupTarget = ref<boolean>(false);
|
||||
const modalRelate = ref<boolean>(false);
|
||||
|
|
@ -160,11 +170,6 @@ const formGroupTarget = reactive<FormGroupTargetPlannedGoal>({
|
|||
level: "",
|
||||
type: null,
|
||||
amount: null,
|
||||
// positions: {
|
||||
// position: "",
|
||||
// posTypePlannedId: "",
|
||||
// posLevelPlannedId: "",
|
||||
// },
|
||||
positions: [
|
||||
{
|
||||
position: "",
|
||||
|
|
@ -202,11 +207,37 @@ function fetchType() {
|
|||
}
|
||||
}
|
||||
|
||||
async function fetchData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.developmentMainTab("tab2", id))
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
actualGoals.value = data.actualGoals;
|
||||
actualPeoples.value = data.actualPeoples;
|
||||
plannedGoals.value = data.plannedGoals;
|
||||
plannedPeoples.value = data.plannedPeoples;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function onClickOpenDialog(type: string, target: string) {
|
||||
isTarget.value = target;
|
||||
if (type === "group") {
|
||||
if (target === "planned") {
|
||||
newModalGroupTarget.value = true;
|
||||
(formGroupTarget.positions = [
|
||||
{
|
||||
position: "",
|
||||
posTypePlannedId: "",
|
||||
posLevelPlannedId: "",
|
||||
},
|
||||
]),
|
||||
(newModalGroupTarget.value = true);
|
||||
} else {
|
||||
modalGroupTarget.value = true;
|
||||
}
|
||||
|
|
@ -215,72 +246,114 @@ function onClickOpenDialog(type: string, target: string) {
|
|||
}
|
||||
}
|
||||
|
||||
function onSubmitGroup() {
|
||||
async function onSubmitGroup() {
|
||||
if (isTarget.value === "planned") {
|
||||
const data = [];
|
||||
data.push(formGroupTarget);
|
||||
const list = data.map((e: FormGroupTargetPlannedGoal) => ({
|
||||
groupTarget: e.groupTarget,
|
||||
groupTargetSub: e.groupTargetSub,
|
||||
positions: e.positions.map((v: any) => ({
|
||||
position: v.position,
|
||||
posTypePlannedId: v.posTypePlannedId,
|
||||
posLevelPlannedId: v.posLevelPlannedId,
|
||||
})),
|
||||
type: e.type ? e.type : null,
|
||||
amount: Number(e.amount),
|
||||
}));
|
||||
if (isEdit.value) {
|
||||
plannedGoals.value.splice(rowIndex.value, 1, ...list);
|
||||
} else {
|
||||
plannedGoals.value.push(...list);
|
||||
}
|
||||
store.formAddProject.plannedGoals = plannedGoals.value;
|
||||
await http
|
||||
.put(
|
||||
config.API.developmentMainTab(
|
||||
isEdit.value ? "tab2_1_edit" : "tab2_1_add",
|
||||
isEdit.value ? editId.value : projectId.value
|
||||
),
|
||||
{
|
||||
groupTarget: formGroupTarget.groupTarget,
|
||||
groupTargetSub: formGroupTarget.groupTargetSub,
|
||||
positions: formGroupTarget.positions.map((v) => ({
|
||||
position: v.position,
|
||||
posTypePlannedId: v.posTypePlannedId,
|
||||
posLevelPlannedId: v.posLevelPlannedId,
|
||||
})),
|
||||
type: formGroupTarget.type ? formGroupTarget.type : "",
|
||||
amount: formGroupTarget.amount,
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
} else {
|
||||
const data = [];
|
||||
data.push(formGroupTarget);
|
||||
const list = data.map((e: FormGroupTarget) => ({
|
||||
groupTarget: e.groupTarget,
|
||||
groupTargetSub: e.groupTargetSub,
|
||||
position: e.position,
|
||||
posTypeActualId: e.posType,
|
||||
posLevelActualId: e.level,
|
||||
type: e.type ? e.type : null,
|
||||
amount: Number(e.amount),
|
||||
}));
|
||||
if (isEdit.value) {
|
||||
actualGoals.value.splice(rowIndex.value, 1, ...list);
|
||||
} else {
|
||||
actualGoals.value.push(...list);
|
||||
}
|
||||
store.formAddProject.actualGoals = actualGoals.value;
|
||||
await http
|
||||
.put(
|
||||
config.API.developmentMainTab(
|
||||
isEdit.value ? "tab2_3_edit" : "tab2_3_add",
|
||||
isEdit.value ? editId.value : projectId.value
|
||||
),
|
||||
{
|
||||
groupTarget: formGroupTarget.groupTarget,
|
||||
groupTargetSub: formGroupTarget.groupTargetSub,
|
||||
position: formGroupTarget.position,
|
||||
posTypeActualId: formGroupTarget.posType,
|
||||
posLevelActualId: formGroupTarget.level,
|
||||
type: formGroupTarget.type,
|
||||
amount: formGroupTarget.amount,
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
fetchData(projectId.value);
|
||||
onClickCloseDialog();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function onSubmitRelate() {
|
||||
async function onSubmitRelate() {
|
||||
if (isTarget.value === "planned") {
|
||||
const data = [];
|
||||
data.push(formGroupRelate);
|
||||
const list = data.map((e: FormGroupRelate) => ({
|
||||
groupTarget: e.relate,
|
||||
amount: Number(e.amount),
|
||||
}));
|
||||
plannedPeoples.value.push(...list);
|
||||
store.formAddProject.plannedPeoples = plannedPeoples.value;
|
||||
await http
|
||||
.put(
|
||||
config.API.developmentMainTab(
|
||||
isEdit.value ? "tab2_2_edit" : "tab2_2_add",
|
||||
isEdit.value ? editId.value : projectId.value
|
||||
),
|
||||
{
|
||||
groupTarget: formGroupRelate.relate,
|
||||
amount: formGroupRelate.amount,
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
} else {
|
||||
const data = [];
|
||||
data.push(formGroupRelate);
|
||||
const list = data.map((e: FormGroupRelate) => ({
|
||||
groupTarget: e.relate,
|
||||
amount: Number(e.amount),
|
||||
}));
|
||||
actualPeoples.value.push(...list);
|
||||
store.formAddProject.actualPeoples = actualPeoples.value;
|
||||
await http
|
||||
.put(
|
||||
config.API.developmentMainTab(
|
||||
isEdit.value ? "tab2_4_edit" : "tab2_4_add",
|
||||
isEdit.value ? editId.value : projectId.value
|
||||
),
|
||||
{
|
||||
groupTarget: formGroupRelate.relate,
|
||||
amount: formGroupRelate.amount,
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
fetchData(projectId.value);
|
||||
onClickCloseDialog();
|
||||
}, 100);
|
||||
}
|
||||
|
|
@ -376,20 +449,21 @@ function deleteTargetData(index: any) {
|
|||
|
||||
onMounted(() => {
|
||||
fetchType();
|
||||
plannedGoals.value = store.formAddProject.plannedGoals
|
||||
? store.formAddProject.plannedGoals
|
||||
: [];
|
||||
plannedPeoples.value = store.formAddProject.plannedPeoples
|
||||
? store.formAddProject.plannedPeoples
|
||||
: [];
|
||||
fetchData(projectId.value);
|
||||
// plannedGoals.value = store.formAddProject.plannedGoals
|
||||
// ? store.formAddProject.plannedGoals
|
||||
// : [];
|
||||
// plannedPeoples.value = store.formAddProject.plannedPeoples
|
||||
// ? store.formAddProject.plannedPeoples
|
||||
// : [];
|
||||
|
||||
actualGoals.value = store.formAddProject.actualGoals
|
||||
? store.formAddProject.actualGoals
|
||||
: [];
|
||||
// actualGoals.value = store.formAddProject.actualGoals
|
||||
// ? store.formAddProject.actualGoals
|
||||
// : [];
|
||||
|
||||
actualPeoples.value = store.formAddProject.actualPeoples
|
||||
? store.formAddProject.actualPeoples
|
||||
: [];
|
||||
// actualPeoples.value = store.formAddProject.actualPeoples
|
||||
// ? store.formAddProject.actualPeoples
|
||||
// : [];
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
|
|
@ -405,6 +479,7 @@ onMounted(() => {
|
|||
v-close-popup
|
||||
@click="
|
||||
cleanFormData();
|
||||
isEdit = false;
|
||||
onClickOpenDialog('group', 'planned');
|
||||
"
|
||||
>
|
||||
|
|
@ -413,7 +488,10 @@ onMounted(() => {
|
|||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="onClickOpenDialog('relate', 'planned')"
|
||||
@click="
|
||||
isEdit = false;
|
||||
onClickOpenDialog('relate', 'planned');
|
||||
"
|
||||
>
|
||||
<q-item-section>ผู้เกี่ยวข้อง</q-item-section>
|
||||
</q-item>
|
||||
|
|
@ -464,28 +542,20 @@ onMounted(() => {
|
|||
() => {
|
||||
isEdit = true;
|
||||
isTarget = 'planned';
|
||||
rowIndex = props.rowIndex;
|
||||
|
||||
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.positions;
|
||||
formGroupTarget.positions =
|
||||
props.row.plannedGoalPositions;
|
||||
newModalGroupTarget = true;
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
<!-- <q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
icon="delete"
|
||||
color="red"
|
||||
@click="onclickDelete(props.rowIndex, 'plannedGoals')"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn> -->
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
|
|
@ -522,15 +592,25 @@ onMounted(() => {
|
|||
</q-td>
|
||||
<q-td>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
icon="delete"
|
||||
color="red"
|
||||
@click="onclickDelete(props.rowIndex, 'plannedPeoples')"
|
||||
flat
|
||||
color="primary"
|
||||
icon="mdi-pencil-outline"
|
||||
size="14px"
|
||||
@click="
|
||||
() => {
|
||||
isEdit = true;
|
||||
|
||||
isTarget = 'planned';
|
||||
editId = props.row.id;
|
||||
formGroupRelate.relate = props.row.groupTarget;
|
||||
formGroupRelate.amount = props.row.amount;
|
||||
modalRelate = true;
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
|
|
@ -606,28 +686,22 @@ onMounted(() => {
|
|||
@click="
|
||||
() => {
|
||||
isEdit = true;
|
||||
|
||||
isTarget = 'actual';
|
||||
rowIndex = props.rowIndex;
|
||||
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.position = props.row.position;
|
||||
formGroupTarget.posType = props.row.posTypeActualId;
|
||||
formGroupTarget.level = props.row.posLevelActualId;
|
||||
modalGroupTarget = true;
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
<!-- <q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
icon="delete"
|
||||
color="red"
|
||||
@click="onclickDelete(props.rowIndex, 'actualGoals')"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn> -->
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
|
|
@ -664,15 +738,24 @@ onMounted(() => {
|
|||
</q-td>
|
||||
<q-td>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
icon="delete"
|
||||
color="red"
|
||||
@click="onclickDelete(props.rowIndex, 'actualPeoples')"
|
||||
flat
|
||||
color="primary"
|
||||
icon="mdi-pencil-outline"
|
||||
size="14px"
|
||||
@click="
|
||||
() => {
|
||||
isEdit = true;
|
||||
isTarget = 'actual';
|
||||
editId = props.row.id;
|
||||
formGroupRelate.relate = props.row.groupTarget;
|
||||
formGroupRelate.amount = props.row.amount;
|
||||
modalRelate = true;
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue