OptionInp.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!-- 带输入框选项 -->
  2. <template>
  3. <div :class="['inpbox',{'iptCheck':item.select}]">
  4. <span class="prefix" v-if="msg.prefix">{{msg.prefix}}</span>
  5. <input :type="msg.type=='number'?'number':'text'"
  6. :placeholder="msg.placeholder"
  7. :style="{'width':!msg.prefix&&!msg.suffix?'90%':'33%'}"
  8. :class="[{'cancel':item.select==0}]"
  9. v-model="txt"
  10. @click="handleCli"
  11. @input="changeVal"
  12. @blur="handleBlur">
  13. <span class="suffix" v-if="msg.suffix">{{msg.suffix}}</span>
  14. </div>
  15. </template>
  16. <script type="text/javascript">
  17. import { getExpStr,isIos} from '@utils/tools';
  18. import $ from 'jquery';
  19. export default {
  20. name:'OptionInp',
  21. props:['item','inx'],
  22. data(){
  23. return{
  24. msg:{},
  25. txt:this.item.value || '',
  26. select:0,
  27. url:[require('../images/iptselect.png'),require('../images/iptdis.png')]
  28. }
  29. },
  30. mounted(){
  31. const text = this.item.description || this.item.name;
  32. this.msg = getExpStr(text);
  33. this.select = this.item.select;
  34. },
  35. methods:{
  36. changeVal(e){
  37. if(this.msg.type=='number'){//数字键盘
  38. this.txt = e.target.value=e.target.value.replace(/^\.$/,'')
  39. }
  40. },
  41. handleBlur(){
  42. this.$emit('handleInp',this.txt,this.inx);
  43. /*setTimeout(()=>{
  44. $(".foot").css({'display':'block'})
  45. },150)*/
  46. },
  47. handleCli(e){
  48. if(this.select){//已选中后点击输入框不取消选中
  49. e.stopPropagation();
  50. }
  51. }
  52. },
  53. watch:{
  54. item:{//清空时更新
  55. handler(newVal,oldVal){
  56. this.txt = newVal.value;
  57. this.select = newVal.select;
  58. },
  59. deep:true
  60. }
  61. },
  62. }
  63. </script>
  64. <style lang="less" scoped>
  65. @import '../less/base.less';
  66. .inpbox{
  67. color:#colors[text];
  68. display: inline-block;
  69. width: 100%;
  70. white-space: normal;
  71. vertical-align: middle;
  72. height: .68rem;
  73. line-height: .68rem;
  74. margin-bottom:.08rem;
  75. .prefix,.suffix{
  76. display: inline-block;
  77. vertical-align: middle;
  78. }
  79. input{
  80. height: 100%;
  81. color: #colors[btn];
  82. font-size: .26rem;
  83. border-bottom: 1px solid #E6E6E6 !important;
  84. border-radius: 0;
  85. padding-left: .05rem;
  86. background-color: transparent;
  87. position: relative;
  88. top: 1px;
  89. box-sizing: border-box;
  90. &.cancel{
  91. color:#ccc ;
  92. }
  93. }
  94. }
  95. .iptCheck{
  96. span{
  97. color: #colors[btn];
  98. }
  99. }
  100. </style>