zoukankan      html  css  js  c++  java
  • 处理后台数据list [ { list[ ] } ],分页

    <!-- 负荷统计  2-->
    <template>
      <div id="electricityMonitoring">
        <!-- 每台变压器平均功率因数 -->
        <searchForm :formConfig="formConfig" ref="tbword_ref" :value="getDataform"></searchForm>
        <el-table class="tableClass" :data="tableList" style=" 100%;height:calc(100% - 100px)" height="calc(100% - 100px)">
          <el-table-column prop="tci_name" label="企业名称" align="center" width="150"></el-table-column>
          <el-table-column label="每台变压器平均功率因数" align="center">
            <el-table-column v-for="item in trMaxLength" :key="item" :prop="'a' + (item - 1)" :label="item + '#'" width="120" align="center"></el-table-column>
          </el-table-column>
          <el-table-column label="合计平均功率因数" prop="sum" align="center" width="200"></el-table-column>
        </el-table>
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="getDataform.pageNum"
          :page-sizes="[15, 30, 50, 100]"
          :page-size="getDataform.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </template>
    
    <script>
    import searchForm from '@searchForm';
    import hjTable from '@hjTable';
    import { factoryInfoList, getCustomer } from '../../../assets/js/customer.js';
    
    export default {
      components: {
        hjTable,
        searchForm
      },
      data() {
        return {
          currentPage: 1,
          loading: true,
          getDataform: {
            pageNum: 1,
            pageSize: 15,
            checkId: 10
          },
          tableList: [],
          trMaxLength: 0,
          total: 0,
          formConfig: {
            inline: true,
            formItemList: [
              {
                type: 'select',
                prop: 'a1',
                placeholder: '请选择园区',
                optName: 'tfi_name',
                optId: 'tfi_id',
                changeFun: this.getCustomer(),
                optList: [],
                style: {
                   '100%'
                }
              },
              {
                type: 'select',
                prop: 'a3',
                placeholder: '请选择企业名',
                optName: 'tci_name',
                optId: 'tci_id',
                optList: [],
                style: {
                   '100%'
                }
              },
              {
                type: 'button',
                operate: [
                  {
                    type: 'primary',
                    marginRight: '10px',
                    style: {
                      marginRight: '10px'
                    },
                    name: '查询',
                    notHasPerm: true,
                    handleClick: this.getData
                  }
                ]
              }
            ]
          }
        };
      },
      created() {
        this.getData();
        factoryInfoList().then(res => {
          this.formConfig.formItemList[0].optList = res;
        });
        getCustomer().then(res => {
          this.formConfig.formItemList[1].optList = res;
        });
      },
      methods: {
        // 获取客户id
        getCustomer(id) {
          getCustomer(id).then(res => {
            this.formConfig.formItemList[1].optList = res;
          });
        },
        handleSizeChange(val) {
          this.getDataform.pageSize = val;
          this.getData();
        },
        handleCurrentChange(val) {
          this.getDataform.pageNum = val;
          this.getData();
        },
        getData() {
          let that = this;
          this.$post('/tbCustomerAmmeterInfo/getCheckValueByCustomerIds', that.getDataform)
            .then(res => {
              if (res.code == 100) {
                that.total = res.data.total;
                let listData = res.data.list;
                let trMaxLength = 0;
                let sum = 0;
                for (let i = 0; i < listData.length; i++) { // 外层list
                  sum = 0;
                  trMaxLength = Math.max(trMaxLength, listData[i].list.length);// 获取内层list[]的最大长度
                  // 内层list
                  for (let j = 0; j < listData[i].list.length; j++) {
                    sum += listData[i].list[j].tads_last_value; // 合计平均功率因数
                    this.$set(listData[i], 'a' + j, listData[i].list[j].tcgp_name);
                  }
                  this.$set(listData[i], 'sum', sum.toFixed(2)); // sum.toFixed(2) 保留后两位小数
                }
                // console.log('*****************************************');
                console.log(listData);
                this.trMaxLength = trMaxLength;
                this.tableList = listData;
              } else {
                that.$message.warning(res.message);
              }
            })
            .catch(() => {});
        },
        changePage(currentPage) {
          this.getDataform.page = currentPage;
          this.getData();
        }
      }
    };
    </script>
    
    <style scope>
    #electricityMonitoring {
      height: 100%;
    }
    .DMClass {
      float: right;
      font-size: 16px;
      font-weight: 700px;
      letter-spacing: 30px;
      margin-bottom: 15px;
      margin-top: 15px;
    }
    .tableClass {
      overflow: hidden;
      overflow-y: auto;
      height: 100%;
    }
    </style>
    

      

  • 相关阅读:
    【小白学PyTorch】1 搭建一个超简单的网络
    【小白学PyTorch】2 浅谈训练集和测试集
    【小白学AI】GBDT梯度提升详解
    【小白学AI】XGBoost推导详解与牛顿法
    【小白写论文】技术性论文结构剖析
    小白学PyTorch 动态图与静态图的浅显理解
    【小白学推荐1】 协同过滤 零基础到入门
    【小白学AI】随机森林 全解 (从bagging到variance)
    OpenCV开发笔记(七十二):红胖子8分钟带你使用opencv+dnn+tensorFlow识别物体
    【python刷题】二叉搜索树-相关题目
  • 原文地址:https://www.cnblogs.com/sylys/p/13457231.html
Copyright © 2011-2022 走看看