
<template>
  <div class="usersList">
    <div class="head-title">
        用户购买记录
        <el-button @click="dialogVisible=true" style="float:right;margin-top: -5px;" size="small" type="primary">批量导出</el-button>
    </div>
    <div class="content">
        <div>
            <el-date-picker
            size="small"
            v-model="dateList"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
            </el-date-picker>
            <div style="margin-left:20px" class="searchInput">
                <el-input style="display:inline-block;width:225px;height:30px"
                placeholder="请输入内容"
                v-model="msg.UserName"
                size="small"
                @clear="getList"
                clearable>
                </el-input>
                <span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
            </div>
        </div>
        <el-table v-loading="loading"
            :data="tableData"
            border
            style="width: 100%;margin:20px 0">
            <el-table-column
            prop="OrderId"
            width="80"
            label="ID">
            </el-table-column>
            <el-table-column
            prop="OrderNo"
            width="280"
            label="订单号">
            </el-table-column>
            <el-table-column
            prop="UserName"
            label="昵称">
            </el-table-column>
            <el-table-column
            prop="Income"
            label="支付金额">
            </el-table-column>
            <el-table-column
            prop="name"
            label="购买情况">
                <template slot-scope="scope">
                    <p>支付方式：{{scope.row.PaymentWayName}}</p>
                    <p>订单状态：{{scope.row.OrderStatusName}}</p>
                </template>
            </el-table-column>
            <el-table-column
            prop="PaymentTime"
            label="支付时间">
            </el-table-column>
            
        </el-table>
        <el-pagination style="text-align:right"
        background
        @current-change="handleCurrentChange"
        :page-size="msg.pageSize"
        layout="prev, pager, next"
        :total="total">
        </el-pagination>
    </div>
    <!-- 选择导出信息 -->
    <el-dialog
        title="选择导出信息"
        :visible.sync="dialogVisible"
        width="960px">
        <el-form style="border: 1px solid #F0F2F7;" :model="addMsg" ref="addMsg" label-width="100px">
            <div style="box-sizing: border-box;background-color: #F3F5F6;width: 100%;padding-left: 20px;height: 50px;line-height: 50px;">
                <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
            </div>
            <div style="margin: 15px 0;"></div>
            <div style="padding: 10px 25px 20px;">
                <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
                    <el-checkbox style="margin-bottom:10px" v-for="city in cities" :label="city.Id" :key="city.Id">{{city.Name}}</el-checkbox>
                </el-checkbox-group>
            </div>
            
        </el-form> 
        <div style="text-align:right;margin-top:20px">
            <el-button size="small" type="primary" @click="Export">导出</el-button>
        </div>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        loading:false,
        checkAll: false,
        checkedCities: [],
        cities: [],
        cityOptions: [],
        isIndeterminate: true,
        addMsg:{},
        dialogVisible:false,
        value:'',
        options:[],
        tableData:[],
        msg:{
            pageIndex:1,
            pageSize:15,
            OrderId:0,
            OrderNo:'',
            UserName:'',
            StartTime:'',
            EndTime:'',
        },
        total:0,
        dateList:[],

        
      };
    },
    created() {
        this.getDown();
        this.getList();
    },
    methods: {
        Export(){
            this.msg.ExcelEnumIds=this.checkedCities;
            let msg = JSON.parse(JSON.stringify(this.msg));
            this.JavaGetLocalFile(
            "/api/order/GetMembersToBuyToExcel",
            msg,
            "会员购买列表.xls"
            );
        },
        getDown(){
            this.cityOptions=[];
            this.apipost("/api/order/GetMembersToBuyExportEnumList",{}, res => {
                this.cities=res.data.data;
                let data=res.data.data;
                data.forEach(item=>{
                    this.cityOptions.push(item.Id)
                })
                
            })
        },
        handleCheckAllChange(val) {
            this.checkedCities = val ? this.cityOptions : [];
            this.isIndeterminate = false;
        },
        handleCheckedCitiesChange(value) {
            let checkedCount = value.length;
            this.checkAll = checkedCount === this.cities.length;
            this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
        },
        handleCurrentChange(val) {
            this.msg.pageIndex = val;
            this.getList();
        },
        getList(){
            this.loading=true;
            
            if(this.dateList && this.dateList.length>0){
                this.msg.StartTime=this.dateList[0];
                this.msg.EndTime=this.dateList[1];
            }else{
                this.msg.StartTime='';
                this.msg.EndTime='';
            }
            this.loading=true;
            this.apipost("/api/order/GetMembersToBuyPageList", this.msg, res => {
                this.loading=false;
                if(res.data.resultCode==1){
                    this.total=res.data.data.count;
                    let pageData=res.data.data.pageData;
                    this.tableData=pageData;
                }
                
            })
        },

    },
    mounted() {
      
    }
  };

</script>
<style>
.usersList .blue{
    color:#409EFF;
    
}
.usersList .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
}
.usersList .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
}
.usersList .content .searchInput{
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
    margin-right: 20px;
}
.usersList .content{
    background: #fff;
    margin-top:10px;
    padding: 20px;
    box-sizing: border-box;
}

</style>
