diff --git a/app/components/pub/custom-ui/doc-entry/field.vue b/app/components/pub/custom-ui/doc-entry/field.vue
index f3b52106..829e0015 100644
--- a/app/components/pub/custom-ui/doc-entry/field.vue
+++ b/app/components/pub/custom-ui/doc-entry/field.vue
@@ -9,6 +9,6 @@ const props = defineProps({
-
{{ props.errMessage }}
+
{{ props.errMessage }}
diff --git a/app/models/_model.ts b/app/models/_model.ts
new file mode 100644
index 00000000..64e4a972
--- /dev/null
+++ b/app/models/_model.ts
@@ -0,0 +1,15 @@
+// Default item meta model for entities
+export interface ItemMeta {
+ id: number;
+ createdAt: string | null;
+ deletedAt: string | null;
+ updatedAt: string | null;
+}
+
+// Pagination meta model for API responses
+export interface PaginationMeta {
+ page_number: string;
+ page_size: string;
+ record_totalCount: string;
+ source: string;
+}
diff --git a/app/services/device.service.ts b/app/services/device.service.ts
index 11fa6479..b979ce87 100644
--- a/app/services/device.service.ts
+++ b/app/services/device.service.ts
@@ -1,8 +1,10 @@
import { xfetch } from '~/composables/useXfetch'
+const mainUrl = '/api/v1/device'
+
export async function getSourceDevices(params: any = null) {
try {
- let url = '/api/v1/device'
+ let url = mainUrl
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
const searchParams = new URLSearchParams()
for (const key in params) {
@@ -26,7 +28,7 @@ export async function getSourceDevices(params: any = null) {
export async function getSourceDeviceDetail(id: string | number) {
try {
- const resp = await xfetch(`/api/v1/device/${id}`, 'GET')
+ const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -39,7 +41,7 @@ export async function getSourceDeviceDetail(id: string | number) {
export async function postSourceDevice(data: any) {
try {
- const resp = await xfetch('/api/v1/device', 'POST', data)
+ const resp = await xfetch(mainUrl, 'POST', data)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -52,7 +54,7 @@ export async function postSourceDevice(data: any) {
export async function patchSourceDevice(id: string | number, data: any) {
try {
- const resp = await xfetch(`/api/v1/device/${id}`, 'PATCH', data)
+ const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', data)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -65,7 +67,7 @@ export async function patchSourceDevice(id: string | number, data: any) {
export async function removeSourceDevice(id: string | number) {
try {
- const resp = await xfetch(`/api/v1/device/${id}`, 'DELETE')
+ const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
diff --git a/app/services/material.service.ts b/app/services/material.service.ts
index 0f4db154..b4723f4c 100644
--- a/app/services/material.service.ts
+++ b/app/services/material.service.ts
@@ -1,8 +1,10 @@
import { xfetch } from '~/composables/useXfetch'
+const mainUrl = '/api/v1/material'
+
export async function getSourceMaterials(params: any = null) {
try {
- let url = '/api/v1/material'
+ let url = mainUrl
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
const searchParams = new URLSearchParams()
for (const key in params) {
@@ -26,7 +28,7 @@ export async function getSourceMaterials(params: any = null) {
export async function getSourceMaterialDetail(id: number | string) {
try {
- const resp = await xfetch(`/api/v1/material/${id}`, 'GET')
+ const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -39,7 +41,7 @@ export async function getSourceMaterialDetail(id: number | string) {
export async function postSourceMaterial(record: any) {
try {
- const resp = await xfetch('/api/v1/material', 'POST', record)
+ const resp = await xfetch(mainUrl, 'POST', record)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -52,7 +54,7 @@ export async function postSourceMaterial(record: any) {
export async function patchSourceMaterial(id: number | string, record: any) {
try {
- const resp = await xfetch(`/api/v1/material/${id}`, 'PATCH', record)
+ const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
@@ -65,7 +67,7 @@ export async function patchSourceMaterial(id: number | string, record: any) {
export async function removeSourceMaterial(id: number | string) {
try {
- const resp = await xfetch(`/api/v1/material/${id}`, 'DELETE')
+ const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
const result: any = {}
result.success = resp.success
result.body = (resp.body as Record) || {}
diff --git a/app/services/medicine-group.service.ts b/app/services/medicine-group.service.ts
new file mode 100644
index 00000000..ce16449b
--- /dev/null
+++ b/app/services/medicine-group.service.ts
@@ -0,0 +1,79 @@
+import { xfetch } from '~/composables/useXfetch'
+
+const mainUrl = '/api/v1/medicine-group'
+
+export async function getMedicineGroups(params: any = null) {
+ try {
+ let url = mainUrl
+ if (params && typeof params === 'object' && Object.keys(params).length > 0) {
+ const searchParams = new URLSearchParams()
+ for (const key in params) {
+ if (params[key] !== null && params[key] !== undefined && params[key] !== '') {
+ searchParams.append(key, params[key])
+ }
+ }
+ const queryString = searchParams.toString()
+ if (queryString) url += `?${queryString}`
+ }
+ const resp = await xfetch(mainUrl, 'GET')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error fetching source materials:', error)
+ throw new Error('Failed to fetch source materials')
+ }
+}
+
+export async function getMedicineGroupDetail(id: number | string) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error fetching source material detail:', error)
+ throw new Error('Failed to get source material detail')
+ }
+}
+
+export async function postMedicineGroup(record: any) {
+ try {
+ const resp = await xfetch(mainUrl, 'POST', record)
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error posting source material:', error)
+ throw new Error('Failed to post source material')
+ }
+}
+
+export async function patchMedicineGroup(id: number | string, record: any) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error putting source material:', error)
+ throw new Error('Failed to put source material')
+ }
+}
+
+export async function removeMedicineGroup(id: number | string) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error deleting record:', error)
+ throw new Error('Failed to delete source material')
+ }
+}
\ No newline at end of file
diff --git a/app/services/medicine-method.service.ts b/app/services/medicine-method.service.ts
index 02327163..319d2c85 100644
--- a/app/services/medicine-method.service.ts
+++ b/app/services/medicine-method.service.ts
@@ -1,9 +1,87 @@
import { xfetch } from '~/composables/useXfetch'
-export async function getMedicineMethods() {
+const mainUrl = '/api/v1/medicine-method'
+
+export async function getMedicineMethodsPrev() {
const resp = await xfetch('/api/v1/medicine-method')
if (resp.success) {
return (resp.body as Record).data
}
throw new Error('Failed to fetch medicine methods')
}
+
+export async function getMedicineMethods(params: any = null) {
+ try {
+ let url = mainUrl
+ if (params && typeof params === 'object' && Object.keys(params).length > 0) {
+ const searchParams = new URLSearchParams()
+ for (const key in params) {
+ if (params[key] !== null && params[key] !== undefined && params[key] !== '') {
+ searchParams.append(key, params[key])
+ }
+ }
+ const queryString = searchParams.toString()
+ if (queryString) url += `?${queryString}`
+ }
+ const resp = await xfetch(mainUrl, 'GET')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error fetching source materials:', error)
+ throw new Error('Failed to fetch source materials')
+ }
+}
+
+export async function getMedicineMethodDetail(id: number | string) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'GET')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error fetching source material detail:', error)
+ throw new Error('Failed to get source material detail')
+ }
+}
+
+export async function postMedicineMethod(record: any) {
+ try {
+ const resp = await xfetch(mainUrl, 'POST', record)
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error posting source material:', error)
+ throw new Error('Failed to post source material')
+ }
+}
+
+export async function patchMedicineMethod(id: number | string, record: any) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'PATCH', record)
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error putting source material:', error)
+ throw new Error('Failed to put source material')
+ }
+}
+
+export async function removeMedicineMethod(id: number | string) {
+ try {
+ const resp = await xfetch(`${mainUrl}/${id}`, 'DELETE')
+ const result: any = {}
+ result.success = resp.success
+ result.body = (resp.body as Record) || {}
+ return result
+ } catch (error) {
+ console.error('Error deleting record:', error)
+ throw new Error('Failed to delete source material')
+ }
+}