<template>
	<div class="flexOne">
		<div class="query-box">
			<ul>
				<li>
					<span><em>{{$t('salesModule.Time')}}</em>
						<el-date-picker
                            v-model="dateList"
                            type="daterange"
                            :range-separator="$t('OrderList.zhi')"
							value-format="yyyy-MM-dd"
                            :start-placeholder="$t('OrderList.star')"
                            :end-placeholder="$t('OrderList.end')">
                            </el-date-picker>
					</span>
				</li>
				<li>
					<span><em>公司</em>
						<el-select @change="getEmployee" filterable  clearable v-model='msg.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 filterable  clearable v-model='msg.EmployeeId' :placeholder="$t('pub.unlimitedSel')">
                            <el-option :label="$t('pub.unlimitedSel')" value='-1'></el-option>
                            <el-option v-for='item in Employee'
                                :label='item.EmName'
                                :value='item.EmployeeId'
                                :key='item.EmployeeId'>
                            </el-option>
                        </el-select>
					</span>
				</li>
				<li>
                    <li>
					<span><em>离职状态</em>
						<el-select filterable  clearable v-model='msg.IsLeave' :placeholder="$t('pub.unlimitedSel')">
                            <el-option :label="$t('pub.unlimitedSel')" :value='-1'></el-option>
                            <el-option label="是" :value='1'></el-option>
                            <el-option label="否" :value='0'></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>
		<p style="padding:15px">
			<span>总计分钟数：{{dataList.TotalMinutes}}</span>
			<span style="margin-left:10px">总计天数：{{dataList.TotalDays}}</span>
			<span style="float:right;color:red">注：每天超过19：00算加班，每天按8小时计算</span>
		</p>
	   <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading='loading'>

		   	<tr>
		   		<th>员工编号</th>
		   		<th>{{$t('system.query_name')}}</th>
		   		<th>日期</th>
		   		<th>打卡时间</th>
		   		<th>打卡状态</th>
		   		<th>加班时长（分钟）</th>
		   	</tr>
		  	<tr v-for="(item,index) in dataList.List">
		   		<td>{{item.EmployeeId}}</td>
		   		<td>{{item.EmName}}</td>
		   		<td>{{item.DateStr}}</td>
		   		<td>{{item.OffDutyTime}}</td>
		   		<td>{{item.OffResult}}</td>
		   		<td>{{item.Minutes}}</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>
import moment from 'moment'
	export default{

		data() {
			return {
                dateList:[],
				loading:true,
				//分页
				total: 0,
				pageSize: '',
				currentPage: 1,
				//请求数据
				msg:{
					pageIndex:1,
					pageSize:15,
                    StartTime:moment().format("YYYY-MM-DD"),
                    EndTime:'',
                    EmployeeId:'-1',
					IsLeave:-1,
					BranchId:-1,
				},
				companyMsg:{
					RB_Group_Id:"0",
					Status:0,
				},
				//返回数据
				dataList:[],
                companyList:[],
                Employee:[],
			}
		},
		methods:{

			getEmployee(val) { //员工
				let str='-1';
				if(val){
					str=val;
				}
				let userInfo = this.getLocalStorage()
				let msg = {
					GroupId: userInfo.RB_Group_id,
					BranchId: str,
					DepartmentId: '-1',
					PostId: '-1',
					IsLeave: '0'
				}
				this.apipost('admin_get_EmployeeGetList', msg, res => {
					if(res.data.resultCode == 1) {
						this.Employee = res.data.data;
					}
				}, err => {})
			},
			getCompany(){ //公司
				this.apipost('admin_get_BranchGetList', this.companyMsg, res => {
				    this.companyList = res.data.data;
				}, err => {})
			},
			getList(){
				this.loading=true;
                if(this.dateList && this.dateList.length>0){
                    this.msg.StartTime=this.dateList[0];
					this.msg.EndTime=this.dateList[1];
                }
                else{
                    this.msg.StartTime=moment().format("YYYY-MM-DD");
					this.msg.EndTime=moment().format("YYYY-MM-DD");
					this.dateList=[this.msg.StartTime,this.msg.EndTime];
                }
				this.apipost('recod_get_GetEmployeeOvertimeHours',this.msg,res=>{
					this.loading=false;
					if(res.data.resultCode==1){
						this.dataList=res.data.data.pageData;
						this.total = res.data.data.count;
					}else{
						this.Error(res.data.message);
					}
				},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} })
	        }
		},
		created(){
		},
		mounted() {
			this.getList();
			this.getEmployee();
			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>
