| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- //
- // HJSalaryDetailViewController.m
- // HappyJob
- //
- // Created by Bob on 2019/5/29.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJSalaryDetailViewController.h"
- #import "HJLabelTextFieldView.h"
- #import "FBScrollLayoutView.h"
- #import "HJResumeModel.h"
- #import "HJUserInfoModel.h"
- #import "HJSalaryPayAPIManager.h"
- #import "HJSalarySheetView.h"
- #import "HJSalaryDataBox.h"
- #import "HJSalaryDetailPromptView.h"
- @interface HJSalaryDetailViewController ()
- <
- FBScrollLayoutViewDelegate,
- FBAPIManagerDelegate,
- FBAPIManagerInterceptor
- >
- @property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
- @property (nonatomic, strong) HJSalaryDetailPromptView *promptView;
- @property (nonatomic, strong) HJSalarySheetView *salarySheetView;
- @property (nonatomic, copy) NSArray *dateDataSource;
- @property (nonatomic, strong) HJSalaryPayAPIManager *salaryPayAPIManager;
- @property (nonatomic, strong) HJSalaryDataBox *dataBox;
- @end
- @implementation HJSalaryDetailViewController
- #pragma mark - life cycle
- - (void)dealloc {
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"薪资详情";
- [self hj_setupNavBar];
- [self subViewsMakeConstraints];
- self.salaryPayAPIManager.hpPayroll_id = self.hpPayroll_id;
- [self.salaryPayAPIManager start];
- // 错误页面刷新事件
- [self.view.errorView.refreshButton addTarget:self
- action:@selector(refreshButtonClicked:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- #pragma mark - init
- - (void)subViewsMakeConstraints {
-
- [self.view addSubview:self.promptView];
- [self.view addSubview:self.scrollLayoutView];
- [self.scrollLayoutView.contentView addSubview:self.salarySheetView];
- [self.promptView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view.mas_left).offset(0);
- make.right.equalTo(self.view.mas_right).offset(0);
- make.top.equalTo(self.view.mas_top).offset(0);
- make.height.mas_equalTo(41);
- }];
- [self.scrollLayoutView makeConstraints];
- }
- #pragma mark - event response
- /* 刷新 */
- - (void)refreshButtonClicked:(UIButton *)btn {
-
- self.salaryPayAPIManager.hpPayroll_id = self.hpPayroll_id;
- [self.salaryPayAPIManager start];
- }
- /* 删除prompt */
- - (void)deleteButtonClick:(UIButton *)btn {
-
- [UIView animateWithDuration:0.5 animations:^{
-
- [self.scrollLayoutView layoutIfNeeded];
-
- [self.promptView mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.view.mas_top).offset(-41);
- }];
- [self.view.superview layoutIfNeeded];
- }];
- }
- #pragma mark - FBScrollLayoutViewDelegate
- - (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
-
- [scrollLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.view).offset(0);
- make.top.equalTo(self.promptView.mas_bottom).offset(0);
- }];
- }
- - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
-
- [self.salarySheetView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.equalTo(contentView).offset(0);
- }];
-
- [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.salarySheetView).with.offset(10);
- }];
- }
- #pragma mark - FBAPIManagerInterceptor
- - (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
-
- [self.view fb_showLoading];
- return YES;
- }
- - (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
-
- [self.view fb_dismiss];
- }
- #pragma mark - FBAPIManagerDelegate
- - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
-
- if (manager == self.salaryPayAPIManager)
- {
- [self.view dismissErrorView];
- NSDictionary *fetchData = [manager fetchDataWithBox:self.dataBox];
- [self.salarySheetView configWithData:fetchData];
- }
- }
- - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
-
- [self.view showErrorView];
- id fetchData = [manager fetchDataWithBox:self.dataBox];
-
- if ([fetchData isKindOfClass:[NSString class]])
- {
- [self.view fb_showFailureWithStatus:fetchData];
- }
- }
- #pragma mark - getters and setters
- - (HJSalaryDataBox *)dataBox {
-
- if (_dataBox == nil)
- {
- _dataBox = [[HJSalaryDataBox alloc] init];
- }
- return _dataBox;
- }
- - (HJSalaryPayAPIManager *)salaryPayAPIManager {
-
- if (_salaryPayAPIManager == nil)
- {
- _salaryPayAPIManager = [[HJSalaryPayAPIManager alloc] init];
- _salaryPayAPIManager.APIManagerDelegate = self;
- _salaryPayAPIManager.APIManagerInterceptor = self;
- }
- return _salaryPayAPIManager;
- }
- - (FBScrollLayoutView *)scrollLayoutView {
-
- if (_scrollLayoutView == nil)
- {
- _scrollLayoutView = [[FBScrollLayoutView alloc] init];
- _scrollLayoutView.delegate = self;
- }
- return _scrollLayoutView;
- }
- - (HJSalaryDetailPromptView *)promptView {
-
- if (_promptView == nil)
- {
- _promptView = [[HJSalaryDetailPromptView alloc]init];
- [_promptView.deletaBtn addTarget:self action:@selector(deleteButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _promptView;
- }
- - (HJSalarySheetView *)salarySheetView {
-
- if (_salarySheetView == nil)
- {
- _salarySheetView = [[HJSalarySheetView alloc] init];
- }
- return _salarySheetView;
- }
- @end
|