From b76f5854cf2b63e3ceb84fdba55c1fbf510e9a7a Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 17 Apr 2024 18:06:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=20=3D>=20API=20=20=E0=B8=A5=E0=B8=B1?= =?UTF-8?q?=E0=B8=81=E0=B8=A9=E0=B8=93=E0=B8=B0=E0=B9=82=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=87=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ProjectDetail.vue | 56 ++++++++++------- .../15_development/interface/index/Main.ts | 15 +++-- .../15_development/interface/response/Main.ts | 42 +++++++------ .../interface/response/Strategic.ts | 8 +++ .../15_development/views/Strategic.vue | 60 +++++++++---------- 5 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 src/modules/15_development/interface/response/Strategic.ts diff --git a/src/modules/15_development/components/ProjectDetail.vue b/src/modules/15_development/components/ProjectDetail.vue index 5efda6cb6..52969818c 100644 --- a/src/modules/15_development/components/ProjectDetail.vue +++ b/src/modules/15_development/components/ProjectDetail.vue @@ -6,9 +6,10 @@ import { useCounterMixin } from "@/stores/mixin"; /**importType*/ import type { - DataOption, + DataOptionTechnique, FormProjectDetail, } from "@/modules/15_development/interface/index/Main"; +import type { DataStrategic } from "@/modules/15_development/interface/response/Main"; import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore"; import http from "@/plugins/http"; @@ -27,18 +28,8 @@ const projectTypeOp = ref([ "โครงการใหม่", "โครงการต่อเนื่อง", ]); -// const projectTechniquesOp = ref([ -// { id: "TRAINING", name: "การอบรม" }, -// { id: "MEETING", name: "การประชุม" }, -// { id: "SEMINAR", name: "การสัมมนา" }, -// { id: "STUDY_TOUR", name: "การศึกษาดูงาน" }, -// { id: "ACADEMIC_SEMINAR", name: "การสัมมนาทางวิชาการ" }, -// { id: "WORKSHOP", name: "การสัมมนาเชิงปฏิบัติการ" }, -// { id: "SPECIAL_LECTURE", name: "การบรรยายพิเศษ" }, -// { id: "STUDY_TRAINING", name: "การฝึกศึกษา" }, -// ]); -const projectTechniquesOp = ref([ +const projectTechniquesOp = ref([ { value: "การอบรม", label: "การอบรม" }, { value: "การประชุม", label: "การประชุม" }, { value: "การสัมมนา", label: "การสัมมนา" }, @@ -65,7 +56,7 @@ const formData = reactive({ projectNigthHoldActual: null, developmentProjectTechniqueActuals: [], projectModalActual: null, - projectModalPlanneds: null, + projectModalPlanned: null, strategyChildPlannedId: null, //id ยุทธศาสตร์เป้าหมายตามแผน strategyChildPlannedNode: 0, //node ยุทธศาสตร์เป้าหมายตามแผน strategyChildActualId: null, //id ยุทธศาสตร์เป้าหมายตามจริง @@ -77,8 +68,8 @@ const filter = ref(""); const filter2 = ref(""); const notFound = ref("ไม่พบข้อมูลที่ค้นหา"); const noData = ref("ไม่มีข้อมูล"); -const expanded = ref>([]); -const expanded2 = ref>([]); +const expanded = ref>([]); +const expanded2 = ref>([]); function fetchData() { showLoader(); http @@ -102,10 +93,33 @@ function fetchData() { formData.projectNigthHoldActual = data.projectNigthHoldActual; formData.developmentProjectTechniqueActuals = data.developmentProjectTechniqueActuals; - formData.strategyChildPlannedId = data.strategyChildPlannedId; - formData.strategyChildPlannedNode = data.strategyChildPlannedNode; - formData.strategyChildActualId = data.strategyChildActualId; - formData.strategyChildActualNode = data.strategyChildActualNode; + formData.projectModalPlanned = data.projectModalPlanned; + expanded.value = [ + data.strategyChild1Planned, + data.strategyChild2Planned, + data.strategyChild3Planned, + data.strategyChild4Planned, + data.strategyChild5Planned, + ]; + expanded2.value = [ + data.strategyChild1Actual, + data.strategyChild2Actual, + data.strategyChild3Actual, + data.strategyChild4Actual, + data.strategyChild5Actual, + ]; + const filteredArray = expanded.value.filter((item) => item !== null); + const filteredArray2 = expanded2.value.filter((item) => item !== null); + const lastItem = filteredArray[filteredArray.length - 1]; + const lastItem2 = filteredArray2[filteredArray2.length - 1]; + formData.strategyChildPlannedId = + lastItem !== undefined ? lastItem : null; + formData.strategyChildPlannedNode = + lastItem !== undefined ? filteredArray.length : null; + formData.strategyChildActualId = + lastItem2 !== undefined ? lastItem2 : null; + formData.strategyChildActualNode = + lastItem2 !== undefined ? filteredArray2.length : null; }) .catch((err) => { messageError($q, err); @@ -147,7 +161,7 @@ async function onSubmit() { }); } -function updateSelected(data: any, type: string) { +function updateSelected(data: DataStrategic, type: string) { if (type === "1") { formData.strategyChildPlannedId = data.id; formData.strategyChildPlannedNode = data.level; @@ -388,7 +402,7 @@ onMounted(() => { :disable="store.projectStatus === 'FINISH'" dense outlined - v-model="formData.projectModalPlanneds" + v-model="formData.projectModalPlanned" label="จำนวน (รุ่น)" mask="#" reverse-fill-mask diff --git a/src/modules/15_development/interface/index/Main.ts b/src/modules/15_development/interface/index/Main.ts index 1d179fe89..5cbce7425 100644 --- a/src/modules/15_development/interface/index/Main.ts +++ b/src/modules/15_development/interface/index/Main.ts @@ -7,6 +7,10 @@ interface DataOptionCheckBox { label: string; value: boolean; } +interface DataOptionTechnique { + label: string; + value: string; +} interface FormFilter { page: number; @@ -78,11 +82,11 @@ interface FormProjectDetail { projectNigthHoldActual: string | null; developmentProjectTechniqueActuals: []; projectModalActual?: string | null; - projectModalPlanneds?: string | null; - strategyChildPlannedId: string | null; //id ยุทธศาสตร์เป้าหมายตามแผน - strategyChildPlannedNode: number; //node ยุทธศาสตร์เป้าหมายตามแผน - strategyChildActualId: string | null; //id ยุทธศาสตร์เป้าหมายตามจริง - strategyChildActualNode: number; //node ยุทธศาสตร์เป้าหมายตามจริง + projectModalPlanned?: string | null; + strategyChildPlannedId?: string | null; //id ยุทธศาสตร์เป้าหมายตามแผน + strategyChildPlannedNode: number | null; //node ยุทธศาสตร์เป้าหมายตามแผน + strategyChildActualId?: string | null; //id ยุทธศาสตร์เป้าหมายตามจริง + strategyChildActualNode: number | null; //node ยุทธศาสตร์เป้าหมายตามจริง } export type { @@ -94,4 +98,5 @@ export type { DataPerson, ItemsDownload, FormProjectDetail, + DataOptionTechnique, }; diff --git a/src/modules/15_development/interface/response/Main.ts b/src/modules/15_development/interface/response/Main.ts index be76f2543..469a5b279 100644 --- a/src/modules/15_development/interface/response/Main.ts +++ b/src/modules/15_development/interface/response/Main.ts @@ -110,22 +110,29 @@ interface ResPlannedGoals { } interface ResRecord { -commandDate: Date | null; -commandNumber: string |null; -firstName: string; -fullName: string; -id: string; -idcard: string; -isDone: boolean; -lastName: string; -org: string; -posExecutive: string | null; -posLevelName :string; -posTypeName: string; -position: string; -prefix: string; -trainingDays: number | null; -type: string; + commandDate: Date | null; + commandNumber: string | null; + firstName: string; + fullName: string; + id: string; + idcard: string; + isDone: boolean; + lastName: string; + org: string; + posExecutive: string | null; + posLevelName: string; + posTypeName: string; + position: string; + prefix: string; + trainingDays: number | null; + type: string; +} + +interface DataStrategic { + id: string; + name: string; + level: number; + children: DataStrategic; } export type { @@ -136,5 +143,6 @@ export type { ResPeople, ResActualGoals, ResPlannedGoals, - ResRecord + ResRecord, + DataStrategic, }; diff --git a/src/modules/15_development/interface/response/Strategic.ts b/src/modules/15_development/interface/response/Strategic.ts new file mode 100644 index 000000000..f2aa563cb --- /dev/null +++ b/src/modules/15_development/interface/response/Strategic.ts @@ -0,0 +1,8 @@ +interface DataStrategic { + id: string; + name: string; + level: number; + children: DataStrategic; +} + +export type { DataStrategic }; diff --git a/src/modules/15_development/views/Strategic.vue b/src/modules/15_development/views/Strategic.vue index dce36070b..8c3d1b0a7 100644 --- a/src/modules/15_development/views/Strategic.vue +++ b/src/modules/15_development/views/Strategic.vue @@ -5,6 +5,8 @@ import http from "@/plugins/http"; import config from "@/app.config"; import type { ItemsMenu } from "@/modules/15_development/interface/index/Main"; +import type { DataStrategic } from "@/modules/15_development/interface/response/Strategic"; + import DialogHeader from "@/components/DialogHeader.vue"; import { useCounterMixin } from "@/stores/mixin"; @@ -40,11 +42,9 @@ const ListMenu = ref([ }, ]); -const nodes = ref([]); +const nodes = ref([]); const filter = ref(""); -const notFound = ref("ไม่พบข้อมูลที่ค้นหา"); -const noData = ref("ไม่มีข้อมูล"); -const expanded = ref>([]); +const expanded = ref>([]); const nodeId = ref(""); function fetchDataTree() { @@ -52,7 +52,7 @@ function fetchDataTree() { http .get(config.API.devStrategy) .then((res) => { - const data = res.data.result; + const data: DataStrategic[] = res.data.result; nodes.value = data; }) .catch((err) => { @@ -63,11 +63,7 @@ function fetchDataTree() { }); } -function updateSelected(data: any) { - nodeId.value = data.orgTreeName; -} - -function onClickAction(type: string, data: any = null) { +function onClickAction(type: string, data: DataStrategic | null = null) { switch (type) { case "ADD": onClickOpenDialog(false, data); @@ -76,7 +72,7 @@ function onClickAction(type: string, data: any = null) { onClickOpenDialog(true, data); break; case "DEL": - onDelete(data); + data && onDelete(data); break; default: break; @@ -88,24 +84,27 @@ const isStatusEdit = ref(false); const strategicName = ref(""); const levelnode = ref(0); const titleDialog = ref(""); -function onClickOpenDialog(status: boolean = false, data: any = null) { +function onClickOpenDialog( + status: boolean = false, + data: DataStrategic | null = null +) { isStatusEdit.value = status; if (status) { - console.log(data); - - nodeId.value = data.id; - strategicName.value = data.name; - levelnode.value = data.level; - titleDialog.value = - data.level === 1 - ? "ยุทธศาสตร์" - : data.level === 2 - ? "ยุทธศาสตร์ที่ 1" - : data.level === 3 - ? "ยุทธศาสตร์ย่อย" - : data.level === 4 - ? "กลยุทธ์ที่/เป้าประสงค์ที่" - : ""; + if (data) { + nodeId.value = data.id; + strategicName.value = data.name; + levelnode.value = data.level; + titleDialog.value = + data.level === 1 + ? "ยุทธศาสตร์" + : data.level === 2 + ? "ยุทธศาสตร์ที่ 1" + : data.level === 3 + ? "ยุทธศาสตร์ย่อย" + : data.level === 4 + ? "กลยุทธ์ที่/เป้าประสงค์ที่" + : ""; + } } else { if (data) { titleDialog.value = @@ -155,8 +154,7 @@ function onSubmit() { }); } -function onDelete(data: any) { - console.log(data); +function onDelete(data: DataStrategic) { dialogRemove($q, () => { showLoader(); const formData = { @@ -218,8 +216,8 @@ onMounted(() => { node-key="id" label-key="id" :filter="filter" - :no-results-label="notFound" - :no-nodes-label="noData" + no-results-label="ไม่พบข้อมูลที่ค้นหา" + no-nodes-label="ไม่มีข้อมูล" v-model:expanded="expanded" >