From 83d3188477f995a6570125a94ac361b8ce7395de Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 31 Oct 2025 10:44:22 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90mall=20=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E3=80=91=E7=A7=92=E6=9D=80=E6=B4=BB=E5=8A=A8=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=88antd=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/promotion/seckill/activity/data.ts | 112 ++++++++++ .../mall/promotion/seckill/activity/index.vue | 2 +- .../seckill/activity/modules/form.vue | 191 +++++++++++++----- 3 files changed, 258 insertions(+), 47 deletions(-) diff --git a/apps/web-antd/src/views/mall/promotion/seckill/activity/data.ts b/apps/web-antd/src/views/mall/promotion/seckill/activity/data.ts index 77124baed..a5c5a8450 100644 --- a/apps/web-antd/src/views/mall/promotion/seckill/activity/data.ts +++ b/apps/web-antd/src/views/mall/promotion/seckill/activity/data.ts @@ -4,6 +4,9 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { z } from '#/adapter/form'; +import { getSimpleSeckillConfigList } from '#/api/mall/promotion/seckill/seckillConfig'; + /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ @@ -29,6 +32,115 @@ export function useGridFormSchema(): VbenFormSchema[] { ]; } +/** 新增/编辑的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + // 隐藏的 ID 字段 + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '秒杀活动名称', + component: 'Input', + componentProps: { + placeholder: '请输入活动名称', + }, + rules: 'required', + formItemClass: 'col-span-2', + }, + { + fieldName: 'startTime', + label: '活动开始时间', + component: 'DatePicker', + componentProps: { + placeholder: '请选择活动开始时间', + showTime: false, + format: 'YYYY-MM-DD', + valueFormat: 'x', + class: 'w-full', + }, + rules: 'required', + }, + { + fieldName: 'endTime', + label: '活动结束时间', + component: 'DatePicker', + componentProps: { + placeholder: '请选择活动结束时间', + showTime: false, + format: 'YYYY-MM-DD', + valueFormat: 'x', + class: 'w-full', + }, + rules: 'required', + }, + { + fieldName: 'configIds', + label: '秒杀时段', + component: 'ApiSelect', + componentProps: { + placeholder: '请选择秒杀时段', + mode: 'multiple', + api: getSimpleSeckillConfigList, + labelField: 'name', + valueField: 'id', + class: 'w-full', + }, + rules: 'required', + formItemClass: 'col-span-2', + }, + { + fieldName: 'totalLimitCount', + label: '总限购数量', + component: 'InputNumber', + componentProps: { + placeholder: '请输入总限购数量', + min: 0, + class: 'w-full', + }, + rules: z.number().min(0).default(0), + }, + { + fieldName: 'singleLimitCount', + label: '单次限购数量', + component: 'InputNumber', + componentProps: { + placeholder: '请输入单次限购数量', + min: 0, + class: 'w-full', + }, + rules: z.number().min(0).default(0), + }, + { + fieldName: 'sort', + label: '排序', + component: 'InputNumber', + componentProps: { + placeholder: '请输入排序', + min: 0, + class: 'w-full', + }, + rules: z.number().min(0).default(0), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + rows: 4, + }, + formItemClass: 'col-span-2', + }, + ]; +} + /** 列表的字段 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ diff --git a/apps/web-antd/src/views/mall/promotion/seckill/activity/index.vue b/apps/web-antd/src/views/mall/promotion/seckill/activity/index.vue index 83538bdd1..dfed233c2 100644 --- a/apps/web-antd/src/views/mall/promotion/seckill/activity/index.vue +++ b/apps/web-antd/src/views/mall/promotion/seckill/activity/index.vue @@ -5,7 +5,6 @@ import type { MallSeckillActivityApi } from '#/api/mall/promotion/seckill/seckil import { onMounted } from 'vue'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { $t } from '@vben/locales'; import { message, Tag } from 'ant-design-vue'; @@ -16,6 +15,7 @@ import { getSeckillActivityPage, } from '#/api/mall/promotion/seckill/seckillActivity'; import { getSimpleSeckillConfigList } from '#/api/mall/promotion/seckill/seckillConfig'; +import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; import { formatConfigNames, formatTimeRange, setConfigList } from './formatter'; diff --git a/apps/web-antd/src/views/mall/promotion/seckill/activity/modules/form.vue b/apps/web-antd/src/views/mall/promotion/seckill/activity/modules/form.vue index 7aef17ae8..ceef1485b 100644 --- a/apps/web-antd/src/views/mall/promotion/seckill/activity/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/seckill/activity/modules/form.vue @@ -1,11 +1,11 @@