Ver código fonte

客户查询支持模糊查询

lichao 3 anos atrás
pai
commit
d6f5eb79b8
1 arquivos alterados com 46 adições e 11 exclusões
  1. 46 11
      src/components/selectComponent/customerSelect.vue

+ 46 - 11
src/components/selectComponent/customerSelect.vue

@@ -7,7 +7,13 @@
         style="border-right: none;width: 100%"
         :disabled="disabled?disabled:false"
         :multiple="configuration.multiple?configuration.multiple:false"
-        :collapse-tags="configuration.collapseTags?configuration.collapseTags:false">
+        :clearable="configuration.clearable?configuration.clearable:false"
+        :collapse-tags="configuration.collapseTags?configuration.collapseTags:false"
+        filterable
+        remote
+        @change="changeName"
+        :remote-method="remoteMethod"
+    >
       <el-option
           v-for="item in configuration.dicData.length !== 0?dicData.length !== 0?dicData:configuration.dicData:dicData"
           :key="item.id"
@@ -41,7 +47,6 @@
                      ref="crud"
                      v-model="form"
                      :page.sync="page"
-                     :before-open="beforeOpen"
                      :before-close="beforeClose"
                      @search-change="searchChange"
                      @search-reset="searchReset"
@@ -115,13 +120,23 @@ export default {
         pageSize: 10,
         pagerCount: 5,
         total: 0,
-      }
+      },
+      // 远程模糊查找loading
+      loading: false,
+      queryParams: {
+        size: 10,
+        current: 1
+      },
     }
   },
   created() {
     this.option.searchShow = this.configuration.searchShow ? this.configuration.searchShow : false
+    this.remoteMethod()
   },
   methods: {
+    changeName(){
+      this.$emit('returnBack', this.value)
+    },
     //刷新触发
     refreshChange() {
       this.page = {
@@ -132,6 +147,7 @@ export default {
     },
     //确认导出触发
     confirmSelection() {
+      this.dicData = []
       if (this.configuration.multipleChoices === true) {
         let value = []
         for (let item in this.selection) {
@@ -146,6 +162,7 @@ export default {
       this.selection = []
       this.$emit('returnBack', this.value)
       this.dialogVisible = false
+      this.$emit('receiveList',this.dicData)
     },
     //选中触发
     selectionChange(selection) {
@@ -172,13 +189,6 @@ export default {
       column.addDisabled = true;
       this.$refs.crud.rowAdd();
     },
-    //新增跳转页面
-    beforeOpen(row, index) {
-      this.$router.push({
-        path: "/detailsPageEdit",
-        query: {id: JSON.stringify(row.id)},
-      });
-    },
     //点击新增时触发
     beforeClose(done) {
       this.parentId = "";
@@ -221,7 +231,32 @@ export default {
       customerList({parentId: parentId}).then(res => {
         resolve(res.data.data.records);
       });
-    }
+    },
+    // 远程模糊查找
+    remoteMethod(query) {
+      if (query !== '') {
+        this.loading = true;
+        this.queryParams = {
+          size: 10,
+          current: 1,
+          cname: query
+        }
+        customerList(this.queryParams).then(res => {
+          this.dicData = res.data.data.records
+          this.loading = false;
+        });
+      } else {
+        this.loading = true
+        this.queryParams = {
+          size: 10,
+          current: 1
+        }
+        customerList(this.queryParams).then(res => {
+          this.dicData = res.data.data.records
+          this.loading = false;
+        });
+      }
+    },
   }
 };
 </script>