<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">人员姓名</label>
        <el-input v-model="query.userName" clearable placeholder="人员姓名" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">人员种类</label>
        <el-select v-model="query.usertype" filterable placeholder="请选择" clearable>
          <el-option
            v-for="item in dict.user_type"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <label class="el-form-item-label">考勤时间</label>
        <date-range-picker
          v-model="query.attendanceTime"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          class="date-item"
        />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="cardNumber" label="卡号" />
        <el-table-column prop="dmUser.name" label="人员姓名" />
        <el-table-column prop="dmUser.usertype" label="人员种类">
          <template slot-scope="scope">
            {{ dict.label.user_type[scope.row.dmUser.usertype] }}
          </template>
        </el-table-column>
        <el-table-column prop="dmUser.dept.name" label="组织机构" />
        <el-table-column prop="attendanceTime" label="考勤时间" />
        <el-table-column prop="dmRoomDevice.name" label="设备名称" />
        <el-table-column prop="dmRoomDevice.buildAddress" label="设备位置" />
        <el-table-column prop="open" label="进出闸情况" />
        <!-- <el-table-column prop="attendancePhoto" label="考勤照片">
          <template slot-scope="{row}">
            <el-image
              :src="baseApi + '/file/' + row.attendancePhoto"
              :preview-src-list="[baseApi + '/file/' + row.attendancePhoto]"
              fit="contain"
              lazy
              class="el-avatar"
            >
              <div slot="error">
                <i class="el-icon-picture" />
              </div>
            </el-image>
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDmAttendanceRecord from '@/api/dmAttendanceRecord'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
// import { mapGetters } from 'vuex'
import DateRangePicker from '@/components/DateRangePicker/index'

const defaultForm = { id: null, userNumber: null, cardNumber: null, roomDevice: null, property: null, attendanceTime: null, attendancePhoto: null, dmRoomDevice: null, open: null }
const optShow = {
  add: false,
  edit: false,
  del: false,
  download: true,
  reset: true
}
export default {
  name: 'DmAttendanceRecord',
  dicts: ['property', 'user_type'],
  components: { pagination, crudOperation, rrOperation, DateRangePicker },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '考勤记录', url: 'api/dmAttendanceRecord', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDmAttendanceRecord }, optShow })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'dmAttendanceRecord:add'],
        edit: ['admin', 'dmAttendanceRecord:edit'],
        del: ['admin', 'dmAttendanceRecord:del']
      },
      rules: {
      }}
  },
  // computed: {
  //   ...mapGetters([
  //     'baseApi'
  //   ])
  // },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
