From 9f3bc47b98cbc51df7cfcea94d4aa0c35f40cbc5 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 13 十月 2026 14:09:06 +0800
Subject: [PATCH] feat: 添加数字格式化工具,支持去掉小数末尾多余的 0 和四舍五入功能

---
 src/views/procurementManagement/procurementLedger/index.vue |  114 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 89 insertions(+), 25 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 6fef889..61852f4 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -66,6 +66,10 @@
     </div>
     <div class="table_list">
       <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
+        <el-button type="success"
+                   plain
+                   v-if="false"
+                   @click="handleBatchGenerate">鎵归噺鐢熸垚鏁版嵁</el-button>
         <el-button type="primary"
                    @click="openForm('add')">鏂板鍙拌处</el-button>
         <el-button type="primary"
@@ -121,7 +125,7 @@
               <el-table-column label="鍙敤鏁伴噺"
                                prop="availableQuality" />
               <el-table-column label="閫�璐ф暟閲�"
-                               prop="returnQuality" />
+                               prop="returnQuantity" />
               <el-table-column label="绋庣巼(%)"
                                prop="taxRate" />
               <el-table-column label="鍚◣鍗曚环(鍏�)"
@@ -144,10 +148,10 @@
                          prop="purchaseContractNumber"
                          width="160"
                          show-overflow-tooltip />
-        <el-table-column label="閿�鍞悎鍚屽彿"
-                         prop="salesContractNo"
-                         width="160"
-                         show-overflow-tooltip />
+<!--        <el-table-column label="閿�鍞悎鍚屽彿"-->
+<!--                         prop="salesContractNo"-->
+<!--                         width="160"-->
+<!--                         show-overflow-tooltip />-->
         <el-table-column label="渚涘簲鍟嗗悕绉�"
                          prop="supplierName"
                          width="160"
@@ -191,6 +195,11 @@
                          width="200"
                          show-overflow-tooltip
                          :formatter="formattedNumber" />
+<!--        <el-table-column label="瀹為檯鍚堝悓閲戦(鍏�)"-->
+<!--                         prop="netContractAmount"-->
+<!--                         width="200"-->
+<!--                         show-overflow-tooltip-->
+<!--                         :formatter="formattedNumber" />-->
         <el-table-column label="褰曞叆浜�"
                          prop="recorderName"
                          width="120"
@@ -590,7 +599,7 @@
             <el-form-item label="鍚◣鍗曚环(鍏�)锛�"
                           prop="taxInclusiveUnitPrice">
               <el-input-number v-model="productForm.taxInclusiveUnitPrice"
-                               :precision="2"
+                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -603,7 +612,7 @@
                           prop="quantity">
               <el-input-number :step="0.1"
                                clearable
-                               :precision="2"
+                               :precision="6"
                                :min="0"
                                style="width: 100%"
                                v-model="productForm.quantity"
@@ -617,7 +626,7 @@
             <el-form-item label="鍚◣鎬讳环(鍏�)锛�"
                           prop="taxInclusiveTotalPrice">
               <el-input-number v-model="productForm.taxInclusiveTotalPrice"
-                               :precision="2"
+                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -629,7 +638,7 @@
             <el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�"
                           prop="taxExclusiveTotalPrice">
               <el-input-number v-model="productForm.taxExclusiveTotalPrice"
-                               :precision="2"
+                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -656,7 +665,7 @@
             <el-form-item label="搴撳瓨棰勮鏁伴噺锛�"
                           prop="warnNum">
               <el-input-number v-model="productForm.warnNum"
-                               :precision="2"
+                               :precision="6"
                                :step="0.1"
                                :min="0"
                                clearable
@@ -721,6 +730,7 @@
     getOptions,
     getPurchaseTemplateList,
     delPurchaseTemplate,
+    batchGeneratePurchaseInboundSteps,
   } from "@/api/procurementManagement/procurementLedger.js";
   import useFormData from "@/hooks/useFormData.js";
   const FileList = defineAsyncComponent(() =>
@@ -751,6 +761,7 @@
   import { modelList, productTreeList } from "@/api/basicData/product.js";
   import dayjs from "dayjs";
   import FileUpload from "@/components/AttachmentUpload/file/index.vue";
+  import { trimZeros } from "@/utils/formatNumber.js";
 
   const userStore = useUserStore();
 
@@ -1075,7 +1086,7 @@
   };
 
   const formattedNumber = (row, column, cellValue) => {
-    return parseFloat(cellValue).toFixed(2);
+    return trimZeros(cellValue, 6);
   };
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -1195,6 +1206,11 @@
         "futureTicketsAmount",
       ],
       {
+        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
+        taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+        taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+        ticketsAmount: { decimalPlaces: 6, trimZeros: true },
+        futureTicketsAmount: { decimalPlaces: 6, trimZeros: true },
         ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
         futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
       }
@@ -1260,15 +1276,30 @@
   };
   // 涓昏〃鍚堣鏂规硶
   const summarizeMainTable = param => {
-    return proxy.summarizeTable(param, ["contractAmount"]);
+    return proxy.summarizeTable(
+      param,
+      ["contractAmount", "netContractAmount"],
+      {
+        contractAmount: { decimalPlaces: 6, trimZeros: true },
+        netContractAmount: { decimalPlaces: 6, trimZeros: true },
+      }
+    );
   };
   // 瀛愯〃鍚堣鏂规硶
   const summarizeProTable = param => {
-    return proxy.summarizeTable(param, [
-      "taxInclusiveUnitPrice",
-      "taxInclusiveTotalPrice",
-      "taxExclusiveTotalPrice",
-    ]);
+    return proxy.summarizeTable(
+      param,
+      [
+        "taxInclusiveUnitPrice",
+        "taxInclusiveTotalPrice",
+        "taxExclusiveTotalPrice",
+      ],
+      {
+        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
+        taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+        taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+      }
+    );
   };
   // 鎵撳紑寮规
   const openForm = async (type, row) => {
@@ -1721,6 +1752,37 @@
       });
   };
 
+  const handleBatchGenerate = async () => {
+    if (selectedRows.value.length === 0) {
+      proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+      return;
+    }
+    const ids = selectedRows.value.map((item) => item.id);
+    
+    ElMessageBox.confirm("纭鎵归噺鐢熸垚鏁版嵁锛�", "鎵归噺鐢熸垚", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "info",
+    })
+      .then(() => {
+        proxy.$modal.loading("姝e湪鎵归噺鐢熸垚鏁版嵁锛岃绋嶅��...");
+        batchGeneratePurchaseInboundSteps({ ids })
+          .then((res) => {
+            proxy.$modal.msgSuccess("鎵归噺鐢熸垚鎴愬姛");
+            getList();
+          })
+          .catch(() => {
+            proxy.$modal.msgError("鎵归噺鐢熸垚澶辫触");
+          })
+          .finally(() => {
+            proxy.$modal.closeLoading();
+          });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
+  };
+
   // 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
   function getCurrentDate() {
     const today = new Date();
@@ -1745,14 +1807,16 @@
     productForm.value.taxInclusiveTotalPrice =
       proxy.calculateTaxIncludeTotalPrice(
         productForm.value.taxInclusiveUnitPrice,
-        productForm.value.quantity
+        productForm.value.quantity,
+        6
       );
     if (productForm.value.taxRate) {
       // 涓嶅惈绋庢�讳环璁$畻
       productForm.value.taxExclusiveTotalPrice =
         proxy.calculateTaxExclusiveTotalPrice(
           productForm.value.taxInclusiveTotalPrice,
-          productForm.value.taxRate
+          productForm.value.taxRate,
+          6
         );
     }
   };
@@ -1783,7 +1847,7 @@
         productForm.value.taxInclusiveUnitPrice = (
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.quantity)
-        ).toFixed(2);
+        ).toFixed(6);
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
           productForm.value.taxInclusiveUnitPrice = "0";
@@ -1794,7 +1858,7 @@
         productForm.value.quantity = (
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.taxInclusiveUnitPrice)
-        ).toFixed(2);
+        ).toFixed(6);
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.quantity) < 0) {
           productForm.value.quantity = "0";
@@ -1804,7 +1868,7 @@
       productForm.value.taxExclusiveTotalPrice = (
         Number(productForm.value.taxInclusiveTotalPrice) /
         (1 + taxRate / 100)
-      ).toFixed(2);
+      ).toFixed(6);
       // 纭繚缁撴灉涓嶄负璐熸暟
       if (Number(productForm.value.taxExclusiveTotalPrice) < 0) {
         productForm.value.taxExclusiveTotalPrice = "0";
@@ -1814,7 +1878,7 @@
       productForm.value.taxInclusiveTotalPrice = (
         Number(productForm.value.taxExclusiveTotalPrice) *
         (1 + taxRate / 100)
-      ).toFixed(2);
+      ).toFixed(6);
       // 纭繚缁撴灉涓嶄负璐熸暟
       if (Number(productForm.value.taxInclusiveTotalPrice) < 0) {
         productForm.value.taxInclusiveTotalPrice = "0";
@@ -1824,7 +1888,7 @@
         productForm.value.taxInclusiveUnitPrice = (
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.quantity)
-        ).toFixed(2);
+        ).toFixed(6);
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
           productForm.value.taxInclusiveUnitPrice = "0";
@@ -1835,7 +1899,7 @@
         productForm.value.quantity = (
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.taxInclusiveUnitPrice)
-        ).toFixed(2);
+        ).toFixed(6);
         // 纭繚缁撴灉涓嶄负璐熸暟
         if (Number(productForm.value.quantity) < 0) {
           productForm.value.quantity = "0";

--
Gitblit v1.9.3