<template>
	<div class="flexOne">
		<div class="query-box">
			<ul>
				<li>
					<span><em>{{$t('system.table_company')}}</em>
						  <el-select filterable   v-model='msg.RB_BranchId' :placeholder="$t('pub.unlimitedSel')">
						        <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>
					<span><em>状态</em>
						<el-select v-model="msg.Status" placeholder="请选项">
							 <el-option :label="$t('pub.unlimitedSel')" value='-1'></el-option>
								<el-option label='开启' value='0'></el-option>
								<el-option label='关闭' value='1'></el-option>
							</el-select>
					</span>	
				</li>-->
				<li>
					<input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="resetPageIndex(),getList()" />
					<!--<input type="button" @click="" class="normalBtn" :value="$t('pub.addBtn')" @click="$router.push('AttendanceRules')"/> -->
				</li>
			</ul>
		</div>
	   <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading='loading'>
		   	<tr>
		   		<th width="400">{{$t('admin.admin_company')}}</th>
		   		<th>{{$t('admin.admin_personNumber')}}</th>
		   		<th>{{$t('adm.adm_Bindingattendance')}}</th>
		   		<th>{{$t('admin.admin_kqTime')}}</th>
		   		<th >{{$t('admin.admin_czPerson')}}</th>
		   		<th width="150">{{$t('admin.admin_operate')}}</th>
		   	</tr>
		  	<tr v-for="(item,index) in dataList">
		   		<td>{{item.BranchName}}</td>
		   		<td>{{item.PeopleNum}}</td>
		   		<td>{{item.IsBind=='1'?$t('adm.adm_binded'):$t('admin.adm_binding')}}</td>
		   		<td>{{item.AttendanceDate}}</td>
		   		<td>{{item.UpdateName}}</td>
		   		<td>
					<el-tooltip class="item" effect="dark" :content="$t('pub.updateMsg')" placement="right">
						<el-button type="primary" icon="el-icon-edit" @click="goUrl('AttendanceRules',item.Id,item.RB_BranchId)" circle></el-button>
					</el-tooltip>
		   		</td>
		   	</tr> 
	   	</table>		   	
		<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>
</template>

<script>
	export default{
		
		data() {
			return {
				loading:true,
				//分页
				total: 0,
				pageSize: '',
				currentPage: 1,	
				//请求数据
				msg:{
					pageIndex:1,
					pageSize:15,
					RB_BranchId:'-1',
					Status:'-1',
					IsBind:'0'
				},
				companyMsg:{
					RB_Group_Id:"0",
					Status:0,
				},				
				//返回数据
				dataList:[],
				companyList:[]
			}
		},
		methods:{
			getList(){
				this.loading=true;
				this.apipost('User_get_AttendanceGetPageList',this.msg,res=>{
					if(res.data.resultCode==1){
						this.loading=false;	
						this.dataList=res.data.data.pageData;
						this.total = res.data.data.count;
					}else{}
				},err=>{})
			},
			getCompany(){ //公司
				this.apipost('admin_get_BranchGetList', this.companyMsg, res => {
				    this.companyList = res.data.data;
				}, err => {})	
			},
			handleCurrentChange(val) {
				this.msg.pageIndex = val;
				this.getList();
			},
			resetPageIndex() {
				this.msg.pageIndex = 1;
				this.currentPage=1
			},
			goUrl (path,id,bId) {
	            this.$router.push({ name: path,query:{"id":id,"bId":bId} }) 
	        }
		},
		mounted() {
			this.getList();
			this.getCompany();
			let userInfo=this.getLocalStorage();
			this.companyMsg.RB_Group_Id=userInfo.RB_Group_id;//集团
		},
		
	}
</script>

<style>
	.singeRowTable th{text-align: left; padding-left: 10px;}
	.singeRowTable td{text-align: left;padding-left: 10px}
</style>