import {
getNameDescriptionTableColumn,
getProjectDomainTableColumn,
getStatusTableColumn,
getEnabledTableColumn,
getTimeTableColumn,
getPublicScopeTableColumn,
} from '@/utils/common/tableColumn'
import i18n from '@/locales'
import { getTagColor, getTagTitle } from '@/utils/common/tag'
import { getTargetColumns } from '../utils'
export default {
created () {
this.columns = [
getNameDescriptionTableColumn({
onManager: this.onManager,
hideField: true,
edit: (row) => {
const { isDomainMode, userInfo } = this.$store.getters
if (isDomainMode && (userInfo.projectDomainId !== row.domain_id)) {
return false
}
return true
},
showDesc: (row) => {
const { isDomainMode, userInfo } = this.$store.getters
if (isDomainMode && (userInfo.projectDomainId !== row.domain_id)) {
return false
}
return true
},
slotCallback: row => {
return (
this.handleOpenSidepage(row)}>{row.name}
)
},
}),
getStatusTableColumn({
statusModule: 'projectMapping',
minWidth: 100,
}),
getEnabledTableColumn(),
{
field: 'rules',
title: i18n.t('cloudenv.text_582'),
slots: {
default: ({ row }) => {
const columns = [
{
field: 'tags',
title: i18n.t('cloudenv.text_582'),
slots: {
default: ({ row }) => {
if (!row.tags) return '-'
return [
{this.getRuleCondition(row)}
, {
row.tags.map(item => {
const rgb = getTagColor(item.key, item.value, 'rgb')
const strRgb = rgb.join(',')
const text = getTagTitle('user:' + item.key, item.value)
return (
{ text }
)
})
}
]
},
},
},
{
field: 'project_name',
title: i18n.t('cloudenv.text_584'),
formatter: ({ row }) => {
if (row.condition === 'and' && !row.hasOwnProperty('project_id') && !row.hasOwnProperty('project')) {
return i18n.t('cloudenv.project_same_as_tag_value')
}
let project = row.project
if (project) {
if (row.project_id) {
project += ` (${this.$t('cloudenv.target_project')})`
} else {
project += ` (${this.$t('cloudenv.target_name')})`
}
}
return project || '-'
},
},
]
return [
]
},
},
},
{
title: this.$t('cloudenv.text_503'),
field: 'account',
slots: {
default: ({ row }) => {
const ret = []
if (row.accounts && row.accounts.length) {
const resIds = row.accounts.map(v => v.id)
ret.push()
}
if (row.managers && row.managers.length) {
const resIds = row.managers.map(v => v.id)
ret.push()
}
if (!ret.length) return '-'
return ret
},
},
},
getPublicScopeTableColumn({ vm: this }),
getProjectDomainTableColumn({ sortable: false }),
getTimeTableColumn(),
]
},
methods: {
getRuleCondition (data) {
const { condition } = data
if (condition === 'or') {
return i18n.t('cloudenv.text_587')
} else if (data.hasOwnProperty('project_id') || data.hasOwnProperty('project')) {
return i18n.t('cloudenv.text_588')
} else {
return i18n.t('cloudenv.match_by_tag_key')
}
},
},
}