<template>
  <div class="wrap">
    <div class="left">
      <div class="box1">
        <div class="box-header">
          <div class="header-left"></div>
          <div class="title">耗时分析</div>
          <div
            class="header-switch-box"
            :class="{ headerSwitchBox1: isShowChartData === 'data' }"
          >
            <div
              class="header-switch-box-left"
              @click="handleSwitch('chart')"
            ></div>
            <div
              class="header-switch-box-right"
              @click="handleSwitch('data')"
            ></div>
          </div>
          <div class="header-btn-box">
            <div class="btn" @click="handleClickBox1Btn(1)">
              <el-button type="primary" plain v-if="box1BtnAvtiveIndex === 1"
                >典型阶段耗时</el-button
              >
              <el-button type="info" plain v-else>典型阶段耗时</el-button>
            </div>
            <div class="btn" @click="handleClickBox1Btn(2)">
              <el-button type="primary" plain v-if="box1BtnAvtiveIndex === 2"
                >辩论投票时长</el-button
              >
              <el-button type="info" plain v-else>辩论投票时长</el-button>
            </div>
          </div>
          <div class="header-right">
            <img src="../assets/images/header-icon.png" alt="" />
          </div>
        </div>
        <div class="box1-main">
          <div
            class="box1-main-center"
            id="chart1"
            v-show="isShowChartData === 'chart'"
          ></div>
          <div class="box1-main-center" v-show="isShowChartData === 'data'">
            <div class="box1-main-table">
              <div class="table-name">
                <div class="name-item">{{ "" }}</div>
                <div class="name-item">{{ dataList[0].data1.name }}</div>
                <div class="name-item">{{ dataList[0].data2.name }}</div>
                <div class="name-item">{{ dataList[0].data3.name }}</div>
                <div class="name-item">{{ dataList[0].data4.name }}</div>
              </div>
              <div
                class="table-item"
                v-for="(item, index) in dataList"
                :key="index"
              >
                <div class="item">{{ item.name }}</div>
                <div class="item">{{ item.data1.value }}</div>
                <div class="item">{{ item.data2.value }}</div>
                <div class="item">{{ item.data3.value }}</div>
                <div class="item">{{ item.data4.value }}</div>
              </div>
            </div>
          </div>
          <div class="box1-main-footer">
            <div class="box-footer-left">
              <img src="../assets/icons/right-icon1.png" alt="" />
            </div>
            <div class="box-footer-center">
              从立法耗时角度分析，大而美法案从提交到签署仅39天，远快于历史同类法案（通常需6个月以上），立法速度极快。
            </div>
            <div class="box-footer-right">
              <img src="../assets/icons/arrow-right.png" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="box2">
        <div class="box-header">
          <div class="header-left"></div>
          <div class="title">政治献金</div>
          <div class="header-btn-box">
            <div class="btn" @click="handleClickBox2Btn(1)">
              <el-button type="primary" plain v-if="box2BtnActiveIndex === 1"
                >参议院</el-button
              >
              <el-button type="info" plain v-else>参议院</el-button>
            </div>
            <div class="btn" @click="handleClickBox2Btn(2)">
              <el-button type="primary" plain v-if="box2BtnActiveIndex === 2"
                >众议院</el-button
              >
              <el-button type="info" plain v-else>众议院</el-button>
            </div>
            <!-- <div class="btn" @click="handleClickBox2Btn(3)">
              <el-button type="primary" plain v-if="box2BtnActiveIndex === 3"
                >保险金融</el-button
              >
              <el-button type="info" plain v-else>保险金融</el-button>
            </div>
            <div class="btn" @click="handleClickBox2Btn(4)">
              <el-button type="primary" plain v-if="box2BtnActiveIndex === 4"
                >制造业</el-button
              >
              <el-button type="info" plain v-else>制造业</el-button>
            </div>
            <div class="btn" @click="handleClickBox2Btn(5)">
              <el-button type="primary" plain v-if="box2BtnActiveIndex === 5"
                >快递物流</el-button
              >
              <el-button type="info" plain v-else>快递物流</el-button>
            </div> -->
          </div>
          <div class="header-right">
            <img src="../assets/images/header-icon.png" alt="" />
          </div>
        </div>
        <div class="box2-main">
          <div class="box2-main-center">
            <div class="box2-main-center-left">
              <div
                class="left-item"
                v-for="(item, index) in box2DataList"
                :key="index"
              >
                <div class="left-item-left">
                  <img :src="item.img" alt="" />
                </div>
                <div class="left-item-center">
                  <div class="left-item-center-top">
                    <div class="name">{{ item.name }}</div>
                    <div class="icon1">
                      <img :src="item.icon1" alt="" />
                    </div>
                    <div class="icon2">
                      <img :src="item.icon2" alt="" />
                    </div>
                  </div>
                  <div class="left-item-center-bottom">
                    {{ item.position }}
                  </div>
                </div>
                <div class="left-item-right">
                  <div class="left-item-right-top">{{ item.money }}</div>
                  <div class="left-item-right-bottom">{{ item.content }}</div>
                </div>
              </div>
            </div>
            <div class="box2-main-center-right">
              <div id="chart2"></div>
              <div class="info-box">
                <div class="item">
                  <div class="item-top">
                    <div class="icon">
                      <img v-if="chart2Data[0].name === '共和党'" src="./assets/images/icon-b.png" alt="" />
                      <img v-else src="./assets/images/icon-a.png" alt="" />

                    </div>
                    <div class="name">{{ chart2Data[0].name }}</div>
                  </div>
                  <div class="item-footer">
                    {{ "$" + chart2Data[0].value * 10000 }}
                  </div>
                </div>
                <div class="item" v-if="chart2Data.length > 1">
                  <div class="item-top">
                    <div class="icon">
                      <img v-if="chart2Data[1].name === '共和党'" src="./assets/images/icon-b.png" alt="" />
                      <img v-else src="./assets/images/icon-a.png" alt="" />
                    </div>
                    <div class="name">{{ chart2Data[1].name }}</div>
                  </div>
                  <div class="item-footer1">
                    {{ "$" + chart2Data[1].value * 10000 }}
                  </div>
                </div>
              </div>
            </div>

            <!-- <div class="box2-main-center-content">
              <div
                class="box2-item"
                v-for="(item, index) in companyList"
                :key="index"
              >
                <div class="box2-item-left">
                  <img :src="item.icon" alt="" />
                </div>
                <div class="box2-item-center">
                  <div class="box2-item-center-top">{{ item.name }}</div>
                  <div class="box2-item-center-bottom">{{ item.info }}</div>
                </div>
                <div class="box2-item-right">
                  <div class="box2-item-right-top">{{ item.money }}</div>
                  <div class="box2-item-right-bottom">{{ item.content }}</div>
                </div>
              </div>
            </div>
            <div class="box2-main-center-footer">
              <el-pagination
                background
                layout="prev, pager, next"
                :total="26"
              />
            </div> -->
          </div>
          <div class="box2-main-footer">
            <div class="box-footer-left">
              <img src="../assets/icons/right-icon1.png" alt="" />
            </div>
            <div class="box-footer-center">
              法案本质是共和党与资本集团的深度联盟，共和党获超
              ​80%利益集团献金，以减税、松监管、军工扩张为核心回报。
            </div>
            <div class="box-footer-right">
              <img src="../assets/icons/arrow-right.png" alt="" />
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="box3">
        <div class="box-header">
          <div class="header-left"></div>
          <div class="title">投票分析</div>
          <div class="header-right">
            <img src="../assets/images/header-icon.png" alt="" />
          </div>
        </div>
        <div class="box3-main">
          <div class="box3-main-center">
            <div class="box3-main-center-header">
              <div class="box1">立法阶段</div>
              <div class="box2">票数</div>
              <div class="box3">平均区间</div>
              <div class="box4">占比</div>
              <div class="box5">
                倒戈人数<span style="font-weight: normal; display: inline-block"
                  >(平均区间)</span
                >
              </div>
              <div class="box6">关键议员</div>
            </div>
            <div class="box3-main-center-content">
              <div class="box3-main-center-content-box">
                <div
                  class="item"
                  v-for="(item, index) in voteAnalysisList1"
                  :key="index"
                >
                  <div class="box1">
                    <div class="box1-left">
                      <div class="icon" v-if="item.nameIcon">
                        <img :src="item.nameIcon" alt="" />
                      </div>
                      <div style="height: 80px">
                        <div class="name" :class="{ nameBlod: item.nameBold }">
                          {{ item.name }}
                        </div>
                        <div class="time">
                          {{ item.time }}
                        </div>
                      </div>
                    </div>
                    <div class="box1-right">
                      <div class="box1-right-top">
                        <el-progress
                          :percentage="item.supportRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                      <div class="box1-right-bottom">
                        <el-progress
                          :percentage="item.againistRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                    </div>
                  </div>
                  <div class="box2">
                    <div class="box2-1">{{ item.support + "票" }}</div>
                    <div class="box2-2">{{ item.againist + "票" }}</div>
                  </div>
                  <div class="box3">
                    <div class="box3-1">{{ item.supportRank }}</div>
                    <div class="box3-2">{{ item.againistRank }}</div>
                  </div>
                  <div class="box4">
                    <div class="box4-1">{{ item.supportRate + "%" }}</div>
                    <div class="box4-2">{{ item.againistRate + "%" }}</div>
                  </div>
                  <div class="box5">
                    <div class="box5-1">{{ item.people }}</div>
                    <div class="box5-2">{{ item.peopleRank }}</div>
                  </div>
                  <div class="box6">
                    <div class="img-box" v-if="item.keyUser">
                      <img :src="item.keyUser" alt="" />
                    </div>
                    <div v-else>
                      <el-icon size="20" color="#555"
                        ><ArrowDownBold
                      /></el-icon>
                    </div>
                  </div>
                </div>
              </div>
              <div class="box3-main-center-content-box">
                <div
                  class="item"
                  v-for="(item, index) in voteAnalysisList2"
                  :key="index"
                >
                  <div class="box1">
                    <div class="box1-left">
                      <div class="icon" v-if="item.nameIcon">
                        <img :src="item.nameIcon" alt="" />
                      </div>
                      <div>
                        <div class="name" :class="{ nameBlod: item.nameBold }">
                          {{ item.name }}
                        </div>
                        <div class="time">
                          {{ item.time }}
                        </div>
                      </div>
                    </div>
                    <div class="box1-right">
                      <div class="box1-right-top">
                        <el-progress
                          :percentage="item.supportRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                      <div class="box1-right-bottom">
                        <el-progress
                          :percentage="item.againistRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                    </div>
                  </div>
                  <div class="box2">
                    <div class="box2-1">{{ item.support + "票" }}</div>
                    <div class="box2-2">{{ item.againist + "票" }}</div>
                  </div>
                  <div class="box3">
                    <div class="box3-1">{{ item.supportRank }}</div>
                    <div class="box3-2">{{ item.againistRank }}</div>
                  </div>
                  <div class="box4">
                    <div class="box4-1">{{ item.supportRate + "%" }}</div>
                    <div class="box4-2">{{ item.againistRate + "%" }}</div>
                  </div>
                  <div class="box5">
                    <div class="box5-1">{{ item.people }}</div>
                    <div class="box5-2">{{ item.peopleRank }}</div>
                  </div>
                  <div class="box6">
                    <div class="img-box" v-if="item.keyUser">
                      <img :src="item.keyUser" alt="" />
                    </div>
                    <div v-else>
                      <el-icon size="20" color="#555"
                        ><ArrowDownBold
                      /></el-icon>
                    </div>
                  </div>
                </div>
              </div>
              <div class="box3-main-center-content-box">
                <div
                  class="item"
                  v-for="(item, index) in voteAnalysisList3"
                  :key="index"
                >
                  <div class="box1">
                    <div class="box1-left">
                      <div class="icon" v-if="item.nameIcon">
                        <img :src="item.nameIcon" alt="" />
                      </div>
                      <div>
                        <div class="name" :class="{ nameBlod: item.nameBold }">
                          {{ item.name }}
                        </div>
                        <div class="time">
                          {{ item.time }}
                        </div>
                      </div>
                    </div>
                    <div class="box1-right">
                      <div class="box1-right-top">
                        <el-progress
                          :percentage="item.supportRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                      <div class="box1-right-bottom">
                        <el-progress
                          :percentage="item.againistRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                    </div>
                  </div>
                  <div class="box2">
                    <div class="box2-1">{{ item.support + "票" }}</div>
                    <div class="box2-2">{{ item.againist + "票" }}</div>
                  </div>
                  <div class="box3">
                    <div class="box3-1">{{ item.supportRank }}</div>
                    <div class="box3-2">{{ item.againistRank }}</div>
                  </div>
                  <div class="box4">
                    <div class="box4-1">{{ item.supportRate + "%" }}</div>
                    <div class="box4-2">{{ item.againistRate + "%" }}</div>
                  </div>
                  <div class="box5">
                    <div class="box5-1">{{ item.people }}</div>
                    <div class="box5-2">{{ item.peopleRank }}</div>
                  </div>
                  <div class="box6">
                    <div class="img-box" v-if="item.keyUser">
                      <img :src="item.keyUser" alt="" />
                    </div>
                    <div v-else>
                      <el-icon size="20" color="#555"
                        ><ArrowDownBold
                      /></el-icon>
                    </div>
                  </div>
                </div>
              </div>
              <div class="box3-main-center-content-box">
                <div
                  class="item"
                  v-for="(item, index) in voteAnalysisList4"
                  :key="index"
                >
                  <div class="box1">
                    <div class="box1-left">
                      <div class="icon" v-if="item.nameIcon">
                        <img :src="item.nameIcon" alt="" />
                      </div>
                      <div>
                        <div class="name" :class="{ nameBlod: item.nameBold }">
                          {{ item.name }}
                        </div>
                        <div class="time">
                          {{ item.time }}
                        </div>
                      </div>
                    </div>
                    <div class="box1-right">
                      <div class="box1-right-top">
                        <el-progress
                          :percentage="item.supportRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                      <div class="box1-right-bottom">
                        <el-progress
                          :percentage="item.againistRate"
                          :show-text="false"
                        >
                        </el-progress>
                      </div>
                    </div>
                  </div>
                  <div class="box2">
                    <div class="box2-1">{{ item.support + "票" }}</div>
                    <div class="box2-2">{{ item.againist + "票" }}</div>
                  </div>
                  <div class="box3">
                    <div class="box3-1">{{ item.supportRank }}</div>
                    <div class="box3-2">{{ item.againistRank }}</div>
                  </div>
                  <div class="box4">
                    <div class="box4-1">{{ item.supportRate + "%" }}</div>
                    <div class="box4-2">{{ item.againistRate + "%" }}</div>
                  </div>
                  <div class="box5">
                    <div class="box5-1">{{ item.people }}</div>
                    <div class="box5-2">{{ item.peopleRank }}</div>
                  </div>
                  <div class="box6">
                    <div class="img-box" v-if="item.keyUser">
                      <img :src="item.keyUser" alt="" />
                    </div>
                    <div v-else>
                      <el-icon size="20" color="#555"
                        ><ArrowDownBold
                      /></el-icon>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="box3-main-footer">
            <div class="box-footer-left">
              <img src="../assets/icons/right-icon1.png" alt="" />
            </div>
            <div class="box-footer-center">
              法案以218:214​（众议院）和51:50​（副总统决胜票）微弱优势强行通过，暴露两党极端对立、党内倒戈频发的特点。
            </div>
            <div class="box-footer-right">
              <img src="../assets/icons/arrow-right.png" alt="" />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import {
  getBillTimeAnalyze,
  getBillXj,
  getBillTotalXj,
  getBillTp,
} from "@/api/deepdig";
import getBoxPlotChcart from "./utils/boxplot";
import * as echarts from "echarts";

import icon1 from "./assets/images/icon1.png";
import icon2 from "./assets/images/icon2.png";
import icon3 from "./assets/images/icon3.png";
import icon4 from "./assets/images/icon4.png";
import icon5 from "./assets/images/icon5.png";
import icon6 from "./assets/images/icon6.png";
import icon7 from "./assets/images/icon7.png";
import icon8 from "./assets/images/icon8.png";
import keyUser from "./assets/images/keyUser.png";
import iconA from "./assets/images/icon-a.png";
import iconB from "./assets/images/icon-b.png";

import user1 from "./assets/images/user1.png";
import user2 from "./assets/images/user2.png";
import user3 from "./assets/images/user3.png";
import user4 from "./assets/images/user4.png";
import user5 from "./assets/images/user5.png";
import userIcon1 from "./assets/images/user-icon1.png";
import userIcon2 from "./assets/images/user-icon2.png";

import getPieChart from "./utils/pieChart";

import CYY from '@/assets/icons/cyy.png'
import ZYY from '@/assets/icons/zyy.png'
import MZD from '@/assets/icons/mzd.png'
import GHD from '@/assets/icons/ghd.png'

const box1BtnAvtiveIndex = ref(1);
const handleClickBox1Btn = (index) => {
  if (box1BtnAvtiveIndex.value === index) return;
  box1BtnAvtiveIndex.value = index;
  let data;
  if (index === 1) {
    data = chartData1.value;
  } else {
    data = chartData2.value;
  }
  let chart1 = getBoxPlotChcart(data);
  setChart(chart1, "chart1");
};

const box2BtnActiveIndex = ref(1);
const handleClickBox2Btn = (index) => {
  box2BtnActiveIndex.value = index;
  if (index === 1) {
    handleGetXj("参议院");
    handleGetTotalXj("参议院");
  } else {
    handleGetXj("众议院");
    handleGetTotalXj("众议院");
  }
};

const isShowChartData = ref("chart");

const handleSwitch = (data) => {
  isShowChartData.value = data;
};

const dataList = ref([
  {
    name: "众议院通过",
    data1: {
      name: "中位数",
      value: "70天",
    },
    data2: {
      name: "平均耗时",
      value: "42-85天",
    },
    data3: {
      name: "最短耗时",
      value: "25天",
    },
    data4: {
      name: "本次耗时",
      value: "11天",
    },
  },
  {
    name: "参议院通过",
    data1: {
      name: "中位数",
      value: "63天",
    },
    data2: {
      name: "平均耗时",
      value: "36-110天",
    },
    data3: {
      name: "最短耗时",
      value: "31天",
    },
    data4: {
      name: "本次耗时",
      value: "12天",
    },
  },
  {
    name: "两院协商",
    data1: {
      name: "中位数",
      value: "52天",
    },
    data2: {
      name: "平均耗时",
      value: "28-63天",
    },
    data3: {
      name: "最短耗时",
      value: "27天",
    },
    data4: {
      name: "本次耗时",
      value: "16天",
    },
  },
  {
    name: "总统签署",
    data1: {
      name: "中位数",
      value: "27天",
    },
    data2: {
      name: "平均耗时",
      value: "32-36天",
    },
    data3: {
      name: "最短耗时",
      value: "19天",
    },
    data4: {
      name: "本次耗时",
      value: "1天",
    },
  },
]);

const box2DataList = ref([
  {
    img: user1,
    name: "乔迪·阿灵顿​",
    icon1: userIcon1,
    icon2: userIcon2,
    position: "众议院预算委员会主席",
    money: "$1,550,000",
    content: "8项游说记录",
  },
  {
    img: user2,
    name: "史蒂夫·戴恩斯",
    icon1: userIcon1,
    icon2: userIcon2,
    position: "众议院预算委员会主席",
    money: "$820,000",
    content: "4项游说记录",
  },
  {
    img: user3,
    name: "伯尼·莫雷诺",
    icon1: userIcon1,
    icon2: userIcon2,
    position: "众议院预算委员会主席",
    money: "$50,000",
    content: "5项游说记录",
  },
  {
    img: user4,
    name: "戴夫·麦考密克",
    icon1: userIcon1,
    icon2: userIcon2,
    position: "众议院预算委员会主席",
    money: "$50,000",
    content: "3项游说记录",
  },
  {
    img: user5,
    name: "蒂姆·希伊",
    icon1: userIcon1,
    icon2: userIcon2,
    position: "众议院预算委员会主席",
    money: "$35,000",
    content: "2项游说记录",
  },
]);

const companyList = ref([
  {
    name: "蓝十字/蓝盾协会",
    info: "美国私人医疗保险公司",
    icon: icon1,
    money: "$18,550,000",
    content: "29项游说报告",
  },
  {
    name: "美国医院协会",
    info: "美国最大的医院行业性组织",
    icon: icon2,
    money: "$12,190,000",
    content: "17项游说报告",
  },
  {
    name: "美国药品研究和制造商协会",
    info: "领先得制药和生物技术研究公司",
    icon: icon3,
    money: "$9,950,000",
    content: "11项游说报告",
  },
  {
    name: "美国奥驰亚集团",
    info: "烟草巨头菲利浦·莫里斯母公司",
    icon: icon4,
    money: "$8,216,000",
    content: "10项游说报告",
  },
  {
    name: "康卡斯特公司",
    info: "美国第二大互联网服务供应商",
    icon: icon5,
    money: "$7,720,000",
    content: "9项游说报告",
  },
  {
    name: "通用汽车公司",
    info: "全球最大汽车集团公司",
    icon: icon6,
    money: "$6,745,000",
    content: "9项游说报告",
  },
  {
    name: "联邦快递公司",
    info: "国际性速递集团",
    icon: icon7,
    money: "$6,320,000",
    content: "8项游说报告",
  },
  {
    name: "伯克希尔·哈撒韦公司",
    info: "保险和多元化投资集团",
    icon: icon8,
    money: "$6,100,000",
    content: "12项游说报告",
  },
]);

const voteAnalysisList1 = ref([
  {
    nameIcon: null,
    name: "委员会审议",
    time: "2025年5月20日",
    nameBold: true,
    support: 17,
    againist: 16,
    supportRank: "(15-20)",
    againistRank: "(14-19)",
    supportRate: 51.5,
    againistRate: 48.5,
    people: "",
    keyUser: null,
  },
  {
    nameIcon: iconA,
    name: "民主党",
    support: 1,
    againist: 15,
    supportRank: "",
    againistRank: "",
    supportRate: 7.3,
    againistRate: 92.7,
    people: 1,
    peopleRank: "0-1",
    keyUser: keyUser,
  },
  {
    nameIcon: iconB,
    name: "共和党",
    support: 16,
    againist: 1,
    supportRank: "",
    againistRank: "",
    supportRate: 94.5,
    againistRate: 5.5,
    people: 1,
    peopleRank: "1-2",
    keyUser: keyUser,
  },
]);

const voteAnalysisList2 = ref([
  {
    nameIcon: null,
    name: "众议院投票",
    time: "2025年5月20日",
    nameBold: true,
    support: 215,
    againist: 214,
    supportRank: "(210-220)",
    againistRank: "(200-215)",
    supportRate: 50.1,
    againistRate: 49.9,
    people: "",
    keyUser: null,
  },
  {
    nameIcon: iconA,
    name: "民主党",
    support: 0,
    againist: 212,
    supportRank: "",
    againistRank: "",
    supportRate: 0,
    againistRate: 92.7,
    people: 0,
    peopleRank: "0-1",
    keyUser: keyUser,
  },
  {
    nameIcon: iconB,
    name: "共和党",
    support: 215,
    againist: 3,
    supportRank: "",
    againistRank: "",
    supportRate: 98.7,
    againistRate: 1.3,
    people: 3,
    peopleRank: "1-3",
    keyUser: keyUser,
  },
]);

const voteAnalysisList3 = ref([
  {
    nameIcon: null,
    name: "参议院投票",
    time: "2025年5月20日",
    nameBold: true,
    support: 51,
    againist: 50,
    supportRank: "(48-51)",
    againistRank: "(49-50)",
    supportRate: 50.5,
    againistRate: 49.5,
    people: "",
    keyUser: null,
  },
  {
    nameIcon: iconA,
    name: "民主党",
    support: 1,
    againist: 15,
    supportRank: "",
    againistRank: "",
    supportRate: 7.3,
    againistRate: 92.7,
    people: 1,
    peopleRank: "0-1",
    keyUser: keyUser,
  },
  {
    nameIcon: iconB,
    name: "共和党",
    support: 16,
    againist: 1,
    supportRank: "",
    againistRank: "",
    supportRate: 94.5,
    againistRate: 5.5,
    people: 1,
    peopleRank: "1-2",
    keyUser: keyUser,
  },
]);

const voteAnalysisList4 = ref([
  {
    nameIcon: null,
    name: "众议院二次投票",
    time: "2025年5月20日",
    nameBold: true,
    support: 17,
    againist: 16,
    supportRank: "(15-20)",
    againistRank: "(14-19)",
    supportRate: 51.5,
    againistRate: 48.5,
    people: "",
    keyUser: null,
  },
  {
    nameIcon: iconA,
    name: "民主党",
    support: 1,
    againist: 15,
    supportRank: "",
    againistRank: "",
    supportRate: 7.3,
    againistRate: 92.7,
    people: 1,
    peopleRank: "0-1",
    keyUser: keyUser,
  },
  {
    nameIcon: iconB,
    name: "共和党",
    support: 16,
    againist: 1,
    supportRank: "",
    againistRank: "",
    supportRate: 94.5,
    againistRate: 5.5,
    people: 1,
    peopleRank: "1-2",
    keyUser: keyUser,
  },
]);

// 绘制echarts图表
const setChart = (option, chartId) => {
  let chartDom = document.getElementById(chartId);
  chartDom.removeAttribute("_echarts_instance_");
  let chart = echarts.init(chartDom);
  chart.setOption(option);
  return chart;
};

const chartData1 = ref({
  dataX: ["众议院通过", "参议院通过", "两院协商", "总统签署"],
  dataY: [
    [
      23, 28, 92, 81, 64, 54, 72, 38, 39, 66, 90, 55, 68, 69, 82, 42, 47, 49,
      85, 81,
    ],
    [
      31, 35, 67, 37, 80, 92, 110, 28, 55, 46, 81, 35, 46, 47, 49, 85, 84, 89,
      55, 43,
    ],
    [
      20, 18, 62, 51, 33, 37, 39, 48, 59, 35, 36, 38, 60, 49, 42, 32, 25, 39,
      55, 41,
    ],
    [
      20, 9, 18, 21, 28, 33, 30, 17, 12, 13, 20, 29, 28, 26, 12, 28, 26, 21, 32,
      35,
    ],
  ],
});

const chartData2 = ref({
  dataX: ["委员会审议", "辩论", "表决"],
  dataY: [
    [12, 15, 32, 42, 37, 33, 21, 20, 14, 15, 18, 25, 35, 36, 37, 33, 44],
    [23, 33, 21, 16, 18, 25, 28, 36, 33, 31, 30, 15, 16, 25, 23, 24, 20],
    [20, 18, 33, 21, 20, 18, 19, 18, 29, 30, 27, 22, 21, 20, 22, 13, 17],
  ],
});

const chart2Data = ref([
  {
    name: "共和党",
    value: "1550000",
  },
  {
    name: "民主党",
    value: "298000",
  },
]);

// 耗时分析
const handleGetBillTimeAnalyze = async () => {
  const params = {
    id: window.sessionStorage.getItem('billId'),
  };
  try {
    const res = await getBillTimeAnalyze(params);
    console.log("耗时分析", res);
    chartData1.value.dataX = res.data.map((item) => {
      return item.lcmc;
    });
    chartData1.value.dataY = res.data.map((item) => {
      return [item.zdhs, item.zshs, item.pjs, item.pjx, item.zws, item.dysc];
    });

    dataList.value = res.data.map((item) => {
      return {
        name: item.lcmc,
        data1: {
          name: "中位数",
          value: item.zws + "天",
        },
        data2: {
          name: "平均耗时",
          value: item.pjx + "-" + item.pjs + "天",
        },
        data3: {
          name: "最短耗时",
          value: item.zshs + "天",
        },
        data4: {
          name: "本次耗时",
          value: item.dysc ? item.dysc : "-" + "天",
        },
      };
    });
  } catch (error) {}
};

// 政治献金
const handleGetXj = async (personCongress) => {
  const params = {
    id: window.sessionStorage.getItem('billId'),
    personCongress: personCongress,
  };
  try {
    const res = await getBillXj(params);
    console.log("政治献金", res);
    box2DataList.value = res.data.map(item => {
      return {
        personId: item.personid,
        name: item.name,
        img: user1,
        icon1: personCongress === '参议院' ? CYY : ZYY,
        icon2: item.dp === '民主党' ? MZD : GHD,
        position: item.zw,
        money: `$${item.totalJe*10000}`,
        content: `${item.totalEventId}项游说记录`
      }
    })
  } catch (error) {}
};

// 党派政治献金
const handleGetTotalXj = async (personCongress) => {
  const params = {
    id: window.sessionStorage.getItem('billId'),
    personCongress: personCongress,
  };
  try {
    const res = await getBillTotalXj(params);
    console.log("党派政治献金", res);
    chart2Data.value = res.data.map((item) => {
      return {
        name: item.dp,
        value: item.totalJe,
      };
    });
    let chart2 = getPieChart(chart2Data.value);
    setChart(chart2, "chart2");
  } catch (error) {}
};

onMounted(async () => {
  await handleGetBillTimeAnalyze();
  handleGetXj("参议院");

  let chart1 = getBoxPlotChcart(chartData1.value);
  setChart(chart1, "chart1");

  handleGetTotalXj("参议院");
});
</script>

<style lang="scss" scoped>
.wrap {
  display: flex;
  .box-header {
    height: 56px;
    display: flex;
    position: relative;
    .header-left {
      margin-top: 20px;
      width: 8px;
      height: 16px;
      border-radius: 0 4px 4px 0;
      background: var(--color-main-active);
    }
    .title {
      margin-left: 22px;
      margin-top: 20px;
      height: 16px;
      line-height: 16px;
      color: var(--color-main-active);
      font-family: Microsoft YaHei;
      font-size: 16px;
      font-weight: 600;
      line-height: 16px;
    }
    .header-switch-box {
      position: absolute;
      top: 14px;
      right: 349px;
      width: 160px;
      height: 28px;
      background: url("./assets/images/chartActive.png");
      background-size: 100% 100%;
      display: flex;
      cursor: pointer;
      .header-switch-box-left {
        width: 80px;
      }
      .header-switch-box-right {
        width: 80px;
      }
    }
    .headerSwitchBox1 {
      background: url("./assets/images/dataActive.png") !important;
      background-size: 100% 100% !important;
    }
    .header-btn-box {
      position: absolute;
      top: 14px;
      right: 52px;
      display: flex;
      .btn {
        margin-left: 20px;
      }
    }
    .header-right {
      position: absolute;
      top: 14px;
      right: 12px;
      width: 32px;
      height: 32px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .left {
    margin-top: 16px;
    .box1 {
      width: 860px;
      height: 415px;
      background: rgb(255, 255, 255);
      border-radius: 10px;
      box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
      .box1-main {
        height: 359px;
        .box1-main-center {
          width: 760px;
          height: 300px;
          margin: 0 50px;
          overflow: hidden;
          .box1-main-table {
            display: flex;
            margin-top: 30px;
            width: 758px;
            height: 240px;
            border-radius: 4px;
            border: 1px solid #e7f1ff;
            .table-name {
              flex: 1;
              text-align: center;
              .name-item {
                height: 48px;
                display: flex;
                align-items: center;
                justify-content: center;
                color: rgba(59, 65, 75, 1);
                font-family: Microsoft YaHei;
                font-size: 16px;
                font-weight: 700;
              }
              .name-item:nth-child(2n-1) {
                background: rgba(246, 251, 255, 1);
              }
            }
            .table-item {
              flex: 1;
              .item {
                height: 48px;
                display: flex;
                align-items: center;
                justify-content: center;
                color: rgba(95, 101, 108, 1);
                font-family: Microsoft YaHei;
                font-size: 16px;
                font-weight: 400;
              }
              .item:first-child {
                color: rgba(59, 65, 75, 1);
                font-family: Microsoft YaHei;
                font-size: 16px;
                font-weight: 700;
              }
              .item:nth-child(3) {
                color: var(--color-main-active);
                font-family: Microsoft YaHei;
                font-size: 16px;
                font-weight: 400;
              }
              .item:nth-child(5) {
                color: rgba(206, 79, 81, 1);
                font-family: Microsoft YaHei;
                font-size: 16px;
                font-weight: 700;
              }
              .item:nth-child(2n-1) {
                background: rgba(246, 251, 255, 1);
              }
            }
          }
        }
        .box1-main-footer {
          width: 830px;
          height: 40px;
          display: flex;
          box-sizing: border-box;
          margin: 0 auto;
          margin-top: 6px;
          background: rgba(246, 251, 255, 1);
          .box-footer-left {
            margin-top: 10px;
            margin-left: 12px;
            width: 19px;
            height: 20px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .box-footer-center {
            margin-left: 13px;
            margin-top: 8px;
            width: 749px;
            height: 24px;
            color: var(--color-main-active);
            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 400;
            line-height: 24px;
          }
          .box-footer-right {
            margin-left: 13px;
            margin-top: 8px;
            width: 24px;
            height: 24px;
            background: rgba(231, 241, 255, 1);
            border-radius: 12px;
            background: #e7f1ff;
            box-sizing: border-box;
            padding: 3px;
            img {
              width: 100%;
              height: 100%;
            }
          }
        }
      }
    }
    .box2 {
      margin-top: 17px;
      width: 860px;
      height: 415px;
      background: rgb(255, 255, 255);
      border-radius: 10px;
      box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
      .box2-main {
        height: 359px;
        .box2-main-center {
          height: 300px;
          margin: 0 23px;
          display: flex;
          .box2-main-center-left {
            width: 480px;
            height: 300px;
            .left-item {
              width: 480px;
              height: 54px;
              box-sizing: border-box;
              border: 1px solid rgba(241, 243, 246, 1);
              border-radius: 4px;
              margin-bottom: 8px;
              display: flex;
              .left-item-left {
                width: 40px;
                height: 40px;
                margin-left: 14px;
                margin-top: 8px;
                img {
                  width: 100%;
                  height: 100%;
                }
              }
              .left-item-center {
                margin-left: 14px;
                width: 240px;
                .left-item-center-top {
                  display: flex;
                  .name {
                    margin-top: 5px;
                    height: 24px;
                    color: rgba(59, 65, 75, 1);
                    font-family: Microsoft YaHei;
                    font-size: 16px;
                    font-weight: 700;
                    line-height: 24px;
                  }
                  .icon1 {
                    margin-left: 6px;
                    margin-top: 9px;
                    width: 16px;
                    height: 16px;
                    img {
                      width: 100%;
                      height: 100%;
                    }
                  }
                  .icon2 {
                    margin-left: 2px;
                    margin-top: 9px;
                    width: 16px;
                    height: 16px;
                    img {
                      width: 100%;
                      height: 100%;
                    }
                  }
                }
                .left-item-center-bottom {
                  color: rgba(132, 136, 142, 1);
                  font-family: Microsoft YaHei;
                  font-size: 14px;
                  font-weight: 400;
                  line-height: 20px;
                }
              }
              .left-item-right {
                width: 150px;
                text-align: right;
                .left-item-right-top {
                  height: 24px;
                  margin-top: 5px;
                  color: rgba(206, 79, 81, 1);
                  font-family: Microsoft YaHei;
                  font-size: 16px;
                  font-weight: 700;
                  line-height: 24px;
                }
                .left-item-right-bottom {
                  height: 20px;
                  color: rgba(132, 136, 142, 1);
                  font-family: Microsoft YaHei;
                  font-size: 14px;
                  font-weight: 400;
                  line-height: 20px;
                }
              }
            }
          }
          .box2-main-center-right {
            width: 330px;
            margin: 0 auto;
            position: relative;
            #chart2 {
              position: relative;
              width: 330px;
              height: 300px;
              z-index: 0;
            }
            .info-box {
              position: absolute;
              z-index: 99;
              left: 90px;
              top: 75px;
              width: 150px;
              height: 150px;
              border-radius: 50px;
              .item {
                margin: 15px 0;

                .item-top {
                  display: flex;
                  justify-content: center;
                  height: 24px;
                  color: rgba(95, 101, 108, 1);
                  font-family: Microsoft YaHei;
                  font-size: 16px;
                  font-weight: 400;
                  line-height: 24px;
                  .icon {
                    width: 20px;
                    height: 20px;
                    margin-top: 2px;
                    margin-right: 2px;
                    img {
                      width: 100%;
                      height: 100%;
                    }
                  }
                }
                .item-footer {
                  color: rgba(206, 79, 81, 1);
                  font-family: Microsoft YaHei;
                  font-size: 16px;
                  font-weight: 700;
                  line-height: 24px;
                  text-align: center;
                }
                .item-footer1 {
                  color: rgba(22, 119, 255, 1);
                  font-family: Microsoft YaHei;
                  font-size: 16px;
                  font-weight: 700;
                  line-height: 24px;
                  text-align: center;
                }
              }
            }
          }
          // .box2-main-center-content {
          //   height: 264px;
          //   display: flex;
          //   flex-wrap: wrap;
          //   justify-content: space-between;
          //   .box2-item {
          //     width: 402px;
          //     height: 58px;
          //     box-sizing: border-box;
          //     border: 1px solid rgba(243, 243, 244, 1);
          //     border-radius: 4px;
          //     margin-bottom: 8px;
          //     display: flex;
          //     .box2-item-left {
          //       width: 36px;
          //       height: 36px;
          //       margin-left: 16px;
          //       margin-top: 11px;
          //       img {
          //         width: 100%;
          //         height: 100%;
          //       }
          //     }
          //     .box2-item-center {
          //       margin-left: 14px;
          //       margin-top: 5px;
          //       width: 220px;
          //       .box2-item-center-top {
          //         height: 24px;
          //         color: rgba(59, 65, 75, 1);
          //         font-family: Microsoft YaHei;
          //         font-size: 14px;
          //         font-weight: 600;
          //         line-height: 24px;
          //       }
          //       .box2-item-center-bottom {
          //         height: 24px;
          //         color: rgba(132, 136, 142, 1);
          //         font-family: Microsoft YaHei;
          //         font-size: 14px;
          //         font-weight: 400;
          //         line-height: 24px;
          //       }
          //     }
          //     .box2-item-right {
          //       margin-left: 2px;
          //       .box2-item-right-top {
          //         height: 24px;
          //         color: rgba(206, 79, 81, 1);
          //         font-family: Microsoft YaHei;
          //         font-size: 14px;
          //         font-weight: 600;
          //         line-height: 24px;
          //       }
          //       .box2-item-right-bottom {
          //         height: 24px;
          //         color: rgba(132, 136, 142, 1);
          //         font-family: Microsoft YaHei;
          //         font-size: 14px;
          //         font-weight: 400;
          //         line-height: 24px;
          //         text-align: right;
          //       }
          //     }
          //   }
          // }
          // .box2-main-center-footer {
          //   height: 36px;
          //   display: flex;
          //   justify-self: center;
          // }
        }
        .box2-main-footer {
          width: 830px;
          height: 40px;
          display: flex;
          box-sizing: border-box;
          margin: 0 auto;
          margin-top: 6px;
          background: rgba(246, 251, 255, 1);
          .box-footer-left {
            margin-top: 10px;
            margin-left: 12px;
            width: 19px;
            height: 20px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .box-footer-center {
            margin-left: 13px;
            margin-top: 8px;
            width: 749px;
            height: 24px;
            color: var(--color-main-active);
            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 400;
            line-height: 24px;
          }
          .box-footer-right {
            margin-left: 13px;
            margin-top: 8px;
            width: 24px;
            height: 24px;
            background: rgba(231, 241, 255, 1);
            border-radius: 12px;
            background: #e7f1ff;
            box-sizing: border-box;
            padding: 3px;
            img {
              width: 100%;
              height: 100%;
            }
          }
        }
      }
    }
  }
  .right {
    margin-left: 16px;
    margin-top: 16px;
    width: 860px;
    height: 847px;
    background: rgb(255, 255, 255);
    .box3 {
      width: 100%;
      height: 100%;
      border-radius: 10px;
      box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
      .box3-main {
        height: 791px;
        .box3-main-center {
          height: 732px;
          margin: 0 23px;
          .box3-main-center-header {
            height: 50px;
            display: flex;
            color: rgba(95, 101, 108, 1);
            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 600;
            line-height: 22px;
            .box1 {
              width: 430px;
              text-align: center;
            }
            .box2 {
              width: 60px;
              text-align: center;
            }
            .box3 {
              width: 77px;
              text-align: center;
            }
            .box4 {
              width: 70px;
              text-align: center;
            }
            .box5 {
              width: 80px;
              text-align: center;
            }
            .box6 {
              width: 126px;
              text-align: center;
            }
          }
          .box3-main-center-content {
            .box3-main-center-content-box {
              width: 830px;
              height: 160px;
              box-sizing: border-box;
              border: 1px solid rgba(243, 243, 244, 1);
              border-radius: 4px;
              background: rgba(255, 255, 255, 1);
              margin-bottom: 10px;
              padding: 20px;
              .item {
                display: flex;
                height: 45px;
                .box1 {
                  width: 400px;
                  display: flex;
                  .box1-left {
                    width: 130px;
                    display: flex;
                    justify-content: flex-end;
                    .icon {
                      width: 16px;
                      height: 16px;
                      img {
                        width: 100%;
                        height: 100%;
                      }
                    }
                    .name {
                      margin-left: 10px;
                      height: 22px;
                      color: rgba(59, 65, 75, 1);
                      font-family: Microsoft YaHei;
                      font-size: 16px;
                      line-height: 22px;
                      text-align: right;
                    }
                    .nameBlod {
                      font-weight: 600;
                    }
                    .time {
                      height: 22px;
                      color: rgba(95, 101, 108, 1);
                      font-family: Microsoft YaHei;
                      font-size: 14px;
                      font-weight: 400;
                      line-height: 22px;
                      text-align: right;
                    }
                  }
                  .box1-right {
                    // border-left: 1px solid rgba(243, 243, 244, 1);
                    // border-right: 1px solid rgba(243, 243, 244, 1);
                    width: 240px;
                    .box1-right-top {
                      :deep(.el-progress-bar__inner) {
                        background: rgba(22, 119, 255, 1);
                        border-radius: 0;
                      }
                      :deep(.el-progress-bar__outer) {
                        background: rgba(22, 119, 255, 0.5);
                        border-radius: 0;
                      }
                    }
                    .box1-right-bottom {
                      :deep(.el-progress-bar__inner) {
                        background: rgba(255, 172, 77, 1);
                        border-radius: 0;
                      }
                      :deep(.el-progress-bar__outer) {
                        background: rgba(255, 172, 77, 0.5);
                        border-radius: 0;
                      }
                    }
                  }
                }
                .box2 {
                  width: 60px;
                  text-align: center;
                  .box2-1 {
                    height: 14px;
                    color: rgba(22, 119, 255, 1);
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                  }
                  .box2-2 {
                    margin-top: 5px;
                    height: 14px;
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                    color: rgba(255, 172, 77, 1);
                  }
                }
                .box3 {
                  width: 77px;
                  text-align: center;
                  .box3-1 {
                    height: 14px;
                    color: rgba(22, 119, 255, 1);
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                  }
                  .box3-2 {
                    margin-top: 5px;
                    height: 14px;
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                    color: rgba(255, 172, 77, 1);
                  }
                }
                .box4 {
                  width: 70px;
                  text-align: center;
                  .box4-1 {
                    height: 14px;
                    color: rgba(22, 119, 255, 1);
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                  }
                  .box4-2 {
                    margin-top: 5px;
                    height: 14px;
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                    text-align: center;
                    color: rgba(255, 172, 77, 1);
                  }
                }
                .box5 {
                  width: 80px;
                  text-align: center;
                  .box5-1 {
                    height: 14px;
                    color: rgba(206, 79, 81, 1);
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 600;
                    line-height: 14px;
                  }
                  .box5-2 {
                    margin-top: 5px;
                    height: 14px;
                    color: rgba(206, 79, 81, 1);
                    font-family: Microsoft YaHei;
                    font-size: 14px;
                    font-weight: 400;
                    line-height: 14px;
                  }
                }
                .box6 {
                  width: 116px;
                  text-align: center;
                  .img-box {
                    width: 30px;
                    height: 30px;
                    margin-left: 50px;
                    img {
                      width: 100%;
                      height: 100%;
                    }
                  }
                }
              }
            }
          }
        }
        .box3-main-footer {
          width: 830px;
          height: 40px;
          display: flex;
          box-sizing: border-box;
          margin: 0 auto;
          margin-top: 6px;
          background: rgba(246, 251, 255, 1);
          .box-footer-left {
            margin-top: 10px;
            margin-left: 12px;
            width: 19px;
            height: 20px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .box-footer-center {
            margin-left: 13px;
            margin-top: 8px;
            width: 749px;
            height: 24px;
            color: var(--color-main-active);
            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 400;
            line-height: 24px;
          }
          .box-footer-right {
            margin-left: 13px;
            margin-top: 8px;
            width: 24px;
            height: 24px;
            background: rgba(231, 241, 255, 1);
            border-radius: 12px;
            background: #e7f1ff;
            box-sizing: border-box;
            padding: 3px;
            img {
              width: 100%;
              height: 100%;
            }
          }
        }
      }
    }
  }
}

:deep(.el-progress-bar__outer) {
  height: 8px !important;
  margin-bottom: 8px;
  width: 230px;
  margin-left: 10px;
}
</style>
