zck 5 дней назад
Родитель
Сommit
8ee813ed8a
1 измененных файлов с 30 добавлено и 21 удалено
  1. 30 21
      src/view/quality/management.vue

+ 30 - 21
src/view/quality/management.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
-    <el-container>
-      <el-aside width="200px">
+    <el-container style="height: calc(100vh - 130px)">
+      <el-aside width="300px" style="height: 100%">
         <div class="JKWTree-tree">
           <h3>现场管理巡查统计</h3>
           <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
@@ -9,8 +9,8 @@
       </el-aside>
       <el-container>
 	  
-        <el-main>
-          <el-table ref="multipleTable" style="width: 100%;height: 70vh" tooltip-effect="dark"
+        <el-main style="padding: 0">
+          <el-table ref="multipleTable" style="width: 100%;height: 100%" tooltip-effect="dark"
                     :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                     :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                     :data="tableData"  border row-key="提交时间"
@@ -81,22 +81,30 @@ const getMenuData = async () => {
     const response = await ManagementInspectionMenu();
     console.log("左侧菜单列表↓");
     console.log(response);
+    if (response.code !== 0 || !response.data) return;
+    // 返回结构:使用部门 => { '机台编号-->机台名称': [日期...] }
     const formattedData = [];
-    for (const category in response.data) {
-      // 对日期进行去重处理
-      const uniqueDates = [...new Set(response.data[category])];
-      // 对日期进行倒序排序
-      const sortedDates = uniqueDates.sort((a, b) => new Date(b) - new Date(a));
-      const categoryNode = {
-        label: category, // 使用机台号作为节点标签
-        children: sortedDates.map(item => ({
-          label: item, // 将日期作为子节点标签
-          machine: category, // 存储机台号
-          date: item // 存储日期
-        }))
-      };
-      formattedData.push(categoryNode);
-    }
+    Object.keys(response.data).forEach((department) => {
+      const machineMap = response.data[department] || {};
+      const machineNodes = Object.keys(machineMap).map((machineLabel) => {
+        const [code, name] = machineLabel.split('-->');
+        const uniqueDates = [...new Set(machineMap[machineLabel] || [])];
+        const sortedDates = uniqueDates.sort((a, b) => new Date(b) - new Date(a));
+        return {
+          label: name ? `${code}(${name})` : code,
+          machine: code,
+          children: sortedDates.map((date) => ({
+            label: date,
+            machine: code,
+            date
+          }))
+        };
+      });
+      formattedData.push({
+        label: department,
+        children: machineNodes
+      });
+    });
     treeData.value = formattedData;
   } catch (error) {
     console.error(error)
@@ -157,11 +165,12 @@ const tableRowDblclick = (row) => {
   background: #ff80ff !important;
 }
 .JKWTree-tree {
-  width: 300px;
+  width: calc(100% - 20px);
+  height: 100%;
+  box-sizing: border-box;
   background-color: #fff;
   padding: 10px;
   margin-right: 20px;
-  max-height: 70vh;
   overflow-y: auto;
 }