# Conflicts: # src/api/02_organizational/api.organization.ts # src/modules/02_organizationalNew/components/tableTree.vue # src/modules/02_organizationalNew/store/organizational.ts
99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
|
|
/** importType*/
|
|
import type {
|
|
DataActive,
|
|
Position,
|
|
PosMaster,
|
|
} from "@/modules/02_organizationalNew/interface/response/organizational";
|
|
|
|
export const useOrganizational = defineStore("organizationalStore", () => {
|
|
const typeOrganizational = ref<string>("current");
|
|
const statusView = ref<string>("list");
|
|
|
|
const dataActive = ref<DataActive>();
|
|
const activeId = ref<string>();
|
|
const draftId = ref<string>();
|
|
const treeId = ref<string>();
|
|
const level = ref<number>();
|
|
const isPublic = ref<boolean>(false);
|
|
const orgPublishDate = ref<Date>();
|
|
|
|
function fetchDataActive(data: DataActive) {
|
|
activeId.value = data.activeId;
|
|
draftId.value = data.draftId;
|
|
dataActive.value = data;
|
|
}
|
|
|
|
function fetchPosMaster(data: PosMaster[]) {
|
|
console.log(data);
|
|
|
|
const newPosMaster = data.map((e: PosMaster) => ({
|
|
...e,
|
|
positionIsSelected: e.positionIsSelected ? "มีคนครอง" : "ไม่มีคนครอง",
|
|
positionName: e.positionName ? e.positionName : "-",
|
|
posTypeName: e.posTypeName ? e.posTypeName : "-",
|
|
posLevelName: e.posLevelName ? e.posLevelName : "-",
|
|
posExecutiveName: e.posExecutiveName ? e.posExecutiveName : "-",
|
|
// positions: [
|
|
// {
|
|
// ...e.positions,
|
|
// positionName: e.positionName ? e.positionName : "-",
|
|
// posTypeName: e.posTypeName ? e.posTypeName : "-",
|
|
// posLevelName: e.posLevelName ? e.posLevelName : "-",
|
|
// posExecutiveName: e.posExecutiveName ? e.posExecutiveName : "-",
|
|
// positionIsSelected: e.positionIsSelected ? "มีคนครอง" : "ไม่มีคนครอง",
|
|
// },
|
|
// ],
|
|
}));
|
|
return newPosMaster;
|
|
}
|
|
|
|
function checkLevel(type: number) {
|
|
switch (type) {
|
|
case 0:
|
|
return "Root";
|
|
case 1:
|
|
return "Child1";
|
|
case 2:
|
|
return "Child2";
|
|
case 3:
|
|
return "Child3";
|
|
default:
|
|
return "Child4";
|
|
}
|
|
}
|
|
|
|
function convertType(type: string) {
|
|
switch (type) {
|
|
case "DEPARTMENT":
|
|
return "ระดับสำนัก";
|
|
case "OFFICE":
|
|
return "ระดับกอง/สำนักงาน/ส่วนราชการ/โรงพยาบาล/เทียบเท่ากอง";
|
|
case "DIVISION":
|
|
return "ระดับส่วน/กลุ่มภารกิจ";
|
|
case "SECTION":
|
|
return "ระดับฝ่าย/กลุ่มงาน";
|
|
default:
|
|
return "-";
|
|
}
|
|
}
|
|
|
|
return {
|
|
typeOrganizational,
|
|
statusView,
|
|
|
|
//
|
|
fetchDataActive,
|
|
checkLevel,
|
|
convertType,
|
|
draftId,
|
|
activeId,
|
|
treeId,
|
|
level,
|
|
isPublic,
|
|
orgPublishDate,
|
|
fetchPosMaster,
|
|
};
|
|
});
|