<template>
  <div>
    <el-form
      class="searchBox"
      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"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="创建人"
        prop="keyWords3"
      >
        <el-select
          v-model="form.keyWords3"
          filterable>
          <el-option
            label="全部"
            value=""></el-option>
          <el-option
            v-for="item in salesList"
            :key="item.id"
            :label="item.nick_name"
            :value="item.nick_name">
          </el-option>
        </el-select>
      </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>
      <div class="btn-wrap">
        <el-button
          @click="reset"
        >
          重置
        </el-button>
        <el-button
          type="primary"
          @click="getData"
        >
          搜索
        </el-button>
      </div>
    </el-form>
    <el-table
      stripe
      border
      v-loading="loading"
      :data="tableData"
    >
      <el-table-column
        prop="orderNo"
        label="订单号"
      >
      </el-table-column>
      <el-table-column
        prop="ticketNo"
        label="票号"
      >
      </el-table-column>
      <el-table-column
        prop="manager_name"
        label="操作人"
      >
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="操作时间"
      >
        <template slot-scope="scope">
          {{ scope.row.createTime|formatTime }}
        </template>
      </el-table-column>
      <el-table-column
        label="操作类型"
      >
        <template slot-scope="scope">
          <el-tag
            v-if="scope.row.handle_type==='delay'"
            type="warning">
            延期
          </el-tag>
          <el-tag
            v-if="scope.row.handle_type==='faceDelay'"
            type="warning">
            人脸延期
          </el-tag>
          <el-tag
            v-if="scope.row.handle_type==='updateScenicTimes'"
            type="primary">
            修改检票次数
          </el-tag>
          <el-tag
            v-if="scope.row.handle_type==='disable'&&scope.row.is_use===1"
            type="success">
            启用
          </el-tag>
          <el-tag
            v-if="scope.row.handle_type==='disable'&&scope.row.is_use===0"
            type="danger">
            禁用
          </el-tag>
          <el-tag
            v-if="scope.row.handle_type==='updateTicketStatus'"
            type="primary">
            修改门票状态
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="old_play_date"
        label="旧游玩截止时间"
      >
      </el-table-column>
      <el-table-column
        prop="play_date"
        label="新游玩截止时间"
      >
      </el-table-column>
      <el-table-column
        prop="old_status"
        label="旧状态"
      >
      </el-table-column>
      <el-table-column
        prop="new_status"
        label="新状态"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      background
      :current-page.sync="form.pageNum"
      :page-size="10"
      layout="total, prev, pager, next"
      @current-change="getData"
      :total="total">
    </el-pagination>
  </div>
</template>
<script>
import { getTicketHandleLogs } from '@/api/order'
import moment from 'moment'

export default {
  components: {
  },
  data () {
    return {
      form: {
        startDate: new Date(moment().startOf('day').valueOf()),
        endDate: new Date(moment().endOf('day').valueOf()),
        keyWords1: '',
        keyWords2: '',
        keyWords3: '',
        pageNum: 1,
        pageSize: 10
      },
      loading: false,
      total: 0,
      tableData: []
    }
  },
  computed: {
    salesList () {
      return this.$store.state.user.salesList
    }
  },
  methods: {
    reset () {
      this.$refs.form.resetFields()
    },
    getData () {
      this.loading = true
      getTicketHandleLogs(this.form).then(res => {
        this.tableData = res?.data.list
        this.total = res?.data.total
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>
