CN-1540 fix: 提取Tag展示逻辑公共部分
This commit is contained in:
@@ -202,9 +202,9 @@ import relatedServer from '@/mixins/relatedServer'
|
||||
import Loading from '@/components/common/Loading'
|
||||
import axios from 'axios'
|
||||
import { api } from '@/utils/api'
|
||||
import { entityDefaultColor, entityDetailTags, tagValueLabelMapping } from '@/utils/constants'
|
||||
import { entityDefaultColor } from '@/utils/constants'
|
||||
import _ from 'lodash'
|
||||
import { getTagColor } from '@/utils/tools'
|
||||
import { getTagColor, formatTags } from '@/utils/tools'
|
||||
|
||||
export default {
|
||||
name: 'Row',
|
||||
@@ -303,28 +303,7 @@ export default {
|
||||
axios.get(`${url}?resource=${this.entity.entityValue}`).then(responese => {
|
||||
const res = responese.data
|
||||
if (responese.status === 200) {
|
||||
Object.keys(res.data).forEach(k => {
|
||||
if (k !== 'userDefinedTags' && res.data[k]) {
|
||||
// 此处是vpnLearningDomain/Ip/App的tag
|
||||
if (_.isArray(res.data[k])) {
|
||||
res.data[k].forEach(k3 => {
|
||||
const find = entityDetailTags[this.entity.entityType].find(t => t.name === k3.pluginName)
|
||||
if (find) {
|
||||
this.levelTwoTags.push({ key: 'pluginName', value: this.tagValueHandler(k3.pluginName), type: find.type })
|
||||
} else {
|
||||
this.levelTwoTags.push({ key: 'pluginName', value: this.tagValueHandler(k3.pluginName), color: k3.knowledgeBase ? (k3.knowledgeBase.color || entityDefaultColor) : entityDefaultColor })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Object.keys(res.data[k]).forEach(k2 => {
|
||||
const find = entityDetailTags[this.entity.entityType].find(t => t.name === k2)
|
||||
if (find) {
|
||||
this.levelTwoTags.push({ key: k2, value: this.tagValueHandler(res.data[k][k2]), type: find.type })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
formatTags(res.data, this.entity.entityType, this.levelTwoTags)
|
||||
if (_.isArray(res.data.userDefinedTags)) {
|
||||
this.levelTwoTags = _.concat(this.levelTwoTags, res.data.userDefinedTags.map(tag => ({ value: tag.tagValue, color: tag.knowledgeBase ? tag.knowledgeBase.color : entityDefaultColor })))
|
||||
}
|
||||
@@ -332,10 +311,6 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
tagValueHandler (value) {
|
||||
const find = tagValueLabelMapping.find(t => t.value === value)
|
||||
return find ? find.name : value
|
||||
},
|
||||
/* 切换折叠状态 */
|
||||
switchCollapse () {
|
||||
this.isCollapse = !this.isCollapse
|
||||
|
||||
Reference in New Issue
Block a user