Refactoring code module 02_organization
This commit is contained in:
parent
63b9aafbaf
commit
0f5d772e53
24 changed files with 805 additions and 1033 deletions
|
|
@ -9,17 +9,17 @@ import type {
|
|||
} from "@/modules/02_organization/interface/response/organizational";
|
||||
|
||||
export const useOrganizational = defineStore("organizationalStore", () => {
|
||||
const typeOrganizational = ref<string>("current");
|
||||
const statusView = ref<string>("list");
|
||||
const typeOrganizational = ref<string>("current"); // ประเภทโครงสร้าง
|
||||
const statusView = ref<string>("list"); // การแสดงผล รายการ,map
|
||||
|
||||
const dataActive = ref<DataActive>();
|
||||
const activeId = ref<string>();
|
||||
const draftId = ref<string>();
|
||||
const historyId = ref<string>();
|
||||
const treeId = ref<string>();
|
||||
const level = ref<number>();
|
||||
const isPublic = ref<boolean>(false);
|
||||
const orgPublishDate = ref<Date | null>(null);
|
||||
const dataActive = ref<DataActive>(); //ข้อมูลโครงสร้าง
|
||||
const activeId = ref<string>(); // id โครงสร้างปัจจุบัน
|
||||
const draftId = ref<string>(); // id แบบร่างโครงสร้าง
|
||||
const historyId = ref<string>(); // id ประวัติโครงสร้าง
|
||||
const isPublic = ref<boolean>(false); // การเผยแพร่
|
||||
const treeId = ref<string>(); // id โหนด
|
||||
const level = ref<number>(); // ระดับโหนด
|
||||
const orgPublishDate = ref<Date | null>(null); // วันเผยแพร่
|
||||
const sumPosition = reactive({
|
||||
total: 0,
|
||||
use: 0,
|
||||
|
|
@ -29,6 +29,10 @@ export const useOrganizational = defineStore("organizationalStore", () => {
|
|||
vacantRoot: 0,
|
||||
});
|
||||
|
||||
/**
|
||||
* ฟังก์ชันกำหนดจำนวนข้อมูลตำแหน่ง
|
||||
* @param data ข้อมุลจำนวนตำแหน่ง
|
||||
*/
|
||||
function getSumPosition(data: SumPosition) {
|
||||
sumPosition.total = data.totalPosition;
|
||||
sumPosition.totalRoot = data.totalRootPosition ? data.totalRootPosition : 0;
|
||||
|
|
@ -56,14 +60,23 @@ export const useOrganizational = defineStore("organizationalStore", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function fetchDataActive(data: DataActive) {
|
||||
/**
|
||||
* ฟังก์ชันกำหนดข้อมูลโครงสร้าง
|
||||
* @param data ข้อมูลโครงสร้าง
|
||||
*/
|
||||
async function fetchDataActive(data: DataActive) {
|
||||
dataActive.value = data;
|
||||
activeId.value = data.activeId;
|
||||
draftId.value = data.draftId;
|
||||
dataActive.value = data;
|
||||
isPublic.value = data.isPublic;
|
||||
orgPublishDate.value = data.orgPublishDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันประมวลผลข้อมูลตำแหน่ง
|
||||
* @param data ข้อมูลตำแหน่ง
|
||||
* @returns ข้อมูลตำแหน่งที่ผ่านการประมวลผลแล้ว
|
||||
*/
|
||||
function fetchPosMaster(data: PosMaster[]) {
|
||||
const newPosMaster = data.map((e: PosMaster) => ({
|
||||
...e,
|
||||
|
|
@ -89,7 +102,12 @@ export const useOrganizational = defineStore("organizationalStore", () => {
|
|||
return newPosMaster;
|
||||
}
|
||||
|
||||
function checkLevel(type: number) {
|
||||
/**
|
||||
* ฟังก์ชันตรวจสอบและแปลงค่าประเภทระดับ
|
||||
* @param type ประเภทระดับ
|
||||
* @returns ชื่อประเภทระดับ
|
||||
*/
|
||||
async function checkLevel(type: number) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
return "Root";
|
||||
|
|
@ -104,6 +122,11 @@ export const useOrganizational = defineStore("organizationalStore", () => {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันตรวจสอบและแปลงค่าระดับหน่วยงาน
|
||||
* @param type ระดับหน่วยงาน
|
||||
* @returns ชื่อประระดับหน่วยงาน
|
||||
*/
|
||||
function convertType(type: string) {
|
||||
switch (type) {
|
||||
case "DEPARTMENT":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue