HJClockInStatisticDetailViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. //
  2. // HJClockInStatisticsDetailViewController.m
  3. // HappyJob
  4. //
  5. // Created by 张晓光 on 2020/8/25.
  6. // Copyright © 2020 Bob. All rights reserved.
  7. //
  8. #import "HJClockInStatisticDetailViewController.h"
  9. #import "HJClockInStatisticDetailInfoView.h"
  10. #import "HJClockInStatisticDetailMonthView.h"
  11. #import "HJClockInStatisticDetailWeekView.h"
  12. #import "HJGetUserInfoAPIManager.h"//用户信息接口
  13. #import "HJClockInStatisticMonthAPI.h"
  14. #import "HJClockInStatisticWeekAPI.h"
  15. #import "HJClockInDataBox.h"
  16. #import "HJClockInInfoModel.h"
  17. #import "HJClockInStatisticDataModel.h"
  18. @interface HJClockInStatisticDetailViewController ()
  19. <
  20. HJClockInStatisticDetailTitleViewDelegate,
  21. FBScrollLayoutViewDelegate,
  22. FBAPIManagerInterceptor,
  23. FBAPIManagerDelegate
  24. >
  25. @property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
  26. @property (nonatomic, strong) HJClockInStatisticDetailInfoView *infoView;
  27. @property (nonatomic, strong) HJClockInStatisticDetailMonthView *monthView;
  28. @property (nonatomic, strong) HJClockInStatisticDetailWeekView *weekView;
  29. @property (nonatomic, strong) HJClockInStatisticDataModel *dataModel;
  30. @property (nonatomic, strong) HJGetUserInfoAPIManager *userInfoAPI;
  31. @property (nonatomic, strong) HJClockInStatisticMonthAPI *monthAPI;
  32. @property (nonatomic, strong) HJClockInStatisticWeekAPI *weekAPI;
  33. @property (nonatomic, strong) HJClockInDataBox *dataBox;
  34. @end
  35. @implementation HJClockInStatisticDetailViewController
  36. #pragma mark - life cycle
  37. - (void)viewWillAppear:(BOOL)animated {
  38. [super viewWillAppear:animated];
  39. }
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. [self hj_setupNavBar];
  43. self.navigationItem.title = @"统计";
  44. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navi_delete"] style:UIBarButtonItemStyleDone target:self action:@selector(exitClick)];
  45. [self makeConstraintsViews];
  46. [self.userInfoAPI start];
  47. self.monthAPI.month_type = @"1";
  48. [self.monthAPI start];
  49. self.weekAPI.week_type = @"1";
  50. [self.weekAPI start];
  51. }
  52. - (void)makeConstraintsViews {
  53. self.view.backgroundColor = COLOR_F5F5F5;
  54. [self.view addSubview:self.scrollLayoutView];
  55. [self.scrollLayoutView.contentView addSubview:self.infoView];
  56. [self.scrollLayoutView.contentView addSubview:self.monthView];
  57. [self.scrollLayoutView.contentView addSubview:self.weekView];
  58. [self.scrollLayoutView makeConstraints];
  59. }
  60. #pragma mark - event
  61. - (void)exitClick{
  62. [self.navigationController popToRootViewControllerAnimated:YES];
  63. }
  64. #pragma mark - FBScrollLayoutViewDelegate
  65. - (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
  66. [scrollLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.right.top.bottom.equalTo(self.view).offset(0);
  68. }];
  69. }
  70. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
  71. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.top.equalTo(contentView).offset(10);
  73. make.left.right.equalTo(contentView);
  74. }];
  75. [self.monthView mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.equalTo(self.infoView.mas_bottom).offset(10);
  77. make.left.right.equalTo(contentView);
  78. }];
  79. [self.weekView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.top.equalTo(self.monthView.mas_bottom).offset(10);
  81. make.left.right.equalTo(contentView);
  82. }];
  83. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.bottom.equalTo(self.weekView.mas_bottom).offset(0);
  85. }];
  86. }
  87. #pragma mark - FBAPIManagerInterceptor
  88. - (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
  89. [self.view fb_showLoading];
  90. return YES;
  91. }
  92. - (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
  93. [self.view fb_dismiss];
  94. }
  95. #pragma mark - FBAPIManagerDelegate
  96. - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
  97. if (manager == self.userInfoAPI)
  98. {
  99. NSDictionary *dataDict = [manager fetchDataWithBox:self.dataBox];
  100. HJClockInInfoModel *userModel = [HJClockInInfoModel yy_modelWithDictionary:dataDict[@"hpUser"]];
  101. HJClockInInfoModel *memberModel = [HJClockInInfoModel yy_modelWithDictionary:dataDict[@"hpMember"]];
  102. [self.infoView.headerIcon sd_setImageWithURL:[NSURL URLWithString:userModel.headImgUrl] placeholderImage:[UIImage imageNamed:@"me_portrait_default"]];
  103. self.infoView.nameLabel.text = memberModel.realName;
  104. if (memberModel.authenticationStatus == 1)
  105. {//认证中
  106. self.infoView.icon.image = [UIImage imageNamed:@"clockin_anth_audit"];
  107. self.infoView.tagLabel.text = @"认证信息审核中";
  108. self.infoView.tagLabel.textColor = COLOR_999999;
  109. }
  110. else
  111. {//认证成功
  112. self.infoView.icon.image = [UIImage imageNamed:@"clockIn_auth_icon"];
  113. self.infoView.tagLabel.text = @"开心工作认证用户";
  114. self.infoView.tagLabel.textColor = COLOR_0177FF;
  115. }
  116. }
  117. if (manager == self.monthAPI)
  118. {
  119. NSDictionary *dataDict = [manager fetchDataWithBox:self.dataBox];
  120. HJClockInInfoModel *model = [HJClockInInfoModel yy_modelWithDictionary:dataDict[@"currentSettlement"]];
  121. // self.monthView.monthTotalAdvanceView.contentLabel.text = [NSString stringWithFormat:@"%@元",model.nextMoney ? [NSString stringWithFormat:@"%.2lf",[model.nextMoney floatValue]] : @"0"];
  122. self.monthView.monthTotalWorkeHourView.contentLabel.text = [NSString stringWithFormat:@"%@小时",model.countDuration ? model.countDuration :@"0"];
  123. self.monthView.monthClickInDaysView.contentLabel.text = [NSString stringWithFormat:@"%@次",model.attendance ? model.attendance :@"0"];
  124. self.monthView.monthNoPunchInView.contentLabel.text = [NSString stringWithFormat:@"%@次",model.lackClock ? model.lackClock :@"0"];
  125. if ([self.monthAPI.month_type isEqualToString:@"1"])
  126. {
  127. [self.monthView.monthView rightButtonAction];
  128. }
  129. else
  130. {
  131. [self.monthView.monthView leftButtonAction];
  132. }
  133. }
  134. if (manager == self.weekAPI)
  135. {
  136. NSDictionary *dataDict = [manager fetchDataWithBox:self.dataBox];
  137. HJClockInInfoModel *model = [HJClockInInfoModel yy_modelWithDictionary:dataDict[@"currentSettlement"]];
  138. // self.weekView.weekTotalAdvanceView.contentLabel.text = [NSString stringWithFormat:@"%@元",model.nextMoney ? [NSString stringWithFormat:@"%.2lf",[model.nextMoney floatValue]] :@"0"];
  139. self.weekView.weekTotalWorkeHourView.contentLabel.text = [NSString stringWithFormat:@"%@小时",model.countDuration ? model.countDuration :@"0"];
  140. self.weekView.weekClockInDaysView.contentLabel.text = [NSString stringWithFormat:@"%@次",model.attendance ? model.attendance : @"0"];
  141. self.weekView.weekNoPunchInView.contentLabel.text = [NSString stringWithFormat:@"%@次",model.lackClock ? model.lackClock :@"0"];
  142. if ([self.weekAPI.week_type isEqualToString:@"1"])
  143. {
  144. [self.weekView.weekView rightButtonAction];
  145. }
  146. else
  147. {
  148. [self.weekView.weekView leftButtonAction];
  149. }
  150. }
  151. }
  152. - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
  153. id fetchData = [manager fetchDataWithBox:self.dataBox];
  154. if ([fetchData isKindOfClass:[NSString class]])
  155. {
  156. [self.view fb_showFailureWithStatus:fetchData];
  157. }
  158. }
  159. #pragma mark - HJClockInStatisticDetailTitleViewDelegate
  160. /* 上月,上周 */
  161. - (void)leftButtonActionDelegate:(NSInteger)tag {
  162. if (tag == 1)
  163. {//上月
  164. self.monthAPI.month_type = @"2";
  165. [self.monthAPI start];
  166. }
  167. else
  168. {//上周
  169. self.weekAPI.week_type = @"2";
  170. [self.weekAPI start];
  171. }
  172. }
  173. /* 本月,本周 */
  174. - (void)rightButtonActionDelegate:(NSInteger)tag {
  175. if (tag == 2)
  176. {//本月
  177. self.monthAPI.month_type = @"1";
  178. [self.monthAPI start];
  179. }
  180. else
  181. {//本周
  182. self.weekAPI.week_type = @"1";
  183. [self.weekAPI start];
  184. }
  185. }
  186. #pragma mark - lazy
  187. - (HJGetUserInfoAPIManager *)userInfoAPI {
  188. if (_userInfoAPI == nil)
  189. {
  190. _userInfoAPI = [[HJGetUserInfoAPIManager alloc]init];
  191. _userInfoAPI.APIManagerDelegate = self;
  192. _userInfoAPI.APIManagerInterceptor = self;
  193. }
  194. return _userInfoAPI;
  195. }
  196. - (HJClockInStatisticMonthAPI *)monthAPI {
  197. if (_monthAPI == nil)
  198. {
  199. _monthAPI = [[HJClockInStatisticMonthAPI alloc]init];
  200. _monthAPI.APIManagerDelegate = self;
  201. _monthAPI.APIManagerInterceptor = self;
  202. }
  203. return _monthAPI;
  204. }
  205. - (HJClockInStatisticWeekAPI *)weekAPI {
  206. if (_weekAPI == nil)
  207. {
  208. _weekAPI = [[HJClockInStatisticWeekAPI alloc]init];
  209. _weekAPI.APIManagerDelegate = self;
  210. _weekAPI.APIManagerInterceptor = self;
  211. }
  212. return _weekAPI;
  213. }
  214. - (HJClockInDataBox *)dataBox {
  215. if (_dataBox == nil)
  216. {
  217. _dataBox = [[HJClockInDataBox alloc] init];
  218. }
  219. return _dataBox;
  220. }
  221. - (FBScrollLayoutView *)scrollLayoutView {
  222. if (_scrollLayoutView == nil)
  223. {
  224. _scrollLayoutView = [[FBScrollLayoutView alloc] init];
  225. _scrollLayoutView.delegate = self;
  226. _scrollLayoutView.backgroundColor = COLOR_F5F5F5;
  227. _scrollLayoutView.contentView.backgroundColor = COLOR_F5F5F5;
  228. _scrollLayoutView.scrollView.showsVerticalScrollIndicator = NO;
  229. }
  230. return _scrollLayoutView;
  231. }
  232. - (HJClockInStatisticDetailInfoView *)infoView {
  233. if (_infoView == nil)
  234. {
  235. _infoView = [[HJClockInStatisticDetailInfoView alloc]init];
  236. }
  237. return _infoView;
  238. }
  239. - (HJClockInStatisticDataModel *)dataModel {
  240. if (_dataModel == nil)
  241. {
  242. _dataModel = [[HJClockInStatisticDataModel alloc] initWithServicerDate:self.servicerDate];
  243. }
  244. return _dataModel;
  245. }
  246. - (HJClockInStatisticDetailMonthView *)monthView {
  247. if (_monthView == nil)
  248. {
  249. _monthView = [[HJClockInStatisticDetailMonthView alloc]init];
  250. _monthView.monthView.contentLabel.text = self.dataModel.yearsArray.lastObject;
  251. _monthView.monthView.titleArray = self.dataModel.yearsArray;
  252. _monthView.monthView.delegate = self;
  253. _monthView.monthView.leftBtn.tag = 1;
  254. _monthView.monthView.rightBtn.tag = 2;
  255. }
  256. return _monthView;
  257. }
  258. - (HJClockInStatisticDetailWeekView *)weekView {
  259. if (_weekView == nil)
  260. {
  261. _weekView = [[HJClockInStatisticDetailWeekView alloc]init];
  262. _weekView.weekView.contentLabel.text = @"本周";
  263. _weekView.weekView.titleArray = @[@"上周",@"本周"];
  264. _weekView.weekView.delegate = self;
  265. _weekView.weekView.leftBtn.tag = 3;
  266. _weekView.weekView.rightBtn.tag = 4;
  267. }
  268. return _weekView;
  269. }
  270. @end