From 64b38f57628375dff92d147ddeefd771e6e85439 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 08 七月 2026 15:55:36 +0800
Subject: [PATCH] Merge branch 'dev_NEW_pro' into dev_黎城_康森商砼

---
 src/views/salesManagement/returnOrder/components/formDia.vue |  383 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 329 insertions(+), 54 deletions(-)

diff --git a/src/views/salesManagement/returnOrder/components/formDia.vue b/src/views/salesManagement/returnOrder/components/formDia.vue
index 27bbb0d..4fc0859 100644
--- a/src/views/salesManagement/returnOrder/components/formDia.vue
+++ b/src/views/salesManagement/returnOrder/components/formDia.vue
@@ -32,7 +32,7 @@
               </el-form-item>
             </el-col>
             <el-col :span="4">
-              <el-form-item label="鍏宠仈鍑哄簱鍗曞彿锛�" prop="shippingId">
+              <el-form-item label="鍏宠仈鍙戣揣鍗曞彿锛�" prop="shippingId">
                 <el-select v-model="form.shippingId" filterable placeholder="璇烽�夋嫨鍑哄簱鍗曞彿" @change="outboundNoChange">
                   <el-option
                     v-for="item in outboundOptions"
@@ -55,19 +55,44 @@
                 <el-date-picker v-model="form.makeTime" type="datetime" style="width:100%" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss" />
               </el-form-item>
             </el-col>
-            <el-col :span="4">
+            <!-- <el-col :span="4">
               <el-form-item label="鐘舵�侊細" prop="status">
                 <el-select v-model="form.status" placeholder="璇烽�夋嫨鐘舵��">
                   <el-option label="寰呭鐞�" :value="0" />
                   <el-option label="宸插鐞�" :value="1" />
                 </el-select>
               </el-form-item>
-            </el-col>
+            </el-col> -->
             <el-col :span="4">
               <el-form-item label="閫�璐у師鍥狅細" prop="returnReason">
                 <el-input v-model="form.returnReason" placeholder="璇疯緭鍏ラ��璐у師鍥�" />
               </el-form-item>
             </el-col>
+            <el-col :span="4">
+              <el-form-item label="鍙戣揣绫诲瀷锛�" prop="shippingType">
+                <el-select v-model="form.shippingType" placeholder="璇烽�夋嫨鍙戣揣绫诲瀷" @change="handleShippingTypeChange">
+                  <el-option label="璐ц溅" :value="1" />
+                  <el-option label="蹇��" :value="2" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="4" v-if="form.shippingType === 1">
+              <el-form-item label="鍙戣揣杞︾墝鍙凤細" prop="truckPlateNo">
+                <el-input v-model="form.truckPlateNo" placeholder="璇疯緭鍏ュ彂璐ц溅鐗屽彿" />
+              </el-form-item>
+            </el-col>
+            <template v-else-if="form.shippingType === 2">
+              <el-col :span="4">
+                <el-form-item label="蹇�掑叕鍙革細" prop="expressCompany">
+                  <el-input v-model="form.expressCompany" placeholder="璇疯緭鍏ュ揩閫掑叕鍙�" />
+                </el-form-item>
+              </el-col>
+              <el-col :span="4">
+                <el-form-item label="蹇�掑崟鍙凤細" prop="expressNo">
+                  <el-input v-model="form.expressNo" placeholder="璇疯緭鍏ュ揩閫掑崟鍙�" />
+                </el-form-item>
+              </el-col>
+            </template>
             <el-col :span="4">
               <el-form-item label="閫�娆炬�婚锛�" prop="refundAmount">
                 <el-input v-model="form.refundAmount" disabled placeholder="鑷姩璁$畻" />
@@ -83,28 +108,28 @@
           </div>
           <PIMTable :isShowPagination="false" rowKey="id" :column="tableColumn" :tableData="tableData">
             <template #returnQuantity="{ row }">
-              <el-input 
-                v-model="row.returnQuantity" 
-                style="width:100px" 
-                placeholder="璇疯緭鍏�" 
+              <el-input
+                v-model="row.returnQuantity"
+                style="width:100px"
+                placeholder="璇疯緭鍏�"
                 type="number"
                 @input="(val) => handleReturnQuantityChange(val, row)"
               />
             </template>
             <template #price="{ row }">
-              <el-input 
-                v-model="row.price" 
-                style="width:100px" 
-                placeholder="璇疯緭鍏�" 
+              <el-input
+                v-model="row.price"
+                style="width:100px"
+                placeholder="璇疯緭鍏�"
                 type="number"
                 @input="(val) => handlePriceChange(val, row)"
               />
             </template>
             <template #amount="{ row }">
-              <el-input 
-                v-model="row.amount" 
-                style="width:100px" 
-                placeholder="鑷姩璁$畻" 
+              <el-input
+                v-model="row.amount"
+                style="width:100px"
+                placeholder="鑷姩璁$畻"
                 type="number"
                 disabled
               />
@@ -116,13 +141,13 @@
               </el-select>
             </template>
             <template #remark="{ row }">
-              <el-input 
-                v-model="row.remark" 
-                style="width:130px" 
-                placeholder="璇疯緭鍏�" 
+              <el-input
+                v-model="row.remark"
+                style="width:130px"
+                placeholder="璇疯緭鍏�"
               />
             </template>
-            <template #action="{ row, index }">
+            <template #action="{ index }">
               <el-button type="danger" link @click="deleteRow(index)">鍒犻櫎</el-button>
             </template>
           </PIMTable>
@@ -137,23 +162,23 @@
     </el-dialog>
 
     <el-dialog v-model="productSelectionVisible" title="閫夋嫨浜у搧" width="70%" append-to-body>
-      <el-table 
-        :data="availableProducts" 
-        style="width: 100%" 
+      <el-table
+        :data="availableProducts"
+        style="width: 100%"
         @selection-change="handleSelectionChange"
         ref="productTableRef"
         row-key="id"
       >
         <el-table-column align="center" type="selection" width="55" />
+        <el-table-column align="center" prop="outboundBatches" label="鍑哄簱鍗曞彿" />
+        <el-table-column align="center" prop="batchNo" label="鎵规鍙�" />
         <el-table-column align="center" prop="productCategory" label="浜у搧澶х被" />
         <el-table-column align="center" prop="specificationModel" label="瑙勬牸鍨嬪彿" />
         <el-table-column align="center" prop="unit" label="鍗曚綅" />
-        <el-table-column align="center" prop="quantity" label="鎬绘暟閲�" />
+        <el-table-column align="center" prop="stockOutNum" label="鎬绘暟閲�" />
+        <el-table-column align="center" label="宸查��璐ф暟閲�" prop="totalReturnNum"></el-table-column>
         <el-table-column align="center" prop="unQuantity" label="鏈��璐ф暟閲�" />
-        <el-table-column align="center" label="宸查��璐ф暟閲�">
-          <template #default="{ row }">{{ calcAlreadyReturned(row) }}</template>
-        </el-table-column>
-
+        <el-table-column align="center" prop="pendingReturnNum" label="寰呭鐞嗛��璐ф暟閲�" />
       </el-table>
       <template #footer>
         <div class="dialog-footer">
@@ -170,8 +195,8 @@
 import { returnManagementAdd, returnManagementUpdate, returnManagementGetByShippingId, getSalesLedger, returnManagementGetById } from "@/api/salesManagement/returnOrder.js";
 import useUserStore from "@/store/modules/user.js";
 import { userListNoPageByTenantId } from "@/api/system/user.js";
-import { listProject } from "@/api/oaSystem/projectManagement.js";
-import {listCustomerPrivatePool} from "@/api/basicData/customerFile.js";
+import { listProject } from "@/api/projectManagement/project.js";
+import {listCustomer} from "@/api/basicData/customer.js";
 
 const { proxy } = getCurrentInstance();
 const emit = defineEmits(['close'])
@@ -186,6 +211,10 @@
     returnNo: "",
     customerId: "",
     shippingId: "",
+    shippingType: "",
+    truckPlateNo: "",
+    expressCompany: "",
+    expressNo: "",
     projectId: "",
     maker: "",
     makeTime: "",
@@ -203,23 +232,27 @@
     }],
     customerId: [{ required: true, message: "璇烽�夋嫨瀹㈡埛", trigger: "change" }],
     shippingId: [{ required: true, message: "璇烽�夋嫨鍏宠仈鍑哄簱鍗曞彿", trigger: "change" }],
+    shippingType: [{ required: true, message: "璇烽�夋嫨鍙戣揣绫诲瀷", trigger: "change" }],
   }
 });
 const { form, rules } = toRefs(data);
 
 const calcAlreadyReturned = (row) => {
-  const total = Number(row?.quantity ?? row?.totalQuantity ?? row?.totalReturnNum ?? 0);
+  const total = Number(row?.stockOutNum ?? row?.totalQuantity ?? row?.totalReturnNum ?? 0);
   const un = Number(row?.unQuantity ?? 0);
   if (!Number.isFinite(total) || !Number.isFinite(un)) return 0;
   return Math.max(total - un, 0);
 };
 
 const tableColumn = ref([
+  {align: "center", label: "鍑哄簱鍗曞彿", prop: "outboundBatches" },
+  {align: "center", label: "鎵规鍙�", prop: "batchNo" },
   {align: "center", label: "浜у搧澶х被", prop: "productCategory" },
   {align: "center", label: "瑙勬牸鍨嬪彿", prop: "specificationModel" },
   {align: "center", label: "鍗曚綅", prop: "unit", width: 80 },
-  {align: "center", label: "鎬绘暟閲�", prop: "quantity", width: 120 },
+  {align: "center", label: "鎬绘暟閲�", prop: "stockOutNum", width: 120 },
   {align: "center", label: "宸查��璐ф暟閲�", prop: "totalReturnNum", width: 120 },
+  {align: "center", label: "寰呭鐞嗛��璐ф暟閲�", prop: "pendingReturnNum", width: 120 },
   {align: "center", label: "鏈��璐ф暟閲�", prop: "unQuantity", width: 120 },
   {align: "center", label: "閫�璐ф暟閲�", prop: "returnQuantity", dataType: "slot", slot: "returnQuantity", width: 120 },
   {align: "center", label: "閫�璐т骇鍝佸崟浠�", prop: "price", dataType: "slot", slot: "price", width: 120 },
@@ -238,8 +271,164 @@
   tableData.value.splice(index, 1);
 };
 
+const sameKey = (a, b) => a != null && b != null && String(a) === String(b);
+
+/** 鎺ュ彛鍙兘鎷嗘垚 shippingProductVoList / productDtoData 涓や唤锛屽彧鍙栧叾涓�浼氱己鎵规銆佹暟閲忕瓑瀛楁 */
+const mergeShippingProductLists = (data) => {
+  const lists = [data?.shippingProductVoList, data?.productDtoData].filter(Array.isArray);
+  if (!lists.length) return [];
+  const map = new Map();
+  for (const list of lists) {
+    for (const p of list) {
+      if (p == null) continue;
+      const key = p.id != null ? String(p.id) : null;
+      if (!key) continue;
+      const prev = map.get(key);
+      map.set(key, prev ? { ...prev, ...p } : { ...p });
+    }
+  }
+  return Array.from(map.values());
+};
+
+const pickShippingLine = (normalized) => {
+  const pid = normalized?.returnSaleLedgerProductId ?? normalized?.id;
+  const sid = normalized?.stockOutRecordId ?? normalized?.shippingProductId;
+  const direct = availableProducts.value.find(
+    (p) =>
+      sameKey(p?.id, pid) ||
+      sameKey(p?.stockOutRecordId, pid) ||
+      sameKey(p?.id, sid) ||
+      sameKey(p?.stockOutRecordId, sid)
+  );
+  if (direct) return direct;
+  const pmid = normalized?.productModelId;
+  if (pmid == null || pmid === "") return undefined;
+  const candidates = availableProducts.value.filter((p) => sameKey(p?.productModelId, pmid));
+  if (!candidates.length) return undefined;
+  if (candidates.length === 1) return candidates[0];
+  const spec = String(normalized?.specificationModel ?? normalized?.model ?? "");
+  if (spec) {
+    const hit = candidates.find((p) => {
+      const ps = String(p?.specificationModel ?? p?.model ?? "");
+      return ps && ps === spec;
+    });
+    if (hit) return hit;
+  }
+  return candidates[0];
+};
+
+const isEmptyText = (v) => v === "" || v == null || v === undefined;
+
+const firstFiniteNumber = (...vals) => {
+  for (const v of vals) {
+    if (v === "" || v == null || v === undefined) continue;
+    const n = Number(v);
+    if (Number.isFinite(n)) return n;
+  }
+  return undefined;
+};
+
+const firstNonEmptyText = (...vals) => {
+  const hit = vals.find((v) => !isEmptyText(v));
+  return hit === undefined ? "" : hit;
+};
+
+/** 璇︽儏鎺ュ彛瀛楁甯镐笉鍏紱{...product,...normalized} 浼氳 normalized 閲岀殑绌轰覆鐩栨帀鍑哄簱琛屼笂鐨勫睍绀哄瓧娈� */
+const mergeShippingLineWithDetail = (product, normalized) => {
+  const row = { ...product, ...normalized };
+  row.outboundBatches = firstNonEmptyText(
+    row.outboundBatches,
+    product?.outboundBatches,
+    product?.shippingNo,
+    product?.outboundNo,
+    normalized?.outboundBatches,
+    normalized?.outboundNo,
+    normalized?.shippingNo
+  );
+  row.batchNo = firstNonEmptyText(
+    row.batchNo,
+    product?.batchNo,
+    product?.batchNumber,
+    product?.lotNo,
+    product?.batchCode,
+    product?.shippingBatchNo,
+    normalized?.batchNo,
+    normalized?.batchNumber,
+    normalized?.lotNo,
+    normalized?.shippingBatchNo
+  );
+  const stock = firstFiniteNumber(
+    row.stockOutNum,
+    product?.stockOutNum,
+    product?.totalQuantity,
+    product?.shippingQuantity,
+    product?.deliveryQuantity,
+    product?.quantity,
+    product?.outQuantity,
+    normalized?.stockOutNum,
+    normalized?.totalQuantity,
+    normalized?.shippingQuantity,
+    normalized?.deliveryQuantity
+  );
+  if (stock !== undefined) row.stockOutNum = stock;
+  const un = firstFiniteNumber(
+    row.unQuantity,
+    product?.unQuantity,
+    product?.remainingQuantity,
+    product?.noReturnQuantity,
+    product?.canReturnQuantity,
+    product?.availableReturnNum,
+    normalized?.unQuantity,
+    normalized?.remainingQuantity,
+    normalized?.noReturnQuantity,
+    normalized?.canReturnQuantity
+  );
+  if (un !== undefined) row.unQuantity = un;
+  else {
+    const s = Number(row.stockOutNum);
+    const ret = Number(row.totalReturnNum ?? 0);
+    if (Number.isFinite(s) && s >= 0 && Number.isFinite(ret) && ret >= 0) {
+      row.unQuantity = Math.max(0, s - ret);
+    }
+  }
+  const returned = firstFiniteNumber(
+    row.totalReturnNum,
+    product?.totalReturnNum,
+    product?.totalReturnedNum,
+    normalized?.totalReturnNum,
+    normalized?.totalReturnedNum
+  );
+  if (returned !== undefined) row.totalReturnNum = returned;
+  else if (isEmptyText(row.totalReturnNum)) row.totalReturnNum = 0;
+  if (isEmptyText(row.unit)) {
+    row.unit = firstNonEmptyText(product?.unit, normalized?.unit);
+  }
+  if (isEmptyText(row.productCategory)) {
+    row.productCategory = firstNonEmptyText(
+      normalized?.productCategory,
+      normalized?.productName,
+      product?.productCategory,
+      product?.productName
+    );
+  }
+  if (isEmptyText(row.specificationModel)) {
+    row.specificationModel = firstNonEmptyText(
+      normalized?.specificationModel,
+      normalized?.model,
+      product?.specificationModel,
+      product?.model
+    );
+  }
+  return row;
+};
+
 const normalizeDetailRow = (raw) => {
-  const productId = raw?.returnSaleLedgerProductId ?? raw?.saleLedgerProductId ?? raw?.id;
+  const ledgerId =
+    raw?.returnSaleLedgerProductId ??
+    raw?.saleLedgerProductId ??
+    raw?.stockOutRecordId ??
+    raw?.shippingProductId;
+  const productId = ledgerId ?? raw?.id;
   const returnSaleProductId = raw?.returnSaleProductId ?? raw?.id;
   const num = Number(raw?.num ?? raw?.returnQuantity ?? 0);
   return {
@@ -248,6 +437,29 @@
     returnSaleProductId,
     returnSaleLedgerProductId: productId,
     productModelId: raw?.productModelId,
+    stockOutRecordId: raw?.stockOutRecordId,
+    shippingProductId: raw?.shippingProductId,
+    productCategory: raw?.productCategory ?? raw?.productName ?? raw?.productTypeName ?? "",
+    specificationModel: raw?.specificationModel ?? raw?.model ?? raw?.specModel ?? "",
+    outboundBatches: raw?.outboundBatches ?? raw?.outboundNo ?? raw?.shippingNo,
+    batchNo:
+      raw?.batchNo ??
+      raw?.batchNumber ??
+      raw?.lotNo ??
+      raw?.batchCode ??
+      raw?.shippingBatchNo,
+    stockOutNum:
+      raw?.stockOutNum ??
+      raw?.totalQuantity ??
+      raw?.shippingQuantity ??
+      raw?.deliveryQuantity ??
+      raw?.quantity,
+    totalReturnNum: raw?.totalReturnNum ?? raw?.totalReturnedNum,
+    unQuantity:
+      raw?.unQuantity ??
+      raw?.remainingQuantity ??
+      raw?.noReturnQuantity ??
+      raw?.canReturnQuantity,
     num,
     returnQuantity: Number.isFinite(num) ? num : 0,
     price: Number(raw?.taxInclusiveUnitPrice ?? raw?.price ?? 0),
@@ -259,7 +471,6 @@
 
 const setFormForEdit = async (row) => {
   const res = await returnManagementGetById({ returnManagementId: row?.id });
-  console.log("res", res);
   const detail = res?.data ?? res ?? {};
 
   Object.assign(form.value, detail);
@@ -281,11 +492,18 @@
   tableData.value = Array.isArray(list)
     ? list.map((raw) => {
         const normalized = normalizeDetailRow(raw);
-        const product = availableProducts.value.find((p) => p.id === normalized.id);
-        return product ? { ...product, ...normalized } : normalized;
+        const product = pickShippingLine(normalized);
+        return product ? mergeShippingLineWithDetail(product, normalized) : normalized;
       })
     : [];
-  
+
+  const headerShipNo = detail?.shippingNo ?? form.value?.shippingNo;
+  if (headerShipNo && Array.isArray(tableData.value) && tableData.value.length) {
+    tableData.value = tableData.value.map((r) =>
+      isEmptyText(r.outboundBatches) ? { ...r, outboundBatches: headerShipNo } : r
+    );
+  }
+
   calculateTotalRefund();
 };
 
@@ -303,6 +521,10 @@
       returnNo: "",
       customerId: "",
       shippingId: "",
+      shippingType: "",
+      truckPlateNo: "",
+      expressCompany: "",
+      expressNo: "",
       projectId: "",
       maker: "",
       makeTime: "",
@@ -319,8 +541,24 @@
 const submitForm = () => {
   proxy.$refs["formRef"].validate(valid => {
     if (!valid) return;
+    if (!tableData.value || tableData.value.length === 0) {
+      proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓��璐т骇鍝�");
+      return;
+    }
+    for (let i = 0; i < tableData.value.length; i++) {
+      const row = tableData.value[i];
+      const qty = Number(row.num ?? row.returnQuantity ?? 0);
+      if (!qty || qty <= 0) {
+        proxy.$modal.msgWarning(`绗�${i + 1}琛岄��璐ф暟閲忓繀椤诲ぇ浜�0`);
+        return;
+      }
+      if (row.price === "" || row.price === null || row.price === undefined || Number(row.price) < 0) {
+        proxy.$modal.msgWarning(`绗�${i + 1}琛岄��璐у崟浠蜂笉鑳戒负璐熸暟`);
+        return;
+      }
+    }
     const returnSaleProducts = (tableData.value || []).map(el => ({
-      returnSaleLedgerProductId: el.returnSaleLedgerProductId ?? el.id,
+      stockOutRecordId: el.returnSaleLedgerProductId ?? el.id,
       productModelId: el.productModelId,
       unit: el.unit,
       num: Number(el.num ?? el.returnQuantity ?? 0),
@@ -333,6 +571,11 @@
     const payload = { ...form.value, returnSaleProducts };
     delete payload.returnNoCheckbox;
     if (operationType.value === "add" && form.value.returnNoCheckbox) delete payload.returnNo;
+    if (payload.shippingType !== 1) payload.truckPlateNo = "";
+    if (payload.shippingType !== 2) {
+      payload.expressCompany = "";
+      payload.expressNo = "";
+    }
     if (operationType.value === "add") {
       returnManagementAdd(payload).then(() => {
         proxy.$modal.msgSuccess("鏂板鎴愬姛");
@@ -351,10 +594,26 @@
   proxy.resetForm("formRef");
   dialogFormVisible.value = false;
   emit('close');
+  data.form = {
+        returnNoCheckbox: true,
+        returnNo: "",
+        customerId: "",
+        shippingId: "",
+        shippingType: "",
+        truckPlateNo: "",
+        expressCompany: "",
+        expressNo: "",
+        projectId: "",
+        maker: "",
+        makeTime: "",
+        status: 0,
+        returnReason: "",
+        refundAmount: "",
+  }
 };
 
 const initCustomers = async () => {
-	listCustomerPrivatePool({current: -1,size:-1}).then((res) => {
+  listCustomer({current: -1,size:-1, type: 0}).then((res) => {
 		customerNameOptions.value = res.data.records.map(item => ({
 			label: item.customerName,
 			value: item.customerName, // Keep value as name if needed for other logic, but request says customerId
@@ -387,13 +646,26 @@
   formRef.value?.validateField('returnNo');
 };
 
+const handleShippingTypeChange = (val) => {
+  if (val === 1) {
+    form.value.expressCompany = "";
+    form.value.expressNo = "";
+  } else if (val === 2) {
+    form.value.truckPlateNo = "";
+  } else {
+    form.value.truckPlateNo = "";
+    form.value.expressCompany = "";
+    form.value.expressNo = "";
+  }
+};
+
 const customerNameChange = async (val, clearDownstream = true) => {
   // val is customerId now
   if (clearDownstream) {
     form.value.shippingId = "";
     outboundOptions.value = [];
   }
-  
+
   // Find customer name for getSalesLedger if it requires name
   const customer = customerNameOptions.value.find(c => c.id === val);
   if (!customer) return;
@@ -401,11 +673,11 @@
   // Assuming getSalesLedger takes customerName. If it takes ID, adjust accordingly.
   // Previous code used customerName. Let's try passing customerName.
   getSalesLedger({
-    customerName: customer.label, 
+    customerName: customer.label,
   }).then(res => {
     if(res.code === 200){
       outboundOptions.value = res.data.map(item => ({
-        label: item.salesContractNo, // Or whatever the outbound number field is
+        label: item.shippingNo, // Or whatever the outbound number field is
         value: item.id,
       }))
     }
@@ -418,18 +690,20 @@
   if(res.code === 200){
     // If backend returns project info, set it
     if (res.data.projectId) form.value.projectId = res.data.projectId;
-    
-    // Store available products for selection
-    availableProducts.value = res.data.productDtoData || [];
+
+    availableProducts.value = mergeShippingProductLists(res.data);
     if (clearTable) tableData.value = [];
   }
 };
 
 const handleReturnQuantityChange = (val, row) => {
   if (val === "" || val === null) return;
-  const max = row.unQuantity === undefined || row.unQuantity === null ? Infinity : Number(row.unQuantity || 0);
+  const unQuantity = row.unQuantity === undefined || row.unQuantity === null ? Infinity : Number(row.unQuantity || 0);//鏈��璐ф暟閲�
+  const pendingReturnNum = row.pendingReturnNum === undefined || row.pendingReturnNum === null ? Infinity : Number(row.pendingReturnNum || 0);//寰呭鐞嗛��璐ф暟閲�
+  //鏈�澶ч��璐ф暟閲忥紝濡傛灉涓虹紪杈戠姸鎬佸姞涓婂緟澶勭悊閫�璐ф暟閲�
+  const max = operationType.value === 'edit' ? unQuantity + pendingReturnNum : unQuantity
   const current = Number(val);
-  
+
   if (current > max) {
     proxy.$nextTick(() => {
       row.returnQuantity = max;
@@ -457,9 +731,9 @@
 };
 
 const calculateRowAmount = (row) => {
-  const quantity = Number(row.returnQuantity || 0);
+  const stockOutNum = Number(row.returnQuantity || 0);
   const price = Number(row.price || 0);
-  row.amount = (quantity * price).toFixed(2);
+  row.amount = (stockOutNum * price).toFixed(2);
 };
 
 const calculateTotalRefund = () => {
@@ -495,7 +769,7 @@
 // Removed checkSelectable to allow toggling existing items
 const confirmProductSelection = () => {
   const newTableData = [];
-  
+
   selectedProducts.value.forEach(product => {
     const existing = tableData.value.find(item => item.id === product.id);
     if (existing) {
@@ -503,7 +777,7 @@
     } else {
       newTableData.push({
         ...product,
-        returnSaleLedgerProductId: product.id, 
+        returnSaleLedgerProductId: product.id,
         productModelId: product.productModelId,
         returnQuantity: 0,
         num: 0,
@@ -511,16 +785,17 @@
         amount: "0.00",
         isQuality: 2,
         remark: "",
+        productCategory: product.productCategory ?? product.productName ?? "",
         productName: product.productName,
-        specificationModel: product.specificationModel,
+        specificationModel: product.specificationModel ?? product.model ?? "",
         unit: product.unit,
-        quantity: product.quantity,
+        stockOutNum: product.stockOutNum,
         totalReturnNum: product.totalReturnNum,
         unQuantity: product.unQuantity
       });
     }
   });
-  
+
   tableData.value = newTableData;
   productSelectionVisible.value = false;
 };

--
Gitblit v1.9.3