149 lines
3.5 KiB
Vue
Raw Normal View History

2025-03-14 17:52:05 +08:00
<template>
2025-03-21 16:48:39 +08:00
<div class="demo roll-list" style="height: 100%" ref="refroll">
<vue3ScrollSeamless class="scroll-wrap" :classOptions="classOptions" :dataList="datalist">
<div v-for="(item, index) in datalist" :key="index" class="list-item">
2025-03-14 17:52:05 +08:00
<div class="list-item-content">
2025-03-17 17:34:32 +08:00
<div class="list-item-l">
<div class="item-top">
<span class="label"> {{ item.title || '--' }}</span>
<span class="value"> {{ item.value || '0' }}</span>
</div>
2025-03-21 16:48:39 +08:00
<div class="progress-val">
<div class="progress-warp" :style="{ width: item.percent + 'px' }">
<div class="progress"></div>
</div>
</div>
2025-03-17 17:34:32 +08:00
</div>
2025-03-14 17:52:05 +08:00
<div class="list-item-r">
{{ '0' + (index + 1) }}
</div>
</div>
</div>
</vue3ScrollSeamless>
</div>
<!-- </div> -->
</template>
<script setup>
import { ref, onMounted, onUnmounted, computed, reactive } from 'vue';
import { vue3ScrollSeamless } from 'vue3-scroll-seamless';
const props = defineProps({
items: {
type: Array,
default: () => [],
},
});
let list = reactive(props.items);
2025-03-21 16:48:39 +08:00
let refroll = ref(null);
2025-03-14 17:52:05 +08:00
const classOptions = {
singleHeight: 48,
};
2025-03-21 16:48:39 +08:00
let datalist = computed(() => {
let maxwidth = refroll.value && refroll.value.clientWidth;
return list.map((m) => {
return { ...m, percent: parseInt(Number(parseInt(m.value) / max.value) * maxwidth) };
});
});
let max = computed(() => {
let valueList = new Set(list.map((item) => parseInt(item.value)));
let sortValue = [...valueList].sort((a, b) => b - a) || [];
// console.info('valueList', sortValue);
return sortValue.length ? sortValue[0] : 0;
});
2025-03-14 17:52:05 +08:00
</script>
<style scoped lang="scss">
2025-03-17 17:34:32 +08:00
.roll-list {
.scroll-wrap {
height: 80%;
2025-03-14 17:52:05 +08:00
width: 100%;
2025-03-17 17:34:32 +08:00
margin: 0 auto;
overflow: hidden;
}
.list-item {
// border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
line-height: 36px;
.list-item-content {
display: inline-flex;
width: 100%;
justify-content: space-around;
position: relative;
.list-item-l,
.list-item-r {
color: #fff;
}
.list-item-l {
width: calc(100% - 0px);
.item-top {
width: 100%;
line-height: 16px;
.label,
.value {
display: inline-block;
width: 100%;
}
.label {
font-size: 12px;
}
.value {
font-size: 10px;
2025-03-21 16:48:39 +08:00
color: #6beff9;
2025-03-17 17:34:32 +08:00
}
}
}
.list-item-r {
text-align: right;
font-size: 20px;
font-weight: bold;
2025-03-21 16:48:39 +08:00
color: #6beff9;
2025-03-17 17:34:32 +08:00
position: absolute;
right: 0;
bottom: 0;
}
2025-03-21 16:48:39 +08:00
.progress-val {
width: calc(100%);
.progress-warp {
.progress {
height: 6px;
border-radius: 6px;
background: linear-gradient(90deg, #45bfe9 0%, #01589c 100%);
animation: expandWidth 1s ease-in-out forwards;
}
@keyframes expandWidth {
from {
width: 0;
}
to {
width: 100%;
}
}
}
}
2025-03-14 17:52:05 +08:00
}
}
2025-03-17 17:34:32 +08:00
.ui-wrap {
list-style: none;
padding: 0;
margin: 0 auto;
}
.li-item {
display: flex;
align-items: center;
width: 100%;
text-align: center;
}
2025-03-14 17:52:05 +08:00
}
2025-03-17 17:34:32 +08:00
.demo {
2025-03-14 17:52:05 +08:00
display: flex;
align-items: center;
2025-03-17 17:34:32 +08:00
justify-content: center;
margin-top: 10px;
2025-03-14 17:52:05 +08:00
}
</style>