<template>
  <el-form
    label-width="160px"
    ref="form"
    :class="className"
    :model="form"
    label-suffix=": "
  >
    <el-form-item
    v-if="!hideMoney"
      label="课程金额(元)"
      prop="paymentAmount"
      :rules="[{required: true, message: '请输入缴费金额', trigger: 'blur'}]"
    >
      <el-input-number
        class="number-input"
        v-model="form.paymentAmount"
        :controls="false"
        :precision="0"
        :min="0"
        @change="paymentAmountChange"
        :disabled="isDisabled"
        placeholder="请输入缴费金额"
      />
    </el-form-item>
    <el-form-item
      label="缴费方式"
      prop="paymentPattern"
      v-if="!hidePaymentPattern"
      :rules="[{required: true, message: '请选择缴费方式', trigger: 'change'}]"
    >
      <el-select style="width: 100%!important;" v-model="form.paymentPattern" placeholder="请选择缴费方式">
        <el-option
          v-for="item in paymentPatternTypeOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item
      label="缴费时间"
      prop="paymentDate"
      v-if="isUserType"
      :rules="[{required: true, message: '请选择缴费时间', trigger: 'blur'}]"
    >
      <el-date-picker
        v-model="form.paymentDate"
        type="daterange"
        style="width: 100%;"
          :picker-options="pickerOptions"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
    </el-form-item>

    <el-form-item
      label="缴费有效期"
      prop="paymentValid"
      v-if="courseViewType!=2 || (courseViewType==2&&paymentType=== undefined)"
      :rules="[{required: true, message: '请选择缴费有效期', trigger: 'blur'}]"
    >
      <el-date-picker
        v-model="form.paymentValid"
         :picker-options="pickerOptions"
        type="daterange"
        style="width: 100%;"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
    </el-form-item>
  </el-form>
</template>
<script>
import { paymentPatternType } from '@/constant'
import { objectToOptions } from '@/utils'
export default {
  props: ['form', 'className', 'isUserType', 'isDisabled', 'isCommon', 'hidePaymentPattern','hideMoney','courseViewType','paymentType'],
  data() {
    return {
      paymentPatternTypeOptions: objectToOptions(paymentPatternType),
         pickerOptions: {
        firstDayOfWeek: 1,
        disabledDate (time) {
          return time.getTime() + 86400000 <= new Date().getTime();
        },
      },
    }
  },
  mounted(){
    // console.log(this.paymentType)
  },
  methods: {
    paymentAmountChange() {
      this.$set(this.form, 'changeed', true)
    }
  }
}
</script>
<style lang="less" scoped>
.number-input{
  /deep/ .el-input__inner {
    text-align: left;
  }

  width: 100%;
}
</style>
