index.vue 12.4 KB
Newer Older
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
Marcus's avatar
Marcus committed
6 7
      <!-- <el-form-item :label="$t('标题')" prop="titleZh">
        <el-input v-model="queryParams.titleZh" :placeholder="$t('请输入标题')" clearable @keyup.enter.native="handleQuery"/>
dragondean@qq.com's avatar
dragondean@qq.com committed
8
      </el-form-item> -->
Marcus's avatar
Marcus committed
9 10
      <!-- <el-form-item :label="$t('标题')" prop="titleEn">
        <el-input v-model="queryParams.titleEn" :placeholder="$t('请输入标题')" clearable @keyup.enter.native="handleQuery"/>
11
      </el-form-item> -->
Marcus's avatar
Marcus committed
12
      <el-form-item :label="$t('类型')" prop="type">
dragondean@qq.com's avatar
dragondean@qq.com committed
13
        <dict-selector :type='DICT_TYPE.ECW_COUPON_TYPE' v-model="queryParams.type" clearable />
14
      </el-form-item>
Marcus's avatar
Marcus committed
15
      <el-form-item :label="$t('状态')" prop="status" clearable>
dragondean@qq.com's avatar
dragondean@qq.com committed
16
        <!-- <dict-selector :type="DICT_TYPE.ECW_COUPON_STATUS" v-model="queryParams.status"/> -->
Marcus's avatar
Marcus committed
17 18 19 20
        <el-select v-model="queryParams.status" :placeholder="$t('请选择')" clearable size="small">
          <el-option :label="$t('草稿')" value="0" />
          <el-option :label="$t('已发布')" value="1" />
          <el-option :label="$t('已过期')" value="2" />
dragondean@qq.com's avatar
dragondean@qq.com committed
21
        </el-select>
dragondean@qq.com's avatar
dragondean@qq.com committed
22
      </el-form-item>
23
      <el-form-item :label="$t('关键字')" prop="searchKey">
Marcus's avatar
Marcus committed
24
        <el-input v-model="queryParams.searchKey" :placeholder="$t('请输入关键字')" clearable @keyup.enter.native="handleQuery"/>
dragondean@qq.com's avatar
dragondean@qq.com committed
25
      </el-form-item>
26
      <el-form-item>
Marcus's avatar
Marcus committed
27 28
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button>
29 30 31 32 33 34 35
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
Marcus's avatar
Marcus committed
36
                   v-hasPermi="['ecw:coupon:create']">{{ $t('新增') }}</el-button>
37 38 39
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
Marcus's avatar
Marcus committed
40
                   v-hasPermi="['ecw:coupon:export']">{{ $t('导出') }}</el-button>
41 42 43 44 45
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
46
    <el-table v-loading="loading" :data="list" border>
dragondean@qq.com's avatar
dragondean@qq.com committed
47
      <el-table-column :label="$t('优惠券ID')" align="center" prop="couponId" />
Marcus's avatar
Marcus committed
48
      <el-table-column :label="$t('类型')" align="center" prop="type">
49
        <template slot-scope="{row}">
50
          <dict-tag :type="DICT_TYPE.ECW_COUPON_TYPE" :value="row.type" />
51 52
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
53 54
      <el-table-column :label="$t('标题')" align="center" prop="titleZh" />
      <!-- <el-table-column :label="$t('描述')" align="center" prop="type">
dragondean@qq.com's avatar
dragondean@qq.com committed
55 56 57
        <template slot-scope="{row}">
          {{$l(row, 'content')}}
        </template>
dragondean@qq.com's avatar
dragondean@qq.com committed
58
      </el-table-column> -->
dragondean@qq.com's avatar
dragondean@qq.com committed
59
      <el-table-column :label="$t('发布人') + '/' + $t('发布时间')" align="center" prop="startTime" width="180">
60 61
        <template slot-scope="scope">
          <div>{{ scope.row.creatorName }}</div>
dragondean@qq.com's avatar
dragondean@qq.com committed
62
          <div>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</div>
63 64
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
65
      <el-table-column :label="$t('开始时间')" align="center" prop="startTime" width="180">
66
        <template slot-scope="scope">
dragondean@qq.com's avatar
dragondean@qq.com committed
67
          <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
68 69
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
70
      <el-table-column :label="$t('结束时间')" align="center" prop="endTime" width="180">
dragondean@qq.com's avatar
dragondean@qq.com committed
71
        <template slot-scope="{row}">
dragondean@qq.com's avatar
dragondean@qq.com committed
72
          <div :style="{red: row.overdueStatus == 0 ? 'red' : null}">{{ parseTime(row.endTime, '{y}-{m}-{d}') }}</div>
Marcus's avatar
Marcus committed
73
          <div v-if="row.overdueStatus == 0" style="color: red">{{ $t('已过期') }}</div>
74 75
        </template>
      </el-table-column>
dragondean@qq.com's avatar
dragondean@qq.com committed
76
      <!-- 
Marcus's avatar
Marcus committed
77
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
78 79 80
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
dragondean@qq.com's avatar
dragondean@qq.com committed
81
      </el-table-column-->
82 83 84 85 86 87
      <el-table-column :label="$t('更新人') + '/' + $t('更新时间')" align="center" width="180">
        <template slot-scope="scope">
          <div>{{ scope.row.updaterName }}</div>
          <div>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</div>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
88
      <el-table-column :label="$t('状态')" align="center" prop="createTime" width="180">
dragondean@qq.com's avatar
dragondean@qq.com committed
89 90 91
        <template slot-scope="{row}">
          <dict-tag :type="DICT_TYPE.ECW_IS_DRAFT" :value="row.status" />
        </template>
dragondean@qq.com's avatar
dragondean@qq.com committed
92
      </el-table-column>
Marcus's avatar
Marcus committed
93
      <el-table-column :label="$t('操作')" align="center" fixed="right" class-name="small-padding fixed-width">
94
        <template slot-scope="scope">
95
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row, true)"
96
                     v-hasPermi="['ecw:coupon:show']">{{ $t('查看') }}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
97
          <el-button v-if="scope.row.status != 1" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
Marcus's avatar
Marcus committed
98
                     v-hasPermi="['ecw:coupon:update']">{{ $t('编辑') }}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
99
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleCopy(scope.row)"
100
                     v-hasPermi="['ecw:coupon:copy']">{{ $t('复制') }}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
101
          <el-button size="mini" type="text" icon="el-icon-edit" @click="updateEndtimeItem = scope.row" v-if="scope.row.endTime && scope.row.status"
102
                     v-hasPermi="['ecw:coupon:delay']">{{ $t('延期') }}</el-button>
103
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
Marcus's avatar
Marcus committed
104
                     v-hasPermi="['ecw:coupon:delete']">{{ $t('删除') }}</el-button>
105 106 107 108 109 110
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
111 112 113 114
    
    <el-dialog :title="$t('延期活动时间')" :visible="!!updateEndtimeItem" :before-close="() => updateEndtimeItem=null">
      <div v-if="updateEndtimeItem">
        {{$t('优惠活动“{name}”的当前结束时间:{time}',{
dragondean@qq.com's avatar
dragondean@qq.com committed
115
          name: $l(updateEndtimeItem, 'title'),
116 117 118 119 120 121
          time: updateEndtimeItem.endTime || $t('永久有效')
          })}}
      </div>
      <div>{{$t('请问您确定延长活动吗?')}}</div>
      <el-form :model="updateEndtimeForm" :rules="updateEndtimeRules" label-position="left" >
        <el-form-item :label="$t('活动结束时间')" prop="endTime">
dragondean@qq.com's avatar
dragondean@qq.com committed
122
          <el-date-picker v-if="!updateEndtimeForm.forever" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" v-model="updateEndtimeForm.endTime" placeholder=""></el-date-picker>
123 124 125 126 127 128 129 130
          <el-checkbox :label="$t('永久有效')" v-model="updateEndtimeForm.forever" class="ml-10"></el-checkbox>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="updateEndtime">{{$t('确定')}}</el-button>
        <el-button type="default" @click="updateEndtimeItem = null">{{$t('取消')}}</el-button>
      </div>
    </el-dialog>
131 132 133 134 135

  </div>
</template>

<script>
136
import { createCoupon, updateCoupon, deleteCoupon, getCoupon, getCouponPage, exportCouponExcel, updateEndtime } from "@/api/ecw/coupon";
137 138

export default {
139
  name: "EcwCouponIndex",
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 优惠券信息列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeStartTime: [],
      dateRangeEndTime: [],
      dateRangeCreateTime: null,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        titleZh: null,
        titleEn: null,
        type: null,
        cashCondition: null,
        reduceAmount: null,
        conditionCurrencyId: null,
        reduceCurrencyId: null,
        afterReceiveDays: null,
        validDays: null,
        costType: null,
        discountDetailed: null,
        isSimilarSuperposition: null,
        couponIds: null,
        suitableUserType: null,
        suitableLineType: null,
        suitableProdType: null,
        limitNum: null,
        overdueStatus: null,
        putonStatus: null,
        getWay: null,
        orderAttr: null,
        isSiteContent: null,
        isCargoControl: null,
        documentDeclaration: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
195 196 197
      },
      updateEndtimeItem: null, // 延期操作的数据
      updateEndtimeForm:{} // 延长有效期的表单数据
198 199
    };
  },
200 201 202 203 204 205 206 207 208
  computed:{
    updateEndtimeRules(){
      return {
        endTime: [
          {required: !this.updateEndtimeForm.forever, message: "请填写结束时间"}
        ]
      }
    }
  },
dragondean@qq.com's avatar
dragondean@qq.com committed
209 210 211 212 213
  watch:{
    updateEndtimeItem(){
      this.updateEndtimeForm = {}
    }
  },
214 215 216
  created() {
    this.getList();
  },
217 218 219
  activated(){
    this.getList()
  },
220 221 222 223 224 225
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
dragondean@qq.com's avatar
dragondean@qq.com committed
226 227 228 229
      if(params.status == 2){
        params.overdueStatus=0
        params.status = null
      }
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
      this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
      this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getCouponPage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeStartTime = [];
      this.dateRangeEndTime = [];
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      return this.$router.push('edit')
    },
    /** 修改按钮操作 */
258
    handleUpdate(row, readonly) {
259
      const couponId = row.couponId;
260 261 262 263 264
      let url = 'edit?id=' + couponId
      if(readonly){
        url += '&readonly=1'
      }
      return this.$router.push(url)
265
    },
266 267 268
    handleDetail(row){
      this.$router.push('detail?id=' + row.couponId + '&readonly=1')
    },
dragondean@qq.com's avatar
dragondean@qq.com committed
269 270
    handleCopy(row){
      this.$router.push('edit?action=copy&id=' + row.couponId)
271 272 273 274
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const couponId = row.couponId;
dragondean@qq.com's avatar
dragondean@qq.com committed
275
      this.$confirm(this.$t('是否确认删除优惠券信息编号为{couponId}的数据项?', {couponId})).then(function() {
276 277 278
          return deleteCoupon(couponId);
        }).then(() => {
          this.getList();
dragondean@qq.com's avatar
dragondean@qq.com committed
279
          this.$message.success(this.$t("删除成功"));
280 281
        }).catch(() => {});
    },
282 283 284 285 286 287 288 289 290 291
    // 延期
    updateEndtime(){
      if(!this.updateEndtimeForm.forever && !this.updateEndtimeForm.endTime){
        return this.$message.error(this.$t("请填写结束时间"))
      }
      let form = {couponId: this.updateEndtimeItem.couponId, ...this.updateEndtimeForm}
      form.isValidity = !form.forever // 是否设置有效期
      updateEndtime(form).then(res => {
        this.getList()
        this.updateEndtimeItem = null
292
        this.$message.success(this.$t('操作成功'))
293 294
      })
    },
295 296 297 298 299 300 301 302 303 304
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
      this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
dragondean@qq.com's avatar
dragondean@qq.com committed
305
      this.$confirm(this.$t('是否确认导出所有优惠券信息数据项?')).then(() => {
306 307 308 309 310 311 312 313 314 315
          this.exportLoading = true;
          return exportCouponExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>