<template>
  <div class="form-wrap">
    <el-form
      class="searchBox"
      ref="form"
      :model="form"
      :inline="true"
      label-width="70px">
      <div class="block-title">
        查询条件
      </div>
      <el-form-item
        label="操作人"
        prop="keyWords1">
        <el-select v-model="form.keyWords1">
          <el-option
            label="全部"
            value=""></el-option>
          <el-option
            v-for="item in salesList"
            :key="item.id"
            :label="item.nick_name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        label="操作名称"
        prop="keyWords2">
        <el-input v-model="form.keyWords2"></el-input>
      </el-form-item>

      <el-form-item
        label="起始时间"
        prop="startDate"
      >
        <el-date-picker
          v-model="form.startDate"
          type="datetime"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="截止时间"
        prop="endDate"
      >
        <el-date-picker
          default-time="23:59:59"
          v-model="form.endDate"
          type="datetime"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>

      <div class="btn-wrap">
        <el-button
          @click="reset"
        >
          重置
        </el-button>
        <el-button
          :disabled="loading"
          type="primary"
          @click="getList(true)"
        >
          搜索
        </el-button>
      </div>
    </el-form>

    <div class="tableBox">
      <div class="block-title">
        统计信息
      </div>
      <el-table
        border
        stripe
        v-loading="loading"
        :data="tableData">
        <el-table-column
          prop="manager_name"
          label="操作人"
        >
        </el-table-column>

        <el-table-column
          prop="operation"
          label="操作名称"
        >
        </el-table-column>

        <el-table-column
          prop="object_id"
          label="对象id"
        >
        </el-table-column>

        <el-table-column
          prop="name"
          label="字段名称"
        >
        </el-table-column>

        <el-table-column
          min-width="100"
          prop="old_value"
          label="原值"
        >
        </el-table-column>
        <el-table-column
          prop="new_value"
          label="新值"
        >
        </el-table-column>

        <el-table-column
          prop="create_time"
          label="修改时间"
        >
          <template slot-scope="scope">
            {{ scope.row.create_time | formatTime }}
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        :current-page.sync="form.pageNum"
        @current-change="getList()"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { getWebLog } from '@/api/systemSetting/webLog.js'

export default {
  computed: {
    salesList () {
      return this.$store.state.user.salesList
    }
  },
  data () {
    return {
      ticketTypeList: [],
      form: {
        startDate: '',
        endDate: '',
        keyWords1: '',
        keyWords2: '',
        pageNum: 1,
        pageSize: 10
      },
      accountList: [],
      tableData: [],
      total: 0,
      loading: false
    }
  },
  async created () {
    this.getList()
  },
  methods: {
    reset () {
      this.$refs.form.resetFields()
    },
    getList (goFirst) {
      this.loading = true
      goFirst && (this.form.pageNum = 1)
      getWebLog(this.form).then(res => {
        this.total = res.total
        this.tableData = res.list
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
