1919 <a-form layout =" vertical" >
2020 <a-form-item :label =" $t('label.owner.type')" >
2121 <a-select
22- @change =" changeDomain "
22+ @change =" changeAccountTypeOrDomain "
2323 v-model:value =" selectedAccountType"
2424 defaultValue =" account"
2525 autoFocus
3737 </a-form-item >
3838 <a-form-item :label =" $t('label.domain')" required >
3939 <a-select
40- @change =" changeDomain "
40+ @change =" changeAccountTypeOrDomain "
4141 v-model:value =" selectedDomain"
4242 showSearch
4343 optionFilterProp =" label"
@@ -136,14 +136,16 @@ export default {
136136 components: { ResourceIcon },
137137 data () {
138138 return {
139+ initialized: false ,
139140 domains: [],
140141 accounts: [],
141142 projects: [],
142143 selectedAccountType: this .$store .getters .project ? .id ? ' Project' : ' Account' ,
143144 selectedDomain: null ,
144145 selectedAccount: null ,
145146 selectedProject: null ,
146- loading: false
147+ loading: false ,
148+ requestToken: 0
147149 }
148150 },
149151 props: {
@@ -177,7 +179,7 @@ export default {
177179 const domainIds = this .domains ? .map (domain => domain .id )
178180 const ownerDomainId = this .$store .getters .project ? .domainid || this .$store .getters .userInfo .domainid
179181 this .selectedDomain = domainIds? .includes (ownerDomainId) ? ownerDomainId : this .domains ? .[0 ]? .id
180- this .changeDomain ()
182+ this .fetchOwnerData ()
181183 })
182184 .catch ((error ) => {
183185 this .$notifyError (error)
@@ -186,8 +188,13 @@ export default {
186188 this .loading = false
187189 })
188190 },
191+ incrementAndGetRequestToken () {
192+ this .requestToken += 1
193+ return this .requestToken
194+ },
189195 fetchAccounts () {
190196 this .loading = true
197+ const currentToken = this .incrementAndGetRequestToken ()
191198 api (' listAccounts' , {
192199 response: ' json' ,
193200 domainId: this .selectedDomain ,
@@ -196,6 +203,9 @@ export default {
196203 isrecursive: false
197204 })
198205 .then ((response ) => {
206+ if (currentToken !== this .requestToken ) {
207+ return
208+ }
199209 this .accounts = response .listaccountsresponse .account || []
200210 if (this .override ? .accounts && this .accounts ) {
201211 this .accounts = this .accounts .filter (item => this .override .accounts .has (item .name ))
@@ -214,10 +224,12 @@ export default {
214224 })
215225 .finally (() => {
216226 this .loading = false
227+ this .initialized = true
217228 })
218229 },
219230 fetchProjects () {
220231 this .loading = true
232+ const currentToken = this .incrementAndGetRequestToken ()
221233 api (' listProjects' , {
222234 response: ' json' ,
223235 domainId: this .selectedDomain ,
@@ -227,6 +239,9 @@ export default {
227239 isrecursive: false
228240 })
229241 .then ((response ) => {
242+ if (currentToken !== this .requestToken ) {
243+ return
244+ }
230245 this .projects = response .listprojectsresponse .project
231246 if (this .override ? .projects && this .projects ) {
232247 this .projects = this .projects .filter (item => this .override .projects .has (item .id ))
@@ -240,9 +255,14 @@ export default {
240255 })
241256 .finally (() => {
242257 this .loading = false
258+ this .initialized = true
243259 })
244260 },
245- changeDomain () {
261+ changeAccountTypeOrDomain () {
262+ this .initialized = true
263+ this .fetchOwnerData ()
264+ },
265+ fetchOwnerData () {
246266 if (this .selectedAccountType === ' Account' ) {
247267 this .fetchAccounts ()
248268 } else {
0 commit comments