<template>
  <div class="form-wrap">
    <el-form
      class="search-box"
      ref="form"
      :model="form"
      :inline="true"
      label-width="140px"
    >
      <div class="block-title">
        查询条件
      </div>
      <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
          v-model="form.endDate"
          type="datetime"
          default-time="23:59:59"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>

      <el-form-item
        label="会员名"
        prop="keyWords1"
      >
        <el-input v-model="form.keyWords1"></el-input>
      </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="keyWords3"
      >
        <el-input v-model="form.keyWords3"></el-input>
      </el-form-item>

      <div class="btn-wrap">
        <!-- <el-button @click="exportStatist">
          导出
        </el-button> -->
        <el-button
          @click="reset"
        >
          重置
        </el-button>
        <el-button
          type="primary"
          @click="getList"
        >
          搜索
        </el-button>
      </div>
    </el-form>

    <div class="table-box">
      <div class="block-title">
        会员检票修改记录
      </div>
      <el-table
        stripe
        border
        v-loading="loading"
        :data="tableData">
        <el-table-column
          prop="member_name"
          label="会员名"
          width="80"
        >
        </el-table-column>
        <el-table-column
          prop="scenic_name"
          label="景点名称"
        >
        </el-table-column>
        <el-table-column
          prop="nickName"
          label="操作员"
        >
        </el-table-column>
        <el-table-column
          prop="old_checked_times"
          label="旧检票过闸次数"
        >
        </el-table-column>
        <el-table-column
          prop="new_checked_times"
          label="新检票过闸次数"
        >
        </el-table-column>
        <el-table-column
          prop="change_time"
          label="最近一次更新时间"
        >
          <template slot-scope="prop">
            {{ prop.row.change_time | formatTime }}
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        :current-page.sync="form.pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="form.pageSize"
        @size-change="handleSizeChange"
        @current-change="getList()"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { exportMemberTradeStatistics } from '@/api/queryReport'
import { getUpdateCheckTimesLogs } from '@/api/member'

import moment from 'moment'

export default {
  name: 'memberCheckTimesLogs',
  data () {
    return {
      scenicList: [],
      form: {
        startDate: new Date(moment().format('YYYY-MM-DD') + ' 00:00:00'),
        endDate: new Date(moment().format('YYYY-MM-DD') + ' 23:59:59'),
        keyWords1: '', // 会员名
        keyWords2: '', // 景点名称
        keyWords3: '', // 操作人
        pageNum: 1,
        pageSize: 10
      },
      tableData: [],
      total: 0,
      loading: false
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    reset () {
      this.$refs.form.resetFields()
    },
    exportStatist () {
      exportMemberTradeStatistics(this.form).then(res => {
        this.$message.success('导出成功。')
        this.goToDownload()
      })
    },
    handleSizeChange (size) {
      this.form.pageSize = size
      this.getList()
    },

    // 获取列表
    getList () {
      this.loading = true
      getUpdateCheckTimesLogs(this.form).then(res => {
        console.log('res', res)
        this.tableData = res?.data.list
        this.total = res?.data.total
        // 设置需要合并单元格的数组
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss">
.form-wrap{
  ::v-deep .el-table tr td:first-child .cell, .el-table tr th:first-child .cell{
    padding-left:10px;
  }
}

</style>
