zhangxiaoxu123
2022-09-14 77536cfa95b1e3c5e60f94dce3a53aa2e93f121a
src/pages/show/shehuiBaozhang/shehuiBaozhangChildren/shebaoShouzhiZongbiao.vue
@@ -3,111 +3,268 @@
    <div class="shebaoShouzhiZongbiao-table">
      <h1>社会保障基金统计表</h1>
      <el-table
        :cell-style="handleCellStyle"
        :max-height="tableHeight"
        :data="tableData"
        :cell-style="handleCellStyle"
        style="width: 100%">
        <template v-for="(item,index) in headerArry">
        <!--<template v-for="(item,index) in headerArry">
          <template v-if="index == 0">
            <el-table-column
              align="center"
              :prop="item.name"
              :prop="item.item"
              label="项目"
              fixed>
              <template slot-scope="scope">
                <span :class="[Number(item.taxesIncome) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.name}}</span>
                <span style="margin-left: 10px">{{scope.row.item}}</span>
              </template>
            </el-table-column>
            <template v-for="(e,i) in item.dataList">
              <el-table-column :label="e.month" align="center">
                <el-table-column
                  align="center"
                  label="总收入">
                  <template slot-scope="scope">
                    <template>
                      <template>
                        <span :class="[Number(e.taxesIncome) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{scope.row.dataList[0].totalIncome}}</span>
                      </template>
                    </template>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  label="征集收入">
                  <template slot-scope="scope">
                    <span :class="[Number(e.taxesIncome) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{scope.row.dataList[0].taxesIncome}}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  label="本月支出">
                  <template slot-scope="scope">
                    <span :class="[Number(e.pay) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{scope.row.dataList[0].pay}}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  label="本月结余">
                  <template slot-scope="scope">
                    <span :class="[Number(e.balance) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{scope.row.dataList[0].balance}}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </template>
            <template>
              <el-table-column
                align="center"
                :prop="item.surplus"
                label="累计结余">
                <template slot-scope="scope">
                  <span :class="[Number(item.surplus) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.surplus}}</span>
                </template>
              </el-table-column>
            </template>
          </template>
          <el-table-column :label="item.month" align="center">
            <el-table-column
              align="center"
              label="总收入">
              <template slot-scope="scope">
                <span :class="[Number(item.totalIncome) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.totalIncome}}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="征集收入">
              <template slot-scope="scope">
                <span :class="[Number(item.taxesIncome) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.taxesIncome}}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="本月支出">
              <template slot-scope="scope">
                <span :class="[Number(item.pay) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.pay}}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="本月结余">
              <template slot-scope="scope">
                <span :class="[Number(item.balance) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.balance}}</span>
              </template>
            </el-table-column>
        </template>-->
        <el-table-column
          width="260"
          align="center"
          prop="item"
          label="项目">
        </el-table-column>
        <el-table-column v-if="tableData[0]" :label="tableData[0].month1" align="center">
          <el-table-column
            align="center"
            label="总收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.totalIncome1) < 0 ? 'fontColorRed' : ''">{{scope.row.totalIncome1}}</span>
            </template>
          </el-table-column>
          <template v-if="index == headerArry.length - 1">
            <el-table-column
              align="center"
              :prop="item.surplus"
              label="累计结余">
              <template slot-scope="scope">
                <span :class="[Number(item.surplus) < 0 ? 'fontColorRed' : '']" style="margin-left: 10px">{{item.surplus}}</span>
              </template>
            </el-table-column>
          <el-table-column
            align="center"
            prop="taxesIncome1"
            label="征集收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.taxesIncome1) < 0 ? 'fontColorRed' : ''">{{scope.row.taxesIncome1}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="pay1"
            label="本月支出">
            <template slot-scope="scope">
              <span :class="Number(scope.row.pay1) < 0 ? 'fontColorRed' : ''">{{scope.row.pay1}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="balance1"
            label="本月结余">
            <template slot-scope="scope">
              <span :class="Number(scope.row.balance1) < 0 ? 'fontColorRed' : ''">{{scope.row.balance1}}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column v-if="tableData[0]" :label="tableData[0].month2" align="center">
          <el-table-column
            align="center"
            prop="totalIncome2"
            label="总收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.totalIncome2) < 0 ? 'fontColorRed' : ''">{{scope.row.totalIncome2}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="taxesIncome2"
            label="征集收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.taxesIncome2) < 0 ? 'fontColorRed' : ''">{{scope.row.taxesIncome2}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="pay2"
            label="本月支出">
            <template slot-scope="scope">
              <span :class="Number(scope.row.pay2) < 0 ? 'fontColorRed' : ''">{{scope.row.pay2}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="balance2"
            label="本月结余">
            <template slot-scope="scope">
              <span :class="Number(scope.row.balance2) < 0 ? 'fontColorRed' : ''">{{scope.row.balance2}}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column v-if="tableData[0]" :label="tableData[0].month3" align="center">
          <el-table-column
            align="center"
            prop="totalIncome3"
            label="总收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.totalIncome3) < 0 ? 'fontColorRed' : ''">{{scope.row.totalIncome3}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="taxesIncome3"
            label="征集收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.taxesIncome3) < 0 ? 'fontColorRed' : ''">{{scope.row.taxesIncome3}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="pay3"
            label="本月支出">
            <template slot-scope="scope">
              <span :class="Number(scope.row.pay3) < 0 ? 'fontColorRed' : ''">{{scope.row.pay3}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="balance3"
            label="本月结余">
            <template slot-scope="scope">
              <span :class="Number(scope.row.balance3) < 0 ? 'fontColorRed' : ''">{{scope.row.balance3}}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column v-if="tableData[0]" :label="tableData[0].month4" align="center">
          <el-table-column
            align="center"
            prop="totalIncome4"
            label="总收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.totalIncome4) < 0 ? 'fontColorRed' : ''">{{scope.row.totalIncome4}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="taxesIncome4"
            label="征集收入">
            <template slot-scope="scope">
              <span :class="Number(scope.row.taxesIncome4) < 0 ? 'fontColorRed' : ''">{{scope.row.taxesIncome4}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="pay4"
            label="本月支出">
            <template slot-scope="scope">
              <span :class="Number(scope.row.pay4) < 0 ? 'fontColorRed' : ''">{{scope.row.pay4}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="balance4"
            label="本月结余">
            <template slot-scope="scope">
              <span :class="Number(scope.row.balance4) < 0 ? 'fontColorRed' : ''">{{scope.row.balance4}}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          align="center"
          prop="surplus"
          label="累计结余">
          <template slot-scope="scope">
            <span :class="Number(scope.row.surplus) < 0 ? 'fontColorRed' : ''">{{scope.row.surplus}}</span>
          </template>
        </template>
        </el-table-column>
      </el-table>
      <div class="shebaoShouzhiZongbiaoEcharts" id="shebaoShouzhiZongbiaoEcharts"></div>
      <div v-show="echartsShow" class="shebaoShouzhiZongbiaoEcharts" id="shebaoShouzhiZongbiaoEcharts"></div>
      <div class="yincang-box">
        <el-button @click="showEchartsBtn" v-show="echartsShow" type="primary">隐藏</el-button>
        <el-button @click="showEchartsBtn" v-show="!echartsShow" type="primary">显示</el-button>
      </div>
    </div>
  </div>
</template>
<script>
  import nowSize from "../../../../libs/nowSize";
  import {getStatisticsTable} from '@/api/shehuiBaozhang'
  import {getStatisticsTable,getStatisticsChart } from '@/api/shehuiBaozhang'
  import index from "../../index/index";
export default {
  name: "shebaoShouzhiZongbiao",
  data() {
    return {
      tableHead:[],
      tableData:[],
      headerArry:[]
      headerArry:{},
      echartsSeries:{},
      tableHeight: window.innerHeight - nowSize(960),
        echartsShow: true
    }
  },
  mounted() {
      this.getStatisticsTable()
     this.shebaoShouzhiZongbiaoEcharts()
     this.getStatisticsChart()
  },
  methods: {
      showEchartsBtn() {
          this.echartsShow = !this.echartsShow
          if(this.echartsShow) {
              this.tableHeight = window.innerHeight - nowSize(960)
          }else {
              this.tableHeight = window.innerHeight - nowSize(320)
          }
      },
      getStatisticsTable() {
          getStatisticsTable().then(res => {
              if(res.code == 1000) {
                  this.tableData = res.list
                  this.getData()
                  res.list.forEach((item,index) => {
                      if(index == 0) {
                          this.headerArry = item
                          console.log(this.headerArry,'this.headerArry====')
                      }
                  })
              }
          })
      },
      getData() {
          let row = []
          this.tableData.forEach((e,index) => {
              e.dataList.forEach((c,i) => {
                  if(index == 0) {
                      row.push({
                          name: e.item,
                          "month": c.month ,
                          "totalIncome": c.totalIncome,
                          "taxesIncome": c.taxesIncome,
                          "pay": c.pay,
                          "balance": c.balance,
                          "surplus": c.surplus || null
                      })
                  }
              })
              this.headerArry = row
              console.log(this.headerArry)
          })
      },
      shebaoShouzhiZongbiaoEcharts() {
@@ -142,13 +299,13 @@
                  top: '15%',
                  left: '4%',
                  right: '18%',
                  bottom: '3%',
                  bottom: '9%',
                  containLabel: true
              },
              xAxis: {
                  type: 'category',
                  boundaryGap: false,
                  data: ['2021/4', '2021/5', '2021/6', '2021/7', '2021/8', '2021/9', '2021/10'],
                  data: this.echartsSeries.years,
                  axisLabel: {
                      show: true,
                      textStyle: {
@@ -191,22 +348,22 @@
                  {
                      name: '年累计总收入',
                      type: 'line',
                      data: [370, 332, 401, 534, 490, 530, 910]
                      data: this.echartsSeries.income
                  },
                  {
                      name: '年累计支出',
                      type: 'line',
                      data: [220, 182, 191, 234, 290, 330, 310]
                      data: this.echartsSeries.pay
                  },
                  {
                      name: '年累计征缴收入',
                      type: 'line',
                      data: [150, 132, 201, 154, 190, 330, 410]
                      data: this.echartsSeries.taxes
                  },
                  {
                      name: '年累计结余',
                      type: 'line',
                      data: [350, 112, 209, 164, 290, 310, 400]
                      data:this.echartsSeries.balance
                  }
              ]
          };
@@ -215,11 +372,20 @@
              myEchart.resize()
          })
      },
      handleCellStyle({rowIndex, columnIndex}) {
      handleCellStyle({row, column, rowIndex, columnIndex}) {
          if(columnIndex == 0) {
              return { background:'#51D2FF' }
          }
      },
    //35. 查询历年社保基金数据分析图数据接口
    getStatisticsChart() {
      getStatisticsChart().then(res => {
        if(res.code ===1000){
          this.echartsSeries = res.obj
          this.shebaoShouzhiZongbiaoEcharts()
        }
      })
    }
  }
}
</script>
@@ -304,4 +470,12 @@
    height: calc(100% - 640px - 0.33203125rem  /* 85/256 */);
  }
}
.shebaoShouzhiZongbiao-table{
  position: relative;
  .yincang-box{
    position: absolute;
    right: 0.078125rem  /* 20/256 */;
    bottom: 0.078125rem  /* 20/256 */;
  }
}
</style>