From 95dc87fc483106b108b35ea6ec5343b1d4b09e00 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 22 六月 2026 10:21:46 +0800
Subject: [PATCH] 新增入库时选择字段及来源修改

---
 src/views/inventoryManagement/stockManagement/New.vue              |  100 +++++++++++++++++++++++++++++++++++++++++++++++---
 src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue |    2 
 2 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue b/src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue
index f9ff79b..bf3b070 100644
--- a/src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue
+++ b/src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue
@@ -18,7 +18,7 @@
           <el-table-column label="瑙勬牸鍨嬪彿"
                            prop="model"
                            show-overflow-tooltip />
-          <el-table-column label="鍘傚"
+          <el-table-column label="渚涘簲鍟�"
                            prop="manufacturerName"
                            show-overflow-tooltip>
             <template #default="scope">
diff --git a/src/views/inventoryManagement/stockManagement/New.vue b/src/views/inventoryManagement/stockManagement/New.vue
index 9a49c46..11dc8ed 100644
--- a/src/views/inventoryManagement/stockManagement/New.vue
+++ b/src/views/inventoryManagement/stockManagement/New.vue
@@ -32,8 +32,37 @@
           <el-input v-model="formState.unit"
                     disabled />
         </el-form-item>
-        <el-form-item label="鍘傚"
-                      prop="manufacturerId">
+        <el-form-item v-if="shouldSelectSupplier"
+                      label="渚涘簲鍟�"
+                      prop="supplierId"
+                      :rules="[
+                {
+                required: true,
+                message: '璇烽�夋嫨渚涘簲鍟�',
+                trigger: 'change',
+              }
+            ]">
+          <el-select v-model="formState.supplierId"
+                     placeholder="璇烽�夋嫨渚涘簲鍟�"
+                     clearable
+                     filterable
+                     style="width: 100%">
+            <el-option v-for="item in supplierOptions"
+                       :key="item.value ?? item.id ?? item.supplierId"
+                       :label="item.label ?? item.supplierName ?? item.name"
+                       :value="item.value ?? item.id ?? item.supplierId" />
+          </el-select>
+        </el-form-item>
+        <el-form-item v-if="shouldSelectManufacturer"
+                      label="鍘傚"
+                      prop="manufacturerId"
+                      :rules="[
+                {
+                required: true,
+                message: '璇烽�夋嫨鍘傚',
+                trigger: 'change',
+              }
+            ]">
           <el-select v-model="formState.manufacturerId"
                      placeholder="璇烽�夋嫨鍘傚"
                      clearable
@@ -129,11 +158,12 @@
 </template>
 
 <script setup>
-  import { ref, computed, watch, getCurrentInstance, onMounted } from "vue";
+  import { ref, computed, watch, getCurrentInstance } from "vue";
   import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
   import { addStockInRecordOnly } from "@/api/inventoryManagement/stockInventory.js";
   import { createStockUnInventory } from "@/api/inventoryManagement/stockUninventory.js";
   import { getManufacturerOptions } from "@/api/inspectionManagement/manufacturerManageFile.js";
+  import { getOptions as getSupplierOptions } from "@/api/procurementManagement/procurementLedger.js";
 
   const props = defineProps({
     visible: {
@@ -158,6 +188,7 @@
     unit: "",
     type: undefined,
     manufacturerId: "",
+    supplierId: "",
     source: "",
     qualitity: 0,
     batchNo: null,
@@ -185,6 +216,8 @@
 
   const handleTypeChange = val => {
     formState.value.source = "";
+    formState.value.manufacturerId = "";
+    formState.value.supplierId = "";
   };
 
   const isShow = computed({
@@ -198,6 +231,21 @@
 
   const showProductSelectDialog = ref(false);
   const manufacturerOptions = ref([]);
+  const supplierOptions = ref([]);
+
+  const shouldSelectSupplier = computed(() => {
+    return (
+      formState.value.type === "qualified" &&
+      formState.value.source === "purchaseReceipt"
+    );
+  });
+
+  const shouldSelectManufacturer = computed(() => {
+    return (
+      formState.value.type === "qualified" &&
+      formState.value.source === "outsourcedReceipt"
+    );
+  });
 
   const loadManufacturerOptions = () => {
     getManufacturerOptions().then(res => {
@@ -205,9 +253,48 @@
     });
   };
 
-  onMounted(() => {
-    loadManufacturerOptions();
-  });
+  const loadSupplierOptions = () => {
+    getSupplierOptions({})
+      .then(res => {
+        const raw = res?.data;
+        if (Array.isArray(raw)) {
+          supplierOptions.value = raw;
+          return;
+        }
+        supplierOptions.value = raw?.records || raw?.list || [];
+      })
+      .catch(() => {
+        supplierOptions.value = [];
+      });
+  };
+
+  watch(
+    () => shouldSelectManufacturer.value,
+    val => {
+      if (val && manufacturerOptions.value.length === 0) {
+        loadManufacturerOptions();
+      }
+    },
+    { immediate: true }
+  );
+
+  watch(
+    () => shouldSelectSupplier.value,
+    val => {
+      if (val && supplierOptions.value.length === 0) {
+        loadSupplierOptions();
+      }
+    },
+    { immediate: true }
+  );
+
+  watch(
+    () => formState.value.source,
+    () => {
+      formState.value.manufacturerId = "";
+      formState.value.supplierId = "";
+    }
+  );
 
   // 鎵瑰彿涓虹┖鏃惰浆涓� null
   watch(
@@ -231,6 +318,7 @@
       unit: "",
       type: undefined,
       manufacturerId: "",
+      supplierId: "",
       source: "",
       qualitity: 0,
       batchNo: null,

--
Gitblit v1.9.3