Browse Source

福达出口贸易销售复制数据错误问题 2023-12-11

caojunjie 1 year ago
parent
commit
4d73b6d6fc

+ 2 - 0
src/views/exportTrade/salesContract/components/goodsInfo.vue

@@ -446,6 +446,7 @@ export default {
     });
     getPricebankAll({ billType: "CG", statusTime: dateFormat(new Date(), "yyyy-MM-dd") }).then(res=>{
       this.goodsoptions = res.data.data
+      this.$emit('goodsoptionsfun',res.data.data)
     })
     // getPricebank(1, 10, {
     //   billType: "CG",
@@ -1289,6 +1290,7 @@ export default {
       }
     },
     handleRowSave(row, done, loading) {
+
       this.data.push(row)
       loading()
       done()

+ 119 - 97
src/views/exportTrade/salesContract/detailsPage.vue

@@ -229,7 +229,7 @@
         </avue-form>
       </trade-card>
       <goods-info ref="goodsInfo" :form="form" :data="data" :detailData="detailData" :orderFeesList.sync="orderFeesList"
-        @formGoodstoFees="formGoodstoFees" @backToList="getDetail"></goods-info>
+        @formGoodstoFees="formGoodstoFees" @backToList="getDetail" @goodsoptionsfun="goodsoptionsfun"></goods-info>
       <!--  <trade-card title="商品信息">
         <avue-crud ref="crud" :data="data" :option="tableOption" @row-del="rowDel"
           @selection-change="goodsSelectionChange" @saveColumn="saveColumn" @resetColumn="resetColumn"
@@ -566,6 +566,7 @@ import goodsInfo from "./components/goodsInfo.vue";
 import checkSchedule from "@/components/check/checkSchedule.vue";
 import check from "@/components/check/check.vue";
 import {getDictionary} from "@/api/system/dictbiz";
+import {getPricebankAll} from "@/api/basicData/customerInquiry";
 export default {
   name: "detailsPageEdit",
   data() {
@@ -1520,101 +1521,101 @@ export default {
     //     }
     //   });
     // },
-    cnameChange(row) {
-      this.goodsoptions.forEach(e => {
-        if (e.id == row.itemId) {
-          row.cname = e.cname;
-          row.code = e.code;
-          row.corpId = e.corpId;
-          row.corpName = e.corpCode;
-          row.priceCategory = e.goodsTypeName;
-          row.itemUrl = e.url;
-          row.itemDescription = e.cnameDescription;
-          row.unit = e.unit;
-          row.purchaseAmount = 0;
-          row.productPrice = productCal(
-            0,
-            row.partsPrice,
-            this.form.coefficient
-          );
-          row.price = sellingCal(
-            productCal(0, row.partsPrice, this.form.coefficient),
-            this.form.exchangeRate
-          );
-          row.amount = amountCal(
-            sellingCal(
-              productCal(0, row.partsPrice, this.form.coefficient),
-              this.form.exchangeRate
-            ),
-            row.orderQuantity,
-            row.freight,
-            row.insurance,
-            row.discount
-          );
-          row.itemMargin = grossProfitCal(
-            0,
-            row.partsPrice,
-            sellingCal(
-              productCal(0, row.partsPrice, this.form.coefficient),
-              this.form.exchangeRate
-            ),
-            this.form.exchangeRate
-          );
-        }
-      });
-      getPricedetail({
-        itemId: row.itemId,
-        corpId: row.corpId
-      }).then(res => {
-        if (res.data.data) {
-          this.goodsoptions.forEach(e => {
-            if (e.id == row.itemId) {
-              row.purchaseAmount = res.data.data.purchaseAmount;
-              row.productPrice = productCal(
-                res.data.data.purchaseAmount,
-                row.partsPrice,
-                this.form.coefficient
-              );
-              row.price = sellingCal(
-                productCal(
-                  res.data.data.purchaseAmount,
-                  row.partsPrice,
-                  this.form.coefficient
-                ),
-                this.form.exchangeRate
-              );
-              row.amount = amountCal(
-                sellingCal(
-                  productCal(
-                    res.data.data.purchaseAmount,
-                    row.partsPrice,
-                    this.form.coefficient
-                  ),
-                  this.form.exchangeRate
-                ),
-                row.orderQuantity,
-                row.freight,
-                row.insurance,
-                row.discount
-              );
-              row.itemMargin = grossProfitCal(
-                res.data.data.purchaseAmount,
-                row.partsPrice,
-                sellingCal(
-                  productCal(
-                    res.data.data.purchaseAmount,
-                    row.partsPrice,
-                    this.form.coefficient
-                  ),
-                  this.form.exchangeRate
-                ),
-                this.form.exchangeRate
-              );
-            }
-          });
-        }
-      });
-    },
+    // cnameChange(row) {
+    //   this.goodsoptions.forEach(e => {
+    //     if (e.id == row.itemId) {
+    //       row.cname = e.cname;
+    //       row.code = e.code;
+    //       row.corpId = e.corpId;
+    //       row.corpName = e.corpCode;
+    //       row.priceCategory = e.goodsTypeName;
+    //       row.itemUrl = e.url;
+    //       row.itemDescription = e.cnameDescription;
+    //       row.unit = e.unit;
+    //       row.purchaseAmount = 0;
+    //       row.productPrice = productCal(
+    //         0,
+    //         row.partsPrice,
+    //         this.form.coefficient
+    //       );
+    //       row.price = sellingCal(
+    //         productCal(0, row.partsPrice, this.form.coefficient),
+    //         this.form.exchangeRate
+    //       );
+    //       row.amount = amountCal(
+    //         sellingCal(
+    //           productCal(0, row.partsPrice, this.form.coefficient),
+    //           this.form.exchangeRate
+    //         ),
+    //         row.orderQuantity,
+    //         row.freight,
+    //         row.insurance,
+    //         row.discount
+    //       );
+    //       row.itemMargin = grossProfitCal(
+    //         0,
+    //         row.partsPrice,
+    //         sellingCal(
+    //           productCal(0, row.partsPrice, this.form.coefficient),
+    //           this.form.exchangeRate
+    //         ),
+    //         this.form.exchangeRate
+    //       );
+    //     }
+    //   });
+    //   getPricedetail({
+    //     itemId: row.itemId,
+    //     corpId: row.corpId
+    //   }).then(res => {
+    //     if (res.data.data) {
+    //       this.goodsoptions.forEach(e => {
+    //         if (e.id == row.itemId) {
+    //           row.purchaseAmount = res.data.data.purchaseAmount;
+    //           row.productPrice = productCal(
+    //             res.data.data.purchaseAmount,
+    //             row.partsPrice,
+    //             this.form.coefficient
+    //           );
+    //           row.price = sellingCal(
+    //             productCal(
+    //               res.data.data.purchaseAmount,
+    //               row.partsPrice,
+    //               this.form.coefficient
+    //             ),
+    //             this.form.exchangeRate
+    //           );
+    //           row.amount = amountCal(
+    //             sellingCal(
+    //               productCal(
+    //                 res.data.data.purchaseAmount,
+    //                 row.partsPrice,
+    //                 this.form.coefficient
+    //               ),
+    //               this.form.exchangeRate
+    //             ),
+    //             row.orderQuantity,
+    //             row.freight,
+    //             row.insurance,
+    //             row.discount
+    //           );
+    //           row.itemMargin = grossProfitCal(
+    //             res.data.data.purchaseAmount,
+    //             row.partsPrice,
+    //             sellingCal(
+    //               productCal(
+    //                 res.data.data.purchaseAmount,
+    //                 row.partsPrice,
+    //                 this.form.coefficient
+    //               ),
+    //               this.form.exchangeRate
+    //             ),
+    //             this.form.exchangeRate
+    //           );
+    //         }
+    //       });
+    //     }
+    //   });
+    // },
     addLibrary() {
       if (!this.form.corpId) {
         return this.$message.error("请选择客户名称");
@@ -2183,6 +2184,10 @@ export default {
       }
       this.dialogVisible = !this.dialogVisible;
     },
+    // 获取商品列表数据 保存的时候循环使用
+    goodsoptionsfun(list){
+       this.goodsoptions = list
+    },
     getDetail(id) {
       this.showBut = false;
       this.pageLoading = true;
@@ -2305,6 +2310,23 @@ export default {
               if (this.data[i].corpId == null) {
                 return this.$message.error(`请输入第${i + 1}行的供应商`);
               }
+              // 复制的重新进行计算
+              for (let item of this.goodsoptions) {
+                 if (item.itemId == this.data[i].itemId) {
+                     this.data[i].exchangeRate = this.form.exchangeRate,
+                     this.data[i].orderQuantity = 0
+                     this.data[i].partsPrice = 0
+                     this.data[i].purchaseCost = costCal(item.price, item.taxRate);
+                     this.data[i].purchaseAmount = item.purchaseAmount
+                     this.data[i].productPrice = productCal(item.purchaseAmount, 0, this.form.coefficient);
+                     this.data[i].outFactoryPrice = sellingCal(productCal(item.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
+                     this.data[i].totalValue = sellingCal(productCal(item.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
+                     this.data[i].price = sellingCal(productCal(item.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
+                     this.data[i].amount = sellingCal(productCal(item.purchaseAmount, 0, this.form.coefficient), this.form.exchangeRate);
+                     this.data[i].itemMargin = grossProfitCal(item.purchaseAmount, 0, sellingCal(productCal(item.purchaseAmount, 0, this
+                            .form.coefficient), this.form.exchangeRate), this.form.exchangeRate);
+                 }
+              }
               amountSum = _.add(
                 amountSum,
                 _.multiply(
@@ -2367,7 +2389,7 @@ export default {
             paySum
           );
           this.form.totalValue = 0
-          this.data.forEach((e, index) => {
+          this.data.forEach(async (e, index) => {
             e.sort = Number(index) + 1
             this.form.totalValue = sum(multiply(e.outFactoryPrice, e.orderQuantity), this.form.totalValue)
           })