From 6ce0d7be73f491fcda424ac815006a82e0d871c4 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 30 三月 2026 10:18:29 +0800
Subject: [PATCH] fix: 添加规格型号搜索

---
 src/views/basicData/product/index.vue |   42 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 7b2a819..27905f8 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -153,12 +153,22 @@
         <el-row>
           <el-col :span="24">
             <el-form-item label="鍗曚綅锛�" prop="unit">
-              <el-input
+              <el-select
                 v-model="modelForm.unit"
-                placeholder="璇疯緭鍏ュ崟浣�"
+                placeholder="璇烽�夋嫨鍗曚綅"
                 clearable
-                @keydown.enter.prevent
-              />
+                style="width: 100%"
+                :filterable="isConsumablesBranch"
+                :allow-create="isConsumablesBranch"
+                :default-first-option="isConsumablesBranch"
+              >
+                <el-option
+                  v-for="u in unitSelectOptions"
+                  :key="u"
+                  :label="u"
+                  :value="u"
+                />
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -174,7 +184,7 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
+import { ref, computed } from "vue";
 import { ElMessageBox } from "element-plus";
 import {
   addOrEditProduct,
@@ -253,6 +263,28 @@
   },
 });
 const { form, rules, modelForm, modelRules } = toRefs(data);
+
+/** 褰撳墠閫変腑浜у搧鏄惁灞炰簬銆岃�楁潗銆嶅ぇ绫讳笅锛堟部鐖堕摼鏌ユ壘 label 涓恒�岃�楁潗銆嶇殑鑺傜偣锛� */
+const isConsumablesBranch = computed(() => {
+  if (!tree.value || !currentId.value) return false;
+  const n = tree.value.getNode(currentId.value);
+  if (!n) return false;
+  let p = n.parent;
+  while (p && p.data) {
+    if (p.data.label === "鑰楁潗") return true;
+    p = p.parent;
+  }
+  return false;
+});
+
+/** 鍗曚綅涓嬫媺锛氳�楁潗鍒嗘敮鍚欢銆佷釜鏁颁笖鍙墜鍔ㄦ柊澧烇紱鍏朵粬鍒嗘敮浠呭惃銆佸叕鏂� */
+const unitSelectOptions = computed(() => {
+  if (isConsumablesBranch.value) {
+    return ["鍚�", "鍏枻", "浠�", "涓暟",'妗�'];
+  }
+  return ["鍚�", "鍏枻"];
+});
+
 // 鏌ヨ浜у搧鏍�
 const getProductTreeList = () => {
   treeLoad.value = true;

--
Gitblit v1.9.3