diff --git a/apps/web-antd/src/components/table-action/icons.ts b/apps/web-antd/src/components/table-action/icons.ts index 88cda5978b6cf8bb86b5835bf407ca2a91c963b2..df5bf1a779cb62fdab3eeccb7ff04c6986ae21ae 100644 --- a/apps/web-antd/src/components/table-action/icons.ts +++ b/apps/web-antd/src/components/table-action/icons.ts @@ -10,4 +10,5 @@ export const ACTION_ICON = { MORE: 'lucide:ellipsis-vertical', VIEW: 'lucide:eye', COPY: 'lucide:copy', + CLOSE: 'lucide:x', }; diff --git a/apps/web-antd/src/views/mall/product/spu/form/modules/spu-table-select.vue b/apps/web-antd/src/views/mall/product/spu/form/modules/spu-table-select.vue new file mode 100644 index 0000000000000000000000000000000000000000..850c5b94c09eaeff4e02a2037a9d64d7258bc5b0 --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/form/modules/spu-table-select.vue @@ -0,0 +1,357 @@ + + + + diff --git a/apps/web-antd/src/views/mall/promotion/components/index.ts b/apps/web-antd/src/views/mall/promotion/components/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd1f9d3c81ca2a2cfb6922dbec42f7faeab7a76d --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/components/index.ts @@ -0,0 +1,5 @@ +export { default as SpuAndSkuList } from './spu-and-sku-list.vue'; +export { default as SpuSkuSelect } from './spu-sku-select.vue'; + +export type * from './types'; + diff --git a/apps/web-antd/src/views/mall/promotion/components/spu-and-sku-list.vue b/apps/web-antd/src/views/mall/promotion/components/spu-and-sku-list.vue new file mode 100644 index 0000000000000000000000000000000000000000..1011e52bcb16d3dc7114c52eb7543afb9bce2b34 --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/components/spu-and-sku-list.vue @@ -0,0 +1,243 @@ + + + + diff --git a/apps/web-antd/src/views/mall/promotion/components/spu-sku-select.vue b/apps/web-antd/src/views/mall/promotion/components/spu-sku-select.vue new file mode 100644 index 0000000000000000000000000000000000000000..2b77a3bf86eb78a1ea48a8235d296393d84d28ee --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/components/spu-sku-select.vue @@ -0,0 +1,341 @@ + + + + diff --git a/apps/web-antd/src/views/mall/promotion/components/types.ts b/apps/web-antd/src/views/mall/promotion/components/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..649c467177ddf7fc980eb4cf2d17ef78d3b66f13 --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/components/types.ts @@ -0,0 +1,15 @@ +import type { PropertyAndValues } from '#/views/mall/product/spu/form'; + +/** + * SPU 属性配置 + * 用于活动商品选择中,关联 SPU 和其属性列表 + */ +export interface SpuProperty { + /** SPU ID */ + spuId: number; + /** SPU 详情 */ + spuDetail: T; + /** 属性列表 */ + propertyList: PropertyAndValues[]; +} + diff --git a/apps/web-antd/src/views/mall/promotion/point/activity/data.ts b/apps/web-antd/src/views/mall/promotion/point/activity/data.ts index 63353aa68ad00e822ff5dca14f3683e58fb76f64..f08fcc5998fb201365122b696291f29d2697d6fe 100644 --- a/apps/web-antd/src/views/mall/promotion/point/activity/data.ts +++ b/apps/web-antd/src/views/mall/promotion/point/activity/data.ts @@ -1,51 +1,18 @@ +// 1. 导入类型 import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; -import { DICT_TYPE } from '@vben/constants'; +// 2. 导入 VBEN 常量和工具 +import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; +import { $t } from '@vben/locales'; -/** 表单配置 */ -export function useFormSchema(): VbenFormSchema[] { - return [ - { - fieldName: 'id', - component: 'Input', - dependencies: { - triggerFields: [''], - show: () => false, - }, - }, - { - fieldName: 'spuId', - label: '积分商城活动商品', - component: 'Input', - componentProps: { - placeholder: '请选择商品', - }, - rules: 'required', - }, - { - fieldName: 'sort', - label: '排序', - component: 'InputNumber', - componentProps: { - placeholder: '请输入排序', - min: 0, - }, - rules: 'required', - }, - { - fieldName: 'remark', - label: '备注', - component: 'Textarea', - componentProps: { - placeholder: '请输入备注', - rows: 4, - }, - }, - ]; -} +// 3. 导入 Zod 用于高级验证 +import { z } from '#/adapter/form'; -/** 列表的搜索表单 */ +/** + * @description: 列表的搜索表单 + */ export function useGridFormSchema(): VbenFormSchema[] { return [ { @@ -53,17 +20,20 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '活动状态', component: 'Select', componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), placeholder: '请选择活动状态', allowClear: true, - dictType: DICT_TYPE.COMMON_STATUS, }, }, ]; } -/** 列表的字段 */ +/** + * @description: 列表的字段 + */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ + { type: 'checkbox', width: 40 }, { field: 'id', title: '活动编号', @@ -75,6 +45,9 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { minWidth: 80, cellRender: { name: 'CellImage', + props: { + height: 40, + }, }, }, { @@ -86,55 +59,101 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'marketPrice', title: '原价', minWidth: 100, - formatter: 'formatAmount2', - }, - { - field: 'point', - title: '兑换积分', - minWidth: 100, - }, - { - field: 'price', - title: '兑换金额', - minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatAmount', }, { field: 'status', title: '活动状态', minWidth: 100, + align: 'center', cellRender: { name: 'CellDict', - props: { type: DICT_TYPE.COMMON_STATUS }, + props: { + type: DICT_TYPE.COMMON_STATUS, + value: CommonStatusEnum.ENABLE, + }, }, }, { field: 'stock', title: '库存', minWidth: 80, + align: 'center', }, { field: 'totalStock', title: '总库存', minWidth: 80, + align: 'center', }, { field: 'redeemedQuantity', title: '已兑换数量', minWidth: 100, - slots: { default: 'redeemedQuantity' }, + align: 'center', + // 使用 formatter 计算已兑换数量 + formatter: ({ row }) => { + return (row.totalStock || 0) - (row.stock || 0); + }, }, { field: 'createTime', - title: '创建时间', + title: $t('common.createTime'), minWidth: 180, + align: 'center', formatter: 'formatDateTime', }, { - title: '操作', + title: $t('common.action'), width: 150, fixed: 'right', slots: { default: 'actions' }, }, ]; } + +/** + * @description: 新增/修改的表单 + */ +export function useFormSchema(): VbenFormSchema[] { + return [ + // 隐藏的 ID 字段 + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'spuId', + label: '积分商城活动商品', + component: 'Input', + rules: 'required', + formItemClass: 'col-span-2', + // 通过插槽实现自定义商品选择器 + renderComponentContent: () => ({ + default: () => null, + }), + }, + { + fieldName: 'sort', + label: '排序', + component: 'InputNumber', + componentProps: { + min: 0, + }, + rules: z.number().default(0), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + rows: 4, + }, + formItemClass: 'col-span-2', + }, + ]; +} diff --git a/apps/web-antd/src/views/mall/promotion/point/activity/index.vue b/apps/web-antd/src/views/mall/promotion/point/activity/index.vue index a592d589eba27e84c10efbae9e6ad579869ac254..fa3f06c0540ee0e4a65f0568d0467235921c188e 100644 --- a/apps/web-antd/src/views/mall/promotion/point/activity/index.vue +++ b/apps/web-antd/src/views/mall/promotion/point/activity/index.vue @@ -1,10 +1,9 @@