CN-671 Dashboard - 多维度表格优化:列数值和环比靠中间对齐;表格增加“show more”,接口请求50条,默认展示10条,点击show more加载全部;增加列排序功能;

This commit is contained in:
hanyuxia
2022-08-26 16:26:31 +08:00
parent 11b1941146
commit 15eb858602
3 changed files with 125 additions and 91 deletions

View File

@@ -1,7 +1,7 @@
.tabs { .tabs {
$blue: #2C72C6; $blue: #2C72C6;
$grey: #353636; $grey: #353636;
height:100%; height:calc(100% - 64px);
font-size:12px; font-size:12px;
.tab-hide{ .tab-hide{
margin-top:40px; margin-top:40px;
@@ -12,7 +12,7 @@
height:100%; height:100%;
border: 1px solid #E2E5EC;; border: 1px solid #E2E5EC;;
padding:1px; padding:1px;
border-radius: 4px; border-radius: 4px 4px 0 0;
.tab-table { .tab-table {
border:0px; border:0px;
.data-click:hover{ .data-click:hover{
@@ -21,12 +21,22 @@
} }
.data-total{ .data-total{
display: flex !important; display: flex !important;
justify-content:center;
}
.data-value{
display: flex !important;
justify-content:right;
width:50%;
}
.data-trend{
display: flex;
width:50%;
} }
.data-total-trend { .data-total-trend {
display: flex; display: flex;
justify-content:left;
margin-left: 6px; margin-left: 6px;
align-items: center; align-items: center;
justify-content: center;
margin-top: 2px; margin-top: 2px;
border-radius: 10px; border-radius: 10px;
font-weight:500; font-weight:500;
@@ -92,10 +102,15 @@
height: calc(100% - 40px); height: calc(100% - 40px);
border:none; border:none;
.el-table__body-wrapper { .el-table__body-wrapper {
height: calc(100% - 32px) !important; height: calc(100% - 34px) !important;
} }
} }
} }
.cn-chart__tabs-hide-tab {
.el-tabs__content {
height: 100% !important;
}
}
.tab-search { .tab-search {
position:absolute; position:absolute;
height:40px; height:40px;
@@ -270,3 +285,33 @@
right:200px !important; right:200px !important;
transform: translateY(126px) !important;*/ transform: translateY(126px) !important;*/
} }
.fixed-row {
display:flex;
justify-content: flex-start;
align-items: center;
margin-top: 2px;
width: 100%;
height:40px;
border:solid 1px #E2E5EC;
padding-left:10px !important;
text-align: left;
border-top:0px;
border-radius:0 0 4px 4px;
color:#046eca;
.fixed-button {
display:flex;
justify-content: center;
padding:7px 10px;
align-items: center;
height: 30px;
}
.fixed-button:hover {
cursor:pointer;
background: #e6f4ff;
box-shadow: 0 2px 4px 0 rgba(51,51,51,0.02);
border-radius: 4px;
}
}
.btn-up{
margin-top:40px;
}

View File

@@ -688,13 +688,15 @@ export const networkTable = {
panelIdOfThirdMenu: drillDownPanelTypeMapping.npmThirdMenu, panelIdOfThirdMenu: drillDownPanelTypeMapping.npmThirdMenu,
bytesColumnNameGroup: bytesColumnNameGroupForNpm, bytesColumnNameGroup: bytesColumnNameGroupForNpm,
packetsColumnNameGroup: {}, // 无metric下拉列表条件用不到此属性 packetsColumnNameGroup: {}, // 无metric下拉列表条件用不到此属性
sessionsColumnNameGroup: {},// 无metric下拉列表条件用不到此属性 sessionsColumnNameGroup: {}, // 无metric下拉列表条件用不到此属性
bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForNmp, bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForNmp,
packetsCycleColumnNameGroup: {}, packetsCycleColumnNameGroup: {},
sessionsCycleColumnNameGroup: {} sessionsCycleColumnNameGroup: {}
} }
} }
export const networkDefaultLimit = 50
export const dnsServerRole = { export const dnsServerRole = {
RTDNS: 'RTDNS', RTDNS: 'RTDNS',
TLDNS: 'TLDNS', TLDNS: 'TLDNS',

View File

@@ -1,8 +1,7 @@
<template> <template>
<div class="tabs"> <div class="tabs" :style="showTabs?'':'height: calc(100% - 104px);'">
<el-tabs v-model="activeTab" <el-tabs v-model="activeTab"
class="cn-chart__tabs" :class="showTabs?'cn-chart__tabs':'tab-hide cn-chart__tabs cn-chart__tabs-hide-tab'"
:class="showTabs?'':'tab-hide'"
@tab-click="handleClick" @tab-click="handleClick"
> >
<template v-for="(tab,index) in list"> <template v-for="(tab,index) in list">
@@ -18,17 +17,21 @@
<el-table <el-table
:id="`tabTable_${index}`" :id="`tabTable_${index}`"
:ref="`dataTable_${index}`" :ref="`dataTable_${index}`"
:data="tableData" :data="tableData.slice(0,showRecordNum)"
border border
:cell-style="tableCellStyle" :cell-style="tableCellStyle"
:header-cell-style="tableHeaderCellStyle" :header-cell-style="tableHeaderCellStyle"
class="tab-table" class="tab-table"
height="100%" height="100%"
:default-sort="{ prop: 'date', order: 'descending' }"
empty-text=" " empty-text=" "
> >
<template v-for="(item,index) in customTableTitles"> <template v-for="(item,index) in customTableTitles">
<el-table-column <el-table-column
v-if="item.checked" v-if="item.checked"
sortable
align="center"
:prop="item.prop"
class="data-column" class="data-column"
> >
<template #header> <template #header>
@@ -37,7 +40,10 @@
<template #default="scope" :column="item"> <template #default="scope" :column="item">
<template v-if="item.columnType === tableColumnType.chainRatio" > <template v-if="item.columnType === tableColumnType.chainRatio" >
<div class="data-total" > <div class="data-total" >
<div class="data-value">
{{scope.row[item.prop]?((scope.row[item.prop][0]||scope.row[item.prop][0]===0)? unitConvert(scope.row[item.prop][0], unitTypes.number).join(' ') : '-'):'' }} {{scope.row[item.prop]?((scope.row[item.prop][0]||scope.row[item.prop][0]===0)? unitConvert(scope.row[item.prop][0], unitTypes.number).join(' ') : '-'):'' }}
</div>
<div class="data-trend">
<template v-if="scope.row[item.prop]"> <template v-if="scope.row[item.prop]">
<div v-if="scope.row[item.prop][1] === 'up'" class="data-total-trend data-total-trend-red"> <div v-if="scope.row[item.prop][1] === 'up'" class="data-total-trend data-total-trend-red">
<i class="cn-icon-rise1 cn-icon"></i><span>{{scope.row[item.prop][2]}}</span> <i class="cn-icon-rise1 cn-icon"></i><span>{{scope.row[item.prop][2]}}</span>
@@ -53,6 +59,7 @@
- -
</template> </template>
</div> </div>
</div>
</template> </template>
<template v-else-if="item.columnType === tableColumnType.dillDown" > <template v-else-if="item.columnType === tableColumnType.dillDown" >
<div class="data-click" @click="handleTabValue(item.label,scope.row['tab'])">{{scope.row['tab']}}</div> <div class="data-click" @click="handleTabValue(item.label,scope.row['tab'])">{{scope.row['tab']}}</div>
@@ -72,10 +79,9 @@
</div> </div>
</template> </template>
</el-table> </el-table>
</el-tab-pane> </el-tab-pane>
</template>
</template>
</el-tabs> </el-tabs>
<div class="tab-search" > <div class="tab-search" >
<div class="search-select" v-if="hasMetricSearch"> <div class="search-select" v-if="hasMetricSearch">
@@ -151,13 +157,14 @@
</el-tabs> </el-tabs>
</el-popover> </el-popover>
</div> </div>
</div> </div>
<div class="fixed-row">
<div class="fixed-button" :class="showTabs?'':''" @click="showMore" >{{$t('network.showTop50Results')}}</div>
</div>
</template> </template>
<script> <script>
import { ref } from 'vue' import { ref } from 'vue'
import { operationType, unitTypes, networkTable, tableColumnType } from '@/utils/constants' import { operationType, unitTypes, networkTable, tableColumnType, networkDefaultLimit } from '@/utils/constants'
import { get } from '@/utils/http' import { get } from '@/utils/http'
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { getChainRatio, computeScore } from '@/utils/tools' import { getChainRatio, computeScore } from '@/utils/tools'
@@ -197,11 +204,12 @@ export default {
networkTabList: [], // 原始状态列表 networkTabList: [], // 原始状态列表
showBackground: false, showBackground: false,
tableData: [], tableData: [],
showRecordNum: 10,
showTabs: true, showTabs: true,
columnNameGroup: {}, columnNameGroup: {},
cycleColumnNameGroup: {}, cycleColumnNameGroup: {},
metricUnit: 'bytes', metricUnit: 'bytes',
//loading: false, // loading: false,
tableColumnType: tableColumnType, tableColumnType: tableColumnType,
curTable: {}, // 当前的表格类型 curTable: {}, // 当前的表格类型
tableType: '', tableType: '',
@@ -234,14 +242,14 @@ export default {
const curTab = this.getCurTab() const curTab = this.getCurTab()
let queryParams = { let queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop type: curTab.prop
} }
const condition = this.$store.getters.getQueryCondition const condition = this.$store.getters.getQueryCondition
if (condition) { if (condition) {
queryParams = { queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop, type: curTab.prop,
q: condition q: condition
} }
@@ -252,6 +260,14 @@ export default {
}, },
mixins: [chartMixin], mixins: [chartMixin],
methods: { methods: {
showMore () {
this.showRecordNum = 50
},
rowClass (row, column, rowIndex, columnIndex) {
if (rowIndex === 49) {
return 'fixed-row'
}
},
changeMetric () { changeMetric () {
const beforeType = this.$store.getters.getTabOperationBeforeType const beforeType = this.$store.getters.getTabOperationBeforeType
if (beforeType != operationType.thirdMenu) { if (beforeType != operationType.thirdMenu) {
@@ -329,14 +345,14 @@ export default {
} }
let queryParams = { let queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop type: curTab.prop
} }
const condition = this.$store.getters.getQueryCondition const condition = this.$store.getters.getQueryCondition
if (condition) { if (condition) {
queryParams = { queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop, type: curTab.prop,
q: condition q: condition
} }
@@ -357,6 +373,22 @@ export default {
return tabObjGroup = this.networkTabList.filter(item => item.checked)[0] return tabObjGroup = this.networkTabList.filter(item => item.checked)[0]
} }
}, },
// 隐藏tabs的标题
hideTabs (curTab) {
// 此处的id为tab-name
this.list.forEach(item => {
const tabDom = document.getElementById('tab-' + item.label)
const paneDom = document.getElementById('pane-' + item.label)
if (tabDom) {
tabDom.style.display = 'none'
}
if (paneDom) {
if (curTab.label === item.label) {
paneDom.style.display = ''
}
}
})
},
initData () { initData () {
const curTab = this.getCurTab() const curTab = this.getCurTab()
const columnName = this.$store.getters.getBreadcrumbColumnName const columnName = this.$store.getters.getBreadcrumbColumnName
@@ -377,19 +409,7 @@ export default {
} }
this.showTabs = true this.showTabs = true
} else if (curOperationType === operationType.thirdMenu) { // 点击的为第三级菜单 } else if (curOperationType === operationType.thirdMenu) { // 点击的为第三级菜单
// 此处的id为tab-name this.hideTabs(curTab)
this.list.forEach(item => {
const tabDom = document.getElementById('tab-' + item.label)
const paneDom = document.getElementById('pane-' + item.label)
if (tabDom) {
tabDom.style.display = 'none'
}
if (paneDom) {
if (curTab.label === item.label) {
paneDom.style.display = ''
}
}
})
this.customTableTitles[0].label = curTab.label this.customTableTitles[0].label = curTab.label
this.showTabs = false this.showTabs = false
} else if (curOperationType === operationType.fourthMenu) { // 点击的为第四级菜单 } else if (curOperationType === operationType.fourthMenu) { // 点击的为第四级菜单
@@ -411,36 +431,14 @@ export default {
} else if (curOperationType === operationType.changeMetric) { // 切换metric } else if (curOperationType === operationType.changeMetric) { // 切换metric
const beforeOperationType = this.$store.getters.getTabOperationBeforeType const beforeOperationType = this.$store.getters.getTabOperationBeforeType
if (beforeOperationType === operationType.thirdMenu) { if (beforeOperationType === operationType.thirdMenu) {
this.list.forEach(item => { this.hideTabs(curTab)
const tabDom = document.getElementById('tab-' + item.label)
const paneDom = document.getElementById('pane-' + item.label)
if (tabDom) {
tabDom.style.display = 'none'
}
if (paneDom) {
if (curTab.label === item.label) {
paneDom.style.display = ''
}
}
})
this.customTableTitles[0].label = curTab.label this.customTableTitles[0].label = curTab.label
this.showTabs = false this.showTabs = false
} }
} else if (curOperationType === operationType.customize) { // customize } else if (curOperationType === operationType.customize) { // customize
const beforeOperationType = this.$store.getters.getTabOperationBeforeType const beforeOperationType = this.$store.getters.getTabOperationBeforeType
if (beforeOperationType === operationType.thirdMenu) { if (beforeOperationType === operationType.thirdMenu) {
this.list.forEach(item => { this.hideTabs(curTab)
const tabDom = document.getElementById('tab-' + item.label)
const paneDom = document.getElementById('pane-' + item.label)
if (tabDom) {
tabDom.style.display = 'none'
}
if (paneDom) {
if (curTab.label === item.label) {
paneDom.style.display = ''
}
}
})
this.customTableTitles[0].label = curTab.label this.customTableTitles[0].label = curTab.label
this.showTabs = false this.showTabs = false
} else { } else {
@@ -472,10 +470,10 @@ export default {
return otherData return otherData
}) })
if(!this.chartData || this.chartData.length === 0){ if (!this.chartData || this.chartData.length === 0) {
this.isNoData = true this.isNoData = true
this.toggleLoading(false) this.toggleLoading(false)
}else { } else {
this.isNoData = false this.isNoData = false
} }
@@ -560,7 +558,7 @@ export default {
score = computeScore(data, tableColumn.scoreType) score = computeScore(data, tableColumn.scoreType)
} }
item.scoreGroup = item.scoreGroup ? [...item.scoreGroup, score] : [score] item.scoreGroup = item.scoreGroup ? [...item.scoreGroup, score] : [score]
}else { } else {
item.scoreGroup = item.scoreGroup ? [...item.scoreGroup, 0] : [0] item.scoreGroup = item.scoreGroup ? [...item.scoreGroup, 0] : [0]
} }
if (scoreNum >= 5) { if (scoreNum >= 5) {
@@ -671,14 +669,14 @@ export default {
let queryParams = { let queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: tabList[0].prop type: tabList[0].prop
} }
const condition = this.$store.getters.getQueryCondition const condition = this.$store.getters.getQueryCondition
if (condition) { if (condition) {
queryParams = { queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: tabList[0].prop, type: tabList[0].prop,
q: condition q: condition
} }
@@ -842,14 +840,14 @@ export default {
let queryParams = { let queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop type: curTab.prop
} }
const condition = this.$store.getters.getQueryCondition const condition = this.$store.getters.getQueryCondition
if (condition) { if (condition) {
queryParams = { queryParams = {
orderBy: this.orderBy, orderBy: this.orderBy,
limit: 10, limit: networkDefaultLimit,
type: curTab.prop, type: curTab.prop,
q: condition q: condition
} }
@@ -970,7 +968,7 @@ export default {
extraParams = { extraParams = {
type: queryType || this.networkTabList[0].prop, type: queryType || this.networkTabList[0].prop,
orderBy: this.orderBy ? this.orderBy : 'bytesTotal', orderBy: this.orderBy ? this.orderBy : 'bytesTotal',
limit: 10 limit: networkDefaultLimit
} }
const condition = this.$store.getters.getQueryCondition const condition = this.$store.getters.getQueryCondition
if (condition) { if (condition) {
@@ -1033,18 +1031,7 @@ export default {
this.customTableTitles[0].label = curTab.label this.customTableTitles[0].label = curTab.label
this.showTabs = false this.showTabs = false
this.$nextTick(() => { this.$nextTick(() => {
this.list.forEach(item => { this.hideTabs(curTab)
const tabDom = document.getElementById('tab-' + item.label)
const paneDom = document.getElementById('pane-' + item.label)
if (tabDom) {
tabDom.style.display = 'none'
}
if (paneDom) {
if (curTab.label === item.label) {
paneDom.style.display = ''
}
}
})
}) })
} }
this.$nextTick(() => { this.$nextTick(() => {