You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

117 lines
2.3 KiB

  1. <template>
  2. <view v-if="!simpleMode">
  3. <view class="cu-form-group" style="border-bottom: none">
  4. <view class="title">
  5. <text v-if="required" class="lr-required">*</text>
  6. {{ title }}
  7. </view>
  8. </view>
  9. <view class="cu-form-group" style="position: relative;border-top: none">
  10. <textarea
  11. @input="textareaInput"
  12. @focus.stop.prevent
  13. :maxlength="maxlength"
  14. :placeholder="displayPlaceHolder"
  15. :fixed="fixed"
  16. :value="display"
  17. :auto-height="autoHeight"
  18. :readonly="readonly"
  19. style="margin-top:0;"
  20. ></textarea>
  21. <cover-view v-if="readonly" @click.stop.prevent class="textarea-mask"></cover-view>
  22. </view>
  23. </view>
  24. <view v-else class="cu-form-group" style="position: relative;">
  25. <textarea
  26. @input="textareaInput"
  27. @focus.stop.prevent
  28. :maxlength="maxlength"
  29. :placeholder="displayPlaceHolder"
  30. :fixed="fixed"
  31. :value="display"
  32. :auto-height="autoHeight"
  33. :readonly="readonly"
  34. :style="textareaStyle"
  35. ></textarea>
  36. <cover-view v-if="readonly" @click.stop.prevent class="textarea-mask"></cover-view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'l-textarea',
  42. props: {
  43. maxlength: { default: -1 },
  44. readonly: {},
  45. placeholder: {},
  46. fixed: {},
  47. value: {},
  48. textareaStyle: {},
  49. autoHeight: {},
  50. simpleMode: {},
  51. required: {},
  52. title: {},
  53. },
  54. data() {
  55. return {
  56. hide: false
  57. }
  58. },
  59. // #ifdef MP-WEIXIN
  60. beforeMount() {
  61. uni.$on('modal', this.handelModal)
  62. },
  63. beforeDestroy() {
  64. uni.$off('modal', this.handelModal)
  65. },
  66. // #endif
  67. methods: {
  68. textareaInput(e) {
  69. this.$emit('change', e.detail.value)
  70. this.$emit('input', e.detail.value)
  71. },
  72. // #ifdef MP-WEIXIN
  73. handelModal(modal) {
  74. this.hide = !!modal
  75. }
  76. // #endif
  77. },
  78. computed: {
  79. display() {
  80. return this.hide ? '' : this.value
  81. },
  82. displayPlaceHolder() {
  83. if (this.readonly || this.hide) {
  84. return ''
  85. }
  86. if (this.placeholder) {
  87. return this.placeholder
  88. }
  89. return !this.simpleMode && this.title ? `请输入${this.title}` : '请输入…'
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="less" scoped>
  95. .textarea-mask {
  96. z-index: 999;
  97. position: absolute;
  98. bottom: 0;
  99. top: 0;
  100. left: 0;
  101. right: 0;
  102. }
  103. </style>