From a0959017c8248e5c487f81a19557b7e7d38ed742 Mon Sep 17 00:00:00 2001 From: waruneeta Date: Fri, 2 Feb 2024 14:50:19 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=AA=E0=B8=A3=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DialogNewStructure.vue | 47 +++++++++++-------- .../components/listView.vue | 30 +++++++++++- .../components/mainTree.vue | 22 ++++++--- .../interface/response/organizational.ts | 17 +++++-- .../store/organizational.ts | 23 ++++++++- .../02_organizationalNew/views/main.vue | 2 +- 6 files changed, 106 insertions(+), 35 deletions(-) diff --git a/src/modules/02_organizationalNew/components/DialogNewStructure.vue b/src/modules/02_organizationalNew/components/DialogNewStructure.vue index 113a38b66..4e5556634 100644 --- a/src/modules/02_organizationalNew/components/DialogNewStructure.vue +++ b/src/modules/02_organizationalNew/components/DialogNewStructure.vue @@ -90,26 +90,33 @@ function validateForm() { /** ฟังชั่น บันทึก */ function onSubmit() { - dialogConfirm($q, () => { - showLoader(); - http - .post(config.API.createOrganization, formData) - .then((res) => { - status.value = true; - store.typeOrganizational = "draft"; - store.draftId = res.data.result.id; - success($q, "บันทึกข้อมูลสำเร็จ"); - // props.fetchActive?.(); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(async () => { - modal.value = await false; - await close(); - await hideLoader(); - }); - }); + dialogConfirm( + $q, + () => { + showLoader(); + http + .post(config.API.createOrganization, formData) + .then((res) => { + status.value = true; + store.typeOrganizational = "draft"; + store.draftId = res.data.result.id; + success($q, "บันทึกข้อมูลสำเร็จ"); + // props.fetchActive?.(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(async () => { + modal.value = await false; + await close(); + await hideLoader(); + }); + }, + "ยืนยันการเพิ่มโครงสร้าง", + store.draftId + ? "คุณมีแบบร่างอยู่หากคุณกดยืนยันระบบจะทำการลบแบบร่างเดิมและสร้างแบบร่างใหม่ ต้องการยืนยันการเพิ่มโครงสร้างนี้ใช่หรือไม่?" + : "ต้องการยืนยันการเพิ่มโครงสร้างนี้ใช่หรือไม่?" + ); } function close() { diff --git a/src/modules/02_organizationalNew/components/listView.vue b/src/modules/02_organizationalNew/components/listView.vue index ec060f33d..00bced78e 100644 --- a/src/modules/02_organizationalNew/components/listView.vue +++ b/src/modules/02_organizationalNew/components/listView.vue @@ -196,6 +196,28 @@ watch(
+ +
+
+
ตำแหน่งทั้งหมด
+ + +
+
+
ตำแหน่งที่มีคนครอง
+ + +
+
+
ตำแหน่งว่าง
+ + +
+
+ - + diff --git a/src/modules/02_organizationalNew/components/mainTree.vue b/src/modules/02_organizationalNew/components/mainTree.vue index 824db0407..052b4a5c2 100644 --- a/src/modules/02_organizationalNew/components/mainTree.vue +++ b/src/modules/02_organizationalNew/components/mainTree.vue @@ -100,14 +100,22 @@ const orgLevel = ref(0); const type = ref(0); const orgId = ref(""); -const updateSelected = (id: string, level: number) => { - store.treeId = id; - store.level = level; - if (id === nodeId.value) { +const updateSelected = (data: any) => { + store.treeId = data.orgTreeId; + store.level = data.orgLevel; + if (data.orgTreeId === nodeId.value) { nodeId.value = ""; } else { - nodeId.value = id ? id : ""; - id && props.fetchDataTable?.(id, level, true); + nodeId.value = data.orgTreeId ? data.orgTreeId : ""; + data.orgTreeId && + props.fetchDataTable?.(data.orgTreeId, data.orgLevel, true); + store.getSumPosition({ + totalPosition: data.totalPosition, + totalPositionCurrentUse: data.totalPositionCurrentUse, + totalPositionCurrentVacant: data.totalPositionCurrentVacant, + totalPositionNextUse: data.totalPositionNextUse, + totalPositionNextVacant: data.totalPositionNextVacant, + }); } }; @@ -353,7 +361,7 @@ onMounted(async () => {});
diff --git a/src/modules/02_organizationalNew/interface/response/organizational.ts b/src/modules/02_organizationalNew/interface/response/organizational.ts index e0a2b2927..8e1e922fb 100644 --- a/src/modules/02_organizationalNew/interface/response/organizational.ts +++ b/src/modules/02_organizationalNew/interface/response/organizational.ts @@ -3,8 +3,16 @@ interface DataActive { activeName: string; draftId: string; draftName: string; - isPublic: boolean, - orgPublishDate: Date | null, + isPublic: boolean; + orgPublishDate: Date | null; +} + +interface SumPosition { + totalPosition: number; + totalPositionCurrentUse: number; + totalPositionCurrentVacant: number; + totalPositionNextUse: number; + totalPositionNextVacant: number; } interface OrgTree { @@ -80,7 +88,7 @@ interface Position { interface PosMaster { id: string; // id อัตรากำลัง posmaster - orgShortname: string; // อักษรย่อตำแหน่ง + orgShortname: string; // อักษรย่อตำแหน่ง posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ) posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช. @@ -114,7 +122,7 @@ interface Position2 { interface PosMaster2 { id: string; // id อัตรากำลัง posmaster - orgShortname: string; // อักษรย่อตำแหน่ง + orgShortname: string; // อักษรย่อตำแหน่ง posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ) posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช. @@ -144,4 +152,5 @@ export type { PosMaster2, Position, Position2, + SumPosition }; diff --git a/src/modules/02_organizationalNew/store/organizational.ts b/src/modules/02_organizationalNew/store/organizational.ts index 1efed1c44..92648777f 100644 --- a/src/modules/02_organizationalNew/store/organizational.ts +++ b/src/modules/02_organizationalNew/store/organizational.ts @@ -1,10 +1,10 @@ import { defineStore } from "pinia"; -import { ref } from "vue"; +import { reactive, ref } from "vue"; /** importType*/ import type { DataActive, - Position, + SumPosition, PosMaster, } from "@/modules/02_organizationalNew/interface/response/organizational"; @@ -19,6 +19,23 @@ export const useOrganizational = defineStore("organizationalStore", () => { const level = ref(); const isPublic = ref(false); const orgPublishDate = ref(null); + const sumPosition = reactive({ + total: 0, + use: 0, + vacant: 0, + }); + + function getSumPosition(data: SumPosition) { + sumPosition.total = data.totalPosition; + sumPosition.use = + typeOrganizational.value == "draft" + ? data.totalPositionNextUse + : data.totalPositionCurrentUse; + sumPosition.vacant = + typeOrganizational.value == "draft" + ? data.totalPositionNextVacant + : data.totalPositionCurrentVacant; + } function fetchDataActive(data: DataActive) { activeId.value = data.activeId; @@ -100,5 +117,7 @@ export const useOrganizational = defineStore("organizationalStore", () => { isPublic, orgPublishDate, fetchPosMaster, + sumPosition, + getSumPosition, }; }); diff --git a/src/modules/02_organizationalNew/views/main.vue b/src/modules/02_organizationalNew/views/main.vue index 740689886..aff66a6dc 100644 --- a/src/modules/02_organizationalNew/views/main.vue +++ b/src/modules/02_organizationalNew/views/main.vue @@ -240,7 +240,7 @@ onMounted(async () => { - +