From 69e585c4abbd2c719fdf60678f68196691b92603 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 六月 2025 15:12:07 +0800
Subject: [PATCH] 产品维护修改

---
 src/views/basicData/product/index.vue |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index dba78e3..d496069 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -4,18 +4,18 @@
       <div>
         <el-input
             v-model="search"
-            style="width: 240px"
+            style="width: 210px"
             placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
             @change="searchFilter"
             @clear="searchFilter"
             clearable
             prefix-icon="Search"
         />
-        <el-button type="primary" @click="openProDia('add')" style="margin-left: 10px">鏂板浜у搧</el-button>
+        <el-button type="primary" @click="openProDia('addOne')" style="margin-left: 10px">鏂板浜у搧澶х被</el-button>
       </div>
-      <div>
+      <div ref="containerRef">
         <el-tree ref="tree" v-loading="treeLoad" :data="list" @node-click="handleNodeClick"
-                 :expand-on-click-node="false"
+                 :expand-on-click-node="false" default-expand-all
                  :default-expanded-keys="expandedKeys" :draggable="true" :filter-node-method="filterNode"
                  :props="{ children: 'children', label: 'label' }" highlight-current node-key="id"
                  style="height: calc(100vh - 190px);overflow-y: scroll;scrollbar-width: none;">
@@ -26,7 +26,9 @@
                 <el-button type="primary" link @click="openProDia('edit', data)">
                   缂栬緫
                 </el-button>
-                <!-- 淇敼姝ゅ -->
+                <el-button type="primary" link @click="openProDia('add', data)">
+                  娣诲姞浜у搧
+                </el-button>
                 <el-button
                     v-if="!node.childNodes.length"
                     style="margin-left: 4px"
@@ -43,7 +45,7 @@
       </div>
     </div>
     <div class="right">
-      <div style="margin-bottom: 10px">
+      <div style="margin-bottom: 10px" v-if="isShowButton">
         <el-button type="primary" @click="openModelDia('add')">鏂板瑙勬牸鍨嬪彿</el-button>
         <el-button type="danger" @click="handleDelete" style="margin-left: 10px" plain>鍒犻櫎</el-button>
       </div>
@@ -67,7 +69,7 @@
         </div>
       </template>
     </el-dialog>
-    <el-dialog v-model="modelDia" title="浜у搧" width="400px">
+    <el-dialog v-model="modelDia" title="瑙勬牸鍨嬪彿" width="400px" @close="closeModelDia">
       <el-form :model="modelForm" label-width="140px" label-position="top" :rules="modelRules" ref="modelFormRef">
         <el-row>
           <el-col :span="24">
@@ -87,7 +89,7 @@
       <template #footer>
         <div class="dialog-footer">
           <el-button type="primary" @click="submitModelForm">纭</el-button>
-          <el-button @click="closeProDia">鍙栨秷</el-button>
+          <el-button @click="closeModelDia">鍙栨秷</el-button>
         </div>
       </template>
     </el-dialog>
@@ -105,6 +107,8 @@
   productTreeList
 } from "@/api/basicData/product.js";
 const { proxy } = getCurrentInstance()
+const tree = ref(null)
+const containerRef = ref(null)
 
 const productDia = ref(false)
 const modelDia = ref(false)
@@ -142,6 +146,7 @@
 ])
 const tableData = ref([])
 const tableLoading = ref(false)
+const isShowButton = ref(false)
 const total = ref(0)
 const selectedRows = ref([])
 const page = reactive({
@@ -209,6 +214,9 @@
       if (operationType.value === 'add') {
         form.value.parentId = currentId.value
         form.value.id = ''
+      } else if (operationType.value === 'addOne') {
+        form.value.id = ''
+        form.value.parentId = ''
       } else {
         form.value.id = currentId.value
         form.value.parentId = ''
@@ -251,6 +259,9 @@
 }
 // 閫夋嫨浜у搧
 const handleNodeClick = (val, node, el) => {
+  // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
+  isShowButton.value = !(val.children && val.children.length > 0);
+  // 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
   currentId.value = val.id
   currentParentId.value = val.parentId
   getModelList()
@@ -270,7 +281,7 @@
     }
   })
 }
-// 鍏抽棴浜у搧寮规
+// 鍏抽棴鍨嬪彿寮规
 const closeModelDia = () => {
   proxy.$refs.modelFormRef.resetFields();
   modelDia.value = false;

--
Gitblit v1.9.3