
<template>
  <div class="usersList PeaceDistribution">
    <div class="head-title">
        微店审核
        <el-button  style="float:right;margin-top: -5px;" size="small" type="primary">
            批量导出
        </el-button>
    </div>
    <div class="content">
        <div>
           
            <div class="searchInput" style="width:230px">
                <el-input style="display:inline-block;width:205px;height:30px"
                placeholder="请输入用户id"
                @keyup.enter.native="msg.pageIndex=1,getList()" 
                @clear="msg.pageIndex=1,getList()"
                v-model="msg.UserId"
                size="small"
                clearable>
                </el-input>
                <span @click="msg.pageIndex=1,getList()" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
            </div>
            <div class="searchInput" style="width:230px">
                <el-input style="display:inline-block;width:205px;height:30px"
                placeholder="请输入微店名称"
                @keyup.enter.native="msg.pageIndex=1,getList()" 
                @clear="msg.pageIndex=1,getList()"
                v-model="msg.Name"
                size="small"
                clearable>
                </el-input>
                <span @click="msg.pageIndex=1,getList()" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
            </div>
            <div class="searchInput" style="width:230px">
                <el-input style="display:inline-block;width:205px;height:30px"
                placeholder="请输入用户名称"
                @keyup.enter.native="msg.pageIndex=1,getList()" 
                @clear="msg.pageIndex=1,getList()"
                v-model="msg.NickName"
                size="small"
                clearable>
                </el-input>
                <span @click="msg.pageIndex=1,getList()" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
            </div>
        </div>
         <div style="margin-top:20px">
        <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>
        <el-table
            :data="tableData"
            v-loading="loading"
            border
            style="width: 100%;margin:20px 0">
            <el-table-column prop="Id"  width="80" label="ID"></el-table-column>
            <el-table-column prop="Name"  width="150" label="微店名称"></el-table-column>
            <el-table-column prop="Logo" width="200" label="用户信息">
                <template slot-scope="scope">
                         <div class="app-image" :style="{backgroundImage:'url(' + scope.row.Logo + ')',backgroundSize:'cover'}"></div>
                            <div flex="dir:left cross:center">
                             {{scope.row.UserName}}
                            </div>
                </template>  
            </el-table-column>
            <el-table-column prop="Commission" label="可提现佣金">
                <el-table-column prop="Moblie" label="总佣金">
                    <template slot-scope="scope">
                        <p>{{scope.row.Commission?scope.row.Commission.toFixed(2):'0.00'}}</p>
                        <p>{{scope.row.TotalCommission?scope.row.TotalCommission.toFixed(2):'0.00'}}</p>
                    </template>
                </el-table-column>    
            </el-table-column>
            <el-table-column prop="AuditStatusName" label="申请状态"> </el-table-column>
            <el-table-column prop="AuditDate" label="审核时间"> </el-table-column>
            <el-table-column prop="Remark" label="备注"> </el-table-column>
            <el-table-column prop="CreateDate" label="操作时间"> </el-table-column>

            <el-table-column
                prop="address"
                
                label="操作">
            <template slot-scope="scope">

                  <el-tooltip class="item" effect="dark" content="同意" placement="top" v-if="scope.row.AuditStatus==1">
                      <img @click="pending(scope.row,1)" v-if="scope.row.AuditStatus==1" class="app-order-icon"
                           src="../../../assets/img/userman/pass.png" alt="">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="拒绝" placement="top" v-if="scope.row.AuditStatus==1">
                      <img @click="pending(scope.row,2)" v-if="scope.row.AuditStatus==1" class="app-order-icon"
                           src="../../../assets/img/userman/nopass.png" alt="">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="添加备注" placement="top-start" v-if="scope.row.AuditStatus==2">
                        <img @click="openRemark(5,scope.row)" style="width:32px;height:32px" src="../../../assets/img/userman/add_remark.png" alt="" v-if="scope.row.AuditStatus==2">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="删除" placement="top-start" v-if="scope.row.AuditStatus==2">
                        <img @click="Delete(3,scope.row)" style="width:32px;height:32px" src="../../../assets/img/userman/del.png" alt="" v-if="scope.row.AuditStatus==2">
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" content="修改微店佣金" placement="top-start" v-if="scope.row.AuditStatus==2">
                        <img @click="openYongjin(scope.row)" style="width:32px;height:32px" src="../../../assets/img/userman/edit.png" alt="" v-if="scope.row.AuditStatus==2">
                    </el-tooltip>
            </template>    
            </el-table-column>
        </el-table>
        <el-pagination style="text-align:right"
        background
        @current-change="handleCurrentChange"
        :page-size="msg.pageSize"
        layout="prev, pager, next"
        :current-page.sync="msg.pageIndex"
        :total="total">
        </el-pagination>
         <!-- 修改可提现佣金 -->
        <el-dialog title="提示" :visible.sync="yjDialog" width="400px">
            <el-form style="margin-top:10px">
                <el-form-item label-width="100px" label="用户">
                {{yjNickName}}
                </el-form-item>
                <el-form-item label-width="100px" label="累计佣金">
                {{TotalCommission}}
                </el-form-item>
                <el-form-item label-width="100px" label="可提现佣金">
                    <el-input v-model="yjMsg.Commission" @keyup.native="checkInteger(yjMsg,'Commission')" style="width:210px;"></el-input>
                </el-form-item>
            </el-form> 
            <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="yjDialog = false">取 消</el-button>
            <el-button size="small" type="primary" @click="setCommission">确 定</el-button>
            </span>
        </el-dialog>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        loading:false,
        yjDialog:false,
        value:'',
        options:[],
        tableData:[],
        msg:{
            pageIndex:1,
            pageSize:15,
            UserId:'',
            AuditStatus:0,
            Name:'',
            NickName:'',
        },
        total:0,
       
        AuditStatusList: [],
        activeName: 'first',
        yjMsg:{
          SmallShopsId:0,
          Commission:0
        },
        yjNickName:'',
        TotalCommission:''
      };
    },
    created() {
        this.getList();
        this.GetAuditStatus()
    },
    methods: {
     
        GetAuditStatus() {
            this.apipost("/api/user/GetDistributorAuditStatusEnumList", {}, res => {
            this.AuditStatusList = res.data.data;
            })
        },
         handleClick(val) {
            this.msg.AuditStatus = val.$attrs.dataId;
            this.getList();
        },
  
        getList(){
            this.loading=true;
            this.apipost("/api/SmallShops/GetSmallShopsPageList", 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;
                }
                
            })
        },

       
    
        handleCurrentChange(val) {
            this.msg.pageIndex = val;
            this.getList();
        },
        //修改
      openYongjin(row){
        this.TotalCommission=row.TotalCommission?row.TotalCommission:0.00;
        this.yjNickName=row.UserName;
        this.yjMsg.SmallShopsId=row.Id;
        this.yjMsg.Commission=row.Commission?row.Commission:0.00;
        this.yjDialog=true;
      },
      //修改佣金
      setCommission(){
         this.apipost("/api/SmallShops/SetSmallShopsCommission",this.yjMsg, res => {
            if(res.data.resultCode==1){
              this.Success(res.data.message);
              this.getList();
              this.yjDialog=false;
            }
        })
      },
      //同意和拒绝
      pending(row,type){
          let msg = {
              SmallShopsId:row.Id,
              Type:type,
              Remark:'',
          }
          let text
          if(type==1){
              text = '同意审核！'
          }else if(type==2){
               text = '拒绝审核！'
          }
           let that=this;
            that.$confirm(text, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.apipost('/api/SmallShops/SetSmallShopsAudit',msg,
                    res => {
                    if (res.data.resultCode === 1) {
                        this.getList();
                        this.Success(res.data.message)
                    } else {
                        this.Error(res.data.message);
                    }
                    },
                    null
                );
            }).catch(() => {
                
            });

      },

    },
    mounted() {
      
    }
  };

</script>
<style>
.usersList .remark_name {
    color: #888888;
    font-size: 12px;
    margin-left: 10px;
    float: right;
}
.usersList .app-image{
    background-position: center center; 
    width: 50px; 
    height: 50px;
     border-radius:0%; 
     float: left;
      margin-right: 8px;
}
.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>
