CN-64 fix: entity左侧筛选框全为单选
This commit is contained in:
@@ -11,17 +11,17 @@
|
|||||||
>
|
>
|
||||||
<el-tree
|
<el-tree
|
||||||
:data="f.data"
|
:data="f.data"
|
||||||
:load="(node, resolve) => f.loadFilter(node, resolve, f.filterType, f.childrenKey, f.key)"
|
:load="(node, resolve) => loadFilter(node, resolve, f)"
|
||||||
:node-key="f.key"
|
:node-key="f.key"
|
||||||
:props="{ isLeaf: 'leaf' }"
|
:props="{ isLeaf: 'leaf' }"
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:lazy="i === 0"
|
:lazy="i === 0"
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-click="nodeClick"
|
@node-click="(data, node, component) => nodeClick(data, node, component, i)"
|
||||||
>
|
>
|
||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<div class="filter-item">
|
<div class="filter-item">
|
||||||
<span>{{node.level === 1 ? data[f.key] : ''}}{{node.level === 2 ? data[f.childrenKey] : ''}}</span>
|
<div :title="node.level === 1 ? data[f.key] : (node.level === 2 ? data[f.childrenKey] : '')">{{node.level === 1 ? data[f.key] : (node.level === 2 ? data[f.childrenKey] : '')}}</div>
|
||||||
<span>{{data.count}}</span>
|
<span>{{data.count}}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -45,18 +45,26 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
nodeClick (data, node) {
|
nodeClick (data, node, component, index) {
|
||||||
this.$emit('select', node, data)
|
// if ((data.country && !data.region) || ())
|
||||||
|
this.$emit('select', data, node, index)
|
||||||
},
|
},
|
||||||
showMore (key, hasnotMore) {
|
showMore (key, hasnotMore) {
|
||||||
if (!hasnotMore) {
|
if (!hasnotMore) {
|
||||||
this.$emit('showMore', key)
|
this.$emit('showMore', key)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
loadFilter (node, resolve, f) {
|
||||||
|
this.$emit('loadFilter', node, resolve, f.filterType, f.childrenKey, f.key)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
filterData (n) {
|
filterData: {
|
||||||
this.active = ['0', '1']
|
deep: true,
|
||||||
|
immediate: true,
|
||||||
|
handler (n) {
|
||||||
|
this.active = ['0', '1']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,6 +114,12 @@ export default {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
div {
|
||||||
|
max-width: 140px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.filter__more {
|
.filter__more {
|
||||||
padding-left: 24px;
|
padding-left: 24px;
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export default {
|
|||||||
} else if (this.isEcharts) {
|
} else if (this.isEcharts) {
|
||||||
const dom = document.getElementById(`chart${this.chartInfo.id}`)
|
const dom = document.getElementById(`chart${this.chartInfo.id}`)
|
||||||
!this.myChart && (this.myChart = echarts.init(dom))
|
!this.myChart && (this.myChart = echarts.init(dom))
|
||||||
this.chartOption = JSON.parse(JSON.stringify(getOption(this.chart.type)))
|
this.chartOption = this.$_.cloneDeep(getOption(this.chart.type))
|
||||||
if (chartParams) {
|
if (chartParams) {
|
||||||
if (this.isEchartsWithTable) {
|
if (this.isEchartsWithTable) {
|
||||||
this.initEchartsWithPieTable(chartParams)
|
this.initEchartsWithPieTable(chartParams)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
:filter-data="filterData"
|
:filter-data="filterData"
|
||||||
@select="select"
|
@select="select"
|
||||||
@showMore="showMore"
|
@showMore="showMore"
|
||||||
|
@loadFilter="loadFilter"
|
||||||
></left-filter>
|
></left-filter>
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<entity-list
|
<entity-list
|
||||||
@@ -130,14 +131,15 @@ export default {
|
|||||||
},
|
},
|
||||||
handleData (n) {
|
handleData (n) {
|
||||||
this.listData = []
|
this.listData = []
|
||||||
|
this.filterData = []
|
||||||
const requests = []
|
const requests = []
|
||||||
const data = []
|
const data = []
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 'ip': {
|
case 'ip': {
|
||||||
requests.push(this.loadFilterData(n, 'country'))
|
requests.push(this.loadFilterData(n, 'country'))
|
||||||
requests.push(this.loadFilterData(n, 'asn'))
|
requests.push(this.loadFilterData(n, 'asn'))
|
||||||
data.push({ title: this.$t('entities.countryOrRegion'), key: 'country', childrenKey: 'region', type: 'country', childrenType: 'region', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.countryOrRegion'), key: 'country', childrenKey: 'region', type: 'country', childrenType: 'region' })
|
||||||
data.push({ title: this.$t('entities.asn'), key: 'asn', type: 'asn', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.asn'), key: 'asn', type: 'asn' })
|
||||||
getEntityIpList({ ...this.pageObjRight }).then(res => {
|
getEntityIpList({ ...this.pageObjRight }).then(res => {
|
||||||
this.listData = res.data.result
|
this.listData = res.data.result
|
||||||
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
||||||
@@ -147,8 +149,8 @@ export default {
|
|||||||
case 'domain': {
|
case 'domain': {
|
||||||
requests.push(this.loadFilterData(n, 'categoryGroup'))
|
requests.push(this.loadFilterData(n, 'categoryGroup'))
|
||||||
requests.push(this.loadFilterData(n, 'reputationLevel'))
|
requests.push(this.loadFilterData(n, 'reputationLevel'))
|
||||||
data.push({ title: this.$t('entities.groupAndName'), key: 'categoryGroup', childrenKey: 'categoryName', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.groupAndName'), key: 'categoryGroup', childrenKey: 'categoryName' })
|
||||||
data.push({ title: this.$t('entities.creditLevel'), key: 'reputationLevel', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.creditLevel'), key: 'reputationLevel' })
|
||||||
getEntityDomainList({ ...this.pageObjRight }).then(res => {
|
getEntityDomainList({ ...this.pageObjRight }).then(res => {
|
||||||
this.listData = res.data.result
|
this.listData = res.data.result
|
||||||
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
||||||
@@ -158,8 +160,8 @@ export default {
|
|||||||
case 'app': {
|
case 'app': {
|
||||||
requests.push(this.loadFilterData(n, 'appCategory'))
|
requests.push(this.loadFilterData(n, 'appCategory'))
|
||||||
requests.push(this.loadFilterData(n, 'appRisk'))
|
requests.push(this.loadFilterData(n, 'appRisk'))
|
||||||
data.push({ title: this.$t('entities.categoryAndSub'), key: 'appCategory', childrenKey: 'appSubcategory', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.categoryAndSub'), key: 'appCategory', childrenKey: 'appSubcategory' })
|
||||||
data.push({ title: this.$t('entities.riskLevel'), key: 'appRisk', loadFilter })
|
data.push({ filterType: n, title: this.$t('entities.riskLevel'), key: 'appRisk' })
|
||||||
getEntityAppList({ ...this.pageObjRight }).then(res => {
|
getEntityAppList({ ...this.pageObjRight }).then(res => {
|
||||||
this.listData = res.data.result
|
this.listData = res.data.result
|
||||||
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
this.pageObjRight = { ...this.pageObjRight, total: res.statistics.result_size }
|
||||||
@@ -176,8 +178,9 @@ export default {
|
|||||||
this.filterData = data
|
this.filterData = data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async select (node, data) {
|
async select (data, node, index) {
|
||||||
const res = await loadList(node, data, this.filterType, this.pageObjRight)
|
this.pageObjRight = { ...this.pageObjRight, ...data }
|
||||||
|
const res = await loadList(node, this.filterType, this.pageObjRight)
|
||||||
this.listData = res.data.result
|
this.listData = res.data.result
|
||||||
},
|
},
|
||||||
getEntityData (param) {
|
getEntityData (param) {
|
||||||
@@ -190,6 +193,38 @@ export default {
|
|||||||
pageNoRight (val) {
|
pageNoRight (val) {
|
||||||
this.pageObjRight.pageNo = val
|
this.pageObjRight.pageNo = val
|
||||||
this.handleData(this.filterType)
|
this.handleData(this.filterType)
|
||||||
|
},
|
||||||
|
loadFilter (node, resolve, filterType, key, parentKey) {
|
||||||
|
if (node.level === 0) {
|
||||||
|
resolve(node.data)
|
||||||
|
} else {
|
||||||
|
const param = { type: key }
|
||||||
|
param[parentKey] = (node.data)[parentKey]
|
||||||
|
let req = null
|
||||||
|
switch (filterType) {
|
||||||
|
case 'ip': {
|
||||||
|
req = getEntityIpFilterList(param)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'domain': {
|
||||||
|
req = getEntityDomainFilterList(param)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'app': {
|
||||||
|
req = getEntityAppFilterList(param)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default: break
|
||||||
|
}
|
||||||
|
if (req !== null) {
|
||||||
|
req.then(res => {
|
||||||
|
res = res.map(r => {
|
||||||
|
return { ...r, leaf: true }
|
||||||
|
})
|
||||||
|
resolve(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -221,16 +256,14 @@ export default {
|
|||||||
childrenKey: 'region',
|
childrenKey: 'region',
|
||||||
data: country,
|
data: country,
|
||||||
hasnotMore: this.$_.isEmpty(country) || country.length < 10,
|
hasnotMore: this.$_.isEmpty(country) || country.length < 10,
|
||||||
filterType: this.filterType,
|
filterType: this.filterType
|
||||||
loadFilter
|
|
||||||
})
|
})
|
||||||
this.filterData.push({
|
this.filterData.push({
|
||||||
title: this.$t('entities.asn'),
|
title: this.$t('entities.asn'),
|
||||||
key: 'asn',
|
key: 'asn',
|
||||||
data: asn,
|
data: asn,
|
||||||
hasnotMore: this.$_.isEmpty(asn) || asn.length < 10,
|
hasnotMore: this.$_.isEmpty(asn) || asn.length < 10,
|
||||||
filterType: this.filterType,
|
filterType: this.filterType
|
||||||
loadFilter
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setup () {
|
setup () {
|
||||||
@@ -241,41 +274,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const loadFilter = (node, resolve, filterType, key, parentKey) => {
|
const loadList = async (node, filterType, pageObj) => {
|
||||||
if (node.level === 0) {
|
|
||||||
resolve(node.data)
|
|
||||||
} else {
|
|
||||||
const param = { type: key }
|
|
||||||
param[parentKey] = (node.data)[parentKey]
|
|
||||||
let req = null
|
|
||||||
switch (filterType) {
|
|
||||||
case 'ip': {
|
|
||||||
req = getEntityIpFilterList(param)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'domain': {
|
|
||||||
req = getEntityDomainFilterList(param)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'app': {
|
|
||||||
req = getEntityAppFilterList(param)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: break
|
|
||||||
}
|
|
||||||
if (req !== null) {
|
|
||||||
req.then(res => {
|
|
||||||
res = res.map(r => {
|
|
||||||
return { ...r, leaf: true }
|
|
||||||
})
|
|
||||||
resolve(res)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const loadList = async (node, data, filterType, pageObj) => {
|
|
||||||
let res
|
let res
|
||||||
const param = { ...pageObj, ...data }
|
const param = { ...pageObj }
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
case 'ip': {
|
case 'ip': {
|
||||||
res = await getEntityIpList(param)
|
res = await getEntityIpList(param)
|
||||||
|
|||||||
Reference in New Issue
Block a user