Browse Source

销售报价单-子表增加采购金额字段

jingbb 3 tháng trước cách đây
mục cha
commit
6160accdca

+ 17 - 33
src/views/saleCode/quotation/components/quotationFormForm.vue

@@ -825,6 +825,7 @@
           item.exchangeRateGys = item.exchangeRateUsd;
           item.taxPriceGys = item.taxPrice;
           item.notes=item.childNotes
+          item.purchaseAmount=(Number(item.quantity) * Number(item.purchasePrice)).toFixed(2)
         }
         var xTable = saleQuotationFormProductTableRef.value!.getXTable();
         var arrProduct = xTable.data.concat(data);
@@ -889,49 +890,32 @@
         return obj;
       }
       function changeValues(prop) {
+        //设置 默认值
         formData.exchangeRate = formData.exchangeRate == '' || formData.exchangeRate === null ? 1 : formData.exchangeRate;
-        prop.row.customerCommision =
-          prop.row.customerCommision == '' || prop.row.customerCommision === null || !prop.row.customerCommision ? 0 : prop.row.customerCommision;
+        prop.row.customerCommision = prop.row.customerCommision == '' || prop.row.customerCommision === null || !prop.row.customerCommision ? 0 : prop.row.customerCommision;
         prop.row.discount = prop.row.discount == '' || prop.row.discount === null || !prop.row.discount ? 0 : prop.row.discount;
         prop.row.tariff = prop.row.tariff == '' || prop.row.tariff === null || !prop.row.tariff ? 0 : prop.row.tariff;
-        prop.row.intermediatorCommission =
-          prop.row.intermediatorCommission == '' || prop.row.intermediatorCommission === null || !prop.row.intermediatorCommission
-            ? 0
-            : prop.row.intermediatorCommission;
-        if (
-          prop.col.key == 'purchasePrice' ||
-          prop.col.key == 'taxRate' ||
-          prop.col.key == 'tariff' ||
-          prop.col.key == 'discount' ||
-          prop.col.key == 'grossMargin' ||
-          prop.col.key == 'customerCommision' ||
-          prop.col.key == 'intermediatorCommission'
-        ) {
-          //汇率默认为1
-          var num =
-            ((prop.row.purchasePrice / Number(formData.exchangeRate)) *
-              (1 + prop.row.taxRate / 100) *
-              (1 + prop.row.tariff / 100) *
-              (1 - prop.row.discount / 100)) /
-            (1 - prop.row.grossMargin / 100 - prop.row.customerCommision / 100 - prop.row.intermediatorCommission / 100);
-
+        prop.row.intermediatorCommission =prop.row.intermediatorCommission == '' || prop.row.intermediatorCommission === null || !prop.row.intermediatorCommission? 0: prop.row.intermediatorCommission;
+        //计算销售单价
+        if (prop.col.key == 'purchasePrice' || prop.col.key == 'taxRate' || prop.col.key == 'tariff' || prop.col.key == 'discount' || prop.col.key == 'grossMargin' || prop.col.key == 'customerCommision' || prop.col.key == 'intermediatorCommission') {
+          var num =((prop.row.purchasePrice / Number(formData.exchangeRate)) *(1 + prop.row.taxRate / 100) *(1 + prop.row.tariff / 100) *(1 - prop.row.discount / 100)) /(1 - prop.row.grossMargin / 100 - prop.row.customerCommision / 100 - prop.row.intermediatorCommission / 100);
           prop.row.salePrice = !isNaN(num) ? num.toFixed(2) : '';
           if (prop.row.quantity) {
-            prop.row.taxAmount = (prop.row.salePrice * prop.row.quantity).toFixed(2);
+            prop.row.taxAmount = (prop.row.salePrice * prop.row.quantity).toFixed(2); //计算金额
+            prop.row.purchaseAmount = (prop.row.purchasePrice * prop.row.quantity).toFixed(2);  //计算采购金额
           }
         }
-        if (prop.col.key == 'quantity' && prop.row.salePrice && prop.row.quantity) {
+        //计算金额
+        if (prop.col.key == 'quantity'&& prop.row.salePrice && prop.row.quantity) {
           prop.row.taxAmount = (prop.row.salePrice * prop.row.quantity).toFixed(2);
         }
+        //计算采购金额
+        if (prop.col.key == 'quantity' && prop.row.quantity&& prop.row.purchasePrice) {
+          prop.row.purchaseAmount = (prop.row.purchasePrice * prop.row.quantity).toFixed(2);
+        }
+        //计算毛利率/金额
         if (prop.col.key == 'salePrice') {
-          var num =
-            1 -
-            (((prop.row.purchasePrice / Number(formData.exchangeRate)) *
-              (1 + prop.row.taxRate / 100) *
-              (1 + prop.row.tariff / 100) *
-              (1 - prop.row.discount / 100)) /
-              prop.row.salePrice +
-              (prop.row.customerCommision / 100 - prop.row.intermediatorCommission / 100));
+          var num =1 -(((prop.row.purchasePrice / Number(formData.exchangeRate)) *(1 + prop.row.taxRate / 100) *(1 + prop.row.tariff / 100) *(1 - prop.row.discount / 100)) /prop.row.salePrice +(prop.row.customerCommision / 100 - prop.row.intermediatorCommission / 100));
           num = (Number(num) * 100).toFixed(2);
           prop.row.grossMargin = !isNaN(num) ? num : '';
           if (prop.row.quantity) {

+ 9 - 0
src/views/saleCode/quotation/quotationForm.data.ts

@@ -267,6 +267,15 @@ export const saleQuotationFormProductColumns: JVxeColumn[] = [
       width:"200px",
       defaultValue:'',
     },
+    {
+      title: '采购金额(purchase amount)',
+      key: 'purchaseAmount',
+      type: JVxeTypes.inputNumber,
+      placeholder: '请输入${title}',
+      width:"200px",
+      defaultValue:'',
+      statistics:['sum'],
+    },
     {
       title: '税率(tax rate)',
       key: 'taxRate',