From 81fb8afca320a12c38d868edf392e6bf9a665a0f Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 14 八月 2026 10:47:56 +0800
Subject: [PATCH] 湟水峡 1.产品维护编辑失败问题

---
 src/views/basicData/product/index.vue |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 3b86b37..06addf8 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -12,6 +12,7 @@
           prefix-icon="Search"
         />
         <el-button
+          v-if="false"
           type="primary"
           @click="openProDia('addOne')"
           style="margin-left: 10px"
@@ -49,6 +50,7 @@
                 <el-button
                   type="primary"
                   link
+                  :disabled="isTopLevelNode(data, node)"
                   @click="openProDia('edit', data)"
                 >
                   缂栬緫
@@ -61,6 +63,7 @@
                   style="margin-left: 4px"
                   type="danger"
                   link
+                  :disabled="isTopLevelNode(data, node)"
                   @click="remove(node, data)"
                 >
                   鍒犻櫎
@@ -285,6 +288,8 @@
 const search = ref("");
 const currentId = ref("");
 const currentParentId = ref("");
+const editId = ref("");
+const editParentId = ref("");
 const operationType = ref("");
 const treeLoad = ref(false);
 const list = ref([]);
@@ -375,13 +380,25 @@
 const searchFilter = () => {
   proxy.$refs.tree.filter(search.value);
 };
+const isTopLevelNode = (data, node) => {
+  if (node?.level !== undefined) {
+    return node.level === 1;
+  }
+  return [null, undefined, "", 0, "0"].includes(data?.parentId);
+};
 // 鎵撳紑浜у搧寮规
 const openProDia = (type, data) => {
+  if (data && type === "edit" && isTopLevelNode(data)) {
+    proxy.$modal.msgWarning("涓�绾ц妭鐐逛笉鑳界紪杈戞垨鍒犻櫎");
+    return;
+  }
   operationType.value = type;
   productDia.value = true;
   form.value.productName = "";
   if (type === "edit") {
     form.value.productName = data.productName;
+    editId.value = data.id;
+    editParentId.value = data.parentId;
   }
 };
 // 鎵撳紑瑙勬牸鍨嬪彿寮规
@@ -406,8 +423,8 @@
         form.value.id = "";
         form.value.parentId = "";
       } else {
-        form.value.id = currentId.value;
-        form.value.parentId = "";
+        form.value.id = editId.value;
+        form.value.parentId = editParentId.value;
       }
       addOrEditProduct(form.value).then((res) => {
         proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
@@ -425,6 +442,10 @@
 
 // 鍒犻櫎浜у搧
 const remove = (node, data) => {
+  if (isTopLevelNode(data, node)) {
+    proxy.$modal.msgWarning("涓�绾ц妭鐐逛笉鑳界紪杈戞垨鍒犻櫎");
+    return;
+  }
   let ids = [];
   ids.push(data.id);
   ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {

--
Gitblit v1.9.3