
<template>
  <div class="disWithdrawal distributors">
    <div class="content">
        <div style="background:#fff;padding:0 20px;position:relative">
            <el-button @click="dialogVisible=true" class="pldc" size="small" type="primary">批量导出</el-button>
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="全部" name="first" :dataId="0"></el-tab-pane>
                <el-tab-pane v-for="(item,index) in AuditStatusList" :dataId="item.Id" :key="index" :label="item.Name" :name="item.Name"></el-tab-pane>
            </el-tabs>
        </div>
        <div style="margin-top:20px;padding:20px;background:#fff;">
            <el-table
                class="table_samll WithTable"
                :data="tableData"
                v-loading="loading"
                border
                style="width: 100%;margin:0 0 20px 0">
                <el-table-column
                prop="address"
                label="基本信息">
                    <template slot-scope="scope">
                        <div class="app-image" :style="{backgroundImage:'url(' + scope.row.Photo + ')',backgroundSize:'cover'}"></div> 
                        <div flex="dir:left cross:center">
                            {{scope.row.UserName}}
                        </div> 
                        <img v-if="scope.row.Source==1" style="width:24px;height:24px" src="../../assets/img/userman/wx.png" alt="" class="platform-img">
                    </template>  
                </el-table-column>
                <el-table-column
                prop="Moblie"
                label="账户信息">
                    <template slot-scope="scope">
                        <span>提现方式：{{scope.row.WithdrawalWayName}}</span>
                    </template>  
                </el-table-column>
                <el-table-column
                prop="Moblie"
                label="提现信息">
                    <template slot-scope="scope">
                        <p>用户申请提现金额:{{scope.row.AppliedMoney}}元</p>
                        <p>手续费:{{scope.row.Fee}}元</p>
                        <p>实际打款金额:<span class="cred">{{scope.row.RemitMoney}}</span>元</p>
                    </template>  
                </el-table-column>
                <el-table-column
                prop="AuditStatusName"
                label="状态">
                </el-table-column>
                <el-table-column
                prop="name"
                label="时间">
                    <template slot-scope="scope">
                        <p v-if="scope.row.CreateDate && scope.row.CreateDate!=''">申请时间:{{scope.row.CreateDate}}</p>
                        <p v-if="scope.row.AuditDate && scope.row.AuditDate!=''">审核时间:{{scope.row.AuditDate}}</p>
                    </template>
                </el-table-column>
                <el-table-column
                prop="AuditRemark"
                label="备注">
                    <template slot-scope="scope">
                        <p v-if="scope.row.AuditRemark && scope.row.AuditRemark!=''">审核备注:{{scope.row.AuditRemark}}</p>
                        <p v-if="scope.row.RemitRemark && scope.row.RemitRemark!=''">打款备注:{{scope.row.RemitRemark}}</p>
                        
                    </template>
                </el-table-column>
                <el-table-column
                prop="address"
                width="200"
                label="操作">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="dark" content="打款" placement="top-start">
                        <img v-if="scope.row.AuditStatus==2" @click="openReason(2,scope.row)" style="width:32px;height:32px" src="../../assets/img/userman/pay.png" alt="">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="同意" placement="top-start">
                        <img v-if="scope.row.AuditStatus==1" @click="openReason(1,scope.row)" style="width:32px;height:32px" src="../../assets/img/userman/pass.png" alt="">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="拒绝" placement="top-start">
                        <img v-if="scope.row.AuditStatus==1" @click="openReason(3,scope.row)" style="width:32px;height:32px" src="../../assets/img/userman/nopass.png" alt="">
                    </el-tooltip>
                </template>    
                </el-table-column>
            </el-table>
        </div>
        
        <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.Name">{{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>
    <!-- 审批同意或拒绝单个修改等级 -->
    <el-dialog title="提示" :visible.sync="reasonDig" width="500px">
      <el-form :model="addMsg" :rules="rules" ref="addMsg" label-width="0">
            <p style="margin-bottom:10px">请输入备注</p>
            <el-form-item>
                <el-input size="small" v-model="addMsg.Remark"></el-input>
            </el-form-item> 
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="reasonDig = false">取 消</el-button>
        <el-button size="small" type="primary" @click="czsubmitForm('addMsg')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    
    data() {
      return {
        adduserDig:false,
        remarkDig:false,
        plDig:false,
        activeName:'first',
        czType:1,
        changeState:false,
        loading:false,
        checkAll: false,
        checkedCities: [],
        cities: [],
        cityOptions: [],
        isIndeterminate: true,
        dialogVisible:false,
        value:'',
        options:[],
        tableData:[],
        msg:{
            pageIndex:1,
            pageSize:15,
            AuditStatus:0,
        },
        total:0,
        platList:[],
        memberGradeList:[],
        userrules:{
            UserId: [
                { required: true, message: '请选择用户', trigger: 'change' }
            ],
        },
        rules:{
            Type: [
                    { required: true, message: '请选择类型', trigger: 'change' }
                ],
            Integral: [
                    { required: true, message: '请输入积分', trigger: 'blur' }
                ],
        },
        addMsg:{
            RemitId:0,
            Type:1,
            Remark:'',
        },
        imgurl:'',
        AuditStatusList:[],
        reasonDig:false,
        DropdownList:[],
        checktableList:[],
        checllen:0,
        usermsg:{
            pageIndex:1,
            pageSize:20,
            Name:'',
            Source:0,
            MemberGrade:0,
            Id:0,
            Moblie:''
        },
        userData:[],
        adduserMsg:{
            UserId:'',
            IsFormSelfApplication:2,
            Name:'',
            Mobile:'',
        },
      };
    },
    created() {
        this.getList();
        this.getplat();
        this.getDown();
        this.GetMemberGradeList();
        this.GetAuditStatus();
        this.GetDropdownList();
    },
    methods: {
        
        openReason(num,row){
            this.addMsg.Remark='';
            this.addMsg.Type=num;
            this.addMsg.RemitId=row.Id;
            this.reasonDig=true;
        },
        handleClick(val){
            this.msg.AuditStatus=val.$attrs.dataId;
            this.getList();
        },
        
        czsubmitForm (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    let cmd="/api/user/SetDistributorRemitAudit";
                    this.apipost(cmd,this.addMsg,
                        res => {
                        if (res.data.resultCode === 1) {
                            this.getList();
                            this.Success(res.data.message)
                            this.reasonDig=false;

                        } else {
                            this.Error(res.data.message);
                        }
                        },
                        null
                    );
                } else {
                return false;
                }
            });
        },
        openChangeDig(){
            this.changeState=true;
            setTimeout(()=>{
                this.$refs.mychild.InitData(this.czType);
            },10)
        },
        Export(){
            this.msg.ExcelEnumIds=this.checkedCities;
            let msg = JSON.parse(JSON.stringify(this.msg));
            this.JavaGetLocalFile(
            "/api/user/GetDistributorRemitListToExcel",
            msg,
            "分销提现.xls"
            );
        },
        ChangeOpenidState(index,row){
            this.tableData[index].OpenIdState=!this.tableData[index].OpenIdState;
        },
        getList(){
            this.loading=true;
            this.apipost("/api/user/GetDistributorRemitPageList", 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;
                }
                
            })
        },
        GetDropdownList(){
            let msg={
                Id:0,
                Grade:0,
                Name:'',
                Enabled:0,
            }
            this.apipost("/api/user/GetDistributorGradeDropdownList",msg, res => {
                this.DropdownList=res.data.data;
            })
        },
        GetAuditStatus(){
            this.apipost("/api/user/GetDistributorRemitAuditStatusEnumList",{}, res => {
                this.AuditStatusList=res.data.data;
            })
        },
        getDown(){
            this.cityOptions=[];
            this.apipost("/api/user/GetDistributorRemitExportEnumList",{}, res => {
                this.cities=res.data.data;
                let data=res.data.data;
                data.forEach(item=>{
                    this.cityOptions.push(item.Id)
                })
                
            })
        },
        GetMemberGradeList(){
            let msg={
                Grade:0,
                Name:'',
                Enabled:0,
            };
            this.apipost("/api/user/GetMemberGradeList",msg, res => {
                this.memberGradeList=res.data.data;
            })
        },
        getplat(){
            this.apipost("/api/user/GetMemberUserSourceEnumList",{}, res => {
                this.platList=res.data.data;
            })
        },
        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();
        },

    },
    mounted() {
      
    }
  };

</script>
<style>
.disWithdrawal .WithTable thead.is-group th{
    background: #fff!important;
}
.disWithdrawal .el-tabs__item{
    height: 56px!important;
    line-height: 56px!important;

}
.disWithdrawal .el-tabs__header{
    height: 56px!important;
    margin:0!important;
}
.disWithdrawal .pldc{
    position: absolute;
    right: 20px;
    margin-top:15px;
    z-index: 10000;
}
.table_samll .cell img{
    margin-right:10px;
}
.plxg .el-dialog__body{
    padding-top:10px!important;
}
.plxg .app-batch .batch-box-left div {
    padding: 5px 0;
    margin: 5px 0;
    cursor: pointer;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
}
.plxg .app-batch .batch-div-active {
    background-color: #e2e2e2;
}
.plxg .app-batch .batch-box-right {
    padding: 5px 20px;
}
.plxg .app-batch .batch-box-left {
    width: 120px;
    border-right: 1px solid #e2e2e2;
    padding: 0 20px;
}
.plxg .app-batch .batch-remark {
    margin-top: 5px;
    color: #999999;
    font-size: 14px;
}
.distributors .absoSpan{
    position: absolute;
    top:22px;
    left:100px;
}
.table_samll td, .table_samll th{
    padding: 8px 0!important;
    font-size:12px;
}
.disWithdrawal .remark_name {
    color: #888888;
    font-size: 12px;
    margin-left: 10px;
    float: right;
}
.disWithdrawal .app-image{
    background-position: center center; 
    width: 50px; 
    height: 50px;
     border-radius:0%; 
     float: left;
      margin-right: 8px;
}
.disWithdrawal .blue{
    color:#409EFF;
    
}
.disWithdrawal .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
}
.disWithdrawal .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
}
.disWithdrawal .content .searchInput{
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
    margin-right: 20px;
}
.disWithdrawal .content{
    margin-top:10px;
    /* padding: 20px; */
    box-sizing: border-box;
}

</style>
