<template>
  <div class="flexOne">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-select filled stack-label @input="resetSearch()" option-value="SId" option-label="SName"
            v-model="msg.RB_BranchId" ref="School_Id" :options="schoolList" label="所属校区" :dense="false" emit-value
            map-options />
        </div>
      </div>
    </div>
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading='loading'>
      <tr>
        <th width="400">校区名称</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>
  import {
    getSchoolDropdown,
  } from '../../api/school/index'
  import {
    getAttendancePageList
  } from '../../api/administration/administration'
  export default {
    meta: {
      title: "考勤管理"
    },
    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: [],
        schoolList: [], //校区数组
      }
    },
    methods: {
      getList() {
        this.loading = true;
        getAttendancePageList(this.msg).then(res => {
          if (res.Code == 1) {
            this.loading = false;
            this.dataList = res.Data.PageData;
            this.total = res.Data.Count;
          } else {
            this.loading = false;
          }
        })
      },
      getCompany() { //公司
        getSchoolDropdown({}).then(res => {
          this.schoolList = res.Data;
          var obj = {
            SName: '全部',
            SId: '-1'
          }
          this.schoolList.unshift(obj);
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      resetSearch() {
        this.msg.pageIndex = 1;
        this.currentPage = 1;
        this.getList();
      },
      goUrl(path, id, bId) {
        this.$router.push({
          path: 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>
  @import "../financial/css/cssReset.css";

  .singeRowTable th {
    text-align: left;
    padding-left: 10px;
  }

  .singeRowTable td {
    text-align: left;
    padding-left: 10px
  }

</style>
