From 0a251e40e30e7c8a96d71b3b9b6c459d4dfa4b22 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 08 七月 2026 23:04:45 +0800
Subject: [PATCH] 暂存

---
 src/views/salesManagement/salesLedger/index.vue |  145 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 106 insertions(+), 39 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index d40b1bf..60deda9 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -123,9 +123,11 @@
               </el-table-column>
               <el-table-column label="蹇�掑叕鍙�"
                                prop="expressCompany"
+                               v-if="false"
                                show-overflow-tooltip />
               <el-table-column label="蹇�掑崟鍙�"
                                prop="expressNumber"
+                               v-if="false"
                                show-overflow-tooltip />
               <el-table-column label="鍙戣揣杞︾墝"
                                minWidth="100px"
@@ -566,7 +568,7 @@
                          width="160"
                          align="right">
           <template #default="scope">
-            {{ Number(scope.row.totalAmount ?? 0).toFixed(2) }}
+            {{ formatDecimal(scope.row.totalAmount) }}
           </template>
         </el-table-column>
         <el-table-column fixed="right"
@@ -664,11 +666,11 @@
           <el-col :span="12">
             <el-form-item label="鍚◣鍗曚环(鍏�)锛�"
                           prop="taxInclusiveUnitPrice">
-              <el-input-number :step="0.01"
+              <el-input-number :step="0.000001"
                                :min="0"
                                v-model="productForm.taxInclusiveUnitPrice"
                                style="width: 100%"
-                               :precision="2"
+                               :precision="6"
                                placeholder="璇疯緭鍏�"
                                clearable
                                @change="calculateFromUnitPrice" />
@@ -722,17 +724,38 @@
               </el-select>
             </el-form-item>
           </el-col>
-<!--          <el-col :span="12">
+          <el-col :span="12">
             <el-form-item label="鏄惁鐢熶骇锛�"
                           prop="isProduction">
-              <el-radio-group v-model="productForm.isProduction">
-                <el-radio label="鏄�"
-                          :value="true" />
-                <el-radio label="鍚�"
-                          :value="false" />
-              </el-radio-group>
+              <div style="display: flex; align-items: center; width: 100%;">
+                <el-radio-group v-model="productForm.isProduction">
+                  <el-radio label="鏄�"
+                            :value="true" />
+                  <el-radio label="鍚�"
+                            :value="false" />
+                </el-radio-group>
+                <div 
+                  v-if="currentStock !== null" 
+                  :style="{
+                    marginLeft: '20px',
+                    padding: '0 12px',
+                    height: '28px',
+                    lineHeight: '28px',
+                    borderRadius: '4px',
+                    fontSize: '13px',
+                    fontWeight: '500',
+                    display: 'inline-block',
+                    whiteSpace: 'nowrap',
+                    backgroundColor: (productForm.quantity || 0) > currentStock ? '#fff0f0' : '#f0f9eb',
+                    border: (productForm.quantity || 0) > currentStock ? '1px solid #ffcccc' : '1px solid #e1f3d8',
+                    color: (productForm.quantity || 0) > currentStock ? '#f56c6c' : '#67c23a'
+                  }"
+                >
+                  <span>褰撳墠搴撳瓨锛歿{ currentStock }} {{ productForm.unit || '' }}</span>
+                </div>
+              </div>
             </el-form-item>
-          </el-col>-->
+          </el-col>
         </el-row>
       </el-form>
     </FormDialog>
@@ -917,6 +940,7 @@
                 <el-option label="璐ц溅"
                            value="璐ц溅" />
                 <el-option label="蹇��"
+                           v-if="false"
                            value="蹇��" />
               </el-select>
             </el-form-item>
@@ -939,7 +963,7 @@
             </el-form-item>
           </el-col>
           <el-col :span="24"
-                  v-else>
+                  v-else-if="false">
             <el-form-item label="蹇�掑叕鍙革細"
                           prop="expressCompany">
               <el-input v-model="deliveryForm.expressCompany"
@@ -949,7 +973,7 @@
           </el-col>
         </el-row>
         <el-row :gutter="30"
-                v-if="deliveryForm.type === '蹇��'">
+                v-if="false">
           <el-col :span="24">
             <el-form-item label="蹇�掑崟鍙凤細"
                           prop="expressNumber">
@@ -1017,6 +1041,7 @@
       <template #footer>
         <div class="dialog-footer">
           <el-button type="primary"
+                     :loading="deliveryLoading"
                      @click="submitDelivery">纭鍙戣揣
           </el-button>
           <el-button @click="closeDeliveryDia">鍙栨秷</el-button>
@@ -1053,6 +1078,11 @@
   import useFormData from "@/hooks/useFormData.js";
   import dayjs from "dayjs";
   import FileUpload from "@/components/AttachmentUpload/file/index.vue";
+  import {
+    tableAmountFormatter,
+    formatDecimal,
+    buildAmountSummaryFormat,
+  } from "@/utils/numberFormat";
   import ImageUpload from "@/components/AttachmentUpload/image/index.vue";
   import { getCurrentDate } from "@/utils/index.js";
   import { listCustomer } from "@/api/basicData/customer.js";
@@ -1182,6 +1212,7 @@
 
   // 鍙戣揣鐩稿叧
   const deliveryFormVisible = ref(false);
+  const deliveryLoading = ref(false);
   const currentDeliveryRow = ref(null);
   const getDeliveryBatchQuantity = item => {
     const quantity =
@@ -1192,6 +1223,27 @@
       item?.qualifiedQuantity ??
       item?.stockQuantity;
     return quantity ?? 0;
+  };
+  const currentStock = ref(null);
+  const fetchCurrentStock = async (productModelId) => {
+    if (!productModelId) {
+      currentStock.value = null;
+      return;
+    }
+    try {
+      const res = await getStockInventoryByModelId(productModelId);
+      const rawList = Array.isArray(res?.data)
+        ? res.data
+        : res?.data?.records || res?.data?.rows || [];
+      let total = 0;
+      rawList.forEach(item => {
+        total += Number(getDeliveryBatchQuantity(item) || 0);
+      });
+      currentStock.value = total;
+    } catch (e) {
+      console.error(e);
+      currentStock.value = 0;
+    }
   };
   const getCurrentDeliveryRowQuantity = () => {
     return Number(currentDeliveryRow.value?.noQuantity || 0);
@@ -1396,12 +1448,7 @@
       return productOptions.value;
     });
   };
-  const formattedNumber = (row, column, cellValue) => {
-    if (cellValue === undefined || cellValue === null || cellValue === "") {
-      return "0.00";
-    }
-    return parseFloat(cellValue).toFixed(2);
-  };
+  const formattedNumber = tableAmountFormatter;
   const findLedgerRecordByRow = row => {
     if (!row) return null;
     if (
@@ -1458,6 +1505,7 @@
   // 鑾峰彇tree瀛愭暟鎹�
   const getModels = value => {
     productForm.value.productCategory = findNodeById(productOptions.value, value);
+    currentStock.value = null;
     modelList({ id: value }).then(res => {
       modelOptions.value = res;
     });
@@ -1467,9 +1515,11 @@
     if (index !== -1) {
       productForm.value.specificationModel = modelOptions.value[index].model;
       productForm.value.unit = modelOptions.value[index].unit;
+      fetchCurrentStock(value);
     } else {
       productForm.value.specificationModel = null;
       productForm.value.unit = null;
+      currentStock.value = null;
     }
   };
   const findNodeById = (nodes, productId) => {
@@ -1564,11 +1614,15 @@
   };
   // 涓昏〃鍚堣鏂规硶
   const summarizeMainTable = param => {
-    return proxy.summarizeTable(param, [
-      "contractAmount",
-      "taxInclusiveTotalPrice",
-      "taxExclusiveTotalPrice",
-    ]);
+    return proxy.summarizeTable(
+      param,
+      ["contractAmount", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"],
+      buildAmountSummaryFormat([
+        "contractAmount",
+        "taxInclusiveTotalPrice",
+        "taxExclusiveTotalPrice",
+      ])
+    );
   };
   // 瀛愯〃鍚堣鏂规硶
   const summarizeChildrenTable = (param, parentRow) => {
@@ -1590,11 +1644,19 @@
         return "";
       });
     }
-    return proxy.summarizeTable(param, [
-      "taxInclusiveUnitPrice",
-      "taxInclusiveTotalPrice",
-      "taxExclusiveTotalPrice",
-    ]);
+    return proxy.summarizeTable(
+      param,
+      [
+        "taxInclusiveUnitPrice",
+        "taxInclusiveTotalPrice",
+        "taxExclusiveTotalPrice",
+      ],
+      buildAmountSummaryFormat([
+        "taxInclusiveUnitPrice",
+        "taxInclusiveTotalPrice",
+        "taxExclusiveTotalPrice",
+      ])
+    );
   };
   // 鎵撳紑寮规
   const openForm = async (type, row) => {
@@ -1722,7 +1784,7 @@
       const quantity = Number(p.quantity ?? 0) || 0;
       const unitPrice = Number(p.unitPrice ?? 0) || 0;
       const taxRate = "13"; // 榛樿 13%锛屼究浜庣洿鎺ユ彁浜わ紙濡傞渶鍙湪浜у搧涓嚜琛屼慨鏀癸級
-      const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+      const taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
       const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(
         taxInclusiveTotalPrice,
         taxRate
@@ -1734,7 +1796,7 @@
         unit: p.unit || "",
         quantity: quantity,
         taxRate: taxRate,
-        taxInclusiveUnitPrice: unitPrice.toFixed(2),
+        taxInclusiveUnitPrice: formatDecimal(unitPrice),
         taxInclusiveTotalPrice: taxInclusiveTotalPrice,
         taxExclusiveTotalPrice: taxExclusiveTotalPrice,
         invoiceType: "澧炴櫘绁�",
@@ -1793,6 +1855,7 @@
 
     productOperationType.value = type;
     productForm.value = {};
+    currentStock.value = null;
     if (type === "add") {
       productForm.value.isProduction = true;
     }
@@ -1819,6 +1882,7 @@
           );
           if (currentModel) {
             productForm.value.productModelId = currentModel.id;
+            fetchCurrentStock(currentModel.id);
           }
         }
       } catch (e) {
@@ -2408,7 +2472,7 @@
     const total = products.reduce((sum, product) => {
       return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
     }, 0);
-    return total.toFixed(2);
+    return formatDecimal(total);
   };
 
   // 鐢ㄤ簬鎵撳嵃鐨勮绠楀嚱鏁�
@@ -2425,7 +2489,7 @@
     const total = products.reduce((sum, product) => {
       return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
     }, 0);
-    return total.toFixed(2);
+    return formatDecimal(total);
   };
 
   const mathNum = () => {
@@ -2466,7 +2530,7 @@
     isCalculating.value = true;
 
     // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
-    productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
+    productForm.value.taxInclusiveUnitPrice = formatDecimal(totalPrice / quantity);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -2503,12 +2567,12 @@
     // 鍏堣绠楀惈绋庢�讳环 = 涓嶅惈绋庢�讳环 / (1 - 绋庣巼/100)
     const taxRateDecimal = taxRate / 100;
     const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
-    productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
+    productForm.value.taxInclusiveTotalPrice = formatDecimal(inclusiveTotalPrice);
 
     // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
-    productForm.value.taxInclusiveUnitPrice = (
+    productForm.value.taxInclusiveUnitPrice = formatDecimal(
       inclusiveTotalPrice / quantity
-    ).toFixed(2);
+    );
 
     isCalculating.value = false;
   };
@@ -2531,7 +2595,7 @@
     isCalculating.value = true;
 
     // 璁$畻鍚◣鎬讳环
-    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+    productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -2563,7 +2627,7 @@
     isCalculating.value = true;
 
     // 璁$畻鍚◣鎬讳环
-    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+    productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -2760,6 +2824,7 @@
         const productModelId =
           currentDeliveryRow.value.productModelId ||
           currentDeliveryRow.value.modelId;
+        deliveryLoading.value = true;
         addShippingInfo({
           salesLedgerId: salesLedgerId,
           salesLedgerProductId: currentDeliveryRow.value.id,
@@ -2810,6 +2875,8 @@
               });
             }
           });
+        }).finally(() => {
+            deliveryLoading.value = false;
         });
       }
     });

--
Gitblit v1.9.3