@property (strong, nonatomic) NSMutableArray *havaSelectMarry; //多选选中的行
- (NSMutableArray *)havaSelectMarry
{
if (!_havaSelectMarry) {
self.havaSelectMarry = [NSMutableArray array];
}
return _havaSelectMarry;
}
- (void)confirmAction
{
NSMutableArray *knowMarray = [NSMutableArray array];
for (LMSNewKnowdgeModel *knowModel in self.havaSelectMarry) {
if (knowModel.isSelect) {
[knowMarray addObject:knowModel.departmentID];
}
}
[[NSUserDefaults standardUserDefaults] setObject:knowMarray forKey:KPlanKnowdge];
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 计算选中人数列表
- (NSMutableArray *)calcullateTotalSelectedPersonAry:(NSArray *)dataAry isAllDepartment:(BOOL)isAll{
__block NSMutableArray *mary = [NSMutableArray array];
__weak typeof (self)weakSelf = self;
// BOOL isAllSel = isAll;
[dataAry enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[LMSNewKnowdgeModel class]]) {
LMSNewKnowdgeModel *model = (LMSNewKnowdgeModel *)obj;
if (model.isSelect) {
[mary addObject:model];
}
[model.children enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[LMSNewKnowdgeModel class]]) {
LMSNewKnowdgeModel *model = (LMSNewKnowdgeModel *)obj;
// if (isAllSel) {
// if (model.isSelect || isAllSel) {
// [mary addObject:model];
// }
// }else{
if (model.isSelect) {
[mary addObject:model];
}
// }
}
}];
NSMutableArray *nextDepartment = [weakSelf calcullateTotalSelectedPersonAry:model.children isAllDepartment:NO];
if (nextDepartment) {
[mary addObjectsFromArray:nextDepartment];
}
NSArray *newarr = [mary valueForKeyPath:@"@distinctUnionOfObjects.self"];
self.havaSelectMarry = [newarr copy];
}
}];
return mary;
}
#pragma mark - 计选择人数,按钮赋值
-(void)getSelectedPeopleCount{
//更新上层模型状态
// [self changParentModelStatus];
// [self changeAllModelStatusWithAry:self.orginalAry];
NSArray *selectAry = [self calcullateTotalSelectedPersonAry:self.orginalAry isAllDepartment:NO];
[self.selectedPeopleBtn setTitle:[NSString stringWithFormat:@"已选择%zd个知识点",self.havaSelectMarry.count] forState:UIControlStateNormal];
}

1302

被折叠的 条评论
为什么被折叠?



