<template>
  <div>
    <p align="center">汇总表</p>
    <div style="margin-top:3%;text-align: center;overflow-x: auto; overflow-y: auto; height: 80%;width: 100%">
      <table border="1px dashed #000" v-model="datapool">
        <!--<tr>-->
        <!--<td v-for="name in listname ">{{name}}</td>-->
        <!--</tr>-->
        <tr v-for="date in datapool" style="width: 200px" align="center">
          <td v-for="i in date" style="width: 100px;" align="center">{{i}}</td>
        </tr>
      </table>
    </div>
  </div>
</template>
<script>


  export default {
    name: 'DrillPool',
    props: {
      pooldata: Array,

    },
    // props: ['total', 'condition', 'startdate', 'enddate'],
    data() {
      return {
        model: [],
        detailcondition: '', //钻取的字段对应的值
        barparam: '',
        echarts: false,
        listname: [],
        datapool: [],
      }
    },
    methods: {
      cloumnname() {
        let arrparams = this.$parent.childdate
        let namedate = []
        var s = 0
        console.log(this.$parent.childdate, '测试点汇总数据')
        for (var i = 0; i < arrparams.length; i++) {
          console.log(arrparams[i][0], '测试点名称')
          var s = 0
          for (var pi in arrparams[i][0]) {
            if (i == 0 && s == 0) {
              namedate.push()
            }
            if (s != 0) {
              if (arrparams[i][0].hasOwnProperty(pi)) {
                namedate.push(pi)
              }
            }
            s++
          }

        }

        this.listname = namedate
        console.log(namedate, '显示汇总表头')
      },
      pooldataearn() {

        let a = this.$parent.childdate
        let c = []
        for (var j = 0; j < a[0].length; j++) {
          let aa = {}
          var l = 0
          for (var i = 0; i < a.length; i++) {
            if (i == 0) {
              aa[l] = a[i][j].name
              l++
              aa[l] = a[i][j].value
            } else {
              aa[l] = a[i][j].value
            }
            l++
          }
          c.push(aa)
        }
        this.$parent.datapool = c
        console.log(this.$parent.datapool, '汇总数据')
      }
    },
    computed: {},
    watch: {
      'pooldata': {
        deep: true,
        handler(val) {
          console.log(this.pooldata, '汇总数据展示')
          let pool = this.pooldata
          pool.forEach(function (s) {
            delete s.drilltype
          })
          this.datapool = pool
          // this.cloumnname()
          // this.pooldataearn()
        }
      },
    },
    ready() {

    }
  }
</script>
<style scoped>
  table {
    margin: auto
  }

  td {
    padding: 4% 0%;
    border: solid 1px #6fd9d0;
    height: 20%;
    width: 20%;
    color: #ffffff;
  }

  td:nth-child(odd) {
    color: #06ecd8;
    background-color: #013e48;
    border: solid 1px #6fd9d0;
  }

  p {
    color: #ffffff;
    font-size: 20px;
  }
</style>
