index.vue 8.04 KB
Newer Older
lixiaomin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24" :xs="24">
        <el-form :model="queryParams"  :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="用户信息" prop="userInfo">
          <el-input v-model="queryParams.userInfo" placeholder="请输入姓名、手机号" clearable style="width: 240px" @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="注册时间" >
          <el-date-picker v-model="createdTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" style="width:230px"></el-date-picker>        
        </el-form-item> 
        <el-form-item label="购买记录" >
          <el-select v-model="queryParams.buyRecords" placeholder="请选择">
            <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
23
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['system:customer:query']">搜索</el-button>
lixiaomin committed
24 25 26 27 28
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>            
        </el-form-item>
        </el-form>       

        <el-table v-loading="loading" :data="customerList"> 
lixiaomin committed
29 30 31 32 33 34
          <el-table-column label="用户" align="center"  prop="userName" >
            <template slot-scope="scope">
              <a  myattr="mcv" v-hasPermi="['system:customer:view']">
                <span @click="getDetial(scope.row)" style="color: blue"> {{ scope.row.userName }}</span>
              </a>              
            </template>
lixiaomin committed
35 36 37 38 39 40 41 42 43 44
          </el-table-column>
          <el-table-column label="手机号" align="center" prop="phoneNumber"/>
          <el-table-column label="订单量" align="center" prop="orderCount"/>
          <el-table-column label="总金额" align="center" prop="amount"/>
          <el-table-column label="已取消" align="center" prop="cancelCount"/>
          <el-table-column label="取消金额" align="center" prop="cancelAmount"/>
          <el-table-column label="已退款" align="center" prop="refundCount"/>
          <el-table-column label="退款金额" align="center"  prop="refundAmount"/>   
          <el-table-column label="最近订单时间" align="center"  prop="lastOrderDate"/> 
          <el-table-column label="注册时间" align="center"  prop="createDate"/>      
lixiaomin committed
45 46 47 48 49 50
          <el-table-column label="来源" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.source=='3'">小程序</span>
              <span v-if="scope.row.source=='12'">点单屏</span>
            </template>
          </el-table-column>
lixiaomin committed
51 52 53 54 55 56 57 58 59 60
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
61
    <!-- 用户详情页 -->
lixiaomin committed
62
    <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body>
lixiaomin committed
63 64 65 66 67 68
      <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;">
lixiaomin committed
69
            <span>{{userName}}</span>
lixiaomin committed
70 71
          </div>
          <div>
lixiaomin committed
72
            <span>{{phoneNumber}}</span>
lixiaomin committed
73 74 75
          </div>
        </div>
        <div style="margin-left: 50px;">
lixiaomin committed
76
          <div style="margin-bottom: 20px;">共{{orderCount}}单,消费{{amount}}元</div>
lixiaomin committed
77
          <div>地址</div>
lixiaomin committed
78
        </div> 
lixiaomin committed
79 80 81
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="正常订单" name="first">
lixiaomin committed
82
          <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table>      
lixiaomin committed
83 84
        </el-tab-pane>
        <el-tab-pane label="取消订单" name="second">
lixiaomin committed
85
          <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table> 
lixiaomin committed
86 87
        </el-tab-pane>
        <el-tab-pane label="退款订单" name="third">
lixiaomin committed
88
         <order-table :orderList="orderList" :orderTotal="orderTotal" :orderLoading="orderLoading" @getOrderList="getOrderList"></order-table>
lixiaomin committed
89 90 91 92 93 94 95 96 97 98 99 100
        </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>
  </div>
</template>

<script>
import {listCustomer,getCustomer} from "@/api/system/customer";
lixiaomin committed
101
import OrderTable from "./orderTable.vue";
lixiaomin committed
102 103
export default {
  name: "Customer",  
lixiaomin committed
104
  components: { OrderTable },  
lixiaomin committed
105 106 107 108 109
  data() {
    return {
      img:"/static/img/profile.473f5971.jpg",
      createdTime:[],
      // 遮罩层
lixiaomin committed
110
      loading: true,  
lixiaomin committed
111 112 113 114 115 116 117 118 119
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 人员表格数据
      customerList: null,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
lixiaomin committed
120
      open: false,      
lixiaomin committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userInfo:null,
        createAtStart: null,
        createAtEnd: null,
        buyRecords: null
      },
      options:[
        {value:"",label:"全部"},
        {value:"1",label:"有购买"},
        {value:"2",label:"无购买"},
        {value:"3",label:"有复购"},
      ],
lixiaomin committed
136 137 138
      activeName:"first" ,
      customerId:null,
      orderList:[],
lixiaomin committed
139 140 141 142 143 144 145 146 147
      orderTotal:0,
      tag:"",
      orderPageNum:1,
      orderPageSize: 10,
      userName:"",
      phoneNumber:"",
      orderCount:"",
      amount:"",
      orderLoading: true,
lixiaomin committed
148 149 150 151
      
    };
  },
  created() {
lixiaomin committed
152
    this.getList();   
lixiaomin committed
153 154 155
  },
  methods: {
    handleClick(){
lixiaomin committed
156
      if(this.activeName=="first"){
lixiaomin committed
157
        this.tag="1";
lixiaomin committed
158
      }else if(this.activeName=="second"){
lixiaomin committed
159
        this.tag="2";
lixiaomin committed
160
      }else if(this.activeName=="third"){
lixiaomin committed
161
        this.tag="3";
lixiaomin committed
162
      }
lixiaomin committed
163 164 165 166 167 168 169 170 171 172 173 174 175
      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;
        }        
      });
lixiaomin committed
176 177 178 179 180 181 182 183 184 185 186 187
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listCustomer(this.queryParams).then((response) => {
        if(response.code=="200"){
          this.customerList = response.rows;
          this.total = response.total;
          this.loading = false;
        }        
      });
    },
lixiaomin committed
188 189 190 191 192 193 194
    getDetial(row){
      this.orderLoading=true;
      this.customerId=row.id;
      this.userName=row.userName;
      this.phoneNumber=row.phoneNumber;
      this.amount=row.amount;
      this.orderCount=row.orderCount;
lixiaomin committed
195 196
      this.open=true;
      this.title="用户信息";
lixiaomin committed
197 198 199 200
      this.orderPageNum=1;
      this.pageSize=10;
      this.activeName="first";
      this.getOrderList(this.orderPageNum,this.pageSize,this.customerId,'1');
lixiaomin committed
201 202 203 204 205 206 207
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
    /** 搜索按钮操作 */
    handleQuery() {
lixiaomin committed
208 209 210
      this.queryParams.createAtStart=null;
      this.queryParams.createAtEnd=null;
      if(this.createdTime!=null && this.createdTime.length>0){
lixiaomin committed
211 212 213
        this.queryParams.createAtStart=this.createdTime[0];
        this.queryParams.createAtEnd=this.createdTime[1];
      }
lixiaomin committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.userInfo=null;
      this.queryParams.buyRecords=null;
      this.createdTime=[];
      this.handleQuery();
    },


    
  },
};
</script>