<template>
  <div>
    <div v-if="mode === 'DESIGN'">
      <a-input
        :placeholder="placeholder"
        type="textarea"
        :autosize="{ minRows: 2, maxRows: 2 }"
        disabled
      />
    </div>
    <div v-else>
      <a-input
        v-if="!readerMode"
        v-model="innerValue"
        :placeholder="placeholder"
        type="textarea"
        :maxlength="255"
        :autosize="{ minRows: 3, maxRows: 3 }"
        allowClear
      />
      <div v-else v-text="innerValue"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TextareaInput',
  props: {
    mode: {
      type: String,
      default: 'DESIGN'
    },
    placeholder: {
      type: String,
      default: '请输入内容'
    },
    readerMode: {
      type: Boolean,
      default: false
    },
    value: {
      type: String,
      default: ''
    },
    showChinese: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      innerValue: this.value
    };
  },
  watch: {
    value(val) {
      this.innerValue = val;
    },
    innerValue(val) {
      this.$emit('update:value', val);
    }
  }
};
</script>

<style scoped lang="less"></style>
