123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // AddPeopleToGongWenCell.m
- // smartRhino
- //
- // Created by tederen on 2019/11/2.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "AddPeopleToGongWenCell.h"
- #import "MyWordCell.h"
- #import "MailListDetailVC.h"
- @interface AddPeopleToGongWenCell()<UICollectionViewDelegate,UICollectionViewDataSource>
- @end
- @implementation AddPeopleToGongWenCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self.collectView registerNib:[UINib nibWithNibName:@"MyWordCell" bundle:nil] forCellWithReuseIdentifier:@"MyWordCell"];
- }
- - (IBAction)addButton:(UIButton *)sender {
- if (self.backBlock) {
- self.backBlock();
- }
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- #pragma mark - UICollectionViewDelegate UICollectionViewDataSource
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- return self.approvalSection.count + 1;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- return CGSizeMake(50.f, 65.f);
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
- return 10.f;
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
- return 10.f;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- MyWordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyWordCell" forIndexPath:indexPath];
- [cell looadDataHiden:(self.approvalSection.count == indexPath.item)];
- if (self.approvalSection.count == indexPath.item) {
- cell.iconImage.image = IMG(@"添加审批人");
- cell.nameLbl.text = @"";
- }else{
- SelectModel *model = self.approvalSection[indexPath.item];
- WS(weakSelf);
- [cell.deleteButton setAction:^{
- [weakSelf deleteHanderBack:indexPath];
- }];
- if (model.AvatarUrl.length > 0) {
- [cell.iconImage setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholder:IMG(@"添加审批人")];
- }else {
- [cell.iconImage setImage:IMG(@"王丽")];
- }
- cell.nameLbl.text = model.UserName;
- }
- cell.indexPath = indexPath;
- [cell.deleteButton setAction:^{
- [weakSelf deleteHanderBack:indexPath];
- }];
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- if(self.approvalSection.count == indexPath.item){
- if ([self.delegate respondsToSelector:@selector(addLookUpPeopleSuccess:failure:)]) {
- [self.delegate addLookUpPeopleSuccess:^(id _Nullable responseObject) {
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- }else{
- [self gotoPeople:indexPath];
- }
- }
- - (void)gotoPeople:(NSIndexPath *)indexPath{
- // SelectModel *model = self.approvalSection[indexPath.item];
- // MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
- // vc.indexId = model.Id;
- // vc.modalPresentationStyle = UIModalPresentationFullScreen;
- // [[UIApplication sharedApplication].windows.firstObject.rootViewController presentViewController:vc animated:YES completion:nil];
- }
- #pragma mark - MyWordCellDelegate
- - (void)deleteHanderBack:(NSIndexPath *)indexPath{
- NSLog(@"MyWordCell 3");
- [self.approvalSection removeObjectAtIndex:indexPath.item];
- [self.collectView reloadData];
- }
- - (void)setApprovalSection:(NSMutableArray *)approvalSection {
- _approvalSection = approvalSection;
- [self.collectView reloadData];
-
- }
- @end
|