CurrentStaffLastMonthPerformanceRankVc.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //
  2. // CurrentStaffPerformanceRankVcViewController.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2018/6/22.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "CurrentStaffLastMonthPerformanceRankVc.h"
  9. @interface CurrentStaffLastMonthPerformanceRankVc ()
  10. @end
  11. @implementation CurrentStaffLastMonthPerformanceRankVc
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. NSString *currentDate=[DateFormat getCurrentDate];
  15. NSArray *dateArray = [currentDate componentsSeparatedByString:@"-"];
  16. _currentYear= [dateArray objectAtIndex:0];
  17. NSString *currentMonth=[dateArray objectAtIndex:1];
  18. int lastMonthDate= [currentMonth intValue]-1;
  19. if(lastMonthDate<10){
  20. _lastMonth=[NSString stringWithFormat:@"0%d",lastMonthDate];
  21. }
  22. else{
  23. _lastMonth=[NSString stringWithFormat:@"%d",lastMonthDate];
  24. }
  25. _dataList=[[NSMutableArray alloc]init];
  26. [self.view setBackgroundColor:[UIColor whiteColor]];
  27. }
  28. -(void) loadStaffData:(NSMutableArray*)staffList{
  29. _currentStaffList=staffList;
  30. if(_currentStaffList.count==1){
  31. [self loadData];
  32. }
  33. }
  34. -(void)loadData{
  35. [self startLoading];
  36. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  37. [dict setObject:@"SalesmanTaskCompleteStatisticsIphone" forKey:@"Action"];
  38. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  39. [dict setObject:kkUserCode forKey:@"UserCode"];
  40. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  41. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  42. [dict setObject:_currentYear forKey:@"TaskAnnual"];
  43. [dict setObject:_lastMonth forKey:@"TaskMonth"];
  44. [dict setObject:@"" forKey:@"StaffIDList"];
  45. [dict setObject:@"1" forKey:@"Granularity"];
  46. [dict setObject:@"1" forKey:@"ShowAllFlag"];
  47. _mDownManager = [[ASIDownManager alloc] init];
  48. _mDownManager.delegate = self;
  49. _mDownManager.onRequestSuccess = @selector(onStaffPerformanceLoadFinish:);
  50. _mDownManager.onRequestFail = @selector(onStaffPerformanceLoadFail:);
  51. [_mDownManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  52. }
  53. /**
  54. 加载数据成功回调
  55. @param sender <#sender description#>
  56. */
  57. - (void)onStaffPerformanceLoadFinish:(ASIDownManager *)sender {
  58. // 服务器返回数据
  59. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  60. // 服务器返回数据状态值
  61. int iStatus = resultModel.status;
  62. [self stopLoading];
  63. // 服务器返回数据消息
  64. NSString *message = resultModel.message;
  65. // 服务器返回数据状态值正确
  66. if (iStatus == 0) {
  67. NSDictionary * infoDic = (NSDictionary *)resultModel.result;
  68. NSArray *infoArray=[infoDic objectForKey:@"Table"];
  69. if(infoArray!=nil&&infoArray.count>0){
  70. for(int i=0;i<infoArray.count;i++){
  71. NSDictionary *dic=[infoArray objectAtIndex:i];
  72. PerformanceRankListModel *performanceListModel=[ PerformanceRankListModel dk_modelWithDictionary:dic];
  73. performanceListModel.rankNo=[NSString stringWithFormat:@"%d",i+1];
  74. [_dataList addObject:performanceListModel];
  75. }
  76. StaffModel *staffModel=[_currentStaffList objectAtIndex:0];
  77. for(int i=0;i<_dataList.count;i++){
  78. PerformanceRankListModel *performanceListModel=[_dataList objectAtIndex:i];
  79. if([staffModel.staffId integerValue]==[performanceListModel.staffId integerValue]){
  80. _myPerformanceModel=performanceListModel;
  81. break;
  82. }
  83. }
  84. [self drawCircle];
  85. }
  86. }
  87. // 服务器返回数据状态值异常
  88. else if(iStatus == ActionResultStatusAuthError
  89. ||iStatus == ActionResultStatusNoLogin
  90. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  91. [self showReLoginDialog:message];
  92. }
  93. else {
  94. [self showAlertViewText:message];
  95. }
  96. }
  97. /**
  98. 数据加载失败回调
  99. @param sender <#sender description#>
  100. */
  101. - (void)onStaffPerformanceLoadFail:(ASIDownManager *)sender {
  102. [self showAlertViewText:@"网络异常"];
  103. }
  104. -(void)drawCircle{
  105. CircleView *circle=[[CircleView alloc]initWithFrame:CGRectMake(0,0,200, 150)];
  106. if(_myPerformanceModel==nil){
  107. circle.completePercent=@"0.00";
  108. }
  109. else{
  110. circle.completePercent=_myPerformanceModel.completePercent;
  111. }
  112. [self.view addSubview:circle];
  113. _lblCompletePercent=[[UILabel alloc]init];
  114. [self.view addSubview:_lblCompletePercent];
  115. _lblCompletePercent.frame=CGRectMake(50,70, 80, 25);
  116. _lblCompletePercent.textColor=[UIColor whiteColor];
  117. if(_myPerformanceModel==nil){
  118. _lblCompletePercent.text=@"0.00%";
  119. }
  120. else{
  121. _lblCompletePercent.text=[NSString stringWithFormat:@"%@%@" , _myPerformanceModel.completePercent,@"%"];
  122. }
  123. UILabel *lblLastMonthCurrentAmountTitle=[[UILabel alloc]init];
  124. lblLastMonthCurrentAmountTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),10, 150, 25);
  125. lblLastMonthCurrentAmountTitle.textColor=LabelGrayTextColor;
  126. lblLastMonthCurrentAmountTitle.text=@"上月完成(元)";
  127. [self.view addSubview:lblLastMonthCurrentAmountTitle];
  128. _lblLastMontnCompleteAmount=[[UILabel alloc]init];
  129. _lblLastMontnCompleteAmount.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(lblLastMonthCurrentAmountTitle.frame)+5,150, 25);
  130. _lblLastMontnCompleteAmount.textColor=[UIColor hexColor:@"fecb6e"];
  131. if(_myPerformanceModel==nil){
  132. _lblLastMontnCompleteAmount.text=@"¥0.00";
  133. }
  134. else{
  135. _lblLastMontnCompleteAmount.text=[NSString stringWithFormat:@"¥%@", _myPerformanceModel.salesAmount];
  136. }
  137. [self.view addSubview:_lblLastMontnCompleteAmount];
  138. UILabel *lblLastMonthTaskAmountTitle=[[UILabel alloc]init];
  139. lblLastMonthTaskAmountTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(_lblLastMontnCompleteAmount.frame)+5, 150, 25);
  140. lblLastMonthTaskAmountTitle.textColor=LabelGrayTextColor;
  141. lblLastMonthTaskAmountTitle.text=@"上月任务(元)";
  142. [self.view addSubview:lblLastMonthTaskAmountTitle];
  143. _lblLastMontnTaskAmount=[[UILabel alloc]init];
  144. _lblLastMontnTaskAmount.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(lblLastMonthTaskAmountTitle.frame)+5,150, 25);
  145. _lblLastMontnTaskAmount.textColor=[UIColor hexColor:@"3ecccb"];
  146. if(_myPerformanceModel==nil){
  147. _lblLastMontnTaskAmount.text=@"¥0.00";
  148. }
  149. else{
  150. _lblLastMontnTaskAmount.text=[NSString stringWithFormat:@"¥%@", _myPerformanceModel.currentMonthTaskAmount];
  151. }
  152. [self.view addSubview:_lblLastMontnTaskAmount];
  153. UILabel *lblLastMonthRankTitle=[[UILabel alloc]init];
  154. lblLastMonthRankTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(_lblLastMontnTaskAmount.frame)+5, 80, 25);
  155. lblLastMonthRankTitle.textColor=LabelGrayTextColor;
  156. lblLastMonthRankTitle.text=@"上月排行";
  157. [self.view addSubview:lblLastMonthRankTitle];
  158. _lblLastMontnRank=[[UILabel alloc]init];
  159. _lblLastMontnRank.frame=CGRectMake(CGRectGetMaxX(lblLastMonthRankTitle.frame), CGRectGetMaxY(_lblLastMontnTaskAmount.frame)+5, 80,25);
  160. _lblLastMontnRank.textColor=[UIColor redColor];
  161. if(_myPerformanceModel==nil){
  162. _lblLastMontnRank.text=@"0";
  163. }
  164. else{
  165. _lblLastMontnRank.text=_myPerformanceModel.rankNo;
  166. }
  167. [self.view addSubview:_lblLastMontnRank];
  168. }
  169. - (void)didReceiveMemoryWarning {
  170. [super didReceiveMemoryWarning];
  171. }
  172. @end