From 2a8dc0db849bcafba80acda057bb554fc566dc53 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期日, 25 十月 2026 21:09:51 +0800
Subject: [PATCH] fix: 优化采购和销售金额展示

---
 src/views/procurementManagement/procurementLedger/index.vue |  165 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 103 insertions(+), 62 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index b28df5d..f4f3a31 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -121,13 +121,17 @@
                 </template>
               </el-table-column>
               <el-table-column label="鏁伴噺"
-                               prop="quantity" />
+                               prop="quantity"
+                               :formatter="formattedNumber" />
               <el-table-column label="鍙敤鏁伴噺"
-                               prop="availableQuality" />
+                               prop="availableQuality"
+                               :formatter="formattedNumber" />
               <el-table-column label="閫�璐ф暟閲�"
-                               prop="returnQuantity" />
+                               prop="returnQuantity"
+                               :formatter="formattedNumber" />
               <el-table-column label="绋庣巼(%)"
-                               prop="taxRate" />
+                               prop="taxRate"
+                               :formatter="formattedNumber" />
               <el-table-column label="鍚◣鍗曚环(鍏�)"
                                prop="taxInclusiveUnitPrice"
                                :formatter="formattedNumber" />
@@ -418,11 +422,13 @@
                            width="70" />
           <el-table-column label="鏁伴噺"
                            prop="quantity"
-                           width="70" />
+                           width="70"
+                           :formatter="formattedNumber" />
           <el-table-column label="搴撳瓨棰勮鏁伴噺"
                            prop="warnNum"
                            width="120"
-                           show-overflow-tooltip />
+                           show-overflow-tooltip
+                           :formatter="formattedNumber" />
           <el-table-column label="绋庣巼(%)"
                            prop="taxRate"
                            width="80" />
@@ -599,7 +605,6 @@
             <el-form-item label="鍚◣鍗曚环(鍏�)锛�"
                           prop="taxInclusiveUnitPrice">
               <el-input-number v-model="productForm.taxInclusiveUnitPrice"
-                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -612,7 +617,6 @@
                           prop="quantity">
               <el-input-number :step="0.1"
                                clearable
-                               :precision="6"
                                :min="0"
                                style="width: 100%"
                                v-model="productForm.quantity"
@@ -626,7 +630,6 @@
             <el-form-item label="鍚◣鎬讳环(鍏�)锛�"
                           prop="taxInclusiveTotalPrice">
               <el-input-number v-model="productForm.taxInclusiveTotalPrice"
-                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -638,7 +641,6 @@
             <el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�"
                           prop="taxExclusiveTotalPrice">
               <el-input-number v-model="productForm.taxExclusiveTotalPrice"
-                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -665,11 +667,11 @@
             <el-form-item label="搴撳瓨棰勮鏁伴噺锛�"
                           prop="warnNum">
               <el-input-number v-model="productForm.warnNum"
-                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
-                               style="width: 100%" />
+                               style="width: 100%"
+                               @change="normalizeProductNumber('warnNum')" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -761,7 +763,7 @@
   import { modelList, productTreeList } from "@/api/basicData/product.js";
   import dayjs from "dayjs";
   import FileUpload from "@/components/AttachmentUpload/file/index.vue";
-  import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js";
+  import { formatDecimal6 } from "@/utils/formatNumber.js";
 
   const userStore = useUserStore();
 
@@ -1086,15 +1088,11 @@
   };
 
   const formattedNumber = (row, column, cellValue) => {
-    return trimZeros(cellValue, 6);
+    return formatDecimal6(cellValue);
   };
-  // 閲戦鏄剧ず鏍煎紡鍖栵細鎸夊崄杩涘埗鍥涜垗浜斿叆鍒� 2 浣嶅皬鏁帮紙涓庢暟鎹簱 ROUND 涓�鑷达級锛屽啀鍘绘帀鏈熬澶氫綑鐨� 0
-  const formatAmount = value => {
-    return trimZeros(roundHalfUp(value, 2), 2);
-  };
-  // 閲戦鍒楃殑琛ㄦ牸鏍煎紡鍖栧嚱鏁帮紙鍗曚环鍒椾粛鐢� formattedNumber 淇濈暀 6 浣嶅皬鏁帮級
+  // 閲戦鏄剧ず鏍煎紡鍖栵細鏈�澶氫繚鐣� 6 浣嶅皬鏁帮紝瓒呰繃 6 浣嶇殑鎸夊崄杩涘埗鍥涜垗浜斿叆
   const formattedAmount = (row, column, cellValue) => {
-    return formatAmount(cellValue);
+    return formatDecimal6(cellValue);
   };
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -1214,10 +1212,10 @@
         "futureTicketsAmount",
       ],
       {
-        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
-        // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
-        taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
-        taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+        taxInclusiveUnitPrice: { formatter: formatDecimal6 },
+        // 閲戦鍒楋細鍚堣鍚庢渶澶氫繚鐣� 6 浣嶅皬鏁帮紝瓒呰繃 6 浣嶆寜鍗佽繘鍒跺洓鑸嶄簲鍏�
+        taxInclusiveTotalPrice: { formatter: formatDecimal6 },
+        taxExclusiveTotalPrice: { formatter: formatDecimal6 },
         ticketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
         futureTicketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
         ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
@@ -1289,9 +1287,9 @@
       param,
       ["contractAmount", "netContractAmount"],
       {
-        // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
-        contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
-        netContractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+        // 閲戦鍒楋細鍚堣鍚庢渶澶氫繚鐣� 6 浣嶅皬鏁帮紝瓒呰繃 6 浣嶆寜鍗佽繘鍒跺洓鑸嶄簲鍏�
+        contractAmount: { formatter: formatDecimal6 },
+        netContractAmount: { formatter: formatDecimal6 },
       }
     );
   };
@@ -1305,10 +1303,10 @@
         "taxExclusiveTotalPrice",
       ],
       {
-        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
-        // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
-        taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
-        taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+        taxInclusiveUnitPrice: { formatter: formatDecimal6 },
+        // 閲戦鍒楋細鍚堣鍚庢渶澶氫繚鐣� 6 浣嶅皬鏁帮紝瓒呰繃 6 浣嶆寜鍗佽繘鍒跺洓鑸嶄簲鍏�
+        taxInclusiveTotalPrice: { formatter: formatDecimal6 },
+        taxExclusiveTotalPrice: { formatter: formatDecimal6 },
       }
     );
   };
@@ -1517,6 +1515,20 @@
       // 澶嶅埗琛屾暟鎹�
       productForm.value = { ...row };
 
+      // 鍚庣鏁伴噺/閲戦瀛楁鎸� 6 浣嶅皬鏁拌繑鍥烇紙濡� 10.000000锛夛紝杞垚鏅�氭暟鍊硷紝
+      // 閬垮厤杈撳叆妗嗗洖鏄惧浣欑殑 0
+      [
+        "quantity",
+        "taxInclusiveUnitPrice",
+        "taxInclusiveTotalPrice",
+        "taxExclusiveTotalPrice",
+        "warnNum",
+      ].forEach(key => {
+        const val = productForm.value[key];
+        if (val === null || val === undefined || val === "") return;
+        productForm.value[key] = toDisplayNumber(val);
+      });
+
       // 濡傛灉鏄粠妯℃澘鍔犺浇鐨勬暟鎹紝鍙兘娌℃湁 productId 鍜� productModelId
       // 闇�瑕佹牴鎹� productCategory 鍜� specificationModel 鏉ユ煡鎵惧搴旂殑 ID
       if (!productForm.value.productId && productForm.value.productCategory) {
@@ -1645,6 +1657,8 @@
   const submitProduct = () => {
     proxy.$refs["productFormRef"].validate(valid => {
       if (valid) {
+        // 鎻愪氦鍓嶇粺涓�鎶婃暟鍊兼敹鏁涘埌鏈�澶� 6 浣嶅皬鏁帮紙瓒呭嚭鍥涜垗浜斿叆锛�
+        normalizeProductNumbers();
         if (operationType.value === "edit") {
           submitProductEdit();
         } else {
@@ -1803,7 +1817,33 @@
     return `${year}-${month}-${day}`;
   }
 
+  // 璁$畻缁撴灉杞垚鏁板瓧锛氭渶澶氫繚鐣� 6 浣嶅皬鏁帮紙瓒呰繃 6 浣嶇殑鍥涜垗浜斿叆锛夛紝骞跺幓鎺夋湯灏炬棤鎰忎箟鐨� 0锛�
+  // 閬垮厤鍥炲~鍒� el-input-number 鏃跺嚭鐜� 100.000000 杩欑被灞曠ず
+  const toDisplayNumber = value => {
+    const num = Number(formatDecimal6(value));
+    return Number.isFinite(num) ? num : 0;
+  };
+
+  // 浜у搧寮圭獥鍗曚釜鏁板�煎瓧娈靛綊涓�鍖栵細杈撳叆瓒呰繃 6 浣嶅皬鏁版椂鍥涜垗浜斿叆鍒� 6 浣�
+  const normalizeProductNumber = key => {
+    const val = productForm.value[key];
+    if (val === null || val === undefined || val === "") return;
+    productForm.value[key] = toDisplayNumber(val);
+  };
+
+  // 浜у搧寮圭獥鍙備笌鑱斿姩璁$畻鐨勬暟鍊煎瓧娈电粺涓�褰掍竴鍖�
+  const normalizeProductNumbers = () => {
+    [
+      "quantity",
+      "taxInclusiveUnitPrice",
+      "taxInclusiveTotalPrice",
+      "taxExclusiveTotalPrice",
+      "warnNum",
+    ].forEach(normalizeProductNumber);
+  };
+
   const mathNum = () => {
+    normalizeProductNumbers();
     if (!productForm.value.taxRate) {
       proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
       return;
@@ -1815,23 +1855,26 @@
       return;
     }
     // 鍚◣鎬讳环璁$畻
-    productForm.value.taxInclusiveTotalPrice =
+    productForm.value.taxInclusiveTotalPrice = toDisplayNumber(
       proxy.calculateTaxIncludeTotalPrice(
         productForm.value.taxInclusiveUnitPrice,
         productForm.value.quantity,
         6
-      );
+      )
+    );
     if (productForm.value.taxRate) {
       // 涓嶅惈绋庢�讳环璁$畻
-      productForm.value.taxExclusiveTotalPrice =
+      productForm.value.taxExclusiveTotalPrice = toDisplayNumber(
         proxy.calculateTaxExclusiveTotalPrice(
           productForm.value.taxInclusiveTotalPrice,
           productForm.value.taxRate,
           6
-        );
+        )
+      );
     }
   };
   const reverseMathNum = field => {
+    normalizeProductNumbers();
     if (!productForm.value.taxRate) {
       proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
       return;
@@ -1846,7 +1889,7 @@
     ) {
       const value = Number(productForm.value[field]);
       if (value < 0) {
-        productForm.value[field] = "0";
+        productForm.value[field] = 0;
         proxy.$modal.msgWarning("鍊间笉鑳藉皬浜�0");
         return;
       }
@@ -1855,65 +1898,63 @@
     if (field === "taxInclusiveTotalPrice") {
       // 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环
       if (productForm.value.quantity) {
-        productForm.value.taxInclusiveUnitPrice = (
+        productForm.value.taxInclusiveUnitPrice = toDisplayNumber(
           Number(productForm.value.taxInclusiveTotalPrice) /
-          Number(productForm.value.quantity)
-        ).toFixed(6);
+            Number(productForm.value.quantity)
+        );
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
-          productForm.value.taxInclusiveUnitPrice = "0";
+          productForm.value.taxInclusiveUnitPrice = 0;
         }
       }
       // 宸茬煡鍚◣鎬讳环鍜屽惈绋庡崟浠凤紝鍙嶇畻鏁伴噺
       else if (productForm.value.taxInclusiveUnitPrice) {
-        productForm.value.quantity = (
+        productForm.value.quantity = toDisplayNumber(
           Number(productForm.value.taxInclusiveTotalPrice) /
-          Number(productForm.value.taxInclusiveUnitPrice)
-        ).toFixed(6);
+            Number(productForm.value.taxInclusiveUnitPrice)
+        );
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.quantity) < 0) {
-          productForm.value.quantity = "0";
+          productForm.value.quantity = 0;
         }
       }
       // 鍙嶇畻涓嶅惈绋庢�讳环
-      productForm.value.taxExclusiveTotalPrice = (
-        Number(productForm.value.taxInclusiveTotalPrice) /
-        (1 + taxRate / 100)
-      ).toFixed(6);
+      productForm.value.taxExclusiveTotalPrice = toDisplayNumber(
+        Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)
+      );
       // 纭繚缁撴灉涓嶄负璐熸暟
       if (Number(productForm.value.taxExclusiveTotalPrice) < 0) {
-        productForm.value.taxExclusiveTotalPrice = "0";
+        productForm.value.taxExclusiveTotalPrice = 0;
       }
     } else if (field === "taxExclusiveTotalPrice") {
       // 鍙嶇畻鍚◣鎬讳环
-      productForm.value.taxInclusiveTotalPrice = (
-        Number(productForm.value.taxExclusiveTotalPrice) *
-        (1 + taxRate / 100)
-      ).toFixed(6);
+      productForm.value.taxInclusiveTotalPrice = toDisplayNumber(
+        Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)
+      );
       // 纭繚缁撴灉涓嶄负璐熸暟
       if (Number(productForm.value.taxInclusiveTotalPrice) < 0) {
-        productForm.value.taxInclusiveTotalPrice = "0";
+        productForm.value.taxInclusiveTotalPrice = 0;
       }
       // 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠�
       if (productForm.value.quantity) {
-        productForm.value.taxInclusiveUnitPrice = (
+        productForm.value.taxInclusiveUnitPrice = toDisplayNumber(
           Number(productForm.value.taxInclusiveTotalPrice) /
-          Number(productForm.value.quantity)
-        ).toFixed(6);
+            Number(productForm.value.quantity)
+        );
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
-          productForm.value.taxInclusiveUnitPrice = "0";
+          productForm.value.taxInclusiveUnitPrice = 0;
         }
       }
       // 宸茬煡鍚◣鍗曚环锛屽弽绠楁暟閲�
       else if (productForm.value.taxInclusiveUnitPrice) {
-        productForm.value.quantity = (
+        productForm.value.quantity = toDisplayNumber(
           Number(productForm.value.taxInclusiveTotalPrice) /
-          Number(productForm.value.taxInclusiveUnitPrice)
-        ).toFixed(6);
+            Number(productForm.value.taxInclusiveUnitPrice)
+        );
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.quantity) < 0) {
-          productForm.value.quantity = "0";
+          productForm.value.quantity = 0;
         }
       }
     }

--
Gitblit v1.9.3