<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
      <el-form-item label="姓名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="日期">
        <el-date-picker
          style="width: 300px"
          v-model="dateRange"
          value-format="yyyy-MM-dd"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="部门" prop="department">
        <el-input
          v-model="queryParams.department"
          placeholder="请输入部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button type="success" icon="el-icon-download" size="mini" @click="exportRecord">导出</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="clockRecordList" stripe>
      <el-table-column label="序号" type="index" width="55" align="center"/>
      <el-table-column label="设备工号" align="center" prop="deviceNum"/>
      <el-table-column label="员工工号" align="center" prop="teacherCode"/>
      <el-table-column label="姓名" align="center" prop="userName"/>
      <el-table-column label="部门" align="center" prop="orgname"/>
      <el-table-column label="考勤日期" align="center" prop="clockDate"/>
      <el-table-column label="打卡时间" align="center" prop="times"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleView(scope.row)"
            v-hasPermi="['system:clockRecord:edit']"
          >删除
          </el-button>
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>

<script>
import {personalList, checkRow} from "@/api/smartSchool/gradeWork/monthRecord.js"

export default {
  name: 'GradeWorkClockRecord',
  data() {
    return {
      // 日期范围
      dateRange: [],
      // 模糊搜索
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        clickDate: undefined,
      },
      // 加载遮罩
      loading: true,
      // 总条数
      total: 0,
      // 记录列表
      clockRecordList: [],
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 获取列表
    getList() {
      this.loading = true;
      personalList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.clockRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    // 模糊搜索
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 导出
    exportRecord() {
      this.download('/schoolAtt/gradeList/export', {
        ...this.queryParams
      }, `clock_${Date.now()}.xlsx`)
    },
  },
  created() {
    this.getList()
  },
  mounted() {
  }
};
</script>
<style scoped>
</style>
