<style scoped>

</style>
<template>
  <div class="flexOne currentManage">
       <div class="query-box" v-if="!isSearch">
           <ul>
               <li>
                    <span>
                       <em>公司别</em>
                        <el-select filterable v-model="msg.RB_Branch_Id" :placeholder="$t('system.ph_choice')">
                            <el-option :label="$t('pub.unlimitedSel')" :value="-1"></el-option>
                            <el-option
                                v-for="item in companyList"
                                :label="item.BName"
                                :value="item.Id"
                                :key="item.Id"
                            ></el-option>
                        </el-select>
                   </span>
               </li>
               <li v-if="msg.TrPerIods==0">
                   <span>
                       <em>员工</em>
                       <el-select  filterable v-model='msg.EmployeeId' >
                            <el-option key="0" :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                            <el-option v-for="item in EmployeeList" :label="item.EmName"
                            :value="item.EmployeeId" :key="item.EmployeeId"></el-option>
                          </el-select>
                   </span>
               </li>
               <li>
                   <span>
                       <em>团队ID</em>
                       <el-input v-model="msg.TCID" :placeholder="$t('fnc.qsrneirong')"></el-input>
                   </span>
               </li>
               <li>
                   <span>
                       <em>团号</em>
                       <el-input v-model="msg.TCNUM" :placeholder="$t('fnc.qsrneirong')"></el-input>
                   </span>
               </li>
               <li>
                    <button class="hollowFixedBtn" @click="getList">{{$t('pub.searchBtn')}}</button>
                    <button class="hollowFixedBtn" @click="method5()">导出</button>
               </li>
           </ul>
       </div>
       <div style="margin:15px 0">
           <span>提成总金额：{{totalInfo.TotalMoney}}</span>
           <span>收客总人数：{{totalInfo.TotalNum}}</span>
       </div>
       <div class="cm_content _scrollbar">

           <table class="po_content singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0" v-loading="loading">
                <tr>
                    <th>公司</th>
                    <th>部门</th>
                    <th>{{$t('system.query_name')}}</th>
                    <th>团号</th>
                    <th>团队ID</th>
                    <th>提成金额</th>
                    <th>收客人数</th>
                    <th>期数</th>
                    <th>{{$t('system.table_operation')}}</th>
                </tr>
                <tr v-for="(item,index) in DataList" :key="index">
                    <td>{{item.BName}}</td>
                    <td>{{item.DepartmentName}}</td>
                    <td>{{item.CreateByStr}}</td>
                    <td>{{item.TCNUM}}</td>
                    <td>{{item.TCID}}</td>
                    <td>{{item.CommissionMoney}}</td>
                    <td>{{item.PeopleCount}}</td>
                    <td>{{item.Periods}}</td>
                    <td>
                        <el-tooltip class="item" effect="dark" :content="$t('fnc.chakan')" placement="top-start">
                                <el-button type="primary" size='mini' circle icon="el-icon-view" @click="goUrl(item)"></el-button>
                            </el-tooltip>
                    </td>
                    <!-- <td>
                        <el-tooltip class="item" effect="dark" :content="$t('system.table_edit')" placement="top-start">
                            <el-button type="primary" class="iconfont icon-bianji-smal" @click="editCurency(item.ID),text=$t('system.table_edit')"></el-button>
                        </el-tooltip>
                    </td> -->
                </tr>
            </table>
           <div class="noData" v-if="DataList.length==0">
                {{$t('system.content_noData')}}
            </div>
           <div>
               <el-pagination
                    background
                    @current-change="handleCurrentChange"
                    :current-page.sync="currentPage"
                    layout="total,prev, pager, next, jumper"
                    :page-size=msg.pageSize
                    :total=total>
                </el-pagination>
           </div>
       </div>



    </div>
</template>
<script>
	export default {
		data() {
			return {
                isSearch: false,
                msg:{
                    pageIndex:1,
                    pageSize:14,
                    EmployeeId:0,
                    PeriodsId:"",
                    TCID:"",
                    TCNUM:"",
                    TrPerIods:0,
                    RB_Branch_Id:-1
                },
                DataList:[],
                loading:false,
                currentPage:1,
                total:0,
                EmployeeList:[],
                companyList:[],
                totalInfo:{},
			}
		},created(){
            this.msg.PeriodsId=this.$route.query.PeriodsId?this.$route.query.PeriodsId:this.msg.PeriodsId;
            this.msg.EmployeeId=this.$route.query.EmployeeId?Number(this.$route.query.EmployeeId):this.msg.EmployeeId;
            this.msg.RB_Branch_Id=this.$route.query.RB_Branch_Id?Number(this.$route.query.RB_Branch_Id):this.msg.RB_Branch_Id;
            this.msg.TrPerIods=this.$route.query.TrPerIods?Number(this.$route.query.TrPerIods):this.msg.TrPerIods;
            this.msg.TCNUM = this.$route.query.TCNUM?this.$route.query.TCNUM:true
            this.isSearch = this.$route.query.isSearch?this.$route.query.isSearch:false
        },
        mounted(){
            this.getCompany();
            this.getEmployeeList();
            this.getList();
        },
		methods: {
            method5: function() {
                let userInfo=this.getLocalStorage();
                let msg = JSON.parse(JSON.stringify(this.msg));
                msg.EmployeeIdUser=userInfo.EmployeeId;
                delete msg.pageIndex;
                delete msg.pageSize;

                this.GetLocalFile(
                    "sellcommission_post_GetOPCommissionSingleDetailsListToExcel",
                    msg,
                    "OP提成明细.xls"
                );
            },
            goUrl(item){
                this.$router.push({
                    path: "productQuery",
                    query: {
                    id: item.TCID,
                    blank:'y'
                    }
                });
            },
            resetPageIndex(){  // 重置页码
                this.msg.pageIndex=1;
                this.currentPage = 1;
            },
            handleCurrentChange(val) { //翻页
                this.msg.pageIndex = val;
                this.getList();
            },
            getList(){
                this.loading=true;
                this.apipost('sellcommission_GetOPCommissionSingleDetailsList', this.msg, res => {
                    this.loading=false;
                    if(res.data.resultCode == 1) {
                        this.DataList = res.data.data.pmodel.pageData;
                        this.total=res.data.data.pmodel.count;
                        this.totalInfo=res.data.data;
                    } else {
                        this.Error(res.data.message);
                    }
                }, err => {})
            },
            //获取公司下拉
            getCompany() {
                let userInfo = this.getLocalStorage()
                var RB_Group_id = userInfo.RB_Group_id
                let msg = {
                    Status: 0,
                    is_show: 0,
                    RB_Group_Id: RB_Group_id
                }
                this.apipost(
                'admin_get_BranchGetList',
                msg,
                res => {
                    if (res.data.resultCode == 1) {
                        this.companyList = res.data.data
                    }else{
                        this.Error(res.data.message);
                    }
                },
                err => {}
                )
            },

            getEmployeeList () {
                let userInfo = this.getLocalStorage()
                let msg = {
                    GroupId: userInfo.RB_Group_id,
                    BranchId: '-1',
                    DepartmentId: '-1',
                    PostId: '-1',
                    IsLeave: '0'
                }
                this.apipost(
                'admin_get_EmployeeGetList', {},
                res => {
                    if (res.data.resultCode == 1) {
                    this.EmployeeList = res.data.data
                    }
                },
                err => {
                }
                )
            },
        },

	}
</script>
