2021-06-23 15:57:34 +08:00
|
|
|
<template>
|
2021-07-14 15:40:05 +08:00
|
|
|
<el-table
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
ref="table"
|
|
|
|
|
class="pie-table"
|
|
|
|
|
:data="pieTableData"
|
|
|
|
|
style="width: 100%;border: 1px solid #E7EAED"
|
|
|
|
|
:row-key="getRowKey"
|
|
|
|
|
@expand-change="currentChange"
|
|
|
|
|
current-row-key="domain"
|
|
|
|
|
tooltip-effect="light"
|
|
|
|
|
:expand-row-keys="expandRowKeys"
|
|
|
|
|
:size="'mini'"
|
|
|
|
|
:height="'100%'">
|
|
|
|
|
<el-table-column type="expand" :min-width="'5%'">
|
|
|
|
|
<template #default="props" style="height: auto">
|
|
|
|
|
<el-table
|
|
|
|
|
tooltip-effect="light"
|
|
|
|
|
class="expand-table"
|
|
|
|
|
:data="childrenTableData"
|
|
|
|
|
style="width: 100%;"
|
|
|
|
|
:show-header="false"
|
2021-06-23 15:57:34 +08:00
|
|
|
:size="'mini'"
|
|
|
|
|
:height="'100%'">
|
2021-07-14 15:40:05 +08:00
|
|
|
<el-table-column
|
|
|
|
|
width="48">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
v-for="(item, index) in tableTitlesOther"
|
|
|
|
|
:key="index"
|
|
|
|
|
show-overflow-tooltip
|
|
|
|
|
:min-width="item.width"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
#default="{row}">
|
2021-07-07 15:51:52 +08:00
|
|
|
<span v-if="item.prop === 'nameColumn'">
|
2021-07-14 15:40:05 +08:00
|
|
|
{{ nameColumn === 'fqdnCategoryName' ? row['fqdnCategoryName'] : row['reputationLevel'] }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
<span v-else-if="item.prop === 'bytes' || item.prop === 'packets' || item.prop === 'sessions'">
|
|
|
|
|
{{ shortFormatter(row[item.prop]) }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
<span v-else>
|
|
|
|
|
{{ row[item.prop] }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
v-for="(item, index) in tableTitles"
|
|
|
|
|
:key="index"
|
|
|
|
|
show-overflow-tooltip
|
|
|
|
|
:min-width="item.width"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
#default="{row}">
|
2021-07-07 15:51:52 +08:00
|
|
|
<span v-if="item.prop === 'nameColumn'">
|
2021-07-14 15:40:05 +08:00
|
|
|
{{ nameColumn === 'fqdnCategoryName' ? row['categoryName'] : row['reputationLevel'] }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
<span v-else-if="item.prop === 'bytes' || item.prop === 'packets' || item.prop === 'sessions'">
|
|
|
|
|
{{ shortFormatter(row[item.prop]) }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
<span v-else>
|
|
|
|
|
{{ row[item.prop] }}
|
2021-07-07 15:51:52 +08:00
|
|
|
</span>
|
2021-07-14 15:40:05 +08:00
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2021-06-23 15:57:34 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-07-20 18:58:55 +08:00
|
|
|
import { shortFormatter } from '@/components/charts/chart-formatter'
|
2021-07-07 15:51:52 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { replaceUrlPlaceholder } from '@/utils/tools'
|
2021-07-14 15:40:05 +08:00
|
|
|
|
2021-06-23 15:57:34 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'PieTable',
|
|
|
|
|
props: {
|
2021-07-07 15:51:52 +08:00
|
|
|
tableData: Array,
|
|
|
|
|
chartInfo: Object,
|
|
|
|
|
order: String,
|
|
|
|
|
startTime: {
|
|
|
|
|
type: Number
|
|
|
|
|
},
|
|
|
|
|
endTime: {
|
|
|
|
|
type: Number
|
|
|
|
|
}
|
2021-06-23 15:57:34 +08:00
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
tableData: {
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n) {
|
2021-07-07 15:51:52 +08:00
|
|
|
this.pieTableData = JSON.parse((JSON.stringify(n)))
|
|
|
|
|
this.pieTableData.forEach(item => {
|
|
|
|
|
item.children = []
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
chartInfo: {
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n) {
|
|
|
|
|
if (n && n.params) {
|
2021-07-13 18:43:40 +08:00
|
|
|
this.nameColumn = n.params.nameColumn
|
2021-07-07 15:51:52 +08:00
|
|
|
}
|
2021-06-23 15:57:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
2021-07-07 15:51:52 +08:00
|
|
|
nameColumn: '',
|
|
|
|
|
pieTableData: [],
|
2021-07-07 17:34:19 +08:00
|
|
|
childrenTableData: [],
|
|
|
|
|
expandRowKeys: [],
|
2021-06-23 15:57:34 +08:00
|
|
|
tableTitles: [
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.domain'),
|
2021-06-23 15:57:34 +08:00
|
|
|
prop: 'domain',
|
|
|
|
|
width: '20%'
|
|
|
|
|
},
|
2021-07-07 15:51:52 +08:00
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('entities.category'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'nameColumn',
|
|
|
|
|
width: '22%'
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.sessions'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'sessions',
|
|
|
|
|
width: '18%'
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.packets'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'packets',
|
|
|
|
|
width: '18%'
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.bytes'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'bytes',
|
|
|
|
|
width: '18%'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
tableTitlesOther: [
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.serverIp'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'serverIp',
|
|
|
|
|
width: '20%'
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.reputation'),
|
2021-07-07 15:51:52 +08:00
|
|
|
prop: 'nameColumn',
|
|
|
|
|
width: '22%'
|
|
|
|
|
},
|
2021-06-23 15:57:34 +08:00
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.sessions'),
|
2021-06-23 15:57:34 +08:00
|
|
|
prop: 'sessions',
|
2021-07-07 15:51:52 +08:00
|
|
|
width: '18%'
|
2021-06-23 15:57:34 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.packets'),
|
2021-06-23 15:57:34 +08:00
|
|
|
prop: 'packets',
|
2021-07-07 15:51:52 +08:00
|
|
|
width: '18%'
|
2021-06-23 15:57:34 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-07-14 15:40:05 +08:00
|
|
|
label: this.$t('common.bytes'),
|
2021-06-23 15:57:34 +08:00
|
|
|
prop: 'bytes',
|
2021-07-07 15:51:52 +08:00
|
|
|
width: '18%'
|
2021-06-23 15:57:34 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2021-07-07 15:51:52 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
shortFormatter: shortFormatter,
|
|
|
|
|
// rowChange (echartParams) {
|
|
|
|
|
// const nameColumnKey = this.nameColumn === 'fqdnCategoryName' ? 'categoryName' : 'reputationLevel'
|
|
|
|
|
// const row = this.pieTableData.find(item => echartParams.name === item[nameColumnKey])
|
|
|
|
|
// this.toggleRowExpansion(row)
|
|
|
|
|
// },
|
|
|
|
|
// toggleRowExpansion (row) {
|
|
|
|
|
// this.$refs.table.toggleRowExpansion(row)
|
|
|
|
|
// },
|
2021-07-07 17:34:19 +08:00
|
|
|
currentChange (row, expandedRows) {
|
2021-07-14 15:40:05 +08:00
|
|
|
this.childrenTableData = []
|
2021-07-07 17:34:19 +08:00
|
|
|
|
|
|
|
|
// this.$refs.table.toggleRowExpansion(row)
|
2021-07-14 15:40:05 +08:00
|
|
|
const url = this.chartInfo.params.urlChildrenTable
|
|
|
|
|
const queryParams = {
|
|
|
|
|
startTime: parseInt(this.startTime / 1000),
|
|
|
|
|
endTime: parseInt(this.endTime / 1000),
|
|
|
|
|
order: this.order,
|
2021-07-20 18:58:55 +08:00
|
|
|
domain: row.domain,
|
|
|
|
|
limit: 10
|
2021-07-14 15:40:05 +08:00
|
|
|
}
|
2021-07-07 15:51:52 +08:00
|
|
|
get(replaceUrlPlaceholder(url, queryParams)).then(response2 => {
|
|
|
|
|
if (response2.code === 200) {
|
2021-07-07 17:34:19 +08:00
|
|
|
this.childrenTableData = response2.data.result
|
2021-07-07 15:51:52 +08:00
|
|
|
}
|
2021-07-14 15:40:05 +08:00
|
|
|
if (this.expandRowKeys[0] && (row.domain === this.expandRowKeys[0])) {
|
|
|
|
|
this.expandRowKeys = []
|
|
|
|
|
} else {
|
|
|
|
|
this.expandRowKeys = [row.domain]
|
|
|
|
|
}
|
2021-07-07 15:51:52 +08:00
|
|
|
})
|
2021-07-07 17:34:19 +08:00
|
|
|
},
|
|
|
|
|
getRowKey (row) {
|
|
|
|
|
return row.domain
|
2021-07-07 15:51:52 +08:00
|
|
|
}
|
2021-06-23 15:57:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2021-07-07 17:34:19 +08:00
|
|
|
<style scoped lang="scss">
|
2021-07-14 15:40:05 +08:00
|
|
|
/deep/ .el-table__expanded-cell[class*=cell] {
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.expand-table /deep/ .el-table__body .el-table__row:last-of-type td {
|
|
|
|
|
border: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pie-table {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: #333333;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
|
|
|
|
/deep/ .el-table__header-wrapper {
|
|
|
|
|
.cell {
|
|
|
|
|
color: #333;
|
2021-06-23 15:57:34 +08:00
|
|
|
}
|
2021-07-14 15:40:05 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.expand-table {
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
|
|
|
|
/deep/ .el-table__body-wrapper {
|
|
|
|
|
height: auto !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-23 15:57:34 +08:00
|
|
|
</style>
|