<template>
  <button
    class="el-button"
    @click="handleClick"
    :disabled="buttonDisabled || loading"
    :autofocus="autofocus"
    :type="nativeType"
    :class="[
      type ? 'el-button--' + type : '',
      buttonSize ? 'el-button--' + buttonSize : '',
      {
        'is-disabled': buttonDisabled,
        'is-loading': loading,
        'is-plain': plain,
        'is-round': round,
        'is-circle': circle,
        'is-search': search,
        'is-normal': normal,
        'is-normaladd': normaladd,
        'is-delnone': delnone,
        'is-ifo': ifo,
        'is-dangerous': dangerous,
        'is-disposal': disposal,
        'is-addM': addM,
        'is-addedit': addedit,
        'is-normaledit': normaledit
      }
    ]"
  >
    <i class="el-icon-loading" v-if="loading"></i>
    <i style="font-size:24px; line-height: 4px;position: relative;top: 3px"  :class="icon" v-if="icon && !loading&&icon!='el-icon-my-edit'"></i>
     <i style="font-size:24px; line-height: 4px;position: relative;top: 3px;color:#4D6BFF"  :class="icon" v-if="icon && !loading&&icon=='el-icon-my-edit'"></i>
    <span v-if="$slots.default"><slot></slot></span>

  </button>
</template>
<script>
  export default {
    name: 'ElButton',
    inject: {
      elForm: {
        default: ''
      },
      elFormItem: {
        default: ''
      }
    },

    props: {
      type: {
        type: String,
        default: 'default'
      },
      size: String,
      icon: {
        type: String,
        default: ''
      },
      nativeType: {
        type: String,
        default: 'button'
      },
      loading: Boolean,
      disabled: Boolean,
      plain: Boolean,
      autofocus: Boolean,
      round: Boolean,
      circle: Boolean,
      normal: Boolean,
      normaladd: Boolean,
      delnone: Boolean,
      search: Boolean,
      ifo: Boolean,
      dangerous: Boolean,
      disposal: Boolean,
      addM: Boolean,
      addedit: Boolean,
      normaledit: Boolean
    },

    computed: {
      _elFormItemSize() {
        return (this.elFormItem || {}).elFormItemSize;
      },
      buttonSize() {
        return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
      },
      buttonDisabled() {
        return this.disabled || (this.elForm || {}).disabled;
      }
    },

    methods: {
      handleClick(evt) {
        this.$emit('click', evt);
      }
    }
  };
</script>
