<style scoped>

</style>
<template>
  <div class="flexOne currentManage">
       <div class="query-box" v-if="!isSearch">
           <ul>
               <li>
                    <span>
                       <em>{{$t('objFill.gongsibie')}}</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>{{$t('system.table_staffs')}}</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>{{$t('active.cl_team')}}+'ID'</em>
                       <el-input v-model="msg.TCID" :placeholder="$t('fnc.qsrneirong')"></el-input>
                   </span>
               </li>
               <li>
                   <span>
                       <em>{{$t('visa.v_tuanhao')}}</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()">{{$t('visa.v_daochu')}}</button>
               </li>
           </ul>
       </div>
       <div style="margin:15px 0">
           <span>{{$t('objFill.v101.administrative.ticehngzje')}}:{{totalInfo.TotalMoney}}</span>
           <span>{{$t('objFill.v101.FinancialModule.shoukezrs')}}:{{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>{{$t('sm.company')}}</th>
                    <th>{{$t('admin.admin_Department')}}</th>
                    <th>{{$t('system.query_name')}}</th>
                    <th>{{$t('visa.v_tuanhao')}}</th>
                    <th>{{$t('active.cl_team')}}+'ID'</th>
                    <th>{{$t('salesModule.TCmoney')}}</th>
                    <th>{{$t('objFill.v101.administrative.shoukerenshu')}}</th>
                    <th>{{$t('tips.qishu')}}</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,
                    this.$t('objFill.v101.FinancialModule.optichengmx')+".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>