Skip to content

Commit 45bb386

Browse files
committed
fix(ui): resource views - fix page display during initialization
1 parent bb46703 commit 45bb386

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

cmdb-ui/src/modules/cmdb/views/ci/index.vue

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<div>
3-
<div v-if="preferenceGroup.length === 0">
3+
<div v-if="pageLoading" class="page-loading">
4+
<a-spin size="large" />
5+
</div>
6+
7+
<div v-else-if="preferenceGroup.length === 0">
48
<a-alert banner>
59
<template #message>
610
<span>{{ $t('cmdb.preference.tips1') }}</span>
@@ -110,8 +114,8 @@ export default {
110114
preferenceGroup: [],
111115
currentTypeId: Number(this.$route?.params?.typeId || localStorage.getItem('ops_ci_typeid') || ''),
112116
resource_type: {},
113-
loading: false,
114-
autoSub: {}
117+
autoSub: {},
118+
pageLoading: false
115119
}
116120
},
117121
computed: {
@@ -152,9 +156,14 @@ export default {
152156
}
153157
},
154158
created() {
155-
this.getPreference()
156-
this.getResourceType()
157-
this.getAutoSubscription()
159+
this.pageLoading = true
160+
Promise.all([
161+
this.getPreference(),
162+
this.getResourceType(),
163+
this.getAutoSubscription()
164+
]).then(() => {
165+
this.pageLoading = false
166+
})
158167
},
159168
methods: {
160169
async getPreference() {
@@ -191,8 +200,8 @@ export default {
191200
}
192201
},
193202
194-
getResourceType() {
195-
searchResourceType({ page_size: 9999, app_id: 'cmdb' }).then(res => {
203+
async getResourceType() {
204+
await searchResourceType({ page_size: 9999, app_id: 'cmdb' }).then(res => {
196205
this.resource_type = { groups: res.groups, id2perms: res.id2perms }
197206
})
198207
},
@@ -247,6 +256,11 @@ export default {
247256
</script>
248257
249258
<style lang="less" scoped>
259+
.page-loading {
260+
text-align: center;
261+
padding-top: 150px;
262+
}
263+
250264
.ci-left {
251265
height: calc(100vh - 90px);
252266
width: 100%;

cmdb-ui/src/modules/cmdb/views/ci/instanceList.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,11 @@ export default {
665665
},
666666
columnDrop() {
667667
this.$nextTick(() => {
668-
const xTable = this.$refs.xTable.getVxetableRef()
668+
const xTable = this.$refs?.xTable?.getVxetableRef?.()
669+
if (!xTable) {
670+
return
671+
}
672+
669673
this.sortable = Sortable.create(
670674
xTable.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'),
671675
{

0 commit comments

Comments
 (0)