ranking.vue 5.05 KB
<template>
  <div v-if="show" class="rank-container">
    <div class="page_title">门店产值排名</div>
    <div class="tipper flex_scb">
      <div class="tip_text">
        <span>共</span>
        <sapn style="color: #5850ff">{{ tableData.length }}</sapn>
        <span>家门店开通精品升级业务,平均单店产值:</span>
        <span style="color: #5850ff">¥{{ pjstoreTotal }}</span>
        <span>;高于平均线</span>
        <span>(同行此业务的平均产值为:</span>
        <span style="color: #5850ff">¥{{ product || 0 }}</span>
        <span>)的共</span>
        <span style="color: #5850ff; font-size: 16px">{{ storeNum }}</span>
        <span>家</span>
      </div>
      <!-- <div class="tip_rig h15_title">
        查看同行如何提高产值
        <i class="el-icon-d-arrow-right"></i>
      </div> -->
    </div>
    <div class="table_widget">
      <el-table :data="tableData" class="hightline" height="350" style="100%" highlight-current-row>
         <el-table-column fixed="left" width="5">
          <template slot-scope="scope">
            <span :scope="scope"></span>
          </template>
        </el-table-column>
        <el-table-column label="排名" width="100" align="center" type="index" :index="index => index + 1"></el-table-column>
        <el-table-column prop="merchantName" label="门店名称" align="center"></el-table-column>
        <el-table-column label="总产值" width="500">
          <template slot-scope="scope">
            <div class="echat_wrap">
              <div class="h19_title xtext">{{ scope.row.divisionMoney }}</div>
              <div class="progress_wrap">
                <div :style="{ width: (100 * scope.row.divisionMoney) / custSortMax + '%' }" class="summary-progress-barin"></div>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="openBtn h18_title" @click="showContainer">
      <span>收缩详情</span>
      <img src="../../assets/updown_icon.png" />
    </div>
  </div>
</template>

<script>
import { orderTotalOfJT } from '../../api/modules/rules'
import { converterApi } from '../../api/modules/converter'
import utils from '../../util/util'
export default {
  name: '',
  data() {
    return {
      tableData: [],
      pjstoreTotal: 0,
      storeNum: 0,
      productValue: 0,
      custSortMax: 0
    }
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    product: Number
  },
  created() {
    this.today = utils.dateFormat(new Date())
  },
  mounted() {
    this.orderAll()
  },
  methods: {
    orderAll() {
      let openInfo = JSON.parse(localStorage.getItem('openInfo'))
      this.bengintime = utils.dateFormat(openInfo.openDate)
      // this.bengintime = this.$defaultStartDate
      let method = orderTotalOfJT()
      let para = {
        routerMethod: method,
        beginDateStr: this.bengintime,
        endDateStr: this.today,
        reportType: 2,
        orderByType: 1 //1 分账  2分润
      }
      converterApi(para).then(res => {
        let arr = res || []
        let total = 0
        this.tableData = arr
        this.custSortMax = 0
        this.tableData.forEach(item => {
          total = total + parseFloat(item.divisionMoney)
          if (item.divisionMoney >= this.custSortMax) {
            this.custSortMax = item.divisionMoney
          }
        })
        this.pjstoreTotal = utils.decimal(total / arr.length, 2)
        this.storeNum = this.sortNum(arr, this.pjstoreTotal)
      })
    },
    sortNum(arr, total) {
      let count = 0
      arr.forEach(item => {
        if (item.divisionMoney > total) {
          count++
        }
      })
      return count
    },
    showContainer() {
      this.show = false
      this.$emit('closeRank', false)
    }
  }
}
</script>
<style lang="scss" scoped>
.rank-container {
  width: 100%;
  height: 454px;
  background: #ffffff;
  box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
  margin-top: 10px;
  position: relative;
}
.openBtn {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  bottom: 10px;
  cursor: pointer;
  > img {
    margin-left: 5px;
    width: 10px;
    height: 9px;
  }
}
.page_title {
  padding: 15px 20px 10px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #333333;
}
.tipper {
  width: 100%;
  box-sizing: border-box;
  padding: 0 20px;
  .tip_text {
    font-size: 12px;
    font-weight: 400;
    color: #000000;
    display: flex;
    align-items: center;
  }
  .tip_rig {
    cursor: pointer;
    > i {
      margin-left: 5px;
    }
  }
}
.table_widget {
  box-sizing: border-box;
  padding: 10px 15px;
  .echat_wrap {
    display: flex;
    align-items: center;
    .xtext {
      width: 20%;
    }
    .progress_wrap {
      margin-left: 10px;
      width: 65%;
    }
    .summary-progress-barin {
      background-color: #5850ff;
      height: 15px;
    }
  }
}
// .table_widget /deep/ .el-table--enable-row-hover .el-table__body tr:hover{
//   background: #f4f3ff !important;
// }
// .table_widget /deep/ .el-table tbody tr:hover >td{
//     background: #f4f3ff !important;
// }
</style>