114 lines
2.5 KiB
Vue
114 lines
2.5 KiB
Vue
<template>
|
|
<div >
|
|
<el-autocomplete
|
|
v-model="svalue"
|
|
:fetch-suggestions="querySearchAsync"
|
|
@select="handleSelect"
|
|
placeholder="请输入内容"
|
|
>
|
|
</el-autocomplete>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import { listUser } from "@/api/system/user";
|
|
|
|
export default {
|
|
name: "EmisUserPicker",
|
|
props: {
|
|
value: {
|
|
type: [String, Number],
|
|
required: false
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
optionItems: [],
|
|
svalue: this.value,
|
|
sideCode:null,
|
|
code:'',
|
|
// 原始数据
|
|
data: [],
|
|
// 搜索后的数据
|
|
filterData:[],
|
|
filterMap:new Map(),
|
|
// 选中的值
|
|
sel:'',
|
|
// 输入的值转为大写后
|
|
queryVal:'',
|
|
noDataText: '无数据',
|
|
loading: false,
|
|
queryParams:{
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
}
|
|
};
|
|
},
|
|
watch: {
|
|
value(newVal) {
|
|
this.svalue = newVal;
|
|
},
|
|
svalue(newVal, oldVal) {
|
|
if (newVal !== oldVal) {
|
|
this.$emit("input", this.svalue);
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
this.queryData();
|
|
},
|
|
methods: {
|
|
//queryString 为在框中输入的值
|
|
//callback 回调函数,将处理好的数据推回
|
|
querySearchAsync(queryString, callback) {
|
|
// var list = [{}];
|
|
// //调用的后台接口
|
|
// let url = 后台接口地址 + queryString;
|
|
// //从后台获取到对象数组
|
|
// axios.get( url ).then((response)=>{
|
|
// //在这里为这个数组中每一个对象加一个value字段, 因为autocomplete只识别value字段并在下拉列中显示
|
|
// for(let i of response.data){
|
|
// i.value = i.想要展示的数据; //将想要展示的数据作为value
|
|
// }
|
|
// list = response.data;
|
|
// callback(list);
|
|
// }).catch((error)=>{
|
|
// console.log(error);
|
|
// });
|
|
},
|
|
handleSelect(item) {
|
|
console.log(item);
|
|
//do something
|
|
},
|
|
}
|
|
};
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.el-s-thead{
|
|
width: 100%;
|
|
color: rgb(177 47 41);
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
display: inline-flex;
|
|
padding: 10px;
|
|
border-bottom: 1px solid #e6e3e3;
|
|
min-width: 500px;
|
|
}
|
|
|
|
.el-data{
|
|
width: 100%;
|
|
color: #000;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
display: inline-flex;
|
|
padding: 5px;
|
|
border-bottom: 1px solid #e6e3e3;
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|