From 985f1bcf23f145adde993a8052cd96a47a289a62 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 18 May 2026 13:44:38 +0700 Subject: [PATCH] feat(persons): add router for persons feature --- .../23_persons/components/TablePersons.vue | 306 ++++++++++++++++++ src/modules/23_persons/interface/Main.ts | 38 +++ src/modules/23_persons/router.ts | 14 + src/modules/23_persons/stores/PersonsStore.ts | 45 +++ src/modules/23_persons/views/Main.vue | 77 +++++ src/router/index.ts | 2 + 6 files changed, 482 insertions(+) create mode 100644 src/modules/23_persons/components/TablePersons.vue create mode 100644 src/modules/23_persons/interface/Main.ts create mode 100644 src/modules/23_persons/router.ts create mode 100644 src/modules/23_persons/stores/PersonsStore.ts create mode 100644 src/modules/23_persons/views/Main.vue diff --git a/src/modules/23_persons/components/TablePersons.vue b/src/modules/23_persons/components/TablePersons.vue new file mode 100644 index 000000000..f3e5b9467 --- /dev/null +++ b/src/modules/23_persons/components/TablePersons.vue @@ -0,0 +1,306 @@ + + + + + diff --git a/src/modules/23_persons/interface/Main.ts b/src/modules/23_persons/interface/Main.ts new file mode 100644 index 000000000..b92ae3cd2 --- /dev/null +++ b/src/modules/23_persons/interface/Main.ts @@ -0,0 +1,38 @@ +interface DataOptions { + id: string; + name: string; +} + +interface PosTypes { + createdAt: Date; + id: string; + lastUpdateFullName: string; + lastUpdatedAt: Date; + posTypeName: string; + posTypeRank: number; + posLevels: PosLevels[]; +} + +interface PosLevels { + createdAt: Date; + id: string; + lastUpdateFullName: string; + lastUpdatedAt: Date; + posLevelAuthority: string; + posLevelName: string; + posLevelRank: number; +} + +interface Person { + citizenId: string; + firstName: string; + id: string; + lastName: string; + posLevel: string; + posType: string; + position: string; + prefix: string; + rank: string; +} + +export type { DataOptions, PosTypes, PosLevels, Person }; diff --git a/src/modules/23_persons/router.ts b/src/modules/23_persons/router.ts new file mode 100644 index 000000000..0ad543b53 --- /dev/null +++ b/src/modules/23_persons/router.ts @@ -0,0 +1,14 @@ +const Main = () => import("@/modules/23_persons/views/Main.vue"); + +export default [ + { + path: "/persons", + name: "personsMain", + component: Main, + meta: { + Auth: true, + Key: "PERSONS", + Role: "PERSONS", + }, + }, +]; diff --git a/src/modules/23_persons/stores/PersonsStore.ts b/src/modules/23_persons/stores/PersonsStore.ts new file mode 100644 index 000000000..e19b5e29f --- /dev/null +++ b/src/modules/23_persons/stores/PersonsStore.ts @@ -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 }; +}); diff --git a/src/modules/23_persons/views/Main.vue b/src/modules/23_persons/views/Main.vue new file mode 100644 index 000000000..ce5c336d8 --- /dev/null +++ b/src/modules/23_persons/views/Main.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index f570ed6ce..565174cf3 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -29,6 +29,7 @@ import ModulePositionCondition from "@/modules/19_condition/router"; import ModulePositionTemp from "@/modules/20_positionTemp/router"; import ModuleReport from "@/modules/21_report/router"; import ModuleIssues from "@/modules/22_issues/router"; +import ModulePersons from "@/modules/23_persons/router"; // TODO: ใช้หรือไม่? import { authenticated, logout } from "@/plugins/auth"; @@ -81,6 +82,7 @@ const router = createRouter({ ...ModulePositionTemp, ...ModuleReport, ...ModuleIssues, + ...ModulePersons, ], }, /**