feat(persons): add router for persons feature
This commit is contained in:
parent
463a35059e
commit
985f1bcf23
6 changed files with 482 additions and 0 deletions
45
src/modules/23_persons/stores/PersonsStore.ts
Normal file
45
src/modules/23_persons/stores/PersonsStore.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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 };
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue