API Position

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-01 13:46:05 +07:00
parent dd9239ac25
commit 1a33f55c6e
8 changed files with 355 additions and 67 deletions

View file

@ -2,7 +2,11 @@ import { defineStore } from "pinia";
import { ref } from "vue";
/** importType*/
import type { DataActive } from "@/modules/02_organizationalNew/interface/response/organizational";
import type {
DataActive,
Position,
PosMaster,
} from "@/modules/02_organizationalNew/interface/response/organizational";
export const useOrganizational = defineStore("organizationalStore", () => {
const typeOrganizational = ref<string>("current");
@ -11,12 +15,39 @@ export const useOrganizational = defineStore("organizationalStore", () => {
const dataActive = ref<DataActive>();
const activeId = ref<string>();
const draftId = ref<string>();
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:
@ -57,5 +88,8 @@ export const useOrganizational = defineStore("organizationalStore", () => {
convertType,
draftId,
activeId,
isPublic,
orgPublishDate,
fetchPosMaster,
};
});