import { getNameDescriptionTableColumn, getProjectDomainTableColumn, getPublicScopeTableColumn, getTimeTableColumn, } from '@/utils/common/tableColumn' export default { destroyed () { this.pm = null }, created () { this.pm = new this.$Manager('policies', 'v1') this.columns = [ getNameDescriptionTableColumn({ onManager: this.onManager, hideField: true, edit: false, slotCallback: row => { return ( this.handleOpenSidepage(row) }>{ row.name } ) }, }), { field: 'match_policies', title: this.$t('dictionary.policy'), width: 100, slots: { default: ({ row }) => { const handleVisibleChange = async (visible) => { if (!visible) return if (row._policies || !row.match_policies || row.match_policies.length === 0) return await this.fetchPolicies({ row }) } if (!row.match_policies || row.match_policies.length === 0) return this.$t('common.notData') const columns = [ { field: 'name', title: this.$t('table.title.name') }, { field: 'description', title: this.$t('table.title.desc') }, ] const policies = row._policies const hasData = Array.isArray(policies) && policies.length > 0 return [ {Array.isArray(policies) ? (hasData ? : { this.$t('common.notData') }) : } { (row.match_policies && row.match_policies.length) || 0 } ] }, }, }, getPublicScopeTableColumn({ vm: this, resource: 'roles' }), getProjectDomainTableColumn(), getTimeTableColumn(), ] }, methods: { async fetchPolicies ({ row }) { const policies = row.match_policies || [] if (policies.length <= 0) { return true } try { const response = await this.pm.list({ params: { name: policies, }, }) const data = response.data.data || [] row._policies = data return response } catch (error) { throw error } }, }, }