fix: Add loading state to AccountInfoFormatter for async data fetching

This commit is contained in:
w940853815 2025-03-14 17:02:49 +08:00 committed by w940853815
parent 7902a8f038
commit 52ef1daa25

View File

@ -5,7 +5,7 @@
trigger="click"
@show="getAsyncItems"
>
<div class="detail-content">
<div v-if="!loading" class="detail-content">
<div v-if="accountData.length === 0" class="empty-item">
<span>{{ $t('No accounts') }}</span>
</div>
@ -29,7 +29,8 @@ export default {
return {
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs),
value: this.cellValue,
accountData: []
accountData: [],
loading: false
}
},
computed: {
@ -39,10 +40,13 @@ export default {
},
methods: {
async getAsyncItems() {
this.loading = true
const userId = this.$route.params.id || 'self'
const url = `/api/v1/perms/users/${userId}/assets/${this.row.id}`
this.$axios.get(url).then(res => {
this.accountData = res?.permed_accounts || []
}).finally(() => {
this.loading = false
})
}
}