HJSalaryDetailViewController.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. //
  2. // HJSalaryDetailViewController.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/5/29.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJSalaryDetailViewController.h"
  9. #import "HJLabelTextFieldView.h"
  10. #import "FBScrollLayoutView.h"
  11. #import "HJResumeModel.h"
  12. #import "HJUserInfoModel.h"
  13. #import "HJSalaryPayAPIManager.h"
  14. #import "HJSalarySheetView.h"
  15. #import "HJSalaryDataBox.h"
  16. #import "HJSalaryDetailPromptView.h"
  17. @interface HJSalaryDetailViewController ()
  18. <
  19. FBScrollLayoutViewDelegate,
  20. FBAPIManagerDelegate,
  21. FBAPIManagerInterceptor
  22. >
  23. @property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
  24. @property (nonatomic, strong) HJSalaryDetailPromptView *promptView;
  25. @property (nonatomic, strong) HJSalarySheetView *salarySheetView;
  26. @property (nonatomic, copy) NSArray *dateDataSource;
  27. @property (nonatomic, strong) HJSalaryPayAPIManager *salaryPayAPIManager;
  28. @property (nonatomic, strong) HJSalaryDataBox *dataBox;
  29. @end
  30. @implementation HJSalaryDetailViewController
  31. #pragma mark - life cycle
  32. - (void)dealloc {
  33. }
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. self.title = @"薪资详情";
  37. [self hj_setupNavBar];
  38. [self subViewsMakeConstraints];
  39. self.salaryPayAPIManager.hpPayroll_id = self.hpPayroll_id;
  40. [self.salaryPayAPIManager start];
  41. // 错误页面刷新事件
  42. [self.view.errorView.refreshButton addTarget:self
  43. action:@selector(refreshButtonClicked:)
  44. forControlEvents:UIControlEventTouchUpInside];
  45. }
  46. #pragma mark - init
  47. - (void)subViewsMakeConstraints {
  48. [self.view addSubview:self.promptView];
  49. [self.view addSubview:self.scrollLayoutView];
  50. [self.scrollLayoutView.contentView addSubview:self.salarySheetView];
  51. [self.promptView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.equalTo(self.view.mas_left).offset(0);
  53. make.right.equalTo(self.view.mas_right).offset(0);
  54. make.top.equalTo(self.view.mas_top).offset(0);
  55. make.height.mas_equalTo(41);
  56. }];
  57. [self.scrollLayoutView makeConstraints];
  58. }
  59. #pragma mark - event response
  60. /* 刷新 */
  61. - (void)refreshButtonClicked:(UIButton *)btn {
  62. self.salaryPayAPIManager.hpPayroll_id = self.hpPayroll_id;
  63. [self.salaryPayAPIManager start];
  64. }
  65. /* 删除prompt */
  66. - (void)deleteButtonClick:(UIButton *)btn {
  67. [UIView animateWithDuration:0.5 animations:^{
  68. [self.scrollLayoutView layoutIfNeeded];
  69. [self.promptView mas_updateConstraints:^(MASConstraintMaker *make) {
  70. make.top.equalTo(self.view.mas_top).offset(-41);
  71. }];
  72. [self.view.superview layoutIfNeeded];
  73. }];
  74. }
  75. #pragma mark - FBScrollLayoutViewDelegate
  76. - (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
  77. [scrollLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.right.bottom.equalTo(self.view).offset(0);
  79. make.top.equalTo(self.promptView.mas_bottom).offset(0);
  80. }];
  81. }
  82. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
  83. [self.salarySheetView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.top.right.equalTo(contentView).offset(0);
  85. }];
  86. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.bottom.equalTo(self.salarySheetView).with.offset(10);
  88. }];
  89. }
  90. #pragma mark - FBAPIManagerInterceptor
  91. - (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
  92. [self.view fb_showLoading];
  93. return YES;
  94. }
  95. - (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
  96. [self.view fb_dismiss];
  97. }
  98. #pragma mark - FBAPIManagerDelegate
  99. - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
  100. if (manager == self.salaryPayAPIManager)
  101. {
  102. [self.view dismissErrorView];
  103. NSDictionary *fetchData = [manager fetchDataWithBox:self.dataBox];
  104. [self.salarySheetView configWithData:fetchData];
  105. }
  106. }
  107. - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
  108. [self.view showErrorView];
  109. id fetchData = [manager fetchDataWithBox:self.dataBox];
  110. if ([fetchData isKindOfClass:[NSString class]])
  111. {
  112. [self.view fb_showFailureWithStatus:fetchData];
  113. }
  114. }
  115. #pragma mark - getters and setters
  116. - (HJSalaryDataBox *)dataBox {
  117. if (_dataBox == nil)
  118. {
  119. _dataBox = [[HJSalaryDataBox alloc] init];
  120. }
  121. return _dataBox;
  122. }
  123. - (HJSalaryPayAPIManager *)salaryPayAPIManager {
  124. if (_salaryPayAPIManager == nil)
  125. {
  126. _salaryPayAPIManager = [[HJSalaryPayAPIManager alloc] init];
  127. _salaryPayAPIManager.APIManagerDelegate = self;
  128. _salaryPayAPIManager.APIManagerInterceptor = self;
  129. }
  130. return _salaryPayAPIManager;
  131. }
  132. - (FBScrollLayoutView *)scrollLayoutView {
  133. if (_scrollLayoutView == nil)
  134. {
  135. _scrollLayoutView = [[FBScrollLayoutView alloc] init];
  136. _scrollLayoutView.delegate = self;
  137. }
  138. return _scrollLayoutView;
  139. }
  140. - (HJSalaryDetailPromptView *)promptView {
  141. if (_promptView == nil)
  142. {
  143. _promptView = [[HJSalaryDetailPromptView alloc]init];
  144. [_promptView.deletaBtn addTarget:self action:@selector(deleteButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  145. }
  146. return _promptView;
  147. }
  148. - (HJSalarySheetView *)salarySheetView {
  149. if (_salarySheetView == nil)
  150. {
  151. _salarySheetView = [[HJSalarySheetView alloc] init];
  152. }
  153. return _salarySheetView;
  154. }
  155. @end