<template>
  <el-form
    class="info-form"
    inline
    label-width="150px">
    <el-form-item label="票种">
      {{ form.ticketTypeName }}
    </el-form-item>
    <el-form-item label="分销商">
      {{ form.otaSourceName }}
    </el-form-item>
    <el-form-item label="合作价格">
      {{ form.salePrice }}
    </el-form-item>
    <el-form-item label="起售日期">
      {{ formatDate(form.sellStartDate) }}
    </el-form-item>
    <el-form-item label="停售日期">
      {{ formatDate(form.sellEndDate) }}
    </el-form-item>
    <el-form-item label="可售时间">
      {{ form.sale_time_start }} - {{ form.sale_time_end }}
    </el-form-item>
    <el-form-item label="当日可售时间">
      {{ form.sale_time_start }} - {{ form.sale_time_end }}
    </el-form-item>
    <el-form-item label="最小提前预订天数">
      {{ form.min_preorder_days }} 天
    </el-form-item>
    <el-form-item label="最大提前预订天数">
      {{ form.max_preorder_days }} 天
    </el-form-item>
    <el-form-item label="是否可退">
      {{ form.is_refund | yesOrNo }}
    </el-form-item>
    <el-form-item label="退票提前天数">
      {{ form.refund_advanceDays }} 天
    </el-form-item>
    <el-form-item label="退票价格">
      {{ form.refund_price }} 元
    </el-form-item>
    <el-form-item label="当日游玩时段">
      {{ form.useTimeStart + ' - '+ form.useTimeEnd }}
    </el-form-item>
    <el-form-item label="是否上传二维码">
      {{ form.is_qrcode | yesOrNo }}
    </el-form-item>
    <el-form-item label="线下产品数量">
      {{ form.offline_count }}
    </el-form-item>
    <el-form-item label="可提前使用天数">
      {{ form.advanceDays }} 天
    </el-form-item>
    <el-form-item label="可延后使用天数">
      {{ form.delay_days }} 天
    </el-form-item>
    <el-form-item label="游玩开始日期">
      {{ formatDate(form.useStartDate) }}
    </el-form-item>
    <el-form-item label="游玩截止日期">
      {{ formatDate(form.useEndDate) }}
    </el-form-item>
    <el-form-item label="游玩天数">
      {{ form.useValidDays }} 天
    </el-form-item>
    <el-form-item label="最小起订数">
      {{ form.minOrderNum }} 张
    </el-form-item>
    <el-form-item label="最大限订数">
      {{ form.maxOrderNum }} 张
    </el-form-item>
    <p class="form-title">身份证规则</p>
    <el-form-item label="性别">
      {{ form.idcard_sex_limit | sexFilter }}
    </el-form-item>
    <el-form-item label="年龄限制">
      {{ form.idcard_age_min }} - {{ form.idcard_age_max || '不限' }}
    </el-form-item>
    <el-form-item
      label="每个身份证"
      v-if="form.realname_limit_days && form.realname_limit_count">
      {{ form.idcard_limit_days }}天内购买{{ form.idcard_limit_count }}张
    </el-form-item>
    <p class="form-title">实名制规则</p>
    <el-form-item label="性别">
      {{ form.realname_sex_limit | sexFilter }}
    </el-form-item>
    <el-form-item label="年龄限制">
      {{ form.realname_age_min }} - {{ form.realname_age_max || '不限' }}
    </el-form-item>
    <el-form-item
      label="每个身份证"
      v-if="form.realname_limit_days && form.realname_limit_count">
      {{ form.realname_limit_days }}天内购买{{ form.realname_limit_count }}张
    </el-form-item>
  </el-form>
</template>

<script>
import moment from 'moment'
export default {
  props: {
    currentItem: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      visible: false,
      form: {}
    }
  },
  watch: {
    visible (val) {
      // 初始化编辑数据
      if (val) {
        if (this.currentItem) {
          console.log(this.currentItem)
          this.form = Object.assign({}, this.currentItem)
          this.form.check_gap_seconds = this.form.check_gap_seconds / 60
          this.form.check_pattern && (this.patternArr = this.form.check_pattern.split(','))
          this.form.useTimeStart = this.form.useTimeStart || '08:00:00'
          this.form.useTimeEnd = this.form.useTimeEnd || '20:00:00'
          this.form.useTime = [
            this.form.useTimeStart,
            this.form.useTimeEnd
          ]
          this.form.sellDate = [
            this.form.sellStartDate,
            this.form.sellEndDate
          ]
          this.form.useDate = [
            this.form.useStartDate,
            this.form.useEndDate
          ]
        }
      }
    }
  },
  methods: {
    handleClose () {
      this.$parent.handleClose()
    },
    formatDate (val) {
      return moment(val).format('YYYY-MM-DD')
    }
  }
}
</script>
