<!--  -->
<template>
  <div>
    <el-alert
        title="手续费设置"
        type="info"
        :closable="false"
        style="margin-bottom: 20px"
      ></el-alert>

      <el-form ref="form" label-position="top" :model="form" label-width="120px"  :inline="true">
        <el-form-item label="手续费费率" prop="chargeRate"
          :rules="[{ required: true, message: '请输入手续费费率', trigger: 'blur' }]">
          <template slot="label">
            手续费费率
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">
                每笔交易支付通道收取的手续费比例
              </div>
              <i
                class="el-icon-question"
                style="
                  font-size: 18px;
                  color: #f56c6c;
                  position: relative;
                  top: 2px;
                "
              ></i>
            </el-tooltip>
          </template>
          <el-input
            :disabled="isDisabled"
            v-model="form.chargeRate"
            @keyup.native='keyupEvent($event)'
            placeholder="请输入手续费费率"
            style="width: 238px;"
            type="number"
          >
            <div slot="append">‰</div>
          </el-input>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
export default {
  props: ['type', 'data'],
  data () {
    return {
      form: {
        id: null,
        chargeRate: null
      }
    };
  },
  computed: {
    isDisabled() {
      return this.type == 'setting' ? true : false
    }
  },
  mounted () {
    if(this.data) {
      this.form.id = this.data.id
      this.form.chargeRate = this.data.chargeRate
    }
  },
  methods: {
    onSubmit() {
      let status = false
      this.$refs.form.validate(_ => {
        status = _
      })
      return status
    },
    getValues() {
      return this.form
    },
  },
};
</script>
<style lang='scss' scoped>
.el-input, .el-select {
  width: 300px !important;
}
</style>
