@@ -196,13 +196,14 @@ export default {
196
196
desktopView: false ,
197
197
dirty: false ,
198
198
rawJson: null ,
199
+ chartForHighlightClicked: false ,
199
200
};
200
201
},
201
202
async created () {
202
203
window .addEventListener (' resize' , this .updateView );
203
204
this .updateView ();
204
- this .highlight ();
205
- this .fetchData ();
205
+ await this .fetchData ();
206
+ await this .highlight ();
206
207
},
207
208
computed: {
208
209
username () {
@@ -262,7 +263,7 @@ export default {
262
263
263
264
orgChartRoot .addEventListener (' click' , (event ) => {
264
265
const li = event .target .closest (' li' );
265
-
266
+ this . chartForHighlightClicked = true ;
266
267
if (event .target .closest (' button' )) {
267
268
this .toggle (li);
268
269
this .saveOrgTree ();
@@ -384,9 +385,36 @@ export default {
384
385
});
385
386
},
386
387
expandAll () {
387
- Object .entries (this .expandables ).forEach (([, li ]) => {
388
- this .toggle (li, true );
389
- });
388
+ const entries = Object .entries (this .expandables );
389
+ const loadSet = (idx , num ) => {
390
+ entries .slice (idx, idx + num).forEach (([, li ]) => {
391
+ this .toggle (li, true );
392
+ });
393
+ };
394
+ let step = 25 ,
395
+ i = 0 ,
396
+ intervalTime = 1000 ;
397
+ let inter = setInterval (() => {
398
+ const run = () => {
399
+ if (i < entries .length ) {
400
+ loadSet (i, step);
401
+ i += step;
402
+ if (i + step > entries .length ) {
403
+ step = entries .length - i;
404
+ }
405
+ } else {
406
+ clearInterval (inter);
407
+ }
408
+ };
409
+ if (this .chartForHighlightClicked ) {
410
+ setTimeout (() => {
411
+ run ();
412
+ this .chartForHighlightClicked = false ;
413
+ });
414
+ } else {
415
+ run ();
416
+ }
417
+ }, intervalTime);
390
418
this .saveOrgTree ();
391
419
},
392
420
collapseAll () {
0 commit comments