MultiLineInput.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div :class="['multipIpt',{'border':border,'inline':inline,'check':select}]">
  3. <span class="prefix" v-if="content.prefix">{{content.prefix}}</span>
  4. <div class="sticP" :style="{paddingRight:content.suffix?'1rem':'0'}">
  5. <div class="iptWrap">
  6. <input class="contentVal" :type="content.type" :placeholder="content.placeholder" v-model="txt" @input="changeVal" @blur="blur">
  7. </div>
  8. </div>
  9. <span class="suffix" v-if="content.suffix">{{content.suffix}}</span>
  10. </div>
  11. </template>
  12. <script>
  13. import { getModelExpStr } from '@utils/tools';
  14. export default {
  15. props:{
  16. msg:{
  17. default:'',
  18. type:String
  19. },
  20. part:{
  21. type:Object,
  22. require: true
  23. },
  24. border:{//最外层边框
  25. default:true,
  26. type:Boolean
  27. },
  28. inline:{ //是否行内元素
  29. default:false,
  30. type:Boolean
  31. },
  32. select:{ //是否选中
  33. default:false,
  34. type:Boolean
  35. },
  36. value:{ //回读的值
  37. default:'',
  38. type:String
  39. }
  40. },
  41. data(){
  42. return {
  43. content:{},
  44. txt:this.part.value || '', //回读用
  45. val:this.value
  46. }
  47. },
  48. mounted(){
  49. this.content = getModelExpStr(this.msg)
  50. },
  51. methods:{
  52. changeVal(){
  53. this.$emit('changeMultipVal',this.txt)
  54. },
  55. blur(){
  56. const newData = Object.assign({},this.part,{value:this.txt,controlType:3});
  57. this.$emit("updata",newData);
  58. this.$emit('handleInp',this.txt)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="less" scoped>
  64. .multipIpt {
  65. width: 100%;
  66. height: .74rem /* 74/100 */;
  67. line-height: .74rem /* 74/100 */;
  68. // border: 1px solid #DFE0E4;
  69. // border-radius: .08rem /* 8/100 */;
  70. padding: 0 .12rem 0 .26rem;
  71. box-sizing: border-box;
  72. position: relative;
  73. margin: .3rem 0;
  74. .contentVal {
  75. font-size: .3rem /* 30/100 */;
  76. color: #4F50FF;
  77. text-align: left;
  78. border: 0 none;
  79. border-bottom: 1px solid #b0afaf !important;
  80. border-radius: 0;
  81. background-color: #fff;
  82. outline-color: invert;
  83. height: .36rem;
  84. line-height: .36rem;
  85. width: 100%;
  86. padding:0 0.1rem;
  87. box-sizing: border-box;
  88. }
  89. }
  90. .border{
  91. border: 1px solid #DFE0E4;
  92. border-radius: .08rem
  93. }
  94. .inline{
  95. display: inline-block;
  96. vertical-align: middle;
  97. color: #7C828E;
  98. padding: 0;
  99. margin:0;
  100. height: auto /* 74/100 */;
  101. line-height: .36rem /* 74/100 */;
  102. }
  103. .prefix {
  104. float: left;
  105. }
  106. .suffix {
  107. position: absolute;
  108. right: .12rem;
  109. top: 0;
  110. width: 1rem;
  111. text-align: right;
  112. text-align: left;
  113. }
  114. .sticP {
  115. width: 100%;
  116. // position: relative;
  117. padding-right: 1rem;
  118. box-sizing: border-box;
  119. .iptWrap {
  120. // width: 100%;
  121. position: relative;
  122. overflow: hidden;
  123. }
  124. }
  125. .check{
  126. color: #4F50FF;
  127. }
  128. </style>