diff --git a/apps/web-antd/src/api/mall/product/spu/index.ts b/apps/web-antd/src/api/mall/product/spu/index.ts index 4b37151c6..0c9f4ce94 100644 --- a/apps/web-antd/src/api/mall/product/spu/index.ts +++ b/apps/web-antd/src/api/mall/product/spu/index.ts @@ -62,13 +62,6 @@ export namespace MallSpuApi { valueName?: string; // 属性值名称 } - // TODO @puhui999:这个还要么? - /** 优惠券模板 */ - export interface GiveCouponTemplate { - id?: number; // 优惠券编号 - name?: string; // 优惠券名称 - } - /** 商品状态更新请求 */ export interface SpuStatusUpdateReqVO { id: number; // 商品编号 diff --git a/apps/web-antd/src/api/mall/promotion/bargain/bargainActivity.ts b/apps/web-antd/src/api/mall/promotion/bargain/bargainActivity.ts index 97917ec2d..f13b64916 100644 --- a/apps/web-antd/src/api/mall/promotion/bargain/bargainActivity.ts +++ b/apps/web-antd/src/api/mall/promotion/bargain/bargainActivity.ts @@ -1,7 +1,5 @@ import type { PageParam, PageResult } from '@vben/request'; -import type { MallSpuApi } from '#/api/mall/product/spu'; - import { requestClient } from '#/api/request'; export namespace MallBargainActivityApi { @@ -32,17 +30,6 @@ export namespace MallBargainActivityApi { bargainMinPrice: number; // 砍价底价 stock: number; // 活动库存 } - - // TODO @puhui999:要不要删除? - /** 扩展 SKU 配置 */ - export type SkuExtension = { - productConfig: BargainProduct; // 砍价活动配置 - } & MallSpuApi.Sku; - - /** 扩展 SPU 配置 */ - export interface SpuExtension extends MallSpuApi.Spu { - skus: SkuExtension[]; // SKU 列表 - } } /** 查询砍价活动列表 */ diff --git a/apps/web-antd/src/api/mall/promotion/combination/combinationActivity.ts b/apps/web-antd/src/api/mall/promotion/combination/combinationActivity.ts index 00471bd65..e497ae204 100644 --- a/apps/web-antd/src/api/mall/promotion/combination/combinationActivity.ts +++ b/apps/web-antd/src/api/mall/promotion/combination/combinationActivity.ts @@ -1,7 +1,5 @@ import type { PageParam, PageResult } from '@vben/request'; -import type { MallSpuApi } from '#/api/mall/product/spu'; - import { requestClient } from '#/api/request'; export namespace MallCombinationActivityApi { @@ -25,23 +23,12 @@ export namespace MallCombinationActivityApi { products: CombinationProduct[]; // 商品列表 } - // TODO @puhui999:要不要删除? /** 拼团活动所需属性 */ export interface CombinationProduct { spuId: number; // 商品 SPU 编号 skuId: number; // 商品 SKU 编号 combinationPrice: number; // 拼团价格 } - - /** 扩展 SKU 配置 */ - export type SkuExtension = { - productConfig: CombinationProduct; // 拼团活动配置 - } & MallSpuApi.Sku; - - /** 扩展 SPU 配置 */ - export interface SpuExtension extends MallSpuApi.Spu { - skus: SkuExtension[]; // SKU 列表 - } } /** 查询拼团活动列表 */ diff --git a/apps/web-antd/src/api/mall/promotion/discount/discountActivity.ts b/apps/web-antd/src/api/mall/promotion/discount/discountActivity.ts index 3beaa1aef..1236140f4 100644 --- a/apps/web-antd/src/api/mall/promotion/discount/discountActivity.ts +++ b/apps/web-antd/src/api/mall/promotion/discount/discountActivity.ts @@ -1,7 +1,5 @@ import type { PageParam, PageResult } from '@vben/request'; -import type { MallSpuApi } from '#/api/mall/product/spu'; - import { requestClient } from '#/api/request'; export namespace MallDiscountActivityApi { @@ -25,17 +23,6 @@ export namespace MallDiscountActivityApi { endTime?: Date; // 结束时间 products?: DiscountProduct[]; // 商品列表 } - - // TODO @puhui999:要不要删除? - /** 扩展 SKU 配置 */ - export type SkuExtension = { - productConfig: DiscountProduct; // 限时折扣配置 - } & MallSpuApi.Sku; - - /** 扩展 SPU 配置 */ - export interface SpuExtension extends MallSpuApi.Spu { - skus: SkuExtension[]; // SKU 列表 - } } /** 查询限时折扣活动列表 */ diff --git a/apps/web-antd/src/api/mall/promotion/point/index.ts b/apps/web-antd/src/api/mall/promotion/point/index.ts index 99f39bced..3cf24a4b2 100644 --- a/apps/web-antd/src/api/mall/promotion/point/index.ts +++ b/apps/web-antd/src/api/mall/promotion/point/index.ts @@ -36,17 +36,6 @@ export namespace MallPointActivityApi { price: number; // 兑换金额,单位:分 } - // TODO @puhui999:这些还需要么? - /** 扩展 SKU 配置 */ - export type SkuExtension = { - productConfig: PointProduct; // 积分商城商品配置 - } & MallSpuApi.Sku; - - /** 扩展 SPU 配置 */ - export interface SpuExtension extends MallSpuApi.Spu { - skus: SkuExtension[]; // SKU 列表 - } - /** 扩展 SPU 配置(带积分信息) */ export interface SpuExtensionWithPoint extends MallSpuApi.Spu { pointStock: number; // 积分商城活动库存 diff --git a/apps/web-antd/src/api/mall/promotion/seckill/seckillActivity.ts b/apps/web-antd/src/api/mall/promotion/seckill/seckillActivity.ts index 51da7d275..82297effd 100644 --- a/apps/web-antd/src/api/mall/promotion/seckill/seckillActivity.ts +++ b/apps/web-antd/src/api/mall/promotion/seckill/seckillActivity.ts @@ -1,7 +1,5 @@ import type { PageParam, PageResult } from '@vben/request'; -import type { MallSpuApi } from '#/api/mall/product/spu'; - import { requestClient } from '#/api/request'; export namespace MallSeckillActivityApi { @@ -34,17 +32,6 @@ export namespace MallSeckillActivityApi { seckillPrice?: number; // 秒杀价格 products?: SeckillProduct[]; // 秒杀商品列表 } - - // TODO @puhui999:这些还需要么? - /** 扩展 SKU 配置 */ - export type SkuExtension = { - productConfig: SeckillProduct; // 秒杀商品配置 - } & MallSpuApi.Sku; - - /** 扩展 SPU 配置 */ - export interface SpuExtension extends MallSpuApi.Spu { - skus: SkuExtension[]; // SKU 列表 - } } /** 查询秒杀活动列表 */ diff --git a/apps/web-antd/src/views/mall/product/spu/components/index.ts b/apps/web-antd/src/views/mall/product/spu/components/index.ts index 122cbcea0..5027259cd 100644 --- a/apps/web-antd/src/views/mall/product/spu/components/index.ts +++ b/apps/web-antd/src/views/mall/product/spu/components/index.ts @@ -1,3 +1,6 @@ +export * from './property-util'; +export { default as SkuList } from './sku-list.vue'; export { default as SkuTableSelect } from './sku-table-select.vue'; export { default as SpuShowcase } from './spu-showcase.vue'; export { default as SpuTableSelect } from './spu-table-select.vue'; +export * from './type'; diff --git a/apps/web-antd/src/views/mall/product/spu/components/property-util.ts b/apps/web-antd/src/views/mall/product/spu/components/property-util.ts new file mode 100644 index 000000000..eac791908 --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/components/property-util.ts @@ -0,0 +1,36 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +import type { MallSpuApi } from '#/api/mall/product/spu'; +import type { PropertyAndValues } from '#/views/mall/product/spu/components/type'; + +/** 获得商品的规格列表 - 商品相关的公共函数(被其他模块如 promotion 使用) */ +const getPropertyList = (spu: MallSpuApi.Spu): PropertyAndValues[] => { + // 直接拿返回的 skus 属性逆向生成出 propertyList + const properties: PropertyAndValues[] = []; + // 只有是多规格才处理 + if (spu.specType) { + spu.skus?.forEach((sku) => { + sku.properties?.forEach( + ({ propertyId, propertyName, valueId, valueName }) => { + // 添加属性 + if (!properties?.some((item) => item.id === propertyId)) { + properties.push({ + id: propertyId!, + name: propertyName!, + values: [], + }); + } + // 添加属性值 + const index = properties?.findIndex((item) => item.id === propertyId); + if ( + !properties[index]?.values?.some((value) => value.id === valueId) + ) { + properties[index]?.values?.push({ id: valueId!, name: valueName! }); + } + }, + ); + }); + } + return properties; +}; + +export { getPropertyList }; diff --git a/apps/web-antd/src/views/mall/product/spu/form/modules/sku-list.vue b/apps/web-antd/src/views/mall/product/spu/components/sku-list.vue similarity index 99% rename from apps/web-antd/src/views/mall/product/spu/form/modules/sku-list.vue rename to apps/web-antd/src/views/mall/product/spu/components/sku-list.vue index efede6a5f..0b219e211 100644 --- a/apps/web-antd/src/views/mall/product/spu/form/modules/sku-list.vue +++ b/apps/web-antd/src/views/mall/product/spu/components/sku-list.vue @@ -1,9 +1,11 @@