NYComplaintListViewController.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // NYComplaintListViewController.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/7/2.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. //
  8. #import "NYComplaintListViewController.h"
  9. #import "NYComplaintPageViewController.h"
  10. #import "NYComplaintListViewCell.h"
  11. #import "ComplaintDataModel.h"
  12. @interface NYComplaintListViewController ()<UITableViewDataSource,UITableViewDelegate>
  13. @property (weak, nonatomic) IBOutlet UIButton *addcomp_button;
  14. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  15. @property (nonatomic,assign) int currentPage;
  16. @property (nonatomic,strong) ComplaintDataModel *complaintDataModel;
  17. @property (nonatomic,strong) NSMutableArray *complaintList;
  18. @end
  19. @implementation NYComplaintListViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view from its nib.
  23. [self setupUI];
  24. }
  25. - (void)viewWillAppear:(BOOL)animated
  26. {
  27. [super viewWillAppear:animated];
  28. [self getComplaintList];
  29. }
  30. - (void)dealloc {
  31. NSLog(@"投诉建议列表-NYComplaintListViewController");
  32. }
  33. #pragma mark - PublicMethods
  34. - (void)getComplaintList{
  35. _currentPage = 1;
  36. NSMutableArray *arr = [NSMutableArray array];
  37. [arr addPro:@"stunum" Value:RQ_USER_MANAGER.currentUser.outId];///学员编号
  38. [arr addPro:@"currentPage" Value:@(_currentPage)];///当前页
  39. [arr addPro:@"pageSize" Value:@10];
  40. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];///地区编号
  41. NSString *method = @"getComplaintList";
  42. @weakify(self)
  43. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  44. NSLog(@"%@",dict);
  45. int code = [dict[@"code"] intValue];
  46. if(code == 0 ){
  47. self.complaintDataModel = [ComplaintDataModel yy_modelWithDictionary:dict[@"body"]];
  48. if(self.complaintDataModel.list.count>0&&self.complaintList.count!=self.complaintDataModel.list.count){
  49. [self.complaintList removeAllObjects];
  50. [self.complaintList addObjectsFromArray:self.complaintDataModel.list];
  51. [self.tableView reloadData];
  52. }
  53. }
  54. }];
  55. }
  56. //更多下一页
  57. - (void)getComplaintListMore {
  58. int total = 10* (_currentPage+1);
  59. if(self.complaintDataModel.total > total){
  60. _currentPage +=1;
  61. NSMutableArray *arr = [NSMutableArray array];
  62. [arr addPro:@"stunum" Value:RQ_USER_MANAGER.currentUser.outId];///学员编号
  63. [arr addPro:@"currentPage" Value:@(_currentPage)];///当前页
  64. [arr addPro:@"pageSize" Value:@10];
  65. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];///地区编号
  66. NSString *method = @"getComplaintList";
  67. @weakify(self)
  68. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  69. NSLog(@"%@",dict);
  70. int code = [dict[@"code"] intValue];
  71. if(code == 0 ){
  72. self.complaintDataModel = [ComplaintDataModel yy_modelWithDictionary:dict[@"body"]];
  73. if(self.complaintDataModel.list.count>0&&self.complaintList.count!=self.complaintDataModel.list.count){
  74. [self.complaintList addObjectsFromArray:self.complaintDataModel.list];
  75. [self.tableView reloadData];
  76. }
  77. }
  78. }];
  79. }
  80. }
  81. #pragma mark - PrivateMethods
  82. - (void)setupUI {
  83. self.title = @"投诉建议列表";
  84. [self configureUI];
  85. }
  86. - (void)configureUI {
  87. self.tableView.backgroundColor = UIColorMakeWithRGBA(242, 243, 245, 1);
  88. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  89. [self.tableView registerNib:[UINib nibWithNibName:@"NYComplaintListViewCell" bundle:nil] forCellReuseIdentifier:@"NYComplaintListViewCell"];
  90. }
  91. #pragma mark - 事件
  92. - (IBAction)pushAddCompdo:(UIButton *)sender {
  93. NYComplaintPageViewController *complaintPageViewController = [[NYComplaintPageViewController alloc] init];
  94. [RQControllerHelper.currentViewController.navigationController qmui_pushViewController:complaintPageViewController animated:YES completion:nil];
  95. }
  96. #pragma mark - UITableViewDataSource
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  98. {
  99. return self.complaintList.count;
  100. }
  101. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  102. {
  103. return 260;
  104. }
  105. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  106. {
  107. NYComplaintListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NYComplaintListViewCell"];
  108. [cell setComplaintInfoModel:self.complaintList[indexPath.row]];
  109. return cell;
  110. }
  111. #pragma mark - UITableViewDelegate
  112. #pragma mark - Lazy
  113. - (NSMutableArray *)complaintList
  114. {
  115. if(!_complaintList){
  116. _complaintList = [NSMutableArray array];
  117. }
  118. return _complaintList;
  119. }
  120. @end