import * as R from 'ramda' import { getNameDescriptionTableColumn, getBrandTableColumn, getStatusTableColumn, getProjectDomainTableColumn, getPublicScopeTableColumn, getAccountTableColumn, getTimeTableColumn, } from '@/utils/common/tableColumn' import i18n from '@/locales' export default { created () { this.columns = [ getNameDescriptionTableColumn({ onManager: this.onManager, hideField: true, formRules: [ { required: true, message: i18n.t('common.text00042') }, ], slotCallback: row => { return ( { row.name } ) }, }), getStatusTableColumn({ statusModule: 'cloudgroup' }), { field: 'cloudpolicies', title: i18n.t('cloudenv.text_329'), slots: { default: ({ row }) => { const handleVisibleChange = async (visible) => { if (visible && !row.feCloudpolicies && row.cloudpolicies && row.cloudpolicies.length > 0) { await this.loadPolicy({ row }) } } if (R.isNil(row.cloudpolicies) || R.isEmpty(row.cloudpolicies)) { return i18n.t('cloudenv.text_330') } const columns = [ { field: 'name', title: this.$t('common.name'), }, { field: 'description', title: this.$t('table.title.desc'), formatter: ({ cellValue }) => cellValue || '-', }, ] return [
0 ? { minWidth: '600px' } : {}}> {row.feCloudpolicies && row.feCloudpolicies.length > 0 ? ( ) : ( )}
{i18n.t('cloudenv.text_245', [row.cloudpolicies.length])}
] }, }, formatter: ({ row }) => { return [i18n.t('cloudenv.text_245', [(row.cloudpolicies && row.cloudpolicies.length) || 0])] }, }, getBrandTableColumn({ field: 'provider' }), getAccountTableColumn({ field: 'cloudaccount', title: this.$t('common.text00108') }), getPublicScopeTableColumn({ vm: this, resource: 'cloudgroups' }), getProjectDomainTableColumn(), getTimeTableColumn(), ] }, methods: { async loadPolicy ({ row }) { let manager = new this.$Manager('cloudpolicies', 'v1') try { const response = await manager.list({ params: { cloudgroup_id: row.id, scope: this.$store.getters.scope, }, }) this.$set(row, 'feCloudpolicies', response.data.data || []) return response } catch (error) { throw error } finally { manager = null } }, }, }