From 04ecdbfb7be63ca4a3d49d3575847e728e3e9ae7 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 27 三月 2026 17:44:13 +0800
Subject: [PATCH] fix:1.耗材选择产品优化

---
 src/views/basicData/product/ProductSelectDialog.vue |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/views/basicData/product/ProductSelectDialog.vue b/src/views/basicData/product/ProductSelectDialog.vue
index 70dbb16..8373c8e 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="鍨嬪彿鍚嶇О">
@@ -20,6 +26,7 @@
       @selection-change="handleSelectionChange" @select="handleSelect">
       <el-table-column type="selection" width="55" />
       <el-table-column type="index" label="搴忓彿" width="60" />
+      <el-table-column prop="parentName" label="绫诲瀷" min-width="160" />
       <el-table-column prop="productName" label="浜у搧澶х被" min-width="160" />
       <el-table-column prop="model" label="鍨嬪彿鍚嶇О" min-width="200" />
       <el-table-column prop="unit" label="鍗曚綅" min-width="160" />
@@ -43,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;
@@ -55,6 +62,8 @@
 const props = defineProps<{
   modelValue: boolean;
   single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
+  fixedProductName?: string; // 鍥哄畾鈥滀骇鍝佸ぇ绫烩�濈瓫閫夛紙渚嬪锛氳�楁潗锛夛紝浼犲叆鍚庝笉鍙紪杈戜笖閲嶇疆涓嶆竻绌�
+  excludeParentNames?: string[]; // 鎺掗櫎鈥滅被鍨嬧��(parentName)锛屼緥濡傦細['鑰楁潗']锛堜粎浼犲叆鏃剁敓鏁堬級
 }>();
 
 const emit = defineEmits(['update:modelValue', 'confirm']);
@@ -65,7 +74,7 @@
 });
 
 const query = reactive({
-  productName: "",
+  parentName: "",
   model: "",
 });
 
@@ -127,7 +136,7 @@
 }
 
 function onReset() {
-  query.productName = "";
+  query.parentName = props.fixedProductName ? props.fixedProductName : "";
   query.model = "";
   page.pageNum = 1;
   loadData();
@@ -155,13 +164,18 @@
   try {
     multipleSelection.value = []; // 缈婚〉/鎼滅储鍚庢竻绌洪�夋嫨鏇寸鍚堥鏈�
     const res: any = await productModelList({
-      productName: query.productName.trim(),
+      parentName: query.parentName.trim(),
       model: query.model.trim(),
       current: page.pageNum,
       size: page.pageSize,
     });
-    tableData.value = res.records;
-    total.value = res.total;
+    const records = (res?.records || []) as any[];
+    const exclude = (props.excludeParentNames || []).filter(Boolean);
+    const filtered = exclude.length
+      ? records.filter((r) => !exclude.includes(String(r?.parentName ?? "")))
+      : records;
+    tableData.value = filtered;
+    total.value = exclude.length ? filtered.length : res.total;
   } finally {
     loading.value = false;
   }
@@ -171,6 +185,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