fix(ui): resource views - fix page display during initialization

This commit is contained in:
LH_R
2025-08-15 21:37:07 +08:00
parent bb467030e2
commit 45bb3867da
2 changed files with 27 additions and 9 deletions

View File

@@ -1,6 +1,10 @@
<template> <template>
<div> <div>
<div v-if="preferenceGroup.length === 0"> <div v-if="pageLoading" class="page-loading">
<a-spin size="large" />
</div>
<div v-else-if="preferenceGroup.length === 0">
<a-alert banner> <a-alert banner>
<template #message> <template #message>
<span>{{ $t('cmdb.preference.tips1') }}</span> <span>{{ $t('cmdb.preference.tips1') }}</span>
@@ -110,8 +114,8 @@ export default {
preferenceGroup: [], preferenceGroup: [],
currentTypeId: Number(this.$route?.params?.typeId || localStorage.getItem('ops_ci_typeid') || ''), currentTypeId: Number(this.$route?.params?.typeId || localStorage.getItem('ops_ci_typeid') || ''),
resource_type: {}, resource_type: {},
loading: false, autoSub: {},
autoSub: {} pageLoading: false
} }
}, },
computed: { computed: {
@@ -152,9 +156,14 @@ export default {
} }
}, },
created() { created() {
this.getPreference() this.pageLoading = true
this.getResourceType() Promise.all([
this.getAutoSubscription() this.getPreference(),
this.getResourceType(),
this.getAutoSubscription()
]).then(() => {
this.pageLoading = false
})
}, },
methods: { methods: {
async getPreference() { async getPreference() {
@@ -191,8 +200,8 @@ export default {
} }
}, },
getResourceType() { async getResourceType() {
searchResourceType({ page_size: 9999, app_id: 'cmdb' }).then(res => { await searchResourceType({ page_size: 9999, app_id: 'cmdb' }).then(res => {
this.resource_type = { groups: res.groups, id2perms: res.id2perms } this.resource_type = { groups: res.groups, id2perms: res.id2perms }
}) })
}, },
@@ -247,6 +256,11 @@ export default {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.page-loading {
text-align: center;
padding-top: 150px;
}
.ci-left { .ci-left {
height: calc(100vh - 90px); height: calc(100vh - 90px);
width: 100%; width: 100%;

View File

@@ -665,7 +665,11 @@ export default {
}, },
columnDrop() { columnDrop() {
this.$nextTick(() => { this.$nextTick(() => {
const xTable = this.$refs.xTable.getVxetableRef() const xTable = this.$refs?.xTable?.getVxetableRef?.()
if (!xTable) {
return
}
this.sortable = Sortable.create( this.sortable = Sortable.create(
xTable.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'), xTable.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'),
{ {