@@ -23,7 +23,7 @@ import { ALAIN_I18N_TOKEN } from '@delon/theme';
2323import { NzModalService } from 'ng-zorro-antd/modal' ;
2424import { NzNotificationService } from 'ng-zorro-antd/notification' ;
2525import { NzTableQueryParams } from 'ng-zorro-antd/table' ;
26- import { TransferChange } from 'ng-zorro-antd/transfer' ;
26+ import { TransferChange , TransferSelectChange , TransferStat } from 'ng-zorro-antd/transfer' ;
2727import { NzFormatEmitEvent , NzTreeNode , NzTreeNodeOptions } from 'ng-zorro-antd/tree' ;
2828import { Subject } from 'rxjs' ;
2929import { finalize , debounceTime , distinctUntilChanged } from 'rxjs/operators' ;
@@ -76,6 +76,7 @@ export class BulletinComponent implements OnInit, OnDestroy {
7676 filterLabels : Record < string , string > = { } ;
7777 filteredMonitors : Monitor [ ] = [ ] ;
7878 private filterSubject = new Subject < string > ( ) ; //filter logic debouncing
79+ currentStat : TransferStat | null = null ; //transfer component status
7980
8081 ngOnInit ( ) {
8182 this . loadTabs ( ) ;
@@ -368,6 +369,42 @@ export class BulletinComponent implements OnInit, OnDestroy {
368369 return tree ;
369370 }
370371
372+ updateTransferStat ( stat : TransferStat ) : boolean {
373+ this . currentStat = stat ;
374+ // stat.shownCount = 33;
375+ return true ;
376+ }
377+
378+ private collectLeafNodes ( nodes : NzTreeNodeOptions [ ] , results : NzTreeNodeOptions [ ] ) : void {
379+ nodes . forEach ( node => {
380+ if ( node . isLeaf && ! node . disabled ) {
381+ results . push ( node ) ;
382+ }
383+ if ( node . children ) {
384+ this . collectLeafNodes ( node . children , results ) ;
385+ }
386+ } ) ;
387+ }
388+
389+ onSelectChange ( event : TransferSelectChange ) : void {
390+ if ( event . direction === 'left' && event . checked && this . currentStat ?. checkAll ) {
391+ const allLeafNodes : NzTreeNodeOptions [ ] = [ ] ;
392+ this . collectLeafNodes ( this . treeNodes , allLeafNodes ) ;
393+
394+ allLeafNodes . forEach ( node => {
395+ const existing = this . checkedNodeList . find ( n => n . origin . id === node . id ) ;
396+ if ( ! existing ) {
397+ const treeNode = new NzTreeNode ( node ) ;
398+ treeNode . isChecked = true ;
399+ this . checkedNodeList . push ( treeNode ) ;
400+ }
401+ } ) ;
402+ }
403+ if ( event . direction === 'left' && ! event . checked && this . currentStat ?. checkAll === false ) {
404+ this . checkedNodeList = [ ] ;
405+ }
406+ }
407+
371408 treeCheckBoxChange ( event : NzFormatEmitEvent , onItemSelect : ( item : NzTreeNodeOptions ) => void ) : void {
372409 this . checkBoxChange ( event . node ! , onItemSelect ) ;
373410 }
0 commit comments