CurrentStaffCurrentMonthPerformanceRankVc.m 7.5 KB

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