Răsfoiți Sursa

fix(accountstatement): 修复金额计算中的小数精度问题

liujt 4 luni în urmă
părinte
comite
138ba84659

+ 8 - 8
src/views/purchasingManage/purchaseOrder/accountstatement/components/addAccountDialog.vue

@@ -149,10 +149,10 @@
       async getInfo(row) {
         let data = await accountstatementInfoAPI(row.id);
         // this.recorpayList = data.recorpayList || [];
-        data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + +cur.orderAmount, 0);
-        data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + +cur.amountTotalPrice, 0);
-        data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.statementAmount, 0);
-        data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.unStatementAmount, 0);
+        data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
+        data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100;
+        data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
+        data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
         this.datasource = data.orderList || [];
         this.dataForm = data;
         switch (this.dataForm.dateType) {
@@ -204,10 +204,10 @@
           // amountTotalPrice: data.amountTotalPrice,
           // amountPayablePass: data.amountPayablePass,
           // amountReceivablePass: data.amountReceivablePass
-          orderTotalAmount: data.reduce((pre, cur) => pre + +cur.orderAmount, 0),
-          amountTotalPrice: data.reduce((pre, cur) => pre + +cur.amountTotalPrice, 0),
-          amountCompletePrice: data.reduce((pre, cur) => pre + +cur.statementAmount, 0),
-          amountUnCompletePrice: data.reduce((pre, cur) => pre + +cur.unStatementAmount, 0)
+          orderTotalAmount: data.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100,
+          amountTotalPrice: data.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100,
+          amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100,
+          amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
         };
         // if (!this.datasource.length) this.$message.warning('暂无订单信息');
       },

+ 9 - 6
src/views/purchasingManage/purchaseOrder/accountstatement/components/searchTable.vue

@@ -3,14 +3,16 @@
   <seekPage :seekList="seekList" :formLength="3" @search="search"></seekPage>
 </template>
 <script>
-import { receiptType, reviewStatusSelect } from '@/enum/dict';
+import { receiptType, reviewStatusSelect, reconciliationType } from '@/enum/dict';
 import {
 
   assessmentIndicatorsOptions
 } from '@/views/targetManage/util.js';
 export default {
   data() {
-    return {};
+    return {
+
+    };
   },
   computed: {
     // 表格列配置
@@ -37,9 +39,10 @@ export default {
         {
           label: '对账方式:',
           value: 'dateType',
-          width: 380,
-          type: 'input',
-          placeholder: '请输入',
+          // width: 380,
+          placeholder: '请选择',
+          type: 'select',
+          planList: reconciliationType
         },
         // {
         //   label: '对账开始日期:',
@@ -83,7 +86,7 @@ export default {
         {
           label: '状态:',
           value: 'reviewStatus',
-          width: 380,
+          // width: 380,
           type: 'select',
           placeholder: '请选择状态',
           planList: reviewStatusSelect

+ 9 - 8
src/views/saleManage/saleOrder/accountstatement/components/addAccountDialog.vue

@@ -184,10 +184,11 @@
       async getInfo(row) {
         let data = await accountstatementInfoAPI(row.id);
         // this.recorpayList = data.recorpayList || [];
-        data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + +cur.orderAmount, 0);
-        data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + +cur.amountTotalPrice, 0);
-        data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.statementAmount, 0);
-        data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.unStatementAmount, 0);
+        // 解决小数精度丢失问题,使用分进行计算
+        data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
+        data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100;
+        data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
+        data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
         data.orderList = data.orderList.map(item => {
             item.deliveryProducts = item.deliveryProducts.map(i => {
               return {
@@ -270,10 +271,10 @@
             // amountTotalPrice: data.amountTotalPrice,
             // amountPayablePass: data.amountPayablePass,
             // amountReceivablePass: data.amountReceivablePass
-            orderTotalAmount: data.reduce((pre, cur) => pre + +cur.orderAmount, 0),
-            amountTotalPrice: data.reduce((pre, cur) => pre + +cur.amountTotalPrice, 0),
-            amountCompletePrice: data.reduce((pre, cur) => pre + +cur.statementAmount, 0),
-            amountUnCompletePrice: data.reduce((pre, cur) => pre + +cur.unStatementAmount, 0)
+            orderTotalAmount: data.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100,
+            amountTotalPrice: data.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100,
+            amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100,
+            amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
           };
           this.$forceUpdate();
         } catch (error) {

+ 3 - 3
src/views/saleManage/saleOrder/accountstatement/components/detailDialog.vue

@@ -110,9 +110,9 @@ export default {
 
       this.datasource = data.orderList
       // this.recorpayList = data.recorpayList || [];
-      data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + +cur.amountTotalPrice, 0),
-      data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.statementAmount, 0),
-      data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + +cur.unStatementAmount, 0)
+        data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100;
+        data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
+        data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
       this.dataForm = data
       switch (this.dataForm.dateType) {
         case 1: