VarText.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="fixedText" :class="{VarTextV2: headerTitleType === 'Head2'}">
  3. <div class="content">
  4. <div class="title" :class="{fontWeight: pageDate && pageDate.status > 20}">
  5. {{ name }}:
  6. </div>
  7. <div class="value">
  8. <el-input
  9. v-if="pageDate.status < 20"
  10. v-model="textValue"
  11. type="textarea"
  12. :placeholder="headerTitleType === 'Head2' ? `请针对${headerTitle}进行分析` : '请输入'"
  13. show-word-limit
  14. />
  15. <span
  16. v-if="pageDate.status > 10 && textValue"
  17. style="display: inline-block;line-height: 1.65; background-color: #f7f7f7; padding: 10px; border-radius: 5px;"
  18. v-html="textValue.replace(/\n/g, '<br />')"
  19. />
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { mapState } from 'vuex'
  26. import _ from 'lodash'
  27. export default {
  28. name: 'VarText',
  29. props: {
  30. title: {
  31. type: String,
  32. required: false,
  33. default: () => ''
  34. },
  35. headerTitle: {
  36. type: String,
  37. required: false,
  38. default: () => ''
  39. },
  40. headerTitleType: {
  41. type: String,
  42. required: false,
  43. default: () => ''
  44. },
  45. name: {
  46. type: String,
  47. required: false,
  48. default: () => ''
  49. },
  50. value: {
  51. type: String,
  52. required: false,
  53. default: () => ''
  54. }
  55. },
  56. data() {
  57. this.upData = _.debounce(this.upData, 800)
  58. return {
  59. textValue: ''
  60. }
  61. },
  62. computed: {
  63. ...mapState('monthlyReportEdit', ['pageType', 'pageDate'])
  64. // pageType() {
  65. // return this.$store.state.monthlyReportEditV2.pageType
  66. // },
  67. // pageDate() {
  68. // return this.$store.state.monthlyReportEditV2.pageDate
  69. // }
  70. },
  71. watch: {
  72. value(val) {
  73. this.textValue = val
  74. },
  75. textValue(val) {
  76. this.upData()
  77. }
  78. },
  79. mounted() {
  80. this.textValue = this.value
  81. },
  82. methods: {
  83. upData() {
  84. this.$emit('input', this.textValue)
  85. }
  86. }
  87. }
  88. </script>
  89. <style scoped lang="less">
  90. .fixedText {
  91. //margin-top: 10px;
  92. padding-top: 10px;
  93. .top-title {
  94. width: 100%;
  95. display: flex;
  96. &-content {
  97. flex: 1;
  98. padding: 10px 0;
  99. }
  100. .handle-box {
  101. flex: none;
  102. width: 50px;
  103. text-align: right;
  104. }
  105. }
  106. .content {
  107. width: 100%;
  108. display: flex;
  109. .title {
  110. //padding: 9px 0;
  111. flex: none;
  112. //font-weight: 600;
  113. color: #333;
  114. width: 50px;
  115. }
  116. .value {
  117. flex: 1;
  118. }
  119. }
  120. }
  121. .VarTextV2 {
  122. padding-top: 10px;
  123. margin-top: 5px;
  124. margin-bottom: 15px;
  125. //.content{
  126. // .title{
  127. // font-weight: 400;
  128. // }
  129. //}
  130. }
  131. .fontWeight {
  132. font-weight: 600;
  133. }
  134. </style>