| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- //
- // CurrentStaffCurrentMonthPerformanceRankVc.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/6/22.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "CurrentStaffCurrentMonthPerformanceRankVc.h"
- @interface CurrentStaffCurrentMonthPerformanceRankVc ()
- @end
- @implementation CurrentStaffCurrentMonthPerformanceRankVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- NSString *currentDate=[DateFormat getCurrentDate];
- NSArray *dateArray = [currentDate componentsSeparatedByString:@"-"];
- _currentYear= [dateArray objectAtIndex:0];
- _currentMonth=[dateArray objectAtIndex:1];
- _dataList=[[NSMutableArray alloc]init];
- [self.view setBackgroundColor:[UIColor whiteColor]];
- }
- -(void) loadStaffData:(NSMutableArray*)staffList{
- _currentStaffList=staffList;
- if(_currentStaffList.count==1){
- [self loadData];
- }
- }
- -(void)loadData{
- [self startLoading];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"SalesmanTaskCompleteStatisticsIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_currentYear forKey:@"TaskAnnual"];
- [dict setObject:_currentMonth forKey:@"TaskMonth"];
- [dict setObject:@"" forKey:@"StaffIDList"];
- [dict setObject:@"1" forKey:@"Granularity"];
- [dict setObject:@"1" forKey:@"ShowAllFlag"];
- _mDownManager = [[ASIDownManager alloc] init];
- _mDownManager.delegate = self;
- _mDownManager.onRequestSuccess = @selector(onStaffPerformanceLoadFinish:);
- _mDownManager.onRequestFail = @selector(onStaffPerformanceLoadFail:);
- [_mDownManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 加载数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onStaffPerformanceLoadFinish:(ASIDownManager *)sender {
-
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- [self stopLoading];
-
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSDictionary * infoDic = (NSDictionary *)resultModel.result;
- NSArray *infoArray=[infoDic objectForKey:@"Table"];
- if(infoArray!=nil&&infoArray.count>0){
-
- for(int i=0;i<infoArray.count;i++){
- NSDictionary *dic=[infoArray objectAtIndex:i];
- PerformanceRankListModel *performanceListModel=[ PerformanceRankListModel dk_modelWithDictionary:dic];
- performanceListModel.rankNo=[NSString stringWithFormat:@"%d",i+1];
- [_dataList addObject:performanceListModel];
- }
-
- StaffModel *staffModel=[_currentStaffList objectAtIndex:0];
-
- for(int i=0;i<_dataList.count;i++){
- PerformanceRankListModel *performanceListModel=[_dataList objectAtIndex:i];
- if([staffModel.staffId integerValue]==[performanceListModel.staffId integerValue]){
- _myPerformanceModel=performanceListModel;
- break;
- }
-
-
- }
-
- [self drawCircle];
-
- }
-
- }
-
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- }
- else {
-
- [self showAlertViewText:message];
- }
- }
- /**
- 数据加载失败回调
- @param sender <#sender description#>
- */
- - (void)onStaffPerformanceLoadFail:(ASIDownManager *)sender {
- [self showAlertViewText:@"网络异常"];
- }
- -(void)drawCircle{
-
- CircleView *circle=[[CircleView alloc]initWithFrame:CGRectMake(0,0,200, 150)];
- if(_myPerformanceModel==nil){
- circle.completePercent=@"0.00";
- }
- else{
- circle.completePercent=_myPerformanceModel.completePercent;
- }
- [self.view addSubview:circle];
-
- _lblCompletePercent=[[UILabel alloc]init];
- [self.view addSubview:_lblCompletePercent];
- _lblCompletePercent.frame=CGRectMake(50,70, 80, 25);
- _lblCompletePercent.textColor=[UIColor whiteColor];
- if(_myPerformanceModel==nil){
- _lblCompletePercent.text=@"0.00%";
- }
- else{
- _lblCompletePercent.text=[NSString stringWithFormat:@"%@%@" , _myPerformanceModel.completePercent,@"%"];
- }
-
- UILabel *lblCurrentMonthCurrentAmountTitle=[[UILabel alloc]init];
- lblCurrentMonthCurrentAmountTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),10, 150, 25);
-
- lblCurrentMonthCurrentAmountTitle.textColor=LabelGrayTextColor;
- lblCurrentMonthCurrentAmountTitle.text=@"本月完成(元)";
- [self.view addSubview:lblCurrentMonthCurrentAmountTitle];
-
- _lblCurrentMontnCompleteAmount=[[UILabel alloc]init];
- _lblCurrentMontnCompleteAmount.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(lblCurrentMonthCurrentAmountTitle.frame)+5,150, 25);
- _lblCurrentMontnCompleteAmount.textColor=[UIColor hexColor:@"fecb6e"];
- if(_myPerformanceModel==nil){
- _lblCurrentMontnCompleteAmount.text=@"¥0.00";
- }
- else{
- _lblCurrentMontnCompleteAmount.text=[NSString stringWithFormat:@"¥%@", _myPerformanceModel.salesAmount];
- }
- [self.view addSubview:_lblCurrentMontnCompleteAmount];
-
-
- UILabel *lblCurrentMonthTaskAmountTitle=[[UILabel alloc]init];
- lblCurrentMonthTaskAmountTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(_lblCurrentMontnCompleteAmount.frame)+5, 150, 25);
-
- lblCurrentMonthTaskAmountTitle.textColor=LabelGrayTextColor;
- lblCurrentMonthTaskAmountTitle.text=@"本月任务(元)";
- [self.view addSubview:lblCurrentMonthTaskAmountTitle];
-
- _lblCurrentMontnTaskAmount=[[UILabel alloc]init];
- _lblCurrentMontnTaskAmount.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(lblCurrentMonthTaskAmountTitle.frame)+5,150, 25);
- _lblCurrentMontnTaskAmount.textColor=[UIColor hexColor:@"3ecccb"];
- if(_myPerformanceModel==nil){
-
- _lblCurrentMontnTaskAmount.text=@"¥0.00";
- }
- else
- {
- _lblCurrentMontnTaskAmount.text=[NSString stringWithFormat:@"¥%@", _myPerformanceModel.currentMonthTaskAmount];
- }
- [self.view addSubview:_lblCurrentMontnTaskAmount];
-
-
- UILabel *lblCurrentMonthRankTitle=[[UILabel alloc]init];
- lblCurrentMonthRankTitle.frame=CGRectMake(CGRectGetMaxX(circle.frame),CGRectGetMaxY(_lblCurrentMontnTaskAmount.frame)+5, 80, 25);
-
- lblCurrentMonthRankTitle.textColor=LabelGrayTextColor;
- lblCurrentMonthRankTitle.text=@"本月排行";
- [self.view addSubview:lblCurrentMonthRankTitle];
-
- _lblCurrentMontnRank=[[UILabel alloc]init];
- _lblCurrentMontnRank.frame=CGRectMake(CGRectGetMaxX(lblCurrentMonthRankTitle.frame), CGRectGetMaxY(_lblCurrentMontnTaskAmount.frame)+5, 80,25);
- _lblCurrentMontnRank.textColor=[UIColor redColor];
- if(_myPerformanceModel==nil){
- _lblCurrentMontnRank.text=@"0";
- }
- else{
- _lblCurrentMontnRank.text=_myPerformanceModel.rankNo;
- }
- [self.view addSubview:_lblCurrentMontnRank];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|