123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <!-- 带输入框选项 -->
- <template>
- <div :class="['inpbox',{'check':item.select}]">
- <span class="prefix" v-if="msg.prefix">{{msg.prefix}}</span>
- <div class="inp" @click="preClick">
- <input :type="msg.type=='number'?'tel':'text'"
- :placeholder="msg.placeholder"
- :disabled="select!=1"
- v-model="txt"
- @click="handleCli"
- @blur="handleBlur"
- @input="changeVal">
- </div>
- <span class="suffix" v-if="msg.suffix">{{msg.suffix}}</span>
- </div>
- </template>
- <script type="text/javascript">
- import { getExpStr,scrollToV} from '@utils/tools';
- export default {
- name:'OptionInp',
- data(){
- return{
- msg:{},
- txt:this.item.value || '',
- select:0
- }
- },
- props:['item'],
- mounted(){
- this.msg = getExpStr(this.item.name);
- this.select = this.item.select;
- },
- methods:{
- changeVal(e){
- if(this.msg.type=='number'){//数字键盘
- this.txt = e.target.value=e.target.value.replace(/[^\d]/g,'')
- }
- },
- handleBlur(){
- // 如果该项未选中,则不存值
- // const select = this.item.select;
- // if(!select){return}
- const newData = Object.assign({},this.part,{value:this.txt});
- this.$emit("updata",newData);
- this.$emit('handleInp',this.txt);
- },
- preClick(e){
- e.stopPropagation();
- },
- handleCli(e){
- scrollToV(e)
- }
- },
- watch:{
- item:{//清空时更新
- handler(newVal,oldVal){
- this.txt = newVal.value;
- this.select = newVal.select;
- },
- deep:true
- }
- },
- }
- </script>
- <style lang="less" scoped>
- .inpbox{
- color:#7C828E;
- display: inline-block;
- .inp{
- display: inline-block;
- vertical-align: top;
- input{
- color: #4F50FF;
- font-size: .3rem;
- border-bottom: 1px solid #DFE0E4 !important;
- border-radius: 0;
- padding-left: .05rem;
- }
- }
- .check{
- color: #4F50FF;
- }
- }
- </style>
|