<template>
  <div>
    <el-form :inline="true">
      <el-form-item label="应到学生数">
        <!-- <el-input disabled
                  :value="studentNum"></el-input> -->
        <div class="inputStyle">{{studentNum}}</div>
      </el-form-item>
      <el-form-item label="到课学生数">
        <!-- <el-input disabled
                  :value="signInNum"></el-input> -->
        <div class="inputStyle">{{signInNum}}</div>
      </el-form-item>
      <el-form-item label="请假学生数">
        <!-- <el-input disabled
                  :value="leaveNum"></el-input> -->
        <div class="inputStyle">{{leaveNum}}</div>
      </el-form-item>
      <el-form-item label="旷课学生数">
        <!-- <el-input disabled
                  :value="leaveNum"></el-input> -->
        <div class="inputStyle">{{truantNum}}</div>
      </el-form-item>
    </el-form>
    <div class="tableWrap">
      <el-table :data='tableList'
                :header-cell-style="{background:'#EDEEF0',color:'#444'}">
        <el-table-column align='center'
                         prop="username"
                         label="学生姓名">
        </el-table-column>
        <el-table-column align='center'
                         prop="phone"
                         label="手机号">
        </el-table-column>
              <el-table-column align='center'
                         prop="signInTime"
                         label="签到时间">
        </el-table-column>
              <el-table-column align='center'
                         prop="signOutTime"
                         label="签退时间">
        </el-table-column>
        <el-table-column align='center'
                         prop="status"
                         label="学生状态">
          <template slot-scope="scope">
            <div>
              <p v-if="scope.row.status">{{scope.row.status | studentRecord}}</p>
              <p v-else>未签到</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="rules.total"
                  :page.sync="rules.page"
                  :limit.sync="rules.limit"
                  @pagination="getList" />
    </div>
  </div>
</template>
<script>
import { findStudentAttendance, sumStudentAttendance } from '@/api/buildTeam'
import pagination from '@/components/Pagination/index'
export default {
  props: ['courseScheduleId'],
  components: { pagination },
  data () {
    return {
      tableList: [],
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
      },
      studentNum: null,
      signInNum: null,
      leaveNum: null,
      truantNum: null
    }
  },
  mounted () {
    this.init()
  },
  activated () {
    this.init()
  },
  methods: {
    init () {
      // console.log(this.courseScheduleId)
      this.getList()

      //  发请求获取学生签到信息
    },
    getList () {
      findStudentAttendance({ search: this.courseScheduleId }).then(res => {
        if (res.code == 200) {
          this.tableList = res.data.rows;
          this.rules.total = res.data.total
        }
      })
      sumStudentAttendance({ courseScheduleId: this.courseScheduleId }).then(res => {
        if (res.code == 200) {
          this.studentNum = res.data.studentNum;
          this.signInNum = res.data.signInNum;
          this.leaveNum = res.data.leaveNum
          this.truantNum = res.data.truantNum
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.inputStyle {
  width: 100px;
  text-align: center;
}
</style>