<template>
  <div style="width: 100%;">
    <template v-if="!$route.query.id">
      <div class="search">
        <div class="left"></div>
        <div class="right">
          <div>
            <el-date-picker
              v-model="search.loginTime"
              type="date"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              clearable
              style="width: 200px;"
            />
          </div>
          <div>
            <el-input v-model="search.userName" style="width: 300px" placeholder="请输入登录名或姓名" clearable></el-input>
          </div>
          <div class="leftBtn">
            <el-button type="primary" @click="fetchData">查询</el-button>
          </div>
        </div>
      </div>
      <cy-comm-table
        ref="commTable"
        v-loading="loading"
        :columns="columns"
        :table-options="tableOptions"
        :data="tableData"
        :count="total"
        parent-component="LogManage"
      />
    </template>
    <router-view />
  </div>
</template>

<script>
import indexTable from './indexTable'
import request from '@/utils/request'

export default {
  name: 'LogManage',
  mixins: [indexTable],
  data() {
    return {
      search: {
        loginTime: '',
        userName: ''
      },
      loading: false
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.loading = true
      request({
        url: '/loginLog/do_list',
        method: 'get',
        params: {
          page: this.page,
          rows: this.size,
          loginTime: this.search.loginTime,
          userName: this.search.userName
        }
      }).then(({ rows, records }) => {
        this.tableData = rows || []
        this.total = records
        this.loading = false
      })
    },
    handlerOperate(type, info) {
      this.$router.push({
        path: '/logDetail',
        query: { id: info.id }
      })
    }
  }
}
</script>

<style lang="scss">

</style>
