MultiLineInput.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.number="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. },
  37. data(){
  38. return {
  39. content:{},
  40. txt:this.part.value || '', //回读用
  41. }
  42. },
  43. mounted(){
  44. this.content = getModelExpStr(this.msg)
  45. },
  46. methods:{
  47. changeVal(){
  48. // this.$emit('changeMultipVal',this.txt)
  49. },
  50. blur(){
  51. const newData = Object.assign({},this.part,{value:this.txt,controlType:3});
  52. this.$emit("updata",newData);
  53. this.$emit('handleInp',this.txt);
  54. }
  55. },
  56. watch:{
  57. part:{//清空时更新
  58. handler(newVal,oldVal){
  59. this.txt = newVal.value;
  60. },
  61. deep:true
  62. }
  63. },
  64. }
  65. </script>
  66. <style lang="less" scoped>
  67. .multipIpt {
  68. width: 100%;
  69. height: .74rem /* 74/100 */;
  70. line-height: .74rem /* 74/100 */;
  71. // border: 1px solid #DFE0E4;
  72. // border-radius: .08rem /* 8/100 */;
  73. padding: 0 .12rem 0 .26rem;
  74. box-sizing: border-box;
  75. position: relative;
  76. margin: .3rem 0;
  77. .contentVal {
  78. font-size: .3rem /* 30/100 */;
  79. color: #4F50FF;
  80. text-align: left;
  81. border: 0 none;
  82. border-bottom: 1px solid #b0afaf !important;
  83. border-radius: 0;
  84. background-color: #fff;
  85. outline-color: invert;
  86. height: .36rem;
  87. line-height: .36rem;
  88. width: 100%;
  89. padding:0 0.1rem;
  90. box-sizing: border-box;
  91. }
  92. }
  93. .border{
  94. border: 1px solid #DFE0E4;
  95. border-radius: .08rem
  96. }
  97. .inline{
  98. display: inline-block;
  99. vertical-align: middle;
  100. color: #7C828E;
  101. padding: 0;
  102. margin:0;
  103. height: auto /* 74/100 */;
  104. line-height: .36rem /* 74/100 */;
  105. }
  106. .prefix {
  107. float: left;
  108. }
  109. .suffix {
  110. position: absolute;
  111. right: .12rem;
  112. top: 0;
  113. width: 1rem;
  114. text-align: right;
  115. text-align: left;
  116. }
  117. .sticP {
  118. width: 100%;
  119. // position: relative;
  120. padding-right: 1rem;
  121. box-sizing: border-box;
  122. .iptWrap {
  123. // width: 100%;
  124. position: relative;
  125. overflow: hidden;
  126. }
  127. }
  128. .check{
  129. color: #4F50FF;
  130. }
  131. </style>