<template>
  <div class="home-container">
    <div class="header">
      <div class="header-left">
        <div
          class="nav-btn"
          :class="{ active: selectedNavBtn == 'equity' }"
          @click="handleNavBtnClick('equity')"
        >
          股权投资
        </div>

        <div
          class="nav-btn"
          :class="{ active: selectedNavBtn == 'fixedRisk' }"
          @click="handleNavBtnClick('fixedRisk')"
        >
          固定风险投资
        </div>
      </div>

      <!-- 中间标题 -->
      <div class="header-middle">
        <span>葛洲坝集团交通投资有限公司投资决策分析系统可视化大屏</span>
      </div>

      <!-- 右侧导航按钮：房地产投资、融资建设投资 -->
      <div class="header-right">
        <div
          class="nav-btn"
          :class="{ active: selectedNavBtn === 'realEstate' }"
          @click="handleNavBtnClick('realEstate')"
        >
          房地产投资
        </div>
        <div
          class="nav-btn"
          :class="{ active: selectedNavBtn === 'financing' }"
          @click="handleNavBtnClick('financing')"
        >
          融资建设投资
        </div>
      </div>

      <!-- 全屏按钮 -->
      <div class="header-fullscreen">
        <span @click="toggleFullscreen" class="fullscreen-text">
          <el-icon :size="18">
            <full-screen />
          </el-icon>
          {{ isFullscreen ? "退出全屏" : "全屏" }}
        </span>
        <span @click="handleInput(!modelValue)" class="fullscreen-text">
          <el-icon :size="18">
            <Switch />
          </el-icon>
          {{ modelValue ? "决策分析可视化大屏" : "交通投资可视化大屏" }}
        </span>
      </div>
    </div>
    <div class="map-container">
      <div class="map-content">
        <Map class="Map" ref="mapRef" :tabKey="selectedContentBtn" />
        <div class="info-right-wraps">
          <div class="info-right-wrap lixiang">
            <div class="infos-title">立项</div>

            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['lixiang']"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="info-right-wrap">
            <div class="infos-title">建设</div>

            <div class="info-title">项目概况</div>
            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['jianshe'].gaikuang"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
            <div class="info-title">投资完成情况</div>
            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['jianshe'].tzwcqk"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
            <div class="info-title">投资完成情况</div>
            <div class="info-progress">
              <div class="progress-pie" ref="progressPie"></div>
              <div class="progress-bar">
                <div class="progress-text">109.04/122.52亿元</div>
                <div class="progress-image">
                  <div class="progress-show-value"></div>
                  <!-- rel100%宽在css上占父元素的85%，进度样式上要做换算 -->
                  <div
                    class="progress-show-value-rel"
                    :style="{ width: `${(89 * 85) / 100}%` }"
                  ></div>
                </div>
              </div>
            </div>
            <div class="info-title">投资回收完成情况</div>
            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['jianshe'].tzhswcqk"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="info-right-wrap">
            <div class="infos-title">运营</div>

            <div class="info-title">项目概况</div>
            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['shiyunying'].gaikuang"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
            <template v-if="infoObj['shiyunying'].tzwcqk">
              <div class="info-title">投资完成情况</div>
              <div class="data-info">
                <div
                  class="info-item"
                  v-for="(item, idx) in infoObj['shiyunying'].tzwcqk"
                  :key="idx"
                >
                  <div class="item-title">{{ item.title }}</div>
                  <div class="item-value">
                    {{ item.value }}
                    <span class="item-unit">{{ item.unit }}</span>
                  </div>
                </div>
              </div>
            </template>
            <div class="info-title">经营计划完成情况</div>
            <div class="data-info-large">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['shiyunying'].jyjhwcqk"
                :key="idx"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-content">
                  <div
                    class="target-item"
                    v-for="(target, index) in item.data"
                    :key="index"
                    :class="{ 'target-small': target.size === 'small' }"
                  >
                    <div class="target-name">{{ target.name }}</div>
                    <div
                      class="target-value"
                      :class="{
                        'target-green':
                          !isNaN(target.value) && target.value < 0,
                        'target-red': !isNaN(target.value) && target.value > 0,
                      }"
                    >
                      {{ target.value }}
                      <el-icon
                        v-if="target.size === 'small' && !isNaN(target.value)"
                      >
                        <Top v-if="target.value > 0" />
                        <Bottom v-else />
                      </el-icon>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="info-title">投资回收完成情况</div>
            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['shiyunying'].tzhswcqk"
                :key="idx"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
            <div class="info-title">2025经营计划完成进度</div>
            <div class="data-info-large">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['shiyunying'].jyjhwcjd"
                :key="idx"
              >
                <div class="item-content">
                  <div
                    class="target-item"
                    v-for="(target, index) in item.data"
                    :key="index"
                  >
                    <div class="target-name">{{ target.name }}</div>
                    <div class="target-value">{{ target.value }}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="info-right-wrap lixiang">
            <div class="infos-title">转让</div>

            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['zhuanrang']"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="info-right-wrap lixiang">
            <div class="infos-title">退出</div>

            <div class="data-info">
              <div
                class="info-item"
                v-for="(item, idx) in infoObj['tuichu']"
                :key="idx"
                @click="handleDetail(item)"
              >
                <div class="item-title">{{ item.title }}</div>
                <div class="item-value">
                  {{ item.value }}
                  <span class="item-unit">{{ item.unit }}</span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div
          class="back-to-country-btn"
          @click="backToCountry"
          v-show="showBackBtn"
        >
          返回全国
        </div>
      </div>
    </div>
    <div class="bottom"></div>
    <!-- 详情信息 -->
    <el-dialog
      :title="dialogTitle + '详情'"
      v-model="dialogVisible"
      width="80%"
      :before-close="handleClose"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <div class="dialog-content">
        <div class="table-wrap">
          <el-table :data="tableData" style="width: 100%" empty-text="暂无数据">
            <el-table-column
              type="index"
              width="60"
              label="序号"
              :align="'center'"
            />
            <el-table-column
              prop="name"
              label="项目名称"
              :align="'center'"
              width="120"
            />
            <el-table-column
              prop="qy"
              label="项目区域"
              :align="'center'"
              width="100"
            />
            <el-table-column prop="jsgm" label="建设规模" :align="'center'">
              <el-table-column
                prop="zlc"
                label="总里程（KM)"
                :align="'center'"
              />
              <el-table-column prop="cds" label="车道数" :align="'center'" />
              <el-table-column prop="qsb" label="桥隧比" :align="'center'" />
            </el-table-column>
            <el-table-column
              prop="jsq"
              label="建设期（年）"
              :align="'center'"
            />
            <el-table-column
              prop="yyqnx"
              label="运营期年限（年）"
              :align="'center'"
              width="100"
            />
            <el-table-column
              prop="jcztz"
              label="决策总投资"
              :align="'center'"
              width="110"
            />
            <el-table-column
              prop="jczt"
              label="决策主体"
              :align="'center'"
              width="100"
            />
            <el-table-column
              prop="jcsj"
              label="决策时间"
              width="110"
              :align="'center'"
            />
            <el-table-column
              prop="sfPPP"
              label="是否是PPP项目"
              :align="'center'"
              width="100"
            />
            <el-table-column
              prop="xmmyms"
              label="项目名义模式"
              :align="'center'"
              width="110"
            />
            <el-table-column
              prop="sjms"
              label="实际模式"
              :align="'center'"
              width="150"
            />
            <el-table-column
              prop="gqjg"
              label="股权结构"
              :align="'center'"
              width="100"
            />
            <el-table-column
              prop="xmzt"
              label="项目状态"
              :align="'center'"
              width="100"
            />
            <el-table-column
              prop="tcsj"
              label="通车时间"
              width="110"
              :align="'center'"
            />
            <el-table-column
              prop="hbfs"
              label="回报方式"
              :align="'center'"
              width="150"
            />
            <el-table-column
              prop="irr"
              label="IRR"
              :align="'center'"
              width="100"
            />
          </el-table>
        </div>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="handleClose">确 定</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import Map from "@/components/CommonMap.vue";
import { reactive, ref, nextTick, watch, onMounted, onUnmounted } from "vue";
import * as echarts from "echarts";

const selectedContentBtn = ref("jianshe");
const showBackBtn = ref(false);
const selectedNavBtn = ref("equity"); // 默认选中股权投资

const props = defineProps({
  modelValue: {
    type: Boolean,
    default: "", // 默认值，避免空值报错
  },
  isFullscreen: {
    // 父组件传递的全屏状态
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits(["update:modelValue", "toggle-fullscreen"]);
const handleInput = (e) => {
  // e.target.value 是输入框的最新值
  emit("update:modelValue", e);
};

// 导航按钮点击事件
const handleNavBtnClick = (key) => {
  selectedNavBtn.value = key;
  // 可根据不同的导航按钮类型，扩展对应的业务逻辑
  switch (key) {
    case "equity":
      // 股权投资相关逻辑
      break;
    case "fixedRisk":
      // 固定风险投资相关逻辑
      break;
    case "realEstate":
      // 房地产投资相关逻辑
      break;
    case "financing":
      // 融资建设投资相关逻辑
      break;
    default:
      break;
  }
};

const navList = reactive([
  {
    index: 1,
    name: "立项",
    key: "lixiang",
  },
  {
    index: 2,
    name: "建设",
    key: "jianshe",
  },
  {
    index: 3,
    name: "试运营",
    key: "shiyunying",
  },
  {
    index: 4,
    name: "运营",
    key: "yunying",
  },
  // {
  //   index: 5,
  //   name: "转让",
  // },
  {
    index: 6,
    name: "退出",
    key: "tuichu",
  },
]);
const infoObj = reactive({
  lixiang: [
    {
      title: "总个数",
      value: "36",
      unit: "个",
      data: [
        {
          name: "/",
          qy: "/",
          zlc: "/",
          cds: "/",
          qsb: "/",
          jsq: "/",
          yyqnx: "/",
          jcztz: "/",
          jczt: "/",
          jcsj: "/",
          sfPPP: "/",
          xmmyms: "/",
          sjms: "/",
          gqjg: "/",
          xmzt: "/",
          tcsj: "/",
          hbfs: "/",
        },
      ],
    },
    { title: "总投资", value: "3107.22", unit: "亿元" },
    { title: "总规模", value: "0", unit: "公里" },
  ],
  zhuanrang: [
    {
      title: "总个数",
      value: "59",
      unit: "个",
      data: [
        {
          name: "/",
          qy: "/",
          zlc: "/",
          cds: "/",
          qsb: "/",
          jsq: "/",
          yyqnx: "/",
          jcztz: "/",
          jczt: "/",
          jcsj: "/",
          sfPPP: "/",
          xmmyms: "/",
          sjms: "/",
          gqjg: "/",
          xmzt: "/",
          tcsj: "/",
          hbfs: "/",
        },
      ],
    },
    { title: "总投资", value: "2733.35", unit: "亿元" },
    { title: "总规模", value: "5116.72", unit: "公里" },
    { title: "累计完成投资", value: "3116.44.72", unit: "公里" },
  ],
  tuichu: [
    {
      title: "总个数",
      value: "59",
      unit: "个",
      data: [
        {
          name: "/",
          qy: "/",
          zlc: "/",
          cds: "/",
          qsb: "/",
          jsq: "/",
          yyqnx: "/",
          jcztz: "/",
          jczt: "/",
          jcsj: "/",
          sfPPP: "/",
          xmmyms: "/",
          sjms: "/",
          gqjg: "/",
          xmzt: "/",
          tcsj: "/",
          hbfs: "/",
        },
      ],
    },
    { title: "总投资", value: "2733.35", unit: "亿元" },
    { title: "总规模", value: "5116.72", unit: "公里" },
    { title: "累计完成投资", value: "3116.44.72", unit: "公里" },
  ],

  jianshe: {
    gaikuang: [
      {
        title: "总个数",
        value: "10",
        unit: "个",
        data: [
          {
            name: "和襄高速",
            qy: "安徽",
            zlc: "170.6",
            cds: "4/6",
            qsb: "29.50%",
            jsq: "3",
            yyqnx: "29.5",
            jcztz: "247.54",
            jczt: "中国能建",
            jcsj: "2023/1/11",
            sfPPP: "是",
            xmmyms: "BOT+建设期投资补助",
            sjms: "BOT+车购税资金50.63亿元",
            gqjg: "控股",
            xmzt: "在建",
            tcsj: "预计2025/12/31",
            hbfs: "使用者付费",
          },
          {
            name: "肇明高速",
            qy: "广东",
            zlc: "98.43",
            cds: "6",
            qsb: "55.12%",
            jsq: "3",
            yyqnx: "25",
            jcztz: "214.94",
            jczt: "中国能建",
            jcsj: "2019/12/12",
            sfPPP: "否",
            xmmyms: "BOT+施工总承包+政府补助",
            sjms: "BOT+政府股权投资",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2029/6/30",
            hbfs: "使用者付费",
          },
          {
            name: "延安东高速",
            qy: "陕西",
            zlc: "57.16",
            cds: "4",
            qsb: "49.7%",
            jsq: "3",
            yyqnx: "30",
            jcztz: "85.94",
            jczt: "中国能建",
            jcsj: "2020/6/29",
            sfPPP: "是",
            xmmyms: "PPP",
            sjms: "BOT+90%工可车流量延期条件兜底",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2025/12/15",
            hbfs: "使用者付费（有合作期末延长收费期条款）",
          },
          {
            name: "关环高速",
            qy: "陕西",
            zlc: "73.74",
            cds: "4",
            qsb: "29.38%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "71.84",
            jczt: "中国能建",
            jcsj: "2020/8/4",
            sfPPP: "是",
            xmmyms: "PPP",
            sjms: "BOT+定补",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2028/9/30",
            hbfs: "使用者付费+政府固定补助",
          },
          {
            name: "横钦高速",
            qy: "广西",
            zlc: "166.024",
            cds: "4",
            qsb: "15.85%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "208.32",
            jczt: "中国能建",
            jcsj: "2021/12/30",
            sfPPP: "是",
            xmmyms: "BOT+施工总承包+可行性缺口补助",
            sjms: "BOT+运营期定补6.1亿/年+缺口延期条件兜底",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2026/9/30",
            hbfs: "使用者付费+可行性缺口补助（实际为固定补助+合作期末延长收费期条款）",
          },
          {
            name: "全灌高速",
            qy: "广西",
            zlc: "75.14",
            cds: "4",
            qsb: "26.1%",
            jsq: "3",
            yyqnx: "30",
            jcztz: "92.73",
            jczt: "中国能建",
            jcsj: "2021/12/30",
            sfPPP: "是",
            xmmyms: "BOT+施工总承包+可行性缺口补助",
            sjms: "BOT+运营期定补3.204亿/年+缺口延期条件兜底",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2026/6/30（泉南拼接2027年3月）",
            hbfs: "使用者付费+可行性缺口补助（实际为固定补助+合作期末延长收费期条款）",
          },
          {
            name: "济商高速（济宁）",
            qy: "山东",
            zlc: "45.076",
            cds: "6",
            qsb: "15.78%",
            jsq: "3",
            yyqnx: "25",
            jcztz: "69.48",
            jczt: "中国能建",
            jcsj: "2021/9/2",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2025/12/31",
            hbfs: "使用者付费",
          },
          {
            name: "济商高速（菏泽）",
            qy: "山东",
            zlc: "65.47",
            cds: "6",
            qsb: "12.43%",
            jsq: "3",
            yyqnx: "30",
            jcztz: "104.07",
            jczt: "中国能建",
            jcsj: "2021/9/28",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2025/12/31",
            hbfs: "使用者付费",
          },
          {
            name: "承克高速",
            qy: "河北",
            zlc: "105.58",
            cds: "4",
            qsb: "26.48%",
            jsq: "3",
            yyqnx: "25",
            jcztz: "130.25",
            jczt: "中国能建",
            jcsj: "2023/3/8",
            sfPPP: "是",
            xmmyms: "BOT+可行性缺口补助",
            sjms: "BOT+车购税+运营期定补9500万元",
            gqjg: "参股",
            xmzt: "在建",
            tcsj: "预计2027/9/10",
            hbfs: "使用者付费+政府固定补助",
          },
          {
            name: "S10高速",
            qy: "甘肃",
            zlc: "194.34",
            cds: "4",
            qsb: "6.8%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "108.94",
            jczt: "中国能建",
            jcsj: "2025/1/6",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "控股",
            xmzt: "筹建",
            tcsj: "预计2028/12/31",
            hbfs: "使用者付费",
          },
        ],
      },
      {
        title: "总投资",
        value: "1334.05",
        unit: "亿元",
      },
      {
        title: "总规模",
        value: "1051.56",
        unit: "公里",
      },
    ],
    tzwcqk: [
      // { title: "10月完成投资", value: "*" },
      { title: "2025年完成投资", value: "109.04", unit: "亿元" },
      { title: "累计完成投资", value: "531.39", unit: "亿元" },
    ],
    tzhswcqk: [
      // { title: "10月完成回收", value: "*" },
      { title: "2025年完成回收", value: "28.84", unit: "亿元" },
      { title: "完成率", value: "53.16", unit: "%" },
    ],
  },
  shiyunying: {
    gaikuang: [
      {
        title: "总个数",
        value: 9,
        unit: "个",
        data: [
          {
            name: "巴万高速",
            qy: "四川",
            zlc: "120.07",
            cds: "4",
            qsb: "64.57%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "188.2",
            jczt: "中国能建",
            jcsj: "2016/12/26",
            sfPPP: "是",
            xmmyms: "BOT+政府股权合作",
            sjms: "BOT+可行性缺口补助（费用兜底）",
            gqjg: "控股",
            xmzt: "已运营",
            tcsj: "2021/1/1",
            hbfs: "使用者付费+可行性缺口费用补助",
          },
          {
            name: "巨单高速",
            qy: "山东",
            zlc: "116.2",
            cds: "4",
            qsb: "5.36%",
            jsq: "3",
            yyqnx: "25",
            jcztz: "80.16",
            jczt: "中国能建",
            jcsj: "2016/12/26",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2020/1/1",
            hbfs: "使用者付费",
          },
          {
            name: "济泰高速",
            qy: "山东",
            zlc: "60.33",
            cds: "6",
            qsb: "49.43%",
            jsq: "3",
            yyqnx: "25",
            jcztz: "101.82",
            jczt: "中国能建",
            jcsj: "2016/12/26",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2020/10/27",
            hbfs: "使用者付费",
          },
          {
            name: "枣菏高速",
            qy: "山东",
            zlc: "187.32",
            cds: "4",
            qsb: "16.69%",
            jsq: "3.5",
            yyqnx: "25",
            jcztz: "144.79",
            jczt: "中国能建",
            jcsj: "2016/12/26",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2020/10/8",
            hbfs: "使用者付费",
          },
          {
            name: "延黄高速",
            qy: "陕西",
            zlc: "149.47",
            cds: "4",
            qsb: "54.92%",
            jsq: "3.25",
            yyqnx: "28",
            jcztz: "145.88",
            jczt: "中国能建",
            jcsj: "2018/7/25",
            sfPPP: "是",
            xmmyms: "BOT",
            sjms: "BOT+车购税资金50.23亿元",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2021/6/30",
            hbfs: "使用者付费",
          },
          {
            name: "宁石高速",
            qy: "陕西",
            zlc: "51.78",
            cds: "4",
            qsb: "54.92%",
            jsq: "3.72",
            yyqnx: "28",
            jcztz: "60.54",
            jczt: "中国能建",
            jcsj: "2018/7/25",
            sfPPP: "是",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2022/12/9",
            hbfs: "使用者付费",
          },
          {
            name: "田西高速",
            qy: "广西",
            zlc: "191.26",
            cds: "4",
            qsb: "53.62%",
            jsq: "3.75",
            yyqnx: "30",
            jcztz: "273.75",
            jczt: "中国能建",
            jcsj: "2018/12/13",
            sfPPP: "是",
            xmmyms: "“DBFOT（设计－建设－融资－运营－移交）”的PPP模式",
            sjms: "BOT+建设期补助29.54亿元（含政府资本金）+运营固定补助3.1045亿元/年+可行性缺口补助（费用兜底）",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2022/12/29",
            hbfs: "使用者付费+固定补助+可行性缺口补助",
          },
          {
            name: "武阳高速",
            qy: "湖北",
            zlc: "91.308",
            cds: "4/6",
            qsb: "40.41%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "113.51",
            jczt: "中国能建",
            jcsj: "2018/11/13",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2023/10/20",
            hbfs: "使用者付费",
          },
          {
            name: "麟法高速",
            qy: "陕西",
            zlc: "46.33",
            cds: "4",
            qsb: "29.38%",
            jsq: "4",
            yyqnx: "30",
            jcztz: "52.79",
            jczt: "中国能建",
            jcsj: "2020/8/4",
            sfPPP: "是",
            xmmyms: "PPP",
            sjms: "BOT+定补",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2025/7/21",
            hbfs: "使用者付费+固定补助",
          },
        ],
      },
      {
        title: "总投资",
        value: 1151.36,
        unit: "亿元",
      },
      {
        title: "总规模",
        value: 945.67,
        unit: "公里",
      },
    ],
    tzwcqk: [
      // { title: "11月完成投资", value: "*" },
      { title: "2025年完成投资", value: "*" },
      { title: "累计完成投资", value: "*" },
    ],
    jyjhwcqk: [
      {
        title: "营业收入",
        data: [
          // {
          //   name: "11月完成",
          //   value: 3.58,
          //   unit: "亿元"
          // },
          {
            name: "第三季度完成",
            value: 31.71,
            unit: "亿元",
          },
          {
            name: "2025累计完成",
            value: 38.86,
            unit: "亿元",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: 3.78,
            unit: "%",
          },
        ],
      },
      {
        title: "运营成本",
        data: [
          // {
          //   name: "11月发生",
          //   value: 1.96,
          //   unit: "亿元"
          // },
          {
            name: "第三季度发生",
            value: 16.99,
            unit: "亿元",
          },
          {
            name: "2025累计完成",
            value: 20.91,
            unit: "亿元",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: -14.73,
            unit: "%",
          },
        ],
      },
      {
        title: "利润总额",
        data: [
          // {
          //   name: "11月完成",
          //   value: -1.015,
          //   unit: "亿元"
          // },
          {
            name: "第三季度完成",
            value: -5.91,
            unit: "亿元",
          },
          {
            name: "2025累计完成",
            value: -7.94,
            unit: "亿元",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: -28.83,
            unit: "%",
          },
        ],
      },
    ],
    tzhswcqk: [
      // { title: "11月完成回收", value: 2.8682,
      //   unit: "亿元"
      // },
      { title: "2025年完成回收", value: 31.55, unit: "亿元" },
      { title: "完成率", value: 85, unit: "%" },
    ],
    jyjhwcjd: [
      {
        data: [
          {
            name: "营业收入完成进度",
            value: 85.81,
            unit: "%",
          },
          {
            name: "实际完成金额",
            value: 38.86,
            unit: "亿元",
          },
          {
            name: "计划完成金额",
            value: 45.27,
            unit: "亿元",
          },
        ],
      },
      {
        data: [
          {
            name: "运营成本完成进度",
            value: 79.6,
            unit: "%",
          },
          {
            name: "实际完成金额",
            value: 20.91,
            unit: "亿元",
          },
          {
            name: "计划完成金额",
            value: 26.27,
            unit: "亿元",
          },
        ],
      },
      {
        data: [
          {
            name: "利润总额完成进度",
            value: 77.59,
            unit: "%",
          },
          {
            name: "实际完成金额",
            value: -7.94,
            unit: "亿元",
          },
          {
            name: "计划完成金额",
            value: -10.23,
            unit: "亿元",
          },
        ],
      },
    ],
  },
  yunying: {
    gaikuang: [
      {
        title: "总个数",
        value: "2",
        unit: "个",
        data: [
          {
            name: "襄荆高速",
            qy: "湖北",
            zlc: "185.42",
            cds: "4",
            qsb: "1.8%",
            jsq: "5",
            yyqnx: "30",
            jcztz: "44.15",
            jczt: "葛洲坝集团",
            jcsj: "2000年",
            sfPPP: "否",
            xmmyms: "BOT",
            sjms: "BOT",
            gqjg: "控股",
            xmzt: "已运营",
            tcsj: "2004/6/26",
            hbfs: "使用者付费",
          },
          {
            name: "杨宣高速",
            qy: "云南",
            zlc: "47.8",
            cds: "4",
            qsb: "50%",
            jsq: "3",
            yyqnx: "30",
            jcztz: "70.08",
            jczt: "授权葛洲坝集团",
            jcsj: "2018/2/9",
            sfPPP: "否",
            xmmyms: "EPC+BOT+股权合作",
            sjms: "BOT+政府股权投资+建设期补助资金",
            gqjg: "参股",
            xmzt: "已运营",
            tcsj: "2021/10/8",
            hbfs: "使用者付费",
          },
        ],
      },
      {
        title: "总投资",
        value: "114.23",
        unit: "亿元",
      },
      {
        title: "总规模",
        value: "233.22",
        unit: "公里",
      },
    ],
    tzhswcqk: [
      // { title: "11月完成回收", value: 0.0318,
      //   unit: "亿元"
      // },
      { title: "2025年完成回收", value: 0.35, unit: "亿元" },
      { title: "完成率", value: 6, unit: "亿元" },
    ],
    jyjhwcqk: [
      {
        title: "营业收入",
        data: [
          // {
          //   name: "11月完成",
          //   value: "*"
          // },
          {
            name: "第三季度完成",
            value: "*",
          },
          {
            name: "2025累计完成",
            value: "*",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: "*",
          },
        ],
      },
      {
        title: "运营成本",
        data: [
          // {
          //   name: "11月完成",
          //   value: "*"
          // },
          {
            name: "第三季度完成",
            value: "*",
          },
          {
            name: "2025累计完成",
            value: "*",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: "*",
          },
        ],
      },
      {
        title: "利润总额",
        data: [
          // {
          //   name: "11月完成",
          //   value: "*"
          // },
          {
            name: "第三季度完成",
            value: "*",
          },
          {
            name: "2025累计完成",
            value: "*",
          },
          {
            name: "累计同期环比",
            size: "small",
            value: "*",
          },
        ],
      },
    ],
    jyjhwcjd: [
      {
        data: [
          {
            name: "营业收入完成进度",
            value: "*",
          },
          {
            name: "实际完成金额",
            value: "*",
          },
          {
            name: "计划完成金额",
            value: "*",
          },
        ],
      },
      {
        data: [
          {
            name: "运营成本完成进度",
            value: "*",
          },
          {
            name: "实际完成金额",
            value: "*",
          },
          {
            name: "计划完成金额",
            value: "*",
          },
        ],
      },
      {
        data: [
          {
            name: "利润总额完成进度",
            value: "*",
          },
          {
            name: "实际完成金额",
            value: "*",
          },
          {
            name: "计划完成金额",
            value: "*",
          },
        ],
      },
    ],
  },
  tuichu: [
    {
      title: "总个数",
      value: "3",
      unit: "个",
      data: [
        {
          name: "内鹤高速",
          qy: "河南",
          zlc: "31.43",
          cds: "4",
          qsb: "20.01%",
          jsq: "3",
          yyqnx: "40",
          jcztz: "40.48",
          jczt: "中国能建",
          jcsj: "",
          sfPPP: "否",
          xmmyms: "BOT",
          sjms: "BOT",
          gqjg: "",
          xmzt: "拟退出",
          tcsj: "",
          hbfs: "",
        },
        {
          name: "内林东段高速",
          qy: "河南",
          zlc: "33.65",
          cds: "4",
          qsb: "18.40%",
          jsq: "3",
          yyqnx: "40",
          jcztz: "43.67",
          jczt: "中国能建",
          jcsj: "",
          sfPPP: "否",
          xmmyms: "BOT",
          sjms: "BOT",
          gqjg: "",
          xmzt: "拟退出",
          tcsj: "",
          hbfs: "",
        },
        {
          name: "内林西段高速",
          qy: "河南",
          zlc: "43.27",
          cds: "4",
          qsb: "30.31%",
          jsq: "3",
          yyqnx: "40",
          jcztz: "57.14",
          jczt: "中国能建",
          jcsj: "",
          sfPPP: "否",
          xmmyms: "BOT",
          sjms: "BOT",
          gqjg: "",
          xmzt: "拟退出",
          tcsj: "",
          hbfs: "",
        },
      ],
    },
    { title: "总投资", value: "141.29", unit: "亿元" },
    { title: "总规模", value: "108.35", unit: "公里" },
    { title: "累计完成投资", value: "0", unit: "亿元" },
  ],
});

// 添加防抖功能，避免频繁切换造成的性能问题
let debounceTimer = null;
const selectContentBtn = (item) => {
  if (debounceTimer) {
    clearTimeout(debounceTimer);
  }
  debounceTimer = setTimeout(() => {
    selectedContentBtn.value = item.key;
    if (item.key === "jianshe") {
      nextTick(() => {
        initProgressPie();
      });
    } else {
      progressPieChart.dispose();
    }
  }, 100);
};
// 绘制投资完成情况环形图
const progressPie = ref(null);
let progressPieChart = null;
const initProgressPie = () => {
  progressPieChart?.dispose();
  progressPieChart = echarts.init(progressPie.value);
  const option = {
    // 中心百分比文字
    title: {
      text: ["{a|89}", "{b|%}"].join(" "),
      left: "center",
      top: "center",
      textStyle: {
        color: "#2FD2FB", // 蓝色文字（匹配截图）
        lineHeight: 1.2,
        fontFamily: "DINBold",
        fontWeight: "bold",
        rich: {
          a: {
            fontSize: 22,
          },
          b: {
            fontSize: 12,
          },
        },
      },
    },
    series: [
      // 1. 外层圆环边框（浅色蓝环）
      {
        type: "pie",
        animationDuration: 2000,
        radius: ["85%", "70%"], // 外层边框的粗细
        startAngle: 0,
        itemStyle: {
          borderColor: "#8692fc",
          borderWidth: 1,
        },
        label: { show: false },
        labelLine: { show: false },
        data: [
          {
            value: 89,
            name: "绿色扇区",
            itemStyle: { color: "#00FF00", fontSize: 12 },
          }, // 绿色扇区
          {
            value: 11,
            name: "背景扇区",
            itemStyle: { color: "transparent" },
          },
        ],
      },
    ],
  };
  progressPieChart.setOption(option);
};
const resizeEcharts = () => {
  progressPieChart?.resize();
};

// 全屏切换功能
const toggleFullscreen = () => {
  emit("toggle-fullscreen"); // 触发父组件的全屏切换方法
};

onMounted(() => {
  initProgressPie();
  window.addEventListener("echarts-resize", resizeEcharts); // 监听父组件的resize事件
});
onUnmounted(() => {
  window.removeEventListener("echarts-resize", resizeEcharts);
});

// // 监听全屏变化事件
// window.addEventListener("fullscreenchange", () => {
//   const homeContainer = document.querySelector(".home-container");

//   if (!document.fullscreenElement) {
//     isFullscreen.value = false;
//     if (homeContainer) {
//       homeContainer.style.height = "100%";
//       // 移除全屏类
//       homeContainer.classList.remove("fullscreen");
//     }
//   } else {
//     isFullscreen.value = true;
//     if (homeContainer) {
//       homeContainer.style.height = "100vh";
//       // 添加全屏类
//       homeContainer.classList.add("fullscreen");
//     }
//   }
// });

// 表格弹框
let tableData = ref([]);
const handleDetail = (item) => {
  if (item.data?.length) {
    tableData.value = item.data;
    dialogVisible.value = true;
  }
};
const dialogTitle = ref("");
const dialogVisible = ref(false);
const handleClose = () => {
  dialogVisible.value = false;
};
</script>

<style scoped lang="less">
.home-container {
  background-image: url("@/assets/images/bg.png");
  background-size: 100% 100%;
  width: 100%;
  height: 100%;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;

  .header {
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: space-between; // 改为space-between，布局更均衡
    align-items: center;
    position: relative;
    padding: 0 20px; // 增加左右内边距，避免内容贴边

    // 左侧导航按钮容器
    .header-left {
      display: flex;
      gap: 10px; // 用gap替代margin-right，布局更可控

      .nav-btn {
        margin-right: -32px;
        width: 194px;
        height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: YouSheBiaoTiYuan;
        font-size: 20px;
        cursor: pointer;
        background-image: url("@/assets/images/leftDefault.png"); // 默认背景图
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100% 100%;
        transition: all 0.2s ease; // 增加过渡动画

        // 激活态样式
        &.active {
          font-size: 22px;
          background-image: url("@/assets/images/activeLeft.png"); // 激活背景图
          background-repeat: no-repeat;
          background-position: center;
          background-size: 100% 100%;
        }
      }
    }

    // 中间标题容器（修正拼写错误：middile -> middle）
    .header-middle {
      flex: 1; // 占满剩余空间，让标题居中
      text-align: center; // 文字居中
      background-image: url("@/assets/images/header.png");
      background-size: 100% 100%;
      height: 75px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0 20px; // 增加左右间距

      span {
        background: linear-gradient(to bottom, #fff, #b4cff2);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        font-weight: 400;
        font-family: "YouSheBiaoTiHei";
        font-size: 28px;

        // 响应式适配
        @media screen and (max-width: 1920px) {
          font-size: 24px;
        }
        @media screen and (max-width: 1440px) {
          font-size: 20px;
        }
      }
    }

    // 右侧导航按钮容器
    .header-right {
      display: flex;
      gap: 10px; // 用gap替代margin-left，布局更可控

      .nav-btn {
        margin-left: -32px;
        width: 194px;
        height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: YouSheBiaoTiYuan;
        font-size: 20px;
        cursor: pointer;
        background-image: url("@/assets/images/rightDetault.png"); // 默认背景图
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100% 100%;
        transition: all 0.2s ease; // 增加过渡动画

        // 激活态样式
        &.active {
          font-size: 22px;
          background-image: url("@/assets/images/activeRight.png"); // 激活背景图
          background-repeat: no-repeat;
          background-position: center;
          background-size: 100% 100%;
        }
      }
    }

    .header-fullscreen {
      display: flex;
      position: absolute;
      right: 4%;
      top: 110%;
      transform: translateY(-50%);
      cursor: pointer;
      z-index: 9999;

      .fullscreen-text {
        margin-right: 16px;
        color: white;
        font-weight: 700;
        font-size: 14px;
        display: flex;
        align-items: center;
        gap: 6px;
      }
    }
  }

  .nav-list {
    display: flex;
    justify-content: center;
    align-items: center;
    .vw(margin-top, 10);
    span {
      .font(14);
      width: 110px;
      height: 35px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      color: rgba(255, 255, 255, 0.5);
      background-image: url("@/assets/images/default-btn.png");
      background-repeat: no-repeat;
      background-size: 80% 80%;
      background-position: center;
      margin-left: -32px;
      &.active {
        color: #fff;
        background-image: url("@/assets/images/nav-hight-btn.png");
      }
      &:nth-child(1) {
        margin-left: 0;
        &.active {
          background-image: url("@/assets/images/立项.png");
        }
        &:not(.active) {
          background-image: url("@/assets/images/initiation-default.png");
        }
      }
      &:nth-child(6) {
        margin-left: -31px;
        background-image: url("@/assets/images/退出.png");
        &.active {
          background-image: url("@/assets/images/退出-active.png");
        }
      }
    }
  }
  .map-container {
    flex: 1;
    height: 0;
    display: flex;
    .vh(margin-bottom, -20);
    .map-content {
      ::v-deep #container {
        .vw(width,1300)
        // width: 1400px;
      }
      // overflow: scroll;
      display: flex;
      position: relative;
      flex: 1;
      height: 100%;
      .info-top-wrap {
        position: absolute;
        width: 100%;
        top: 0;
        z-index: 777;
        .vh(margin-top, 10);
      }
      .info-right-wraps {
        .infos-title {
          background-image: url("@/assets/images/titleBgc.png");
          background-size: 100% 100%;
          background-repeat: no-repeat;
          height: 36px;
          width: 102px;
          text-align: center;
          line-height: 36px;

          font-weight: 600;
          font-size: 18px;
          text-align: center;
          vertical-align: middle;
          margin-bottom: 30px;
        }
        display: flex;
        position: absolute;
        left: 42vw;
        top: 50px;
        .info-right-wrap {
          .vw(right, 44);
          .vw(width, 580);
          display: flex;
          margin-right: 50px;
          flex-direction: column;
          z-index: 777;
          .info-title {
            .vw(width, 180);
            .vh(height, 32);
            .vh(line-height,32);
            .font(16);
            .vw(padding-left,20);
            .vh(margin-bottom,14);
            text-align: left;
            color: #fff;
            white-space: nowrap;
            font-family: YouSheBiaoTiYuan;
            background-image: url("@/assets/images/tag.png");
            background-size: 100% 100%;
          }
          .data-info {
            justify-content: flex-start;
          }
        }
      }

      .data-info {
        display: flex;
        align-items: center;
        justify-content: center;
        .vh(margin-bottom,15);
        .info-item {
          .vw(width, 180);
          // .vh(height, 90);
          .vw(border-radius, 5);
          .vw(padding, 10);
          .vw(margin-right,20);
          background-image: url("@/assets/images/total2.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          cursor: pointer;
          .item-title {
            .font(12);
            // white-space: nowrap;
          }
          .item-value {
            .font(20);
            color: @Color;
            font-family: "DIN";
            .item-unit {
              .font(10);
            }
          }
        }
        :last-child {
          margin-right: 0;
          margin-bottom: 0;
        }
      }
      .info-progress {
        display: flex;
        align-items: center;
        .progress-pie {
          .vw(width, 120);
          .vw(height, 120);
        }
        .progress-bar {
          flex: 1;
          width: 0;
          position: relative;
          .progress-text {
            position: absolute;
            top: -5px;
            right: 0;
            .font(20);
            font-family: DIN;
          }
          .progress-image {
            width: 100%;
            .vh(height, 98);
            background-image: url("@/assets/images/progressBar.png");
            background-size: 100% 100%;
            .progress-show-value {
              position: absolute;
              top: 35%;
              left: 15%;
              width: 85%;
              height: 30%;
              background-image: url("@/assets/images/baseRate.png");
              background-size: 100% 100%;
            }
            .progress-show-value-rel {
              position: absolute;
              top: 36%;
              left: 15%;
              height: 30%;
              background-image: url(/src/assets/images/progress.png);
              background-size: auto 100%;
              -webkit-transform: skew(-30deg);
              transform: skew(-30deg);
            }
          }
        }
      }
      .data-info-large {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .vh(margin-bottom,15);
        .info-item {
          .vw(width, 180);
          .vw(border-radius, 5);
          .vw(margin-right,10);
          .vw(padding-left, 10);
          .vw(padding-right, 10);
          .vw(padding-top, 5);
          .vw(padding-bottom, 5);
          background-image: url("@/assets/images/complete.png");
          background-size: 100% 100%;
          display: flex;
          flex-direction: column;
          .item-title {
            .vh(height, 22);
            display: flex;
            justify-content: center;
            align-items: center;
            background-image: url("@/assets/images/completeTitle.png");
            background-size: 100% 100%;
            .font(12);
            display: flex;
            justify-content: center;
            align-items: center;
          }
          .item-content {
            display: flex;
            flex-wrap: wrap;
            align-items: flex-end;
            justify-content: space-between;
            .vh(padding-top, 10);
            .target-item {
              min-width: 49%;
              .target-name {
                .font(10);
                color: #fff;
              }
              .target-value {
                .font(20);
                color: #96f6ff;
                font-family: DINBold;
              }
              &.target-small {
                width: 40%;
                min-width: 40%;
                .target-name {
                  .font(8);
                  color: rgba(255, 255, 255, 0.7);
                }
                .target-value {
                  .font(14);
                  display: flex;
                  align-items: center;
                  &.target-green {
                    color: #32d25a;
                  }
                  &.target-red {
                    color: #d2216e;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  // .bottom {
  //   width: 100%;
  //   .vh(height, 110);
  // }
  .dialog-content {
    display: flex;
    flex-direction: column;
    .table-wrap {
      .el-table {
        height: 100%;
        thead {
          color: #000;
          th {
            background: #f5f7fa;
            .cell {
              text-align: center;
            }
          }
        }
      }
    }
    .page-wrap {
      margin-top: 10px;
      display: flex;
      justify-content: flex-end;
    }
  }
}
.home-container {
  .el-dialog {
    height: 75%;
    display: flex;
    flex-direction: column;
    .el-dialog__body {
      flex: 1;
      height: 0;
    }
  }
  .dialog-content {
    height: 100%;
    .table-wrap {
      max-height: 100%;
      .el-table {
        height: 100%;
        thead {
          color: #000;
          th {
            background: #f5f7fa;
            .cell {
              text-align: center;
            }
          }
        }
      }
    }
  }
}

.lixiang {
  margin-right: 0 !important;
  .vw(width, 222) !important;
  .data-info {
    display: block !important;
    .info-item {
      margin-bottom: 28px;
      margin-right: 0;
    }
  }
}
</style>
