<template>
  <div>
    <el-form
      inline
      class="dialog-info"
      label-width="100px">
      <div class="block-title">
        门票信息
      </div>
      <el-form-item
        label="票号">
        {{ info.ticketNo }}
      </el-form-item>
      <el-form-item
        label="取票码">
        {{ info.selfservice_code }}
      </el-form-item>
      <el-form-item
        label="票种">
        {{ info.tname }}
      </el-form-item>
      <el-form-item
        label="票价">
        {{ info.price }} 元
      </el-form-item>
      <el-form-item
        label="状态">
        {{ info.status | ticketStatus }}
      </el-form-item>
      <el-form-item
        label="游客">
        {{ info.guestName }}
      </el-form-item>
      <el-form-item
        label="手机号码">
        {{ info.guestPhone }}
      </el-form-item>
      <el-form-item
        label="证件号码">
        {{ info.guestIdentify }}
      </el-form-item>
    </el-form>
    <div class="dialog-btn-wrap">
      <el-button
        @click="submit"
        type="primary">
        确定
      </el-button>
    </div>
  </div>
</template>

<script>
import { printTicket } from '@/api/printOnlineTicket'

export default {
  props: {
    info: {
      type: Object,
      default: () => {}
    },
    ticketType: {
      type: Object,
      default: () => {}
    },
    orderInfo: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      currentPrint: null, // 当前打印的票
      printPlayDateBegin: ''
    }
  },
  methods: {
    handleClose () {
      this.$parent.handleClose()
    },
    submit () {
      let params = {
        ticketList: [this.info.ticketNo]
      }
      printTicket(params).then(res => {
        this.$message.success('取票成功')
        this.info.orderNo = this.orderInfo.orderNo
        this.info.createTime = this.orderInfo.createTime
        this.currentTicket = this.info
        this.currentTicket.hidePrice = true
        // 打印单张门票
        this.$print(null, this.currentTicket)

        this.$emit('updateList')
        this.handleClose()
      })
    }
  }
}
</script>
