index.vue 16.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标题" prop="titleZh">
        <el-input v-model="queryParams.titleZh" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <!-- <el-form-item label="标题" prop="titleEn">
        <el-input v-model="queryParams.titleEn" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="类型" prop="type">
        <!-- 1:优惠卷 2:金额-满减 3:方数-满减 4 折扣 5优惠 6 特价 7区间价-->
        <!-- <el-select v-model="queryParams.type" placeholder="请选择类型 1:优惠卷 2:金额-满减 3:方数-满减 4 折扣 5优惠 6 特价 7区间价" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select> -->
        <dict-selector :type='DICT_TYPE.ECW_COUPON_TYPE' v-model="queryParams.type" />
      </el-form-item>
      <!-- <el-form-item label="使用条件(优惠卷专用)" prop="cashCondition">
        <el-input v-model="queryParams.cashCondition" placeholder="请输入使用条件(优惠卷专用)" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="减免金额(优惠卷专用)" prop="reduceAmount">
        <el-input v-model="queryParams.reduceAmount" placeholder="请输入减免金额(优惠卷专用)" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="条件货币ID" prop="conditionCurrencyId">
        <el-input v-model="queryParams.conditionCurrencyId" placeholder="请输入条件货币ID" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="开始时间">
        <el-date-picker v-model="dateRangeStartTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
      <!-- <el-form-item label="减免货币ID" prop="reduceCurrencyId">
        <el-input v-model="queryParams.reduceCurrencyId" placeholder="请输入减免货币ID" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="结束时间">
        <el-date-picker v-model="dateRangeEndTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
      <!-- <el-form-item label="领券后X天起生效" prop="afterReceiveDays">
        <el-input v-model="queryParams.afterReceiveDays" placeholder="请输入领券后X天起生效" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="有效天数" prop="validDays">
        <el-input v-model="queryParams.validDays" placeholder="请输入有效天数" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="费用类型" prop="costType">
        <dict-selector :type="DICT_TYPE.ECW_COUPON_COST_TYPE" v-model="queryParams.costType"/>
      </el-form-item>
      <!-- <el-form-item label="优惠清单" prop="discountDetailed">
        <el-input v-model="queryParams.discountDetailed" placeholder="请输入优惠清单" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="同类优惠劵是否可以叠加 0否  1是" prop="isSimilarSuperposition">
        <el-select v-model="queryParams.isSimilarSuperposition" placeholder="请选择同类优惠劵是否可以叠加 0否  1是" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="可叠加优惠劵列表" prop="couponIds">
        <el-input v-model="queryParams.couponIds" placeholder="请输入可叠加优惠劵列表" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="适用用户类型 0全部用户 1部分用户 2指定用户不参与" prop="suitableUserType">
        <el-select v-model="queryParams.suitableUserType" placeholder="请选择适用用户类型 0全部用户 1部分用户 2指定用户不参与" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="适用线路类型 0全部线路参与 1指定线路参与 2指定线路不参与" prop="suitableLineType">
        <el-select v-model="queryParams.suitableLineType" placeholder="请选择适用线路类型 0全部线路参与 1指定线路参与 2指定线路不参与" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="适用产品类型 0全部产品参与 1指定产品参与 2指定产品不参与" prop="suitableProdType">
        <el-select v-model="queryParams.suitableProdType" placeholder="请选择适用产品类型 0全部产品参与 1指定产品参与 2指定产品不参与" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="每个用户领券上限,如不填则默认为1" prop="limitNum">
        <el-input v-model="queryParams.limitNum" placeholder="请输入每个用户领券上限,如不填则默认为1" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="过期状态" prop="overdueStatus">
        <dict-selector :type="DICT_TYPE.ECW_COUPON_OVERDUE_STATUS" v-model="queryParams.overdueStatus"/>
      </el-form-item>
      <el-form-item label="投放状态" prop="putonStatus">
        <dict-selector :type="DICT_TYPE.ECW_COUPON_PUTON_STATUS" v-model="queryParams.putonStatus"/>
      </el-form-item>
      <!-- <el-form-item label="获取方式 0=客户领取 1=平台发放" prop="getWay">
        <el-input v-model="queryParams.getWay" placeholder="请输入获取方式 0=客户领取 1=平台发放" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="订单属性(可多选) 1 普货 2重货 3泡货" prop="orderAttr">
        <el-input v-model="queryParams.orderAttr" placeholder="请输入订单属性(可多选) 1 普货 2重货 3泡货" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="是否发送站内信 0否  1是" prop="isSiteContent">
        <el-select v-model="queryParams.isSiteContent" placeholder="请选择是否发送站内信 0否  1是" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否控货(可多选) 0否 1是" prop="isCargoControl">
        <el-input v-model="queryParams.isCargoControl" placeholder="请输入是否控货(可多选) 0否 1是" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="单证报关(可多选) 1 我司全代 2自单代报 3混合报关" prop="documentDeclaration">
        <el-input v-model="queryParams.documentDeclaration" placeholder="请输入单证报关(可多选) 1 我司全代 2自单代报 3混合报关" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item> -->
      <el-form-item label="状态" prop="status">
        <dict-selector :type="DICT_TYPE.ECW_COUPON_STATUS" v-model="queryParams.status"/>
      </el-form-item>
      <!-- <el-form-item label="创建时间">
        <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </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"
                   v-hasPermi="['ecw:coupon:create']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['ecw:coupon:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
      <el-table-column label="优惠券ID" align="center" prop="couponId" />
      <el-table-column label="类型" align="center" prop="type">
        <template slot-scope="{row}">
131
          <dict-tag :type="DICT_TYPE.ECW_COUPON_TYPE" :value="row.type" />
132 133 134
        </template>
      </el-table-column>
      <el-table-column label="标题" align="center" prop="titleZh" />
135 136 137 138 139 140
      <el-table-column label="发布人/发布时间" align="center" prop="startTime" width="180">
        <template slot-scope="scope">
          <div>{{ scope.row.creatorName }}</div>
          <div>{{ parseTime(scope.row.createTime) }}</div>
        </template>
      </el-table-column>
141 142 143 144 145 146 147 148 149 150
      <el-table-column label="开始时间" align="center" prop="startTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="endTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime) }}</span>
        </template>
      </el-table-column>
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['ecw:coupon:update']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['ecw:coupon:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

  </div>
</template>

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

export default {
  name: "Coupon",
  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: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      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;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        couponId: undefined,
        titleZh: undefined,
        titleEn: undefined,
        type: undefined,
        cashCondition: undefined,
        reduceAmount: undefined,
        conditionCurrencyId: undefined,
        startTime: undefined,
        reduceCurrencyId: undefined,
        endTime: undefined,
        afterReceiveDays: undefined,
        validDays: undefined,
        costType: undefined,
        discountDetailed: undefined,
        isSimilarSuperposition: undefined,
        couponIds: undefined,
        suitableUserType: undefined,
        suitableLineType: undefined,
        suitableProdType: undefined,
        limitNum: undefined,
        overdueStatus: undefined,
        putonStatus: undefined,
        getWay: undefined,
        orderAttr: undefined,
        isSiteContent: undefined,
        isCargoControl: undefined,
        documentDeclaration: undefined,
        status: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    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')
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      const couponId = row.couponId;
      return this.$router.push('edit?id=' + couponId)
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.couponId != null) {
          updateCoupon(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createCoupon(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const couponId = row.couponId;
      this.$modal.confirm('是否确认删除优惠券信息编号为"' + couponId + '"的数据项?').then(function() {
          return deleteCoupon(couponId);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    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');
      // 执行导出
      this.$modal.confirm('是否确认导出所有优惠券信息数据项?').then(() => {
          this.exportLoading = true;
          return exportCouponExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>