hrms-mgt/src/modules/23_persons/stores/PersonsStore.ts
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 985f1bcf23 feat(persons): add router for persons feature
2026-05-18 13:44:38 +07:00

45 lines
1.1 KiB
TypeScript

import { defineStore } from "pinia";
import { reactive } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
DataOptions,
PosTypes,
} from "@/modules/23_persons/interface/Main";
export const usePersonsStore = defineStore("personsStore", () => {
const routeCheck = {
registry: {
meta: { Auth: true, Key: "SYS_REGISTRY_OFFICER", Role: "OWNER" },
},
org: {
meta: { Auth: true, Key: "SYS_ORG", Role: "OWNER" },
},
};
const optionsData = reactive({
posType: [] as DataOptions[],
posLevel: [] as DataOptions[],
dataType: [] as PosTypes[],
});
/** ฟังก์ชันดึงข้อมูลประเภทตำแหน่ง */
async function fetchPosType() {
if (optionsData.posType.length > 0) {
return optionsData.posType;
}
const res = await http.get(config.API.orgPosType);
optionsData.dataType = res.data.result;
optionsData.posType = res.data.result.map((e: PosTypes) => ({
id: e.id,
name: e.posTypeName,
}));
return optionsData.posType;
}
return { routeCheck, optionsData, fetchPosType };
});