<template>
  <!-- 仓储设备投资建设上报 -->
  <div class="content-main">
    <span class="spanStyle">仓储设备投资建设统计表</span>
    <span class="spanStyleRight">单位：万元、个、把、台</span>
    <el-table :data="tableData" style="width: 100%;" row-key="name" border default-expand-all
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
      <el-table-column style="text-align: left!important;" prop="name" align="left" label=""></el-table-column>
      <el-table-column prop="grsl" label="购入数量" align="center"></el-table-column>
      <el-table-column prop="hj" label="合计" align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
  import { queryCcsbtzjsmx,saveCcsbtzjsmx,queryCcsbtzjsmxForHz,queryCcsbtzjsmxForHzExport } from '@/api/zgsq/ccsbtzmx'
  export default {
    data() {
      return {
        nf: '',
        tableData: []
      }
    },
    created() {
      // this.getTableData();
    },
    methods: {
      // 报表数据
      init(data,type) {
        queryCcsbtzjsmxForHz(data).then(res =>{
            if(res.infoCode == 200){
              this.tableData=res.data
              // this.ccsjList=res.data[3].ccsjList
            }
        })

        // 模拟数据
        // this.tableData = [{"id":"1","lx":"按设备类型分","grsl":7,"hj":2.4,"children":[{"id":"11","lx":"粮食设备","grsl":3,"hj":1.4},{"id":"12","lx":"仓储器材","grsl":3,"hj":1}]},{"id":"2","lx":"按设备器材类别分","grsl":7,"hj":2.4,"children":[{"id":"22","lx":" 按粮食设备类别分","grsl":3,"hj":2.4,"children":[{"id":"222","lx":" 粮油通用机械设备","grsl":3,"hj":1.4,"children":[{"id":"2222","lx":" 网带出清筛","grsl":2,"hj":1},{"id":"2223","lx":" 圆筒出清筛","grsl":1,"hj":0.4}]}]}]},{"id":"3","lx":"合计","grsl":7,"hj":2.4}];
      },
	  exportExcel(data){
		  queryCcsbtzjsmxForHzExport(data).then(res => {
		      let blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
		  	const link = document.createElement('a');
		  	link.style.display = 'none';
		  	link.href = URL.createObjectURL(blob);
		  	link.setAttribute('download', '仓储设备投资建设统计表');
		  	document.body.appendChild(link);
		  	link.click();
		  	document.body.removeChild(link);
		  }).catch((err) => {
		      this.$message.error(err);
		  });
	  },
    }
  }
</script>

<style scoped>
  .spanStyle {
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .spanStyleRight {
    display: flex;
    justify-content: right;
    align-items: right;
  }
</style>
<style>
	.el-table td.is-left, .el-table th.is-left{
		  text-align: left!important;
	} 
</style>
