fix(products): 修正产品规格值显示问题
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m56s

- 修复产品规格表中规格名显示不正确的问题
- 调整产品规格数据结构
This commit is contained in:
2025-10-31 15:08:37 +08:00
4 changed files with 31 additions and 14 deletions

View File

@ -11,7 +11,7 @@
<el-descriptions-item
v-for="subItem in item.specs"
:key="subItem.key"
:label="subItem.value"
:label="subItem.key"
>
{{ subItem.value }}
</el-descriptions-item>

View File

@ -34,9 +34,8 @@ export const useProduct = (id: string) => {
specs: [
'id',
{
translations: ['id', 'key'],
translations: ['id', 'key', 'value'],
},
'value',
],
},
],

View File

@ -61,12 +61,13 @@ export function toProductSpecGroupView(
export function toProductSpecView(raw: ProductSpec): ProductSpecView {
const trans = raw.translations?.[0] ?? {
key: '',
value: '',
};
return {
id: raw.id,
key: trans.key,
value: raw.value,
value: trans.value,
};
}

View File

@ -26,13 +26,6 @@ export interface ContactInfoTranslation {
content?: string | null;
}
export interface DocumentsTranslation {
/** @primaryKey */
id: number;
languages_code?: Language | string | null;
title?: string | null;
}
export interface Homepage {
/** @primaryKey */
id: number;
@ -55,6 +48,28 @@ export interface Language {
direction?: 'ltr' | 'rtl' | null;
}
export interface MeiliIndexConfig {
/** @primaryKey */
id: number;
/** @description 要索引的集合名 */
collection_name?: string | null;
/** @description MeiliSearch 索引名称 */
index_name?: string | null;
/** @description 要索引的字段数组 */
fields?: 'json' | null;
/** @description 是否启用 */
enabled?: boolean | null;
}
export interface MeiliSearchConfig {
/** @primaryKey */
id: number;
/** @description MeiliSearch 主机地址 */
host?: string | null;
/** @description MeiliSearch API Key */
api_key?: string | null;
}
export interface ProductDocument {
/** @primaryKey */
id: number;
@ -110,7 +125,6 @@ export interface ProductSpec {
id: number;
group?: ProductSpecGroup | string | null;
sort?: number | null;
value?: string | null;
translations?: ProductSpecsTranslation[] | null;
}
@ -120,6 +134,7 @@ export interface ProductSpecsTranslation {
product_specs_id?: ProductSpec | string | null;
languages_code?: Language | string | null;
key?: string | null;
value?: string | null;
}
export interface ProductType {
@ -728,10 +743,11 @@ export interface Schema {
company_profile_translations: CompanyProfileTranslation[];
contact_info: ContactInfo;
contact_info_translations: ContactInfoTranslation[];
documents_translations: DocumentsTranslation[];
homepage: Homepage;
homepage_files: HomepageFile[];
languages: Language[];
meili_index_configs: MeiliIndexConfig[];
meili_search_config: MeiliSearchConfig;
product_documents: ProductDocument[];
product_documents_translations: ProductDocumentsTranslation[];
product_images: ProductImage[];
@ -787,10 +803,11 @@ export enum CollectionNames {
company_profile_translations = 'company_profile_translations',
contact_info = 'contact_info',
contact_info_translations = 'contact_info_translations',
documents_translations = 'documents_translations',
homepage = 'homepage',
homepage_files = 'homepage_files',
languages = 'languages',
meili_index_configs = 'meili_index_configs',
meili_search_config = 'meili_search_config',
product_documents = 'product_documents',
product_documents_translations = 'product_documents_translations',
product_images = 'product_images',