<template>
    <div class="test">
        <StructureTable
            :selectData="selectData"
            :tableHead="tableHead"
            :tableBody="tableBody"
            :weekShow="true"
            :labelName="'名称'"
            :getWeekData="getWeekData"
        >
            
        </StructureTable>
    </div>
</template>

<script>
import components from '../../components/index'
export default {
  data(){
      return{
          selectData:[
              {
                  label:'点赞数',
                  value:'likeNumber',
                  mergeType: 'add',
                  showType: 'number',
              },
              {
                  label:'好评率',
                  value:'commentNumber',
                  mergeType: 'average',
                  showType: 'percent',
                  selected:true
              }
          ],
          tableHead:['2017-11', '2017-12', '2018-01', '2018-02'],
          tableBody:[
              {
                  name:'行1',
                  '2017-11':{
                      likeNumber:12323,
                      commentNumber:0.7
                  },
                  '2017-12':{
                      likeNumber:8323,
                      commentNumber:0.8
                  }
              },
              {
                  name:'行2',
                  '2018-01':{
                      likeNumber:6323,
                      commentNumber:0.9
                  },
                  '2018-02':{
                      likeNumber:6323,
                      commentNumber:0.6
                  }
              },
              {
                  name:'行3',
                  '2017-11':{
                      likeNumber:7323,
                      commentNumber:0.8
                  },
                  '2017-12':{
                      likeNumber:5323,
                      commentNumber:0.65
                  }
              }
          ]
      }
  },
  components,
  methods: {
      getWeekData(cb){
          setTimeout(() => {
              let tableHead = ['2018-01-07','2018-01-14','2018-01-21'];
              let tableBody = [
                  {
                      name: '行1',
                    '2018-01-07':{
                        likeNumber:12323,
                        commentNumber:0.7
                    },
                    '2018-01-14':{
                        likeNumber:8323,
                        commentNumber:0.8
                    },
                    '2018-01-21':{
                        likeNumber:12323,
                        commentNumber:0.7
                    }
                  }
              ]
              cb(tableHead, tableBody);
          },2000)
      }
  }
}
</script>

<style scoped>
.test{
    width: 100%;
    height: 500px;
    position: relative;
}
</style>

