zhang_nuo
2026-08-26 9b25e5c7a4e2e300b213ad4d5fb4d4b72cdced39
src/views/procurementManagement/purchaseReturnOrder/New.vue
@@ -3,8 +3,10 @@
    <el-dialog
        v-model="isShow"
        title="新增采购退货"
        width="1600"
        width="70%"
        top="3vh"
        @close="closeModal"
        class="purchase-return-dialog"
    >
      <el-form label-width="140px" :model="formState" label-position="top" ref="formRef" :inline="true">
        <div class="section-title">
@@ -221,19 +223,19 @@
          <el-input style="width: 240px" v-model="formState.remark" :rows="1" type="textarea" placeholder="请输入备注"/>
        </el-form-item>
        <div style="margin: 20px 0;">
        <div style="margin:20px 0;min-width:0;">
            <div class="section-title">
              <span class="title-dot"></span>
              <span class="title-text">产品列表</span>
            </div>
            <el-button type="primary" size="small" style="margin-bottom: 20px" @click="isShowProductsModal = true" :disabled="!formState.purchaseLedgerId">添加产品</el-button>
            <div class="product-table-scroll">
            <el-table class="product-table-inner"
            <el-button type="primary" size="small" style="margin-bottom:20px" @click="isShowProductsModal = true" :disabled="!formState.purchaseLedgerId">添加产品</el-button>
            <el-table
                      :data="formState.purchaseReturnOrderProductsDtos"
                      border
                      max-height="400"
                      show-summary
                      :summary-method="summarizeChildrenTable">
                      :summary-method="summarizeChildrenTable"
                      style="width:100%;min-width:0;">
              <el-table-column align="center"
                               type="selection"
                               width="55" />
@@ -261,8 +263,11 @@
                               prop="unQuantity"
                               width="130" />
              <el-table-column label="已退货数量"
                               prop="totalReturnNum"
                               width="130" />
                               width="130">
                <template #default="scope">
                  {{ calcAlreadyReturned(scope.row) }}
                </template>
              </el-table-column>
              <el-table-column label="退货数量"
                               prop="returnQuantity"
                               width="180">
@@ -270,6 +275,7 @@
                  <el-input-number v-model="scope.row.returnQuantity"
                            controls-position="right"
                            :step="1"
                            :precision="6"
                            :min="0"
                            :max="getReturnQtyMax(scope.row)"
                            :disabled="getReturnQtyMax(scope.row) <= 0"
@@ -321,7 +327,6 @@
                </template>
              </el-table-column>
            </el-table>
            </div>
          </div>
        <div class="section-title">
@@ -336,7 +341,7 @@
          <el-input-number v-model="formState.totalDiscountAmount"
                           controls-position="right"
                           :step="0.01"
                           :precision="2"
                           :precision="6"
                           style="width: 100%;"
                           @change="handleChangeTotalDiscountAmount"
                           placeholder="请输入整单折扣额"/>
@@ -349,7 +354,7 @@
          <el-input v-model="formState.totalDiscountRate"
                           controls-position="right"
                           :step="0.01"
                           :precision="2"
                           :precision="6"
                           style="width: 100%;"
                           @change="totalDiscount"
                           placeholder="请输入整单折扣率">
@@ -373,7 +378,7 @@
          <el-input-number v-model="formState.totalAmount"
                           controls-position="right"
                           :step="0.01"
                           :precision="2"
                           :precision="6"
                           style="width: 100%;"
                           placeholder="请输入成交金额"/>
        </el-form-item>
@@ -507,7 +512,7 @@
});
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
  return parseFloat(cellValue).toFixed(6);
};
const formatAmount = (value) => {
@@ -518,7 +523,7 @@
  if (Number.isNaN(num)) {
    return '--'
  }
  return num.toFixed(2)
  return num.toFixed(6)
}
const toNumber = (val) => {
@@ -526,11 +531,20 @@
  return Number.isNaN(num) ? 0 : num
}
/** 已退货数量 = 入库行总数量 − 当前可退货数量(剩余) */
const calcAlreadyReturned = (row) => {
  const total = Number(row?.stockInNum ?? row?.totalQuantity ?? row?.quantity ?? 0)
  const un = Number(row?.unQuantity ?? 0)
  if (!Number.isFinite(total) || !Number.isFinite(un)) return 0
  // 保留6位小数,避免浮点减法产生精度误差
  return Math.max(parseFloat((total - un).toFixed(6)), 0)
}
const getReturnTotal = (row) => {
  const qty = toNumber(row?.returnQuantity)
  const unitPrice = toNumber(row?.taxInclusiveUnitPrice)
  const total = qty * unitPrice
  return Number(total.toFixed(2))
  return Number(total.toFixed(6))
}
const syncReturnTotal = (row) => {
@@ -556,7 +570,7 @@
  }
  const baseAmount = getBaseAmount()
  // 折扣额 = 产品退货总价合计 * 折扣率
  formState.value.totalDiscountAmount = Number((baseAmount * (discountRate / 100)).toFixed(2))
  formState.value.totalDiscountAmount = Number((baseAmount * (discountRate / 100)).toFixed(6))
  syncTotalAmount()
}
@@ -584,9 +598,12 @@
        "taxExclusiveTotalPrice",
      ],
      {
        stockInNum: { noDecimal: true }, // 不保留小数
        returnQuantity: { noDecimal: true }, // 不保留小数
        unQuantity: { noDecimal: true }, // 不保留小数
        stockInNum: { decimalPlaces: 6 },
        returnQuantity: { decimalPlaces: 6 },
        unQuantity: { decimalPlaces: 6 },
        taxInclusiveUnitPrice: { decimalPlaces: 6 },
        taxInclusiveTotalPrice: { decimalPlaces: 6 },
        taxExclusiveTotalPrice: { decimalPlaces: 6 },
      }
  );
};
@@ -608,11 +625,11 @@
  if (normalizedAmount > baseAmount) {
    proxy.$modal.msgError("整单折扣额不能大于产品退货总价合计")
    formState.value.totalDiscountAmount = Number(baseAmount.toFixed(2))
    formState.value.totalDiscountAmount = Number(baseAmount.toFixed(6))
  }
  const discountRate = (toNumber(formState.value.totalDiscountAmount) / baseAmount) * 100
  formState.value.totalDiscountRate = Number(discountRate.toFixed(2))
  formState.value.totalDiscountRate = Number(discountRate.toFixed(6))
  syncTotalAmount()
}
@@ -627,7 +644,7 @@
  const baseAmount = getBaseAmount()
  const discount = toNumber(formState.value.totalDiscountAmount)
  // 成交金额 = 产品退货总价合计 - 折扣额
  formState.value.totalAmount = Number((baseAmount - discount).toFixed(2))
  formState.value.totalAmount = Number((baseAmount - discount).toFixed(6))
}
// 获取供应商选项
@@ -689,7 +706,7 @@
    ...item,
    returnQuantity: undefined,
    taxInclusiveTotalPrice: 0,
    salesLedgerProductId: item.salesLedgerProductId ?? item.id,
    // salesLedgerProductId: item.salesLedgerProductId,
  }));
  formState.value.purchaseReturnOrderProductsDtos.push(...newProducts);
  syncTotalAmount()
@@ -792,12 +809,5 @@
  margin-right: 8px;
}
.product-table-scroll {
  width: 100%;
  overflow-x: auto;
}
.product-table-inner {
  min-width: 1280px;
}
</style>