Refactoring code module 02_organization

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-11 17:00:27 +07:00
parent 63b9aafbaf
commit 0f5d772e53
24 changed files with 805 additions and 1033 deletions

View file

@ -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":