45 lines
1.1 KiB
TypeScript
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 };
|
|
});
|