<script>
import _ from 'lodash'
export default {
  data() {
    return {
      dataLoading: true,
      sysInfo: []
    }
  },
  computed: {
    showData() {
      let arr = _.filter(this.sysInfo, function(item) {
        return _.includes(['应用信息', '数据库信息', '基础软件信息'], item.title)
      })
      if (arr.length === 3) {
        [arr[1], arr[2]] = [arr[2], arr[1]]
      }
      arr = _.forEach(arr, function(item) {
        item.data = _.filter(item.data, function(value, index, collection) {
          if (item.title === '基础软件信息') {
            return _.includes([0, 1, 3, 4], index)
          } else {
            return index < 4
          }
        })
      })
      return arr
    }
  },
  created() {
    this.init()
  },
  methods: {
    async init() {
      this.dataLoading = true
      let resp = await axios.get('/ui/info')
      if (resp.data.status === 1) {
        let sysInfo = resp.data.data
        this.sysInfo = [sysInfo.appInfo, sysInfo.dbInfo, sysInfo.envInfo, sysInfo.licenseInfo]
      }
      this.dataLoading = false
    }
  }
}
</script>
<template>
    <div class="sysinfo-list" v-loading="dataLoading">
      <div class="sysinfo-item" :class="'sysinfo-item-'+sIndex" v-for="(sysitem,sIndex) in showData" :key="sIndex">
        <h4 v-text="sysitem.title"></h4>
        <dl v-for="(valueItem,vIndex) in sysitem.data" :key="vIndex"><dt>{{valueItem.item}}：</dt><dd>{{valueItem.value}}</dd></dl>
        <div class="point"></div>
      </div>
    </div>
</template>
<style scoped>
  .sysinfo-list{
    width: 100%;
    min-height:420px;
    position:relative;
    margin-bottom: -30px;
  }
  .sysinfo-list:before{
    content:'';
    top:50%;
    left:0;
    position:absolute;
    width:100%;
    height:1px;
    background: #DCDCDC;

  }
  .sysinfo-item{
    position:absolute;
    width:40%;
    height:50%;
  }
  .point{
    position: absolute;
    left:50%;
    bottom:0;
    margin-bottom:-5px;
    width:11px;
    height:35px;
  }
  .point:before{
    width:1px;
    height:25px;
    position:absolute;
    display: block;
    content:'';
    background:#ddd;
    left:5px;
  }
  .point:after{
    width:5px;
    height:5px;
    display:block;
    box-sizing: content-box;
    content:'';
    position: absolute;
    left:0;
    bottom:0;
    border:solid 1px #fff;
    box-sizing: 0 0 3px #ddd;
    border-radius:50%;
    background:#444;
    border:solid 3px #D2D2D2;

  }
  .sysinfo-item-0,.sysinfo-item-2 {
    left: 0;
    top:0;
    padding-top:30px;
    padding-left: 20px;
    border: solid 1px #eee;
    background-color: #fff;
    border-bottom: none;
  }
  .sysinfo-item-1 {
    left: 30%;
    bottom:0;
    padding-top:45px;
    border: solid 1px #eee;
    background-color: #fff;
  }
  .sysinfo-item:hover{
    border:solid 1px #ddd;
    box-shadow: 0 -8px 15px #ddd;
  }
  .sysinfo-item-1:hover{
    border-bottom:solid 1px #ddd;
    box-shadow: 0 6px 10px #ddd;
  }
  .sysinfo-item-1 .point{
    top:-5px;
    bottom:auto;

  }
  .sysinfo-item-1 .point:after{
    top:0;
    bottom:auto;
  }
  .sysinfo-item-1 .point:before{
    top:auto;
    bottom:0;
  }
  .sysinfo-item:hover .point:after{
    background:#28B06E;
    border:solid 3px #FFF;
    box-shadow: 0 0 3px #28B06E;
  }
  .sysinfo-item:hover .point:before{
    background:#28B06E
  }
  .sysinfo-item:hover h4{
    color:#28B06E
  }
  .sysinfo-item-2 {
    left: 60%;
  }
  .sysinfo-item h4{
    font-size:16px;
    font-weight:bold;
    text-align: center;
    margin-bottom:20px;
  }
  .sysinfo-item dt,.sysinfo-item dd{
    display: inline-block;
    vertical-align: middle;
  }
  .sysinfo-item dt{
    font-weight: normal;
    width:10em;
    text-align: right
  }
  .sysinfo-item dd{
    color: #242;
  }
</style>
