19
19
<a-form layout =" vertical" >
20
20
<a-form-item :label =" $t('label.owner.type')" >
21
21
<a-select
22
- @change =" changeDomain "
22
+ @change =" changeAccountTypeOrDomain "
23
23
v-model:value =" selectedAccountType"
24
24
defaultValue =" account"
25
25
autoFocus
37
37
</a-form-item >
38
38
<a-form-item :label =" $t('label.domain')" required >
39
39
<a-select
40
- @change =" changeDomain "
40
+ @change =" changeAccountTypeOrDomain "
41
41
v-model:value =" selectedDomain"
42
42
showSearch
43
43
optionFilterProp =" label"
@@ -144,7 +144,8 @@ export default {
144
144
selectedDomain: null ,
145
145
selectedAccount: null ,
146
146
selectedProject: null ,
147
- loading: false
147
+ loading: false ,
148
+ requestToken: 0
148
149
}
149
150
},
150
151
props: {
@@ -178,7 +179,7 @@ export default {
178
179
const domainIds = this .domains ? .map (domain => domain .id )
179
180
const ownerDomainId = this .$store .getters .project ? .domainid || this .$store .getters .userInfo .domainid
180
181
this .selectedDomain = domainIds? .includes (ownerDomainId) ? ownerDomainId : this .domains ? .[0 ]? .id
181
- this .changeDomain ()
182
+ this .fetchOwnerData ()
182
183
})
183
184
.catch ((error ) => {
184
185
this .$notifyError (error)
@@ -187,8 +188,13 @@ export default {
187
188
this .loading = false
188
189
})
189
190
},
191
+ increamentAndGetRequestToken () {
192
+ this .requestToken += 1
193
+ return this .requestToken
194
+ },
190
195
fetchAccounts () {
191
196
this .loading = true
197
+ const currentToken = this .increamentAndGetRequestToken ()
192
198
api (' listAccounts' , {
193
199
response: ' json' ,
194
200
domainId: this .selectedDomain ,
@@ -197,6 +203,9 @@ export default {
197
203
isrecursive: false
198
204
})
199
205
.then ((response ) => {
206
+ if (currentToken !== this .requestToken ) {
207
+ return
208
+ }
200
209
this .accounts = response .listaccountsresponse .account || []
201
210
if (this .override ? .accounts && this .accounts ) {
202
211
this .accounts = this .accounts .filter (item => this .override .accounts .has (item .name ))
@@ -220,6 +229,7 @@ export default {
220
229
},
221
230
fetchProjects () {
222
231
this .loading = true
232
+ const currentToken = this .increamentAndGetRequestToken ()
223
233
api (' listProjects' , {
224
234
response: ' json' ,
225
235
domainId: this .selectedDomain ,
@@ -229,6 +239,9 @@ export default {
229
239
isrecursive: false
230
240
})
231
241
.then ((response ) => {
242
+ if (currentToken !== this .requestToken ) {
243
+ return
244
+ }
232
245
this .projects = response .listprojectsresponse .project
233
246
if (this .override ? .projects && this .projects ) {
234
247
this .projects = this .projects .filter (item => this .override .projects .has (item .id ))
@@ -245,7 +258,11 @@ export default {
245
258
this .initialized = true
246
259
})
247
260
},
248
- changeDomain () {
261
+ changeAccountTypeOrDomain () {
262
+ this .initialized = true
263
+ this .fetchOwnerData ()
264
+ },
265
+ fetchOwnerData () {
249
266
if (this .selectedAccountType === ' Account' ) {
250
267
this .fetchAccounts ()
251
268
} else {
0 commit comments