NYComplaintListViewCell.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // NYComplaintListViewCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/7/3.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. //
  8. #import "NYComplaintListViewCell.h"
  9. #import "CollectionViewCell.h"
  10. @interface NYComplaintListViewCell()<UICollectionViewDelegate,UICollectionViewDataSource>{
  11. }
  12. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *content_layout_h;
  13. @property (nonatomic ,strong) UICollectionView *collectionView;
  14. @property (nonatomic ,strong) NSMutableArray *photosArray;
  15. @end
  16. @implementation NYComplaintListViewCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. [self setupUI];
  21. }
  22. - (void)setupUI{
  23. [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"comp_cell"];
  24. [self.imagelist_view addSubview:self.collectionView];
  25. self.collectionView.backgroundColor = UIColor.whiteColor;
  26. [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.edges.mas_equalTo(self.imagelist_view);
  28. }];
  29. }
  30. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  31. [super setSelected:selected animated:animated];
  32. // Configure the view for the selected state
  33. }
  34. - (void)setComplaintInfoModel:(ComplaintInfoModel *)complaintInfoModel
  35. {
  36. _complaintInfoModel = complaintInfoModel;
  37. if(complaintInfoModel){
  38. self.name_label.text = RQ_USER_MANAGER.currentUser.schoolName;
  39. self.content_label.text = complaintInfoModel.CI_CONTENT;
  40. // 0 待提交 1 待审核 2 审核通过 3 审核驳回 4 撤销
  41. NSString *statename = @"";
  42. switch (complaintInfoModel.AUDIT_STATUS.intValue) {
  43. case 0:
  44. statename = @"待提交";
  45. break;
  46. case 1:
  47. statename = @"待审核";
  48. break;
  49. case 2:
  50. statename = @"审核通过";
  51. break;
  52. case 3:
  53. statename = @"审核驳回";
  54. break;
  55. case 4:
  56. statename = @"撤销";
  57. break;
  58. default:
  59. break;
  60. }
  61. [self.state_button setTitle:statename forState:UIControlStateNormal];
  62. if(complaintInfoModel.AUDIT_STATUS.intValue==2){
  63. self.state_button.backgroundColor = UIColorHex(0x498EF5);
  64. YES;
  65. }else {
  66. self.state_button.backgroundColor = UIColorHex(0xEAEBED);
  67. self.cancel_button.hidden = NO;
  68. }
  69. self.cancel_button.hidden = complaintInfoModel.AUDIT_STATUS.intValue ==0 ? NO:YES;
  70. [self.photosArray removeAllObjects];
  71. //图片
  72. if(complaintInfoModel.PICURLS.length>0){
  73. complaintInfoModel.PICURLS = [complaintInfoModel.PICURLS stringByReplacingOccurrencesOfString:@" " withString:@""];
  74. NSArray *list = [complaintInfoModel.PICURLS componentsSeparatedByString:@","];
  75. [self.photosArray addObjectsFromArray:list];
  76. }
  77. [self.collectionView reloadData];
  78. }
  79. }
  80. #pragma mark UICollectionViewDelegate
  81. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  82. [self.imagesCommand execute:@[self.photosArray,@(indexPath.row)]];
  83. }
  84. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  85. return _photosArray.count;
  86. }
  87. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  88. CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"comp_cell" forIndexPath:indexPath];
  89. cell.deleteButton.hidden = YES;
  90. NSString *imgUrl = self.photosArray[indexPath.row];
  91. [cell.imagev sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
  92. return cell;
  93. }
  94. #pragma mark - Lray
  95. - (NSMutableArray *)photosArray{
  96. if (!_photosArray) {
  97. self.photosArray = [NSMutableArray array];
  98. }
  99. return _photosArray;
  100. }
  101. -(UICollectionView *)collectionView{
  102. if (!_collectionView) {
  103. UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc] init];
  104. flowLayOut.itemSize = CGSizeMake(50, 50);
  105. flowLayOut.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
  106. flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  107. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayOut];
  108. self.collectionView.showsHorizontalScrollIndicator = NO;
  109. self.collectionView.delegate = self;
  110. self.collectionView.dataSource = self;
  111. // self.collectionView.scrollEnabled = NO;
  112. }
  113. return _collectionView;
  114. }
  115. - (IBAction)cancelActiondo:(id)sender {
  116. [self.cancelCommand execute:self.complaintInfoModel];
  117. }
  118. @end