<template>
  <el-form
    inline
    label-width="100px"
    :model="form"
    class="form-wrap"
    ref="form">
    <div class="dialog-info">
      <el-form-item
        label="票种名称"
        v-if="currentLog.ticket_type_name">
        {{ currentLog.ticket_type_name }}
      </el-form-item>
      <el-form-item
        label="创建时间"
        v-if="currentLog.create_time">
        {{ currentLog.create_time | formatTime }}
      </el-form-item>
      <el-form-item
        verify
        label="导出序号"
        prop="minId">
        <el-input-number
          v-model="form.minId"
          :max="form.maxId"
          :step="1"
          :precision="0"></el-input-number>
      </el-form-item>
      <el-form-item
        verify
        label-width="40px"
        label="至"
        prop="maxId">
        <el-input-number
          v-model="form.maxId"
          :min="form.minId"
          :step="1"
          :precision="0"></el-input-number>
      </el-form-item>
    </div>
    <div class="dialog-btn-wrap">
      <el-button
        type="primary"
        @click="submit">
        确定
      </el-button>
    </div>
  </el-form>
</template>
<script>
import { ticketInStockPrint } from '@/api/ticketType'
export default {
  props: {
    currentLog: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      visible: false,
      form: {
        minId: 0,
        maxId: 0
      }
    }
  },
  watch: {
    visible (val) {
      if (val) {
        this.reset()
        this.form.minId = this.currentLog.min_id
        this.form.maxId = this.currentLog.max_id
      }
    }
  },
  methods: {
    reset () {
      this.$refs.form.resetFields()
    },
    handleClose () {
      this.$parent.handleClose()
    },
    submit () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          ticketInStockPrint(this.form).then(res => {
            this.$message.success('操作成功')
            this.handleClose()
            this.$emit('update')
          })
        }
      })
    }
  }
}
</script>
