<!--  -->
<template>
  <div>
    <main-top :crumb="crumbData"></main-top>
    <div class="table-interface">
      <div class="top-body">
        <div class="info-top">
          <div class="info-left">
            <!-- <span>按用户操作查看：</span> -->
            <!-- <el-select style="width:100px;" v-model="region" placeholder="请选择">
              <el-option label="全部" value="all"></el-option>
              <el-option label="发布" value="fb"></el-option>
              <el-option label="编辑" value="bj"></el-option>
              <el-option label="删除" value="sc"></el-option>
              <el-option label="排序" value="px"></el-option>
            </el-select> -->
            <span style="margin-left:20px;">按操作模块查看：</span>
            <el-select style="width:120px;" v-model="params.type" placeholder="请选择">
              <el-option label="全部" value=""></el-option>
              <el-option label="展览管理" value="展览管理"></el-option>
              <el-option label="文物库" value="文物库"></el-option>
              <el-option label="日志管理" value="日志管理"></el-option>
              <el-option label="用户管理" value="用户管理"></el-option>
            </el-select>
            <el-input style="width:220px;margin:0 20px;" v-model="params.description" placeholder="请输入操作事件内容"></el-input>
            <el-button type="primary" @click="handleSearchBtnClick">查找</el-button>
            <el-button>重置</el-button>
          </div>
        </div>
        <el-table :data="tableData" style="width: 100%">
          <el-table-column
            v-for="(item, idx) in data"
            :key="idx"
            :prop="item.prop"
            :label="item.label"
          >
          <template slot-scope="scope">
            <span>{{scope.row[item.prop]}}</span>
          </template>
          </el-table-column>
        </el-table>
        <div class="e-pagination">
          <el-pagination @current-change="handleCurrentChange" :current-page.sync="params.pageNum" :page-size="params.pageSize" layout="prev, pager, next, jumper" :total="total">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';

import MainTop from '@/components/main-top'
import SearchBar from '@/components/search-bar'
const crumbData = [
  {
    name: '工作日志',
    id: 7
  }
]

export default {
  // import引入的组件需要注入到对象中才能使用
  components: {
    MainTop,
    SearchBar
  },
  data () {
    // 这里存放数据
    let data = [
      {
        prop: 'id',
        label: '序号'
      },
      {
        prop: 'userName',
        label: '账号'
      },
      {
        prop: 'type',
        label: '操作模块'
      },
      {
        prop: 'description',
        label: '操作事件'
      },
      {
        prop: 'createTime',
        label: '操作时间'
      }
    ]

    return {
      crumbData,
      data,
      region: 'all',
      region1: 'all',
      infoName: '',
      tableData: [],
      params: {
        pageNum: 1,
        description: '',
        pageSize: 20,
        type: ''
      },
      total: 0
    }
  },
  mounted () {
    this.getModuleList()
    this.getLogs()
  },
  methods: {
    getModuleList () {
      this.$http.post('/resource/find').then(res => {
        console.log(res, '/resource/find')
      })
    },
    getLogs () {
      this.$http.post('/log/list', this.params).then(res => {
        console.log(res)
        this.tableData = res.data.list
        this.total = res.data.total
      })
    },
    handleCurrentChange () {
      this.getLogs()
    },
    handleSearchBtnClick () {
      this.params.pageNum = 1
      this.getLogs()
    }
  }
}
</script>

<style scoped>
/* 引入公共css类 */
@import url(./style);
</style>
