Browse Source

【修改】销售政策新增编辑

howie 2 years ago
parent
commit
449c8ffce7

+ 19 - 22
src/views/sales_policy/components/AddPolicy.vue

@@ -845,7 +845,7 @@ export default {
       this.handletwoList();
     },
     // 获取货品信息
-    handletwoList() {
+   async  handletwoList() {
       // this.searchForm.type
       this.listLoading = true;
 
@@ -855,10 +855,10 @@ export default {
         policyId: this.comCode,
         saleTypeCode: "",
       };
-
-      getMaterialList(paramss)
-        .then((result) => {
-          result.data.records.forEach((k) => {
+      try {
+        const {data}  =  await getMaterialList(paramss)
+      this.dataList = [...this.dataList,...data.records];
+          data.records.forEach((k) => {
             k.walletIds = [];
             k.rebateWalletIds = [];
             if (!k.specification) {
@@ -866,27 +866,24 @@ export default {
               k.specification = k.materialId;
             }
 
-            k.walletRelaList.forEach((l) => {
-              l.id = l.walletId;
-              l.name = l.walletName;
-              if (l.type === "REBATE") {
-                k.rebateWalletIds = [...k.rebateWalletIds, l.walletId];
+            for (let i = 0; i < k.walletRelaList.length; i++) {
+              const d =  k.walletRelaList[i];
+              d.id = d.walletId;
+              d.name = d.walletName;
+              if (d.type === "REBATE") {
+                k.rebateWalletIds = [...k.rebateWalletIds, d.walletId];
               } else {
-                k.walletIds = [...k.walletIds, l.walletId];
+                k.walletIds = [...k.walletIds, d.walletId];
               }
-              // k.walletIds = [...k.walletIds, l.walletId]
-            });
+            }
+
           });
-          // this.dataList=[]
-          console.log();
-          this.dataList = [...this.dataList,...result.data.records];
-          this.listTotal = result.data.total;
+          this.listTotal = data.total;
           this.listLoading = false;
-        })
-        .catch((err) => {
-          console.error(err);
-          // this.listLoading = false
-        });
+      } catch (error) {
+          console.error(error);
+      }
+
     },
     // 提交审核
     handleAddPolicy(policyCustomers,region) {

+ 8 - 7
src/views/sales_policy/components/editPolicy.vue

@@ -890,15 +890,16 @@ export default {
               k.specification = k.materialId
             }
 
-            k.walletRelaList.forEach((l) => {
-              l.id = l.walletId
-              l.name = l.walletName
-              if (l.type === 'REBATE') {
-                k.rebateWalletIds = [...k.rebateWalletIds, l.walletId]
+            for (let i = 0; i < k.walletRelaList.length; i++) {
+              const d =  k.walletRelaList[i];
+              d.id = d.walletId;
+              d.name = d.walletName;
+              if (d.type === "REBATE") {
+                k.rebateWalletIds = [...k.rebateWalletIds, d.walletId];
               } else {
-                k.walletIds = [...k.walletIds, l.walletId]
+                k.walletIds = [...k.walletIds, d.walletId];
               }
-            })
+            }
           })
 
           this.dataList = [...this.dataList,...result.data.records]