Commit 3c10058dbd8a9083ca2682ff5e96d2aeaa45d0b9

Authored by YunaiV
1 parent 979ba0f9

promotion:实现部分优惠劵模板的前端逻辑

yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java
... ... @@ -3,7 +3,10 @@ package cn.iocoder.yudao.framework.common.util.string;
3 3 import cn.hutool.core.util.ArrayUtil;
4 4 import cn.hutool.core.util.StrUtil;
5 5  
  6 +import java.util.Arrays;
6 7 import java.util.Collection;
  8 +import java.util.List;
  9 +import java.util.stream.Collectors;
7 10  
8 11 /**
9 12 * 字符串工具类
... ... @@ -37,4 +40,9 @@ public class StrUtils {
37 40 return false;
38 41 }
39 42  
  43 + public static List<Long> splitToLong(String value, CharSequence separator) {
  44 + long[] longs = StrUtil.splitToLong(value, separator);
  45 + return Arrays.stream(longs).boxed().collect(Collectors.toList());
  46 + }
  47 +
40 48 }
... ...
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/LongListTypeHandler.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.mybatis.core.type;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.common.util.string.StrUtils;
  5 +import org.apache.ibatis.type.JdbcType;
  6 +import org.apache.ibatis.type.MappedJdbcTypes;
  7 +import org.apache.ibatis.type.MappedTypes;
  8 +import org.apache.ibatis.type.TypeHandler;
  9 +
  10 +import java.sql.CallableStatement;
  11 +import java.sql.PreparedStatement;
  12 +import java.sql.ResultSet;
  13 +import java.sql.SQLException;
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * List<Long> 的类型转换器实现类,对应数据库的 varchar 类型
  18 + *
  19 + * @author 芋道源码
  20 + */
  21 +@MappedJdbcTypes(JdbcType.VARCHAR)
  22 +@MappedTypes(List.class)
  23 +public class LongListTypeHandler implements TypeHandler<List<Long>> {
  24 +
  25 + private static final String COMMA = ",";
  26 +
  27 + @Override
  28 + public void setParameter(PreparedStatement ps, int i, List<Long> strings, JdbcType jdbcType) throws SQLException {
  29 + // 设置占位符
  30 + ps.setString(i, CollUtil.join(strings, COMMA));
  31 + }
  32 +
  33 + @Override
  34 + public List<Long> getResult(ResultSet rs, String columnName) throws SQLException {
  35 + String value = rs.getString(columnName);
  36 + return getResult(value);
  37 + }
  38 +
  39 + @Override
  40 + public List<Long> getResult(ResultSet rs, int columnIndex) throws SQLException {
  41 + String value = rs.getString(columnIndex);
  42 + return getResult(value);
  43 + }
  44 +
  45 + @Override
  46 + public List<Long> getResult(CallableStatement cs, int columnIndex) throws SQLException {
  47 + String value = cs.getString(columnIndex);
  48 + return getResult(value);
  49 + }
  50 +
  51 + private List<Long> getResult(String value) {
  52 + if (value == null) {
  53 + return null;
  54 + }
  55 + return StrUtils.splitToLong(value, COMMA);
  56 + }
  57 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateBaseVO.java
... ... @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum;
6 6 import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
7 7 import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
8 8 import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
  9 +import com.fasterxml.jackson.annotation.JsonIgnore;
9 10 import io.swagger.annotations.ApiModelProperty;
10 11 import lombok.Data;
11 12 import org.springframework.format.annotation.DateTimeFormat;
... ... @@ -92,48 +93,56 @@ public class CouponTemplateBaseVO {
92 93 private Integer discountPriceLimit;
93 94  
94 95 @AssertTrue(message = "商品 SPU 编号的数组不能为空")
  96 + @JsonIgnore
95 97 public boolean isProductSpuIdsValid() {
96 98 return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
97 99 || CollUtil.isNotEmpty(productSpuIds);
98 100 }
99 101  
100 102 @AssertTrue(message = "生效开始时间不能为空")
  103 + @JsonIgnore
101 104 public boolean isValidStartTimeValid() {
102 105 return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType())
103 106 || validStartTime != null;
104 107 }
105 108  
106 109 @AssertTrue(message = "生效结束时间不能为空")
  110 + @JsonIgnore
107 111 public boolean isValidEndTimeValid() {
108 112 return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType())
109 113 || validEndTime != null;
110 114 }
111 115  
112 116 @AssertTrue(message = "开始天数不能为空")
  117 + @JsonIgnore
113 118 public boolean isFixedStartTermValid() {
114 119 return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType())
115 120 || fixedStartTerm != null;
116 121 }
117 122  
118 123 @AssertTrue(message = "结束天数不能为空")
  124 + @JsonIgnore
119 125 public boolean isFixedEndTermValid() {
120 126 return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType())
121 127 || fixedEndTerm != null;
122 128 }
123 129  
124 130 @AssertTrue(message = "折扣百分比不能为空")
  131 + @JsonIgnore
125 132 public boolean isDiscountPercentValid() {
126 133 return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
127 134 || discountPercent != null;
128 135 }
129 136  
130 137 @AssertTrue(message = "优惠金额不能为空")
  138 + @JsonIgnore
131 139 public boolean isDiscountPriceValid() {
132 140 return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType())
133 141 || discountPrice != null;
134 142 }
135 143  
136 144 @AssertTrue(message = "折扣上限不能为空")
  145 + @JsonIgnore
137 146 public boolean isDiscountPriceLimit() {
138 147 return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
139 148 || discountPriceLimit != null;
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java
... ... @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon;
2 2  
3 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  5 +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
5 6 import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
6 7 import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
7 8 import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
... ... @@ -10,7 +11,6 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
10 11 import com.baomidou.mybatisplus.annotation.TableField;
11 12 import com.baomidou.mybatisplus.annotation.TableId;
12 13 import com.baomidou.mybatisplus.annotation.TableName;
13   -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
14 14 import lombok.Data;
15 15 import lombok.EqualsAndHashCode;
16 16  
... ... @@ -85,7 +85,7 @@ public class CouponTemplateDO extends BaseDO {
85 85 /**
86 86 * 商品 SPU 编号的数组
87 87 */
88   - @TableField(typeHandler = JacksonTypeHandler.class)
  88 + @TableField(typeHandler = LongListTypeHandler.class)
89 89 private List<Long> productSpuIds;
90 90 /**
91 91 * 生效日期类型
... ...
yudao-ui-admin/src/api/promotion/couponTemplate.js 0 → 100755
  1 +import request from '@/utils/request'
  2 +
  3 +// 创建优惠劵模板
  4 +export function createCouponTemplate(data) {
  5 + return request({
  6 + url: '/promotion/coupon-template/create',
  7 + method: 'post',
  8 + data: data
  9 + })
  10 +}
  11 +
  12 +// 更新优惠劵模板
  13 +export function updateCouponTemplate(data) {
  14 + return request({
  15 + url: '/promotion/coupon-template/update',
  16 + method: 'put',
  17 + data: data
  18 + })
  19 +}
  20 +
  21 +// 删除优惠劵模板
  22 +export function deleteCouponTemplate(id) {
  23 + return request({
  24 + url: '/promotion/coupon-template/delete?id=' + id,
  25 + method: 'delete'
  26 + })
  27 +}
  28 +
  29 +// 获得优惠劵模板
  30 +export function getCouponTemplate(id) {
  31 + return request({
  32 + url: '/promotion/coupon-template/get?id=' + id,
  33 + method: 'get'
  34 + })
  35 +}
  36 +
  37 +// 获得优惠劵模板分页
  38 +export function getCouponTemplatePage(query) {
  39 + return request({
  40 + url: '/promotion/coupon-template/page',
  41 + method: 'get',
  42 + params: query
  43 + })
  44 +}
  45 +
  46 +// 导出优惠劵模板 Excel
  47 +export function exportCouponTemplateExcel(query) {
  48 + return request({
  49 + url: '/promotion/coupon-template/export-excel',
  50 + method: 'get',
  51 + params: query,
  52 + responseType: 'blob'
  53 + })
  54 +}
... ...
yudao-ui-admin/src/views/promotion/couponTemplate/index.vue 0 → 100755
  1 +<template>
  2 + <div class="app-container">
  3 +
  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">
  7 + <el-input v-model="queryParams.name" placeholder="请输入优惠劵名" clearable @keyup.enter.native="handleQuery"/>
  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"/>
  13 + </el-select>
  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)"
  24 + :key="dict.value" :label="dict.label" :value="dict.value"/>
  25 + </el-select>
  26 + </el-form-item>
  27 + <el-form-item label="创建时间" prop="createTime">
  28 + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  29 + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  30 + </el-form-item>
  31 + <el-form-item>
  32 + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  33 + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  34 + </el-form-item>
  35 + </el-form>
  36 +
  37 + <!-- 操作工具栏 -->
  38 + <el-row :gutter="10" class="mb8">
  39 + <el-col :span="1.5">
  40 + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  41 + v-hasPermi="['promotion:coupon-template:create']">新增</el-button>
  42 + </el-col>
  43 + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  44 + </el-row>
  45 +
  46 + <!-- 列表 -->
  47 + <el-table v-loading="loading" :data="list">
  48 + <el-table-column label="优惠券名称" align="center" prop="name" />
  49 + <el-table-column label="优惠券类型" align="center" prop="discountType">
  50 + <template slot-scope="scope">
  51 + <dict-tag :type="DICT_TYPE.PRODUCT_SPU_STATUS" :value="scope.row.type" />
  52 + </template>
  53 + </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">
  64 + <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>
  71 + </template>
  72 + </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 + <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  81 + <template slot-scope="scope">
  82 + <span>{{ parseTime(scope.row.createTime) }}</span>
  83 + </template>
  84 + </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 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  91 + <template slot-scope="scope">
  92 + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  93 + v-hasPermi="['promotion:coupon-template:update']">修改</el-button>
  94 + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  95 + v-hasPermi="['promotion:coupon-template:delete']">删除</el-button>
  96 + </template>
  97 + </el-table-column>
  98 + </el-table>
  99 + <!-- 分页组件 -->
  100 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  101 + @pagination="getList"/>
  102 +
  103 + <!-- 对话框(添加 / 修改) -->
  104 + <el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
  105 + <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  106 + <el-form-item label="优惠劵名" prop="name">
  107 + <el-input v-model="form.name" placeholder="请输入优惠劵名" />
  108 + </el-form-item>
  109 + <el-form-item label="状态" prop="status">
  110 + <el-radio-group v-model="form.status">
  111 + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
  112 + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
  113 + </el-radio-group>
  114 + </el-form-item>
  115 + <el-form-item label="类型" prop="type">
  116 + <el-select v-model="form.type" placeholder="请选择类型">
  117 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PRODUCT_SPU_STATUS)"
  118 + :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
  119 + </el-select>
  120 + </el-form-item>
  121 + <el-form-item label="发行总量" prop="totalCount">
  122 + <el-input v-model="form.totalCount" placeholder="请输入发行总量" />
  123 + </el-form-item>
  124 + <el-form-item label="每人限领个数" prop="takeLimitCount">
  125 + <el-input v-model="form.takeLimitCount" placeholder="请输入每人限领个数" />
  126 + </el-form-item>
  127 + <el-form-item label="领取方式" prop="takeType">
  128 + <el-select v-model="form.takeType" placeholder="请选择领取方式">
  129 + <el-option label="请选择字典生成" value="" />
  130 + </el-select>
  131 + </el-form-item>
  132 + <el-form-item label="是否设置满多少金额可用,单位:分" prop="usePrice">
  133 + <el-input v-model="form.usePrice" placeholder="请输入是否设置满多少金额可用,单位:分" />
  134 + </el-form-item>
  135 + <el-form-item label="商品范围" prop="productScope">
  136 + <el-input v-model="form.productScope" placeholder="请输入商品范围" />
  137 + </el-form-item>
  138 + <el-form-item label="商品 SPU 编号的数组" prop="productSpuIds">
  139 + <el-input v-model="form.productSpuIds" placeholder="请输入商品 SPU 编号的数组" />
  140 + </el-form-item>
  141 + <el-form-item label="生效日期类型" prop="validityType">
  142 + <el-select v-model="form.validityType" placeholder="请选择生效日期类型">
  143 + <el-option label="请选择字典生成" value="" />
  144 + </el-select>
  145 + </el-form-item>
  146 + <el-form-item label="固定日期-生效开始时间" prop="validStartTime">
  147 + <el-date-picker clearable v-model="form.validStartTime" type="date" value-format="timestamp" placeholder="选择固定日期-生效开始时间" />
  148 + </el-form-item>
  149 + <el-form-item label="固定日期-生效结束时间" prop="validEndTime">
  150 + <el-date-picker clearable v-model="form.validEndTime" type="date" value-format="timestamp" placeholder="选择固定日期-生效结束时间" />
  151 + </el-form-item>
  152 + <el-form-item label="领取日期-开始天数" prop="fixedStartTerm">
  153 + <el-input v-model="form.fixedStartTerm" placeholder="请输入领取日期-开始天数" />
  154 + </el-form-item>
  155 + <el-form-item label="领取日期-结束天数" prop="fixedEndTerm">
  156 + <el-input v-model="form.fixedEndTerm" placeholder="请输入领取日期-结束天数" />
  157 + </el-form-item>
  158 + <el-form-item label="优惠类型" prop="discountType">
  159 + <el-select v-model="form.discountType" placeholder="请选择优惠类型">
  160 + <el-option label="请选择字典生成" value="" />
  161 + </el-select>
  162 + </el-form-item>
  163 + <el-form-item label="折扣百分比" prop="discountPercent">
  164 + <el-input v-model="form.discountPercent" placeholder="请输入折扣百分比" />
  165 + </el-form-item>
  166 + <el-form-item label="优惠金额,单位:分" prop="discountPrice">
  167 + <el-input v-model="form.discountPrice" placeholder="请输入优惠金额,单位:分" />
  168 + </el-form-item>
  169 + <el-form-item label="折扣上限" prop="discountPriceLimit">
  170 + <el-input v-model="form.discountPriceLimit" placeholder="请输入折扣上限,仅在 {@link #preferentialType} 等于 2 时生效" />
  171 + </el-form-item>
  172 + <el-form-item label="领取优惠券的数量" prop="takeNum">
  173 + <el-input v-model="form.takeNum" placeholder="请输入领取优惠券的数量" />
  174 + </el-form-item>
  175 + <el-form-item label="使用优惠券的次数" prop="useCount">
  176 + <el-input v-model="form.useCount" placeholder="请输入使用优惠券的次数" />
  177 + </el-form-item>
  178 + </el-form>
  179 + <div slot="footer" class="dialog-footer">
  180 + <el-button type="primary" @click="submitForm">确 定</el-button>
  181 + <el-button @click="cancel">取 消</el-button>
  182 + </div>
  183 + </el-dialog>
  184 + </div>
  185 +</template>
  186 +
  187 +<script>
  188 +import { createCouponTemplate, updateCouponTemplate, deleteCouponTemplate, getCouponTemplate, getCouponTemplatePage, exportCouponTemplateExcel } from "@/api/promotion/couponTemplate";
  189 +
  190 +export default {
  191 + name: "CouponTemplate",
  192 + components: {
  193 + },
  194 + data() {
  195 + return {
  196 + // 遮罩层
  197 + loading: true,
  198 + // 导出遮罩层
  199 + exportLoading: false,
  200 + // 显示搜索条件
  201 + showSearch: true,
  202 + // 总条数
  203 + total: 0,
  204 + // 优惠劵模板列表
  205 + list: [],
  206 + // 弹出层标题
  207 + title: "",
  208 + // 是否显示弹出层
  209 + open: false,
  210 + // 查询参数
  211 + queryParams: {
  212 + pageNo: 1,
  213 + pageSize: 10,
  214 + name: null,
  215 + status: null,
  216 + type: null,
  217 + createTime: [],
  218 + },
  219 + // 表单参数
  220 + form: {},
  221 + // 表单校验
  222 + rules: {
  223 + name: [{ required: true, message: "优惠劵名不能为空", trigger: "blur" }],
  224 + status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
  225 + type: [{ required: true, message: "类型", trigger: "change" }],
  226 + totalCount: [{ required: true, message: "发行总量不能为空", trigger: "blur" }],
  227 + takeLimitCount: [{ required: true, message: "每人限领个数不能为空", trigger: "blur" }],
  228 + takeType: [{ required: true, message: "领取方式不能为空", trigger: "change" }],
  229 + usePrice: [{ required: true, message: "是否设置满多少金额可用,单位:分不能为空", trigger: "blur" }],
  230 + productScope: [{ required: true, message: "商品范围不能为空", trigger: "blur" }],
  231 + validityType: [{ required: true, message: "生效日期类型不能为空", trigger: "change" }],
  232 + discountType: [{ required: true, message: "优惠类型不能为空", trigger: "change" }],
  233 + takeNum: [{ required: true, message: "领取优惠券的数量不能为空", trigger: "blur" }],
  234 + useCount: [{ required: true, message: "使用优惠券的次数不能为空", trigger: "blur" }],
  235 + }
  236 + };
  237 + },
  238 + created() {
  239 + this.getList();
  240 + },
  241 + methods: {
  242 + /** 查询列表 */
  243 + getList() {
  244 + this.loading = true;
  245 + // 执行查询
  246 + getCouponTemplatePage(this.queryParams).then(response => {
  247 + this.list = response.data.list;
  248 + this.total = response.data.total;
  249 + this.loading = false;
  250 + });
  251 + },
  252 + /** 取消按钮 */
  253 + cancel() {
  254 + this.open = false;
  255 + this.reset();
  256 + },
  257 + /** 表单重置 */
  258 + reset() {
  259 + this.form = {
  260 + id: undefined,
  261 + name: undefined,
  262 + status: undefined,
  263 + type: undefined,
  264 + totalCount: undefined,
  265 + takeLimitCount: undefined,
  266 + takeType: undefined,
  267 + usePrice: undefined,
  268 + productScope: undefined,
  269 + productSpuIds: undefined,
  270 + validityType: undefined,
  271 + validStartTime: undefined,
  272 + validEndTime: undefined,
  273 + fixedStartTerm: undefined,
  274 + fixedEndTerm: undefined,
  275 + discountType: undefined,
  276 + discountPercent: undefined,
  277 + discountPrice: undefined,
  278 + discountPriceLimit: undefined,
  279 + takeNum: undefined,
  280 + useCount: undefined,
  281 + };
  282 + this.resetForm("form");
  283 + },
  284 + /** 搜索按钮操作 */
  285 + handleQuery() {
  286 + this.queryParams.pageNo = 1;
  287 + this.getList();
  288 + },
  289 + /** 重置按钮操作 */
  290 + resetQuery() {
  291 + this.resetForm("queryForm");
  292 + this.handleQuery();
  293 + },
  294 + /** 新增按钮操作 */
  295 + handleAdd() {
  296 + this.reset();
  297 + this.open = true;
  298 + this.title = "添加优惠劵模板";
  299 + },
  300 + /** 修改按钮操作 */
  301 + handleUpdate(row) {
  302 + this.reset();
  303 + const id = row.id;
  304 + getCouponTemplate(id).then(response => {
  305 + this.form = response.data;
  306 + this.open = true;
  307 + this.title = "修改优惠劵模板";
  308 + });
  309 + },
  310 + /** 提交按钮 */
  311 + submitForm() {
  312 + this.$refs["form"].validate(valid => {
  313 + if (!valid) {
  314 + return;
  315 + }
  316 + // 修改的提交
  317 + if (this.form.id != null) {
  318 + updateCouponTemplate(this.form).then(response => {
  319 + this.$modal.msgSuccess("修改成功");
  320 + this.open = false;
  321 + this.getList();
  322 + });
  323 + return;
  324 + }
  325 + // 添加的提交
  326 + createCouponTemplate(this.form).then(response => {
  327 + this.$modal.msgSuccess("新增成功");
  328 + this.open = false;
  329 + this.getList();
  330 + });
  331 + });
  332 + },
  333 + /** 删除按钮操作 */
  334 + handleDelete(row) {
  335 + const id = row.id;
  336 + this.$modal.confirm('是否确认删除优惠劵模板编号为"' + id + '"的数据项?').then(function() {
  337 + return deleteCouponTemplate(id);
  338 + }).then(() => {
  339 + this.getList();
  340 + this.$modal.msgSuccess("删除成功");
  341 + }).catch(() => {});
  342 + },
  343 + }
  344 +};
  345 +</script>
... ...