<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-input
          v-model="query.personName"
          clearable
          size="small"
          placeholder="请输入用户名"
          style="width: 160px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-input
          v-model="query.ipAddress"
          clearable
          size="small"
          placeholder="请输入IP地址"
          style="width: 160px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-select
          v-model="query.logStatus"
          filterable
          clearable
          size="small"
          placeholder="请选择登录状态"
          class="filter-item"
          style="width: 160px"
          @change="crud.toQuery"
        >
          <el-option :value="1" label="成功"></el-option>
          <el-option :value="0" label="失败"></el-option>
        </el-select>
        <date-range-picker
          type="datetimerange"
          v-model="customs.timeRange"
          class="date-item"
          style="width: 400px !important"
          @change="crud.toQuery"
        />
        <rrOperation />
      </div>
      <crudOperation :permission="permission"></crudOperation>
    </div>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column
        v-for="item in logLoginTableOptions"
        :key="item.prop"
        :label="item.label"
        :prop="item.prop"
        :width="item.width"
        :align="item.align"
        :fixed="item.fixed"
        :sortable="item.sortable"
      ></el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import permission from '@/directive/permission'
import DateRangePicker from '@/components/DateRangePicker'
import crudLogLogin from '@/api/system/logLogin'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudComps from '@crud'
import { logLoginTableOptions } from '../tableConfig'

const defaultForm = {
  id: '',
  baseCreateTime: null,
  userName: '',
  logStatus: 0,
  ipAddress: '',
  ipLocation: '',
  browser: '',
  os: '',
  remark: '',
  extraRemark: '',
}

export default {
  name: 'LogLogin',
  directives: { permission },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  components: { ...crudComps, DateRangePicker },
  cruds() {
    return CRUD({
      title: '系统登录日志',
      url: 'system/logLogin/getList',
      listOrder: [],
      crudMethod: { ...crudLogLogin },
      optShow: { add: false, edit: false, del: false },
    })
  },
  computed: {
    crudCU() {
      return this.crud.status.cu > 0
    },
  },
  created() {
    this.getOptions()
  },
  data() {
    return {
      datetimeRange: undefined,
      logLoginTableOptions,
      viewLoading: false,
      permission: {
        del: ['admin', 'logLogin:del'],
      },
    }
  },
  methods: {
  },
}
</script>

<style></style>
