From 390d9d7ca7f46795a6ed12684d2c1baaf931f8ec Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 24 Nov 2025 15:03:20 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90mal?= =?UTF-8?q?l=E3=80=91=20spu=20=E7=9B=B8=E5=85=B3=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/product/spu/components/index.ts | 2 + .../spu/components/spu-and-sku-list.vue | 177 +++++++++++ .../product/spu/components/spu-select-data.ts | 129 ++++++++ .../product/spu/components/spu-select.vue | 285 ++++++++++++++++++ .../views/mall/product/spu/components/type.ts | 6 + .../promotion/point/activity/modules/form.vue | 18 +- 6 files changed, 609 insertions(+), 8 deletions(-) create mode 100644 apps/web-antd/src/views/mall/product/spu/components/spu-and-sku-list.vue create mode 100644 apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts create mode 100644 apps/web-antd/src/views/mall/product/spu/components/spu-select.vue 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 5027259cd..bedd27a45 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,6 +1,8 @@ export * from './property-util'; export { default as SkuList } from './sku-list.vue'; export { default as SkuTableSelect } from './sku-table-select.vue'; +export { default as SpuAndSkuList } from './spu-and-sku-list.vue'; +export { default as SpuSkuSelect } from './spu-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/spu-and-sku-list.vue b/apps/web-antd/src/views/mall/product/spu/components/spu-and-sku-list.vue new file mode 100644 index 000000000..971843c2c --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/components/spu-and-sku-list.vue @@ -0,0 +1,177 @@ + + + diff --git a/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts b/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts new file mode 100644 index 000000000..67331682e --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts @@ -0,0 +1,129 @@ +import type { Ref } from 'vue'; + +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MallCategoryApi } from '#/api/mall/product/category'; + +import { computed } from 'vue'; + +import { formatToFraction } from '@vben/utils'; + +import { getRangePickerDefaultProps } from '#/utils'; + +/** + * @description: 列表的搜索表单 + */ +export function useGridFormSchema( + categoryTreeList: Ref, +): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '商品名称', + component: 'Input', + componentProps: { + placeholder: '请输入商品名称', + allowClear: true, + }, + }, + { + fieldName: 'categoryId', + label: '商品分类', + component: 'TreeSelect', + componentProps: { + treeData: computed(() => categoryTreeList.value), + fieldNames: { + label: 'name', + value: 'id', + }, + treeCheckStrictly: true, + placeholder: '请选择商品分类', + allowClear: true, + showSearch: true, + treeNodeFilterProp: 'name', + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** + * @description: 列表的字段 + */ +export function useGridColumns( + isSelectSku: boolean, +): VxeTableGridOptions['columns'] { + return [ + { + type: 'expand', + width: 30, + visible: isSelectSku, + slots: { content: 'expand_content' }, + }, + { type: 'checkbox', width: 55 }, + { + field: 'id', + title: '商品编号', + minWidth: 100, + align: 'center', + }, + { + field: 'picUrl', + title: '商品图', + width: 100, + align: 'center', + cellRender: { + name: 'CellImage', + }, + }, + { + field: 'name', + title: '商品名称', + minWidth: 300, + showOverflow: 'tooltip', + }, + { + field: 'price', + title: '商品售价', + minWidth: 90, + align: 'center', + formatter: ({ cellValue }) => { + // 格式化价格显示(价格以分为单位存储) + return formatToFraction(cellValue); + }, + }, + { + field: 'salesCount', + title: '销量', + minWidth: 90, + align: 'center', + }, + { + field: 'stock', + title: '库存', + minWidth: 90, + align: 'center', + }, + { + field: 'sort', + title: '排序', + minWidth: 70, + align: 'center', + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + align: 'center', + formatter: 'formatDateTime', + }, + ] as VxeTableGridOptions['columns']; +} diff --git a/apps/web-antd/src/views/mall/product/spu/components/spu-select.vue b/apps/web-antd/src/views/mall/product/spu/components/spu-select.vue new file mode 100644 index 000000000..32920ecd4 --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/components/spu-select.vue @@ -0,0 +1,285 @@ + + + diff --git a/apps/web-antd/src/views/mall/product/spu/components/type.ts b/apps/web-antd/src/views/mall/product/spu/components/type.ts index 0d5a65ef7..ba3ffc292 100644 --- a/apps/web-antd/src/views/mall/product/spu/components/type.ts +++ b/apps/web-antd/src/views/mall/product/spu/components/type.ts @@ -20,3 +20,9 @@ export interface RuleConfig { // 校验不通过时的消息提示 message: string; } + +export interface SpuProperty { + propertyList: PropertyAndValues[]; + spuDetail: T; + spuId: number; +} diff --git a/apps/web-antd/src/views/mall/promotion/point/activity/modules/form.vue b/apps/web-antd/src/views/mall/promotion/point/activity/modules/form.vue index cffca849f..174871b10 100644 --- a/apps/web-antd/src/views/mall/promotion/point/activity/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/point/activity/modules/form.vue @@ -1,8 +1,9 @@