<el-autocomplete
class="inline-input"
v-model="enterpriseForm.companyName"
:fetch-suggestions="querySearch"
@focus="groupListMe"
placeholder="请填写企业名称"
style="width: 400px"
@select="handleSelect"
></el-autocomplete>
watch:{
'enterpriseForm.companyName': {
deep: true,
handler: function (newVal,oldVal){
console.log(newVal, oldVal)
this.groupArr = [];
var len = this.groupList.length;
var arr = [];
for (var i = 0; i < len; i++) {
if (this.groupList[i].companyName.indexOf(newVal) >= 0) {
arr.push({
value: this.groupList[i].companyName,
id: this.groupList[i].id
})
}
}
this.groupArr = arr
}
}
},
methods: {
getCompanyInfoList(companyName) {
getCompanyInfo({
page: 1,
size: 999,
companyName
})
.then(res => {
if (res.code == 1) {
this.groupList = []
this.groupArr = []
this.groupList = res.data
for(let item of this.groupList) {
this.groupArr.push({
value: item.name,
id: item.id
})
}
}
})
},
querySearch(queryString, cb) {
var groupArr = this.groupArr;
cb(groupArr);
},
groupListMe() {
this.getCompanyInfoList(this.enterpriseForm.companyName)
},
}