@@ -119,6 +119,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
119
119
this . cascaderSrv . initOptions ( this . options ) ;
120
120
this . cascaderSrv . isMultiple = this . multiple ;
121
121
this . cascaderSrv . isLazyLoad = this . isLazyLoad ;
122
+ this . cascaderSrv . checkboxRelation = this . checkboxRelation ;
122
123
this . initObservale ( ) ;
123
124
this . initI18n ( ) ;
124
125
}
@@ -247,6 +248,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
247
248
tagEvent . event . stopPropagation ( ) ;
248
249
this . cascaderSrv . updateOptionCheckedStatus ( option . value , false , this . checkboxRelation . upward , this . checkboxRelation . downward ) ;
249
250
this . multipleValueList = this . multipleValueList . filter ( t => t . value !== option . value ) ;
251
+ this . onChange ( this . cascaderSrv . currentMultipleValue ) ;
250
252
// 当taglist变化导致input高度变化时,更新相对位置
251
253
setTimeout ( ( ) => {
252
254
this . mainDropdown . updateCdkConnectedOverlayOrigin ( ) ;
@@ -287,9 +289,11 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
287
289
const targetList = [ ] ;
288
290
valueList . forEach ( value => {
289
291
let cur : CascaderItem ;
292
+ let cacheTarget : CascaderItem ;
290
293
let list = this . cascaderSrv . options ;
291
294
for ( let i = 0 ; i < value . length ; i ++ ) {
292
295
cur = list . find ( l => l . value === value [ i ] ) ;
296
+ cacheTarget = cur ;
293
297
if ( this . isLazyLoad && cur && ! cur . children ?. length && ! cur . isLeaf ) {
294
298
this . cascaderSrv . lazyloadMultipleChild ( cur , i ) ;
295
299
break ;
@@ -299,17 +303,24 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
299
303
}
300
304
if ( cur && cur . isLeaf ) {
301
305
targetList . push ( cur ) ;
306
+ cacheTarget = null ;
302
307
this . cascaderSrv . updateOptionCheckedStatus ( cur . value , true , this . checkboxRelation . upward , this . checkboxRelation . downward ) ;
303
308
}
309
+
310
+ if ( cacheTarget ) {
311
+ targetList . push ( cacheTarget ) ;
312
+ this . cascaderSrv . updateOptionCheckedStatus ( cacheTarget . value , true , this . checkboxRelation . upward , this . checkboxRelation . downward ) ;
313
+ }
304
314
} ) ;
315
+
305
316
return targetList ;
306
317
}
307
318
308
319
// 获取路径末的label
309
320
getLabelFromValue ( value : Array < number | string > ) : string {
310
321
let cur ;
311
322
let list = this . cascaderSrv . options ;
312
- value . map ( item => {
323
+ value . forEach ( item => {
313
324
cur = list . find ( t => t . value === item ) || '' ;
314
325
list = cur . children || [ ] ;
315
326
} ) ;
@@ -323,7 +334,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
323
334
let cur ;
324
335
let list = this . cascaderSrv . options ;
325
336
326
- value . map ( ( item , index ) => {
337
+ value . forEach ( ( item , index ) => {
327
338
cur = list . find ( t => t . value === item ) || '' ;
328
339
if ( cur ) {
329
340
path = path === '' ? path + cur . label : path + ' / ' + cur . label ;
@@ -385,7 +396,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
385
396
const width = this . dropdownComp . overlay . overlayRef ?. overlayElement . clientWidth ;
386
397
const offsetX = this . dropdownComp . overlay . overlayRef ?. overlayElement . offsetLeft ;
387
398
const offsetRight = window . innerWidth - width - offsetX - 20 ;
388
- this . subMenuDirections . map ( t => { t . offsetX = offsetRight < 0 ? offsetRight : 0 ; } ) ;
399
+ this . subMenuDirections . forEach ( t => { t . offsetX = offsetRight < 0 ? offsetRight : 0 ; } ) ;
389
400
this . dropdownComp . reposition ( ) ;
390
401
} , 0 ) ;
391
402
}
0 commit comments