<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-input v-model="query.taskName" clearable placeholder="打印文档名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <!-- <label class="el-form-item-label">文档总页数</label>
        <el-input v-model="query.filePageNum" clearable placeholder="文档总页数" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">文档份数</label>
        <el-input v-model="query.fileRepeatNum" clearable placeholder="文档份数" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
        <label class="el-form-item-label">打印机编号</label>
        <el-input v-model="query.printerCode" clearable placeholder="打印机编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />

        <!-- <label class="el-form-item-label">目前状态</label>
        <el-input v-model="query.status" clearable placeholder="目前状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
        <rrOperation :crud="crud" />
        <!-- <deviceTemp @on-change-device="changeVal" /> -->
        <!-- <userTemp @on-change="changeUser" /> -->
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />

      <!-- <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @row-dblclick="showInfo" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="countUser.name" label="姓名" />
        <el-table-column prop="countUser.dept.name" label="组织名称" />
        <el-table-column prop="taskName" label="打印文档名称" />
        <el-table-column prop="fileRepeatNum" label="打印份数" />
        <el-table-column prop="filePageNum" label="打印页数" />
        <el-table-column prop="countDevice.name" label="打印机名称" />
        <el-table-column prop="countDevice.code" label="打印机编号" />
        <el-table-column prop="countDevice.style" label="打印机类型" />
      </el-table> -->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @row-dblclick="showInfo" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="countUser.name" label="姓名" />
        <el-table-column prop="countUser.dept.name" label="组织机构" />
        <el-table-column prop="taskName" label="任务名称" />
        <el-table-column prop="filePageNum" label="文档总页数" />
        <el-table-column prop="fileRepeatNum" label="文档份数" />
        <el-table-column prop="countDevice.code" label="打印机编号" />
        <el-table-column prop="countDevice.name" label="打印机名称" />
      </el-table>

      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>
<script>
// import { getToken } from '@/utils/auth'
import crudDmPrintingCount from '@/api/dm/printingCount/dmPrintingCount'
// import { mapGetters } from 'vuex'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
// import deviceTemp from '@/components/Device/index'
// import userTemp from '@/components/User/dmUserindex'

const defaultForm = { id: null, taskCode: null, taskName: null, filePageNum: '', fileRepeatNum: '', countDevice: { id: null }, countUser: { id: null }, status: null, remark: null, name: '', file: { id: null }}
export default ({
  name: 'DmPrintingCount',
  components: { pagination, crudOperation, rrOperation }, //, udOperation, deviceTemp, userTemp
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['print_approval_status'],
  cruds() {
    return CRUD({ title: '文印统计', url: '/api/dmPrintingCount', idField: 'id', tempBtnShow: { user: false }, selectOne: true,
      crudMethod: { ...crudDmPrintingCount }, optShow: { del: false, edit: false, add: false, download: true, reset: true }})
  },
  data() {
    return {
      deviceList: [], // 设备集合
      fileList: [], // 文件集合
      deviceId: '', // 设备
      initFileId: '', // 编辑时，存储 添加时的文件id,防止误删
      beforeSubmitFileId: '', // 编辑时，存储 添加时的文件id,防止误删
      tmpType: '', // 弹框所属字段
      openid: '', // 弹框项
      permission: {
        add: ['admin', 'dmPrintingCount:add'],
        edit: ['admin', 'dmPrintingCount:edit'],
        del: ['admin', 'dmPrintingCount:del']
      },
      queryTypeOptions: [
        { key: 'userName', display_name: '姓名' },
        { key: 'taskName', display_name: '任务名称' },
        { key: 'filePageNum', display_name: '文档总页数' },
        { key: 'fileRepeatNum', display_name: '文档份数' },
        { key: 'printerCode', display_name: '打印机编号' }
        // { key: 'status', display_name: '目前状态（已通过、未审核、已驳回）' }
      ]
    //   headers: { 'Authorization': getToken() }
    }
  },
  //   computed: {
  //     ...mapGetters([
  //       'baseApi',
  //     //   'fileUploadApi'
  //     ])
  //   },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    showInfo(row) {
      console.info('data ==>', row)
      this.crud.doOpenDeviceInfo(row)
    }
  }
})
</script>
