<template>
    <div class="data-check-content">
        <div class="content-tree" >
            <el-tree 
            :default-expanded-keys="['0', '0-1', '0-2', '0-3', '1']" 
            node-key="id" 
            :data="data"
            :props="defaultProps" 
            @node-click="handleNodeClick" />
        </div>
        <div class="content-right-Tabs" style="height: 500px;">
              <el-tabs type="border-card" style="height: 100%;">
                  <el-tab-pane 
                      v-for="tab in tabs" 
                      :key="tab.name" 
                      :label="tab.label" 
                      :name="tab.name">
                              <!-- 频率tab -->
                              <el-tabs type="border-card" style="height: 430px;">
                                    <el-tab-pane 
                                      v-for="subTab in tab.subTabs" 
                                      :key="subTab.name" 
                                      :label="subTab.label" 
                                      :name="subTab.name">
                                  <!-- 子标签页内容 -->
                                </el-tab-pane>
                              </el-tabs>
                  </el-tab-pane>
              </el-tabs>
        </div>                  
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { data } from "@/api/plan/autoTest.json";

const tabs = ref([
  {
    label: '频率',
    name: 'resultTab',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab' }
    ]
  },
  {
    label: '电压',
    name: 'resultTab1',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab1' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab1' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab1' }
    ]
  },
  {
    label: '电流',
    name: 'resultTab2',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab2' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab2' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab2' }
    ]
  },
  {
    label: '电压不平衡度',
    name: 'resultTab3',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab3' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab3' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab3' }
    ]
  },
  {
    label: '电流不平衡度',
    name: 'resultTab4',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab4' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab4' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab4' }
    ]
  },
  {
    label: '谐波电压',
    name: 'resultTab5',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab5' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab5' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab5' }
    ]
  },
  {
    label: '谐波电流',
    name: 'resultTab6',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab6' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab6' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab6' }
    ]
  },
  {
    label: '间谐波电压',
    name: 'resultTab7',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab7' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab7' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab7' }
    ]
  },
  {
    label: '间谐波电流',
    name: 'resultTab8',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab8' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab8' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab8' }
    ]
  },
  {
    label: '电压暂升暂降',
    name: 'resultTab9',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab9' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab9' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab9' }
    ]
  },
  {
    label: '闪变',
    name: 'resultTab10',
    subTabs: [
      { label: '额度工作条件下的检测', name: 'quotaConditionTab10' },
      { label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab10' },
      { label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab10' }
    ]
  }
]);

const defaultProps = {
  children: "children",
  label: "name",
  pid: "pid",
};

const handleNodeClick = (data: any) => {
  console.log(data);
};


</script>
<style scoped>
.data-check-content {
  display: flex;
  gap: 20px;
}

.content-tree {
  width: 300px;
  height: 500px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  margin-right: 10px;
  overflow: auto; /* 同时启用垂直和水平滚动 */
  overflow-x: auto; /* 确保水平滚动条生效 */
}

/* 确保 el-tree 内容可以超出容器宽度 */
.el-tree {
  width: fit-content; /* 根据内容自适应宽度 */
}

.content-right-Tabs {
  flex: 1; /* 根据需要调整宽度比例 */
}
</style>





