diff --git a/src/components/04_flow-management/FormFlow.vue b/src/components/04_flow-management/FormFlow.vue index 3e4b264e..95dd1c6f 100644 --- a/src/components/04_flow-management/FormFlow.vue +++ b/src/components/04_flow-management/FormFlow.vue @@ -455,7 +455,12 @@ onMounted(async () => { :key="i" class="surface-2 bordered rounded q-px-xs" > - {{ optionStore.mapOption(att.fieldName ?? '') }} + {{ + optionStore.mapOption( + att.fieldName ?? '', + 'propertiesField', + ) + }} diff --git a/src/components/04_product-service/WorkManagementComponent.vue b/src/components/04_product-service/WorkManagementComponent.vue index 2bf5db83..e79872d9 100644 --- a/src/components/04_product-service/WorkManagementComponent.vue +++ b/src/components/04_product-service/WorkManagementComponent.vue @@ -584,7 +584,12 @@ watch( :key="i" class="surface-2 bordered rounded q-px-xs" > - {{ optionStore.mapOption(att.fieldName ?? '') }} + {{ + optionStore.mapOption( + att.fieldName ?? '', + 'propertiesField', + ) + }}
diff --git a/src/components/04_property-management/FormProperty.vue b/src/components/04_property-management/FormProperty.vue new file mode 100644 index 00000000..34067e8e --- /dev/null +++ b/src/components/04_property-management/FormProperty.vue @@ -0,0 +1,226 @@ + + + + + diff --git a/src/components/dialog/DialogProperties.vue b/src/components/dialog/DialogProperties.vue index 0d05baab..4dffdb4e 100644 --- a/src/components/dialog/DialogProperties.vue +++ b/src/components/dialog/DialogProperties.vue @@ -1,10 +1,17 @@ + + + diff --git a/src/pages/04_property-managment/PropertyDialog.vue b/src/pages/04_property-managment/PropertyDialog.vue new file mode 100644 index 00000000..333f0ec7 --- /dev/null +++ b/src/pages/04_property-managment/PropertyDialog.vue @@ -0,0 +1,252 @@ + + + diff --git a/src/pages/05_quotation/QuotationFormProductSelect.vue b/src/pages/05_quotation/QuotationFormProductSelect.vue index 0a22545b..eb6ffef8 100644 --- a/src/pages/05_quotation/QuotationFormProductSelect.vue +++ b/src/pages/05_quotation/QuotationFormProductSelect.vue @@ -773,7 +773,12 @@ watch( :key="att" class="bordered q-py-xs q-px-sm rounded" > - {{ optionStore.mapOption(att.fieldName) }} + {{ + optionStore.mapOption( + att.fieldName, + 'propertiesField', + ) + }}
diff --git a/src/pages/08_request-list/PropertiesExpansion.vue b/src/pages/08_request-list/PropertiesExpansion.vue index b7ac0250..b2b9baad 100644 --- a/src/pages/08_request-list/PropertiesExpansion.vue +++ b/src/pages/08_request-list/PropertiesExpansion.vue @@ -164,12 +164,15 @@ defineEmits<{ class="row items-center q-pb-sm" >
- {{ i + 1 }} {{ optionStore.mapOption(prop.fieldName) }} + {{ i + 1 }} + {{ optionStore.mapOption(prop.fieldName, 'propertiesField') }}
diff --git a/src/router/routes.ts b/src/router/routes.ts index 2f7405d1..c4573313 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -80,6 +80,11 @@ const routes: RouteRecordRaw[] = [ name: 'Workflow', component: () => import('pages/04_flow-managment/MainPage.vue'), }, + { + path: '/property', + name: 'Property', + component: () => import('pages/04_property-managment/MainPage.vue'), + }, { path: '/quotation', name: 'Quotation', diff --git a/src/stores/options/index.ts b/src/stores/options/index.ts index 98db8b02..d425389b 100644 --- a/src/stores/options/index.ts +++ b/src/stores/options/index.ts @@ -1,8 +1,11 @@ import { ref, watch } from 'vue'; import { defineStore } from 'pinia'; import { useI18n } from 'vue-i18n'; +import { useProperty } from 'src/stores/property'; +import { toCamelCase } from '../utils'; const useOptionStore = defineStore('optionStore', () => { + const { getPropertyList } = useProperty(); const { locale } = useI18n(); const globalOption = ref(); @@ -12,6 +15,36 @@ const useOptionStore = defineStore('optionStore', () => { rawOption.value = await fetch('/option/option.json').then((r) => r.json()); _switchOptionLang(); + + const res = await getPropertyList({ pageSize: 999, activeOnly: true }); + const targetOptions = globalOption.value?.propertiesField ?? []; + + if (!res) return; + + const propList = res.result.map((v) => { + return { + label: locale.value === 'eng' ? v.nameEN : v.name, + value: toCamelCase(v.nameEN), + type: v.type.type, + }; + }); + + globalOption.value.propertiesField = [...targetOptions]; + + const existingValues = new Set( + globalOption.value.propertiesField.map( + (item: { value: string }) => item.value, + ), + ); + const newProps = propList.filter((prop) => !existingValues.has(prop.value)); + + if (newProps) { + globalOption.value.propertiesField.splice( + globalOption.value.propertiesField.length - 4, + 0, + ...newProps, + ); + } })(); watch(locale, _switchOptionLang); diff --git a/src/stores/property/index.ts b/src/stores/property/index.ts new file mode 100644 index 00000000..c840c053 --- /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) { + 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..31c251e5 --- /dev/null +++ b/src/stores/property/types.ts @@ -0,0 +1,10 @@ +import { Status } from '../types'; + +export type Property = { + id?: string; + status?: Status; + registeredBranchId?: string; + name: string; + nameEN: string; + type: Record; +};