From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/mall/promotion/coupon/formatter.ts | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/views/mall/promotion/coupon/formatter.ts b/src/views/mall/promotion/coupon/formatter.ts
new file mode 100644
index 0000000..8005d0c
--- /dev/null
+++ b/src/views/mall/promotion/coupon/formatter.ts
@@ -0,0 +1,59 @@
+import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants'
+import { formatDate } from '@/utils/formatTime'
+import { CouponTemplateVO } from '@/api/mall/promotion/coupon/couponTemplate'
+import { floatToFixed2 } from '@/utils'
+
+// 鏍煎紡鍖栥�愪紭鎯犻噾棰�/鎶樻墸銆�
+export const discountFormat = (row: CouponTemplateVO) => {
+ if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) {
+ return `锟�${floatToFixed2(row.discountPrice)}`
+ }
+ if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) {
+ return `${row.discountPercent}%`
+ }
+ return '鏈煡銆�' + row.discountType + '銆�'
+}
+
+// 鏍煎紡鍖栥�愰鍙栦笂闄愩��
+export const takeLimitCountFormat = (row: CouponTemplateVO) => {
+ if (row.takeLimitCount) {
+ if (row.takeLimitCount === -1) {
+ return '鏃犻鍙栭檺鍒�'
+ }
+ return `${row.takeLimitCount} 寮�/浜篳
+ } else {
+ return ' '
+ }
+}
+
+// 鏍煎紡鍖栥�愭湁鏁堟湡闄愩��
+export const validityTypeFormat = (row: CouponTemplateVO) => {
+ if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) {
+ return `${formatDate(row.validStartTime)} 鑷� ${formatDate(row.validEndTime)}`
+ }
+ if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) {
+ return `棰嗗彇鍚庣 ${row.fixedStartTerm} - ${row.fixedEndTerm} 澶╁唴鍙敤`
+ }
+ return '鏈煡銆�' + row.validityType + '銆�'
+}
+
+// 鏍煎紡鍖栥�恡otalCount銆�
+export const totalCountFormat = (row: CouponTemplateVO) => {
+ if (row.totalCount === -1) {
+ return '涓嶉檺鍒�'
+ }
+ return row.totalCount
+}
+
+// 鏍煎紡鍖栥�愬墿浣欐暟閲忋��
+export const remainedCountFormat = (row: CouponTemplateVO) => {
+ if (row.totalCount === -1) {
+ return '涓嶉檺鍒�'
+ }
+ return row.totalCount - row.takeCount
+}
+
+// 鏍煎紡鍖栥�愭渶浣庢秷璐广��
+export const usePriceFormat = (row: CouponTemplateVO) => {
+ return `锟�${floatToFixed2(row.usePrice)}`
+}
--
Gitblit v1.8.0