QuKatie пре 3 година
родитељ
комит
c2b84859c9

+ 2 - 2
src/components/fee-info/main.vue

@@ -395,8 +395,8 @@ export default {
         unit: null,
         quantity: null,
         amount: null,
-        currency: null,
-        exchangeRate: null,
+        currency:'CNY',
+        exchangeRate: 1,
         remarks: null,
         $cellEdit: true,
         feesType:this.selectTab

+ 13 - 0
src/util/calculate.js

@@ -63,3 +63,16 @@ export function grossProfitCal(num, num2, num3, num4) {
   const sum = _.multiply(_.divide(_.subtract(_.multiply(price, exchangeRate), _.add(purchase, fitting)), _.multiply(price, exchangeRate)), 100)
   return Number(sum).toFixed(2)
 }
+//单票毛利: (金额*汇率+费用应收合计)-(成本*数量+费用应付合计)
+export function STGPCal(num, num2, num3, num4){
+  const amountSum= Number(num ? num : 0)
+  const reSum = Number(num2 ? num2 : 0)
+  const costSum = Number(num3 ? num3 : 0)
+  const paySum = Number(num4 ? num4 : 0)
+  const sum=_.subtract(_.add(amountSum,reSum),_.add(costSum,paySum))
+  return Number(sum).toFixed(2)
+}
+//校验值是否合法
+export function numCal(num){
+  return Number(num ? num : 0)
+}

+ 54 - 1
src/views/exportTrade/customerInquiry/detailsPage.vue

@@ -562,7 +562,9 @@ import {
   sellingCal,
   amountCal,
   transformCal,
-  grossProfitCal
+  grossProfitCal,
+  STGPCal,
+  numCal
 } from "@/util/calculate";
 
 import _ from "lodash";
@@ -1283,6 +1285,7 @@ export default {
             e.price,
             this.form.exchangeRate
           );
+          e.exchangeRate = this.form.exchangeRate;
         });
       }
       this.oldExchange = this.deepClone(this.form.exchangeRate);
@@ -1306,6 +1309,7 @@ export default {
             e.price,
             this.form.exchangeRate
           );
+          e.exchangeRate = this.form.exchangeRate;
         });
       }
       this.oldExchange = this.deepClone(row);
@@ -1451,6 +1455,7 @@ export default {
                 );
                 item.unit = e.unit;
                 item.remarks = this.reData.remarks;
+                item.exchangeRate = this.reData.exchangeRate;
                 item.$cellEdit = true;
               }
             });
@@ -1488,6 +1493,7 @@ export default {
             unit: e.unit,
             itemMargin: 0,
             remarks: null,
+            exchangeRate: this.form.exchangeRate,
             $cellEdit: true
           });
         });
@@ -1576,6 +1582,7 @@ export default {
             this.form.exchangeRate
           ),
           remarks: null,
+          exchangeRate: this.form.exchangeRate,
           $cellEdit: true
         });
       });
@@ -1613,11 +1620,32 @@ export default {
         done();
         if (valid) {
           let orderFeesList = this.$refs.feeInfo.submitData();
+          let amountSum = 0;
+          let reSum = 0;
+          let costSum = 0;
+          let paySum = 0;
           if (this.data.length > 0) {
             for (let i = 0; i < this.data.length; i++) {
               if (this.data[i].corpId == null) {
                 return this.$message.error(`请输入第${i + 1}行的供应商`);
               }
+              amountSum = _.add(
+                amountSum,
+                _.multiply(
+                  numCal(this.data[i].amount),
+                  numCal(this.data[i].exchangeRate)
+                )
+              );
+              costSum = _.add(
+                costSum,
+                _.multiply(
+                  _.add(
+                    numCal(this.data[i].purchaseAmount),
+                    numCal(this.data[i].partsPrice)
+                  ),
+                  numCal(this.data[i].orderQuantity)
+                )
+              );
             }
           }
           for (let i = 0; i < orderFeesList.length; i++) {
@@ -1630,7 +1658,32 @@ export default {
             if (orderFeesList[i].orderQuantity == 0) {
               return this.$message.error(`请正确输入第${i + 1}行的数量`);
             }
+            if (!orderFeesList[i].currency) {
+              return this.$message.error(`请正确选择第${i + 1}行的币别`);
+            }
+            if (!orderFeesList[i].exchangeRate) {
+              return this.$message.error(`请正确输入第${i + 1}行的汇率`);
+            }
+            if (orderFeesList[i].feesType == 1) {
+              reSum=_.add(
+                reSum,
+                _.multiply(
+                  numCal(orderFeesList[i].amount),
+                  numCal(orderFeesList[i].exchangeRate)
+                )
+              );
+            }
+             if (orderFeesList[i].feesType == 2) {
+              paySum=_.add(
+                paySum,
+                _.multiply(
+                  numCal(orderFeesList[i].amount),
+                  numCal(orderFeesList[i].exchangeRate)
+                )
+              );
+            }
           }
+          this.form.singleTicketMargin=STGPCal(amountSum,reSum,costSum,paySum)
           this.subLoading = true;
           submit({
             ...this.form,

+ 61 - 3
src/views/exportTrade/salesContract/detailsPage.vue

@@ -610,7 +610,9 @@ import {
   sellingCal,
   amountCal,
   transformCal,
-  grossProfitCal
+  grossProfitCal,
+  STGPCal,
+  numCal
 } from "@/util/calculate";
 export default {
   name: "detailsPageEdit",
@@ -1106,7 +1108,7 @@ export default {
       }
     },
     cnameChange(row) {
-    this.goodsoptions.forEach(e => {
+      this.goodsoptions.forEach(e => {
         if (e.id == row.itemId) {
           row.cname = e.cname;
           row.code = e.code;
@@ -1385,6 +1387,7 @@ export default {
             e.price,
             this.form.exchangeRate
           );
+          e.exchangeRate = this.form.exchangeRate;
         });
       }
       this.oldExchange = this.deepClone(this.form.exchangeRate);
@@ -1408,6 +1411,7 @@ export default {
             e.price,
             this.form.exchangeRate
           );
+          e.exchangeRate = this.form.exchangeRate;
         });
       }
       this.oldExchange = this.deepClone(row);
@@ -1521,6 +1525,7 @@ export default {
                 );
                 item.unit = e.unit;
                 item.remarks = this.reData.remarks;
+                item.exchangeRate = this.reData.exchangeRate;
                 item.$cellEdit = true;
               }
             });
@@ -1557,6 +1562,7 @@ export default {
             unit: e.unit,
             itemMargin: 0,
             remarks: null,
+            exchangeRate: this.form.exchangeRate,
             $cellEdit: true
           });
         });
@@ -1644,6 +1650,7 @@ export default {
             this.form.exchangeRate
           ),
           remarks: null,
+          exchangeRate: this.form.exchangeRate,
           $cellEdit: true
         });
       });
@@ -1680,11 +1687,32 @@ export default {
       this.$refs["form"].validate((valid, done) => {
         done();
         if (valid) {
+          let amountSum = 0;
+          let reSum = 0;
+          let costSum = 0;
+          let paySum = 0;
           if (this.data.length > 0) {
             for (let i = 0; i < this.data.length; i++) {
               if (this.data[i].corpId == null) {
                 return this.$message.error(`请输入第${i + 1}行的供应商`);
               }
+              amountSum = _.add(
+                amountSum,
+                _.multiply(
+                  numCal(this.data[i].amount),
+                  numCal(this.data[i].exchangeRate)
+                )
+              );
+              costSum = _.add(
+                costSum,
+                _.multiply(
+                  _.add(
+                    numCal(this.data[i].purchaseAmount),
+                    numCal(this.data[i].partsPrice)
+                  ),
+                  numCal(this.data[i].orderQuantity)
+                )
+              );
             }
           }
           const orderFeesList = this.$refs.feeInfo.submitData();
@@ -1698,7 +1726,37 @@ export default {
             if (orderFeesList[i].quantity == 0) {
               return this.$message.error(`请正确输入第${i + 1}行的数量`);
             }
+            if (!orderFeesList[i].currency) {
+              return this.$message.error(`请正确选择第${i + 1}行的币别`);
+            }
+            if (!orderFeesList[i].exchangeRate) {
+              return this.$message.error(`请正确输入第${i + 1}行的汇率`);
+            }
+            if (orderFeesList[i].feesType == 1) {
+              reSum = _.add(
+                reSum,
+                _.multiply(
+                  numCal(orderFeesList[i].amount),
+                  numCal(orderFeesList[i].exchangeRate)
+                )
+              );
+            }
+            if (orderFeesList[i].feesType == 2) {
+              paySum = _.add(
+                paySum,
+                _.multiply(
+                  numCal(orderFeesList[i].amount),
+                  numCal(orderFeesList[i].exchangeRate)
+                )
+              );
+            }
           }
+          this.form.singleTicketMargin = STGPCal(
+            amountSum,
+            reSum,
+            costSum,
+            paySum
+          );
           const orderFilesList = this.$refs.uploadFile.submitData();
           this.subLoading = true;
           submit({
@@ -1794,7 +1852,7 @@ export default {
               e.srcId = e.id;
               e.specificationAndModel = e.itemType;
               e.productDesc = e.itemDescription;
-              delete e.id;
+              (e.exRate0 = e.exchangeRate), delete e.id;
               delete e.version;
               delete e.status;
               delete e.createUser;