diff --git a/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts b/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts index ad5cf83e5..905b47f36 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts +++ b/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts @@ -1,5 +1,7 @@ import type { VbenFormSchema } from '#/adapter/form'; +import { h } from 'vue'; + import { DeliveryTypeEnum, DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { handleTree } from '@vben/utils'; @@ -9,6 +11,8 @@ import { getSimpleBrandList } from '#/api/mall/product/brand'; import { getCategoryList } from '#/api/mall/product/category'; import { getSimpleTemplateList } from '#/api/mall/trade/delivery/expressTemplate'; +import SkuList from './sku-list.vue'; + /** 基础设置的表单 */ export function useInfoFormSchema(): VbenFormSchema[] { return [ @@ -104,7 +108,11 @@ export function useInfoFormSchema(): VbenFormSchema[] { } /** 价格库存的表单 */ -export function useSkuFormSchema(): VbenFormSchema[] { +export function useSkuFormSchema( + propertyList: any[] = [], + ruleConfig: any[] = [], + isDetail: boolean = false, +): VbenFormSchema[] { return [ { fieldName: 'id', @@ -152,7 +160,65 @@ export function useSkuFormSchema(): VbenFormSchema[] { }, rules: 'required', }, - // TODO @xingyu:待补充商品属性 + // 单规格时显示的 SkuList + { + fieldName: 'singleSkuList', + label: '', + component: h(SkuList), + componentProps: { + propertyList, + ruleConfig, + }, + dependencies: { + triggerFields: ['specType'], + // 当 specType 为 false(单规格)时显示 + show: (values) => values.specType === false, + }, + }, + // 多规格时显示的商品属性(占位,实际通过插槽渲染) + { + fieldName: 'productAttributes', + label: '商品属性', + component: 'Input', + componentProps: {}, + dependencies: { + triggerFields: ['specType'], + // 当 specType 为 true(多规格)时显示 + show: (values) => values.specType === true, + }, + }, + // 多规格 - 批量设置 + { + fieldName: 'batchSkuList', + label: '批量设置', + component: h(SkuList), + componentProps: { + isBatch: true, + propertyList, + }, + dependencies: { + triggerFields: ['specType'], + // 当 specType 为 true(多规格)且 propertyList 有数据时显示,且非详情模式 + show: (values) => + values.specType === true && propertyList.length > 0 && !isDetail, + }, + }, + // 多规格 - 规格列表 + { + fieldName: 'multiSkuList', + label: '规格列表', + component: h(SkuList), + componentProps: { + propertyList, + ruleConfig, + isDetail, + }, + dependencies: { + triggerFields: ['specType'], + // 当 specType 为 true(多规格)且 propertyList 有数据时显示 + show: (values) => values.specType === true && propertyList.length > 0, + }, + }, ]; } diff --git a/apps/web-antd/src/views/mall/product/spu/modules/form.vue b/apps/web-antd/src/views/mall/product/spu/modules/form.vue index 3cfb43dab..8a395feac 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/form.vue +++ b/apps/web-antd/src/views/mall/product/spu/modules/form.vue @@ -1,11 +1,13 @@