Browse Source

采购订单详情-参照可以进行搜索

002390 1 year ago
parent
commit
6cca19d28d
1 changed files with 74 additions and 2 deletions
  1. 74 2
      src/components/popover-select/index.vue

+ 74 - 2
src/components/popover-select/index.vue

@@ -146,6 +146,22 @@ export default {
         });
         if (code === 200) {
           this.data = rows;
+          // 处理新增字段无法映射
+          let that = this;
+
+          this.TableColumnTemp.forEach(({item,attr}) =>{
+
+            that.data = that.data.map(d =>{
+
+              if(!attr.is && attr.formatter){
+                d[item.key] = attr.formatter(d);
+              }
+
+              return d;
+
+            })
+
+          })
           this.page.total = total;
         }
       } catch (err) {
@@ -180,11 +196,18 @@ export default {
     },
     // confirm
     useConfirm(prop) {
+      
       const { multiple } = this.$props;
+
+      this.selectData = [...prop];
+      console.log(this.selectData,'this.selectData');
+   
       this.useUpdate(multiple ? prop : prop[0]);
+
       this.emitChange(this.selectData);
       this.lastSelectData = deepCopy(this.selectData);
       this.hide();
+      
     },
     // delete
     useDelete(prop) {
@@ -232,6 +255,22 @@ export default {
         this.innerValue = "";
       }
     },
+    async useAutocomplete(prop, cb) {
+      if (prop) {
+        this.page.pageSize = 10;
+
+        this.model = {
+          ...this.model,
+          search:prop,
+          type:this.type,
+        }
+        // 
+        await this.fetchList(this.model, this.page);
+        await cb(this.data);
+      } else {
+        cb([]);
+      }
+    },
   },
   created() {
 
@@ -242,7 +281,40 @@ export default {
 </script>
 <template>
   <div class="popover-select">
-    <el-input
+    <el-autocomplete
+      clearable
+      v-bind="$attrs"
+      v-model="innerValue"
+      :value-key="valueKey"
+      :fetch-suggestions="useAutocomplete"
+      @select="useConfirm([$event])"
+      style="width: 100%"
+    >
+      <i class="el-icon-search" slot="suffix" @click="open"> </i>
+      <template slot-scope="{ item }">
+        <p
+          style="
+            text-overflow: ellipsis;
+            overflow: hidden;
+            line-height: 15px;
+            margin: 5px 0;
+          "
+        >
+          {{ item.name }}
+        </p>
+        <p
+          style="
+            font-size: 12px;
+            color: #b4b4b4;
+            line-height: 15px;
+            margin: 5px 0;
+          "
+        >
+          {{ item.code }}
+        </p>
+      </template>
+    </el-autocomplete>
+    <!-- <el-input
       v-model="innerValue"
       :size="size"
       :disabled="disabled"
@@ -257,7 +329,7 @@ export default {
         icon="el-icon-search"
         @click="open"
       ></el-button>
-    </el-input>
+    </el-input> -->
     <el-dialog
       :title="`${title}(${multiple ? '多选' : '单选'})`"
       :width="width"