From 25af653216679fb80dcfec11c592e216543072c7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 7 Oct 2025 16:28:15 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90mem?= =?UTF-8?q?ber=20=E4=BC=9A=E5=91=98=E3=80=91=E8=BF=81=E7=A7=BB=20CouponSen?= =?UTF-8?q?dForm=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/promotion/coupon/components/data.ts | 64 +++++++++++++++++++ .../mall/promotion/coupon/components/index.ts | 2 + .../{CouponSendForm.vue => send-form.vue} | 63 ++---------------- apps/web-antd/src/views/member/user/index.vue | 2 +- 4 files changed, 74 insertions(+), 57 deletions(-) create mode 100644 apps/web-antd/src/views/mall/promotion/coupon/components/data.ts create mode 100644 apps/web-antd/src/views/mall/promotion/coupon/components/index.ts rename apps/web-antd/src/views/mall/promotion/coupon/components/{CouponSendForm.vue => send-form.vue} (59%) diff --git a/apps/web-antd/src/views/mall/promotion/coupon/components/data.ts b/apps/web-antd/src/views/mall/promotion/coupon/components/data.ts new file mode 100644 index 000000000..35a823b79 --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/coupon/components/data.ts @@ -0,0 +1,64 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeGridProps } from '#/adapter/vxe-table'; + +import { + discountFormat, + remainedCountFormat, + usePriceFormat, + validityTypeFormat, +} from '../formatter'; + +/** 搜索表单的 schema */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'name', + label: '优惠券名称', + componentProps: { + placeholder: '请输入优惠券名称', + allowClear: true, + }, + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeGridProps['columns'] { + return [ + { + title: '优惠券名称', + field: 'name', + minWidth: 120, + }, + { + title: '优惠金额 / 折扣', + field: 'discount', + minWidth: 120, + formatter: ({ row }) => discountFormat(row), + }, + { + title: '最低消费', + field: 'usePrice', + minWidth: 100, + formatter: ({ row }) => usePriceFormat(row), + }, + { + title: '有效期限', + field: 'validityType', + minWidth: 140, + formatter: ({ row }) => validityTypeFormat(row), + }, + { + title: '剩余数量', + minWidth: 100, + formatter: ({ row }) => remainedCountFormat(row), + }, + { + title: '操作', + width: 100, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mall/promotion/coupon/components/index.ts b/apps/web-antd/src/views/mall/promotion/coupon/components/index.ts new file mode 100644 index 000000000..3e18ad3c7 --- /dev/null +++ b/apps/web-antd/src/views/mall/promotion/coupon/components/index.ts @@ -0,0 +1,2 @@ +export { default as CouponSendForm } from './send-form.vue'; +export * from './data'; \ No newline at end of file diff --git a/apps/web-antd/src/views/mall/promotion/coupon/components/CouponSendForm.vue b/apps/web-antd/src/views/mall/promotion/coupon/components/send-form.vue similarity index 59% rename from apps/web-antd/src/views/mall/promotion/coupon/components/CouponSendForm.vue rename to apps/web-antd/src/views/mall/promotion/coupon/components/send-form.vue index 7a6247606..442217efe 100644 --- a/apps/web-antd/src/views/mall/promotion/coupon/components/CouponSendForm.vue +++ b/apps/web-antd/src/views/mall/promotion/coupon/components/send-form.vue @@ -11,12 +11,7 @@ import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { sendCoupon } from '#/api/mall/promotion/coupon/coupon'; import { getCouponTemplatePage } from '#/api/mall/promotion/coupon/couponTemplate'; -import { - discountFormat, - remainedCountFormat, - usePriceFormat, - validityTypeFormat, -} from '../formatter'; +import { useFormSchema, useGridColumns } from './data'; /** 发送优惠券 */ async function handleSendCoupon(row: MallCouponTemplateApi.CouponTemplate) { @@ -35,57 +30,10 @@ async function handleSendCoupon(row: MallCouponTemplateApi.CouponTemplate) { const [Grid] = useVbenVxeGrid({ formOptions: { - // TODO @AI:挪到 data.ts - schema: [ - { - component: 'Input', - fieldName: 'name', - label: '优惠券名称', - componentProps: { - placeholder: '请输入优惠券名称', - allowClear: true, - }, - }, - ], + schema: useFormSchema(), }, gridOptions: { - // TODO @AI:挪到 data.ts - columns: [ - { - title: '优惠券名称', - field: 'name', - minWidth: 120, - }, - { - title: '优惠金额 / 折扣', - field: 'discount', - minWidth: 120, - formatter: ({ row }) => discountFormat(row), - }, - { - title: '最低消费', - field: 'usePrice', - minWidth: 100, - formatter: ({ row }) => usePriceFormat(row), - }, - { - title: '有效期限', - field: 'validityType', - minWidth: 140, - formatter: ({ row }) => validityTypeFormat(row), - }, - { - title: '剩余数量', - minWidth: 100, - formatter: ({ row }) => remainedCountFormat(row), - }, - { - title: '操作', - width: 100, - fixed: 'right', - slots: { default: 'actions' }, - }, - ], + columns: useGridColumns(), height: 500, keepSource: true, proxyConfig: { @@ -111,7 +59,10 @@ const [Grid] = useVbenVxeGrid({ } as VxeGridProps, }); -const [Modal, modalApi] = useVbenModal({}); +const [Modal, modalApi] = useVbenModal({ + showCancelButton: false, + showConfirmButton: false, +});