|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
+ <!-- @focus="onFocus" -->
|
|
|
<el-select
|
|
|
v-bind="{...$attrs}"
|
|
|
:value="value"
|
|
@@ -10,7 +11,7 @@
|
|
|
:multiple="multiple"
|
|
|
:placeholder="placeholder"
|
|
|
:remote-method="remoteMethod"
|
|
|
- @focus="remoteMethod"
|
|
|
+
|
|
|
:loading="loading"
|
|
|
@change="changeValue"
|
|
|
:style="{ width: this.selectWidt + 'px!important' }"
|
|
@@ -68,17 +69,19 @@ export default {
|
|
|
this.list.length <= this.constant
|
|
|
? this.list
|
|
|
: slice(this.list, 0, this.constant);
|
|
|
-
|
|
|
+ this.options = uniqBy(this.options, 'userId')
|
|
|
// console.log(this.options)
|
|
|
},
|
|
|
remoteMethod(query) {
|
|
|
// throttle
|
|
|
+
|
|
|
throttle(this.getOptions, 800)(query);
|
|
|
},
|
|
|
async getOptions(query) {
|
|
|
+
|
|
|
if (query&&query.length>0) {
|
|
|
let flag;
|
|
|
- this.options = this.list.filter((item) => {
|
|
|
+ this.options = uniqBy(this.list.filter((item) => {
|
|
|
flag =
|
|
|
item.userName.toLowerCase().indexOf(query.toString().toLowerCase()) > -1 ||
|
|
|
item.userId == query;
|
|
@@ -88,7 +91,7 @@ export default {
|
|
|
// console.log(query,this.value)
|
|
|
return flag || item.userId == this.value;
|
|
|
}
|
|
|
- });
|
|
|
+ }), 'userId')
|
|
|
} else {
|
|
|
try{
|
|
|
await this.getList()
|
|
@@ -106,10 +109,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
changeValue(val) {
|
|
|
+ console.log('调用changeValue')
|
|
|
this.isFirst = false;
|
|
|
this.$emit("input", val);
|
|
|
this.$emit("change", val);
|
|
|
+
|
|
|
},
|
|
|
+ onFocus(val){
|
|
|
+
|
|
|
+ // getOptions
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
computed: {
|
|
|
enumer() {
|
|
@@ -125,7 +135,7 @@ export default {
|
|
|
deep: true,
|
|
|
handler(val) {
|
|
|
// && this.isFirst
|
|
|
- if (this.multiple) {
|
|
|
+ if (this.multiple&& this.isFirst) {
|
|
|
if (val?.length > 0 ) {
|
|
|
this.getOptions()
|
|
|
}
|