InputItem.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="container">
  3. <span class="text-left" v-text="textLeft"></span>
  4. <!--<div class="expand"></div>-->
  5. <!--手机号-->
  6. <input
  7. class="edit-right"
  8. v-model="getInputText"
  9. :placeholder="textHolder"
  10. type="number"
  11. pattern="[0-9]*"
  12. onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
  13. @blur="blur"
  14. v-if="isNumber"
  15. />
  16. <!--所在地区-->
  17. <div class="disable-right" @click="click" v-if="isDisabled">
  18. <svg class="icon-left" aria-hidden="true">
  19. <use xlink:href="#icondingwei"></use>
  20. </svg>
  21. <input
  22. class="edit-right"
  23. v-model="getInputText"
  24. :placeholder="textHolder"
  25. disabled
  26. />
  27. <svg class="icon-right" aria-hidden="true">
  28. <use xlink:href="#iconchevronright"></use>
  29. </svg>
  30. </div>
  31. <!--文字类输入-->
  32. <input
  33. class="edit-right"
  34. v-model="getInputText"
  35. :placeholder="textHolder"
  36. @blur="blur"
  37. v-if="!isDisabled && !isNumber"
  38. />
  39. </div>
  40. </template>
  41. <script type="text/ecmascript-6">
  42. export default {
  43. name: 'InputItem',
  44. data() {
  45. return {
  46. inputText: ''
  47. };
  48. },
  49. props: {
  50. textLeft: {
  51. type: String,
  52. required: true,
  53. default: 'text-left-required!!!'
  54. },
  55. textDefault: {
  56. type: String
  57. },
  58. textHolder: {
  59. type: String
  60. // default: null
  61. },
  62. isNumber: {
  63. type: Boolean
  64. },
  65. isDisabled: {
  66. type: Boolean
  67. }
  68. },
  69. computed: {
  70. getInputText: {
  71. get: function() {
  72. // console.log('getInputText', 'text',this.inputText, 'def',this.textDefault)
  73. this.inputText = this.textDefault;
  74. return this.inputText;
  75. },
  76. set: function(newText) {
  77. this.inputText = newText;
  78. this.$emit('getText', this.inputText);
  79. }
  80. }
  81. },
  82. methods: {
  83. blur() {
  84. this.$emit('blur', this.inputText);
  85. },
  86. click() {
  87. this.$emit('click', this.inputText);
  88. }
  89. },
  90. watch: {
  91. textDefault(newValue, oldValue) {
  92. // console.log('getTebxtst', newValue,oldValue)
  93. this.$emit('getText', this.textDefault);
  94. }
  95. },
  96. mounted() {
  97. // console.log('textDefault', this.textDefault)
  98. }
  99. };
  100. </script>
  101. <style lang="stylus" rel="stylesheet/stylus" scoped>
  102. @import '~assets/mobile.styl';
  103. .container {
  104. display: flex;
  105. justify-content: flex-end;
  106. align-items: center;
  107. flex-wrap: nowrap;
  108. background: white;
  109. height: vw(66);
  110. line-height: vw(66);
  111. word-vw(14, gray3);
  112. }
  113. .text-left {
  114. padding-left: cellPadding;
  115. flex: 0.3;
  116. /* border salmon 1px solid */
  117. }
  118. .disable-right {
  119. /* border 1px slateblue solid */
  120. height: vw(66);
  121. display: flex;
  122. flex: 1;
  123. flex-direction: row;
  124. flex-wrap: nowrap;
  125. align-items: center;
  126. }
  127. /* .expand {
  128. flex 1
  129. } */
  130. .edit-right {
  131. background-color: grayF;
  132. text-align: left;
  133. padding-right: vw(15);
  134. flex: 1;
  135. height: vw(19);
  136. line-height: vw(19);
  137. ellipsis();
  138. /* border salmon 1px solid */
  139. }
  140. .icon-right {
  141. margin-right: cellPadding;
  142. width: vw(10);
  143. height: vw(15);
  144. overflow: hidden;
  145. fill: gray9;
  146. display: flex;
  147. justify-content: center;
  148. }
  149. .icon-left{
  150. web-icon(18,second-color)
  151. }
  152. ::-webkit-input-placeholder {
  153. word-vw(12, gray9);
  154. }
  155. :-moz-placeholder {
  156. word-vw(12, gray9);
  157. }
  158. ::-moz-placeholder {
  159. word-vw(12, gray9);
  160. }
  161. :-ms-input-placeholder {
  162. word-vw(12, gray9);
  163. }
  164. </style>