Browse Source

用户查询组件优化(0。2)

洪海涛 4 years ago
parent
commit
4b3b460670
1 changed files with 3 additions and 24 deletions
  1. 3 24
      src/components/select/searchPeople.vue

+ 3 - 24
src/components/select/searchPeople.vue

@@ -77,7 +77,6 @@ export default {
   watch: {
     value: {
       handler(newV, oldV) {
-        // console.log({ newV, oldV })
         if (this.searchValue === newV) {
           return
         }
@@ -88,7 +87,7 @@ export default {
         }
         const type = Object.prototype.toString.call(this.searchValue)
         if (type.indexOf('Array') < 0) {
-          this.searchPeople(this.searchValue, true)
+          this.getMember(this.searchValue)
         } else if (type.indexOf('Array') > 0 && this.searchValue.length > 0 && this.firstGetArr) {
           this.initMore(this.searchValue)
           this.firstGetArr = false
@@ -103,16 +102,13 @@ export default {
   methods: {
     remoteMethod: _.debounce(function(query, initMore = false) {
       query !== '' ? this.getMember(query, initMore) : this.options = []
-    }, 700),
+    }, 2000),
     searchPeople(query, initMore = false) {
       this.loading = true
       this.remoteMethod(query, initMore)
     },
     initMore(arr) { // 当多人时候,对数组每一个人员进行搜索
       if (this.multiple) {
-        // for (const item of arr) {
-        //   this.getMember(item, true)
-        // }
         this.getMember(arr, true)
       } else {
         this.getMember(arr, true)
@@ -139,24 +135,7 @@ export default {
      * @param initMore[Boolean]    搜索时,当有原始数据存在时,必然需要去重,否则会导致人员可选数据重复[true:初始化;false:用户搜索时]
      */
     arrayNonRepeatfy(data, initMore = false) {
-      this.options = initMore ? data.map(e => e) : Array.from(new Set([...this.options, ...data]))
-      // console.log(this.options, data, 139)
-      // const weakMap = new Map()
-      // for (const item of data) {
-      //   if (!weakMap.has(item.idap)) {
-      //     weakMap.set(item.idap, item)
-      //   }
-      // }
-      // let op = null
-      // const hash = {}
-      // const item = []
-      // initMore ? op = [...this.options, ...weakMap.values()] : op = [...weakMap.values()]
-      // op.map(t => {
-      //   if (!hash[t.deptid]) {
-      //     hash[t.deptid] = true && item.push(t)
-      //   }
-      // })
-      // this.options = item
+      this.options = !initMore ? data.map(e => e) : Array.from(new Set([...this.options, ...data]))
     },
     changeSelect(e) {
       if (this.searchValue === [] || this.searchValue === '') {