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