textsearchplan.vue
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<style>
</style>
<template>
<div :class="class" :style="{overflow:'inherit',width:width}" >
<input type="text" id="cn1" v-model="value"
v-on:focus="focus" v-on:blur="blur" v-on:keyup="keyup">
<ul class="hint-list" v-bind:style="{width:widthul}"
v-show="show "
v-on:mouseover="over=1" v-on:mouseout="over=0">
<li v-for="item in list" v-on:click="check(item)">
<span>{{item.label}}</span>
</li>
<li v-show="list.length==0"><span>暂无结果</span></li>
</ul>
</div>
</template>
<script>
module.exports={
props:{
class:{
type:String,default:' control control-hint'
},
type:{
type:String,default:'1'
},width:{
type:String,default:'auto'
},widthul:{
type:String,default:'100%'
},value:[String,Number],host:{
type:String,default:'http://localhost:3003/'
},url:{
type:String,default:'search/'
},ms:{
type:String,default:300
},medguid:{
type:[String,Number],default:''
},guid:{
type:[String,Number],default:''
}
},
data:function(){
return {
show:false,list:[],settime:'',over:0,parameter:{
parameter_EQ_medguid:'',
parameter_LIKE_entrpname:''
}
}
},methods:{
getData:function(){
var that=this;
this.parameter.parameter_EQ_medguid=this.medguid;
this.parameter.parameter_LIKE_entrpname=this.value;
Ajax.get(this.url,this.parameter).then(function(res){
var result=res.data;
if(result.data){
that.$set('list',result.data);
}
})
},check:function(item){
this.value=item.label;
this.guid=item.VALUE;
this.show=false;
},focus:function(){
this.show=true;
this.clear();
},blur:function(){
if(this.over==false){
this.show=false;
}
},keyup:function(){
this.clear();
},clear:function(){
var that=this;
clearTimeout(this.settime);
this.settime=setTimeout(function(){
that.getData();
},this.ms)
}
}
}
</script>