// // NYComplaintListViewCell.m // jiaPei // // Created by Ning.ge on 2023/7/3. // Copyright © 2023 JCZ. All rights reserved. // #import "NYComplaintListViewCell.h" #import "CollectionViewCell.h" @interface NYComplaintListViewCell(){ } @property (weak, nonatomic) IBOutlet NSLayoutConstraint *content_layout_h; @property (nonatomic ,strong) UICollectionView *collectionView; @property (nonatomic ,strong) NSMutableArray *photosArray; @end @implementation NYComplaintListViewCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code [self setupUI]; } - (void)setupUI{ [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"comp_cell"]; [self.imagelist_view addSubview:self.collectionView]; self.collectionView.backgroundColor = UIColor.whiteColor; [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.imagelist_view); }]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)setComplaintInfoModel:(ComplaintInfoModel *)complaintInfoModel { _complaintInfoModel = complaintInfoModel; if(complaintInfoModel){ self.name_label.text = RQ_USER_MANAGER.currentUser.schoolName; self.content_label.text = complaintInfoModel.CI_CONTENT; // 0 待提交 1 待审核 2 审核通过 3 审核驳回 4 撤销 NSString *statename = @""; switch (complaintInfoModel.AUDIT_STATUS.intValue) { case 0: statename = @"待提交"; break; case 1: statename = @"待审核"; break; case 2: statename = @"审核通过"; break; case 3: statename = @"审核驳回"; break; case 4: statename = @"撤销"; break; default: break; } [self.state_button setTitle:statename forState:UIControlStateNormal]; if(complaintInfoModel.AUDIT_STATUS.intValue==2){ self.state_button.backgroundColor = UIColorHex(0x498EF5); YES; }else { self.state_button.backgroundColor = UIColorHex(0xEAEBED); self.cancel_button.hidden = NO; } self.cancel_button.hidden = complaintInfoModel.AUDIT_STATUS.intValue ==0 ? NO:YES; [self.photosArray removeAllObjects]; //图片 if(complaintInfoModel.PICURLS.length>0){ complaintInfoModel.PICURLS = [complaintInfoModel.PICURLS stringByReplacingOccurrencesOfString:@" " withString:@""]; NSArray *list = [complaintInfoModel.PICURLS componentsSeparatedByString:@","]; [self.photosArray addObjectsFromArray:list]; } [self.collectionView reloadData]; } } #pragma mark UICollectionViewDelegate - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ [self.imagesCommand execute:@[self.photosArray,@(indexPath.row)]]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return _photosArray.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"comp_cell" forIndexPath:indexPath]; cell.deleteButton.hidden = YES; NSString *imgUrl = self.photosArray[indexPath.row]; [cell.imagev sd_setImageWithURL:[NSURL URLWithString:imgUrl]]; return cell; } #pragma mark - Lray - (NSMutableArray *)photosArray{ if (!_photosArray) { self.photosArray = [NSMutableArray array]; } return _photosArray; } -(UICollectionView *)collectionView{ if (!_collectionView) { UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc] init]; flowLayOut.itemSize = CGSizeMake(50, 50); flowLayOut.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5); flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayOut]; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; // self.collectionView.scrollEnabled = NO; } return _collectionView; } - (IBAction)cancelActiondo:(id)sender { [self.cancelCommand execute:self.complaintInfoModel]; } @end