<template>
  <div class="dashboard-container">
    <!-- 顶部导航栏 -->
    <header class="dashboard-header">
      <div class="logo">
        <div class="logo_header">
          <i class="icon-dashboard"> 
            <img src="@/assets/images/headers/config_header.png" alt="" style="width: 20px; height: 20px;">
          </i>
          <span class="logo_header_content">大屏配置</span>
        </div>
        <div class="logo_header_right">
          <span class="logo_header_right_content">[区域一特事故]</span>
        </div>
      </div>
      
      <div class="logo logo_right">
        <hr class="divider">
      </div>
      <div class="header-controls">
        <button class="close-btn" @click="emits('handleScreenConfigeClose')">×</button>
      </div>
    </header>

    <!-- 主体内容区 -->
    <main class="dashboard-main">
      <!-- 标签页导航 -->
      <div class="tabs-container">
        <div 
          class="tab-item" 
          :class="{ 'active': activeTab === 'equipmentCount' }"
          @click="activeTab = 'equipmentCount'"
        >
          对象选取
        </div>
        <div 
          class="tab-item" 
          :class="{ 'active': activeTab === 'failureStatus' }"
          @click="activeTab = 'failureStatus'"
        >
          模板列表
        </div>
        <div class="tab-indicator" :style="indicatorStyle"></div>
      </div>
      
      <!-- 标签页内容区域 -->
      <div class="tab-content">
        <!-- 根据选中的标签显示不同内容 -->
        <div v-if="activeTab === 'equipmentCount'" class="tab-panel">
          <!-- 地面站设备数量内容 -->
          <div class="equipment-content">
            <!-- 下拉选择器区域 -->
            <div class="selector-container">
              <div class="selector-item" v-for="(item, index) in objectSelector" :key="index">
                <label class="selector-label">{{ item.label }}</label>
                <div class="custom-select">
                 <!-- 粒度 -->
                  <el-select v-model="item.default" effect="dark" placeholder="Select" style="width: 100%;" >
                    <el-option
                      v-for="itemele in item.options"
                      :key="itemele.value"
                      :label="itemele.label"
                      :value="itemele.value"
                    />
                  </el-select>
                </div>
              </div>
              
                <!-- <div class="selector-item">
                  <label class="selector-label">{{ objectSelector[1].label }}</label>
                  <div class="custom-select">
                    <div class="select-trigger" @click="toggleDropdown(1)">
                      <span class="select-value">{{ selectedValues[1] }}</span>
                      <i class="select-arrow">▼</i>
                    </div>
                    <div class="select-dropdown" v-if="dropdownVisible[1]">
                      <div class="dropdown-option" v-for="option in objectSelector[1].options" :key="option" @click="selectOption(1, option)">
                        {{ option }}
                      </div>
                    </div>
                  </div>
                </div>
                
                <div class="selector-item">
                  <label class="selector-label">{{ objectSelector[2].label }}</label>
                  <div class="custom-select">
                    <div class="select-trigger" @click="toggleDropdown(2)">
                      <span class="select-value">{{ selectedValues[2] }}</span>
                      <i class="select-arrow">▼</i>
                    </div>
                    <div class="select-dropdown" v-if="dropdownVisible[2]">
                      <div class="dropdown-option" v-for="option in objectSelector[2].options" :key="option" @click="selectOption(2, option)">
                        {{ option }}
                      </div>
                    </div>
                  </div>
                </div> -->
            </div>
                <div class="content-item">
                  <hotMapComponent></hotMapComponent>
                  <cdf :allIdName="allIdName[0]"></cdf>
                  <instant :allIdName="allIdName[1]"></instant>
                </div>
                <div>
                  <el-button type="primary" class="apply-btn">应用</el-button>
                </div>
          </div>
        </div>
        
        <div v-if="activeTab === 'failureStatus'" class="tab-panel">
          <!-- 模板案例情况内容 -->
          <div class="failure-content">
            <div class="templateCase_left templateCase">
              <div class="templateCase_left_header">
                <div class="templateCase_left_header_item_title">模板列表</div>
                <div class="templateCase_left_header_item_tool">
                  <el-icon @click="templateCasedeleteHandFn"><Delete /></el-icon>
                  <el-icon @click="templateCaseAddHandFn"><Plus /></el-icon>
                  
                </div>
              </div>
              <div class="templateCase_left_content"> 
                <div class="templateCase_left_content_item" v-for="(item, index) in templateCaseList" :key="index">
                  {{item}}
                </div>
              </div>
            </div>
            <div class="templateCase_right templateCase">
              <screenConfigCase></screenConfigCase>
            </div>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script setup>

import { ref, computed, onMounted } from 'vue';
import hotMapComponent from '@/pages/all/components/hotMapComponents/index.vue';
import cdf from '@/pages/all/components/cdf/index.vue';
import instant from '@/pages/all/components/instant/index.vue';
import screenConfigCase from './screenConfigCase.vue';

const emits = defineEmits(['handleScreenConfigeClose']);
const allIdName = ref([['allIdName11', 'allIdName12'], ['allIdName21', 'allIdName22']]);
// 标签页状态管理
const activeTab = ref('equipmentCount'); // 默认选中"地面站设备数量"
const objectSelector = [
  {
    label: '地面粒度',
    default: '区域',
    options: [
      {
        value: '区域',
        label: '区域',
      },
      {
        value: '站点',
        label: '站点',
      },
      {
        value: '设备类型',
        label: '设备类型',
      },
      {
        value: '具体设备',
        label: '具体设备',
      }
    ]
  },
  {
    label: '卫星粒度',
    default: '卫星',
    options: [
      {
        value: '卫星',
        label: '卫星',
      },
      {
        value: '星座',
        label: '星座',
      },
      {
        value: '波束',
        label: '波束',
      },
      {
        value: '转发器',
        label: '转发器',
      }
    ]
  },
  {
    label: '模板',
    default: 'Example #1',
    options: [
      {
        value: 'Example #1',
        label: 'Example #1',
      },
      {
        value: 'Example #2',
        label: 'Example #2',
      },
      {
        value: 'Example #3',
        label: 'Example #3',
      },
      {
        value: '自定义模板',
        label: '自定义模板',
      }
    ]
  }
];
const templateCaseList = ref(['模板1', '模板2', '模板3', '模板4', '模板26', '模板27', '模板28'])
// 下拉选择器状态
const selectedValues = ref([]);
const dropdownVisible = ref([false, false, false]);
const templateCasedeleteHandFn = () => {
  console.log('templateCasedeleteHandFn');
};
const templateCaseAddHandFn = () => {
  console.log('templateCaseAddHandFn');
};
// 初始化选中值
onMounted(() => {
  selectedValues.value = objectSelector.map(item => item.default);
});

// 切换下拉菜单显示
const toggleDropdown = (index) => {
  // 关闭其他下拉菜单
  dropdownVisible.value = dropdownVisible.value.map((val, i) => i === index ? !val : false);
};

// 选择下拉选项
const selectOption = (index, option) => {
  selectedValues.value[index] = option;
  dropdownVisible.value[index] = false; // 选择后关闭下拉菜单
};

// 点击外部关闭下拉菜单
document.addEventListener('click', (e) => {
  if (!e.target.closest('.custom-select')) {
    dropdownVisible.value = [false, false, false];
  }
});

// 计算指示器位置
const indicatorStyle = computed(() => {
  return activeTab.value === 'equipmentCount' 
    ? { left: '0%', width: '50%' } 
    : { left: '50%', width: '50%' };
});
</script>

<style scoped>
/* 基础样式设置 */
.dashboard-container {
  width: 120%;
 
  background-color: #000000;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  left: -5%;
  top: -120px;
}

/* 头部样式 */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  padding: 0rem 1rem;
}

.logo {
  display: flex;
  align-items: center;
  height: 100%;
  width: 200px;
  justify-content: space-between;
  color: #ffffff;
}

.logo_header {
  width: 90px;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  display: flex;
}

.icon-dashboard {
  width: 10px;
  height: 10px;
  display: flex;
  align-items: center;  
}

.logo_header_content {
  font-weight: 900;
  font-size: 16px;
  /* font-family: 'Consolas', monospace;  */
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.logo_header_right {
  display: flex;
  padding-left: 10px;
  align-items: center;
  width: 100px; 
  height: 100%;
}

.logo_header_right_content {
  color: #000000;
  padding: 2px;
  font-size: 12px;
  border-radius: 5px;
  font-weight: 200;
  background-color: #6ffcba;
}

.logo_right {
  width: 70%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.divider {
  width: 100%;
  border: none;
  border-top: 1px solid #3e3f3f;
  margin: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.close-btn {
  background: none;
  border: none;
  color: #8890a6;
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #ffffff;
}

/* 主内容区域 */
.dashboard-main {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

/* 标签页样式 */
.tabs-container {
  display: flex;
  width: 300px;
  background-color: #0f172a;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  /* margin-bottom: 5px; */
}

.tab-item {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #cbd5e1;
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.tab-item.active {
  color: #ffffff;
  font-weight: 500;
}

/* 标签页激活指示器 */
.tab-indicator {
  position: absolute;
  height: 100%;
  background: linear-gradient(to bottom, #2c78f5, #000000);
  border-bottom: 1px solid #2c78f5;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 标签页内容区域 */
.tab-content {
  background-color: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  padding: 5px 15px;
}

.tab-panel {
  min-height: 600px;
  color: #e2e8f0;
}
.failure-content {
  display: flex;
  flex-direction: row;
 font-size: 15px;
  /* gap: 20px; 添加间距 */
  /* height: 500px; */
  /* background-color: rgba(1, 73, 241, 0.5); */
  /* padding: 15px; 添加内边距 */
  border-radius: 8px; /* 添加圆角 */
}

.templateCase {
  flex: 1;
  height: 100%;
  /* background-color: rgba(241, 1, 81, 0.5); */
  /* border-radius: 6px; 添加圆角 */
  /* border: 1px solid rgba(255, 255, 255, 0.1); 添加边框 */
  /* padding: 10px; 添加内边距 */
  overflow: hidden; /* 防止内容溢出 */
}

/* 可以为左右两侧添加不同样式 */
.templateCase_left {
  flex: 0.21;
  height: 100%;
  /* background-color: rgba(241, 1, 81, 0.5); */
  /* border-radius: 6px; */
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  /* padding: 10px; */
  overflow: hidden;
}

.templateCase_right {
  flex: 1;
  height: 100%;
  background-color: rgba(2, 2, 2, 0.5);
  /* border-radius: 6px; */
  /* border: 1px solid rgba(255, 255, 255, 0.1); */
  /* padding: 10px; */
  overflow: hidden;
}


.templateCase_right_content{
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  /* background-color: #2b70df; */
  /* padding: 10px 10px; */
}
.templateCase_right_content_header{
  display: flex;
  flex-direction: column;
  height: 8%;
  width: 100%;
  padding: 10px 10px;
  /* background-color: #df2b34; */
}
.templateCase_right_content_body{
  height: 92%;
  width: 100%;
  background-color: #73df2b;
}
/* 新增样式 */
.horizontal-sections {
  display: flex;
  height: 100%;
  /* gap: 10px; 可选：段落之间的间距 */
}

.section-item {
  flex: 1;
  height: 100%;
  background-color: #1e293b; /* 您可以选择合适的背景色 */
  border: 1px solid rgba(255, 255, 255, 0.1); /* 可选：边框 */
  padding: 10px 10px;
  /* border-radius: 4px; 可选：圆角 */
}
.templateCase_right_content_header_item{
 
  height: 100%;
  width: 8%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* background-color: #6ffcba; */

}
.templateCase_left_header{
  display: flex;
  padding: 10px 0;
}
.templateCase_left_header_item_title{
  flex: 0.61;
  padding-left: 10px;
  /* background-color: #2c60b4; */
}
.templateCase_left_header_item_tool {
  display: flex;
  justify-content: flex-end;
  flex: 0.39;
  gap: 15px;
  padding-right: 10px;
  align-items: center; /* 垂直居中对齐 */
}




.templateCase_left_content{
  /* background-color: #6ffcba; */
  width: 100%;
  height: 100%;
  overflow-y: auto;
}
.templateCase_left_content_item{
  height: 40px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: left;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  /* background-color: #2c78f5; */
}
.templateCase_left_content_item:hover{
  background: linear-gradient(to right, #2b70df 0, rgba(0, 0, 0, 1) 100%);
}
/* 下拉选择器样式 */
.selector-container {
  display: flex;
  gap: 20px;
  /* padding: 10px 0; */
  
}

.selector-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 15px;
}

.selector-label {
  font-size: 14px;
  color: #94a3b8;
}

.custom-select {
  position: relative;
  width: 160px;
  /* color: #ffffff; */
  border:1px solid #000000;
}
:deep(.custom-select .el-select__wrapper) {
  height: 12.5px;
}
:deep(.custom-select .el-select ){
  background: #000000;
  border:1px solid #000000;
  /* color: #ffffff; */
}
:deep(.custom-select .el-select .el-select__wrapper ){
  background: #000000;
  border:1px solid #000000;
  box-shadow: 0 0 2px rgba(131, 131, 131, 0.95);
  /* color: #ffffff; */
}

:deep(.custom-select.el-range-input) {
  color: #ffffff;
  /* font-size: 10px; */
}

:deep(.el-popper){
  background-color: #000000 !important;
}
:deep(.el-select-dropdown){
  background: #000000 !important;
}
:deep(.el-select-dropdown){
  background-color: #000000 !important;
}
.select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background-color: #91380f;
  border: 1px solid #334155;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #e2e8f0;
}

.select-value {
  flex: 1;
  text-align: left;
}

.select-arrow {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s;
}

.custom-select:hover .select-arrow {
  color: #e2e8f0;
}

.select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  z-index: 10;
  max-height: 150px;
  overflow-y: auto;
}

.dropdown-option {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.dropdown-option:hover {
  background-color: #334155;
  color: #ffffff;
}
.content-item{
  display: flex;
  flex-direction: row;
  gap: 20px;
  padding: 10px 5px;
  /* background-color: #1c5abe; */
}

.content-item > * {
  flex: 1;
  min-width: 0;
}
.content-item > *:not(:last-child) {
  padding-right: 10px;
  border-right: 1px solid #1b1b1b; /* 右边框样式 */
}


:deep(.apply-btn){
  width: 100px;
  height: 30px;
  margin-top: 10%;
  border: none;
  border-radius: 0px;
  background: linear-gradient(to bottom, #2c78f5 0, rgba(0, 0, 0, 1));
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #2c78f5;
}
/* 滚动条样式 */
.select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.select-dropdown::-webkit-scrollbar-track {
  background: #1e293b;
}

.select-dropdown::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
</style>