소스 검색

优化产品管理菜单列表

liuhairui 1 년 전
부모
커밋
0717f0f547
1개의 변경된 파일32개의 추가작업 그리고 7개의 파일을 삭제
  1. 32 7
      src/view/yunyin/chanpinziliao/chanpinziliao.vue

+ 32 - 7
src/view/yunyin/chanpinziliao/chanpinziliao.vue

@@ -579,8 +579,13 @@
         <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
           <div class="JKWTree-tree" style="height: 200px">
             <h3> 产品管理</h3>
-            <el-tree :data="treeData" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
-              <template #default="{node,data}">{{data['客户编号']}}【{{data['客户名称']}}】</template>
+<!--            <el-tree :data="treeData" @node-click="handleNodeClick" @node-expand="handleNodeExpand">-->
+<!--              <template #default="{node,data}">{{data['客户编号']}}【{{data['客户名称']}}】</template>-->
+<!--            </el-tree>-->
+            <el-tree :data="treeData" node-key="label" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+              <template #default="{ node, data }">
+                {{ node.label }}
+              </template>
             </el-tree>
           </div>
         </layout-sider>
@@ -2438,10 +2443,25 @@ const hscstzCancel = () => {hscstzlist.value = false;};
 const treeData = ref({})
 const getCustomdata = async () => {
   try {
-    const data  = await getCustom()
-    console.log("左侧菜单列表↓")
-    console.log(data)
-    treeData.value = data.data;
+    // const data  = await getCustom()
+    // console.log("左侧菜单列表↓")
+    // console.log(data)
+    // treeData.value = data.data;
+    const response = await getCustom();
+    console.log("左侧菜单列表↓");
+    console.log(response);
+    const formattedData = [];
+    for (const category in response.data) {
+      const categoryNode = {
+        label: category, // 使用分类名称作为节点标签
+        children: response.data[category].map(item => ({
+          label: `${item['客户编号']}【${item['客户名称']}】`, // 将客户信息格式化为节点标签
+          ...item // 保留原始数据,可能在后面需要使用
+        }))
+      };
+      formattedData.push(categoryNode);
+    }
+    treeData.value = formattedData;
   } catch (error) {
     console.error('Error fetching custom data:', error);
   }
@@ -2452,6 +2472,11 @@ getCustomdata()
 const tableData = reactive([])
 const _custom_code = ref(null)
 const handleNodeClick = async (node) => {
+  if(node.label === '印刷产品' || node.label === '糊盒产品'){
+    tableData.splice(0);
+    return false;
+  }
+  console.log(node.客户编号)
   _custom_code.value = node.客户编号;
   //清空搜索框
   searchInfo.value = '';
@@ -2477,7 +2502,7 @@ const tableRowClick = async (row) => {
   _product_code.value = row.产品编号;
   _kehu_code.value = row.产品名称;
   const res = await getProductData({product_code:_product_code.value});
-  console.log("点击表格行 下方表格获取数据")
+  console.log(row.产品编号 + "--->下方表格获取数据")
   console.log(res)
   yjtableData.splice(0, yjtableData.length, ...res.data.yjData);
   gytableData.splice(0, gytableData.length, ...res.data.gyData);