<template>
  <div class='main-box'>
    <!-- 头部方形图形 -->
    <div class="header flex">
      <el-card
        class='header-card'
        shadow="hover"
        v-for="item in headerData"
        :style='{background: item.backgroundColor}'
      >
        <span class="text size">{{item.name}}/已执行(元)</span>
        <span class="count size">
          <count-to
            :startVal='0'
            :endVal='item.count'
            :duration=4000
            class='size'
          ></count-to>/ <count-to
            :startVal='0'
            :endVal='item.count1'
            :duration=4000
            class='size'
          ></count-to>
        </span>
        <span class="bottom">
          <p>较上年</p>
          <p
            v-if='item.type == "add"'
            style='color:#ee6666'
          >
            <span>
              <i class='el-icon-top'></i>
            </span>
            <span>+</span>
            <span>
              <count-to
                :startVal='0'
                :endVal='item.count2'
                :duration=4000
              ></count-to>
            </span>
            <span>%</span>
          </p>
          <p
            v-else
            style='color: #91cc75'
          >
            <span>
              <i class='el-icon-bottom'></i>
            </span>
            <span>-</span>
            <span>
              <count-to
                :startVal='0'
                :endVal='item.count2'
                :duration=4000
              ></count-to>
            </span>
            <span>%</span>
          </p>
        </span>
      </el-card>
      <!-- <div
        class='more'
        @click='handleMore'
      >{{isMore ? '隐藏' :  '更多'}}
        <i :class='isMore ? "el-icon-d-arrow-left" : "el-icon-d-arrow-right"'></i></div> -->
    </div>
    <!-- 内容 -->
    <div class="center flex">
      <div class="center-div center-div-1 border-radius">
        <span class='title'>年度投资情况</span>
        <columnar-chart />
      </div>
      <div class="center-div center-div-1 border-radius">
        <span class='title'>项目开工执行情况</span>
        <Column />
      </div>
    </div>
    <!-- <div class='center flex'>
      <div class="center-div border-radius">
        <span class='title'>项目执行情况</span>
        <Column />
      </div>
    </div> -->
    <!-- 底部内容 -->
    <div class='bottom flex'>
      <div class='bottom-div-2 common border-radius'>
        <span class='title'>项目执行进度</span>
        <gantt-chart />
      </div>
      <div class="bottom-div-1 common border-radius">
        <span class='title'>项目投资占比</span>
        <radar-chart />
      </div>
      <!-- <div class='bottom-div-1 common border-radius'>
        <span class='title'>合同占比</span>
        <cloumn-bar-chart />
      </div> -->
    </div>
    <div
      class='flex'
      style="height:480px"
    >
      <!-- 建设概况 -->
      <div
        class='model border-radius'
        style="display: flex"
      >
        <span
          class='title'
          style='margin-bottom: 10px'
        >建设概况</span>
        <el-table
          :data="tableData"
          border
          style="width: 100%"
        >
          <el-table-column
            prop="type"
            label="类型"
            width="180"
            align='center'
          >
          </el-table-column>
          <el-table-column
            prop="count"
            label="项目个数(个)"
            width="180"
            align='center'
          >
          </el-table-column>
          <el-table-column
            prop="price"
            label="总投资(万元)"
            align='center'
          >
          </el-table-column>
          <el-table-column
            prop="price1"
            label="产值(万元)"
            align='center'
          >
          </el-table-column>
          <el-table-column
            prop="road"
            label="里程/面积"
            align='center'
          >
          </el-table-column>
          <el-table-column
            prop="company"
            label="单位"
            align='center'
          >
          </el-table-column>
        </el-table>
      </div>
      <div
        class='bottom-div-1 common border-radius'
        style="flex: 1"
      >
        <span class='title'>合同占比</span>
        <cloumn-bar-chart />
      </div>
    </div>

  </div>
</template>
<script>
import countTo from 'vue-count-to'
import dataJson from '../../src/assets/js/index.json'
import PieChart from '@/components/charts/PieChart.vue'
import ColumnarChart from '@/components/charts/ColumnarChart.vue'
import ColumnPieChart from '@/components/charts/ColumnPieChart.vue'
import CloumnBarChart from '@/components/charts/CloumnBarChart.vue'
import GanttChart from '@/components/charts/GanttChart.vue'
import RadarChart from '@/components/charts/RadarChart.vue'
import Column from '@/components/charts/Column.vue'
export default {
  components: {
    countTo,
    PieChart,
    ColumnarChart,
    ColumnPieChart,
    CloumnBarChart,
    GanttChart,
    RadarChart,
    Column
  },
  data() {
    return {
      isMore: false, //是否显示头部全部数据
      // headerData: dataJson.header.slice(0, 6),
      headerData:dataJson.header,
      tableData: dataJson.tableData
    }
  },
  methods: {
    handleMore() {
      if (!this.isMore) {
        this.headerData = dataJson.header
      } else {
        this.headerData = dataJson.header.slice(0, 6)
      }
      this.isMore = !this.isMore
    }
  }
}
</script>
<style lang="scss" scoped>
.main-box {
  overflow-y: auto;
}
.background {
  background-color: #fff;
}
.border-radius {
  border-radius: 8px;
}
.flex {
  display: flex;
  margin: 10px;
}
.header {
  height: 120px;
  // padding-top: 12px;
  position: relative;
  .more {
    position: absolute;
    top: -5px;
    right: 10px;
    cursor: pointer;
    &:hover {
      color: #63b2ee;
    }
  }
  .header-card {
    flex: 1;
    background-color: #fff;
    /deep/ .el-card__body {
      padding: 10px !important;
      display: flex;
      flex-direction: column;
    }
    &:nth-child(2n) {
      margin-left: 10px;
    }
    &:nth-child(n + 2) {
      margin-left: 10px;
    }
    .size {
      font-size: 16px;
      font-weight: bold;
    }
    .text {
      margin-bottom: 15px;
      // color: #419bfd;
    }
    .count {
      text-align: center;
      font-size: 14px;
    }
    p {
      display: inline;
      margin: 0;
    }
    .bottom {
      display: flex;
      justify-content: space-between;
      background: #fff;
      margin: 20px -10px -10px;
      padding: 5px;
    }
  }
}
.center {
  .center-div {
    background-color: #fff;
    height: 430px;
    width: 100%;
    display: flex;
    flex-direction: column;
    &:nth-child(2) {
      margin-left: 10px;
    }
  }
  .center-div-1 {
    flex: 1;
  }
  .center-div-2 {
    flex: 2;
  }
}
.title {
  font-size: 18px;
  margin-top: 10px;
  margin-left: 20px;
  font-weight: bold;
}
.bottom {
  // .common {
  //   background-color: #fff;
  //   height: 480px;
  //   display: flex;
  //   flex-direction: column;
  // }
  .bottom-div-2 {
    flex: 2;
  }
  .bottom-div-1 {
    flex: 1;
    margin-left: 10px;
  }
}
.model {
  flex-direction: column;
  background-color: #fff;
  align-items: start;
  flex: 2;
  height: 100%;
  widows: 100%;
  margin-right: 10px;
}
.common {
  background-color: #fff;
  height: 480px;
  display: flex;
  flex-direction: column;
}
/deep/ .el-table--border {
  border-radius: 10px;
}
</style>