单选
<el-autocomplete size="mini" v-model="form.projectLeader" :fetch-suggestions="userAutoSearch" @select="val => userAutoSelect(1, val)" clearable @clear="handleProjectNumberOfPeople" :disabled="currentPhase == '项目已完成'" placeholder="请输入项目负责人">
<template slot-scope="{ item }">
{{ item.pinyin + ' ' + item.userCode }}
</template>
</el-autocomplete>
userAutoSearch(queryString, cb) {
if (queryString.trim() == '') {
cb([])
}
else {
let that = this
let _data = {
searchParam: queryString,
returnDataType: 1
}
that.$store.dispatch('peopleAccosiation', _data).then((res) => {
cb(res.data)
}, (err) => {
console.log(err.message)
})
}
},
userAutoSelect(_no, val) {
let _user = val.pinyin + ' ' + val.userCode
if (_no == 1) {
this.form.projectLeader = _user
this.handleProjectNumberOfPeople()
}
else {
}
}
多选
<el-select size="mini" v-model="form.TC" :disabled="currentPhase == '项目已完成'" multiple filterable clearable remote :remote-method="userSearch" @change="handleReportTo" placeholder="请输入TC" :loading="userLoading">
<el-option v-for="(user, index) in userSearchData" :key="index" :value="user.pinyin + ' ' + user.userCode"></el-option>
</el-select>
userSearch(val) {
let that = this
if (val.trim() == '') {
that.userSearchData = []
}
else {
that.userLoading = true
let _data = {
searchParam: val,
returnDataType: 1
}
that.$store.dispatch('peopleAccosiation', _data).then((res) => {
that.userSearchData = res.data
that.userLoading = false
}, (err) => {
console.log(err.message)
that.userLoading = false
})
}
},