Authored by 鲁尚清

新增资源状态组件

... ... @@ -10,10 +10,11 @@ export function getData(data) {
data,
})
}
export function queryAllDataSet(data) {
export function getHealth(data) {
let data1='58462E5E615D0A65377458145C66983A';
// access_token:'1ff53981-08b8-44f0-8068-d545003649d8'
return request({
url: 'dataSet/queryAllDataSet',
url: ' api-web/detail/resouce/health?resId='+data1,
method: 'get',
})
}
... ...
... ... @@ -19,6 +19,14 @@ export const monitorHealthStatus = {
value: '健康度',
},
{
type: 'el-input-text',
label: '标题名称',
name: 'titleName',
required: false,
placeholder: '',
value: '',
},
{
type: 'custom-upload',
label: '标题图片地址',
name: 'imageAdress',
... ... @@ -34,6 +42,22 @@ export const monitorHealthStatus = {
placeholder: '',
value: '3'
},
/*{
type: 'el-switch',
label: '显示数量',
name: 'isNum',
required: false,
placeholder: '',
value: false
},*/
{
type: 'el-switch',
label: '显示资源名称',
name: 'isName',
required: false,
placeholder: '',
value: true
},
{
type: 'custom-upload',
label: '状态默认图片地址',
... ... @@ -68,7 +92,7 @@ export const monitorHealthStatus = {
},
{
type: 'el-select',
label: '标题图片位置',
label: '标题位置',
name: 'textAlign',
required: false,
placeholder: '',
... ... @@ -85,8 +109,15 @@ export const monitorHealthStatus = {
name: 'fontSize',
required: false,
placeholder: '',
value: '16'
}
value: '14'
},
{
type: 'el-input-number',
label: '图片宽度',
name: 'imgWidth',
required: false,
value: 220,
},
],
data: [
{
... ... @@ -134,15 +165,15 @@ export const monitorHealthStatus = {
{
name:'应用',
id:'002',
healthStatus: 1,
healthStatus: 2,
healthStatusUrl:''
},
/*{
{
name:'日志',
id:'003',
healthStatus: 1,
healthStatus: 3,
healthStatusUrl:''
}*/
}
],
},
{
... ... @@ -181,7 +212,7 @@ export const monitorHealthStatus = {
name: 'width',
required: false,
placeholder: '该容器在1920px大屏中的宽度',
value: 600,
value: 700,
},
{
type: 'el-input-number',
... ...
/*
* 健康度情况json
* author lsq
* 2022/01/13
* */
export const monitorResourceStatus = {
code: 'monitor-resource-status',
type: 'html',
label: '资源状态',
icon: 'iconbiaoge',
options: {
setup: [
{
type: 'el-input-text',
label: '图层名称',
name: 'layerName',
required: false,
placeholder: '',
value: '资源状态',
},
{
type: 'el-input-text',
label: '标题名称',
name: 'titleName',
required: false,
placeholder: '',
value: '',
},
{
type: 'custom-upload',
label: '标题图片地址',
name: 'imageAdress',
required: false,
placeholder: '',
value: require("../../../../../../../assets/images/healthStatus/title-asset.png"),
},
/* {
type: 'el-input-number',
label: '显示数据数',
name: 'dataNum',
required: false,
placeholder: '',
value: '3'
}, /*{
type: 'el-switch',
label: '显示数量',
name: 'isNum',
required: false,
placeholder: '',
value: false
},*/
{
type: 'el-switch',
label: '显示状态名称',
name: 'isName',
required: false,
placeholder: '',
value: true
},
{
type: 'custom-upload',
label: '状态默认图片地址',
name: 'imageAdressHealthBg',
required: false,
placeholder: '',
value: require("../../../../../../../assets/images/healthStatus/state_bg.png"),
},
{
type: 'custom-upload',
label: '优-图片地址',
name: 'imageAdressHealthGood',
required: false,
placeholder: '',
value: require("../../../../../../../assets/images/healthStatus/state_01.png"),
},
{
type: 'custom-upload',
label: '良-图片地址',
name: 'imageAdressHealthWorse',
required: false,
placeholder: '',
value:require("../../../../../../../assets/images/healthStatus/state_02.png"),
},
{
type: 'custom-upload',
label: '差-图片地址',
name: 'imageAdressHealthBad',
required: false,
placeholder: '',
value: require("../../../../../../../assets/images/healthStatus/state_03.png"),
},
{
type: 'el-select',
label: '标题位置',
name: 'textAlign',
required: false,
placeholder: '',
selectOptions: [
{code: 'center', name: '居中'},
{code: 'left', name: '左对齐'},
{code: 'right', name: '右对齐'},
],
value: 'left'
},
{
type: 'el-input-number',
label: '字体大小',
name: 'fontSize',
required: false,
placeholder: '',
value: '14'
},
{
type: 'el-input-number',
label: '图片宽度',
name: 'imgWidth',
required: false,
value: 220,
},
],
data: [
{
type: 'el-radio-group',
label: '数据类型',
name: 'dataType',
require: false,
placeholder: '',
selectValue: true,
selectOptions: [
{
code: 'staticData',
name: '静态数据',
},
{
code: 'dynamicData',
name: '动态数据',
},
],
value: 'staticData',
},
{
type: 'el-input-number',
label: '刷新时间(毫秒)',
name: 'refreshTime',
relactiveDom: 'dataType',
relactiveDomValue: 'dynamicData',
value: 30000
},
{
type: 'el-button',
label: '静态数据',
name: 'staticData',
required: false,
placeholder: '',
relactiveDom: 'dataType',
relactiveDomValue: 'staticData',
value: {
icon: "good",
state: "优",
yb: "0",
yz: "0",
zy: "0"
},
},
{
type: 'dycustComponents',
label: '',
name: 'dynamicData',
required: false,
placeholder: '',
relactiveDom: 'dataType',
relactiveDomValue: 'dynamicData',
chartType: 'widget-table',
dictKey: 'TEXT_PROPERTIES', //表格的暂不起作用
value: '',
},
],
position: [
{
type: 'el-input-number',
label: '左边距',
name: 'left',
required: false,
placeholder: '',
value: 0,
},
{
type: 'el-input-number',
label: '上边距',
name: 'top',
required: false,
placeholder: '',
value: 0,
},
{
type: 'el-input-number',
label: '宽度',
name: 'width',
required: false,
placeholder: '该容器在1920px大屏中的宽度',
value: 700,
},
{
type: 'el-input-number',
label: '高度',
name: 'height',
required: false,
placeholder: '该容器在1080px大屏中的高度',
value: 300,
},
]
}
}
... ...
... ... @@ -35,6 +35,7 @@ import {widgetLineCompare} from "./echartsConfigJson/widget-line-compare"
import {widgetDecoratePie} from "./echartsConfigJson/widget-decorate-pie";
import {monitorHealthStatus} from "./echartsConfigJson/monitorConfigJson/monitor-health-status";
import {monitorResourceStatus} from "./echartsConfigJson/monitorConfigJson/monitor-resource-status";
export const widgetTool = [
// type=html类型的组件
... ... @@ -65,4 +66,5 @@ export const widgetTool = [
widgetLineCompare,
widgetDecoratePie,
monitorHealthStatus,
monitorResourceStatus
]
... ...
... ... @@ -2,14 +2,32 @@
<div class="healthStatus-container" :style="styleObj">
<!-- <div class="healthStatus-container">-->
<div class="title-div" :style="styleColor">
<img :src="imgStyle.imageAdress" :style="imgStyle" alt="">
<img v-if="!imgStyle.titleName" :src="imgStyle.imageAdress" :style="imgStyle" alt="">
<div v-if="imgStyle.titleName" class="title-name">{{imgStyle.titleName}}</div>
</div>
<el-row>
<el-col :span="8" v-for="item in healthDataComputed" :key="item.id">
<el-col class="flex-around" :span="imgStyle.spanNum" v-for="item in healthDataComputed" :key="item.id">
<div class="health-service">
<span class="health-name">{{item.name}}</span>
<img v-if="item.healthStatusUrl" :src="item.healthStatusUrl" alt="">
<span v-if="imgStyle.isName" class="health-name">{{item.name}}</span>
<img :style="imgStyleContent" width="100%" v-if="item.healthStatusUrl" :src="item.healthStatusUrl" alt="">
</div>
<!-- <div class="health-num-content" :style="fontStyle" v-if="imgStyle.isNum">
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">严重告警:</span>
<span class="health-num">{{ healthNumData.yz }}</span>
</div>
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">重要告警:</span>
<span class="health-num">{{ healthNumData.zy }}</span>
</div>
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">一般告警:</span>
<span class="health-num">{{ healthNumData.yb }}</span>
</div>
</div>-->
</el-col>
</el-row>
... ... @@ -18,13 +36,22 @@
<script>
import {
getData
getData,
getHealth
} from "@/api/platform";
export default {
name: "healthStatus",
data() {
return {
options: {},
spanNum:24,//col的span的个数
healthNumData:{
icon: "worse",
state: "量",
yb: "0",
yz: "0",
zy: "1"
},//资源状态告警个数数据 good worse worst
healthData:[
/*{
name:'服务器',
... ... @@ -51,6 +78,7 @@ export default {
}*/
],
optionsSetUp: {},
optionsPosition:{},
optionsData:{}
}
},
... ... @@ -64,7 +92,7 @@ export default {
return this.objToOne(this.options);
},
styleObj() {
const allStyle = this.optionsSetUp;
const allStyle = this.optionsPosition;
return {
position: this.ispreview ? "absolute" : "static",
width: allStyle.width + "px",
... ... @@ -81,14 +109,26 @@ export default {
};
},
fontStyle(){
return{
"font-size": this.transStyle.fontSize + "px",
}
},
imgStyleContent(){
return{
'width':this.transStyle.imgWidth+'px',
}
},
imgStyle() {
return {
imageAdress: this.transStyle.imageAdress?this.transStyle.imageAdress:require("../../../../../../assets/images/healthStatus/title-asset.png"),
"border-radius": this.transStyle.borderRadius + "px",
opacity: this.transStyle.transparency / 100,
isNum:this.transStyle.isNum,
spanNum:this.transStyle.isNum?24:8,
titleName:this.transStyle.titleName,
isName:this.transStyle.isName,
};
},
imgStyleHealth() {
... ... @@ -103,11 +143,9 @@ export default {
healthDataComputed(){
let healthData=this.healthData;
healthData=this.initImageUrl();
console.log("datanum",this.imgStyleHealth.dataNum)
if(this.imgStyleHealth.dataNum){
healthData=healthData.slice(0,this.imgStyleHealth.dataNum);
}
return healthData;
}
},
... ... @@ -116,35 +154,44 @@ export default {
handler(val) {
this.options = val;
this.optionsSetUp = val.setup;
this.optionsPosition = val.position;
this.optionsData=val.data;
this.handlerData();
if(this.optionsSetUp.isNum){
this.changeHealthNum();
this.getHealthData();
}else{
}
},
deep: true
}
},
mounted() {
// this.initImageUrl();
this.options=this.value;
this.optionsSetUp = this.value.setup;
this.optionsPosition = this.value.position;
this.optionsData = this.value.data;
this.handlerData();
if(this.optionsSetUp.isNum){
this.changeHealthNum();
this.getHealthData();
}
},
methods: {
initImageUrl(){
console.log("len",this.healthData.length)
if(this.healthData && this.healthData.length<3){
let len=3-this.healthData.length;
for(let i=0;i<len;i++){
console.log("i",i)
this.healthData.push({
name:'',
healthStatusUrl:''
})
}
}
console.log("healthData",this.healthData)
this.healthData.map(item=>{
console.log("abc",this.imgStyleHealth.dataNum)
if(!item.healthStatusUrl){
item.healthStatusUrl=this.imgStyleHealth.imageAdressHealthBg;
}
... ... @@ -187,6 +234,47 @@ export default {
this.getEchartData(data);
}*/
},
async getHealthData(){
//显示告警数量时根据告警数量接口返回的状态更改
if(this.healthNumData.icon=='good'){
this.healthData[0].healthStatus=1;
}else if(this.healthNumData.icon=='worse'){
this.healthData[0].healthStatus=2;
}else if(this.healthNumData.icon=='worst'){
this.healthData[0].healthStatus=3;
}else{
this.healthData[0].healthStatus=1;
}
/*
const { code, data } = await getHealth();
if (code != 200) return;
this.healthNumData=data;
console.log("health",data)*/
},
//当选择显示告警数量时,把之前的数据同步到数量接口中
changeHealthNum(){
let icon='good';
let state='优';
if(this.healthData[0].healthStatus==2){
icon='worse';
state='量'
}else if(this.healthData[0].healthStatus==3){
icon='worst';
state='中'
}
this.healthNumData={
icon: icon,
state: state,
yb: "0",
yz: "0",
zy: "0"
}
},
},
}
... ... @@ -194,12 +282,18 @@ export default {
<style scoped lang="scss">
.healthStatus-container{
max-width:700px;
/*max-width:700px;*/
}
.title-div{
text-align: left;
padding:10px;
}
.title-name{
color:rgb(30,159,255);
font-size: 16px;
padding:10px;
font-weight: bold;
}
.health-service{
position: relative;
}
... ... @@ -210,4 +304,33 @@ export default {
right:0;
color:#FFFFFF;
}
.health-num-content{
font-size: 14px;
}
.health-num-title{
margin-left: 30px;
color:#666666;
}
.health-num-item:nth-child(2){
margin: 60px 0;
}
.health-color{
width:14px;
height:14px;
display: inline-block;
}
.health-num-item:nth-child(1) .health-color{
background: #D81E06;
}
.health-num-item:nth-child(2) .health-color{
background: #F5A623;
}
.health-num-item:nth-child(3) .health-color{
background: #7BE00D;
}
.flex-around{
display: flex;
justify-content: space-around;
align-items: center;
}
</style>
... ...
<template>
<div class="healthStatus-container" :style="styleObj">
<!-- <div class="healthStatus-container">-->
<div class="title-div" :style="styleColor">
<img v-if="!imgStyle.titleName" :src="imgStyle.imageAdress" :style="imgStyle" alt="">
<div v-if="imgStyle.titleName" class="title-name">{{imgStyle.titleName}}</div>
</div>
<el-row>
<!-- <el-col class="flex-around" :span="imgStyle.spanNum" v-for="item in healthDataComputed" :key="item.id">-->
<el-col class="flex-around" :span="24" >
<div class="health-service">
<span v-if="imgStyle.isName" :style="lineHeightStyle" class="health-name">{{healthNumData.state}}</span>
<img :style="imgStyleContent" width="100%" :src="healthStatusUrl" alt="">
</div>
<div class="health-num-content" :style="fontStyle" >
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">严重告警:</span>
<span class="health-num">{{ healthNumData.yz }}</span>
</div>
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">重要告警:</span>
<span class="health-num">{{ healthNumData.zy }}</span>
</div>
<div class="health-num-item">
<span class="health-color"></span>
<span class="health-num-title">一般告警:</span>
<span class="health-num">{{ healthNumData.yb }}</span>
</div>
</div>
</el-col>
</el-row>
</div>
</template>
<script>
import {
getData,
getHealth
} from "@/api/platform";
export default {
name: "healthStatus",
data() {
return {
options: {},
spanNum:24,//col的span的个数
healthStatusUrl:'',
healthNumData:{
icon: "worse",
state: "量",
yb: "0",
yz: "0",
zy: "1"
},//资源状态告警个数数据 good worse worst
healthData:[
],
optionsSetUp: {},
optionsPosition:{},
optionsData:{}
}
},
components: {},
props: {
value: Object,
ispreview: Boolean
},
computed: {
transStyle() {
return this.objToOne(this.options);
},
styleObj() {
const allStyle = this.optionsPosition;
return {
position: this.ispreview ? "absolute" : "static",
width: allStyle.width + "px",
height: allStyle.height + "px",
left: allStyle.left + "px",
top: allStyle.top + "px",
// background:this.transStyle.BgColor
};
},
styleColor() {
return {
"text-align": this.transStyle.textAlign,
};
},
fontStyle(){
return{
"font-size": this.transStyle.fontSize + "px",
'height':this.transStyle.imgWidth+'px',
}
},
lineHeightStyle(){
return{
'line-height':this.transStyle.imgWidth+'px',
}
},
imgStyleContent(){
return{
'width':this.transStyle.imgWidth+'px',
}
},
imgStyle() {
return {
imageAdress: this.transStyle.imageAdress?this.transStyle.imageAdress:require("../../../../../../assets/images/healthStatus/title-asset.png"),
"border-radius": this.transStyle.borderRadius + "px",
isNum:this.transStyle.isNum,
spanNum:this.transStyle.isNum?24:8,
titleName:this.transStyle.titleName,
isName:this.transStyle.isName,
imgWidth:this.transStyle.imgWidth
};
},
imgStyleHealth() {
return {
imageAdressHealthBg:this.transStyle.imageAdressHealthBg?this.transStyle.imageAdressHealthBg:require("../../../../../../assets/images/healthStatus/state_bg.png"),
imageAdressHealthGood:this.transStyle.imageAdressHealthGood?this.transStyle.imageAdressHealthGood:require("../../../../../../assets/images/healthStatus/state_01.png"),
imageAdressHealthWorse:this.transStyle.imageAdressHealthWorse?this.transStyle.imageAdressHealthWorse:require("../../../../../../assets/images/healthStatus/state_02.png"),
imageAdressHealthBad:this.transStyle.imageAdressHealthBad?this.transStyle.imageAdressHealthBad:require("../../../../../../assets/images/healthStatus/state_03.png"),
dataNum:this.transStyle.dataNum?this.transStyle.dataNum:'3'
};
},
/* healthDataComputed(){
let healthData=this.healthData;
healthData=this.initImageUrl();
if(this.imgStyleHealth.dataNum){
healthData=healthData.slice(0,this.imgStyleHealth.dataNum);
}
return healthData;
}*/
},
watch: {
value: {
handler(val) {
this.options = val;
this.optionsSetUp = val.setup;
this.optionsPosition = val.position;
this.optionsData=val.data;
this.handlerData();
this.initImageUrl();
this.getHealthData();
},
deep: true
}
},
mounted() {
// this.initImageUrl();
this.options=this.value;
this.optionsSetUp = this.value.setup;
this.optionsPosition = this.value.position;
this.optionsData = this.value.data;
this.handlerData();
this.initImageUrl();
this.getHealthData();
},
methods: {
initImageUrl(){
//显示告警数量时根据告警数量接口返回的状态更改
if(this.healthNumData.icon=='good'){
this.healthStatusUrl=this.imgStyleHealth.imageAdressHealthGood;
}else if(this.healthNumData.icon=='worse'){
this.healthStatusUrl=this.imgStyleHealth.imageAdressHealthWorse;
}else if(this.healthNumData.icon=='worst'){
this.healthStatusUrl=this.imgStyleHealth.imageAdressHealthBad;
}else{
this.healthStatusUrl=this.imgStyleHealth.imageAdressHealthBg;
}
return this.healthNumData;
},
async init(){
const reportCode = this.$route.query.reportCode;
const { code, data } = await getData(reportCode);
if (code != 200) return;
},
handlerData() {
const resData = this.optionsData;
console.log("resdata",resData)
resData.dataType == "staticData"
? this.handlerStaticData(resData.staticData)
: this.handlerDynamicData(resData.dynamicData, resData.refreshTime);
},
handlerStaticData(data) {
this.healthNumData = data;
},
handlerDynamicData(data, refreshTime) {
if (!data) return;
/* if (this.ispreview) {
this.getEchartData(data);
this.flagInter = setInterval(() => {
this.getEchartData(data);
}, refreshTime);
} else {
this.getEchartData(data);
}*/
},
async getHealthData(){
/*
const { code, data } = await getHealth();
if (code != 200) return;
this.healthNumData=data;
console.log("health",data)*/
},
},
}
</script>
<style scoped lang="scss">
.healthStatus-container{
/*max-width:700px;*/
}
.title-div{
text-align: left;
padding:10px;
}
.title-name{
color:rgb(30,159,255);
font-size: 16px;
padding:10px;
font-weight: bold;
}
.health-service{
position: relative;
}
.health-name{
position: absolute;
left:0;
right:0;
font-size: 30px;
color:#666666;
line-height: 220px;
}
.health-num-content{
font-size: 14px;
justify-content: space-around;
display: flex;
flex-flow: column;
}
.health-num-title{
margin-left: 30px;
color:#666666;
}
.health-num-item:nth-child(2){
/*margin: 60px 0;*/
}
.health-color{
width:14px;
height:14px;
display: inline-block;
}
.health-num-item:nth-child(1) .health-color{
background: #D81E06;
}
.health-num-item:nth-child(2) .health-color{
background: #F5A623;
}
.health-num-item:nth-child(3) .health-color{
background: #7BE00D;
}
.flex-around{
display: flex;
justify-content: space-around;
align-items: center;
}
</style>
... ...
... ... @@ -38,6 +38,7 @@ import widgetLineCompareChart from "./line/widgetLineCompareChart";
import widgetDecoratePieChart from "./decorate/widgetDecoratePieChart";
import monitorHealthStatus from "./monitor/healthStatus";
import monitorResourceStatus from "./monitor/resourceStatus";
export default {
name: "WidgetTemp",
... ... @@ -68,7 +69,8 @@ export default {
widgetLineCompareChart,
widgetDecoratePieChart,
monitorHealthStatus
monitorHealthStatus,
monitorResourceStatus
},
model: {
prop: "value",
... ...
... ... @@ -49,6 +49,7 @@ import widgetLineCompareChart from "./line/widgetLineCompareChart";
import widgetDecoratePieChart from "./decorate/widgetDecoratePieChart";
import monitorHealthStatus from "./monitor/healthStatus";
import monitorResourceStatus from "./monitor/resourceStatus";
export default {
... ... @@ -80,6 +81,7 @@ export default {
widgetLineCompareChart,
widgetDecoratePieChart,
monitorHealthStatus,
monitorResourceStatus
},
model: {
prop: "value",
... ...