<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>

            <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 = [
  "杭州",
  "宁波",
  "温州",
  "湖州",
  "嘉兴",
  "绍兴",
  "金华",
  "衢州",
  "舟山",
  "台州",
  "丽水",
];
// const cityData = {
//   value: [75, 37, 4, 17, 8, 10, 1, 1, 0, 0, 2],
// };
/**
 * 军民协同创新
 */

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() {
      this.TargetBars.showLoading();
      this.TargetBars.setOption(this.optionCity);
      this.TargetBars.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",
          },
          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: "10%",
          left: "5%",
          right: "2%",
          bottom: "3%",
          containLabel: true,
        },
        yAxis: {
          type: "value",
          name: "数量(个)",
        },
        xAxis: {
          type: "category",
          data: xAxisCity,
        },
        series: [...seriesBar],
      };
    },
  },
  methods: {
    initEcharts() {
      this.initCityEcharts();
    },
    initCityEcharts() {
      const dom = document.getElementById("TargetBars");
      const mapEcharts = echarts.init(dom);
      mapEcharts.setOption(this.optionCity);
      this.TargetBars = mapEcharts;
    },
  },
  unmounted() {
    if (this.TargetBars) {
      this.TargetBars.dispose();
      this.TargetBars = null;
    }
  },
});
</script>
<style lang="scss" scoped>
// .meeting {
//   height: 50px;
//   line-height: 50px;
//   border-radius: 4px;
//   color: #666666;
//   background: rgba(248, 249, 251, 1);
//   display: flex;
//   justify-content: space-between;
//   padding: 0 10px 0 10px;
//   box-sizing: border-box;
//   margin-top: 10px;
// }

.target-bar {
  flex: 1;
  height: calc(100% - 100px);
  box-sizing: border-box;
  margin-top: 10px;
}
// .frequency {
//   color: rgba(65, 152, 255, 1);
//   font-weight: 500;
// }
// .second {
//   color: #666666;
//   font-size: 12px;
//   font-weight: normal;
// }
.card-item {
  background: #fff;
  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: #f8f9fb;
        border-radius: 5px;
        font-size: 14px;
        color: #333;
        display: flex;
        align-items: center;
        justify-content: space-between;
        &:last-of-type {
          margin-right: 0;
        }
        .value-des {
          font-size: 12px;
          color: #999;
          display: flex;
          align-items: center;
          span {
            font-size: 20px;
            margin-right: 5px;
            color: #4198ff;
          }
        }
      }
    }
  }
}

.map-warpper {
  box-sizing: border-box;
  .economic-construct {
    flex: 1;
  }
  .map-right {
    .card-item {
      flex: 1;
    }
  }
}
.footer-warpper {
  margin-bottom: 20px;
}
</style>
