From d48f5076b64aeacad45c0d2cf5ad2188256948f9 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 24 四月 2026 10:22:22 +0800
Subject: [PATCH] fix: 仓储物流新增bug修改

---
 src/views/basicData/product/ProductSelectDialog.vue |   62 +++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/src/views/basicData/product/ProductSelectDialog.vue b/src/views/basicData/product/ProductSelectDialog.vue
index 229cf87..cdaab57 100644
--- a/src/views/basicData/product/ProductSelectDialog.vue
+++ b/src/views/basicData/product/ProductSelectDialog.vue
@@ -2,7 +2,13 @@
   <el-dialog v-model="visible" title="閫夋嫨浜у搧" width="900px" destroy-on-close :close-on-click-modal="false">
     <el-form :inline="true" :model="query" class="mb-2">
       <el-form-item label="浜у搧澶х被">
-        <el-input v-model="query.productName" placeholder="杈撳叆浜у搧澶х被" clearable @keyup.enter="onSearch" />
+        <el-input
+          v-model="query.parentName"
+          placeholder="杈撳叆浜у搧澶х被"
+          clearable
+          :disabled="Boolean(props.fixedProductName)"
+          @keyup.enter="onSearch"
+        />
       </el-form-item>
 
       <el-form-item label="鍨嬪彿鍚嶇О">
@@ -44,7 +50,7 @@
 <script setup lang="ts">
 import { computed, onMounted, reactive, ref, watch, nextTick } from "vue";
 import { ElMessage } from "element-plus";
-import { productModelList } from '@/api/basicData/productModel'
+import { productModelList } from "../../../api/basicData/productModel.js";
 
 export type ProductRow = {
   id: number;
@@ -56,6 +62,8 @@
 const props = defineProps<{
   modelValue: boolean;
   single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
+  fixedProductName?: string; // 鍥哄畾鈥滀骇鍝佸ぇ绫烩�濈瓫閫夛紙渚嬪锛氳�楁潗锛夛紝浼犲叆鍚庝笉鍙紪杈戜笖閲嶇疆涓嶆竻绌�
+  excludeParentNames?: string[]; // 鎺掗櫎鈥滅被鍨嬧��(parentName)锛屼緥濡傦細['鑰楁潗']锛堜粎浼犲叆鏃剁敓鏁堬級
 }>();
 
 const emit = defineEmits(['update:modelValue', 'confirm']);
@@ -66,7 +74,7 @@
 });
 
 const query = reactive({
-  productName: "",
+  parentName: "",
   model: "",
 });
 
@@ -128,7 +136,7 @@
 }
 
 function onReset() {
-  query.productName = "";
+  query.parentName = props.fixedProductName ? props.fixedProductName : "";
   query.model = "";
   page.pageNum = 1;
   loadData();
@@ -155,14 +163,40 @@
   loading.value = true;
   try {
     multipleSelection.value = []; // 缈婚〉/鎼滅储鍚庢竻绌洪�夋嫨鏇寸鍚堥鏈�
-    const res: any = await productModelList({
-      productName: query.productName.trim(),
+    const queryParams = {
+      parentName: query.parentName.trim(),
       model: query.model.trim(),
-      current: page.pageNum,
-      size: page.pageSize,
-    });
-    tableData.value = res.records;
-    total.value = res.total;
+    };
+    const exclude = (props.excludeParentNames || []).filter(Boolean);
+
+    // 鍏堟媺鍙栧叏閮ㄦ暟鎹紝鍐嶇粺涓�杩囨护锛岄伩鍏嶁�滃彧杩囨护鍒板綋鍓嶉〉鈥濆鑷存紡鏁版嵁
+    const allRecords: any[] = [];
+    const fetchSize = 200;
+    let current = 1;
+    let serverTotal = 0;
+    while (true) {
+      const res: any = await productModelList({
+        ...queryParams,
+        current,
+        size: fetchSize,
+      });
+      const records = (res?.records || []) as any[];
+      serverTotal = Number(res?.total || 0);
+      allRecords.push(...records);
+      if (records.length === 0 || allRecords.length >= serverTotal) {
+        break;
+      }
+      current += 1;
+    }
+
+    const filtered = exclude.length
+      ? allRecords.filter((r) => !exclude.includes(String(r?.parentName ?? "")))
+      : allRecords;
+
+    total.value = filtered.length;
+    const start = (page.pageNum - 1) * page.pageSize;
+    const end = start + page.pageSize;
+    tableData.value = filtered.slice(start, end);
   } finally {
     loading.value = false;
   }
@@ -172,6 +206,12 @@
 watch(() => props.modelValue, (visible) => {
   if (visible) {
     multipleSelection.value = [];
+    // 鍙湁浼犱簡 fixedProductName 鎵嶅惎鐢�"鍥哄畾澶х被绛涢��"鐨勭壒娈婇�昏緫锛屽叾瀹冨満鏅繚鎸佸師琛屼负涓嶅彉
+    if (props.fixedProductName) {
+      query.parentName = props.fixedProductName;
+      page.pageNum = 1;
+      loadData();
+    }
   }
 });
 

--
Gitblit v1.9.3