|
1 | 1 | <template> |
2 | 2 | <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"> |
4 | 8 | <a-alert banner> |
5 | 9 | <template #message> |
6 | 10 | <span>{{ $t('cmdb.preference.tips1') }}</span> |
@@ -110,8 +114,8 @@ export default { |
110 | 114 | preferenceGroup: [], |
111 | 115 | currentTypeId: Number(this.$route?.params?.typeId || localStorage.getItem('ops_ci_typeid') || ''), |
112 | 116 | resource_type: {}, |
113 | | - loading: false, |
114 | | - autoSub: {} |
| 117 | + autoSub: {}, |
| 118 | + pageLoading: false |
115 | 119 | } |
116 | 120 | }, |
117 | 121 | computed: { |
@@ -152,9 +156,14 @@ export default { |
152 | 156 | } |
153 | 157 | }, |
154 | 158 | 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 | + }) |
158 | 167 | }, |
159 | 168 | methods: { |
160 | 169 | async getPreference() { |
@@ -191,8 +200,8 @@ export default { |
191 | 200 | } |
192 | 201 | }, |
193 | 202 |
|
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 => { |
196 | 205 | this.resource_type = { groups: res.groups, id2perms: res.id2perms } |
197 | 206 | }) |
198 | 207 | }, |
@@ -247,6 +256,11 @@ export default { |
247 | 256 | </script> |
248 | 257 |
|
249 | 258 | <style lang="less" scoped> |
| 259 | +.page-loading { |
| 260 | + text-align: center; |
| 261 | + padding-top: 150px; |
| 262 | +} |
| 263 | +
|
250 | 264 | .ci-left { |
251 | 265 | height: calc(100vh - 90px); |
252 | 266 | width: 100%; |
|
0 commit comments