perf: 资产授权添加协议

This commit is contained in:
ibuler
2023-10-27 17:18:23 +08:00
committed by 老广
parent 74a905ee85
commit da00ae84a8
3 changed files with 25 additions and 3 deletions

View File

@@ -17,6 +17,11 @@ export default {
default: null
}
},
data() {
return {
formatterData: ''
}
},
computed: {
displayValue() {
if ([null, undefined, ''].includes(this.value)) {
@@ -65,7 +70,17 @@ export default {
},
render(h) {
if (typeof this.formatter === 'function') {
return this.formatter(this.item, this.value)
const data = this.formatter(this.item, this.value)
if (data instanceof Promise) {
data.then(res => {
this.formatterData = res
})
} else {
this.formatterData = data
}
return (
<span>{this.formatterData}</span>
)
}
if (this.value instanceof Array) {
const newArr = this.value || []

View File

@@ -68,7 +68,14 @@ export default {
},
{
key: this.$t('assets.Protocols'),
value: row.protocols.map(item => item.name).join(', ')
formatter: () => {
return this.$axios.get(`/api/v1/perms/users/self/assets/${row.id}/`).then(res => {
const protocols = res.permed_protocols
const names = protocols.map(item => item.name).join(', ')
console.log('Names: ', names)
return names
})
}
},
{
key: this.$t('assets.Category'),

View File

@@ -96,7 +96,7 @@ export default {
el: {
resource: this.$t('assets.Protocol'),
select2: {
url: '/api/v1/assets/categories/protocols/',
url: '/api/v1/assets/protocols/',
ajax: {
transformOption: (item) => {
return { label: item.label, value: item.value }