2020-03-18 19:22:45 +08:00
|
|
|
<template>
|
2020-03-19 19:21:12 +08:00
|
|
|
<div class="table-box" :class="{'table-column-box':showData&&showData.screen&&showData.screen.direction=='column'}">
|
2020-03-18 19:22:45 +08:00
|
|
|
<loading ref="loading"></loading>
|
2020-03-19 19:21:12 +08:00
|
|
|
<template v-if="showData&&showData.screen">
|
2020-03-23 18:20:19 +08:00
|
|
|
<div class="table-box-left" :class="{'table-box-left-half':showData.screen.total.direction == 'column'}" v-show="showData.screen.show">
|
2020-03-25 20:36:52 +08:00
|
|
|
<div class="table-screen" :class="{'fill-flex-cavity':!showData.screen.stat.show&&showData.screen.total.direction != 'column'&&showData.screen.direction!='column'}">
|
2020-03-19 19:21:12 +08:00
|
|
|
<div class="screen-top" v-show="showData.screen.total.show" >
|
|
|
|
|
<div :class="{'screen-row':showData.screen.total.direction == 'row','screen-column':showData.screen.total.direction == 'column'}">
|
|
|
|
|
<div class="screen-col"><i class="super-icon" :class="showData.screen.total.icon"></i></div>
|
|
|
|
|
<div class="screen-col">
|
|
|
|
|
<div>{{showData.screen.total.title}}</div>
|
|
|
|
|
<template v-if="showData.screen.total.showPopover">
|
|
|
|
|
<el-popover trigger="hover" placement="top">
|
|
|
|
|
<div class="popover-container">
|
|
|
|
|
<div v-for="(pop,index) in showData.screen.total.popover">
|
|
|
|
|
<span>{{pop.label}}:</span>
|
|
|
|
|
<span>{{pop.value}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<template slot="reference">
|
2020-03-23 18:20:19 +08:00
|
|
|
<!-- <div class="super-font">{{showData.screen.total.num}}</div>-->
|
|
|
|
|
<div class="super-font" v-html="showData.screen.total.num"></div>
|
2020-03-19 19:21:12 +08:00
|
|
|
</template>
|
|
|
|
|
</el-popover>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div class="super-font">{{showData.screen.total.num}}</div>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="screen-bottom" v-show="showData.screen.stat.show">
|
|
|
|
|
<div class="screen-row">
|
|
|
|
|
<div class="screen-col avg-children-space"><i class="nz-icon nz-icon-arrow-up middle-icon green-icon"></i><span class="middle-font">{{showData.screen.stat.up}}</span></div>
|
|
|
|
|
<div class="screen-col avg-children-space"><i class="nz-icon nz-icon-arrow-down middle-icon red-icon"></i><span class="middle-font">{{showData.screen.stat.down}}</span></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-if="showData&&showData.table">
|
|
|
|
|
<div class="table-box-right overview-table" v-show="showData.table.show">
|
|
|
|
|
<el-table
|
|
|
|
|
class="overview-table"
|
|
|
|
|
:data="showData.table.tableData"
|
|
|
|
|
v-scrollBar:el-table
|
2020-03-30 10:18:11 +08:00
|
|
|
tooltip-effect="light"
|
2020-03-19 19:21:12 +08:00
|
|
|
height="100%"
|
2020-03-25 16:27:00 +08:00
|
|
|
ref="dataTable"
|
2020-03-19 19:21:12 +08:00
|
|
|
>
|
|
|
|
|
<el-table-column
|
|
|
|
|
:resizable="false"
|
|
|
|
|
v-for="(item, index) in showData.table.tableLabel"
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
:key="`col-${index}`"
|
2020-03-30 10:18:11 +08:00
|
|
|
:class-name="typeof item.showOverflowTooltip != 'undefined'&& item.showOverflowTooltip == false?'cell-tooltip':''"
|
2020-03-23 18:20:19 +08:00
|
|
|
:width="item.width"
|
2020-03-19 19:21:12 +08:00
|
|
|
:label="item.label"
|
2020-03-20 18:22:44 +08:00
|
|
|
:render-header="item.renderHeader"
|
2020-03-30 10:18:11 +08:00
|
|
|
:show-overflow-tooltip="typeof item.showOverflowTooltip != 'undefined'?item.showOverflowTooltip:true"
|
2020-03-19 19:21:12 +08:00
|
|
|
min-width="90"
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
<template v-if="item.showPopover">
|
|
|
|
|
<el-popover trigger="hover" placement="right" >
|
2020-03-18 19:22:45 +08:00
|
|
|
<div class="popover-container">
|
2020-03-19 19:21:12 +08:00
|
|
|
<div v-for="(pop,index) in item.popover">
|
2020-03-18 19:22:45 +08:00
|
|
|
<span>{{pop.label}}:</span>
|
2020-03-19 19:21:12 +08:00
|
|
|
<span>{{scope.row[pop.prop]}}</span>
|
2020-03-18 19:22:45 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<template slot="reference">
|
2020-03-23 18:20:19 +08:00
|
|
|
<span v-html="scope.row[item.prop]"></span>
|
2020-03-18 19:22:45 +08:00
|
|
|
</template>
|
|
|
|
|
</el-popover>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
2020-03-23 18:20:19 +08:00
|
|
|
<span v-html="scope.row[item.prop]"></span>
|
2020-03-18 19:22:45 +08:00
|
|
|
</template>
|
|
|
|
|
</template>
|
2020-03-19 19:21:12 +08:00
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2020-03-18 19:22:45 +08:00
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: "tableBox",
|
|
|
|
|
components:{
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
popData: {type:Object,required:true},
|
|
|
|
|
},
|
|
|
|
|
data(){
|
|
|
|
|
return {
|
|
|
|
|
showData:{
|
|
|
|
|
screen:{ //左侧概览信息
|
|
|
|
|
show:true,
|
|
|
|
|
total:{ //左侧上方大图标及total信息
|
|
|
|
|
show:true,
|
|
|
|
|
num:0,
|
2020-03-19 19:21:12 +08:00
|
|
|
title:'',
|
|
|
|
|
showPopover:true,
|
|
|
|
|
icon:'0',
|
|
|
|
|
popover:[]
|
2020-03-18 19:22:45 +08:00
|
|
|
},
|
|
|
|
|
stat:{//左侧下方 小图标,
|
|
|
|
|
show:true,
|
|
|
|
|
up:0,
|
|
|
|
|
down:0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
table:{//右侧table
|
|
|
|
|
show:true,
|
|
|
|
|
tableData:[],
|
|
|
|
|
tableLabel:[]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
startLoading(){
|
|
|
|
|
this.$refs.loading.startLoading();
|
|
|
|
|
},
|
|
|
|
|
endLoading(){
|
|
|
|
|
this.$refs.loading.endLoading();
|
2020-03-25 20:36:52 +08:00
|
|
|
},
|
2020-03-30 10:18:11 +08:00
|
|
|
formatTableColumn:function(column,len=14){
|
|
|
|
|
let length=this.getLength(column);
|
|
|
|
|
if(length<=15){
|
|
|
|
|
return column;
|
|
|
|
|
}else{
|
|
|
|
|
let tempStr=column.substr(0,len);
|
|
|
|
|
if(this.getLength(tempStr) <= 15){
|
|
|
|
|
return tempStr+'';
|
|
|
|
|
}else{
|
|
|
|
|
return this.formatTableColumn(tempStr,len-1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getLength(val) {
|
|
|
|
|
var str = new String(val);
|
|
|
|
|
var bytesCount = 0;
|
|
|
|
|
for (var i = 0 ,n = str.length; i < n; i++) {
|
|
|
|
|
var c = str.charCodeAt(i);
|
|
|
|
|
if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
|
|
|
|
|
bytesCount += 1;
|
|
|
|
|
} else {
|
|
|
|
|
bytesCount += 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bytesCount;
|
2020-03-18 19:22:45 +08:00
|
|
|
}
|
2020-03-30 10:18:11 +08:00
|
|
|
|
2020-03-18 19:22:45 +08:00
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
},
|
|
|
|
|
watch:{
|
|
|
|
|
popData:{
|
|
|
|
|
immediate:true,
|
|
|
|
|
deep:true,
|
|
|
|
|
handler(n,o){
|
2020-03-20 18:22:44 +08:00
|
|
|
// this.showData=JSON.parse(JSON.stringify(n));
|
|
|
|
|
this.showData=Object.assign({},n);
|
2020-03-18 19:22:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
@import "tableBox.scss";
|
|
|
|
|
</style>
|
|
|
|
|
<style>
|
|
|
|
|
.overview-table th, .overview-table tr {
|
|
|
|
|
background-color: #FCFCFC !important;
|
|
|
|
|
}
|
2020-03-30 10:18:11 +08:00
|
|
|
.cell-tooltip .cell{
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
min-width: 50px;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
2020-03-18 19:22:45 +08:00
|
|
|
</style>
|