From 8d36dd0ec84133585443750e2001147d5bc127c8 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 20:40:42 +0800
Subject: [PATCH] 新疆-融邦 1.油品出库要绑定销售订单

---
 src/views/inventoryManagement/stockManagement/OilStockOutDialog.vue |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/OilStockOutDialog.vue b/src/views/inventoryManagement/stockManagement/OilStockOutDialog.vue
index a3c01df..587b66e 100644
--- a/src/views/inventoryManagement/stockManagement/OilStockOutDialog.vue
+++ b/src/views/inventoryManagement/stockManagement/OilStockOutDialog.vue
@@ -500,7 +500,7 @@
   import { allOilDepot } from "@/api/basicData/oilDepot.js";
   import { allTankInfo } from "@/api/basicData/tankInfo.js";
   import { allVehicle } from "@/api/basicData/vehicle.js";
-  import { listCustomer } from "@/api/basicData/customer.js";
+  import { listCustomer, getCustomer } from "@/api/basicData/customer.js";
 
   const props = defineProps({
     visible: {
@@ -728,6 +728,30 @@
     }
   };
 
+  // 鍙拌处甯﹀洖鐨勫鎴凤細customerChange 鍙槸 el-select 鐨� @change锛屽�肩敱 v-model 鍐欙紝杩欓噷瑕佹樉寮忚祴鍊�
+  const applyLedgerCustomer = row => {
+    formState.value.customerId = row.customerId;
+    const customer = customerList.value.find(item => item.id === row.customerId);
+    if (customer) {
+      customerChange(customer.id);
+      return;
+    }
+    formState.value.customerName = row.customerName || "";
+    if (!row.customerId) return;
+    // 瀹㈡埛妗f涓嬫媺閲屾病鏈夎繖鏉★紙涓嶅湪绉佹捣鎴栬秴鍑哄姞杞芥潯鏁帮級锛氬洖鏌ヨ鎯呰ˉ涓�涓�欓�夛紝鍚﹀垯涓嬫媺妗嗘樉绀虹┖鐧�
+    getCustomer(row.customerId)
+      .then(res => {
+        const detail = res?.data;
+        if (!detail) return;
+        customerList.value = [detail, ...customerList.value];
+        formState.value.customerName =
+          formState.value.customerName || detail.customerName || "";
+        formState.value.contactPerson = detail.contactPerson || "";
+        formState.value.contactPhone = detail.contactPhone || "";
+      })
+      .catch(() => {});
+  };
+
   // 杞﹁締閫夋嫨鏀瑰彉锛氳溅鐗屽彿銆佽溅鎸傜墝鍙蜂笌鍙告満淇℃伅鐢辫溅杈嗕富鏁版嵁甯﹀嚭锛屽嚭搴撴椂鍙告満鍙墜鍔ㄨ鐩�
   const vehicleChange = id => {
     const vehicle = vehicleList.value.find(item => item.id === id);
@@ -873,9 +897,7 @@
     }
     // 鍑哄簱绫诲埆涓庡鎴蜂互鍙拌处涓哄噯锛堝悗绔篃浼氬己鍒惰鐩栵級锛屽墠绔悓姝ュ睍绀哄苟缃伆
     formState.value.outCategory = row.ledgerType === "浠e偍" ? "浠e偍" : "閿�鍞�";
-    customerChange(row.customerId);
-    formState.value.customerName =
-      row.customerName || formState.value.customerName || "";
+    applyLedgerCustomer(row);
     if (row.ledgerType === "浠e偍") {
       formState.value.oilDepotId = row.oilDepotId;
       formState.value.oilDepotName = row.oilDepotName || "";
@@ -899,11 +921,15 @@
         formState.value.netWeight = netWeight.value;
         formState.value.lossQuantity = lossQuantity.value;
         formState.value.actualVolume = actualVolume.value;
-        // 鐓х墖杞� JSON 瀛楃涓叉彁浜わ紙鍚庣瀛楁涓烘枃鏈瓨鍌級
-        formState.value.loadingPhotos = JSON.stringify(formState.value.loadingPhotos || []);
-        formState.value.poundPhotos = JSON.stringify(formState.value.poundPhotos || []);
+        // 鐓х墖杞� JSON 瀛楃涓叉彁浜わ紙鍚庣瀛楁涓烘枃鏈瓨鍌級锛涗笉鑳界洿鎺ユ敼 formState锛�
+        // 鍚﹀垯鎻愪氦澶辫触鏃剁粦瀹氬湪鍚屼竴瀛楁涓婄殑 ImageUpload 浼氭嬁鍒板瓧绗︿覆銆佸浘鐗囧叏涓�
+        const payload = {
+          ...formState.value,
+          loadingPhotos: JSON.stringify(formState.value.loadingPhotos || []),
+          poundPhotos: JSON.stringify(formState.value.poundPhotos || []),
+        };
 
-        addOilOutRecordOnly(formState.value).then(res => {
+        addOilOutRecordOnly(payload).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeModal();
           emit("completed");

--
Gitblit v1.9.3