|
2 | 2 | <div class="app-container">
|
3 | 3 |
|
4 | 4 | <!-- 搜索工作栏 -->
|
5 |
| - <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
6 |
| - <el-form-item label="优惠劵名" prop="name"> |
| 5 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="82px"> |
| 6 | + <el-form-item label="优惠券名称" prop="name"> |
7 | 7 | <el-input v-model="queryParams.name" placeholder="请输入优惠劵名" clearable @keyup.enter.native="handleQuery"/>
|
8 | 8 | </el-form-item>
|
9 |
| - <el-form-item label="状态" prop="status"> |
10 |
| - <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small"> |
11 |
| - <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" |
12 |
| - :key="dict.value" :label="dict.label" :value="dict.value"/> |
| 9 | + <el-form-item label="优惠券类型" prop="discountType"> |
| 10 | + <el-select v-model="queryParams.discountType" placeholder="请选择优惠券类型" clearable size="small"> |
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)" |
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> |
13 | 13 | </el-select>
|
14 | 14 | </el-form-item>
|
15 |
| - <el-form-item label="类型 |
16 |
| - * |
17 |
| - * 1-优惠劵 |
18 |
| - * 2-优惠码" prop="type"> |
19 |
| - <el-select v-model="queryParams.type" placeholder="请选择类型 |
20 |
| - * |
21 |
| - * 1-优惠劵 |
22 |
| - * 2-优惠码" clearable size="small"> |
23 |
| - <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PRODUCT_SPU_STATUS)" |
| 15 | + <el-form-item label="优惠券状态" prop="status"> |
| 16 | + <el-select v-model="queryParams.status" placeholder="请选择优惠券状态" clearable size="small"> |
| 17 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" |
24 | 18 | :key="dict.value" :label="dict.label" :value="dict.value"/>
|
25 | 19 | </el-select>
|
26 | 20 | </el-form-item>
|
|
48 | 42 | <el-table-column label="优惠券名称" align="center" prop="name" />
|
49 | 43 | <el-table-column label="优惠券类型" align="center" prop="discountType">
|
50 | 44 | <template slot-scope="scope">
|
51 |
| - <dict-tag :type="DICT_TYPE.PRODUCT_SPU_STATUS" :value="scope.row.type" /> |
| 45 | + <dict-tag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="scope.row.discountType" /> |
52 | 46 | </template>
|
53 | 47 | </el-table-column>
|
54 |
| - <el-table-column label="发行总量" align="center" prop="totalCount" /> |
55 |
| - <el-table-column label="每人限领个数 |
56 |
| - * |
57 |
| - * null - 则表示不限制" align="center" prop="takeLimitCount" /> |
58 |
| - <el-table-column label="领取方式" align="center" prop="takeType" /> |
59 |
| - <el-table-column label="是否设置满多少金额可用,单位:分" align="center" prop="usePrice" /> |
60 |
| - <el-table-column label="商品范围" align="center" prop="productScope" /> |
61 |
| - <el-table-column label="商品 SPU 编号的数组" align="center" prop="productSpuIds" /> |
62 |
| - <el-table-column label="生效日期类型" align="center" prop="validityType" /> |
63 |
| - <el-table-column label="固定日期-生效开始时间" align="center" prop="validStartTime" width="180"> |
| 48 | + <el-table-column label="优惠金额 / 折扣" align="center" prop="discount" :formatter="discountFormat" /> |
| 49 | + <el-table-column label="发放数量" align="center" prop="totalCount" /> |
| 50 | + <el-table-column label="剩余数量" align="center" prop="totalCount" :formatter="row => (row.totalCount - row.takeCount)" /> |
| 51 | + <el-table-column label="领取上限" align="center" prop="takeLimitCount" :formatter="takeLimitCountFormat" /> |
| 52 | + <el-table-column label="有效期限" align="center" prop="validityType" width="180" :formatter="validityTypeFormat" /> |
| 53 | + <el-table-column label="状态" align="center" prop="status"> |
64 | 54 | <template slot-scope="scope">
|
65 |
| - <span>{{ parseTime(scope.row.validStartTime) }}</span> |
66 |
| - </template> |
67 |
| - </el-table-column> |
68 |
| - <el-table-column label="固定日期-生效结束时间" align="center" prop="validEndTime" width="180"> |
69 |
| - <template slot-scope="scope"> |
70 |
| - <span>{{ parseTime(scope.row.validEndTime) }}</span> |
| 55 | + <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
71 | 56 | </template>
|
72 | 57 | </el-table-column>
|
73 |
| - <el-table-column label="领取日期-开始天数" align="center" prop="fixedStartTerm" /> |
74 |
| - <el-table-column label="领取日期-结束天数" align="center" prop="fixedEndTerm" /> |
75 |
| - <el-table-column label="折扣百分比" align="center" prop="discountPercent" /> |
76 |
| - <el-table-column label="优惠金额,单位:分" align="center" prop="discountPrice" /> |
77 |
| - <el-table-column label="折扣上限" /> |
78 |
| - <el-table-column label="领取优惠券的数量" align="center" prop="takeNum" /> |
79 |
| - <el-table-column label="使用优惠券的次数" align="center" prop="useCount" /> |
80 | 58 | <el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
81 | 59 | <template slot-scope="scope">
|
82 | 60 | <span>{{ parseTime(scope.row.createTime) }}</span>
|
83 | 61 | </template>
|
84 | 62 | </el-table-column>
|
85 |
| - <el-table-column label="优惠券类型" align="center" prop="status"> |
86 |
| - <template slot-scope="scope"> |
87 |
| - <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
88 |
| - </template> |
89 |
| - </el-table-column> |
90 | 63 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
91 | 64 | <template slot-scope="scope">
|
92 | 65 | <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
|
185 | 158 | </template>
|
186 | 159 |
|
187 | 160 | <script>
|
188 |
| -import { createCouponTemplate, updateCouponTemplate, deleteCouponTemplate, getCouponTemplate, getCouponTemplatePage, exportCouponTemplateExcel } from "@/api/promotion/couponTemplate"; |
| 161 | +import { createCouponTemplate, updateCouponTemplate, deleteCouponTemplate, getCouponTemplate, getCouponTemplatePage } from "@/api/promotion/couponTemplate"; |
| 162 | +import {CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum} from "@/utils/constants"; |
189 | 163 |
|
190 | 164 | export default {
|
191 | 165 | name: "CouponTemplate",
|
@@ -340,6 +314,33 @@ export default {
|
340 | 314 | this.$modal.msgSuccess("删除成功");
|
341 | 315 | }).catch(() => {});
|
342 | 316 | },
|
| 317 | + // 格式化【优惠金额/折扣】 |
| 318 | + discountFormat(row, column) { |
| 319 | + if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { |
| 320 | + return `¥${(row.discountPrice / 100.0).toFixed(2)}`; |
| 321 | + } |
| 322 | + if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) { |
| 323 | + return `¥${(row.discountPrice / 100.0).toFixed(2)}`; |
| 324 | + } |
| 325 | + return '未知【' + row.discountType + '】'; |
| 326 | + }, |
| 327 | + // 格式化【领取上限】 |
| 328 | + takeLimitCountFormat(row, column) { |
| 329 | + if (row.takeLimitCount === -1) { |
| 330 | + return '无领取限制'; |
| 331 | + } |
| 332 | + return `${row.takeLimitCount} 张/人` |
| 333 | + }, |
| 334 | + // 格式化【有效期限】 |
| 335 | + validityTypeFormat(row, column) { |
| 336 | + if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { |
| 337 | + return `${parseTime(row.validStartTime)} 至 ${parseTime(row.validEndTime)}` |
| 338 | + } |
| 339 | + if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) { |
| 340 | + return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用` |
| 341 | + } |
| 342 | + return '未知【' + row.validityType + '】'; |
| 343 | + } |
343 | 344 | }
|
344 | 345 | };
|
345 | 346 | </script>
|
0 commit comments