index.vue 4.15 KB
<template>
  <div class="dashboard-card rank-card">
    <div class="card-header">
      <span class="card-title">线上运营分布</span>
    </div>
    <div class="rank-list">
      <!-- 表头 -->
      <div class="rank-header">
        <div v-for="col in rankColumns"
             :key="col.key"
             :class="col.className">
          {{ col.label }}
        </div>
      </div>
      <!-- 列表内容 -->
      <template v-if="rankData.length > 0">
        <div v-for="(item, index) in rankData"
             :key="index"
             class="rank-item">
          <!-- 排名 Icon 处理 -->
          <div class="rank-index"
               :class="`rank-${index + 1}`">
            <img v-if="index < 3"
                 style="width: 24px; height: 24px;"
                 :src="require(`@/assets/strategy/icon-strategy-rank0${index + 1}.png`)" />
            <span v-else
                  style="width: 20px; height: 20px; border-radius: 50%; opacity: 1; background: #2a58ad1a; display: inline-block; text-align: center; line-height: 20px;">
              {{ index + 1 }}
            </span>
          </div>
          <div class="rank-name" :title="item.staffName">
            {{ item.staffName || '-' }}
          </div>
          <div class="rank-col">
            {{ item.strategyCount }}
          </div>
          <div class="rank-col">
            {{ item.strategyCountPercent }}%
          </div>
          <div class="rank-col">
            {{ item.storeCount }}
          </div>
          <div class="rank-col">
            {{ item.storeCountPercent }}%
          </div>
        </div>
      </template>
    </div>
    <div v-if="rankData.length === 0" class="empty-box">
      <img alt="暂无数据" :src="noDataImg">
      <div class="empty-text">
        暂无数据
      </div>
    </div>
    <div class="bottom-cover"></div>
  </div>
</template>

<script>
import noDataImg from "@/assets/strategy/emepty-strategy.png";

const RANK_COLUMNS = [
	{ key: "rank", label: "排名", className: "rank-index" },
	{ key: "name", label: "姓名", className: "rank-name" },
	{ key: "strategyCount", label: "策略总数", className: "rank-col" },
	{ key: "strategyPercent", label: "占比", className: "rank-col" },
	{ key: "storeCount", label: "门店总数", className: "rank-col" },
	{ key: "storePercent", label: "占比", className: "rank-col" },
];

export default {
	name: "OnlineOperatorRanking",
	props: {
		// 排行榜数据(由父组件传递)
		rankData: {
			type: Array,
			default: () => [],
		},
	},
	data() {
		return {
			noDataImg,
			rankColumns: RANK_COLUMNS,
		};
	},
};
</script>

<style lang="scss" scoped>
$bg-white: #fff;

.dashboard-card {
	background: $bg-white;
	border-radius: 4px;
	padding: 20px;
	padding-right: 28px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
	position: relative;
	&.rank-card {
		height: 332px;
		box-sizing: border-box;
	}

	.card-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;

		.card-title {
			font-size: 16px;
			font-weight: 500;
			color: #303133;
		}
	}

	.bottom-cover {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 72px;
		border-radius: 10px;
		background: linear-gradient(0deg, #ffffff 0%, #ffffff00 100%);
	}
}

/* 排行榜样式 */
.rank-list {
	font-size: 13px;
	overflow: scroll;
	max-height: 260px;
	.rank-index,
	.rank-name,
	.rank-col {
		flex: 1;
	}

	.rank-col {
		text-align: center;
	}

	.rank-header {
		display: flex;
		color: #909399;
	}

	.rank-item {
		display: flex;
		align-items: center;
		box-sizing: border-box;
		margin-top: 16px;
		&:last-child {
			border-bottom: none;
		}

		.rank-name {
			color: #303133;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.rank-col {
			color: #606266;
		}
	}
}

.empty-box {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	color: #909399;
	text-align: center;
	width: calc(100% - 48px); // 减去左右 padding (20px + 28px)
	box-sizing: border-box;

	img {
		width: 86px;
		height: 86px;
	}

	.empty-text {
		margin-top: 0;
	}
}
</style>