<template>
  <el-input
    :id="id"
    ref="form-item"
    v-model="model"
		:style="{'border-bottom': isShowRed ? `1px solid ${isShowRed}` : ''}"
    type="textarea"
    v-bind="$attrs"
    v-on="$listeners"
    v-bind:disabled="isDisable"
    :rows="maxRows"
    resize="none"
    :placeholder="placeholderEnable || placeholder || $t('components.请输入')"
		@blur="blurEvent"
		@change="handleChange"
  />
</template>
<script>
import commonDepend from '~/mixin/commonDepend.js'
import markSetShowRed from '~/components/business/componentMixins/markSetShowRed.js'
export default {
	inject: {
		root: {
			default: () => null
		}
	},

	mixins: [commonDepend, markSetShowRed],
  props: {
    id: {
      type: String,
      default: undefined
    },
    value: {
      type: [String, Number],
      default: undefined
    },
    disabled: {
      type: Boolean,
      default: false
    },
    maxRows: {
      type: Number,
      default: 3
    },
    placeholder:{
      type: String,
      default: null
    },
    // 此对象为markset或者modifySet所在的对象,如果传了此对象可以标记当前对象下的字段为红色下划线
    markSetData: {
      type: Object,
      default: () => null
    },
		customModifykey: {
			type: String,
      default: null
		}
  },
  computed: {
    model: {
      get () {
        return this.value
      },
      set (newVal) {
        this.$emit('input', newVal)
      }
		},
		mode () {
      return this.$store.state.Status.mode
    },
    isDisable() {
			return this.mode === 'display' || this.disabled
		},
    placeholderEnable(){
      let label = this.$parent.label
      let curLabel = ''
      if (label) {
        curLabel = this.$i18n.locale === 'en' ? this.$t('components.请输入') + ' ' +  this.$t('components.' + label) : this.$t('components.请输入') + this.$t('components.' + label)
      }
      return curLabel
    },
  },
  watch: {
    disabled(newVal) {
      if (newVal) {
        this.resetValidate()
      }
    }
  },
  methods: {
		blurEvent () {
			this.$emit('blur', this.model)
		},
		handleChange () {
			if (!this.customModifykey) {
				// 添加isModify属性
				this.changeModify()
			}
		}
	}
}
</script>