<template>
  <div class="app-container">
    <div class="head-container">
      <Search />
      <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-if="false" prop="id" label="id"/>-->
      <el-table-column prop="operate" label="操作" :min-width="flexWidth('operate',crud.data,操作)" />
      <el-table-column prop="device_code" label="设备号" :min-width="flexWidth('device_code',crud.data,设备号)" />
      <!-- <el-table-column prop="trace_id" label="链路追踪" /> -->
      <el-table-column prop="task_code" label="任务编号" :min-width="flexWidth('task_code',crud.data,任务编号)" />
      <el-table-column prop="instruct_code" label="指令编号" :min-width="flexWidth('instruct_code',crud.data,指令编号)" />
      <el-table-column prop="method" label="方法" :min-width="flexWidth('method',crud.data,方法)" />
      <el-table-column prop="status_code" label="状态码" :min-width="flexWidth('status_code',crud.data,状态码)" />
      <el-table-column prop="requestparam" label="请求参数" :min-width="flexWidth('requestparam',crud.data,请求参数)" />
      <el-table-column prop="responseparam" label="返回参数" :min-width="flexWidth('responseparam',crud.data,返回参数)" />
      <el-table-column prop="logTime" label="记录时间" :min-width="flexWidth('logTime',crud.data,记录时间)" />
      <el-table-column prop="content" label="内容详情" :show-overflow-tooltip="true" />

    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import Search from './search'
import CRUD, { crud, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import { delAll } from '@/api/acs/lucene/log'

export default {
  name: 'LuceneLog',
  components: { Search, pagination, crudOperation },
  mixins: [presenter(), header(), crud()],
  cruds: function() {
    return CRUD({
      title: '系统参数', url: 'api/lucene/getAll', idField: 'id', sort: 'id,desc',
      queryOnPresenterCreated: true,
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: false
      },
      page: {
        size: 40,
        total: 0,
        page: 0
      },
      query: {
        createTime: [new Date(new Date().setTime(new Date().getTime() - 3600 * 1000)), new Date(new Date().setTime(new Date().getTime() + 3600 * 1000))],
      }
    })
  },
  data() {
    return {
      query: { blurry: '123' },
      permission: {
        add: ['admin', 'param:add'],
        edit: ['admin', 'param:edit'],
        del: ['admin', 'param:del']
      },

      rules: {}
    }
  },
  created() {
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    confirmDelAll() {
      this.$confirm(`确认清空所有操作日志吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.crud.delAllLoading = true
        delAll('device_execute').then(res => {
          this.crud.delAllLoading = false
          this.crud.dleChangePage(1)
          this.crud.delSuccessNotify()
          this.crud.toQuery()
        }).catch(err => {
          this.crud.delAllLoading = false
          console.log(err.response.data.message)
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>

</style>
