<template>
  <div class="dashboard-container">
    <!-- 首页 -->
    <div>
      <orgTree style="float:left" @selectItem="selectItem" @defaultSite="defaultSite"/>
      <div class="ml300">
        <type :type="type" :curInfo="curInfo" />
      </div>
    </div>

  </div>
</template>

<script>
import { treeBaseInfo } from './api'
import orgTree from '@/components/orgTree.vue'
import Type from './components/index.vue'

export default {
  name: 'Dashboard',
  data() {
    return {
      type: 1,
      curInfo: {}
    }
  },
  components: {
    orgTree,
    Type,
  },
  computed: {
  },
  mounted() {
    // this.defaultSite()
    // this.getDetailNode(30)
  },
  methods: {
    defaultSite(data){
   this.getDetailNode(data)
    },
    selectItem(data) {
      this.type = data.type
      this.getDetailNode(data.id)
    }, 
    getDetailNode(data) {
      let param = {
        type: this.type,
        id: data
      }
      treeBaseInfo(param).then(res => {
        let controlLimit = res.controlLimit || []
        if(controlLimit) {
          controlLimit.map(item => {
            res[`type${item.type}`]= item.sum
          })
        }
        this.curInfo = res
        console.log(res);
      })
    },
  }
}

</script>

<style lang="scss" scoped>
.header_title {
  font-size: 23px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  line-height: 40px;
  text-align: center;
  color: #0058ff;
  letter-spacing: 5px;
  opacity: 1;
  margin-bottom: 20px;
}
::v-deep.el-card {
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  min-height: 243px;
  .el-card__header {
    font-size: 18px;
    color: #333333;
    font-weight: 500;
    text-align: center;
    background: rgba(226, 235, 255, 0.39);
    opacity: 1;
  }
  .el-card__body {
    padding: 0px;
  }
}
.posa {
  position: relative;
}
.savebtn {
  position: absolute;
  right: 2%;
}
// .el-col {
//   margin-bottom: 20px;
// }
.text {
  // display: flex;
  padding: 10px 20px 10px 20px;
  border-bottom: 1px solid #e3e3e3;
  &:last-child {
    border-bottom: none;
  }
  .item_name,
  .item_data,
  .value_handle {
    height: 16px;
    line-height: 16px;
    margin-top: 12px;
    margin-bottom: 12px;
  }
  .item_name {
    width: 262px;
    height: 16px;
    line-height: 16px;
    color: #7e7e7e;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .item_data {
  }
  .value_handle {
    color: red;
    margin-right: 10px;
  }
  .alarmbtn {
    margin-top: 6px;
    margin-bottom: 6px;
  }
  .el-card:last-child .text {
    border-bottom: none !important;
  }
}
.text2 {
  // display: flex;
  padding: 10px 20px 10px 20px;
  border-bottom: 1px solid #e3e3e3;
  .item_name,
  .item_data,
  .value_handle {
    height: 16px;
    line-height: 16px;
    margin-top: 12px;
    margin-bottom: 12px;
  }
  .item_name {
    width: 262px;
    height: 16px;
    line-height: 16px;
    color: #7e7e7e;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .item_data {
  }
  .value_handle {
    color: red;
    margin-right: 10px;
    min-width: 52px;
  }
  .alarmbtn {
    margin-top: 6px;
    margin-bottom: 6px;
  }
  .el-card:last-child .text {
    border-bottom: none !important;
  }
}
</style>
