From 1757de73ff2bc1e708fc1bd4eb26277ad141ab42 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 22 Apr 2024 09:55:17 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=20=3D>=20=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20inter?= =?UTF-8?q?face?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15_development/components/BasicInfo.vue | 88 +++---- .../15_development/components/MainTab.vue | 234 ++---------------- .../15_development/interface/response/Main.ts | 31 +++ src/modules/15_development/views/MainPage.vue | 78 +++--- 4 files changed, 141 insertions(+), 290 deletions(-) diff --git a/src/modules/15_development/components/BasicInfo.vue b/src/modules/15_development/components/BasicInfo.vue index 0ae8749a7..d8e5c314f 100644 --- a/src/modules/15_development/components/BasicInfo.vue +++ b/src/modules/15_development/components/BasicInfo.vue @@ -2,30 +2,22 @@ import { reactive, ref, onMounted } from "vue"; import { useQuasar } from "quasar"; import { useRoute } from "vue-router"; - -import type { FormBasicinfo } from "@/modules/15_development/interface/request/Main"; - -import DialogSelectAgency from "@/modules/15_development/components/DialogSelectAgency.vue"; - -import { useCounterMixin } from "@/stores/mixin"; -import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore"; import http from "@/plugins/http"; import config from "@/app.config"; -const $q = useQuasar(); -const store = useDevelopmentDataStore(); -const mixin = useCounterMixin(); +/** importType*/ +import type { FormBasicinfo } from "@/modules/15_development/interface/request/Main"; +import type { DataTree } from "@/modules/15_development/interface/response/Main"; -const { - dialogRemove, - dialogConfirm, - showLoader, - hideLoader, - messageError, - success, - date2Thai, -} = mixin; +/** importStore*/ +import { useCounterMixin } from "@/stores/mixin"; + +/** use*/ +const $q = useQuasar(); const route = useRoute(); +const mixin = useCounterMixin(); +const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin; + const projectId = ref(route.params.id.toLocaleString()); const formData = reactive({ @@ -41,8 +33,12 @@ const formData = reactive({ const orgName = ref(""); const node = ref([]); const filter = ref(""); -const expanded = ref([]); +const expanded = ref([]); +/** + * function fetch ข้อมูลเบื้องต้น + * @param id ProjectId + */ function fetchData(id: string) { showLoader(); http @@ -76,29 +72,26 @@ function fetchData(id: string) { }); } -async function editData(id: string) { - await http - .put(config.API.developmentMainTab("tab1", id), formData) - .then(() => { - fetchData(id); - success($q, "บันทึกข้อมูลสำเร็จ"); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - +/** function บันทึกข้อมูล*/ function onSubmit() { - dialogConfirm($q, async () => { + dialogConfirm($q, () => { showLoader(); - editData(projectId.value); - hideLoader(); + http + .put(config.API.developmentMainTab("tab1", projectId.value), formData) + .then(() => { + fetchData(projectId.value); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }); } +/** function fetch หา Id หน่วยงานที่ Active*/ function fetchActive() { showLoader(); http @@ -113,11 +106,15 @@ function fetchActive() { }); } -async function fetchTree(id: string) { +/** + * function fetch โครงสร้างปจุบัน + * @param id โครงสร้างปจุบัน + */ +function fetchTree(id: string) { showLoader(); http .get(config.API.orgByid(id.toString())) - .then(async (res) => { + .then((res) => { const data = res.data.result; node.value = data; fetchData(projectId.value); @@ -130,13 +127,19 @@ async function fetchTree(id: string) { }); } -function updateSelected(data: any) { +/** function เลือกหน่วยงาน*/ +function updateSelected(data: DataTree) { orgName.value = data.orgTreeName; formData.node = data.orgLevel; formData.nodeId = data.orgTreeId; formData.orgRevisionId = data.orgRevisionId; } +/** + * function หาหน่วยงานที่รับผิดชอบ + * @param orgTreeData ข้อมูล nodeTree + * @param treeId tree ID + */ async function searchAndReplace(orgTreeData: any, treeId: string | null) { if (orgTreeData) { for (let orgTree of orgTreeData) { @@ -154,9 +157,6 @@ async function searchAndReplace(orgTreeData: any, treeId: string | null) { onMounted(async () => { fetchActive(); - // setTimeout(() => { - // fetchData(projectId.value); - // }, 500); }); diff --git a/src/modules/15_development/components/MainTab.vue b/src/modules/15_development/components/MainTab.vue index b2e3889c8..57fcf039e 100644 --- a/src/modules/15_development/components/MainTab.vue +++ b/src/modules/15_development/components/MainTab.vue @@ -1,220 +1,43 @@ diff --git a/src/modules/15_development/interface/response/Main.ts b/src/modules/15_development/interface/response/Main.ts index 469a5b279..21835f09a 100644 --- a/src/modules/15_development/interface/response/Main.ts +++ b/src/modules/15_development/interface/response/Main.ts @@ -135,6 +135,36 @@ interface DataStrategic { children: DataStrategic; } +interface DataTree { + labelName: string; + orgCode: string; + orgLevel: number | null; + orgName: string; + orgRevisionId: string; + orgRootName: string; + orgTreeCode: string; + orgTreeFax: string; + orgTreeId: string; + orgTreeName: string; + orgTreeOrder: number | null; + orgTreePhoneEx: string; + orgTreePhoneIn: string; + orgTreeRank: string; + orgTreeRankSub: string | null; + orgTreeShortName: string; + totalPosition: number | null; + totalPositionCurrentUse: number | null; + totalPositionCurrentVacant: number | null; + totalPositionNextUse: number | null; + totalPositionNextVacant: number | null; + totalRootPosition: number | null; + totalRootPositionCurrentUse: number | null; + totalRootPositionCurrentVacant: number | null; + totalRootPositionNextUse: number | null; + totalRootPositionNextVacant: number | null; + children: DataTree; +} + export type { ResGroup, ResLevel, @@ -145,4 +175,5 @@ export type { ResPlannedGoals, ResRecord, DataStrategic, + DataTree, }; diff --git a/src/modules/15_development/views/MainPage.vue b/src/modules/15_development/views/MainPage.vue index 06a0042f4..79fd0cba6 100644 --- a/src/modules/15_development/views/MainPage.vue +++ b/src/modules/15_development/views/MainPage.vue @@ -17,7 +17,10 @@ import type { FormQueryListProject, FormProject, } from "@/modules/15_development/interface/request/Main"; -import type { ResListProject } from "@/modules/15_development/interface/response/Main"; +import type { + ResListProject, + DataTree, +} from "@/modules/15_development/interface/response/Main"; /** importStore*/ import { useCounterMixin } from "@/stores/mixin"; @@ -28,9 +31,8 @@ const router = useRouter(); const { showLoader, hideLoader, messageError, dialogMessageNotify } = useCounterMixin(); -const ticked = ref([]); const node = ref([]); -const expanded = ref([]); +const expanded = ref([]); const filter = ref(""); const filterMain = ref(""); const splitterModel = ref(60); @@ -77,6 +79,14 @@ const statusOpt = ref([ { id: "ONGOING", name: "กำลังดำเนินการ" }, { id: "FINISH", name: "เสร็จสิ้นโครงการ" }, ]); + +const formProject = reactive({ + year: null, + projectName: "", + node: null, + nodeId: null, + orgRevisionId: null, +}); /** formQuery*/ const formQuery = reactive({ year: new Date().getFullYear(), @@ -88,7 +98,6 @@ const formQuery = reactive({ node: null, nodeId: null, }); - const totalList = ref(1); //จำนวนข้อมูลรายการ /** funciton fetch รายการโครงการ*/ @@ -121,31 +130,18 @@ function onClickAddOrView(status: boolean = false, id: string = "") { status ? router.push(`/development/${id}`) : router.push("/development/add"); } +/** function เปิด Dialog เพิ่มโครงการ/หลักสูตรการฝึกอบรม*/ function onAdd() { modal.value = true; } -/** - * function updatePagination - * @param newPagination ข้อมูล Pagination ใหม่ - */ -function updatePagination(newPagination: NewPagination) { - formQuery.page = 1; - formQuery.pageSize = newPagination.rowsPerPage; -} - -/** callbackFunction ทำเมื่อมีการอัปเดท pageSize*/ -watch( - () => formQuery.pageSize, - () => { - fetchListProject(); - } -); +/** function fetchข้อมูลหน้าแรกใหม่*/ function fetchListProjectNew() { formQuery.page = 1; fetchListProject(); } +/** function Download รายการโครงการ*/ function onDownload() { showLoader(); http @@ -165,6 +161,7 @@ function onDownload() { }); } +/** function ปิด Dialog เพิ่มโครงการ/หลักสูตรการฝึกอบรม*/ function closeDialog() { modal.value = false; year.value = 0; @@ -172,14 +169,6 @@ function closeDialog() { projectName.value = ""; } -const formProject = reactive({ - year: null, - projectName: "", - node: null, - nodeId: null, - orgRevisionId: null, -}); - /** dialog submit */ function onSubmit() { if (formProject.nodeId) { @@ -198,6 +187,7 @@ function onSubmit() { } } +/** function fetch หา Id หน่วยงานที่ Active*/ function fetchActive() { showLoader(); http @@ -212,7 +202,11 @@ function fetchActive() { }); } -async function fetchTree(id: string) { +/** + * function fetch โครงสร้างปจุบัน + * @param id โครงสร้างปจุบัน + */ +function fetchTree(id: string) { showLoader(); http .get(config.API.orgByid(id.toString())) @@ -228,13 +222,15 @@ async function fetchTree(id: string) { }); } -function updateSelected(data: any) { +/** function เลือกหน่วยงานที่รับผิดชอบ*/ +function updateSelected(data: DataTree) { formProject.node = data.orgLevel; formProject.nodeId = data.orgTreeId; formProject.orgRevisionId = data.orgRevisionId; } -function updateSelectedTreeMain(data: any) { +/** function เลือกหน่วยงานที่จะค้นหาโครงการ */ +function updateSelectedTreeMain(data: DataTree) { if (formQuery.node === data.orgLevel && formQuery.nodeId === data.orgTreeId) { formQuery.node = null; formQuery.nodeId = null; @@ -242,10 +238,26 @@ function updateSelectedTreeMain(data: any) { formQuery.node = data.orgLevel; formQuery.nodeId = data.orgTreeId; } - - fetchListProjectNew(); + fetchListProjectNew(); // fetch โครงการ } +/** + * function updatePagination + * @param newPagination ข้อมูล Pagination ใหม่ + */ +function updatePagination(newPagination: NewPagination) { + formQuery.page = 1; + formQuery.pageSize = newPagination.rowsPerPage; +} + +/** callbackFunction ทำเมื่อมีการอัปเดท pageSize*/ +watch( + () => formQuery.pageSize, + () => { + fetchListProject(); + } +); + onMounted(() => { fetchActive(); fetchListProject();