From b87e15301fc97e78391b1df3674d27589bea7414 Mon Sep 17 00:00:00 2001 From: puriphatt <162551324+puriphatt@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:11:42 +0700 Subject: [PATCH] feat: menu agencies (#65) * feat: agencies => add agencies menu --------- Co-authored-by: Methapon Metanipat --- .../FormBasicInfoAgencies.vue | 73 ++ src/components/ProfileBanner.vue | 19 +- src/components/StatCardComponent.vue | 14 +- src/components/form/AddressForm.vue | 16 +- src/i18n/eng.ts | 9 + src/i18n/tha.ts | 9 + src/layouts/DrawerComponent.vue | 1 + .../07_agencies-management/AgenciesDialog.vue | 334 ++++++++ src/pages/07_agencies-management/MainPage.vue | 723 ++++++++++++++++++ src/router/routes.ts | 5 + src/stores/institution/index.ts | 75 ++ src/stores/institution/types.ts | 45 ++ 12 files changed, 1305 insertions(+), 18 deletions(-) create mode 100644 src/components/07_agencies-management/FormBasicInfoAgencies.vue create mode 100644 src/pages/07_agencies-management/AgenciesDialog.vue create mode 100644 src/pages/07_agencies-management/MainPage.vue create mode 100644 src/stores/institution/index.ts create mode 100644 src/stores/institution/types.ts diff --git a/src/components/07_agencies-management/FormBasicInfoAgencies.vue b/src/components/07_agencies-management/FormBasicInfoAgencies.vue new file mode 100644 index 00000000..b2fdd203 --- /dev/null +++ b/src/components/07_agencies-management/FormBasicInfoAgencies.vue @@ -0,0 +1,73 @@ + + + diff --git a/src/components/ProfileBanner.vue b/src/components/ProfileBanner.vue index e242e535..f9d4fe26 100644 --- a/src/components/ProfileBanner.vue +++ b/src/components/ProfileBanner.vue @@ -1,6 +1,7 @@ + + diff --git a/src/pages/07_agencies-management/MainPage.vue b/src/pages/07_agencies-management/MainPage.vue new file mode 100644 index 00000000..b52da96b --- /dev/null +++ b/src/pages/07_agencies-management/MainPage.vue @@ -0,0 +1,723 @@ + + + diff --git a/src/router/routes.ts b/src/router/routes.ts index 1d35d94a..1b1fcf58 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -89,6 +89,11 @@ const routes: RouteRecordRaw[] = [ name: 'document-management', component: () => import('pages/06_edm/MainPage.vue'), }, + { + path: '/agencies-management', + name: 'agencies-management', + component: () => import('pages/07_agencies-management/MainPage.vue'), + }, ], }, diff --git a/src/stores/institution/index.ts b/src/stores/institution/index.ts new file mode 100644 index 00000000..ef2775a9 --- /dev/null +++ b/src/stores/institution/index.ts @@ -0,0 +1,75 @@ +import { defineStore } from 'pinia'; +import { ref } from 'vue'; +import { Institution, InstitutionPayload } from './types'; +import { api } from 'src/boot/axios'; +import { PaginationResult } from 'src/types'; + +export const useInstitution = defineStore('institution-store', () => { + const data = ref([]); + const page = ref(1); + const pageMax = ref(1); + const pageSize = ref(30); + + async function getInstitution(id: string) { + const res = await api.get(`/institution/${id}`); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function getInstitutionList(params?: { + page?: number; + pageSize?: number; + query?: string; + group?: string; + }) { + const res = await api.get>('/institution', { + params, + }); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function createInstitution(data: InstitutionPayload) { + const res = await api.post('/institution', data); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function editInstitution(data: InstitutionPayload & { id: string }) { + const res = await api.put(`/institution/${data.id}`, { + ...data, + id: undefined, + }); + if (res.status < 400) { + return res.data; + } + return null; + } + + async function deleteInstitution(id: string) { + const res = await api.delete(`/institution/${id}`); + if (res.status < 400) { + return res.data; + } + return null; + } + + return { + data, + page, + pageMax, + pageSize, + + getInstitution, + getInstitutionList, + createInstitution, + editInstitution, + deleteInstitution, + }; +}); diff --git a/src/stores/institution/types.ts b/src/stores/institution/types.ts new file mode 100644 index 00000000..c0353f52 --- /dev/null +++ b/src/stores/institution/types.ts @@ -0,0 +1,45 @@ +import { District, Province, SubDistrict } from '../address'; + +export type Institution = { + id: string; + code: string; + group: string; + name: string; + nameEN: string; + + addressEN: string; + address: string; + soi: string | null; + soiEN: string | null; + moo: string | null; + mooEN: string | null; + street: string | null; + streetEN: string | null; + province?: Province; + district?: District; + subDistrict?: SubDistrict; + + subDistrictId: string; + districtId: string; + provinceId: string; +}; + +export type InstitutionPayload = { + code: string; + name: string; + nameEN: string; + group?: string; + + addressEN: string; + address: string; + soi?: string | null; + soiEN?: string | null; + moo?: string | null; + mooEN?: string | null; + street?: string | null; + streetEN?: string | null; + + subDistrictId: string; + districtId: string; + provinceId: string; +};