AddPeopleToGongWenCell.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // AddPeopleToGongWenCell.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/2.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AddPeopleToGongWenCell.h"
  9. #import "MyWordCell.h"
  10. #import "MailListDetailVC.h"
  11. @interface AddPeopleToGongWenCell()<UICollectionViewDelegate,UICollectionViewDataSource>
  12. @end
  13. @implementation AddPeopleToGongWenCell
  14. - (void)awakeFromNib {
  15. [super awakeFromNib];
  16. [self.collectView registerNib:[UINib nibWithNibName:@"MyWordCell" bundle:nil] forCellWithReuseIdentifier:@"MyWordCell"];
  17. }
  18. - (IBAction)addButton:(UIButton *)sender {
  19. if (self.backBlock) {
  20. self.backBlock();
  21. }
  22. }
  23. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  24. [super setSelected:selected animated:animated];
  25. }
  26. #pragma mark - UICollectionViewDelegate UICollectionViewDataSource
  27. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  28. return 1;
  29. }
  30. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  31. return self.approvalSection.count + 1;
  32. }
  33. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  34. return CGSizeMake(50.f, 65.f);
  35. }
  36. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  37. return 10.f;
  38. }
  39. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  40. return 10.f;
  41. }
  42. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  43. WS(weakSelf);
  44. MyWordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyWordCell" forIndexPath:indexPath];
  45. [cell looadDataHiden:(self.approvalSection.count == indexPath.item)];
  46. if (self.approvalSection.count == indexPath.item) {
  47. cell.iconImage.image = IMG(@"添加审批人");
  48. cell.nameLbl.text = @"";
  49. }else{
  50. SelectModel *model = self.approvalSection[indexPath.item];
  51. WS(weakSelf);
  52. [cell.deleteButton setAction:^{
  53. [weakSelf deleteHanderBack:indexPath];
  54. }];
  55. if (model.AvatarUrl.length > 0) {
  56. [cell.iconImage setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholder:IMG(@"添加审批人")];
  57. }else {
  58. [cell.iconImage setImage:IMG(@"王丽")];
  59. }
  60. cell.nameLbl.text = model.UserName;
  61. }
  62. cell.indexPath = indexPath;
  63. [cell.deleteButton setAction:^{
  64. [weakSelf deleteHanderBack:indexPath];
  65. }];
  66. return cell;
  67. }
  68. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  69. if(self.approvalSection.count == indexPath.item){
  70. if ([self.delegate respondsToSelector:@selector(addLookUpPeopleSuccess:failure:)]) {
  71. [self.delegate addLookUpPeopleSuccess:^(id _Nullable responseObject) {
  72. } failure:^(NSError * _Nonnull error) {
  73. }];
  74. }
  75. }else{
  76. [self gotoPeople:indexPath];
  77. }
  78. }
  79. - (void)gotoPeople:(NSIndexPath *)indexPath{
  80. // SelectModel *model = self.approvalSection[indexPath.item];
  81. // MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  82. // vc.indexId = model.Id;
  83. // vc.modalPresentationStyle = UIModalPresentationFullScreen;
  84. // [[UIApplication sharedApplication].windows.firstObject.rootViewController presentViewController:vc animated:YES completion:nil];
  85. }
  86. #pragma mark - MyWordCellDelegate
  87. - (void)deleteHanderBack:(NSIndexPath *)indexPath{
  88. NSLog(@"MyWordCell 3");
  89. [self.approvalSection removeObjectAtIndex:indexPath.item];
  90. [self.collectView reloadData];
  91. }
  92. - (void)setApprovalSection:(NSMutableArray *)approvalSection {
  93. _approvalSection = approvalSection;
  94. [self.collectView reloadData];
  95. }
  96. @end