From 97e692d2fc99aa9877cd921f6cb06806772c5211 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 18 Oct 2025 11:37:28 +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=E4=BC=98=E6=83=A0=E5=8A=B5-=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8850%=20ele=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/mall/promotion/coupon/data.ts | 22 ------- .../views/mall/promotion/coupon/formatter.ts | 12 ++-- .../src/views/mall/promotion/coupon/index.vue | 62 +++++++++++++------ 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/apps/web-ele/src/views/mall/promotion/coupon/data.ts b/apps/web-ele/src/views/mall/promotion/coupon/data.ts index 891e46cbf..c16369b58 100644 --- a/apps/web-ele/src/views/mall/promotion/coupon/data.ts +++ b/apps/web-ele/src/views/mall/promotion/coupon/data.ts @@ -2,7 +2,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; -import { getDictOptions } from '@vben/hooks'; import { getRangePickerDefaultProps } from '#/utils'; @@ -109,24 +108,3 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, ]; } - -/** 获取状态选项卡配置 */ -export function getStatusTabs() { - const tabs = [ - { - label: '全部', - value: 'all', - }, - ]; - - // 添加字典状态选项 - const statusOptions = getDictOptions(DICT_TYPE.PROMOTION_COUPON_STATUS); - for (const option of statusOptions) { - tabs.push({ - label: option.label, - value: String(option.value), - }); - } - - return tabs; -} diff --git a/apps/web-ele/src/views/mall/promotion/coupon/formatter.ts b/apps/web-ele/src/views/mall/promotion/coupon/formatter.ts index 1c4ca1fc7..2f34863ff 100644 --- a/apps/web-ele/src/views/mall/promotion/coupon/formatter.ts +++ b/apps/web-ele/src/views/mall/promotion/coupon/formatter.ts @@ -6,7 +6,7 @@ import { } from '@vben/constants'; import { floatToFixed2, formatDate } from '@vben/utils'; -// 格式化【优惠金额/折扣】 +/** 格式化【优惠金额/折扣】 */ export function discountFormat(row: MallCouponTemplateApi.CouponTemplate) { if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { return `¥${floatToFixed2(row.discountPrice)}`; @@ -17,7 +17,7 @@ export function discountFormat(row: MallCouponTemplateApi.CouponTemplate) { return `未知【${row.discountType}】`; } -// 格式化【领取上限】 +/** 格式化【领取上限】 */ export function takeLimitCountFormat( row: MallCouponTemplateApi.CouponTemplate, ) { @@ -31,7 +31,7 @@ export function takeLimitCountFormat( } } -// 格式化【有效期限】 +/** 格式化【有效期限】 */ export function validityTypeFormat(row: MallCouponTemplateApi.CouponTemplate) { if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}`; @@ -42,7 +42,7 @@ export function validityTypeFormat(row: MallCouponTemplateApi.CouponTemplate) { return `未知【${row.validityType}】`; } -// 格式化【totalCount】 +/** 格式化【totalCount】 */ export function totalCountFormat(row: MallCouponTemplateApi.CouponTemplate) { if (row.totalCount === -1) { return '不限制'; @@ -50,7 +50,7 @@ export function totalCountFormat(row: MallCouponTemplateApi.CouponTemplate) { return row.totalCount; } -// 格式化【剩余数量】 +/** 格式化【剩余数量】 */ export function remainedCountFormat(row: MallCouponTemplateApi.CouponTemplate) { if (row.totalCount === -1) { return '不限制'; @@ -58,7 +58,7 @@ export function remainedCountFormat(row: MallCouponTemplateApi.CouponTemplate) { return row.totalCount - row.takeCount; } -// 格式化【最低消费】 +/** 格式化【最低消费】 */ export function usePriceFormat(row: MallCouponTemplateApi.CouponTemplate) { return `¥${floatToFixed2(row.usePrice)}`; } diff --git a/apps/web-ele/src/views/mall/promotion/coupon/index.vue b/apps/web-ele/src/views/mall/promotion/coupon/index.vue index e1a4f39a8..df3569ada 100644 --- a/apps/web-ele/src/views/mall/promotion/coupon/index.vue +++ b/apps/web-ele/src/views/mall/promotion/coupon/index.vue @@ -5,30 +5,37 @@ import type { MallCouponApi } from '#/api/mall/promotion/coupon/coupon'; import { ref } from 'vue'; import { DocAlert, Page } from '@vben/common-ui'; +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; +import { $t } from '@vben/locales'; -import { ElLoading, ElMessage } from 'element-plus'; +import { ElLoading, ElMessage, ElTabPane, ElTabs } from 'element-plus'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteCoupon, getCouponPage, } from '#/api/mall/promotion/coupon/coupon'; -import { $t } from '#/locales'; -import { getStatusTabs, useGridColumns, useGridFormSchema } from './data'; +import { useGridColumns, useGridFormSchema } from './data'; defineOptions({ name: 'PromotionCoupon' }); const activeTab = ref('all'); const statusTabs = ref(getStatusTabs()); +/** 刷新表格 */ +function handleRefresh() { + gridApi.query(); +} + /** 删除优惠券 */ async function handleDelete(row: MallCouponApi.Coupon) { const loadingInstance = ElLoading.service({ text: $t('ui.actionMessage.deleting', [row.name]), }); try { - await deleteCoupon(row.id as number); + await deleteCoupon(row.id!); ElMessage.success('回收成功'); handleRefresh(); } finally { @@ -36,18 +43,27 @@ async function handleDelete(row: MallCouponApi.Coupon) { } } -/** 刷新表格 */ -function handleRefresh() { - gridApi.query(); +/** 获取状态选项卡配置 */ +function getStatusTabs() { + const tabs = [ + { + label: '全部', + value: 'all', + }, + ]; + const statusOptions = getDictOptions(DICT_TYPE.PROMOTION_COUPON_STATUS); + for (const option of statusOptions) { + tabs.push({ + label: option.label, + value: String(option.value), + }); + } + return tabs; } -/** Tab切换 */ -function onTabChange(tabName: string) { +/** Tab 切换 */ +function handleTabChange(tabName: any) { activeTab.value = tabName; - // 设置状态查询参数 - const formValues = gridApi.formApi.getValues(); - const status = tabName === 'all' ? undefined : Number(tabName); - gridApi.formApi.setValues({ ...formValues, status }); gridApi.query(); } @@ -95,15 +111,20 @@ const [Grid, gridApi] = useVbenVxeGrid({ /> - + +