From c4f061d623e70d174afc87806d0045d69a04df3d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期六, 28 三月 2026 09:23:30 +0800
Subject: [PATCH] fix: 耗材单位修改

---
 src/views/basicData/product/index.vue |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index d2df67c..f9cc6a2 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -158,9 +158,16 @@
                 placeholder="璇烽�夋嫨鍗曚綅"
                 clearable
                 style="width: 100%"
+                :filterable="isConsumablesBranch"
+                :allow-create="isConsumablesBranch"
+                :default-first-option="isConsumablesBranch"
               >
-                <el-option label="鍚�" value="鍚�" />
-                <el-option label="鍏枻" value="鍏枻" />
+                <el-option
+                  v-for="u in unitSelectOptions"
+                  :key="u"
+                  :label="u"
+                  :value="u"
+                />
               </el-select>
             </el-form-item>
           </el-col>
@@ -177,7 +184,7 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
+import { ref, computed } from "vue";
 import { ElMessageBox } from "element-plus";
 import {
   addOrEditProduct,
@@ -256,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