From ab4a83eb2e6518a6b2f592f90b8fc33edac0ae83 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 18 Apr 2024 12:21:10 +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>=20=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B9=84=E0=B8=82=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3/=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81?= =?UTF-8?q?=E0=B8=AA=E0=B8=B9=E0=B8=95=E0=B8=A3=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=9D=E0=B8=B6=E0=B8=81=E0=B8=AD=E0=B8=9A=E0=B8=A3=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15_development/components/BasicInfo.vue | 349 ++++++++++++------ .../15_development/interface/request/Main.ts | 4 +- src/modules/15_development/views/History.vue | 8 +- 3 files changed, 249 insertions(+), 112 deletions(-) diff --git a/src/modules/15_development/components/BasicInfo.vue b/src/modules/15_development/components/BasicInfo.vue index 3f15b64bd..e2f80d0ac 100644 --- a/src/modules/15_development/components/BasicInfo.vue +++ b/src/modules/15_development/components/BasicInfo.vue @@ -30,21 +30,19 @@ const projectId = ref(route.params.id.toLocaleString()); const formData = reactive({ year: new Date().getFullYear(), - org: "", projectName: "", reason: "", objective: "", + node: null, + nodeId: null, + orgRevisionId: null, }); -const rows = ref([]); - -const modalDialogSelect = ref(false); -function selectAgency() { - modalDialogSelect.value = true; -} -function updateAgency(name: string) { - formData.org = name; -} +const orgName = ref(""); +const node = ref([]); +const nodeId = ref(""); +const filter = ref(""); +const expanded = ref([]); async function fetchData(id: string) { showLoader(); @@ -56,6 +54,17 @@ async function fetchData(id: string) { formData.reason = data.reason; formData.projectName = data.projectName; formData.objective = data.objective; + formData.nodeId = data.nodeId; + + const test = await searchAndReplace(node.value, formData?.nodeId); + console.log(test); + + const parts = test.orgName.split("/"); + for (let i = 0; i < parts.length; i++) { + const arrangedParts = parts[i]; + expanded.value.push(arrangedParts); + } + updateSelected(test); }) .catch((err) => { messageError($q, err); @@ -67,12 +76,7 @@ async function fetchData(id: string) { async function editData(id: string) { await http - .put(config.API.developmentMainTab("tab1", id), { - year: formData.year, - reason: formData.reason, - projectName: formData.projectName, - objective: formData.objective, - }) + .put(config.API.developmentMainTab("tab1", id), formData) .then(() => { fetchData(id); success($q, "บันทึกข้อมูลสำเร็จ"); @@ -93,106 +97,229 @@ function onSubmit() { }); } +function fetchActive() { + showLoader(); + http + .get(config.API.activeOrganization) + .then((res) => { + const data = res.data.result; + fetchTree(data.activeId); + }) + .catch((err) => { + messageError($q, err); + hideLoader(); + }); +} + +async function fetchTree(id: string) { + showLoader(); + http + .get(config.API.orgByid(id.toString())) + .then(async (res) => { + const data = res.data.result; + node.value = data; + fetchData(projectId.value); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +function updateSelected(data: any) { + console.log(expanded.value); + + nodeId.value = data.orgTreeId; + orgName.value = data.orgTreeName; + formData.node = data.orgLevel; + formData.nodeId = data.orgTreeId; + formData.orgRevisionId = data.orgRevisionId; +} + +function searchAndReplace(orgTreeData: any, treeId: string | null) { + for (let orgTree of orgTreeData) { + if (orgTree.orgTreeId === treeId) { + return orgTree; + } + let foundOrg: any = searchAndReplace(orgTree.children, treeId); + if (foundOrg) { + return foundOrg; + } + } + return null; +} + onMounted(async () => { - fetchData(projectId.value); + fetchActive(); + // setTimeout(() => { + // fetchData(projectId.value); + // }, 500); }); + + + + +
+ +
+
+ + /> +
+
+ +
+
+ +
+ + + -
- -
-
- -
- +
@@ -210,10 +337,18 @@ onMounted(async () => {
- + /> --> - + diff --git a/src/modules/15_development/interface/request/Main.ts b/src/modules/15_development/interface/request/Main.ts index 9becd25ac..ab597d054 100644 --- a/src/modules/15_development/interface/request/Main.ts +++ b/src/modules/15_development/interface/request/Main.ts @@ -9,10 +9,12 @@ interface FormQueryListProject { interface FormBasicinfo { year: number; - org: string; projectName: string; reason: string; objective: string; + node: number | null; + nodeId: string | null; + orgRevisionId: string | null; } interface FormGroupTarget { diff --git a/src/modules/15_development/views/History.vue b/src/modules/15_development/views/History.vue index 5d12a9afb..28f4bf4ba 100644 --- a/src/modules/15_development/views/History.vue +++ b/src/modules/15_development/views/History.vue @@ -1,18 +1,18 @@