From 841f1157b1871f5d395b06bdbd401020c960d5c6 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 10 Mar 2025 15:47:24 +0700 Subject: [PATCH] feat: up code test --- src/i18n/tha.ts | 6 + src/layouts/DrawerComponent.vue | 1 + src/pages/04_property-managment/MainPage.vue | 511 ++++++++++++++++++- src/stores/property/index.ts | 71 +++ src/stores/property/types.ts | 5 + 5 files changed, 592 insertions(+), 2 deletions(-) create mode 100644 src/stores/property/index.ts create mode 100644 src/stores/property/types.ts diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 06a21d9c..ea4066d6 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -194,6 +194,7 @@ export default { personnel: 'บุคลากร', productService: 'สินค้าและบริการ', workflow: 'ขั้นตอนการทำงาน', + property: 'คุณสมบัติ', customer: 'ลูกค้า', mainData: 'ข้อมูลหลัก', agencies: 'หน่วยงาน', @@ -1431,4 +1432,9 @@ export default { 11: 'พฤศจิกายน', 12: 'ธันวาคม', }, + + property: { + title: 'คุณสมบัติ', + caption: 'จัดการคุณสมบัติ', + }, }; diff --git a/src/layouts/DrawerComponent.vue b/src/layouts/DrawerComponent.vue index 5e07ca3a..6d9f0e06 100644 --- a/src/layouts/DrawerComponent.vue +++ b/src/layouts/DrawerComponent.vue @@ -120,6 +120,7 @@ onMounted(async () => { ), }, { label: 'workflow', route: '/workflow' }, + { label: 'property', route: '/property' }, { label: 'productService', route: '/product-service' }, { label: 'customer', route: '/customer-management' }, { label: 'agencies', route: '/agencies-management' }, diff --git a/src/pages/04_property-managment/MainPage.vue b/src/pages/04_property-managment/MainPage.vue index aab4caa5..60c0c329 100644 --- a/src/pages/04_property-managment/MainPage.vue +++ b/src/pages/04_property-managment/MainPage.vue @@ -1,3 +1,510 @@ - - + + diff --git a/src/stores/property/index.ts b/src/stores/property/index.ts new file mode 100644 index 00000000..93109146 --- /dev/null +++ b/src/stores/property/index.ts @@ -0,0 +1,71 @@ +import { ref } from 'vue'; +import { defineStore } from 'pinia'; +import { api } from 'src/boot/axios'; +import { PaginationResult } from 'src/types'; +import { Status } from '../types'; +import { Property } from './types'; + +export const useProperty = defineStore('property-store', () => { + const data = ref([]); + const page = ref(1); + const pageMax = ref(1); + const pageSize = ref(30); + + async function getProperty(id: string) { + const res = await api.get(`/property/${id}`); + + if (res.status >= 400) return null; + + return res.data; + } + + async function getPropertyList(params?: { + page?: number; + pageSize?: number; + query?: string; + status?: Status; + activeOnly?: boolean; + }) { + const res = await api.get>('/property', { + params, + }); + + if (res.status >= 400) return null; + + return res.data; + } + + async function creatProperty(data: Property) { + const res = await api.post('/property', data); + if (res.status >= 400) return null; + return res; + } + + async function editProperty(data: Property & { id: string }) { + const res = await api.put(`/property/${data.id}`, { + ...data, + id: undefined, + }); + if (res.status >= 400) return null; + return res; + } + + async function deleteProperty(id: string) { + const res = await api.delete(`/property/${id}`); + if (res.status >= 400) return null; + return res; + } + + return { + data, + page, + pageSize, + pageMax, + + getProperty, + getPropertyList, + creatProperty, + editProperty, + deleteProperty, + }; +}); diff --git a/src/stores/property/types.ts b/src/stores/property/types.ts new file mode 100644 index 00000000..778b6504 --- /dev/null +++ b/src/stores/property/types.ts @@ -0,0 +1,5 @@ +export type Property = { + name: string; + nameEn: string; + type: Record; +};