<template>
  <div class="app-container tab-container">
    <div class="head-container" style="display: flex; justify-content: space-between; align-items: center; padding-bottom: 20px;">
      <div class="head-search" style="margin-bottom: 0;">
        <el-input
          v-model="keyWord"
          size="small"
          clearable
          placeholder="输入关键字可模糊检索"
          style="width: 245px;"
          class="filter-item"
          @clear="crud.toQuery"
          @keyup.enter.native="crud.toQuery"
        />
        <date-range-picker v-model="burryTime" class="date-item" />
        <el-button class="filter-item filter-search" size="mini" type="success" icon="el-icon-search" @click="crud.toQuery">搜索</el-button>
        <el-button class="filter-item  filter-refresh" size="mini" type="warning" icon="el-icon-refresh-left" @click="resetQuery()">重置</el-button>
        <el-checkbox v-model="myEditing" style="line-height: 32px; padding-left: 10px;">我参与得编研</el-checkbox>
      </div>
      <crudOperation :permission="permission" />
    </div>
    <el-table
      ref="table"
      :data="crud.data"
      row-key="id"
      style="width: 100%;"
      height="calc(100vh - 330px)"
      @row-click="clickRowHandler"
      @cell-dblclick="tableDoubleClick"
      @selection-change="crud.selectionChangeHandler"
    >

      <el-table-column type="selection" :reserve-selection="true" width="55" align="center" />
      <el-table-column prop="username" label="编研主题" />
      <el-table-column prop="username" label="编研类型" align="center" />
      <el-table-column prop="username" label="主编人" align="center" />
      <el-table-column prop="username" label="其他编研人员" align="center" />
      <el-table-column prop="createTime" label="开始时间" width="200">
        <template slot-scope="scope">
          <div>{{ scope.row.createTime | parseTime }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="结束时间" width="200">
        <template slot-scope="scope">
          <div>{{ scope.row.createTime | parseTime }}</div>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-if="crud.data.length !== 0" />
    <EditingDetail ref="editingDetail" />
  </div>
</template>

<script>
import CRUD, { presenter, crud } from '@crud/crud'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker'
import crudOperation from '@crud/CRUD.operation'
import EditingDetail from './module/detail'

export default {
  name: 'ArchiveEditing',
  components: { pagination, DateRangePicker, crudOperation, EditingDetail },
  mixins: [presenter(), crud()],
  cruds() {
    return CRUD({
      url: 'api/log/initLog',
      title: '档案编研',
      optShow: {
        add: true,
        edit: true,
        del: true,
        download: false,
        reset: false,
        group: false
      }
    })
  },
  props: {
    activeIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      permission: {
        add: ['admin', 'archiveEditing:add'],
        edit: ['admin', 'archiveEditing:edit'],
        del: ['admin', 'archiveEditing:del']
      },
      keyWord: null,
      options: [
        { value: 'username', label: '利用人' },
        { value: 'account', label: '利用事由' }
      ],
      optionVal: '',
      burryTime: null,
      myEditing: false
    }
  },
  mounted() {
  },
  methods: {
    [CRUD.HOOK.beforeRefresh]() {
    },
    resetQuery() {

    },
    clickRowHandler(row) {
      // this.$refs.table.clearSelection()
      this.$refs.table.toggleRowSelection(row)
    },
    tableDoubleClick(row) {
      this.$refs.editingDetail.editingDetailVisible = true
    },
    handleCloseDialog(done) {
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
