From 4e591bd0b0042c4bc28f7a999ceea064f8ed5d43 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 02 六月 2026 17:28:06 +0800
Subject: [PATCH] 富边商务电子 1.发货审批点击详情的时候产品列表没有展示问题

---
 src/views/procurementManagement/purchaseReturnOrder/New.vue |   94 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/src/views/procurementManagement/purchaseReturnOrder/New.vue b/src/views/procurementManagement/purchaseReturnOrder/New.vue
index f130733..b9bf522 100644
--- a/src/views/procurementManagement/purchaseReturnOrder/New.vue
+++ b/src/views/procurementManagement/purchaseReturnOrder/New.vue
@@ -184,12 +184,12 @@
         </el-form-item>
 
         <el-form-item
-            label="閲囪喘鍚堝悓鍙凤細"
+            label="閲囪喘鍗曞彿锛�"
             prop="purchaseLedgerId"
             :rules="[
               {
                 required: true,
-                message: '璇烽�夋嫨閲囪喘鍚堝悓鍙�',
+                message: '璇烽�夋嫨閲囪喘鍗曞彿',
                 trigger: 'change',
               }
             ]"
@@ -334,12 +334,17 @@
             label="鏁村崟鎶樻墸鐜囷細"
             prop="totalDiscountAmount"
         >
-          <el-input-number v-model="formState.totalDiscountRate"
+          <el-input v-model="formState.totalDiscountRate"
                            controls-position="right"
                            :step="0.01"
                            :precision="2"
                            style="width: 100%;"
-                           placeholder="璇疯緭鍏ユ暣鍗曟姌鎵g巼"/>
+                           @change="totalDiscount"
+                           placeholder="璇疯緭鍏ユ暣鍗曟姌鎵g巼">
+            <template #append>
+                %
+            </template>
+          </el-input>
         </el-form-item>
 
         <el-form-item
@@ -372,7 +377,7 @@
           v-model="formState.incomeType"
           placeholder="璇烽�夋嫨"
           clearable
-          
+
         >
           <el-option :label="item.label" :value="item.value" v-for="(item,index) in payment_methods" :key="index" />
         </el-select>
@@ -412,7 +417,24 @@
   }
 });
 let { proxy } = getCurrentInstance()
-const { payment_methods } = proxy.useDict("payment_methods");
+const payment_methods  = [
+    {
+        "label": "鐜伴噾",
+        "value": "0",
+    },
+    {
+        "label": "鏀エ",
+        "value": "1",
+    },
+    {
+        "label": "閾惰杞处",
+        "value": "2",
+    },
+    {
+        "label": "鍏朵粬",
+        "value": "3",
+    },
+]
 const emit = defineEmits(['update:visible', 'completed']);
 
 // 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
@@ -509,6 +531,26 @@
   row.taxInclusiveTotalPrice = getReturnTotal(row)
 }
 
+const getBaseAmount = () => {
+  const rows = formState.value.purchaseReturnOrderProductsDtos || []
+  return rows.reduce((sum, item) => {
+    return sum + toNumber(item.taxInclusiveTotalPrice)
+  }, 0)
+}
+
+// 鍚屾鎶樻墸棰�
+const totalDiscount = () => {
+  const discountRate = toNumber(formState.value.totalDiscountRate)
+  if (discountRate < 0 || discountRate > 100) {
+    proxy.$modal.msgError("璇疯緭鍏�0-100涔嬮棿鐨勬姌鎵g巼")
+    return
+  }
+  const baseAmount = getBaseAmount()
+  // 鎶樻墸棰� = 浜у搧閫�璐ф�讳环鍚堣 * 鎶樻墸鐜�
+  formState.value.totalDiscountAmount = Number((baseAmount * (discountRate / 100)).toFixed(2))
+  syncTotalAmount()
+}
+
 const getReturnQtyMax = (row) => {
   const max = Number(row?.availableQuality)
   if (Number.isNaN(max) || max < 0) {
@@ -541,14 +583,39 @@
 };
 
 const handleChangeTotalDiscountAmount= () => {
+  const discountAmount = toNumber(formState.value.totalDiscountAmount)
+  if (discountAmount < 0) {
+    proxy.$modal.msgError("鏁村崟鎶樻墸棰濅笉鑳藉皬浜�0")
+    formState.value.totalDiscountAmount = 0
+  }
+
+  const baseAmount = getBaseAmount()
+  const normalizedAmount = toNumber(formState.value.totalDiscountAmount)
+  if (baseAmount <= 0) {
+    formState.value.totalDiscountRate = 0
+    syncTotalAmount()
+    return
+  }
+
+  if (normalizedAmount > baseAmount) {
+    proxy.$modal.msgError("鏁村崟鎶樻墸棰濅笉鑳藉ぇ浜庝骇鍝侀��璐ф�讳环鍚堣")
+    formState.value.totalDiscountAmount = Number(baseAmount.toFixed(2))
+  }
+
+  const discountRate = (toNumber(formState.value.totalDiscountAmount) / baseAmount) * 100
+  formState.value.totalDiscountRate = Number(discountRate.toFixed(2))
   syncTotalAmount()
 }
 
+const resetFeeInfo = () => {
+  formState.value.totalDiscountAmount = 0
+  formState.value.totalDiscountRate = undefined
+  formState.value.totalAmount = 0
+  formState.value.incomeType = undefined
+}
+
 const syncTotalAmount = () => {
-  const rows = formState.value.purchaseReturnOrderProductsDtos || []
-  const baseAmount = rows.reduce((sum, item) => {
-    return sum + toNumber(item.taxInclusiveTotalPrice)
-  }, 0)
+  const baseAmount = getBaseAmount()
   const discount = toNumber(formState.value.totalDiscountAmount)
   // 鎴愪氦閲戦 = 浜у搧閫�璐ф�讳环鍚堣 - 鎶樻墸棰�
   formState.value.totalAmount = Number((baseAmount - discount).toFixed(2))
@@ -594,6 +661,11 @@
 
 // 澶勭悊鏀瑰彉閲囪喘鍙拌处鏁版嵁
 const handleChangePurchaseLedgerId = async () => {
+  resetFeeInfo()
+  if (!formState.value.purchaseLedgerId) {
+    formState.value.purchaseReturnOrderProductsDtos = []
+    return
+  }
   const res = await productList({ salesLedgerId: formState.value.purchaseLedgerId, type: 2 });
   formState.value.purchaseReturnOrderProductsDtos = res.data.map(item => ({
     ...item,
@@ -712,4 +784,4 @@
   border-radius: 50%;
   margin-right: 8px;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3