ActivityTable.vue 5.4 KB
<template>
  <div>
    <el-table :data="tableData" style="width: 100%" :header-cell-style="{ color: '#ffffff', fontSize: '12px', height: '4.44vh', background: '#244888' }" :row-class-name="tableRowClassName">
      <el-table-column label="序号" width="80">
        <template slot-scope="scope">
          {{ curPageSize * (currentPage - 1) + (scope.$index + 1) }}
        </template>
      </el-table-column>
      <el-table-column prop="activityName" label="活动名称" width="300"></el-table-column>
      <el-table-column prop="startTime" label="活动时间" width="240"></el-table-column>
      <el-table-column prop="goodsCategory" label="品类"></el-table-column>
      <el-table-column prop="outputvalue" label="产值">
        <template slot-scope="scope">
          {{ numAddSymbol(scope.row.outputvalue) }}
        </template>
      </el-table-column>
      <el-table-column prop="browseCount" label="浏览量">
        <template slot-scope="scope">
          {{ numAddSymbol(scope.row.browseCount) }}
        </template>
      </el-table-column>
      <el-table-column prop="shareCount" label="分享次数">
        <template slot-scope="scope">
          {{ numAddSymbol(scope.row.shareCount) }}
        </template>
      </el-table-column>
      <el-table-column prop="orderCount" label="订单量">
        <template slot-scope="scope">
          {{ numAddSymbol(scope.row.orderCount) }}
        </template>
      </el-table-column>
      <el-table-column prop="transRate" label="转化率">
        <template slot-scope="scope">
          {{ toPercent(scope.row.transRate) }}
        </template>
      </el-table-column>
      <el-table-column prop="perCusTrans" label="客单价">
        <template slot-scope="scope">
          {{ numAddSymbol(scope.row.perCusTrans) }}
        </template>
      </el-table-column>
      <el-table-column prop="chargebackRate" label="退单率">
        <template slot-scope="scope">
          {{ toPercent(scope.row.chargebackRate) }}
        </template>
      </el-table-column>
      <template slot="empty">
        <div class="empty">
          <Empty></Empty>
        </div>
      </template>
    </el-table>
    <el-pagination
      class="pagination-box"
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="curPageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="dataTotal"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  name: 'ActivityTable',
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    dataTotal: Number
  },
  data() {
    return {
      currentPage: 1,
      curPageSize: 10
    }
  },

  mounted() {},

  methods: {
    tableRowClassName({ rowIndex }) {
      if (rowIndex % 2 === 0) {
        return 'usual-row'
      } else if (rowIndex % 2 === 1) {
        return 'warning-row'
      }
    },
    handleSizeChange(e) {
      this.curPageSize = e
      this.$emit('sizeChange', e)
    },
    handleCurrentChange(e) {
      this.currentPage = e
      this.$emit('pageChange', e)
    }
  }
}
</script>

<style lang="scss">
.el-table {
  font-weight: 400;
  font-size: 12px;
  text-align: center;
  thead {
    height: 4.44vh;
    background: #244888;
    color: #ffffff;
  }
  tbody tr {
    height: 5.33vh;
    color: #cccccc;
  }
}
.el-table__body-wrapper {
  max-height: 52vh;
  overflow-y: scroll;
}
.el-table tr {
  background-color: transparent;
}
.el-table .el-table__cell {
  padding: 0 !important;
}
.el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: transparent !important;
}
.el-table--enable-row-hover .el-table__body tr:hover {
  background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%) !important;
  font-weight: 500;
  color: #ffffff;
}
.pagination-box {
  margin-top: 1.78vh;
}
.el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: transparent;
  background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
  color: #fff;
}
.el-pagination.is-background .btn-next,
.el-pagination.is-background .btn-prev,
.el-pagination.is-background .el-pager li {
  background-color: #072545;
  color: #c9c9c9;
}
.el-pagination__total,
.el-pagination__jump {
  color: #c9c9c9;
}
.el-pagination .el-input__inner {
  color: #c9c9c9;
  background: #051526;
  border: 2px solid;
  border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
}
.el-table td.el-table__cell,
.el-table th.el-table__cell.is-leaf {
  border-bottom: none;
}
.el-table--border::after,
.el-table--group::after,
.el-table::before {
  content: '';
  position: absolute;
  background-color: transparent;
  z-index: 1;
}
.el-scrollbar {
  .el-scrollbar__wrap {
    margin-bottom: -15px !important;
  }
}
.el-select-dropdown {
  border-radius: 0;
  background: #051526;
  border: 2px solid;
  border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
}
.el-select-dropdown__item {
  color: #c9c9c9;
  font-size: 14px;
}
.el-select-dropdown__item.selected {
  color: #ffffff;
  font-weight: 500;
}
.el-select-dropdown__item.hover,
.el-select-dropdown__item:hover {
  background-color: #072545;
}
.el-table__empty-block {
  background-color: #051526;
}
.el-table .cell {
  line-height: 1vw;
}
.usual-row {
  background: #051526 !important;
}
.warning-row {
  background: #072545 !important;
}
</style>

<style lang="scss" scoped>
.empty {
  margin: 15vh 0;
}
</style>