index.vue 7.61 KB
Newer Older
1 2
<template>
  <div class="app-container">
3 4 5 6 7 8 9 10 11 12 13 14 15
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
      <el-form-item label="渠道入口">
        <el-input placeholder="请输入渠道入口" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="优惠券">
        <el-select v-model="queryParams.couponId" placeholder="请选择优惠券" clearable @keyup.enter.native="handleQuery" filterable>
          <el-option
            v-for="item in couponList"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['coupon:category:query']">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>   

    <el-table v-loading="loading" :data="couponInfoList">     
34
      <el-table-column label="用户名" align="center">       
35
        <template slot-scope="scope">
36 37 38
          <a  myattr="mcv" v-hasPermi="['system:customer:view']">
            <span @click="getDetial(scope.row)" style="color: blue"> {{ scope.row.custName }}</span>
          </a>
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        </template>     
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="orderNo" />
      <el-table-column label="用户手机号" align="center" prop="custPhone" />
      <el-table-column label="领取优惠券名称" align="center" prop="couponName" />
      <el-table-column label="领取入口" align="center" prop="source"/>     
      <el-table-column label="触发事件" align="center" prop="typeDesc"/> 
      <el-table-column label="领取时间" align="center" prop="receiveTime"/> 
      <el-table-column label="优惠券适用时间" align="center" >
        <template slot-scope="scope">
          {{formateTime(scope.row.startTime)}}~{{formateTime(scope.row.expiredTime)}}
        </template>
      </el-table-column> 
      <el-table-column label="优惠券状态" align="center" prop="stateDesc"/> 
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
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

    <!-- 用户详情页 -->
    <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body>
      <div style="display: flex;align-items: center;">
        <div>
          <img v-bind:src="img" class="img-circle img-lg" />
        </div>
        <div style="margin-left: 20px;">
          <div style="margin-bottom: 20px;">
            <span>{{userName}}</span>
          </div>
          <div>
            <span>{{phoneNumber}}</span>
          </div>
        </div>
        <div style="margin-left: 50px;">
          <div style="margin-bottom: 20px;">共{{orderCount}}单,消费{{amount}}元</div>
          <div>地址</div>
        </div> 
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="正常订单" name="first">
          <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table>      
        </el-tab-pane>
        <el-tab-pane label="取消订单" name="second">
          <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table> 
        </el-tab-pane>
        <el-tab-pane label="退款订单" name="third">
         <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table>
        </el-tab-pane>
      </el-tabs>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
92 93 94 95 96
  </div>
</template>

<script>
import {getCouponInfoList} from "@/api/coupon/coupon";
97 98
import {getCustomer} from "@/api/system/customer";
import OrderTable from "../../customer/orderTable.vue";
99
import {listCoupon} from "@/api/coupon/coupon";
100
export default {
101 102
  components: { OrderTable },  
  data() { 
103
    return {
104
      img:"/static/img/profile.473f5971.jpg",
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      couponInfoList: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      options: [{
        value: null,
        label: '全部'
      },{
        value: '1',
123
        label: '有效'
124 125
      },{
        value: '2',
126 127 128 129
        label: '被使用'
      },{
        value: '3',
        label: '过期失效'
130
      }],
131 132 133 134 135 136 137 138 139 140 141
      activeName:"first" ,
      title: "",
      userName:"",
      phoneNumber:"",
      orderCount:"",
      amount:"",
      orderLoading: true,
      orderList:[],
      orderTotal:0,
      orderPageNum:1,
      orderPageSize: 10,
142 143
      customerId:null,
      couponList:[]
144 145 146 147
    };
  },
  created() {
    this.getList();
148
    this.getCouponList();
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
  },
  methods: {
    formateTime(val){
      let index =val.indexOf(":");
      val=val.substring(0, index-3);
      console.log("val",val);
      return val;
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      getCouponInfoList(this.queryParams).then((response) => {
        this.couponInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.name=null;
      this.queryParams.state=null;
      this.handleQuery();
    },
177 178
    getDetial(row){
      this.orderLoading=true;
179
      this.customerId=row.custId;
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
      this.userName=row.custName;
      this.phoneNumber=row.custPhone;
      this.amount=row.amount;
      this.orderCount=row.orderCount;
      this.open=true;
      this.title="用户信息";
      this.orderPageNum=1;
      this.pageSize=10;
      this.activeName="first";
      this.getOrderList(this.orderPageNum,this.pageSize,this.customerId,'1');
    },
    handleClick(){
      if(this.activeName=="first"){
        this.tag="1";
      }else if(this.activeName=="second"){
        this.tag="2";
      }else if(this.activeName=="third"){
        this.tag="3";
      }
      this.orderPageNum=1;
      this.pageSize=10;
      this.orderLoading=true;
      this.getOrderList(this.orderPageNum,this.pageSize,this.customerId,this.tag);
    },
    getOrderList(pageNum,pageSize,id,tag) {
      getCustomer({'id':id,'status':tag,'pageNum':pageNum,'pageSize':pageSize}).then((response) => {
        if(response.code=="200"){
          this.orderList = response.rows;
          this.orderTotal = response.total;
          this.orderLoading=false;
        }        
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
217 218 219 220 221 222 223 224
    /** 查询优惠券列表 */
    getCouponList() {      
      listCoupon({pageNum: 1,pageSize: 1000,state: 1}).then((response) => {
        if(response.code==200){
          this.couponList = response.rows;          
        }
      });
    }
225 226 227
  },
};
</script>