From e1e0907fb7e538e559d984e1021f3c7db645a678 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 23 五月 2026 11:30:44 +0800
Subject: [PATCH] 天津宝东 1.销售台账编辑权限修改

---
 src/views/salesManagement/salesLedger/index.vue |  112 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 96 insertions(+), 16 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 3d88828..2784f80 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -158,6 +158,8 @@
               </el-table-column>
               <el-table-column label="鏁伴噺"
                                prop="quantity" />
+              <el-table-column label="姣忎欢鏁伴噺"
+                               prop="singleQuantity" />
               <el-table-column label="寰呭彂璐ф暟閲�"
                                prop="noQuantity" />
               <el-table-column label="绋庣巼(%)"
@@ -243,7 +245,7 @@
             <el-button link
                        type="primary"
                        @click="openForm('edit', scope.row)"
-                       :disabled="!scope.row.isEdit || scope.row.hasProductionRecord || !canEditLedger(scope.row)">缂栬緫
+                       :disabled="!canEditLedger(scope.row)">缂栬緫
             </el-button>
             <el-button link
                        type="primary"
@@ -287,10 +289,15 @@
           <el-col :span="12">
             <el-form-item label="閿�鍞悎鍚屽彿锛�"
                           prop="salesContractNo">
-              <el-input v-model="form.salesContractNo"
-                        placeholder="鑷姩鐢熸垚"
-                        clearable
-                        disabled />
+              <div style="display: flex; align-items: center; gap: 12px;width: 100%;">
+                <el-checkbox v-model="form.autoGenerateContractNo" v-if="operationType === 'add'">鑷姩鐢熸垚
+                </el-checkbox>
+                <el-input v-model="form.salesContractNo"
+                          :placeholder="form.autoGenerateContractNo ? '鑷姩鐢熸垚' : '璇疯緭鍏�'"
+                          clearable
+                          :disabled="form.autoGenerateContractNo" />
+
+              </div>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -443,6 +450,8 @@
                            prop="unit" />
           <el-table-column label="鏁伴噺"
                            prop="quantity" />
+          <el-table-column label="姣忎欢鏁伴噺"
+                           prop="singleQuantity" />
           <el-table-column label="绋庣巼(%)"
                            prop="taxRate" />
           <el-table-column label="鍚◣鍗曚环(鍏�)"
@@ -673,6 +682,21 @@
                                clearable
                                :precision="2"
                                @change="calculateFromQuantity"
+                               style="width: 100%" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="姣忎欢鏁伴噺锛�"
+                          prop="singleQuantity">
+              <el-input-number :step="1"
+                               :min="1"
+                               v-model="productForm.singleQuantity"
+                               placeholder="璇疯緭鍏�"
+                               clearable
+                               :precision="0"
+                               @change="calculateFromSingleQuantity"
                                style="width: 100%" />
             </el-form-item>
           </el-col>
@@ -954,7 +978,7 @@
         </el-row>
         <el-row :gutter="30">
           <el-col :span="24">
-            <el-form-item label="鎵瑰彿锛�"
+            <el-form-item label="搴撳瓨锛�"
                           prop="batchNo">
               <el-table :data="deliveryForm.batchNoList"
                         border
@@ -964,6 +988,15 @@
                 <el-table-column label="鎵瑰彿"
                                  prop="batchNo"
                                  min-width="180" />
+                <el-table-column label="浜у搧澶х被"
+                                 prop="productName"
+                                 min-width="100" />
+                <el-table-column label="瑙勬牸鍨嬪彿"
+                                 prop="model"
+                                 min-width="100" />
+                <el-table-column label="鍗曚綅"
+                                 prop="unit"
+                                 min-width="100" />
                 <el-table-column label="搴撳瓨鏁伴噺"
                                  min-width="120"
                                  align="center">
@@ -1072,6 +1105,7 @@
     },
     form: {
       salesContractNo: "",
+      autoGenerateContractNo: true,
       salesman: "",
       customerId: "",
       entryPerson: "",
@@ -1080,7 +1114,6 @@
       maintenanceTime: "",
       productData: [],
       executionDate: "",
-      hasProductionRecord: false,
     },
     rules: {
       salesman: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1103,6 +1136,7 @@
       specificationModel: "",
       unit: "",
       quantity: "",
+      singleQuantity: 1,
       taxInclusiveUnitPrice: "",
       taxRate: "",
       taxInclusiveTotalPrice: "",
@@ -1590,6 +1624,8 @@
       form.value.entryDate = getCurrentDate();
       // 绛捐鏃ユ湡榛樿涓哄綋澶�
       form.value.executionDate = getCurrentDate();
+      // 榛樿鑷姩鐢熸垚閿�鍞悎鍚屽彿
+      form.value.autoGenerateContractNo = true;
     } else {
       currentId.value = row.id;
       getSalesLedgerWithProducts({ id: row.id, type: 1 }).then(res => {
@@ -1597,6 +1633,8 @@
         form.value.entryPerson = Number(res.entryPerson);
         productData.value = form.value.productData;
         fileList.value = form.value.storageBlobVOs;
+        // 缂栬緫鏃惰缃嚜鍔ㄧ敓鎴愪负false锛屽厑璁告墜鍔ㄤ慨鏀�
+        form.value.autoGenerateContractNo = false;
       });
     }
     // let userAll = await userStore.getInfo()
@@ -1708,6 +1746,8 @@
         taxExclusiveTotalPrice: taxExclusiveTotalPrice,
         invoiceType: "澧炴櫘绁�",
         isProduction: true,
+        productId: p.productId,
+        productModelId: p.productModelId
       };
     });
 
@@ -1731,6 +1771,9 @@
         }
         form.value.storageBlobDTOs = fileList;
         form.value.type = 1;
+        if (form.value.autoGenerateContractNo) {
+          form.value.salesContractNo = '';
+        }
         addOrUpdateSalesLedger(form.value).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeDia();
@@ -2426,6 +2469,7 @@
 
     const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
     const quantity = parseFloat(productForm.value.quantity);
+    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
 
     if (!totalPrice || !quantity || quantity <= 0) {
       return;
@@ -2433,8 +2477,8 @@
 
     isCalculating.value = true;
 
-    // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
-    productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
+    // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / (鏁伴噺 * 姣忎欢鏁伴噺)
+    productForm.value.taxInclusiveUnitPrice = (totalPrice / (quantity * singleQuantity)).toFixed(2);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -2461,6 +2505,7 @@
     );
     const quantity = parseFloat(productForm.value.quantity);
     const taxRate = parseFloat(productForm.value.taxRate);
+    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
 
     if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
       return;
@@ -2473,9 +2518,9 @@
     const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
     productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
 
-    // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
+    // 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / (鏁伴噺 * 姣忎欢鏁伴噺)
     productForm.value.taxInclusiveUnitPrice = (
-      inclusiveTotalPrice / quantity
+      inclusiveTotalPrice / (quantity * singleQuantity)
     ).toFixed(2);
 
     isCalculating.value = false;
@@ -2491,6 +2536,7 @@
 
     const quantity = parseFloat(productForm.value.quantity);
     const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
+    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
 
     if (!quantity || quantity <= 0 || !unitPrice) {
       return;
@@ -2498,8 +2544,8 @@
 
     isCalculating.value = true;
 
-    // 璁$畻鍚◣鎬讳环
-    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+    // 璁$畻鍚◣鎬讳环 = 鍗曚环 * 鏁伴噺 * 姣忎欢鏁伴噺
+    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -2523,6 +2569,7 @@
 
     const quantity = parseFloat(productForm.value.quantity);
     const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
+    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
 
     if (!quantity || quantity <= 0 || !unitPrice) {
       return;
@@ -2530,8 +2577,41 @@
 
     isCalculating.value = true;
 
-    // 璁$畻鍚◣鎬讳环
-    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+    // 璁$畻鍚◣鎬讳环 = 鍗曚环 * 鏁伴噺 * 姣忎欢鏁伴噺
+    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
+
+    // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
+    if (productForm.value.taxRate) {
+      productForm.value.taxExclusiveTotalPrice =
+        proxy.calculateTaxExclusiveTotalPrice(
+          productForm.value.taxInclusiveTotalPrice,
+          productForm.value.taxRate
+        );
+    }
+
+    isCalculating.value = false;
+  };
+
+  // 鏍规嵁姣忎欢鏁伴噺鍙樺寲璁$畻鎬讳环
+  const calculateFromSingleQuantity = () => {
+    if (!productForm.value.taxRate) {
+      proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+      return;
+    }
+    if (isCalculating.value) return;
+
+    const quantity = parseFloat(productForm.value.quantity);
+    const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
+    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
+
+    if (!quantity || quantity <= 0 || !unitPrice) {
+      return;
+    }
+
+    isCalculating.value = true;
+
+    // 璁$畻鍚◣鎬讳环 = 鍗曚环 * 鏁伴噺 * 姣忎欢鏁伴噺
+    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
 
     // 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
     if (productForm.value.taxRate) {
@@ -3041,4 +3121,4 @@
       page-break-after: avoid;
     }
   }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3