<template>
  <div>
    <div class="head-container">
      <!-- <crudOperation /> -->
      <!-- <el-button v-permission="permission.download" :loading="crud.downloadLoading" :disabled="!selections.length" size="mini" icon="el-icon-download" @click="handleDownload">导出</el-button> -->
      <el-button :loading="crud.downloadLoading" size="mini" icon="el-icon-download" @click="handleDownload">导出</el-button>
      <el-select v-model="oprType" class="filter-item" style="width: 100px; height: 30px;margin:0 0 0 10px" @change="crud.toQuery">
        <el-option v-for="item in oprTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-input
        v-model="keyWord"
        size="small"
        clearable
        placeholder="请输入关键词"
        style="width: 300px;margin-right:10px;padding-left:10px"
        class="input-prepend filter-item"
      >
        <!-- <el-select slot="prepend" v-model="optionVal" style="width: 100px" @keyup.enter.native="crud.toQuery"> -->
        <el-select slot="prepend" v-model="optionVal" style="width: 100px">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-input>
      <date-range-picker v-model="queryTime" class="date-item" />
      <rrOperation />
    </div>
    <el-table
      ref="table"
      :data="crud.data"
      style="width: 100%;"
      height="calc(100vh - 356px)"
      @row-click="clickRowHandler"
      @selection-change="selectionChangeHandler"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" width="100" align="center" />
      <el-table-column prop="" label="登录账号" min-width="150" align="center" />
      <el-table-column prop="" label="用户名" align="center" min-width="150" />
      <el-table-column prop="" label="用户角色" align="center" min-width="150" />
      <el-table-column prop="" label="所属部门" align="center" min-width="180" />
      <el-table-column prop="" label="IP地址" align="center" min-width="180" />
      <el-table-column prop="" label="登录时间" align="center" min-width="180" />
    </el-table>
    <pagination />

  </div>
</template>

<script>
import rrOperation from '@crud/RR.operation'
import CRUD, { presenter, crud } from '@crud/crud'
import DateRangePicker from '@/components/DateRangePicker'
import pagination from '@crud/Pagination'

export default {
  name: 'LoginLog',
  components: { rrOperation, DateRangePicker, pagination },
  mixins: [presenter(), crud()],
  cruds() {
    return CRUD({
      url: 'api/storage/initStorageLogList',
      sort: ['update_time,desc'],
      // crudMethod: caseCrudMethod,
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: true
      }
    })
  },
  data() {
    return {
      selections: [],
      keyWord: '',
      oprType: 0,
      oprTypeOptions: [
        { value: 0, label: '全部' },
        { value: 1, label: '成功' },
        { value: 2, label: '失败' }
      ],
      optionVal: 1,
      options: [
        { value: 1, label: '操作人' },
        { value: 2, label: '所属部门' }
      ],
      queryTime: null
    }
  },
  methods: {
    // 导出
    handleDownload() {

    },
    test() {
      console.log(this.crud, 'crud')
    },
    clickRowHandler(row) {
      this.$refs.table.toggleRowSelection(row) // 单击选中
    },
    selectionChangeHandler(val) {
      this.selections = val
    }
  }
}
</script>

<style lang="scss" scoped>
@import "~@/assets/styles/archives-manage.scss";

</style>
