This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/dashboard/overview/tableBox.vue

152 lines
5.3 KiB
Vue
Raw Normal View History

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">
<div class="table-box-left" v-show="showData.screen.show">
<div class="table-screen" :class="{'fill-flex-cavity':!showData.screen.stat.show&&showData.screen.total.direction != 'column'}">
<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>&nbsp;
<span>{{pop.value}}</span>
</div>
</div>
<template slot="reference">
<div class="super-font">{{showData.screen.total.num}}</div>
</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
height="100%"
>
<el-table-column
:resizable="false"
v-for="(item, index) in showData.table.tableLabel"
v-if="item.show"
:key="`col-${index}`"
:label="item.label"
:render-header="item.renderHeader"
2020-03-19 19:21:12 +08:00
show-overflow-tooltip
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>&nbsp;
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-19 19:21:12 +08:00
<span>{{scope.row[item.prop]}}</span>
2020-03-18 19:22:45 +08:00
</template>
</el-popover>
</template>
<template v-else>
2020-03-19 19:21:12 +08:00
{{scope.row[item.prop]}}
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();
}
},
mounted() {
},
watch:{
popData:{
immediate:true,
deep:true,
handler(n,o){
// 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;
}
</style>