Răsfoiți Sursa

fix: 在产品列表新增查询功能,支持按编码和名称筛选,并优化数据源处理逻辑

yusheng 9 luni în urmă
părinte
comite
c926311125

+ 1 - 0
src/views/saleManage/saleOrder/entrustedReceive/components/inventoryTable.vue

@@ -450,6 +450,7 @@
             width: 150,
             width: 150,
             prop: 'singlePrice',
             prop: 'singlePrice',
             label: '单价',
             label: '单价',
+            headerSlot: 'headerTotalCount',
             slot: 'singlePrice',
             slot: 'singlePrice',
             align: 'center'
             align: 'center'
           },
           },

+ 87 - 13
src/views/saleManage/saleOrder/invoice/components/product-listNew.vue

@@ -10,6 +10,59 @@
     :resizable="true"
     :resizable="true"
   >
   >
     <el-card shadow="never">
     <el-card shadow="never">
+      <el-form
+        size="small"
+        label-width="80px"
+        class="ele-form-search"
+        @keyup.enter.native="search"
+        @submit.native.prevent
+      >
+        <el-row :gutter="10">
+          <el-col :span="6">
+            <el-form-item label="编码">
+              <el-input
+                clearable
+                size="small"
+                v-model.trim="where.productCode"
+                placeholder="请输入"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="名称">
+              <el-input
+                clearable
+                size="small"
+                v-model.trim="where.productName"
+                placeholder="请输入"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6" style="display: flex; justify-content: flex-end">
+            <el-form-item>
+              <el-button
+                size="mini"
+                type="primary"
+                icon="el-icon-search"
+                class="ele-btn-icon"
+                @click="search"
+              >
+                查询
+              </el-button>
+
+              <el-button
+                @click="search('reset')"
+                icon="el-icon-refresh"
+                class="ele-btn-icon"
+                size="mini"
+                >重置</el-button
+              >
+
+              <slot></slot>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
       <ele-pro-table
       <ele-pro-table
         ref="table"
         ref="table"
         :columns="columns"
         :columns="columns"
@@ -36,6 +89,10 @@
       return {
       return {
         visible: false,
         visible: false,
         datasource: [],
         datasource: [],
+        where: {
+          productCode: '',
+          productName: ''
+        },
         columns: [
         columns: [
           {
           {
             width: 45,
             width: 45,
@@ -201,33 +258,50 @@
             }
             }
           }
           }
         ],
         ],
-        selection: []
+        selection: [],
+        oldDatasource: []
       };
       };
     },
     },
 
 
     watch: {},
     watch: {},
     methods: {
     methods: {
       open(datasource) {
       open(datasource) {
+        this.oldDatasource = datasource;
         this.datasource = datasource || [];
         this.datasource = datasource || [];
         this.visible = true;
         this.visible = true;
       },
       },
-
+      search(type) {
+        if (type == 'reset') {
+          this.where = {
+            productName: '',
+            productCode: ''
+          };
+        }
+        if (this.where.productName == '' && this.where.productCode == '') {
+          this.datasource = this.oldDatasource;
+          return
+        }
+        this.datasource = this.oldDatasource.filter((item) => {
+          if (
+            this.where.productName &&
+            item.productName.includes(this.where.productName)
+          ) {
+            return item;
+          }
+          if (
+            this.where.productCode &&
+            item.productCode.includes(this.where.productCode)
+          ) {
+            return item;
+          }
+        });
+      },
       selected() {
       selected() {
         if (!this.selection.length) {
         if (!this.selection.length) {
           return this.$message.warning('请至少选择一条数据');
           return this.$message.warning('请至少选择一条数据');
         }
         }
-        // let idKey =
-        //   this.type == 'receive' ? 'receiveProductId' : 'sendProductId';
-        // console.log(this.current);
-        // console.log(this.currentData);
-
-        // let index = this.currentData.findIndex(
-        //   (r) => r[idKey] == this.current.id
-        // );
-        // if (index != -1 && ['receive', 'send'].includes(this.type)) {
-        //   return this.$message.error('选择的产品已经存在列表了');
-        // }
         this.$emit('changeParent', this.selection);
         this.$emit('changeParent', this.selection);
+
         this.visible = false;
         this.visible = false;
       }
       }
     }
     }