index.vue 8.04 KB
Newer Older
1 2
<template>
  <div class="app-container">
3 4
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
      <el-form-item label="渠道入口">
lixiaomin committed
5
        <el-input v-model="queryParams.source" placeholder="请输入渠道入口" clearable @keyup.enter.native="handleQuery" />
6 7 8 9 10 11 12 13 14 15
      </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
      </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>
lixiaomin committed
28
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['coupon:user:list']">搜索</el-button>
29 30 31 32 33
        <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
  </div>
</template>

<script>
96
import {listCoupon,getCouponInfoList,getCusOrderNum} from "@/api/coupon/coupon";
97 98
import {getCustomer} from "@/api/system/customer";
import OrderTable from "../../customer/orderTable.vue";
99
export default {
100 101
  components: { OrderTable },  
  data() { 
102
    return {
103
      img:"/static/img/profile.473f5971.jpg",
104 105 106 107 108 109 110 111 112 113 114 115
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      couponInfoList: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
lixiaomin committed
116 117 118
        source:"",
        state:null,
        couponId:null
119 120 121 122 123
      },
      options: [{
        value: null,
        label: '全部'
      },{
124
        value: '0',
125
        label: '有效'
126
      },{
127 128
        value: '1',
        label: '已使用'
129
      },{
130 131
        value: '2',
        label: '已失效'
132
      }],
133 134 135 136 137 138 139 140 141 142 143
      activeName:"first" ,
      title: "",
      userName:"",
      phoneNumber:"",
      orderCount:"",
      amount:"",
      orderLoading: true,
      orderList:[],
      orderTotal:0,
      orderPageNum:1,
      orderPageSize: 10,
144 145
      customerId:null,
      couponList:[]
146 147 148 149
    };
  },
  created() {
    this.getList();
150
    this.getCouponList();
151 152 153 154 155 156 157 158 159 160
  },
  methods: {
    formateTime(val){
      let index =val.indexOf(":");
      val=val.substring(0, index-3);
      return val;
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
lixiaomin committed
161 162
      getCouponInfoList(this.queryParams.pageNum,this.queryParams.pageSize,
      {source:this.queryParams.source,state:this.queryParams.state,couponId:this.queryParams.couponId}).then((response) => {
163 164 165 166 167 168 169 170 171 172 173 174
        this.couponInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
175 176
      this.queryParams.source=null;
      this.queryParams.couponId=null;
177 178 179
      this.queryParams.state=null;
      this.handleQuery();
    },
180 181
    getDetial(row){
      this.orderLoading=true;
182
      this.customerId=row.custId;
183 184 185 186 187 188 189
      this.userName=row.custName;
      this.phoneNumber=row.custPhone;
      this.open=true;
      this.title="用户信息";
      this.orderPageNum=1;
      this.pageSize=10;
      this.activeName="first";
190
      this.getCusOrderNum(row.custId);
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
      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;
    },
219 220
    /** 查询优惠券列表 */
    getCouponList() {      
lixiaomin committed
221
      listCoupon(1,10000,{state: 1}).then((response) => {
222 223 224 225
        if(response.code==200){
          this.couponList = response.rows;          
        }
      });
226 227 228 229 230 231 232 233 234
    },
    //获取用户总订单量、总金额
    getCusOrderNum(custId){
      getCusOrderNum(custId).then((response) => {
        if(response.code==200){
          this.amount=response.data.orderAmount;
          this.orderCount=response.data.orderCount;
        }
      });
235
    }
236 237 238
  },
};
</script>