el-tabel 行转列 横向显示

在这里插入图片描述

在这里插入图片描述

el-table 行转列

    <el-table border :data="transData">
              <el-table-column
                v-for="(item, index) in transTitle"
                :label="item"
                :key="index"
                align="center"
                :fixed="index===0"
                min-width="200"
              >
                <template slot-scope="scope">
                  <div class="cg_box" v-if="scope.row[index] == '推送成功'">
                    {{ scope.row[index] }}
                  </div>
                  <div
                    class="sb_box"
                    v-else-if="scope.row[index] == '推送失败'"
                  >
                    {{ scope.row[index] }}
                  </div>
                  <div v-else>
                    {{ scope.row[index] }}
                  </div>
                </template>
              </el-table-column>
            </el-table>
 data() {
    return {
      originData: [
        {
          phone: "18999888899",
          status: "推送成功",
          time: "2023-11-28 18:00:00"
        },
        {
          phone: "18999888899",
          status: "推送成功",
          time: "2023-11-28 18:00:00"
        },
        {
          phone: "18999888899",
          status: "推送失败",
          time: "2023-11-28 18:00:00"
        },
        {
          phone: "18999888899",
          status: "推送成功",
          time: "2023-11-28 18:00:00"
        },
        {
          phone: "18999888899",
          status: "推送成功",
          time: "2023-11-28 18:00:00"
        }
      ],
      originTitle: ["推送电话", "推送状态", "推送时间"],
      transTitle: [
        "推送人",
        "张三",
        "李四",
        "王五",
        "赵六六",
        "A",
        "B",
      ],
      transData: []
    };
  },
  created() {
    let matrixData = this.originData.map(row => {
      let arr = [];
      for (let key in row) {
        arr.push(row[key]);
      }
      return arr;
    });
    // 加入标题拼接最终的数据
    this.transData = matrixData[0].map((col, i) => {
      return [
        this.originTitle[i],
        ...matrixData.map(row => {
          return row[i];
        })
      ];
    });
  }
<style lang="scss" scoped>
.dia_box {
  padding: 0 70px;
  .title_box {
    width: 1227px;
    height: 59px;
    background: url(/img/kanban/aqyh/hz_title.png) no-repeat;
    background-size: 100% 100%;
    font-size: 20px;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    color: #ffe5da;
    text-align: center;
    line-height: 59px;
  }
  .content_box {
    padding: 0 39px;
    margin-top: 40px;
    .row_box {
      display: flex;
      align-items: center;
      margin-bottom: 27px;
      .label {
        font-size: 16px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        color: #e6f2ff;
      }
      .value {
        font-size: 16px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        color: #74ffc2;
      }
      .hj_box {
        width: 54px;
        height: 26px;
        border-radius: 2px;
        border: 1px solid #f43300;
        text-align: center;
        line-height: 22px;
        color: #ff9a7f;
        font-size: 15px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        background-color: #4a2e41;
      }
    }
    .bt_box {
      margin-top: 30px;
      margin-bottom: 28px;
      .title_v {
        font-size: 22px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        color: #e6f2ff;
      }
    }
    .cg_box {
      width: 76px;
      height: 24px;
      border-radius: 2px;
      border: 1px solid #00ffb0;
      background-color: #0e6385;
      font-size: 12px;
      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      color: #7fffc1;
      margin-left: 50%;
      transform: translate(-50%);


    }
    .sb_box {
      width: 76px;
      height: 24px;
      border-radius: 2px;
      border: 1px solid #f43300;
      background-color: #4a2e41;
      font-size: 12px;
      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      color: #ff9a7f;
      margin-left: 50%;
      transform: translate(-50%);

    }
  }
}

::v-deep .theme-turing .el-table th {
  background-color: #34afff !important;
}

::v-deep .el-table th {
  background: #04406f !important;
}

::v-deep .el-table--border {
  border: unset !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

::v-deep .el-table--border::after {
  width: 0 !important;
}

::v-deep .el-table--border td {
  border-color: #025781 !important;
}

::v-deep .el-table--border th {
  border: unset !important;
}

::v-deep tbody > tr > td {
  background: #052d57 !important;
}
::v-deep .el-table__empty-block {
  background-color: #081f40 !important;
}
</style>
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值