go-view-fetch/src/packages/components/Charts/MyComponents/DeviceStatus/index.vue

266 lines
7.2 KiB
Vue
Raw Normal View History

2025-08-20 12:44:02 +08:00
<template>
<div class="go-device-status">
2025-08-20 16:58:08 +08:00
<div class="header">
2025-08-20 18:46:54 +08:00
<div class="header-left">
<div class="title-icon-bg" :style="{ backgroundColor: option.headerBgColor1 }">
<svg-icon icon-class="rocket" class="title-icon" :style="{ color: option.iconColor }"></svg-icon>
</div>
<div class="title-text-bg" :style="{ backgroundColor: option.headerBgColor2 }">
<span :style="{ color: option.titleColor, fontSize: option.titleSize + 'px' }">{{ option.title }}</span>
</div>
</div>
<div class="header-right">
<div class="legend">
<div v-for="color in option.legendColors" :key="color" class="legend-item" :style="{ backgroundColor: color }"></div>
</div>
<div class="device-count">
<span class="online">{{ option.onlineDevice }}</span>
<span class="total">/ {{ option.totalDevice }}</span>
</div>
2025-08-20 16:58:08 +08:00
</div>
</div>
<div class="status-section">
<div class="online-rate">
2025-08-20 18:46:54 +08:00
<div class="rate-circle-bg">
<div
class="rate-circle"
:style="{ background: `conic-gradient(${option.progressColor} 0% ${option.onlineRate}%, ${option.progressBgColor} ${option.onlineRate}% 100%)` }"
>
<div class="rate-text-wrapper">
<span class="rate-text">{{ option.onlineRate }}</span>
<span class="rate-percent">%</span>
</div>
</div>
2025-08-20 12:44:02 +08:00
</div>
2025-08-20 16:58:08 +08:00
<span class="rate-label">设备在线率</span>
</div>
2025-08-20 18:46:54 +08:00
<div class="progress-bar-wrapper">
<div class="progress-bar" :style="{ backgroundColor: option.progressBgColor }">
<div class="progress" :style="{ width: option.onlineRate + '%', backgroundColor: option.progressColor }"></div>
</div>
2025-08-20 16:58:08 +08:00
</div>
</div>
<div class="table-header" :style="{ backgroundColor: option.headerBackgroundColor, height: option.headerHeight + 'px' }">
<div v-for="header in option.header" :key="header" class="header-item" :style="{ color: option.headerTextColor, fontSize: option.fontSize + 'px' }">
{{ header }}
</div>
2025-08-20 18:46:54 +08:00
<div class="header-item"></div>
2025-08-20 16:58:08 +08:00
</div>
<div class="table-body">
<div v-for="(item, index) in option.dataset" :key="index" class="table-row" :style="{ backgroundColor: option.itemBackgroundColor, height: option.itemHeight + 'px' }">
<div class="row-item" :style="{ color: option.textColor, fontSize: option.fontSize + 'px' }">{{ item.enterprise }}</div>
<div class="row-item" :style="{ color: option.textColor, fontSize: option.fontSize + 'px' }">{{ item.deviceType }}</div>
<div class="row-item" :style="{ color: option.textColor, fontSize: option.fontSize + 'px' }">{{ item.deviceName }}</div>
<div class="row-item time" :style="{ color: option.timeColor, fontSize: option.fontSize + 'px' }">{{ item.time }}</div>
2025-08-20 12:44:02 +08:00
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { option as configOption } from './config'
const props = defineProps({
chartConfig: {
type: Object as PropType<{ option: typeof configOption }>,
required: true
}
})
const option = computed(() => props.chartConfig.option)
</script>
<style lang="scss" scoped>
.go-device-status {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
2025-08-20 18:46:54 +08:00
background-color: #041126;
2025-08-20 16:58:08 +08:00
color: #ffffff;
2025-08-20 18:46:54 +08:00
padding: 15px;
2025-08-20 16:58:08 +08:00
box-sizing: border-box;
2025-08-20 12:44:02 +08:00
2025-08-20 16:58:08 +08:00
.header {
display: flex;
align-items: center;
2025-08-20 18:46:54 +08:00
justify-content: space-between;
margin-bottom: 15px;
.header-left {
display: flex;
align-items: center;
.title-icon-bg {
width: 50px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
clip-path: polygon(0 0, 80% 0, 100% 100%, 0% 100%);
.title-icon {
font-size: 28px;
}
}
.title-text-bg {
height: 40px;
padding: 0 20px 0 30px;
margin-left: -10px;
display: flex;
align-items: center;
justify-content: center;
clip-path: polygon(0 0, 95% 0, 100% 100%, 5% 100%);
}
}
.header-right {
2025-08-20 16:58:08 +08:00
display: flex;
align-items: center;
2025-08-20 18:46:54 +08:00
.legend {
display: flex;
2025-08-20 16:58:08 +08:00
margin-right: 10px;
2025-08-20 18:46:54 +08:00
.legend-item {
width: 15px;
height: 8px;
margin-left: 5px;
}
}
.device-count {
font-size: 20px;
.online {
color: #00e5ff;
}
.total {
color: #ffffff;
}
2025-08-20 16:58:08 +08:00
}
}
2025-08-20 12:44:02 +08:00
}
2025-08-20 16:58:08 +08:00
.status-section {
2025-08-20 12:44:02 +08:00
display: flex;
align-items: center;
2025-08-20 18:46:54 +08:00
margin-bottom: 15px;
2025-08-20 16:58:08 +08:00
.online-rate {
display: flex;
align-items: center;
2025-08-20 18:46:54 +08:00
margin-right: 15px;
.rate-circle-bg {
position: relative;
width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
&::after {
content: '';
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
border-radius: 50%;
filter: blur(5px);
background: radial-gradient(circle, rgba(0, 229, 255, 0.5), transparent 70%);
}
}
2025-08-20 16:58:08 +08:00
.rate-circle {
2025-08-20 18:46:54 +08:00
width: 60px;
height: 60px;
2025-08-20 16:58:08 +08:00
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
2025-08-20 18:46:54 +08:00
position: relative;
z-index: 1;
&::before {
content: '';
width: 48px;
height: 48px;
background-color: #041126;
border-radius: 50%;
}
.rate-text-wrapper {
position: absolute;
color: #00e5ff;
.rate-text {
font-size: 22px;
font-weight: bold;
}
.rate-percent {
font-size: 12px;
margin-left: 2px;
}
2025-08-20 16:58:08 +08:00
}
}
.rate-label {
2025-08-20 18:46:54 +08:00
font-size: 16px;
margin-left: 10px;
2025-08-20 16:58:08 +08:00
}
}
2025-08-20 18:46:54 +08:00
.progress-bar-wrapper {
2025-08-20 16:58:08 +08:00
flex: 1;
2025-08-20 18:46:54 +08:00
}
.progress-bar {
width: 100%;
height: 12px;
border-radius: 6px;
2025-08-20 16:58:08 +08:00
overflow: hidden;
.progress {
height: 100%;
2025-08-20 18:46:54 +08:00
border-radius: 6px;
2025-08-20 16:58:08 +08:00
}
}
2025-08-20 12:44:02 +08:00
}
2025-08-20 16:58:08 +08:00
.table-header {
2025-08-20 12:44:02 +08:00
display: flex;
align-items: center;
2025-08-20 16:58:08 +08:00
padding: 0 10px;
2025-08-20 18:46:54 +08:00
border-radius: 5px;
2025-08-20 16:58:08 +08:00
.header-item {
2025-08-20 18:46:54 +08:00
text-align: left;
padding-left: 10px;
&:nth-child(1) { flex: 2; }
&:nth-child(2) { flex: 2; }
&:nth-child(3) { flex: 3; }
&:nth-child(4) { flex: 1; }
2025-08-20 12:44:02 +08:00
}
}
2025-08-20 16:58:08 +08:00
.table-body {
flex: 1;
overflow-y: auto;
2025-08-20 18:46:54 +08:00
margin-top: 5px;
2025-08-20 16:58:08 +08:00
.table-row {
display: flex;
align-items: center;
padding: 0 10px;
2025-08-20 18:46:54 +08:00
margin-bottom: 5px;
border-radius: 5px;
&:last-child {
border-bottom: none;
}
2025-08-20 16:58:08 +08:00
.row-item {
2025-08-20 18:46:54 +08:00
text-align: left;
padding-left: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:nth-child(1) { flex: 2; }
&:nth-child(2) { flex: 2; }
&:nth-child(3) { flex: 3; }
&:nth-child(4) {
flex: 1;
text-align: right;
padding-right: 10px;
}
2025-08-20 16:58:08 +08:00
&.time {
2025-08-20 18:46:54 +08:00
color: #ff4d4f;
2025-08-20 16:58:08 +08:00
}
2025-08-20 12:44:02 +08:00
}
}
}
}
2025-08-20 18:46:54 +08:00
</style>