ydf 1 år sedan
förälder
incheckning
12a184c7a7
2 ändrade filer med 24 tillägg och 10 borttagningar
  1. 13 0
      src/global/decimalCompute.ts
  2. 11 10
      src/views/InformationFilling/outIssue/detail.vue

+ 13 - 0
src/global/decimalCompute.ts

@@ -25,3 +25,16 @@ export function decimalDev(a: number, b: number) {
25 25
 
26 26
   return result.toNumber(); // 返回精确乘法结果(可选,根据需要转换为数字或保留为Decimal对象)
27 27
 }
28
+
29
+//加法
30
+export function decimalAdd(a: number, b: number) {
31
+  const one = Number(a),
32
+    two = Number(b);
33
+
34
+  const decimalA = new Decimal(one);
35
+  const decimalB = new Decimal(two);
36
+
37
+  const result = decimalA.add(decimalB);
38
+
39
+  return result.toNumber(); // 返回精确乘法结果(可选,根据需要转换为数字或保留为Decimal对象)
40
+}

+ 11 - 10
src/views/InformationFilling/outIssue/detail.vue

@@ -356,7 +356,7 @@ import { getQuery } from "@/hooks/detailQuery/index";
356 356
 import store from "@/store";
357 357
 import { useGetters } from "@/hooks/storeHooks";
358 358
 const { access_token } = useGetters(["access_token"]);
359
-import { decimalMul, decimalDev } from "@/global/decimalCompute";
359
+import { decimalMul, decimalDev, decimalAdd } from "@/global/decimalCompute";
360 360
 import type { TableColumnCtx } from "element-plus";
361 361
 
362 362
 const { outdound_type, is_available, province_ch } = useDict("outdound_type", "is_available", "province_ch");
@@ -492,16 +492,16 @@ const getDeptName = (value: any, index: number) => {
492 492
 
493 493
 
494 494
 interface Product {
495
-  id: string
496
-  quantity: string
497
-  unitPrice: number
498
-  totalPrice: number
495
+  id: string;
496
+  quantity: string;
497
+  unitPrice: number;
498
+  totalPrice: number;
499 499
 }
500 500
 interface SummaryMethodProps<T = Product> {
501
-  columns: TableColumnCtx<T>[]
502
-  data: T[]
501
+  columns: TableColumnCtx<T>[];
502
+  data: T[];
503 503
 }
504
-const summaryJson = ["quantity","totalPrice"]
504
+const summaryJson = ["quantity", "totalPrice"];
505 505
 const getSummaries = (param: SummaryMethodProps) => {
506 506
   const { columns, data } = param;
507 507
   const sums: (string | VNode)[] = [];
@@ -510,13 +510,14 @@ const getSummaries = (param: SummaryMethodProps) => {
510 510
       sums[index] = h("div", ["合计"]);
511 511
       return;
512 512
     }
513
-    if(summaryJson.indexOf(column.property)!=-1){
513
+    if (summaryJson.indexOf(column.property) != -1) {
514 514
       const values = data.map((item) => Number(item[column.property]));
515 515
       if (!values.every((value) => Number.isNaN(value))) {
516 516
         sums[index] = `${values.reduce((prev, curr) => {
517 517
           const value = Number(curr);
518 518
           if (!Number.isNaN(value)) {
519
-            return prev + curr;
519
+            return decimalAdd(prev, curr);
520
+            // return prev + curr;
520 521
           } else {
521 522
             return prev;
522 523
           }