<template>
  <div class="left2all" :style="{ fontSize: fontSizeChangeTemp + 'px' }">
    <div class="equipment-panel_header11">
      <div class="equipment-panel_header11_content">
        <div class="header-item header-item-left" @click="backHomeClick">
          <span class="header-label">
            <img src="@/assets/images/left2/back.png" alt="@" srcset=""
              style="width: 30px; height: 20px;padding-right: 10px;">
          </span>
          <span class="header-value">返回</span>
        </div>
        <div class="header-item header-item-center">
          <span class="header-label header-item-center_label_title">

            <img :src="headerItemAllContent.forwardContent.imgUrl" alt="@" srcset=""
              style="width: 50px; height: 30px;padding-right: 10px;position: relative;top: -5px;">
          </span>
          <span class="header-value header-item-center_value">
            <div class="header-item-center_value_title">{{ headerItemAllContent.forwardContent.title }}</div>
            <div class="header-item-center_value_sub">{{ headerItemAllContent.forwardContent.subtitle }}</div>
          </span>
        </div>
        <div class="header-item header-item-right">

          <div v-for="(item, index) in headerItemAllContent.backContent" :key="index"
            style="display: flex;flex-direction: row;">
            <div class="header-item-right_content_before">
              <img src="@/assets/images/left2/item1.png" alt="@" srcset="" style="width: 20px; height: 30px;">
            </div>
            <div class="header-item-right_content">
              <span class="header-label header-label_fontColor">{{ item.label }}</span>
              <span class="header-value header-value_fontColor" v-if="item.label === '信关站'">{{
                isTimeInRange(useAppStoreInstance.subSystemTimeLineEndSelectTime, item.value[0]?.arcStartTime,
                  item.value[0]?.arcEndTime) ? item.value[0]?.stationName : "-" }}</span>
              <span v-else>
                <span class="header-value header-value_fontColor" v-if="index < 4">{{ item.value }}</span>
                <span class="header-value header-value_fontColor header-value_fontColor_progress" v-else>
                  <span style="width: 100%;">
                    <el-progress :text-inside="true" :stroke-width="5"
                      :percentage="item.value.match(/[\d.]+/) === null ? 0 : item.value.match(/[\d.]+/)[0]"
                      status="success" />
                  </span>
                  <span class="header-value header-value_fontColor" style="position: relative;top: -3px;left: 10px;">{{
                    item.value
                  }}</span>
                </span>
              </span>

            </div>

          </div>

        </div>
      </div>
    </div>
    <div class="constellation-panel">

      <!-- 顶部区域：标题与核心指标 -->
      <div class="header-container">
        <!-- 标题栏 -->
        <div class="section-divider">
          <div class="divider-line"></div>
          <h3 class="section-title">分系统实时遥测</h3>
          <div class="divider-line"></div>
        </div>

        <!-- 系统标签页 -->
        <div class="system-tabs">
          <div v-for="(item, index) in tabs" :key="index" class="tab-item" :class="{ active: activeIndex === index }"
            @click="handleTabClick(index)">
            {{ item }}
          </div>
        </div>

        <!-- 单列数据列表展示区域 -->
        <div class="telemetry-data" id="telemetry_item">

          <div class="telemetry-item" v-for="([key, value]) in Object.entries(currentTelemetryData)" :key="key">
            <div class="telemetry-label" id="telemetry_item_key">{{ key }}</div>
            <div class="telemetry-value" id="telemetry_item_value">{{ value }}</div>
          </div>

        </div>
        <div class="fontSizeChange">
          <el-popover :width="350" popper-style="width: 200px;border:none;background-color: #000000;">
            <template #reference>
              <el-avatar :size="20">
                <template #default>
                  <div class="set_carousel_text">
                    <el-icon>
                      <Setting />
                    </el-icon>
                  </div>
                </template>
              </el-avatar>
            </template>
            <template #default>


              <div class="setting-item">
                <div class="setting-label">

                  <span>字体大小(px)</span>
                </div>
                <el-input v-model="fontSizeChangeTemp" type="number" placeholder="请输入字体大小(ms)"
                  @blur="handleglobalIntervalTimeChange" class="setting-input">

                </el-input>

              </div>
            </template>

          </el-popover>
        </div>
      </div>

      <!-- 历史数据区域 -->
      <div class="ground-system-section">
        <div class="section-divider">
          <div class="divider-line"></div>
          <h3 class="section-title">遥测历史数据</h3>
          <div class="divider-line"></div>
        </div>
        <div class="equipment-panel_header">
          <!-- <div class="equipment-panel_header-item">
          <span class="equipment-panel_header-item-label">分系统</span>
          <span class="equipment-panel_header-item-value">姿轨控系统</span>
        </div> -->
          <div class="query-panel">
            <div class="header-container" style="height: 35px;padding-bottom: 40px;">
              <div class="system-tabs1">
                <div v-for="(item, index) in arcHistorytabs" :key="index" class="tab-item"
                  :class="{ active: arcHistoryActiveIndex === index }" @click="handleArcHistoryTabClick(index)">
                  {{ item }}
                </div>
              </div>
            </div>
            <!-- <div class="query-button-container">
            <el-button type="primary" class="query-button" @click="handleQuery">查询</el-button>
            <el-button type="primary" class="query-button" @click="handleQuery">查询</el-button>
            <el-button type="primary" class="query-button" @click="handleQuery">查询</el-button>
          </div> -->
            <div class="query-row">
              <!-- 时间段选择 -->
              <div class="query-group time-range-group">
                <label class="query-label">时间段</label>
                <div class="time-range-container">
                  <el-date-picker v-model="historyTimeDateRange" type="daterange" range-separator="→" disabled="true"
                    start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
                    prefix-icon="none" class="time-picker" :popper-options="{
                      placement: 'bottom-start',
                      // modifiers: [
                      //   {
                      //     name: 'offset',
                      //     options: {
                      //       offset: [120, 5] // [水平偏移, 垂直偏移]
                      //     }
                      //   }
                      // ]
                    }" />
                  <!-- <el-icon class="calendar-icon">
            <Calendar />
          </el-icon> -->
                </div>
              </div>

              <!-- 卫星粒度选择 -->
              <div class="query-group satellite-group">
                <label class="query-label">卫星粒度</label>
                <el-select v-model="satelliteGranularity" class="satellite-select">
                  <el-option v-for="item in satelliteOptions" :key="item.value" :label="item.label" :value="item.value"
                    :default-first-option=true @click="handleSatelliteGranularityChange(item.value)" />
                </el-select>
              </div>
            </div>

            <!-- 查询按钮 -->
            <div class="query-button-container">
              <el-button type="primary" class="query-button" @click="cureSearchHandleFn">查询</el-button>
            </div>
          </div>









        </div>
        <div class="equipment-panel">

          <curve :propsDate="left2BottomOpition" :idName="'left2_bottom'"></curve>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import 'element-plus/dist/index.css'
import { ref, onMounted, onBeforeMount, nextTick, watch, onUnmounted, h } from 'vue';
import { ElMessage } from 'element-plus'
import curve from './component/cruve.vue';
import useAppStore from '@/store/module/app.js';
// import Header from './component/header.vue'
// import wss from '@/utils/subSystemRequestSocket.js'
import { useRouter } from 'vue-router';
import { getSubSystemOpitionListApi, getSubSystemCurveListApi } from '../../api/Zodiac'

import SubWss from '@/utils/subSystemRequestSocket.js'
import Loading from '@/pages/all/components/loadingComponent/index.js';

const subWssInstance = ref(SubWss)
const router = useRouter();
const useAppStoreInstance = useAppStore();
const activeIndex = ref(0);
const arcHistoryActiveIndex = ref(null);
const currentTelemetryData = ref({});

const arcHistoryData = ref(true);

const arcHistorytabs = [
  "姿轨控分系统",
  "能源分系统",
  "热控分系统"
]

const fontSizeChangeTemp = ref(10);
const handleSatelliteGranularityChange = (value) => {

  historyCode.value = value;
  isFlagOfSeletctType.value = true;

}

const tempCount = ref(0);
const handleglobalIntervalTimeChange = () => {
  // console.log("handleglobalIntervalTimeChange",fontSizeChangeTemp.value);
  console.log("fontSizeChangeTemp.value", document.getElementById("telemetry_item"));
  tempCount.value++;
  document.getElementById("telemetry_item").style.fontSize = fontSizeChangeTemp.value + "px";
  // document.getElementById("telemetry_item_key").style.fontSize = fontSizeChangeTemp.value + "px";
  // document.getElementById("telemetry_item_value").style.fontSize = fontSizeChangeTemp.value + "px";
}

function isTimeInRange(time, timeStart, endTime) {
  // console.log("isTimeInRange",time, timeStart, endTime);
  if (time === null || timeStart === null || endTime === null ||
    time === undefined || timeStart === undefined || endTime === undefined
  ) {
    // console.log("zoiulezheli");

    return false;
  }
  const t = new Date(time).getTime();
  const start = new Date(timeStart).getTime();
  const end = new Date(endTime).getTime();


  return t >= start && t <= end;
}

const formatToMidnight = (isoString) => {
  const date = new Date(isoString);
  // 使用 UTC 年月日构造新的 Date，避免时区偏移影响
  const year = date.getUTCFullYear();
  const month = String(date.getUTCMonth() + 1).padStart(2, '0');
  const day = String(date.getUTCDate()).padStart(2, '0');
  return `${year}-${month}-${day} 00:00:00`;
};

const defaultGetSubSystemCurveList = () => {
  console.log("******", historyCode.value,);

  getSubSystemCurveListApi({
    endTime: (historyTimeDateRange.value[1]),
    satelliteId: useAppStoreInstance.globalSatelliteSearchID === '0' ? "4097" : (useAppStoreInstance.globalSatelliteSearchID),
    startTime: (historyTimeDateRange.value[0]),
    subSystemType: arcHistorySubSystemOptions[arcHistoryActiveIndex.value],
    code: historyCode.value,
  }).then(res => {
    left2BottomOpitionX.value = []
    left2BottomOpitionY.value = []
    res.data.map(item => (
      left2BottomOpitionX.value.push(item.x),
      left2BottomOpitionY.value.push(item.y)
    ))

    left2BottomOpition.value = {
      // falgStartSearch:isFalgStartSearch.value,
      unit: res.data[0]?.unit === "" ? "" : `( ${res.data[0]?.unit} )`,
      maxY: ceilForMaxValue(Math.max(...left2BottomOpitionY.value)),
      minY: floorForMinValue(Math.min(...left2BottomOpitionY.value)),
      isFirstSearch: true,
      dataX: left2BottomOpitionX.value,
      dataY: left2BottomOpitionY.value,
      type: 'line',
      chartName: satelliteOptions.value.filter((item) => (String(historyCode.value) === String(item.value)))[0]?.label
    }
  })
  // console.log("defaultGetSubSystemCurveList结束了",res.data[0]?.unit === "");
  arcHistoryData.value = true;
}

const arcHistorySubSystemOptions = ['CONTROL', 'POWER', 'THERMAL'];
const handleArcHistoryTabClick = (index) => {
  if (!arcHistoryData.value) {
    ElMessage.warning('请勿连续操作！');
    return;
  }
  arcHistoryActiveIndex.value = index;
  isFlagOfSeletctType.value = false;

  isFalgStartSearch.value = false;
  subSystemOptionsFn(arcHistorySubSystemOptions[index]);
  arcHistoryData.value = false;

  // cureSearchHandleFn(satelliteOptions.value[0].code)
}

watch(() => arcHistoryActiveIndex.value,
  () => {
    nextTick(() => {
      setTimeout(() => {
        //console.log("arcHistoryActiveIndex.value发生改变",satelliteOptions.value[0]);

        defaultGetSubSystemCurveList();



      }, 500);

    })

    // defaultGetSubSystemCurveList();
  })
// 系统标签
const tabs = [
  "综电分系统",
  "载荷分系统",
  "姿轨控分系统",
  "能源分系统",
  "热控分系统"
];

const headerItemAllContent = ref({
  forwardContent:
  {
    title: "分系统",
    subtitle: "姿轨控系统",
    imgUrl: new URL('../../assets/images/footers/smallSatellite_normal.png', import.meta.url).href
  },
  backContent:
    [
      {
        label: "信关站",
        value: { "arcStartTime": "2025-11-03 09:09:42.0", "arcEndTime": "2025-11-03 09:17:29.0", "stationName": "烟台信关站" }
      },
      {
        label: "生命周期状态",
        value: "-"
      },
      // {
      //   label: "工作模式",
      //   value: "运行中"
      // },
      {
        label: "管理状态",
        value: "-"
      },
      {
        label: "健康状态",
        value: "-"
      },
      {
        label: "剩余燃料",
        value: "9.5kg"
      },

    ]

})

const backHomeClick = () => {
  console.log("我执行了");

  router.push('/');
  // //console.log("1111111111111111111111111", useAppStoreInstance.isSourceLegendShow);
  useAppStoreInstance.setGlobalisFromTosub(true);
  useAppStoreInstance.setislegendShow(useAppStoreInstance.isSourceLegendShow ? true : false);
  // //console.log("11111111111111111111111112", useAppStoreInstance.islegendShow);
  useAppStoreInstance.setiscontrolPanelShow(true);
  if (window.ue5) {

    window.ue5("callBackSubSysToMainSysFn", String(JSON.stringify({
      SubToMain: true
    })));


  }

}
// 遥测数据 - 姿轨控系统示例数据
const telemetryData = {
  0: [
    { label: "TMK501姿控工作模式", value: "3" },
    { label: "TMK502姿控工作模式", value: "1" },
    { label: "TMK503惯性系姿态稳定模式", value: "2" },
    { label: "TMK504惯性系角速度稳定模式", value: "2" },
    { label: "TMK505轨道系姿态角Euler X", value: "-0.15°" },
    { label: "TMK506轨道系姿态角Euler Y", value: "0.05°" },
    { label: "TMK507轨道系姿态角Euler Z", value: "0.08°" },
    { label: "TMK508轨道系角速度wx", value: "0.012°/s" },
    { label: "TMK509轨道系角速度wy", value: "-0.008°/s" },
    { label: "TMK510轨道系角速度wz", value: "0.015°/s" },
    { label: "TMK521推进工作模式", value: "0" },
    { label: "TMK522反作用轮工作模式", value: "4" },
    { label: "TMK523磁力力矩器工作模式", value: "2" },
    { label: "TMK538星敏A额定四元数q1", value: "0.7071" },
    { label: "TMK539星敏A额定四元数q2", value: "-0.00105" },
    { label: "TMK539星敏A额定四元数q3", value: "0.0087" },
    { label: "TMK539星敏A额定四元数q4", value: "0.0087" },
    { label: "TMK546双敏感器使用状态", value: "1" },
    { label: "TMK547单星敏使用状态", value: "0" },
    { label: "TMK548陀螺认定角速度Wbx(deg/s)", value: "0.012°/s" }
  ],
  1: [
    { label: "载荷分系统参数1", value: "值1" },
    { label: "载荷分系统参数2", value: "值2" },
  ],
};

const CONTROL_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
    return [
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      // { label: '惯性系角速度确定模式TMKS011工程值', value: data.angularVelocityModeTmks011 === null ? 0 : data.angularVelocityModeTmks011 },
      // { label: '惯性系姿态确定模式TMKS010工程值', value: data.attitudeDeterminationModeTmks010 === null ? 0 : data.attitudeDeterminationModeTmks010 },

      { label: '电推工作模式TMK521工程值', value: data.electricPropulsionModeTmk521 === null ? 0 : data.electricPropulsionModeTmk521 },
      { label: '误差角速度XTMK580工程值', value: data.errorAngularVelocityXTmk580 === null ? 0 + ' °/s' : data.errorAngularVelocityXTmk580 + ' °/s' },
      { label: '误差角速度YTMK581工程值', value: data.errorAngularVelocityYTmk581 === null ? 0 + ' °/s' : data.errorAngularVelocityYTmk581 + ' °/s' },
      { label: '误差角速度ZTMK582工程值', value: data.errorAngularVelocityZTmk582 === null ? 0 + ' °/s' : data.errorAngularVelocityZTmk582 + ' °/s' },
      { label: '误差姿态角XTMK577工程值', value: data.errorAttitudeAngleXTmk57 === null ? 0 + ' °' : data.errorAttitudeAngleXTmk57 + ' °' },
      { label: '误差姿态角YTMK578工程值', value: data.errorAttitudeAngleYTmk578 === null ? 0 + ' °' : data.errorAttitudeAngleYTmk578 + ' °' },
      { label: '误差姿态角ZTMK579工程值', value: data.errorAttitudeAngleZTmk579 === null ? 0 + ' °' : data.errorAttitudeAngleZTmk579 + ' °' },
      { label: '磁力矩器工作模式TMK523工程值', value: data.magnetorquerModeTmk523 === null ? 0 : data.magnetorquerModeTmk523 },
      // { label: '接收时间', value: data.onboardTime === null ? 0 : data.onboardTime },
      { label: '轨道系角速度wboxTMK508工程值', value: data.orbitAngularVelocityXTmk509 === null ? 0 + ' °/s' : data.orbitAngularVelocityXTmk509 + ' °/s' },
      { label: '轨道系角速度wboyTMK509工程值', value: data.orbitAngularVelocityYTmk509 === null ? 0 + ' °/s' : data.orbitAngularVelocityYTmk509 + ' °/s' },
      { label: '轨道系角速度wbozTMK510工程值', value: data.orbitAngularVelocityZTmk510 === null ? 0 + ' °/s' : data.orbitAngularVelocityZTmk510 + ' °/s' },
      { label: '轨道系姿态角EulerXTMK505工程值', value: data.orbitAttitudeAngleXTmk507 === null ? 0 + ' °' : data.orbitAttitudeAngleXTmk507 + ' °' },
      { label: '轨道系姿态角EulerYTMK506工程值', value: data.orbitAttitudeAngleYTmk507 === null ? 0 + ' °' : data.orbitAttitudeAngleYTmk507 + ' °' },
      { label: '轨道系姿态角EulerZTMK507工程值', value: data.orbitAttitudeAngleZTmk507 === null ? 0 + ' °' : data.orbitAttitudeAngleZTmk507 + ' °' },
      { label: '反作用轮工作模式TMK522工程值', value: data.reactionWheelModeTmk522 === null ? 0 : data.reactionWheelModeTmk522 },
      { label: 'SADA期望工作模式字TMK620工程值', value: data.sadaExpectedModeTmk620 === null ? 0 : data.sadaExpectedModeTmk620 },
      { label: 'SADA工作状态TMK619工程值', value: data.sadaWorkingStatusTmk619 === null ? 0 : data.sadaWorkingStatusTmk619 },
      // { label: '上注完成情况(星)', value: data.arcCompleteNum === null ? 0 : data.arcCompleteNum },
      // { label: '上注失败星数(星)', value: data.arcFaultNum === null ? 0 : data.arcFaultNum }
    ];
  }
  // else if (Array.isArray(data)) {
  //   // 如果意外传入了数组，仍然处理数组
  //   return data.map(item => ([ 
  //     { label: '地面站数', value: item.groundStationNum === null ? 0 : item.groundStationNum },
  //   { label: '开通格网数', value: item.openGridNum === null ? 0 : item.openGridNum },
  //   { label: '弧段数量', value: item.arcNum === null ? 0 : item.arcNum },
  //   { label: '执行情况-弧段', value: item.arcExecuteNum === null ? 0 : item.arcExecuteNum },
  //   { label: '设备故障', value: item.faultDeviceNum === null ? 0 : item.faultDeviceNum },
  //   // { label: '上注完成情况(星)', value: item.arcCompleteNum === null ? 0 : item.arcCompleteNum },
  //   // { label: '上注失败星数(星)', value: item.arcFaultNum === null ? 0 : item.arcFaultNum }
  // ]));
  // }

  // 如果 data 不是对象也不是数组，返回空数组
  // return [];
};
const PAYLOAD_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
    return [
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      { label: '波束模式', value: data.beamModeTmz147 === null ? 0 : data.beamModeTmz147 },
      { label: '变频转发器5V', value: data.converter5vTmz201 === null ? 0 + ' V' : data.converter5vTmz201 + ' V' },
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      { label: '变频转发器20V', value: data.converter20vTmz203 === null ? 0 + ' V' : data.converter20vTmz203 + ' V' },
      { label: '变频转发器功放1功率TMZ060工程值', value: data.converterAmplifier1PowerTmz060 === null ? 0 + ' W' : data.converterAmplifier1PowerTmz060 + ' W' },
      { label: '变频转发器前向变频功率TMZ061工程值', value: data.converterForwardConversionPowerTmz061 === null ? 0 + ' W' : data.converterForwardConversionPowerTmz061 + ' W' },
      { label: '变频转发器前向变频温度', value: data.converterForwardConversionTempTmz209 === null ? 0 + ' °C' : data.converterForwardConversionTempTmz209 + ' °C' },
      { label: '变频转发器-5V', value: data.converterMinus5vTmz202 === null ? 0 + ' V' : data.converterMinus5vTmz202 + ' V' },
      { label: '变频转发器反向变频温度', value: data.converterReverseConversionTempTmz210 === null ? 0 + ' °C' : data.converterReverseConversionTempTmz210 + ' °C' },
      { label: '变频转发器V接收前端温度1', value: data.converterVReceiveFrontendTemp1Tmz206 === null ? 0 + ' °C' : data.converterVReceiveFrontendTemp1Tmz206 + ' °C' },
      { label: '变频转发器V接收前端温度2', value: data.converterVReceiveFrontendTemp2Tmz207 === null ? 0 + ' °C' : data.converterVReceiveFrontendTemp2Tmz207 + ' °C' },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      // { label: '扩展小区表状态TMZ058工程值', value: data.extendedCellTableStatusTmz058 === null ? 0 : data.extendedCellTableStatusTmz058 },
      { label: '馈电1方位角', value: data.feed1AzimuthAngleTmz151 === null ? 0 + ' °' : data.feed1AzimuthAngleTmz151 + ' °' },
      { label: '馈电1俯仰角', value: data.feed1ElevationAngleTmz150 === null ? 0 + ' °' : data.feed1ElevationAngleTmz150 + ' °' },
      { label: '馈电1信关站TMZ149工程值', value: data.feed1GatewayStationTmz149 === null ? 0 : data.feed1GatewayStationTmz149 },
      { label: '馈电2方位角', value: data.feed2AzimuthAngleTmz154 === null ? 0 + ' °' : data.feed2AzimuthAngleTmz154 + ' °' },
      { label: '馈电2俯仰角', value: data.feed2ElevationAngleTmz153 === null ? 0 + ' °' : data.feed2ElevationAngleTmz153 + ' °' },
      { label: '馈电2信关站TMZ152工程值', value: data.feed2GatewayStationTmz152 === null ? 0 : data.feed2GatewayStationTmz152 },
      { label: '馈电下一弧段开始时间', value: data.feedNextArcStartTimeTmz137 === null ? 0 : data.feedNextArcStartTimeTmz137 },
      { label: '馈电指向时间_秒', value: data.feedPointingTimeSecondsTmz148 === null ? 0 + ' s' : data.feedPointingTimeSecondsTmz148 + ' s' },
      { label: '地面站参数表状态', value: data.groundStationParamTableStatusTmz128 === null ? 0 : data.groundStationParamTableStatusTmz128 },
      // { label: '接收时间', value: data.onboardTime === null ? 0 : data.onboardTime },


      { label: '载管CPU使用率TMZ062工程值', value: data.payloadCpuUsageTmz062 === null ? 0 : data.payloadCpuUsageTmz062 },



      { label: '载管状态TMZ009工程值', value: data.payloadManagementStatusTmz009 === null ? 0 : data.payloadManagementStatusTmz009 },
      { label: '载管主备状态TMZ115工程值', value: data.payloadMasterSlaveStatusTmz115 === null ? 0 : data.payloadMasterSlaveStatusTmz115 },
      { label: 'PPS选择源TMZ119工程值', value: data.ppsSourceTmz119 === null ? 0 + ' dBm' : data.ppsSourceTmz119 + ' dBm' },
      { label: 'QV伺服1备份5V电路电流', value: data.qvServo1Backup5vCurrentTmz215 === null ? 0 + ' A' : data.qvServo1Backup5vCurrentTmz215 + ' A' },
      { label: 'QV伺服1备份功率电流', value: data.qvServo1BackupPowerCurrentTmz213 === null ? 0 + ' A' : data.qvServo1BackupPowerCurrentTmz213 + ' A' },
      { label: 'QV伺服1主份5V电路电流', value: data.qvServo1Main5vCurrentTmz214 === null ? 0 + ' A' : data.qvServo1Main5vCurrentTmz214 + ' A' },
      { label: 'QV伺服1主份功率电流', value: data.qvServo1MainPowerCurrentTmz212 === null ? 0 + ' A' : data.qvServo1MainPowerCurrentTmz212 + ' A' },
      { label: 'QV伺服1遥测请求异常TMZ012工程值', value: data.qvServo1TelemetryErrorTmz012 === null ? 0 : data.qvServo1TelemetryErrorTmz012 },
      { label: 'QV伺服2遥测请求异常TMZ023工程值', value: data.qvServo2TelemetryErrorTmz023 === null ? 0 : data.qvServo2TelemetryErrorTmz023 },
      { label: 'QV伺服2_5V电源电流', value: data.qvServo25vCurrentTmz219 === null ? 0 + ' A' : data.qvServo25vCurrentTmz219 + ' A' },
      { label: 'QV伺服2_5V电压', value: data.qvServo25vVoltageTmz217 === null ? 0 + ' V' : data.qvServo25vVoltageTmz217 + ' V' },
      { label: 'QV伺服2_1.9V电源电流', value: data.qvServo219vCurrentTmz218 === null ? 0 + ' A' : data.qvServo219vCurrentTmz218 + ' A' },
      // { label: 'QV伺服2_2.4V电源电流', value: data.qvServo224vCurrentTmz220 === null ? 0 : data.qvServo224vCurrentTmz220 },
      { label: 'QV伺服2_24V电压', value: data.qvServo224vVoltageTmz216 === null ? 0 + ' V' : data.qvServo224vVoltageTmz216 + ' V' },
      { label: '接收阵-1.5V遥测', value: data.receiveArray15vTmz345 === null ? 0 + ' V' : data.receiveArray15vTmz345 + ' V' },
      { label: '接收阵+3.3V电源1遥测', value: data.receiveArray33vPower1Tmz350 === null ? 0 + ' V' : data.receiveArray33vPower1Tmz350 + ' V' },
      { label: '接收阵-3.6V遥测', value: data.receiveArray36vTmz347 === null ? 0 + ' V' : data.receiveArray36vTmz347 + ' V' },
      { label: '接收阵+5.1V电源2遥测', value: data.receiveArray51vPower2Tmz351 === null ? 0 + ' V' : data.receiveArray51vPower2Tmz351 + ' V' },
      { label: '接收阵+5.1V电源遥测', value: data.receiveArray51vPowerTmz349 === null ? 0 + ' V' : data.receiveArray51vPowerTmz349 + ' V' },
      { label: '接收阵-电流遥测', value: data.receiveArrayCurrentTmz348 === null ? 0 + ' A' : data.receiveArrayCurrentTmz348 + ' A' },
      { label: '接收阵-DCDC温度', value: data.receiveArrayDcdcTempTmz354 === null ? 0 + ' °C' : data.receiveArrayDcdcTempTmz354 + ' °C' },

      { label: '接收阵遥测请求异常TMZ039工程值', value: data.receiveArrayTelemetryErrorTmz039 === null ? 0 : data.receiveArrayTelemetryErrorTmz039 },
      { label: '接收阵-温度遥测1', value: data.receiveArrayTemp1Tmz355 === null ? 0 + ' °C' : data.receiveArrayTemp1Tmz355 + ' °C' },
      { label: '接收阵-温度遥测2', value: data.receiveArrayTemp2Tmz356 === null ? 0 + ' °C' : data.receiveArrayTemp2Tmz356 + ' °C' },
      { label: '接收阵-温度遥测3', value: data.receiveArrayTemp3Tmz357 === null ? 0 + ' °C' : data.receiveArrayTemp3Tmz357 + ' °C' },
      // { label: '星上时间', value: data.receiveTime === null ? 0 : data.receiveTime },
      { label: '接收波控3.3V电压', value: data.receiveWaveControl33vVoltageTmz224 === null ? 0 + ' V' : data.receiveWaveControl33vVoltageTmz224 + ' V' },
      { label: '反向路径补偿模式', value: data.reversePathCompensationModeTmz195 === null ? 0 : data.reversePathCompensationModeTmz195 },
      { label: '反向额定输入通量密度', value: data.reverseRatedInputFluxDensityTmz196 === null ? 0 + ' W/㎡' : data.reverseRatedInputFluxDensityTmz196 + ' W/㎡' },
      // { label: '卫星编码', value: data.satelliteId === null ? 0  : data.satelliteId },
      { label: '遥测轮询计数TMZ001工程值', value: data.telemetryPollingCountTmz001 === null ? 0 : data.telemetryPollingCountTmz001 },
      { label: '发射1波控3.3V电压', value: data.transmit1WaveControl33vCurrentTmz221 === null ? 0 + ' V' : data.transmit1WaveControl33vCurrentTmz221 + ' V' },
      { label: '发射1波控3.3V电流', value: data.transmit1WaveControl33vVoltageTmz220 === null ? 0 + ' A' : data.transmit1WaveControl33vVoltageTmz220 + ' A' },
      { label: '发射1波控遥测请求异常TMZ033工程值', value: data.transmit1WaveControlErrorTmz033 === null ? 0 : data.transmit1WaveControlErrorTmz033 },
      { label: '发射2波控3.3V电压', value: data.transmit2WaveControl33vCurrentTmz223 === null ? 0 + ' V' : data.transmit2WaveControl33vCurrentTmz223 + ' V' },
      { label: '发射2波控3.3V电流', value: data.transmit2WaveControl33vVoltageTmz222 === null ? 0 + ' A' : data.transmit2WaveControl33vVoltageTmz222 + ' A' },
      { label: '发射2波控遥测请求异常', value: data.transmit2WaveControlErrorTmz036 === null ? 0 : data.transmit2WaveControlErrorTmz036 },
      { label: '发射阵1-DCDC温度', value: data.transmitArray1DcdcTempTmz274 === null ? 0 + ' °C' : data.transmitArray1DcdcTempTmz274 + ' °C' },
      { label: '发射阵1-温度遥测1', value: data.transmitArray1Temp1Tmz275 === null ? 0 + ' °C' : data.transmitArray1Temp1Tmz275 + ' °C' },
      { label: '发射阵1-温度遥测2', value: data.transmitArray1Temp2Tmz276 === null ? 0 + ' °C' : data.transmitArray1Temp2Tmz276 + ' °C' },
      { label: '发射阵1-温度遥测3', value: data.transmitArray1Temp3Tmz277 === null ? 0 + ' °C' : data.transmitArray1Temp3Tmz277 + ' °C' },
      { label: '发射阵1-温度遥测4', value: data.transmitArray1Temp4Tmz278 === null ? 0 + ' °C' : data.transmitArray1Temp4Tmz278 + ' °C' },
      { label: '发射阵2-电流遥测', value: data.transmitArray2CurrentTmz308 === null ? 0 + ' A' : data.transmitArray2CurrentTmz308 + ' A' },
      { label: '发射阵2-DCDC温度', value: data.transmitArray2DcdcTempTmz314 === null ? 0 : data.transmitArray2DcdcTempTmz314 },
      { label: '发射阵2-温度遥测1', value: data.transmitArray2Temp1Tmz315 === null ? 0 + ' °C' : data.transmitArray2Temp1Tmz315 + ' °C' },
      { label: '发射阵2-温度遥测2', value: data.transmitArray2Temp2Tmz316 === null ? 0 + ' °C' : data.transmitArray2Temp2Tmz316 + ' °C' },
      { label: '发射阵2-温度遥测3', value: data.transmitArray2Temp3Tmz317 === null ? 0 + ' °C' : data.transmitArray2Temp3Tmz317 + ' °C' },
      { label: '发射阵2-温度遥测4', value: data.transmitArray2Temp4Tmz318 === null ? 0 + ' °C' : data.transmitArray2Temp4Tmz318 + ' °C' },
      { label: '发射阵1-1.5V遥测', value: data.transmitArray115vTmz265 === null ? 0 + ' V' : data.transmitArray115vTmz265 + ' V' },
      { label: '发射阵1-3.3V遥测', value: data.transmitArray133vTmz266 === null ? 0 + ' V' : data.transmitArray133vTmz266 + ' V' },
      { label: '发射阵1-3.6V遥测', value: data.transmitArray136vTmz267 === null ? 0 + ' V' : data.transmitArray136vTmz267 + ' V' },
      { label: '发射阵2-1.5V遥测', value: data.transmitArray215vTmz305 === null ? 0 + ' V' : data.transmitArray215vTmz305 + ' V' },
      { label: '发射阵2-3.3V遥测', value: data.transmitArray233vTmz306 === null ? 0 + ' V' : data.transmitArray233vTmz306 + ' V' },
      { label: '发射阵2-3.6V遥测', value: data.transmitArray236vTmz307 === null ? 0 + ' V' : data.transmitArray236vTmz307 + ' V' },
      // { label: '发射等通量模式', value: data.transmitEqualFluxModeTmz194 === null ? 0 : data.transmitEqualFluxModeTmz194 },
      { label: '转发器频率源主备状态TMZ055工程值', value: data.transponderFreqSourceStatusTmz055 === null ? 0 : data.transponderFreqSourceStatusTmz055 },
      // { label: '时间戳', value: data.ts === null ? 0 : data.ts },

    ];
  }
  //  else if (Array.isArray(data)) {
  //   // 如果意外传入了数组，仍然处理数组
  //   return data.map(item => ([ 
  //     { label: '地面站数', value: item.groundStationNum === null ? 0 : item.groundStationNum },
  //   { label: '开通格网数', value: item.openGridNum === null ? 0 : item.openGridNum },
  //   { label: '弧段数量', value: item.arcNum === null ? 0 : item.arcNum },
  //   { label: '执行情况-弧段', value: item.arcExecuteNum === null ? 0 : item.arcExecuteNum },
  //   { label: '设备故障', value: item.faultDeviceNum === null ? 0 : item.faultDeviceNum },
  //   // { label: '上注完成情况(星)', value: item.arcCompleteNum === null ? 0 : item.arcCompleteNum },
  //   // { label: '上注失败星数(星)', value: item.arcFaultNum === null ? 0 : item.arcFaultNum }
  // ]));
  // }

  // 如果 data 不是对象也不是数组，返回空数组
  // return [];
};
const ELECTRONICS_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
    return [
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      { label: 'GNSS-定轨数据有效标记TM010工程值', value: data.gnssOrbitValidTm010 === null ? 0 : data.gnssOrbitValidTm010 },

      { label: 'GNSS-定位数据有效标记TM009工程值', value: data.gnssPositionValidTm009 === null ? 0 : data.gnssPositionValidTm009 },
      { label: 'GNSSB-定轨数据有效标记TMC490工程值', value: data.gnssbOrbitDataValidTmc490 === null ? 0 : data.gnssbOrbitDataValidTmc490 },
      { label: 'GNSSB-定位数据有效标记TMC489工程值', value: data.gnssbPositionDataValidTmc489 === null ? 0 : data.gnssbPositionDataValidTmc489 },
      { label: 'KUA遥控位同步TMC003工程值', value: data.kuaTelecommandBitSyncTmc003 === null ? 0 : data.kuaTelecommandBitSyncTmc003 },
      { label: 'KUA遥控载波锁定标志TMC001工程值', value: data.kuaTelecommandCarrierLockTmc001 === null ? 0 : data.kuaTelecommandCarrierLockTmc001 },
      { label: 'KUA遥控指令计数TMC027工程值', value: data.kuaTelecommandCountTmc027 === null ? 0 : data.kuaTelecommandCountTmc027 },
      { label: 'KUA遥控伪码锁定标志TMC002工程值', value: data.kuaTelecommandPseudoCodeLockTmc002 === null ? 0 : data.kuaTelecommandPseudoCodeLockTmc002 },
      { label: 'KUA发射机开关机状态TMC005工程值', value: data.kuaTransmitterPowerStatusTmc005 === null ? 0 : data.kuaTransmitterPowerStatusTmc005 },
      { label: 'KUB遥控位同步TMC033工程值', value: data.kubTelecommandBitSyncTmc033 === null ? 0 : data.kubTelecommandBitSyncTmc033 },
      { label: 'KUB遥控载波锁定标志TMC031工程值', value: data.kubTelecommandCarrierLockTmc031 === null ? 0 : data.kubTelecommandCarrierLockTmc031 },
      { label: 'KUB遥控伪码锁定标志TMC032工程值', value: data.kubTelecommandPseudoCodeLockTmc032 === null ? 0 : data.kubTelecommandPseudoCodeLockTmc032 },
      { label: 'KUB发射机开关机状态TMC035工程值', value: data.kubTransmitterPowerStatusTmc035 === null ? 0 : data.kubTransmitterPowerStatusTmc035 },
      // { label: '接收时间', value: data.onboardTime === null ? 0 : data.onboardTime },
      { label: 'QVA遥控指令计数TMC077工程值', value: data.qvaTelecommandCountTmc077 === null ? 0 : data.qvaTelecommandCountTmc077 },
      // { label: '星上时间', value: data.receiveTime === null ? 0 : data.receiveTime },
      { label: '接收指令计数TMC333工程值', value: data.receivedCommandCountTmc333 === null ? 0 : data.receivedCommandCountTmc333 },
      // { label: '卫星编码', value: data.satelliteId === null ? 0 : data.satelliteId },
      { label: '遥控应急模式状态TMC594工程值', value: data.telecommandEmergencyModeTmc594 === null ? 0 : data.telecommandEmergencyModeTmc594 },
      { label: '遥测应急模式状态TMC626工程值', value: data.telemetryEmergencyModeTmc626 === null ? 0 : data.telemetryEmergencyModeTmc626 },
      { label: '境内外标识TMC524工程值', value: data.territoryFlagTmc524 === null ? 0 : data.territoryFlagTmc524 },
      { label: '测控工作模式TMC529工程值', value: data.ttcWorkModeTmc529 === null ? 0 : data.ttcWorkModeTmc529 },

      // { label: '时间戳', value: data.ts === null ? 0 : data.ts },

    ];
  }
  // else if (Array.isArray(data)) {
  //   // 如果意外传入了数组，仍然处理数组
  //   return data.map(item => ([ 
  //     { label: '地面站数', value: item.groundStationNum === null ? 0 : item.groundStationNum },
  //   { label: '开通格网数', value: item.openGridNum === null ? 0 : item.openGridNum },
  //   { label: '弧段数量', value: item.arcNum === null ? 0 : item.arcNum },
  //   { label: '执行情况-弧段', value: item.arcExecuteNum === null ? 0 : item.arcExecuteNum },
  //   { label: '设备故障', value: item.faultDeviceNum === null ? 0 : item.faultDeviceNum },
  //   // { label: '上注完成情况(星)', value: item.arcCompleteNum === null ? 0 : item.arcCompleteNum },
  //   // { label: '上注失败星数(星)', value: item.arcFaultNum === null ? 0 : item.arcFaultNum }
  // ]));
  // }

  // 如果 data 不是对象也不是数组，返回空数组
  // return [];
};
const POWER_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
    return [
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      // { label: '阳极电源输出电流TMK026工程值', value: data.anodeOutputCurrent === null ? 0 : data.anodeOutputCurrent },

      // { label: '阳极电源输出电压TMK025工程值', value: data.anodeOutputVoltage === null ? 0 : data.anodeOutputVoltage },
      { label: '蓄电池组电压TMY012工程值', value: data.batteryVoltageTmy012 === null ? 0 + ' V' : data.batteryVoltageTmy012 + ' V' },
      { label: '42V母线电压TMY011工程值', value: data.bus42vVoltageTmy011 === null ? 0 + ' V' : data.bus42vVoltageTmy011 + ' V' },
      { label: 'CAN总线正确帧计数TMY002工程值', value: data.canCorrectFrameCountTmy002 === null ? 0 : data.canCorrectFrameCountTmy002 },
      { label: '充电电流TMY014工程值', value: data.chargeCurrentTmy014 === null ? 0 + ' A' : data.chargeCurrentTmy014 + ' A' },
      { label: '放电电流TMY015工程值', value: data.dischargeCurrentTmy015 === null ? 0 + ' A' : data.dischargeCurrentTmy015 + ' A' },
      { label: '42V负载电流TMY013工程值', value: data.loadCurrent42vTmy013 === null ? 0 + ' A' : data.loadCurrent42vTmy013 + ' A' },
      // { label: '接收时间', value: data.onboardTime === null ? 0 : data.onboardTime },

      { label: '接收指令计数TMY003工程值', value: data.receiveCommandCountTmy003 === null ? 0 : data.receiveCommandCountTmy003 },
      // { label: '星上时间', value: data.receiveTime === null ? 0 : data.receiveTime },
      // { label: '卫星编码', value: data.satelliteId === null ? 0 : data.satelliteId },

      { label: '方阵电流1TMY023工程值', value: data.solarArrayCurrent1Tmy023 === null ? 0 : data.solarArrayCurrent1Tmy023 },
      { label: '方阵电流2TMY024工程值', value: data.solarArrayCurrent2Tmy024 === null ? 0 + ' A' : data.solarArrayCurrent2Tmy024 + ' A' },
      { label: '遥测请求指令计数TMY001工程值', value: data.telemetryRequestCountTmy001 === null ? 0 + ' A' : data.telemetryRequestCountTmy001 + ' A' },

      // { label: '时间戳', value: data.ts === null ? 0 : data.ts },

    ];
  }
  // else if (Array.isArray(data)) {
  //   // 如果意外传入了数组，仍然处理数组
  //   return data.map(item => ([ 
  //     { label: '地面站数', value: item.groundStationNum === null ? 0 : item.groundStationNum },
  //   { label: '开通格网数', value: item.openGridNum === null ? 0 : item.openGridNum },
  //   { label: '弧段数量', value: item.arcNum === null ? 0 : item.arcNum },
  //   { label: '执行情况-弧段', value: item.arcExecuteNum === null ? 0 : item.arcExecuteNum },
  //   { label: '设备故障', value: item.faultDeviceNum === null ? 0 : item.faultDeviceNum },
  //   // { label: '上注完成情况(星)', value: item.arcCompleteNum === null ? 0 : item.arcCompleteNum },
  //   // { label: '上注失败星数(星)', value: item.arcFaultNum === null ? 0 : item.arcFaultNum }
  // ]));
  // }

  // 如果 data 不是对象也不是数组，返回空数组
  // return [];
};

const THERMAL_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
    return [
      // { label: '通道', value: data.channel === null ? 0 : data.channel },
      // { label: '实时/延时', value: data.dataType === null ? 0 : data.dataType },
      // { label: '蓄电池组温度1（热敏63）TMY026工程值', value: data.batteryTemp1 === null ? 0 : data.batteryTemp1 },
      // { label: '接收时间', value: data.onboardTime === null ? 0 : data.onboardTime },
      //  { label: '星上时间', value: data.receiveTime === null ? 0 : data.receiveTime },
      { label: '热控模式TMR001工程值', value: data.thermalModeTmr === null ? 0 : data.thermalModeTmr },
      { label: 'RM11_+Y发射相控阵+Y侧', value: data.rm11YTransmitArrayYSide === null ? 0 + ' °C' : data.rm11YTransmitArrayYSide + ' °C' },
      { label: 'RM13_+Y发射相控阵-Y侧', value: data.rm13YTransmitArrayYSide3 === null ? 0 + ' °C' : data.rm13YTransmitArrayYSide3 + ' °C' },
      { label: 'RM15_-Y发射相控阵+Y侧', value: data.rm15YTransmitArrayYSide2 === null ? 0 + ' °C' : data.rm15YTransmitArrayYSide2 + ' °C' },
      { label: 'RM17_-Y发射相控阵-Y侧', value: data.rm17YTransmitArrayYSide4 === null ? 0 + ' °C' : data.rm17YTransmitArrayYSide4 + ' °C' },
      { label: 'RM19_变频转发器安装面', value: data.rm19ConverterTransponderMount === null ? 0 + ' °C' : data.rm19ConverterTransponderMount + ' °C' },
      { label: 'RM20_动量轮A温度', value: data.rm20MomentumWheelATemp === null ? 0 + ' °C' : data.rm20MomentumWheelATemp + ' °C' },
      { label: 'RM21_动量轮C温度', value: data.rm21MomentumWheelCTemp === null ? 0 + ' °C' : data.rm21MomentumWheelCTemp + ' °C' },

      { label: 'RM22_动量轮B温度', value: data.rm22MomentumWheelBTemp === null ? 0 + ' °C' : data.rm22MomentumWheelBTemp + ' °C' },

      // { label: '卫星编码', value: data.satelliteId === null ? 0 : data.satelliteId },

      // { label: 'RM23_动量轮D温度', value: data.rm23MomentumWheelDTemp === null ? 0 : data.rm23MomentumWheelDTemp },
      { label: 'RM24_伺服控制器1安装面温度', value: data.rm24ServoController1MountTemp === null ? 0 + ' °C' : data.rm24ServoController1MountTemp + ' °C' },
      { label: 'RM26_星敏温度+Y侧', value: data.rm26StarSensorTempY === null ? 0 + ' °C' : data.rm26StarSensorTempY + ' °C' },

      // { label: '时间戳', value: data.ts === null ? 0 : data.ts },





      { label: 'RM27_星敏温度-Y侧', value: data.rm27StarSensorTempY2 === null ? 0 + ' °C' : data.rm27StarSensorTempY2 + ' °C' },
      { label: 'RM33_SADM温度测点1', value: data.rm33SadmTemp1 === null ? 0 + ' °C' : data.rm33SadmTemp1 + ' °C' },
      { label: 'RM36_气瓶温度（中心）', value: data.rm36GasBottleTempCenter === null ? 0 + ' °C' : data.rm36GasBottleTempCenter + ' °C' },
      { label: 'RM38_高压管路（舱外）', value: data.rm38HighPressurePipeOut === null ? 0 + ' °C' : data.rm38HighPressurePipeOut + ' °C' },
      { label: 'RM44_流量控制器本体', value: data.rm44FlowControllerBody === null ? 0 + ' °C' : data.rm44FlowControllerBody + ' °C' },
      { label: 'RM46_接收相控阵测点+Y侧', value: data.rm46ReceiveArrayYSide === null ? 0 + ' °C' : data.rm46ReceiveArrayYSide + ' °C' },
      { label: 'RM47_接收相控阵测点-Y侧', value: data.rm47ReceiveArrayYSide2 === null ? 0 + ' °C' : data.rm47ReceiveArrayYSide2 + ' °C' },

      { label: 'RM49_霍尔电控箱安装面温度+X侧', value: data.rm49HallControlBoxMountX === null ? 0 + ' °C' : data.rm49HallControlBoxMountX + ' °C' },

      { label: 'RM52_KU测控应答机安装面', value: data.rm52KuTtcTransponderMount === null ? 0 + ' °C' : data.rm52KuTtcTransponderMount + ' °C' },

      { label: 'RM55_陀螺与时频安装面', value: data.rm55GyroTimeFreqMount === null ? 0 + ' °C' : data.rm55GyroTimeFreqMount + ' °C' },
      { label: 'RM56_综合电子测温1', value: data.rm56IntegratedElectronicsTemp1 === null ? 0 + ' °C' : data.rm56IntegratedElectronicsTemp1 + ' °C' },
      { label: 'RM58_电源控制器安装面1', value: data.rm58PowerControllerMount1 === null ? 0 + ' °C' : data.rm58PowerControllerMount1 + ' °C' },



    ];
  }
  // else if (Array.isArray(data)) {
  //   // 如果意外传入了数组，仍然处理数组
  //   return data.map(item => ([ 
  //     { label: '地面站数', value: item.groundStationNum === null ? 0 : item.groundStationNum },
  //   { label: '开通格网数', value: item.openGridNum === null ? 0 : item.openGridNum },
  //   { label: '弧段数量', value: item.arcNum === null ? 0 : item.arcNum },
  //   { label: '执行情况-弧段', value: item.arcExecuteNum === null ? 0 : item.arcExecuteNum },
  //   { label: '设备故障', value: item.faultDeviceNum === null ? 0 : item.faultDeviceNum },
  //   // { label: '上注完成情况(星)', value: item.arcCompleteNum === null ? 0 : item.arcCompleteNum },
  //   // { label: '上注失败星数(星)', value: item.arcFaultNum === null ? 0 : item.arcFaultNum }
  // ]));
  // }

  // 如果 data 不是对象也不是数组，返回空数组
  // return [];
};


const ALL_wssTransformGroundSatelliteData = (data) => {
  // 检查 data 是否为对象且不为 null
  //console.log("...........3.......",Array.isArray(data) );

  // let transformedData = []
  if (Array.isArray(data) && Object.keys(data).length > 0) {
    // transformedData = data.map(item => ({
    //   ...item.fields
    // }))

    currentTelemetryData.value = Object.assign({}, ...data.map(item => ({
      ...item.fields
    })))

    //console.log("5555555555555555100",currentTelemetryData.value,typeof currentTelemetryData.value);
  } else {
    currentTelemetryData.value = {}
    return {};
  }

  // 如果 data 不是对象也不是数组，返回空数组

};

// 时间格式化函数
const formatTime = (date) => {
  if (!date) return '';
  const hours = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const seconds = String(date.getSeconds()).padStart(2, '0');
  return `${hours}:${minutes}:${seconds}`;
};

// 日期时间格式化函数
const formatDateTime = (date) => {
  if (!date) return '未选择';
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  return `${year}-${month}-${day} ${formatTime(date)}`;
};

// 日期范围选择
const historyTimeDateRange = ref(null);

// 卫星粒度选择
const satelliteGranularity = ref();
const satelliteOptions = ref([
  // { label: 'TMK505轨道系姿态角Euler X', value: 'TMK505' },

]);


const subSystemOptionsFn = (subSystemTypeValue) => {
  getSubSystemOpitionListApi({ subSystemType: subSystemTypeValue }).then(res => {
    //console.log("getSubSystemOpitionListApi-----------",res);


    satelliteOptions.value = res.map(item => ({
      label: item.name,
      value: item.code
    }));

    satelliteGranularity.value = satelliteOptions.value[0].value

    // satelliteGranularity.value = ""

    historyCode.value = satelliteOptions.value[0].value;
  })
}
const historyCode = ref("11")
const isFlagOfSeletctType = ref(false)

const left2BottomOpitionX = ref([])
const left2BottomOpitionY = ref([])
const isFalgStartSearch = ref(false)


const left2BottomOpition = ref({
  isFirstSearch: false,
})

// 查询处理函数
const cureSearchHandleFn = () => {
  //console.log("11111111111111-------1111:",isFlagOfSeletctType.value);

  // if (!isFlagOfSeletctType.value) {
  //    ElMessage({
  //       type: 'error',
  //       message: `请选择卫星粒度`,
  //     })

  // }else
  {


    //     //console.log('查询参数:', {
    //   // dateRange: historyTimeDateRange.value,
    //   code: historyCode.value,
    //   endTime: historyTimeDateRange.value[1],
    //   satelliteId: useAppStoreInstance.globalSatelliteSearchID==='0'? "4097": (useAppStoreInstance.globalSatelliteSearchID),
    //   startTime: historyTimeDateRange.value[0],
    //   subSystemType: arcHistorySubSystemOptions[arcHistoryActiveIndex.value],


    //   // satelliteGranularity: satelliteGranularity.value
    // });

    isFalgStartSearch.value = true;



    //  //console.log("propsDate-min--3333333333--------",{
    //     endTime: historyTimeDateRange.value[1],
    //     satelliteId: useAppStoreInstance.globalSatelliteSearchID==='0'? "4097": (useAppStoreInstance.globalSatelliteSearchID),
    //     startTime: historyTimeDateRange.value[0],
    //     subSystemType: arcHistorySubSystemOptions[arcHistoryActiveIndex.value],
    //     code: historyCode.value ,
    //   });

    getSubSystemCurveListApi({
      endTime: (historyTimeDateRange.value[1]),
      satelliteId: useAppStoreInstance.globalSatelliteSearchID === '0' ? "4097" : (useAppStoreInstance.globalSatelliteSearchID),
      startTime: (historyTimeDateRange.value[0]),
      subSystemType: arcHistorySubSystemOptions[arcHistoryActiveIndex.value],
      code: historyCode.value,
    }).then(res => {
      if (res.code !== 200) {
        // Loading.hide()
      }
      // return
      left2BottomOpitionX.value = []
      left2BottomOpitionY.value = []
      res.data.map(item => (
        left2BottomOpitionX.value.push(item.x),
        left2BottomOpitionY.value.push(item.y)
      ))

      left2BottomOpition.value = {
        // falgStartSearch:isFalgStartSearch.value,
        unit: res.data[0]?.unit === "" ? "" : `( ${res.data[0]?.unit} )`,
        maxY: ceilForMaxValue(Math.max(...left2BottomOpitionY.value)),
        minY: floorForMinValue(Math.min(...left2BottomOpitionY.value)),
        isFirstSearch: true,
        dataX: left2BottomOpitionX.value,
        dataY: left2BottomOpitionY.value,
        type: 'line',
        chartName: satelliteOptions.value.filter((item) => (String(historyCode.value) === String(item.value)))[0].label
      }
    })
    arcHistoryData.value = true;
  }

};

// 处理最大值的函数 - 向上取整
const ceilForMaxValue = (value) => {
  if (value === 0) return 0;

  const isNegative = value < 0;
  const absValue = Math.abs(value);

  const exponent = Math.floor(Math.log10(absValue));
  const factor = 10 ** exponent;
  const normalized = absValue / factor;

  let result;

  // Determine the ceiling based on normalized value
  if (normalized <= 1) {
    result = 1 * factor;
  } else if (normalized <= 2) {
    result = 2 * factor;
  } else if (normalized <= 5) {
    result = 5 * factor;
  } else {
    result = 10 * factor;
  }

  // Handle negative values (round toward -∞)
  if (isNegative) {
    if (absValue >= 1) {
      result = Math.floor(absValue);
      if (result >= absValue) {
        result = Math.floor(absValue / factor) * factor;
      }
    } else {
      result = Math.floor(absValue / factor) * factor;
      if (result >= absValue) {
        result = factor;
      }
    }
    result = -result;
  }

  return result;
};

const floorForMinValue = (value) => {
  if (value === 0) return 0;

  const isNegative = value < 0;
  const absValue = Math.abs(value);

  const exponent = Math.floor(Math.log10(absValue));
  const factor = 10 ** exponent;
  const normalized = absValue / factor;

  let result;

  // Determine the floor based on normalized value
  if (normalized >= 10) {
    result = 10 * factor;
  } else if (normalized >= 5) {
    result = 5 * factor;
  } else if (normalized >= 2) {
    result = 2 * factor;
  } else {
    result = 1 * factor;
  }

  // Handle negative values (round toward +∞)
  if (isNegative) {
    if (absValue >= 1) {
      result = Math.ceil(absValue);
      if (result <= absValue) {
        result = Math.ceil(absValue / factor) * factor;
      }
    } else {
      result = Math.ceil(absValue / factor) * factor;
      if (result <= absValue) {
        result = 10 * factor;
      }
    }
    result = -result;
  }

  return result;
};
const wssOpenHandle = (data) => {
  // //console.log('wssOpenHandle', wss,wss.readyState, WebSocket.OPEN);
  if ((subWssInstance.value).readyState === WebSocket.OPEN) {
    // 如果连接已打开，直接发送数据
    // //console.log('连接yi打开...');

    (subWssInstance.value).send(JSON.stringify(data));
  } else if ((subWssInstance.value).readyState === WebSocket.CLOSED) {

    (subWssInstance.value) = new WebSocket((subWssInstance.value).url);
    (subWssInstance.value).onopen = () => {
      (subWssInstance.value).send(JSON.stringify(data));
    };
  }
  else {
    // 否则等待连接打开后再发送
    // //console.log('连接未打开，等待...');
    (subWssInstance.value).onopen = () => {
      (subWssInstance.value).send(JSON.stringify(data));
    };
  }
};
const socketTypeMap = ["ELECTRONICS", "PAYLOAD", "CONTROL", "POWER", "THERMAL"]
const toNumber = (value) => {
  const num = Number(value);
  return isNaN(num) ? 0 : num; // 如果转换失败则返回0
}
// 切换标签页
const handleTabClick = (index) => {
  // //console.log('实时遥测标签:', index);
  activeIndex.value = index;
  useAppStoreInstance.setglobalSubsystemActiveIndex(index)
  if (window.ue5) {
    window.ue5("callBackTelemetryTagFn", String(JSON.stringify({
      // isSelect: true,
      telemetryTag: tabs[index],
    })));
  }
  wssOpenHandle({


    // "isFastForward":false, 
    // "taskCode":"1111111111111",
    // "satelliteId":"4097",
    // "type":"POWER" ,

    isFastForward: useAppStoreInstance.globalSubsystemIsFastForward || false,
    // speed: useAppStoreInstance.globalSubsystemSpeed || 1,
    // startTime: formatDateTime(pick_select_date.value[0]),
    // endTime: formatDateTime(pick_select_date.value[1]),
    taskCode: String(useAppStoreInstance.globalSubsystemTaskCode || 0),
    type: socketTypeMap[index] || 'CONTROL',
    satelliteId: useAppStoreInstance.globalSatelliteSearchID === '0' ? "4097" : (useAppStoreInstance.globalSatelliteSearchID),
  })
  //   (subWssInstance.value).onmessage = (event) => {
  //   //console.log('我走了这里，收到数据21');

  //     const data = JSON.parse(event.data);
  //     // //console.log('我是left2,type == time获取的wssRespone:', data);
  //     useAppStoreInstance.setSubsystemSocketContent(data)
  // };
  // switch (useAppStoreInstance.globalSubsystemActiveIndex) {
  //   case 0:
  //     if (window.ue5) {
  //       window.ue5("callBackTelemetryTagFn", String(JSON.stringify({
  //         isSelect: true,
  //         telemetryTag: tabs[index],
  //       })));
  //     }
  //     break;
  //   case 1:
  //     break;
  //   case 2:
  //     break;
  //   case 3:
  //     break;
  //   case 4:
  //     break;
  //   case 5:
  //     break;
  //   default:
  //     break;
  // }
  // currentTelemetryData.value = telemetryData[index] || [];
};

onBeforeMount(() => {
  subSystemOptionsFn("CONTROL");

  // //console.log("12222222222222222222222222",satelliteOptions.value[0].code);


  // 发送api请求
  // subSystemStatisticsInfoApi({
  //   id: 0,
  // }).then(res => {
  //   //console.log(res);
  // })
  //             (subWssInstance.value).onmessage = (event) => {
  //   //console.log('我走了这里，收到数据22');

  //     const data = JSON.parse(event.data);
  //     const transformedData = CONTROL_wssTransformGroundSatelliteData(data);
  //     currentTelemetryData.value = transformedData;

  //     // transformConstellationData(JSONdata)
  //     // //console.log('我是left2,type == time获取的wssRespone:', data);

  // };

})

const force_Refresh = ref(0)
// 日期时间格式化函数
const mountformatDateTime = (date) => {
  if (!date) return '未选择';

  // 确保传入的是Date对象
  const d = new Date(date);

  // 获取年月日时分秒
  const year = d.getFullYear();
  const month = String(d.getMonth() + 1).padStart(2, '0');
  const day = String(d.getDate()).padStart(2, '0');
  const hours = String(d.getHours()).padStart(2, '0');
  const minutes = String(d.getMinutes()).padStart(2, '0');
  const seconds = String(d.getSeconds()).padStart(2, '0');

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};


const middleWssImgUrlMap = {
  "上海小卫星": new URL('../../assets/images/footers/smallSatellite_normal.png', import.meta.url).href,
  "格思航天": new URL('../../assets/images/footers/gosiSatellite_normal copy.png', import.meta.url).href,
}
const middleWssTransformGroundNetworkElementStatus = (data) => {
  headerItemAllContent.value = {
    forwardContent:
    {
      title: data?.elementName || "-",
      subtitle: useAppStoreInstance.subSystemTimeLineEndSelectTime,
      imgUrl: middleWssImgUrlMap[data?.manufacturer || "上海小卫星"] || middleWssImgUrlMap["上海小卫星"],
    },
    backContent:
      [
        {
          label: "信关站",
          value: data?.siteName || "-"
        },
        {
          label: "生命周期状态",
          value: data?.lifecycleStatus || "-"
        },

        {
          label: "管理状态",
          value: data?.managementStatus || "-"
        },
        {
          label: "健康状态",
          value: data?.operationalStatus || "-"
        },
        {
          label: "剩余燃料",
          value: data?.fuelRemaining || "-"
        },

      ]
  }
}

watch(() => useAppStoreInstance.subsystemSocketContent, (newVal, oldValue) => {
  // const newValue = useAppStoreInstance.subsystemSocketContent
  //console.log("22222222222left******************",useAppStoreInstance.subsystemSocketContent);
  // handleTabClick(useAppStoreInstance.globalSubsystemActiveIndex)
  ALL_wssTransformGroundSatelliteData(newVal?.leftTop)
  middleWssTransformGroundNetworkElementStatus(newVal?.groundNetworkElementStatus)

  // console.log("22222222222left******************",newVal.groundNetworkElementStatus);




  force_Refresh.value += 1
  // switch (toNumber(useAppStoreInstance.globalSubsystemActiveIndex)) {
  //   case 0:
  //     const transformedData = CONTROL_wssTransformGroundSatelliteData(newVal.leftTop);

  //     // currentTelemetryData.value = [];
  //     currentTelemetryData.value = transformedData;
  //     // //console.log('22222222222left0---transformedData0*********************:', transformedData);
  //     break;
  //   case 1:
  //     const transformedData1 = PAYLOAD_wssTransformGroundSatelliteData(newVal.leftTop);
  //     // currentTelemetryData.value = [];
  //     currentTelemetryData.value = transformedData1;
  //     // //console.log('22222222222left1---transformedData1*********************:', transformedData1);
  //     break;
  //   case 2:
  //     const transformedData2 = ELECTRONICS_wssTransformGroundSatelliteData(newVal.leftTop);
  //     // currentTelemetryData.value = [];
  //     currentTelemetryData.value = transformedData2;
  //     // //console.log('22222222222left2---transformedData2*********************:', transformedData2);
  //     break;
  //   case 3:
  //     const transformedData3 = POWER_wssTransformGroundSatelliteData(newVal.leftTop);
  //     // currentTelemetryData.value = [];
  //     currentTelemetryData.value = transformedData3;
  //     // //console.log('22222222222left3---transformedData3*********************:', transformedData3);
  //     break;
  //   case 4:
  //     const transformedData4 = THERMAL_wssTransformGroundSatelliteData(newVal.leftTop);
  //     // currentTelemetryData.value = [];
  //     currentTelemetryData.value = transformedData4;

  //     // //console.log('22222222222left4---transformedData4*********************:', transformedData4);
  //     break;
  //   default:
  //     // currentTelemetryData.value = [];
  //     //console.log('22222222222left---transformedData default*********************:');
  //     break;
  // }













  // activeIndex.value = 0;
  // //console.log("222222222-------------------******kaishi ");
  // const transformedData = CONTROL_wssTransformGroundSatelliteData(useAppStoreInstance.subsystemSocketContent);
  // currentTelemetryData.value = transformedData;
  // // //console.log("-------------------******jieshu ");
  // // //console.log('subsystemSocketContent 变化了:', newValue,typeof newValue);
  // // const transformedData = CONTROL_wssTransformGroundSatelliteData(newValue);
  // // currentTelemetryData.value = transformedData;
  // // //console.log('transformedData*********************:', transformedData);
  // // 这里可以添加处理新值的逻辑



}, { deep: true, immediate: true });







onMounted(() => {
  currentTelemetryData.value = {}
  // (subWssInstance.value) = new WebSocket(wss.url);
  nextTick(() => {

    //console.log("我走了globalSubsystemSelectedTimeRange---left2",mountformatDateTime(useAppStoreInstance.globalSubsystemSelectedTimeRange[0]), mountformatDateTime(useAppStoreInstance.globalSubsystemSelectedTimeRange[1]));

    if (useAppStoreInstance.footerTimeHasedSelectTimeToSub) {
      // historyTimeDateRange.value = [new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),new Date(Date.now()).toISOString()];
      historyTimeDateRange.value = [mountformatDateTime(useAppStoreInstance.globalSubsystemSelectedTimeRange[0]), mountformatDateTime(useAppStoreInstance.globalSubsystemSelectedTimeRange[1])]
    } else {
      historyTimeDateRange.value = [new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(), new Date(Date.now()).toISOString()];
    }
    useAppStoreInstance.setiscontrolPanelShow(false);
    // (subWssInstance.value).onmessage = (event) => {
    //   //console.log('我走了这里，收到数据23');

    //     const data = JSON.parse(event.data);
    //     const transformedData = CONTROL_wssTransformGroundSatelliteData(data);
    //     currentTelemetryData.value = transformedData;

    //     // transformConstellationData(JSONdata)
    //     // //console.log('我是left2,type == time获取的wssRespone:', data);

    // };
    left2BottomOpition.value = {
      isFirstSearch: false,
    }
  })
  arcHistoryActiveIndex.value = 0
});
onUnmounted(() => {
  // useAppStoreInstance.setGlobalSubsystemSelectedTimeRange([]);
});
</script>

<style scoped>
/* 基础样式 */
.constellation-panel {
  color: #e0e7ff;
  padding: 15px;
  border-radius: 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  background-color: #010102;
}

.left2all {
  color: #e0e7ff;
  /* padding: 15px; */
  border-radius: 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  background-color: #010102;
}

.equipment-panel_header11 {
  position: fixed;
  top: 6%;
  left: 25%;
  width: 50%;
  min-height: 60px;

  min-width: 750px;
  background: rgba(0, 0, 0, 1);
  /* background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.12) 0%,
    rgba(46,125,255,0.2)  50%,
    rgba(0, 0, 0, 0.12) 100%
  ); */
  /* margin-bottom: 15px; */
  /* border-radius: 8px; */
  /* padding: 10px; */
  box-sizing: border-box;
  border-top: 2px solid rgba(0, 0, 0, 0.92);
  /* background: linear-gradient(to right, 
    rgba(0, 0, 0, 0.1) 0%,
 rgba(13, 34, 70, 0.4) 50%,
  rgba(0, 0, 0, 0.193) 100%); */
  /* box-shadow: inset 0 0 30px 0px rgb(46,125,255); */
  border-bottom: 2px solid rgba(0, 0, 0, 0.92);
  border-image: linear-gradient(to right,
      rgb(29, 43, 66) 0%,
      rgb(46, 125, 255) 50%,
      rgb(29, 43, 66) 100%) 1;
}

.equipment-panel_header11_content {
  background: linear-gradient(to right,
      transparent 0%,
      rgba(46, 125, 255, 0.1) 30%,
      rgba(46, 125, 255, 0.2) 50%,
      rgba(46, 125, 255, 0.1) 70%,
      transparent 100%);
}

/* .equipment-panel_header11::before {
  content: '';
  position: absolute;
  
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70px;
  background: linear-gradient(to right, 
    transparent 0%,
     rgba(46,125,255,0.1) 30%,
     rgba(46,125,255,0.2) 50%,
     rgba(46,125,255,0.1) 70%,
    transparent 100%);

} */



.equipment-panel_header11_content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px;
  width: 100%;
  height: 100%;
  z-index: 100 !important;
  padding: 5px 0;
}

.header-item {
  flex: 1;
  min-height: 60px;

  /* background-color: #0066ff; */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* padding: 5px 10px; */

}

.header-item-left {
  flex: 0.15;
  flex-direction: row;
  cursor: pointer;
  /* 添加这行 */
}

.header-item-center {
  flex: 0.3;
  flex-direction: row;
}

.header-item:first-child {
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.header-item-center_label_title {
  align-items: normal;
  /* background-color: #1a2c4d; */
  height: 38px;
}

.header-label {
  color: #a0a0a0;
  font-size: 12px;
  /* margin-bottom: 4px; */
}

.header-value {
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
}

.header-item-center_value {
  flex-direction: column;
}

.header-item-center_value_sub {
  font-size: 10px;
  color: #a0a0a0;
}

.header-item-right {
  /* background-color: chocolate; */
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  /* 或使用 space-evenly */
  align-items: center;
  /* padding: 0 10px; */
}

.header-item-right_content {
  display: flex;
  flex-direction: column;
  /* 垂直排列 */
  align-items: left;
  /* 水平居中 */
  justify-content: center;
  /* 垂直居中 */
  padding: 8px 12px;
  /* background-color: rgba(0, 0, 0, 0.2); */
  border-radius: 4px;
  min-width: 60px;
  /* margin: 0 5px; */
}

.header-item-right_content_before {
  position: relative;
  top: 3px;
  left: -5px;
  width: 10px;
  height: 10px;
  /* background-color: #474747;
  padding: 4px;
  border: 2px solid #1900ff; 使用border属性设置边框颜色 */
}

.header-label_fontColor {
  color: rgb(212, 212, 212);
}

.header-value_fontColor {
  color: #6FFCBA;
  font-size: 10px;
  padding-top: 1.5px;
}

.header-label_status_ok {
  color: #6FFCBA;
}

.header-value_fontColor_progress {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  /* gap: 5px; */
}

:depp(.el-progress-bar) {
  background-color: #000000 !important;
  /* background: #000000 !important; */

}

:depp(.el-progress-bar .el-progress-bar__outer) {
  background-color: #000000 !important;
  /* background: #000000 !important; */

}

:deep(.el-progress-bar__innerText) {
  display: none;
}

:deep(.el-progress.is-success .el-progress-bar__inner) {
  background-color: #6FFCBA;
}

/* 顶部容器 */
.header-container {
  display: flex;
  flex-direction: column;
  gap: 15px;

  /* 添加 */
  /* max-height: 400px; */
}

/* 标题栏 */
.section-divider {
  display: flex;
  align-items: center;
  margin: 5px 0;
  background-image: url('@/assets/images/lefts/bg_title.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(59, 130, 246, 0.3), transparent);
}

.section-title {
  font-size: 14px;
  color: #ffffff;
  font-weight: 900;
  padding: 0 15px;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* 系统标签页 */
/* 系统标签页 */
.system-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* 每行三等分 */
  grid-auto-rows: 1fr;
  /* 自动行高 */
  background-color: #000000;
  padding: 2px;
  height: 70px;
  gap: 2px;
  /* 设置网格间距 */
}

.system-tabs1 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* 每行三等分 */
  grid-auto-rows: 1fr;
  /* 自动行高 */
  background-color: #000000;
  padding: 2px;
  height: 35px;
  gap: 2px;
  /* 设置网格间距 */
}

.tab-item {
  padding: 8px 5px;
  text-align: center;
  color: #b4c5e0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  background: linear-gradient(to bottom, #2c2c2c 0%, #000000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  /* 占满网格单元 */
  box-sizing: border-box;
  min-width: 0;
  /* 防止内容撑开 */
}

.tab-item.active {
  background: linear-gradient(to bottom, #1a5fc5 0%, #000000 100%);
  color: #ffffff;
  /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); */
  border-bottom: 1px solid #0066ff;
}

/* .tab-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #4dc3ff;
} */

.tab-item:not(.active):hover {
  background-color: #1a2c4d;
  color: #e6eeff;
}

/* 遥测数据列表 - 调整对齐方式 */
.telemetry-data {
  background: rgba(10, 14, 23, 0.6);
  border-radius: 8px;
  /* padding: 8px; */
  /* max-height: 55vh; */
  height: 35vh;
  overflow-y: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 整体内容居中 */
}

.telemetry-item {
  display: flex;
  justify-content: space-between;
  /* 左右分布 */
  align-items: center;
  /* 垂直居中 */
  color: #ffffff;
  font-size: var(--fontSize);
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
  /* 控制宽度，留出边距 */
}

.fontSizeChange {
  position: relative;
  top: -70%;
  left: 91%;
  /* right: 8%; */
  width: 10px;
  /* background-color: #a52121; */
}

:deep(.fontSizeChange .el-avatar) {
  background-color: #000000;
}

.set_carousel_text {
  background-color: none;
}

.setting-item {
  display: flex;
  /* align-items: center; */
  flex-direction: row;
  gap: 8px;
  flex: 1;
  color: #ffffff;
}

.setting-input {
  color: #ffffff;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #ffffff;
  white-space: nowrap;
}

.telemetry-label {
  color: #c5c5c5;
  text-align: right;
  /* 标签右对齐 */
  flex: 1.2;
  padding-right: 15px;
  /* 增加与值的间距 */
  word-break: break-word;
}

.telemetry-value {
  color: #ffffff;
  text-align: left;
  /* 值左对齐 */
  /* font-family: 'Consolas', monospace; */
  flex: 0.96;
  word-break: break-all;
}

/* 历史数据区域 */
.ground-system-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: 470px;
  /* background-color: burlywood; */
}

.equipment-panel {
  background: rgba(10, 14, 23, 0.6);
  /* border-radius: 8px; */
  width: 100%;
  /* background-color: #165dff; */
  overflow: hidden;
  /* position: relative; */
  /* top:-10px;
  height: 270px; */
  /* min-height: 25vh; */
  /* padding: 15px; */
}


.equipment-panel_header {
  /* background-color: rgba(18, 81, 226, 0.6); */
  border-radius: 8px;
  /* padding: 8px; */
  /* height: 80px; */
}





/* 基础容器样式 */
.query-panel {
  /* background-color: #1a1a1a; */
  /* padding: 15px; */
  border-radius: 6px;
}

/* 查询行布局 */
.query-row {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 15px;
}

/* 查询组基础样式 */
.query-group {
  display: flex;
  flex-direction: column;
  gap: 15px;

}

.satellite-group {
  height: 71px;
  /* background-color: #165dff; */
}

/* 标签样式 */
.query-label {
  color: #e0e7ff;
  font-size: 14px;
  margin-bottom: 3px;
}

/* 时间段选择容器 */
.time-range-container {
  position: relative;
  width: 185px;
  background-color: #000000;
  border: none !important;
  /* border-radius: 4px; */
}


/* 日期选择器样式 */

.time-picker {
  width: 90%;
  background-color: #000000;
  border: 1px solid #3d3d3d;
  border-radius: 4px;
  color: #e0e7ff;
}

:deep(.time-range-container) {
  border: none !important;
}

:deep(.time-range-container .time-picker) {
  width: 100%;
  font-size: 4px;
  border: none !important;
  background-color: #000000 !important;
}

:deep(.el-input__wrapper) {
  background-color: #000000 !important;
}

:deep(.el-range-separator) {
  color: #ffffff;
}

:deep(.el-date-editor .el-range-input) {
  color: #ffffff;
  font-size: 10px;
  background: #000000;
}

/* 日历图标 */
.calendar-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  cursor: pointer;
}

/* 卫星粒度选择器 */
.satellite-select {
  width: 120px;
  /* background-color: #2d2d2d; */
  /* border: 1px solid #e90303; */
  border-radius: 4px;
  height: 3px;
}

:deep(.satellite-select .el-select__wrapper) {
  height: 12.5px;
}

:deep(.satellite-select .el-select__selected-item) {
  color: #ffffff;
  font-size: 10px;

}

:deep(.satellite-select .el-select__selection) {
  height: 12.5px;
}

:deep(.satellite-select .el-select__input) {
  font-size: 10px;
}

:deep(.satellite-select .el-tooltip__trigger) {
  background-color: #000000 !important;
  color: #f9fafd !important;
  border: none !important;

}

/* 按钮容器 */
.query-button-container {
  display: flex;
  justify-content: flex-start;
}



.query-button:hover {
  color: #ffffff;
}

/* 自定义Element Plus组件样式 */
:deep(.el-date-picker__input) {
  background-color: transparent !important;
  color: #e0e7ff !important;
  border: none !important;
}

:deep(.el-input__wrapper) {
  background-color: #2d2d2d !important;
  /* border-color: #3d3d3d !important; */
}

:deep(.el-select-dropdown) {
  background-color: #000000 !important;
  /* border-color: #3d3d3d !important; */
}

:deep(.el-select-dropdown__item) {
  color: #ffffff !important;
}

:deep(.el-select-dropdown__item:hover) {
  background-color: #3d3d3d !important;
}

:deep(.el-select-dropdown__item.selected) {
  background-color: #165dff !important;
  color: white !important;
}





/* 查询按钮 */
.query-button {
  background: linear-gradient(to bottom, #1a5fc5 0%, #000000 100%);
  /* border-color: #165dff; */
  width: 100px;
  height: 36px;
  font-size: 14px;
  color: #a7a5a5;
  /* border-radius: 4px; */
  /* border: none !important; */

  /* transition: all 0.2s ease; */
}

:deep(.query-button-container .query-button) {
  border: none;
  border-bottom: 1px solid #0f6fff;

}

.setting-item :deep(.el-input .el-input__wrapper) {
  background-color: #000000 !important;
  border: none !important;
  box-shadow: 0 0 0 1px #424242 !important;
  color: #ffffff !important;
}


:deep(.el-date-editor.el-input__wrapper) {
  /* background-color: #1a1a1a !important; */
  border: 1px solid #424242 !important;
  box-shadow: none !important;
}

:deep(.satellite-select .el-select__wrapper) {
  border: 1px solid #424242 !important;
  box-shadow: none !important;

}


:deep(.custom-table .el-table__inner-wrapper .el-scrollbar__wrap) {
  border: 1px solid #424242 !important;
  box-shadow: none !important;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: rgba(79, 79, 80, 0.6);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(123, 123, 124, 0.6);
}

@media (max-width: 1560px) {
  .equipment-panel_header11 {
    display: none;
  }
}

/* @media (max-width: 900px) {
  .equipment-panel_header11{
    display: block;
  }
} */
</style>