zzq
2023-09-27 8a668aeb3faa31d68dc2987204a372ad32f7b4f7
src/components/makepager/TableCommonView.vue
@@ -1,6 +1,9 @@
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
<template>
  <div :class="{'table-view':true,'table_height':!showSummary}" v-loading="loading">
  <div
    :class="{ 'table-view': true, table_height: !showSummary }"
    v-loading="loading"
  >
    <el-table
      ref="table"
      border
@@ -178,10 +181,10 @@
      type: Boolean,
      default: true,
    },
    showSummary:{
      type:Boolean,
      default:false
    }
    showSummary: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
@@ -252,52 +255,54 @@
    },
    //求和
    getSummaries(param) {
      if(this.tableList.countcol&&this.tableList.countcol.length>0){
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = " ";
          return;
        }
        this.tableList.countcol.forEach((countcols,idx) => {
          if (column.label === countcols) {
            const values = data.map((item) => Number(item[column.property]));
            if (!values.every((value) => isNaN(value))) {
              sums[index] = values.reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                  return prev + curr;
                } else {
                  return prev;
                }
              }, 0);
              sums[index] = sums[index].toLocaleString();
              // console.log(sums,"sums")
            } else {
              sums[index] = "";
            }
          } else {
      if (this.tableList.countcol && this.tableList.countcol.length > 0) {
        const { columns, data } = param;
        const sums = [];
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = " ";
            return;
          }
          this.tableList.countcol.forEach((countcols) => {
            if (column.label === countcols) {
              const values = data.map((item) => Number(item[column.property]));
              if (!values.every((value) => isNaN(value))) {
                sums[index] = values.reduce((prev, curr) => {
                  const value = Number(curr);
                  if (!isNaN(value)) {
                    return prev + curr;
                  } else {
                    return prev;
                  }
                }, 0);
                sums[index] =
                  this.tableList.tableColumn[index - 1].unit + "" + sums[index];
              } else {
                sums[index] = "";
              }
            } else {
              return;
            }
          });
        });
      });
      return sums;
      }else{
        return sums;
      }
    },
  },
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.table_height{
.table_height {
  height: 100%;
}
.el-table__body-wrapper{
  height: 100%;
}
.table-view {
  position: relative;
  height: 100%;
  .blue {
    width: 70px;
    text-align: center;
@@ -375,9 +380,8 @@
    border-top-right-radius: 12px;
    overflow: auto;
  }
  .el-table__body-wrapper{
  .el-table__body-wrapper {
    // height: ;
  }
}
</style>