From 5af665569d0cc093184f99b70ac38745ef53b911 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 21 九月 2026 20:39:04 +0800
Subject: [PATCH] 新疆-融邦环保 1.油品出库表单改「多台账分摊绑定」:各台账数量之和必须等于出库吨位,产品取各台账明细交集,代储不锁行可自由增删 2.新增到货记录模块:销售台账页入口,车辆随出库单联动,到货上限=该台账分摊量,附件走永久链接 3.发货台账改层级父行:油品出库为父行,children 为到货记录,来源列区分发货单/油品出库/到货 4.开票/收款候选按「出库单×客户」拆行,bindingId 与出库单 id 分两串回传,防重复开票/收款 5.销售台账下拉补产品/规格型号 6.代储入库绑定销售订单:油品入库表单加销售订单下拉,入库台账列表加「销售订单」列 7.采购申请补齐台账字段(油库、采购合同号、提货方式、物流方式、最佳到站日期、采购类别、付款方式、预警数量、附件等) 8.修复采购申请「转订单后跳转无反应」 9.采购台账删掉「销售合同号」的搜索条件、列表列和表单字段 10.公海客户新增「信托基金(元)」,代储金额合计超限标红提示

---
 src/views/financialManagement/receivable/invoiceApply.vue |   78 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/src/views/financialManagement/receivable/invoiceApply.vue b/src/views/financialManagement/receivable/invoiceApply.vue
index 21b5f0e..000c7a6 100644
--- a/src/views/financialManagement/receivable/invoiceApply.vue
+++ b/src/views/financialManagement/receivable/invoiceApply.vue
@@ -231,7 +231,7 @@
         ref="outboundTableRef"
         v-loading="outboundBatchLoading"
         :data="outboundBatchList"
-        row-key="id"
+        :row-key="getOutboundOptionValue"
         border
         stripe
         max-height="480"
@@ -339,6 +339,8 @@
 const outboundSelectVisible = ref(false);
 const outboundTableRef = ref(null);
 const dialogOutboundSelection = ref([]);
+// 宸茬‘璁ら�変腑鐨勫嚭搴撳�欓�夋暣琛岋紙鍚� bindingId锛夛紝鎻愪氦鏃舵寜瀹冩媶鍒� id 绌洪棿
+const selectedOutboundRows = ref([]);
 
 const getCustomerList = () => {
   listCustomer({ current: -1, size: -1, type: 0 }).then((res) => {
@@ -347,6 +349,39 @@
     }
   });
 };
+
+// 涓�涓� CK 鍙峰彲鑳芥寜瀹㈡埛鎷嗘垚澶氳锛堟补鍝佸嚭搴撴寜銆屽嚭搴撳崟 脳 瀹㈡埛銆嶅嚭鍙傦級锛�
+// 鎵�浠ヤ笉鑳界敤鍑哄簱鍗� id 褰撳敮涓�閿細鏈� bindingId 鐨勮鐢� bindingId锛屽叾浣欑敤鍑哄簱鍗� id
+const getOutboundOptionValue = (row) => {
+  const bindingId = row?.bindingId;
+  if (bindingId !== undefined && bindingId !== null && bindingId !== "") {
+    return `binding-${bindingId}`;
+  }
+  const id = row?.id ?? row?.stockOutRecordId;
+  return id === undefined || id === null ? undefined : `record-${id}`;
+};
+
+// 涓や釜 id 绌洪棿閮芥槸灏忔暣鏁帮紝娣风潃瀛樹細鎾炲彿锛團IND_IN_SET 鍒嗕笉鍑烘潵锛夊鑷撮噸澶嶅紑绁紝
+// 鎵�浠ュ繀椤绘寜 bindingId 鏄惁涓虹┖鎷嗘垚涓や覆鍒嗗紑鍥炰紶
+const splitOutboundIds = (rows) => {
+  const recordIds = [];
+  const bindingIds = [];
+  rows.forEach((row) => {
+    const bindingId = row?.bindingId;
+    if (bindingId !== undefined && bindingId !== null && bindingId !== "") {
+      bindingIds.push(bindingId);
+      return;
+    }
+    const id = row?.id ?? row?.stockOutRecordId;
+    if (id !== undefined && id !== null) {
+      recordIds.push(id);
+    }
+  });
+  return { recordIds, bindingIds };
+};
+
+// 缂栬緫鍥炴樉鏃惰〃鍗曢噷瀛樼殑鏄甫鍓嶇紑鐨勯�夐」鍊硷紝鍥炰紶鍓嶈杩樺師鎴愯8 id
+const stripOutboundPrefix = (value) => String(value).replace(/^(record|binding)-/, "");
 
 const normalizeOutboundBatchOptions = (data) => {
   const list = Array.isArray(data) ? data : [];
@@ -362,7 +397,7 @@
       item.outboundNo ??
       item.label ??
       `鍑哄簱鍗�${index + 1}`;
-    const value = item.id ?? item.stockOutRecordId ?? item.stockOutRecordIds ?? label;
+    const value = getOutboundOptionValue(item) ?? label;
     const outboundAmount = Number(item.outboundAmount) || 0;
     const taxRate =
       item.taxRate !== undefined && item.taxRate !== null && item.taxRate !== ""
@@ -413,8 +448,6 @@
   form.amount = sum > 0 ? Number(sum.toFixed(2)) : 0;
 };
 
-const getOutboundRowId = (row) => row?.id ?? row?.stockOutRecordId;
-
 const outboundBatchDisplayText = computed(() => {
   if (isEdit.value || isView.value) {
     return form.outboundBatches || "";
@@ -440,7 +473,7 @@
     table.clearSelection();
     const selectedIds = new Set((form.outboundBatchNos || []).map((id) => String(id)));
     outboundBatchList.value.forEach((row) => {
-      const rowId = getOutboundRowId(row);
+      const rowId = getOutboundOptionValue(row);
       if (rowId !== undefined && rowId !== null && selectedIds.has(String(rowId))) {
         table.toggleRowSelection(row, true);
       }
@@ -468,7 +501,7 @@
   const prevIds = [...(form.outboundBatchNos || [])];
   const prevBatches = form.outboundBatches;
   form.outboundBatchNos = dialogOutboundSelection.value
-    .map((row) => getOutboundRowId(row))
+    .map((row) => getOutboundOptionValue(row))
     .filter((id) => id !== undefined && id !== null);
   form.outboundBatches = dialogOutboundSelection.value
     .map((row) => row.outboundBatches ?? row.batchNo ?? row.shippingNo ?? "")
@@ -479,6 +512,8 @@
     form.outboundBatches = prevBatches;
     return;
   }
+  // 淇濈暀鏁磋锛氭彁浜ゆ椂鎵嶇煡閬撴瘡琛屾槸璧� stockOutRecordIds 杩樻槸 stockOutBindingIds
+  selectedOutboundRows.value = [...dialogOutboundSelection.value];
   outboundSelectVisible.value = false;
   syncInvoiceAmount();
   formRef.value?.validateField("outboundBatchNos");
@@ -494,6 +529,8 @@
     outboundBatchOptions.value = [];
     if (!keepSelected) {
       form.outboundBatchNos = [];
+      form.stockOutBindingIds = [];
+      selectedOutboundRows.value = [];
       form.amount = 0;
     }
     return Promise.resolve();
@@ -525,6 +562,8 @@
 
 const handleCustomerChange = (customerId) => {
   form.outboundBatchNos = [];
+  form.stockOutBindingIds = [];
+  selectedOutboundRows.value = [];
   form.outboundBatches = "";
   form.amount = 0;
   loadOutboundBatches(customerId);
@@ -534,6 +573,8 @@
   applyCode: "",
   customerId: "",
   outboundBatchNos: [],
+  // 娌瑰搧鍑哄簱鐨勭粦瀹氳 id锛堜笌鍑哄簱鍗� id 鍒嗗紑瀛橈紝娣风敤浼氭挒鍙凤級
+  stockOutBindingIds: [],
   outboundBatches: "",
   amount: 0,
   taxRate: 13,
@@ -740,9 +781,12 @@
 };
 
 const fillFormFromRow = (row) => {
-  const outboundBatchNos = Array.isArray(row.outboundBatchNos)
-    ? row.outboundBatchNos
-    : parseStockOutRecordIds(row.stockOutRecordIds ?? row.stockOutRecordId);
+  // 甯﹀墠缂�鍥炴樉鎵嶈兘鍜屽�欓�夐�夐」鐨勫�煎涓婏紙缁戝畾琛屼笌鍑哄簱鍗曟槸涓や釜 id 绌洪棿锛�
+  const outboundBatchNos = (
+    Array.isArray(row.outboundBatchNos)
+      ? row.outboundBatchNos
+      : parseStockOutRecordIds(row.stockOutRecordIds ?? row.stockOutRecordId)
+  ).map((id) => `record-${id}`);
   Object.assign(form, {
     ...row,
     applyCode: row.applyCode ?? row.invoiceApplicationNo ?? "",
@@ -750,6 +794,10 @@
     content: row.content ?? row.invoiceContent,
     status: normalizeStatus(row.status ?? row.auditStatus),
     outboundBatchNos,
+    // 缂栬緫鏃朵笉閲嶅紑閫夋嫨寮规锛屽師鏍峰甫鍥炲幓鎵嶈兘淇濅綇缁戝畾琛屽叧鑱�
+    stockOutBindingIds: parseStockOutRecordIds(row.stockOutBindingIds).map(
+      (id) => `binding-${id}`
+    ),
     outboundBatches: formatOutboundBatches(row.outboundBatches),
     createTime: row.createTime ?? "",
   });
@@ -763,6 +811,7 @@
     applyCode: "",
     customerId: "",
     outboundBatchNos: [],
+    stockOutBindingIds: [],
     outboundBatches: "",
     amount: 0,
     taxRate: 13,
@@ -774,6 +823,7 @@
   });
   outboundBatchList.value = [];
   outboundBatchOptions.value = [];
+  selectedOutboundRows.value = [];
   dialogVisible.value = true;
 };
 
@@ -788,9 +838,17 @@
 };
 
 const buildSubmitPayload = (forUpdate = false) => {
+  // 鏂伴�夌殑琛屾寜 bindingId 鎷嗘垚涓や覆锛涚紪杈戞椂閫夋嫨寮规娌¢噸寮�锛屾部鐢ㄨ褰曢噷甯﹀洖鏉ョ殑涓や覆
+  const { recordIds, bindingIds } = selectedOutboundRows.value.length
+    ? splitOutboundIds(selectedOutboundRows.value)
+    : {
+        recordIds: (form.outboundBatchNos || []).map(stripOutboundPrefix),
+        bindingIds: (form.stockOutBindingIds || []).map(stripOutboundPrefix),
+      };
   const payload = {
     customerId: form.customerId,
-    stockOutRecordIds: (form.outboundBatchNos || []).join(","),
+    stockOutRecordIds: recordIds.join(","),
+    stockOutBindingIds: bindingIds.join(","),
     invoiceApplicationNo: form.applyCode || "",
     invoiceType: form.invoiceType,
     applyDate: form.applyDate,

--
Gitblit v1.9.3