1
0

完善组件TopAlarms

This commit is contained in:
Free-sss 2025-08-21 16:06:26 +08:00
parent 945c386c2e
commit 75c95a6fe0
4 changed files with 117 additions and 74 deletions

View File

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

View File

@ -2,24 +2,29 @@ import { PublicConfigClass } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d' import { CreateComponentType } from '@/packages/index.d'
import { TopAlarmsConfig } from './index' import { TopAlarmsConfig } from './index'
import dataJson from './data.json' import dataJson from './data.json'
import { chartInitConfig } from '@/settings/designSetting'
export const option = { export const option = {
dataset: dataJson.source, dataset: dataJson.source,
title: '未处置报警数TOP5', title: '未处置报警数TOP5',
titleColor: '#ffffff', titleColor: '#ffffff',
titleSize: 18, titleSize: 17,
rankColor: '#ffffff', rankColor: '#5AA1AD',
nameColor: '#B0E0E6', nameColor: '#eeeeee',
valueColor: '#ffffff', valueColor: '#eeeeee',
barColorStart: '#00D9FF', barColorStart: '#2f72b5',
barColorEnd: '#0055FF', barColorEnd: '#99C6E6',
dropdownOptions: ['当日', '当月', '当年'], dropdownOptions: ['当日', '当月', '当年'],
dropdownDefault: '当日', dropdownDefault: '当日',
iconColor: '#00E5FF' iconColor: '#00E5FF',
letterSpacing:2,
paddingX: 40,
paddingY: -5,
isShowButton: false
} }
export default class Config extends PublicConfigClass implements CreateComponentType { export default class Config extends PublicConfigClass implements CreateComponentType {
public key = TopAlarmsConfig.key public key = TopAlarmsConfig.key
public chartConfig = TopAlarmsConfig public chartConfig = TopAlarmsConfig
public option = option public option = option
public attr = { ...chartInitConfig, x: 0, y: 0, w: 450, h: 300, zIndex: 1 }
} }

View File

@ -1,15 +1,22 @@
<template> <template>
<SmallBorder class="SmallBorder">
<div class="go-top-alarms"> <div class="go-top-alarms">
<div class="header"> <div class="header">
<div class="title"> <div class="title">
<div class="title-prefix"> <!-- <div class="title-prefix">
<svg-icon icon-class="rocket" class="title-icon" :style="{ color: option.iconColor }"></svg-icon> <svg-icon icon-class="rocket" class="title-icon" :style="{ color: option.iconColor }"></svg-icon>
</div> </div> -->
<div class="title-text"> <div class="title-text">
<span :style="{ color: option.titleColor, fontSize: option.titleSize + 'px' }">{{ option.title }}</span> <span :style="{
color: option.titleColor,
fontSize: option.titleSize + 'px',
marginTop: option.paddingY + 'px',
marginLeft: option.paddingX + 'px',
letterSpacing: option.letterSpacing + 'px'
}">{{ option.title }}</span>
</div> </div>
</div> </div>
<n-dropdown trigger="hover" :options="dropdownOptions" @select="handleSelect"> <n-dropdown v-if='option.isShowButton' trigger="hover" :options="dropdownOptions" @select="handleSelect">
<div class="dropdown-button"> <div class="dropdown-button">
{{ selectedOption }} {{ selectedOption }}
<svg-icon icon-class="arrow-down" class="arrow-down-icon" /> <svg-icon icon-class="arrow-down" class="arrow-down-icon" />
@ -25,30 +32,33 @@
{{ item.rank }} {{ item.rank }}
</span> </span>
<span class="name" :style="{ color: option.nameColor }">{{ item.name }}</span> <span class="name" :style="{ color: option.nameColor }">{{ item.name }}</span>
</div> </div>
<div class="item-value"> <div class="item-value">
<span class="value" :style="{ color: option.valueColor }">{{ item.value }}</span> <span class="value" :style="{ color: option.valueColor }">{{ item.value }}</span>
</div> </div>
<div class="progress-bar-wrapper"> <div class="progress-bar-wrapper">
<div class="progress-bar"> <div class="progress-bar">
<div <div class="progress" :style="{
class="progress"
:style="{
width: calculateWidth(item.value), width: calculateWidth(item.value),
background: `linear-gradient(to right, ${option.barColorStart}, ${option.barColorEnd})` background: `linear-gradient(to right, ${option.barColorStart}, ${option.barColorEnd})`
}" }"></div>
></div>
</div> </div>
</div> </div>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</SmallBorder>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, PropType } from 'vue' import { ref, computed, PropType } from 'vue'
import { option as configOption } from './config' import { option as configOption } from './config'
import SmallBorder from '../SmallBorder/index.vue'
const props = defineProps({ const props = defineProps({
chartConfig: { chartConfig: {
@ -84,10 +94,18 @@ const handleSelect = (key: string) => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.SmallBorder {
position: relative;
}
.go-top-alarms { .go-top-alarms {
position: absolute;
top: 0;
right: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #0a162b; margin-top: -10px;
// background-color: #0a162b;
padding: 15px; padding: 15px;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
@ -103,25 +121,28 @@ const handleSelect = (key: string) => {
.title { .title {
display: flex; display: flex;
align-items: center; align-items: center;
.title-prefix {
width: 40px; // .title-prefix {
height: 35px; // width: 40px;
background-image: linear-gradient(to bottom, #2e69e0, #1e55a7); // height: 35px;
clip-path: polygon(0 0, 100% 0, 75% 100%, 0% 100%); // background-image: linear-gradient(to bottom, #2e69e0, #1e55a7);
display: flex; // clip-path: polygon(0 0, 100% 0, 75% 100%, 0% 100%);
justify-content: center; // display: flex;
align-items: center; // justify-content: center;
.title-icon { // align-items: center;
font-size: 22px;
} // .title-icon {
} // font-size: 22px;
// }
// }
.title-text { .title-text {
height: 35px; height: 35px;
display: flex; display: flex;
align-items: center; align-items: center;
background-image: linear-gradient(to bottom, #17325f, #0e2142); // background-image: linear-gradient(to bottom, #17325f, #0e2142);
padding: 0 20px 0 20px; padding: 0 20px 0 20px;
margin-left: -10px; margin-left: 0px;
clip-path: polygon(10% 0, 100% 0, 100% 100%, 0% 100%); clip-path: polygon(10% 0, 100% 0, 100% 100%, 0% 100%);
} }
} }
@ -136,6 +157,7 @@ const handleSelect = (key: string) => {
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
color: #fff; color: #fff;
.arrow-down-icon { .arrow-down-icon {
margin-left: 8px; margin-left: 8px;
font-size: 14px; font-size: 14px;
@ -145,6 +167,10 @@ const handleSelect = (key: string) => {
.content { .content {
flex: 1; flex: 1;
margin-top: -15px;
padding-right: 10px;
font-size: 12.5px;
ul { ul {
list-style: none; list-style: none;
padding: 0; padding: 0;
@ -164,7 +190,10 @@ const handleSelect = (key: string) => {
'info value' 'info value'
'bar bar'; 'bar bar';
align-items: center; align-items: center;
gap: 5px 15px; // margin-right: 10px;
padding: 0 10px;
gap: 6px 15px;
// background-color: antiquewhite;
.item-info { .item-info {
grid-area: info; grid-area: info;
@ -173,52 +202,61 @@ const handleSelect = (key: string) => {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
// background-color: yellowgreen;
.rank { .rank {
font-weight: bold; font-weight: normal;
margin-right: 10px; margin-right: 10px;
display: flex; display: flex;
align-items: center; align-items: center;
// background-color: #fff;
.rank-icon { .rank-icon {
display: inline-block; display: inline-block;
width: 10px; width: 4px;
height: 10px; height: 4px;
border-radius: 50%; border-radius: 50%;
background-color: #00e5ff; background-color: #00e5ff;
margin-right: 8px; margin-right: 8px;
box-shadow: 0 0 5px #00e5ff; margin-left: 6px;
box-shadow: 0 0 6px #00e5ff;
} }
} }
.name { .name {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
flex-grow: 1;
} }
} }
.item-value { .item-value {
grid-area: value; grid-area: value;
text-align: right; text-align: right;
font-size: 16px; // font-size: 16px;
font-weight: bold; font-weight: normal;
// background-color: aquamarine;
} }
.progress-bar-wrapper { .progress-bar-wrapper {
grid-area: bar; grid-area: bar;
width: calc(100% - 60px); /* Adjust width to not overlap value */ width: calc(100% - 60px);
/* Adjust width to not overlap value */
position: relative; position: relative;
left: 60px; /* Align with name */ left: 20px;
/* Align with name */
} }
.progress-bar { .progress-bar {
width: 100%; width: 100%;
height: 5px; height: 5px;
background-color: rgba(42, 58, 91, 0.5); // background-color: rgba(42, 58, 91, 0.5);
border-radius: 3px; border-radius: 1px;
overflow: hidden; overflow: hidden;
.progress { .progress {
height: 100%; height: 100%;
border-radius: 3px; border-radius: 1px;
} }
} }
} }