255 lines
6.0 KiB
Vue
Raw Normal View History

2024-10-18 17:31:35 +08:00
<!--
* @Author: SunTao 328867980@qq.com
* @Date: 2024-10-18 15:22:31
* @LastEditors: SunTao 328867980@qq.com
2024-10-31 09:20:08 +08:00
* @LastEditTime: 2024-10-30 16:04:22
2024-10-18 17:31:35 +08:00
* @FilePath: \znxjxt-ui\src\views\big-screen\road-components\road-statistic.vue
* @Description: 道路资产大屏-路产统计
-->
<template>
<div class="content">
2024-10-31 09:20:08 +08:00
<vue-seamless-scroll
class="vue-scroll"
:class-option="defaultOption"
:data="roadList"
v-if="roadList.length > 9"
2024-10-18 17:31:35 +08:00
>
2024-10-31 09:20:08 +08:00
<div
class="road-div"
v-for="(item, index) in roadList"
:key="`road-${index}`"
>
<div class="road-top">
<div class="road-top-name">
<a>{{ index + 1 < 10 ? "0" + (index + 1) : index + 1 }}</a
>{{ item.label }}
</div>
<div class="road-top-value">
<span>{{ item.value }}</span
><a></a>
</div>
2024-10-18 17:31:35 +08:00
</div>
2024-10-31 09:20:08 +08:00
<div class="road-bottom">
<div
class="road-bottom-div"
:style="{ width: `${item.rate * 100}%` }"
:class="`bottom-${index}`"
></div>
2024-10-22 09:55:33 +08:00
</div>
2024-10-18 17:31:35 +08:00
</div>
2024-10-31 09:20:08 +08:00
</vue-seamless-scroll>
<template v-else>
<div
class="road-div"
v-for="(item, index) in roadList"
:key="`road-${index}`"
>
<div class="road-top">
<div class="road-top-name">
<a>{{ index + 1 < 10 ? "0" + (index + 1) : index + 1 }}</a
>{{ item.label }}
</div>
<div class="road-top-value">
<span>{{ item.value }}</span
><a></a>
</div>
</div>
<div class="road-bottom">
<div
class="road-bottom-div"
:style="{ width: `${item.rate * 100}%` }"
:class="`bottom-${index}`"
></div>
</div>
2024-10-18 17:31:35 +08:00
</div>
2024-10-31 09:20:08 +08:00
</template>
2024-10-18 17:31:35 +08:00
</div>
</template>
<script>
2024-10-25 17:29:08 +08:00
import { roadStatisticList } from "@/api/xj/screen/road-screen";
2024-10-31 09:20:08 +08:00
import vueSeamlessScroll from "vue-seamless-scroll";
2024-10-18 17:31:35 +08:00
export default {
name: "RoadStatistic",
2024-10-31 09:20:08 +08:00
components: {
vueSeamlessScroll,
},
2024-10-25 17:29:08 +08:00
props: {
select: {
type: String,
default: "",
},
},
2024-10-18 17:31:35 +08:00
data() {
return {
2024-10-31 09:20:08 +08:00
// 轮播配置
defaultOption: {
step: 0.2, // 数值越大速度滚动越快
limitMoveNum: 1,
hoverStop: true, // 是否开启鼠标悬停stop
direction: 1, // 0向下 1向上 2向左 3向右
openWatch: true, // 开启数据实时监控刷新dom
singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动)direction => 0/1
singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
waitTime: 2000, // 单步运动停止的时间(默认值1000ms)
},
// 路产数据
2024-10-25 17:29:08 +08:00
roadList: [],
2024-10-18 17:31:35 +08:00
};
},
2024-10-25 17:29:08 +08:00
watch: {
select: {
handler() {
this.getRoadList();
},
immediate: true,
},
},
created() {},
methods: {
/* 获取路产统计信息 */
getRoadList() {
roadStatisticList({ type: this.select }).then(({ code, data }) => {
if (code === 200) {
let sum = 0;
data.forEach((element) => {
sum += element.value;
});
this.roadList = data.map((item) => {
return {
...item,
rate: item.value / sum,
};
});
}
});
},
},
2024-10-18 17:31:35 +08:00
};
</script>
<style lang="scss" scoped>
.content {
width: 100%;
height: 100%;
2024-10-31 09:20:08 +08:00
overflow: hidden;
2024-10-18 17:31:35 +08:00
color: #ffffff;
.road-div {
2024-10-22 09:55:33 +08:00
height: 2.5rem;
2024-10-18 17:31:35 +08:00
width: 100%;
padding: 0 1.5rem;
display: flex;
flex-direction: column;
justify-content: center;
> div {
display: flex;
align-items: center;
justify-content: space-between;
}
.index {
width: 4.5rem;
}
.name {
width: 5rem;
}
.value {
width: 6.5rem;
}
.road-top {
.road-top-name {
line-height: 1.5rem;
2024-10-22 09:55:33 +08:00
color: #c7daf2;
a {
display: inline-block;
width: 1.5rem;
color: #808c9f;
}
}
.road-top-value {
span {
font-family: "DouYu";
color: #c7daf2;
background: linear-gradient(
to bottom,
#ffffff,
#2773d0
); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
background-clip: text; /*将设置的背景颜色限制在文字中*/
-webkit-text-fill-color: transparent; /*给文字设置成透明*/
}
a {
margin-left: 0.5rem;
font-size: 0.8rem;
color: #808c9f;
}
2024-10-18 17:31:35 +08:00
}
}
.road-bottom {
2024-10-22 09:55:33 +08:00
width: 100%;
2024-10-18 17:31:35 +08:00
height: 0.5rem;
2024-10-22 09:55:33 +08:00
background-color: rgba(50, 72, 127, 0.3);
position: relative;
.img {
position: absolute;
width: 100%;
height: 100%;
}
.road-bottom-div {
width: 100%;
height: 100%;
display: flex;
2024-10-31 09:20:08 +08:00
background: linear-gradient(90deg, #0e183e 0%, #4087e8 100%);
2024-10-22 09:55:33 +08:00
}
.bottom-0 {
background: linear-gradient(90deg, #0e183e 0%, #4087e8 100%);
}
.bottom-1 {
background: linear-gradient(90deg, #0e183e 0%, #08b4a6 100%);
}
.bottom-2 {
background: linear-gradient(90deg, #0e183e 0%, #be8b13 100%);
}
.bottom-3 {
background: linear-gradient(90deg, #0e183e 0%, #4087e8 100%);
}
.bottom-4 {
background: linear-gradient(90deg, #0e183e 0%, #08b4a6 100%);
}
.bottom-5 {
background: linear-gradient(90deg, #0e183e 0%, #be8b13 100%);
}
.bottom-6 {
background: linear-gradient(90deg, #0e183e 0%, #4087e8 100%);
}
.bottom-7 {
background: linear-gradient(90deg, #0e183e 0%, #08b4a6 100%);
}
.bottom-8 {
background: linear-gradient(90deg, #0e183e 0%, #be8b13 100%);
}
.bottom-9 {
background: linear-gradient(90deg, #0e183e 0%, #4087e8 100%);
}
2024-10-18 17:31:35 +08:00
}
}
}
</style>