<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
      <el-form-item label="日期" prop="attMon">
        <el-date-picker
          v-model="queryParams.attMon"
          value-format="yyyy-MM"
          type="month"
          placeholder="请选择月份">
        </el-date-picker>
      </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="warning" icon="el-icon-upload" size="mini" @click="importRecord">导入</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="userName"/>
      <el-table-column label="部门" align="center" prop="orgname"/>
      <el-table-column label="日期" align="center" prop="attMon"/>
      <el-table-column label="请假时长" align="center" prop="attEa">
        <template slot-scope="scope">
          {{ scope.row.attEa }}天
        </template>
      </el-table-column>
      <el-table-column label="加班时长" align="center" prop="attOt">
        <template slot-scope="scope">
          {{ scope.row.attOt }}时
        </template>
      </el-table-column>
      <!-- <el-table-column label="打卡时间" align="center" prop="reasonForLeave"/> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row)"
            v-hasPermi="['system:monthRecord:check']"
          >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 查看请假加班时长信息对话框 -->
    <el-dialog title="" :visible.sync="openForCheck" width="1000px">
      <div>
        <el-form ref="checkForm" :model="checkForm" size="small" :inline="true" label-width="80px">
          <el-form-item label="姓名：">
            <el-input v-model="checkForm.userName" disabled></el-input>
          </el-form-item>
          <el-form-item label="部门：">
            <el-input v-model="checkForm.orgName" disabled></el-input>
          </el-form-item>
          <el-form-item label="月份：">
            <el-input v-model="checkForm.attMon" disabled></el-input>
          </el-form-item>
          <el-form-item label="加班：">
            <el-input v-model="checkForm.attEa" disabled></el-input>
          </el-form-item>
          <el-form-item label="请假：">
            <el-input v-model="checkForm.attOt" disabled></el-input>
          </el-form-item>
        </el-form>
        <el-divider></el-divider>
        <el-table v-loading="loading" :data="eaList" stripe>
          <el-table-column label="序号" type="index" width="55" align="center"/>
          <el-table-column label="请假开始时间" align="center" prop="startTime"/>
          <el-table-column label="请假结束时间" align="center" prop="endTime"/>
          <el-table-column label="请假时长" align="center" prop="totalTime">
            <template slot-scope="scope">
              {{ scope.row.totalTime }}天
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="remarks"/>
        </el-table>
        <el-divider></el-divider>
        <el-table v-loading="loading" :data="otList" stripe>
          <el-table-column label="序号" type="index" width="55" align="center"/>
          <el-table-column label="加班开始时间" align="center" prop="startTime"/>
          <el-table-column label="加班结束时间" align="center" prop="endTime"/>
          <el-table-column label="加班时长" align="center" prop="totalTime">
            <template slot-scope="scope">
              {{ scope.row.totalTime }}时
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="remarks"/>
        </el-table>
      </div>
      <div slot="footer">
        <el-button @click="handleCancel">关 闭</el-button>
        <!-- <el-button type="primary" @click="handleSubmit">确 定</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>

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

export default {
  name: '',
  components: {},
  props: {},
  data() {
    return {
      // 模糊搜索
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        attMOn: undefined,
      },
      // 加载遮罩
      loading: true,
      // 记录数
      total: 0,
      // 记录列表
      clockRecordList: [],
      // 查看请假加班时长信息对话框
      openForCheck: false,
      // 查看表单
      checkForm: {},
      // 请假记录
      eaList: [],
      // 加班时长
      otList: [],
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 获取列表
    getList() {
      this.loading = true;
      personalList(this.queryParams).then(response => {
        this.clockRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    // 模糊搜索
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //查看请假加班时长信息对话框
    handleView(row) {
      this.openForCheck = true;
      this.checkForm.userName = row.userName;
      this.checkForm.orgName = row.orgname;
      this.checkForm.attMon = row.attMon;
      this.checkForm.attEa = row.attEa;
      this.checkForm.attOt = row.attOt;
      checkRow(row.id).then(response => {
        this.eaList = response.eaList;
        this.otList = response.otList;
      })
    },
    // 取消
    handleCancel() {
      this.checkForm = {};
      this.openForCheck = false;
    },
  },
  created() {
    this.getList()
  },
  mounted() {
  }
};
</script>
<style scoped>
</style>
