<template>
  <el-row class="footer-warpper" :gutter="16">
    <el-col class="map-left" :span="8">
      <div class="business-extend footer-item card-item">
        <Outline />
      </div>
    </el-col>

    <el-col class="map-right" :span="16">
      <div class="footer-item card-item">
        <Munitions />
      </div>
    </el-col>
  </el-row>

  <!-- foot -->
  <el-row class="map-warpper" :gutter="16">
    <el-col class="map-left" :span="8">
      <div class="footer-item card-item">
        <Platform />
      </div>
    </el-col>
    <el-col class="map-right" :span="16">
      <el-row :gutter="16">
        <el-col :span="12">
          <div class="economic-construct card-item">
            <ScientificInvestment />
          </div>
        </el-col>
        <el-col :span="12">
          <div class="card-item">
            <MapTitle text="国防科技工业产值规模分布" />

            <div class="echarts-search">
              <div class="card-items">
                <div class="item">
                  <span>省直部门新认定的领跑技术（产品）</span>
                  <div class="value-des">
                    <span>{{ count || "--" }}</span
                    >个
                  </div>
                </div>
              </div>

              <div class="title2X">各市领跑技术（产品）分布情况</div>
            </div>

            <div id="TargetBars" class="target-bar"></div>
          </div>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import Platform from "./model/Platform/index.vue";
import Outline from "./model/Outline/index.vue";
import Science from "./model/Science/index.vue";
import Munitions from "./model/Munitions/index.vue";
import ScientificInvestment from "./model/ScientificInvestment/index.vue";
import Industrial from "./model/Industrial/index.vue";
import MapTitle from "@/components/mapTitle/index.vue";
import * as echarts from "echarts";
import { Aim } from "@element-plus/icons";
import Mock from "./mock";
import { mapState } from "vuex";
const xAxisCity = [
  "杭州",
  "宁波",
  "温州",
  "湖州",
  "嘉兴",
  "绍兴",
  "金华",
  "衢州",
  "舟山",
  "台州",
  "丽水",
];
let MAP_ECHARTS = null;
/**
 * 军民协同创新
 */

export default defineComponent({
  components: {
    Platform,
    Outline,
    Science,
    Munitions,
    ScientificInvestment,
    Industrial,
    MapTitle,
    Aim,
  },
  setup() {},
  data() {
    return {
      countryEcharts: null,
      shu: "155",
      TargetBars: null,
    };
  },
  mounted() {
    this.initEcharts();
  },
  watch: {
    seriesData() {
      MAP_ECHARTS.showLoading();
      MAP_ECHARTS.setOption(this.optionCity, true);
      MAP_ECHARTS.hideLoading();
    },
  },
  computed: {
    ...mapState({
      curDataType: (state) => state.curDataType,
    }),
    seriesData() {
      return Mock[this.curDataType].cityData;
    },
    count() {
      return Mock[this.curDataType].count;
    },
    optionCity() {
      const seriesBar = this.seriesData.map((item) => {
        return {
          type: "bar",

          itemStyle: {
            color: "#4198ff",
          },
          barWidth: 20,

          data: item.value.map((item) => {
            return {
              value: item,
              label: "收入规模",
            };
          }),
        };
      });
      return {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
            shadowStyle: {
              color: "#1881e120",
            },
          },
          formatter: (params) => {
            let html = ``;

            html += `<div class="munition-echart ">
                <span class=" title color_1">${params[0].axisValue}市</span>
                <br />
                <span class="text text-color_1">${params[0].data.value}</span>个
               </div>
             `;

            return html;
          },
        },
        legend: {},
        grid: {
          top: "15%",
          left: "5%",
          right: "2%",
          bottom: "3%",
          containLabel: true,
        },
        yAxis: {
          type: "value",
          name: "数量(个)",
          nameTextStyle: {
            color: "#fff",
          },
          axisLabel: {
            show: true,
            color: "#fff",
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "#125ba3",
              type: "dotted",
            },
          },
        },
        xAxis: {
          type: "category",
          data: xAxisCity,
          axisLabel: {
            show: true,
            color: "#ffffff",
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "#125ba3",
            },
          },
          axisTick: {
            show: false,
          },
        },
        series: [...seriesBar],
      };
    },
  },
  methods: {
    initEcharts() {
      this.initCityEcharts();
    },
    initCityEcharts() {
      const dom = document.getElementById("TargetBars");
      MAP_ECHARTS = echarts.init(dom);
      MAP_ECHARTS.setOption(this.optionCity);
      this.TargetBars = MAP_ECHARTS;
    },
  },
  unmounted() {
    if (this.TargetBars) {
      this.TargetBars.dispose();
      this.TargetBars = null;
    }
  },
});
</script>
<style lang="scss" scoped>
.target-bar {
  flex: 1;
  height: calc(100% - 130px);
  box-sizing: border-box;
  margin-top: 10px;
}

.card-item {
  background-color: #197ded15;
  border: 1px solid #125ba3;
  border-radius: 5px;
  padding: 15px 20px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  // box-shadow: 2px 2px 10px #eee;
  flex: 1;
  height: 100%;
  box-sizing: border-box;
  .echarts-search {
    padding-left: 10px;
    .title {
      color: #4198ff;
      margin: 12px 0;
      font-size: 16px;
    }
    .card-items {
      margin: 15px 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 14px;
      .item {
        flex: 1;
        padding: 8px 15px;
        margin-right: 15px;
        background: #197ded15;
        border-radius: 5px;
        font-size: 14px;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        &:last-of-type {
          margin-right: 0;
        }
        .value-des {
          font-size: 12px;
          color: #fff;
          display: flex;
          align-items: center;
          span {
            font-size: 20px;
            margin-right: 5px;
            color: #19ecff;
          }
        }
      }
    }
  }
}

.map-warpper {
  box-sizing: border-box;

  .economic-construct {
    flex: 1;
  }
  .map-right {
    .card-item {
      flex: 1;
    }
  }
}
.footer-warpper {
  margin-bottom: 20px;
}
.title2X {
  margin-top: 15px;
  font-size: 16px;
  color: #4198ff;
}
</style>
