<template>
  <ai-list class="AppLoginLog">
    <template slot="title">
      <ai-title title="登录日志" isShowBottomBorder></ai-title>
    </template>
    <template slot="content">
      <ai-search-bar class="search-bar">
        <template #left>
        </template>
        <template slot="right">
          <el-input
            v-model="search.userName"
            size="small"
            v-throttle="() => { search.current = 1, getList() }"
            placeholder="请输入姓名/部门"
            clearable
            @clear="search.current = 1, search.userName = '', getList()"
            suffix-icon="iconfont iconSearch">
          </el-input>
        </template>
      </ai-search-bar>
      <ai-table
        :tableData="tableData"
        :col-configs="colConfigs"
        :total="total"
        style="margin-top: 6px; width: 100%;"
        :current.sync="search.current"
        :size.sync="search.size"
        @getList="getList">
      </ai-table>
    </template>
  </ai-list>
</template>

<script>
  export default {
    name: 'AppLoginLog',
    label: '登录日志',

    props: {
      instance: Function,
      dict: Object
    },

    data() {
      return {
        search: {
          current: 1,
          size: 10,
          userName: ''
        },
        tableData: [],
        total: 0,
        colConfigs: [
          { prop: 'userName', label: '姓名' },
          { prop: 'departFullName', label: '部门', align: 'center' },
          { prop: 'ip', label: 'IP', align: 'center' },
          { prop: 'clientId', label: '客户端', align: 'center' },
          { prop: 'createTime', label: '登录时间', align: 'center' }
        ]
      }
    },

    created () {
      this.getList()
    },

    methods: {
      getList() {
        this.instance.post(`/app/sysuserloginlog/list`, null, {
          params: {
            ...this.search
          }
        }).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records
            this.total = res.data.total
          }
        })
      }
    }
  }
</script>

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