<template>
  <div class="statistical-analysis">
    <!-- 左侧树形菜单 -->
    <div class="left-menu">
      <!-- 这个部分用的是组件-后期替换 -->
      <el-tree
        :data="treeData"
        :props="defaultProps"
        @node-click="handleNodeClick"
        default-expand-all
      />
    </div>

    <!-- 右侧内容区 -->
    <div class="right-content">
      <!-- 顶部筛选 -->
      <div class="filter-section">
        <el-radio-group v-model="radio">
          <el-radio :label="it.value" v-for="it in timeList" :key="it.value">{{
            it.label
          }}</el-radio>
        </el-radio-group>
        <el-date-picker
          v-model="dateRange"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          @change="handleDateChange"
        />
        <el-button type="primary" @click="handleExport">查询</el-button>
        <el-button type="primary" @click="handleExport">重置</el-button>
      </div>

      <!-- 统计图表区域 -->
      <div class="charts-container">
        <div class="chart-item">
          <div class="chart-title">
            <span>线索采集统计</span>
            <el-button type="primary">导出统计表</el-button>
          </div>
          <div class="chart">
            <PieEcharts
              echartsId="pieChart"
              color="#333"
              :data="obj.cjList"
            ></PieEcharts>
          </div>
        </div>
        <div class="chart-item">
          <div class="chart-title">
            <span>指令统计</span>
            <el-button type="primary">导出统计表</el-button>
          </div>
          <div class="chart">
            <DbarEcharts
              echartsId="bar3DChart"
              :data="obj.zlList"
            ></DbarEcharts>
          </div>
        </div>
        <div class="chart-item">
          <div class="chart-title">
            <span>线索类型统计</span>
            <el-button type="primary">导出统计表</el-button>
          </div>
          <ul class="chart mt8">
            <li v-for="(it, idx) in obj.jjList" :key="idx" class="mb6">
              <div style="color: #333">{{ it.label }}</div>
              <el-progress
                :text-inside="true"
                :stroke-width="20"
                :percentage="50"
                status="exception"
              >
                <span
                  ><span style="color: #e37233">{{ it.value }}</span> 个</span
                >
              </el-progress>
            </li>
          </ul>
        </div>
        <div class="chart-item">
          <div class="chart-title">
            <span>线索类型统计</span>
            <el-button type="primary">导出统计表</el-button>
          </div>
          <lineEcharts
            color="#333"
            echartsId="areaChart"
            :data="obj.bkgzList"
          ></lineEcharts>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import lineEcharts from "@/views/home/echarts/lineEcharts.vue";
import PieEcharts from "@/views/home/echarts/pieEcharts.vue";
import DbarEcharts from "@/views/home/echarts/3DbarEcharts.vue";
import { qcckGet, qcckPost, qcckDelete } from "@/api/qcckApi.js";
import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import * as echarts from "echarts";
const radio = ref("日");
const timeList = ref([
  { label: "日", value: "0" },
  { label: "月", value: "1" },
  { label: "季", value: "2" },
  { label: "年", value: "3" }
]);
const obj = reactive({
  listQuery: {},
  cjList: [
    { label: "采纳数", value: 18 },
    { label: "编刊数", value: 20 },
    { label: "退回数", value: 50 },
    { label: "合并数", value: 40 },
    { label: "其他", value: 30 }
  ],
  // 布控工作统计
  bkgzList: [
    { label: "发起总数", value: 10 },
    { label: "审核总数", value: 20 },
    { label: "审批总数", value: 50 },
    { label: "处置总数", value: 40 },
    { label: "其他", value: 30 }
  ],
  jjList: [
    { label: "涉稳", value: 10 },
    { label: "涉毒", value: 20 },
    { label: "行政", value: 50 },
    { label: "群体", value: 40 },
    { label: "灾害", value: 40 }
  ],
  zlList: {
    list: [
      { label: "下发数", val: 50 },
      { label: "未签收", val: 40 },
      { label: "已签收", val: 10 },
      { label: "超时签收", val: 30 },
      { label: "未反馈", val: 40 },
      { label: "已反馈", val: 40 }
    ],
    topColor:'#1bd6c2',
    colors: ["#28EEBF","#0DBAC5"],
  }
});

// 树形菜单数据
const treeData = ref([
  {
    label: "林芝市公安局（200）",
    children: [
      { label: "工布江达县公安局（100）" },
      { label: "工布江达城区派出所（10）" },
      { label: "某某某派出所（10）" },
      { label: "某某某公安局（100）" }
    ]
  }
]);

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

// 日期范围
const dateRange = ref([]);

// 事件处理函数
const handleNodeClick = (data) => {
  console.log(data);
};

const handleDateChange = () => {
  // 处理日期变化
};

const handleExport = () => {
  // 处理导出
};

onMounted(() => {});
</script>

<style lang="scss" scoped>
.statistical-analysis {
  display: flex;
  height: 100%;

  .left-menu {
    width: 280px;
    padding: 20px;
    margin-top: 20px;
    border-radius: 4px;
    background-color: #fff;
    border-right: 1px solid #e8e8e8;
  }

  .right-content {
    flex: 1;
    padding: 20px;
    .filter-section {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 20px;
      background: #fff;
      padding: 10px;
      box-sizing: border-box;
      border-radius: 4px;
    }

    .charts-container {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      height: calc(100% - 50px);
      .chart-item {
        width: 49.5%;
        height: calc(50% - 5px);
        background-color: #fff;
        border-radius: 8px;
        padding: 20px;
        box-sizing: border-box;
        overflow: hidden;
        overflow-y: auto;
        .chart-title {
          font-size: 16px;
          font-weight: bold;
          color: #333;
          display: flex;
          justify-content: space-between;
          align-items: center;
        }
        .chart {
          height: calc(100% - 40px);
          overflow: hidden;
          overflow-y: auto;
        }
      }
    }
  }
  
  ::v-deep .el-radio {
    color: #333;
  }
  ::v-deep .el-radio__inner {
    border-radius: 4px;
  }
  ::v-deep .el-progress-bar__innerText {
    color: #333;
    margin: 0 -40px;
  }
  ::v-deep .el-progress.is-exception .el-progress-bar__inner {
    background: linear-gradient(90deg, #fe5d00 0%, #face35 100%);
  }
}
</style>
