// // VersionDataVC.m // smartRhino // // Created by tederen on 2019/11/28. // Copyright © 2019 tederen. All rights reserved. // #import "VersionDataVC.h" #import "UILabel+RightAndLeft.h" #import "DepartureController.h" #import "NoteBookShareVC.h" @interface VersionDataVC () @property (weak, nonatomic) IBOutlet UILabel *yearMonthDaylabel; @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC; #pragma mark - 财务数据 属性 #pragma mark - 收入 @property (weak, nonatomic) IBOutlet UIView *incomeHeader; @property (weak, nonatomic) IBOutlet UILabel *incomKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *incomValueLabel; @property (weak, nonatomic) IBOutlet UILabel *incomeScaleKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *incomeScaleValueLabel; @property (weak, nonatomic) IBOutlet UIImageView *incomeScaleValueImage; @property (weak, nonatomic) IBOutlet UIView *incomeTableView; @property (weak, nonatomic) IBOutlet UIButton *incomeDayBtn; @property (weak, nonatomic) IBOutlet UIButton *incomeWeekBtn; @property (weak, nonatomic) IBOutlet UIButton *incomeMonthBtn; @property (weak, nonatomic) IBOutlet UIButton *incomeYearBtn; @property (nonatomic, strong) WKEchartsView *incomeEchartsView; #pragma mark - 支出 @property (weak, nonatomic) IBOutlet UIView *expensesHeader; @property (weak, nonatomic) IBOutlet UILabel *expensesKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *expensesValueLabel; @property (weak, nonatomic) IBOutlet UILabel *expensesScaleKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *expensesScaleValueLabel; @property (weak, nonatomic) IBOutlet UIImageView *expensesScaleValueImage; @property (weak, nonatomic) IBOutlet UIView *expensesTableView; @property (weak, nonatomic) IBOutlet UIButton *expensesDayBtn; @property (weak, nonatomic) IBOutlet UIButton *expensesWeekBtn; @property (weak, nonatomic) IBOutlet UIButton *expensesMonthBtn; @property (weak, nonatomic) IBOutlet UIButton *expensesYearBtn; @property (nonatomic, strong) WKEchartsView *expensesEchartsView; #pragma mark - 利润 @property (weak, nonatomic) IBOutlet UIView *profitHeader; @property (weak, nonatomic) IBOutlet UILabel *profitKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *profitValueLabel; @property (weak, nonatomic) IBOutlet UILabel *profitScaleKeyLabel; @property (weak, nonatomic) IBOutlet UILabel *profitScaleValueLabel; @property (weak, nonatomic) IBOutlet UIImageView *profitScaleValueImage; @property (weak, nonatomic) IBOutlet UIView *profitTableView; @property (weak, nonatomic) IBOutlet UIButton *profitDayBtn; @property (weak, nonatomic) IBOutlet UIButton *profitWeekBtn; @property (weak, nonatomic) IBOutlet UIButton *profitMonthBtn; @property (weak, nonatomic) IBOutlet UIButton *profitYearBtn; @property (nonatomic, strong) WKEchartsView *profitEchartsView; @property (nonatomic, strong) VersionDataModel *incomeModel; @property (nonatomic, strong) VersionDataModel *expensesModel; @property (nonatomic, strong) VersionDataModel *profitModel; #pragma mark - 出版数据 属性 /// 出版 /// 本年累计出版册数 @property (weak, nonatomic) IBOutlet UILabel *yearVersionNumberLabel; /// 本年累计印费 @property (weak, nonatomic) IBOutlet UILabel *yearPrintNuberLabel; /// 月出版种类 @property (weak, nonatomic) IBOutlet UILabel *monthVersionKindLabel; /// 月出版数量 @property (weak, nonatomic) IBOutlet UILabel *monthVerionNumberLabel; /// 月印费 @property (weak, nonatomic) IBOutlet UILabel *monthPrintNumberlael; @property (weak, nonatomic) IBOutlet UILabel *monthMoneyScaleLabel; @property (weak, nonatomic) IBOutlet UIImageView *monthPrintScaleImageView; /// 发行 @property (weak, nonatomic) IBOutlet UILabel *pubilshMonthLabel; @property (weak, nonatomic) IBOutlet UILabel *publisScaleLabel; @property (weak, nonatomic) IBOutlet UIImageView *publisScaleImageView; /// 库存 @property (weak, nonatomic) IBOutlet UILabel *storeLabel; @property (weak, nonatomic) IBOutlet UIImageView *storeScaleImageView; #pragma mark - 人事数据 属性 ///人员工资总额 @property (weak, nonatomic) IBOutlet UILabel *allPersonMoneyLabel; /// 人员工资上月同比 @property (weak, nonatomic) IBOutlet UILabel *allPersonScaleValueLabel; @property (weak, nonatomic) IBOutlet UIImageView *allPersonScaleImageView; /// 入职人员工资 @property (weak, nonatomic) IBOutlet UILabel *addPersonMoneyLabel; /// 入职人员工资上月同比 @property (weak, nonatomic) IBOutlet UILabel *addPersonScaleValueLabel; @property (weak, nonatomic) IBOutlet UIImageView *addPersonScaleImageView; /// 离职人员工资 @property (weak, nonatomic) IBOutlet UILabel *movePersonLabel; @property (weak, nonatomic) IBOutlet UIView *movePersonView; @property (nonatomic, assign) NSInteger netFlag; @end @implementation VersionDataVC - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.noteBookShareVC.view]; self.fd_prefersNavigationBarHidden = YES; self.netFlag = 1; [self getData]; [self setingUI]; self.movePersonView.hidden = YES; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; } - (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } #pragma mark - 查看离职人员详情 - (IBAction)movePersonHander:(UIButton *)sender { DepartureController *departureController = [[DepartureController alloc] init]; [self.navigationController pushViewController:departureController animated:YES]; } - (IBAction)backButton:(UIButton *)sender { [self.navigationController popViewControllerAnimated:YES]; } - (IBAction)sencondBackButton:(UIButton *)sender { [super menuAction:sender]; } #pragma mark - 保存数据 - (IBAction)versionDownLoadHander:(UIButton *)sender { [self shareHander]; } /// 转发正文 - (void)shareHander{ [self.noteBookShareVC initNoteBookShareData]; self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden; } - (NoteBookShareVC *)noteBookShareVC{ if (_noteBookShareVC == nil) { _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC]; [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)]; [_noteBookShareVC.view setHidden:YES]; _noteBookShareVC.delegate = self; } return _noteBookShareVC; } -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{ self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden; if ([typeName isEqualToString:@"发给微信好友"]) { }else if ([typeName isEqualToString:@"发到朋友圈"]){ }else if ([typeName isEqualToString:@"发到微博"]){ }else if ([typeName isEqualToString:@"发给QQ好友"]){ }else if ([typeName isEqualToString:@"发到消息"]){ }else if ([typeName isEqualToString:@"发到小组"]){ }else if ([typeName isEqualToString:@"发到笔记"]){ }else if ([typeName isEqualToString:@"发到话题"]){ }else{ } } #pragma mark - 收入 点击事件 - (IBAction)incomeHander:(UIButton *)sender { NSInteger date = 0; if ([[sender titleLabel].text isEqualToString:@"日"]) { self.incomeDayBtn.selected = YES; self.incomeWeekBtn.selected = NO; self.incomeMonthBtn.selected = NO; self.incomeYearBtn.selected = NO; date = 1; } if ([[sender titleLabel].text isEqualToString:@"周"]) { self.incomeDayBtn.selected = NO; self.incomeWeekBtn.selected = YES; self.incomeMonthBtn.selected = NO; self.incomeYearBtn.selected = NO; date = 2; } if ([[sender titleLabel].text isEqualToString:@"月"]) { self.incomeDayBtn.selected = NO; self.incomeWeekBtn.selected = NO; self.incomeMonthBtn.selected = YES; self.incomeYearBtn.selected = NO; date = 3; } if ([[sender titleLabel].text isEqualToString:@"年"]) { self.incomeDayBtn.selected = NO; self.incomeWeekBtn.selected = NO; self.incomeMonthBtn.selected = NO; self.incomeYearBtn.selected = YES; date = 4; } SHOWLOADING switch (self.pageType) { case 1:{ [VersionDataVC getDataWithDataType:2 withDateType:date success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"收入%@",self.incomeModel); REMOVESHOW [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 2:{ [VersionDataVC getDataWithVersisonType:1 withDateType:date success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"收入%@",self.incomeModel); REMOVESHOW [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 3:{ [VersionDataVC getDataWithHumanType:1 withDateType:date success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事%@",self.incomeModel); REMOVESHOW [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; default: break; } } #pragma mark - 支出 点击事件 - (IBAction)expensesHander:(UIButton *)sender { NSInteger date = 0; if ([[sender titleLabel].text isEqualToString:@"日"]) { self.expensesDayBtn.selected = YES; self.expensesWeekBtn.selected = NO; self.expensesMonthBtn.selected = NO; self.expensesYearBtn.selected = NO; date = 1; } if ([[sender titleLabel].text isEqualToString:@"周"]) { self.expensesDayBtn.selected = NO; self.expensesWeekBtn.selected = YES; self.expensesMonthBtn.selected = NO; self.expensesYearBtn.selected = NO; date = 2; } if ([[sender titleLabel].text isEqualToString:@"月"]) { self.expensesDayBtn.selected = NO; self.expensesWeekBtn.selected = NO; self.expensesMonthBtn.selected = YES; self.expensesYearBtn.selected = NO; date = 3; } if ([[sender titleLabel].text isEqualToString:@"年"]) { self.expensesDayBtn.selected = NO; self.expensesWeekBtn.selected = NO; self.expensesMonthBtn.selected = NO; self.expensesYearBtn.selected = YES; date = 4; } SHOWLOADING switch (self.pageType) { case 2: { [VersionDataVC getDataWithDataType:2 withDateType:date success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"支出%@",self.expensesModel); REMOVESHOW [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 1:{ [VersionDataVC getDataWithPublishType:2 withDateType:date success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"支出%@",self.expensesModel); REMOVESHOW [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 3:{ [VersionDataVC getDataWithHumanType:2 withDateType:date success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事 入职数据%@",self.expensesModel); REMOVESHOW [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; default: break; } } #pragma mark - 利润 点击事件 - (IBAction)profitHander:(UIButton *)sender { NSInteger date = 0; if ([[sender titleLabel].text isEqualToString:@"日"]) { self.profitDayBtn.selected = YES; self.profitWeekBtn.selected = NO; self.profitMonthBtn.selected = NO; self.profitYearBtn.selected = NO; date = 1; } if ([[sender titleLabel].text isEqualToString:@"周"]) { self.profitDayBtn.selected = NO; self.profitWeekBtn.selected = YES; self.profitMonthBtn.selected = NO; self.profitYearBtn.selected = NO; date = 2; } if ([[sender titleLabel].text isEqualToString:@"月"]) { self.profitDayBtn.selected = NO; self.profitWeekBtn.selected = NO; self.profitMonthBtn.selected = YES; self.profitYearBtn.selected = NO; date = 3; } if ([[sender titleLabel].text isEqualToString:@"年"]) { self.profitDayBtn.selected = NO; self.profitWeekBtn.selected = NO; self.profitMonthBtn.selected = NO; self.profitYearBtn.selected = YES; date = 4; } switch (self.pageType) { case 1:{ SHOWLOADING [VersionDataVC getDataWithDataType:3 withDateType:date success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"利润%@",self.profitModel); REMOVESHOW [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 2:{ [VersionDataVC getDataWithStoreType:3 withDateType:date success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"库存%@",self.profitModel); REMOVESHOW [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; case 3:{ [VersionDataVC getDataWithHumanType:3 withDateType:date success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事数据离职%@",self.profitModel); REMOVESHOW [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]) }]; }break; default: break; } } #pragma mark - init +(VersionDataVC *)initVersionDataVC{ VersionDataVC *controller = [StoryboardManager.shared.verisonData instantiateViewControllerWithIdentifier:@"VersionData"]; return controller; } +(VersionDataVC *)initVersionData2VC{ VersionDataVC *controller = [StoryboardManager.shared.verisonData instantiateViewControllerWithIdentifier:@"VersionData2"]; return controller;} +(VersionDataVC *)initVersionData3VC{ VersionDataVC *controller = [StoryboardManager.shared.verisonData instantiateViewControllerWithIdentifier:@"VersionData3"]; return controller; } #pragma mark - seting UI - (void)setingUI{ self.yearMonthDaylabel.text = [ZYCTool getYearAndMonthAndDay]; [self setConrerWith:self.incomeHeader]; [self setConrerWith:self.expensesHeader]; [self setConrerWith:self.profitHeader]; self.incomeEchartsView = [self createEchartsView:self.incomeEchartsView withSuperView:self.incomeTableView]; self.expensesEchartsView = [self createEchartsView:self.expensesEchartsView withSuperView:self.expensesTableView]; self.profitEchartsView = [self createEchartsView:self.profitEchartsView withSuperView:self.profitTableView]; switch (self.pageType) { case 1:{ // 设置收入 [self.incomKeyLabel textAlignmentLeftAndRight]; [self.incomeScaleKeyLabel textAlignmentLeftAndRight]; // 设置支出 [self.expensesKeyLabel textAlignmentLeftAndRight]; [self.expensesScaleKeyLabel textAlignmentLeftAndRight]; // 设置收入 [self.profitKeyLabel textAlignmentLeftAndRight]; [self.profitScaleKeyLabel textAlignmentLeftAndRight]; }break; case 2:{ }break; case 3:{ }break; default: break; } } #pragma mark - 设置圆角 - (UIView *)setConrerWith:(UIView *)view{ view.layer.cornerRadius = 2.5; view.layer.masksToBounds = YES; view.layer.borderColor = UIColorHex(#7FE8E3).CGColor; view.layer.borderWidth = 2; return view; } - (WKEchartsView *)createEchartsView:(WKEchartsView *)echartsView withSuperView:(UIView *)superView{ echartsView = [[WKEchartsView alloc] initWithFrame:superView.bounds]; [superView addSubview:echartsView]; [echartsView addHandlerForAction:PYEchartActionClick withBlock:^(NSDictionary *params) { NSLog(@"The params from Echarts:\n%@", params); }]; NSArray *xArray = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7"]; NSArray *yArray =@[@100,@500,@180,@1200,@900,@1400,@700]; [echartsView setOption:[VersionDataVC addOptionxArray:xArray withYArray:yArray]]; [echartsView loadEcharts]; return echartsView; } #pragma mark - 根据网络数据 刷新视图 - (void)updateIncomeView:(VersionDataModel *)model{ NSMutableArray *xArray = [NSMutableArray array]; NSMutableArray *yArray = [NSMutableArray array]; for (VersionDataSub *tempModel in model.HumanAffairsChartDataResult) { [xArray addObject:[NSString stringWithFormat:@"%ld",(long)tempModel.NavigationNumber]]; [yArray addObject:@(tempModel.ResultParameter)]; } [self.incomeEchartsView setOption:[VersionDataVC addOptionxArray:xArray withYArray:yArray]]; [self.incomeEchartsView loadEcharts]; switch (self.pageType) { case 1:{ if (model.ToDayIncome == 0) { self.incomValueLabel.text = @"--"; }else{ self.incomValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ToDayIncome]; } if (model.ComparedMonthAmount == 0) { self.incomeScaleValueLabel.text = @"--"; self.incomeScaleValueImage.hidden = YES; } else if (model.ComparedMonthAmount > 0){ self.incomeScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.incomeScaleValueImage.hidden = NO; } else{ self.incomeScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.incomeScaleValueImage.hidden = YES; } }break; case 2:{ if (model.YearPressAmount == 0) { self.incomValueLabel.text = @"--"; }else{ self.incomValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.YearPressAmount]; } if (model.YearPrintCount == 0) { self.yearVersionNumberLabel.text = @"--"; }else{ self.yearVersionNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.YearPrintCount]; } if (model.YearPressAmount == 0) { self.yearPrintNuberLabel.text = @"--"; }else{ self.yearPrintNuberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.YearPressAmount]; } if (model.MonthPressAmount == 0) { self.monthPrintNumberlael.text = @"--"; }else{ self.monthPrintNumberlael.text = [NSString stringWithFormat:@"%ld",(long)model.MonthPressAmount]; } if (model.MonthPrintCount == 0) { self.monthVerionNumberLabel.text = @"--"; }else{ self.monthVerionNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.MonthPrintCount]; } if (model.ComparedMonthCount == 0) { self.monthMoneyScaleLabel.text = @"--"; self.monthPrintScaleImageView.hidden = YES; }else{ self.monthMoneyScaleLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthCount]; if (model.ComparedMonthCount > 0) { self.monthPrintScaleImageView.hidden = NO; }else{ self.monthPrintScaleImageView.hidden = YES; } } if (model.ComparedMonthAmount == 0) { self.incomeScaleValueLabel.text = @"--"; self.incomeScaleValueImage.hidden = YES; }else{ self.incomeScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; if (model.ComparedMonthAmount > 0) { self.incomeScaleValueImage.hidden = NO; }else{ self.incomeScaleValueImage.hidden = YES; } } if (model.MonthPrintAmount == 0) { self.monthVersionKindLabel.text = @"--"; }else{ self.monthVersionKindLabel.text = [NSString stringWithFormat:@"%ld",(long)model.MonthPrintAmount]; } }break; case 3:{ if(model.PersonCount == 0){ self.incomValueLabel.text = @"--"; }else{ self.incomValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.PersonCount]; } if(model.Salary == 0){ self.allPersonMoneyLabel.text = @"--"; }else{ self.allPersonMoneyLabel.text = [NSString stringWithFormat:@"%ld",(long)model.Salary]; } if(model.ComparedMonthAmount == 0){ self.allPersonScaleValueLabel.text = @"--"; self.allPersonScaleImageView.hidden = YES; }else{ self.allPersonScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; if (model.ComparedMonthAmount > 0) { self.allPersonScaleImageView.hidden = NO; }else{ self.allPersonScaleImageView.hidden = YES; } } if(model.ComparedMonthCount == 0){ self.incomeScaleValueLabel.text = @"--"; self.incomeScaleValueImage.hidden = YES; }else{ self.incomeScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.PersonCount]; if (model.ComparedMonthCount > 0) { self.incomeScaleValueImage.hidden = NO; }else{ self.incomeScaleValueImage.hidden = YES; } } }break; default: break; } } - (void)updateExpensesView:(VersionDataModel *)model{ NSMutableArray *xArray = [NSMutableArray array]; NSMutableArray *yArray = [NSMutableArray array]; for (VersionDataSub *tempModel in model.HumanAffairsChartDataResult) { [xArray addObject:[NSString stringWithFormat:@"%ld",(long)tempModel.NavigationNumber]]; [yArray addObject:@(tempModel.ResultParameter)]; } [self.expensesEchartsView setOption:[VersionDataVC addOptionxArray:xArray withYArray:yArray]]; [self.expensesEchartsView loadEcharts]; switch (self.pageType) { case 1: { if (model.ToDayIncome == 0) { self.expensesValueLabel.text = @"--";; }else{ self.expensesValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ToDayIncome]; } if (model.ComparedMonthAmount == 0) { self.expensesScaleValueLabel.text = @"--"; self.expensesScaleValueImage.hidden = YES; } else if (model.ComparedMonthAmount > 0){ self.expensesScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.expensesScaleValueImage.hidden = NO; } else{ self.expensesScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.expensesScaleValueImage.hidden = YES; } }break; case 2:{ if (model.MonthSellCount == 0) { self.expensesValueLabel.text = @"--";; }else{ self.expensesValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.MonthSellCount]; } if (model.MonthSellAmount == 0) { self.pubilshMonthLabel.text = @"--";; }else{ self.pubilshMonthLabel.text = [NSString stringWithFormat:@"%ld",(long)model.MonthSellAmount]; } if (model.ComparedMonthAmount == 0) { self.publisScaleLabel.text = @"--";; self.publisScaleImageView.hidden = YES; }else{ self.publisScaleLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; if(model.ComparedMonthAmount > 0){ self.publisScaleImageView.hidden = NO; }else{ self.publisScaleImageView.hidden = YES; } } if (model.ComparedMonthCount == 0) { self.expensesScaleValueLabel.text = @"--";; self.expensesScaleValueImage.hidden = YES; }else{ self.expensesScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; if (model.ComparedMonthCount == 0) { self.expensesScaleValueImage.hidden = NO; }else{ self.expensesScaleValueImage.hidden = YES; } } }break; case 3:{ if (model.PersonCount == 0) { self.expensesValueLabel.text = @"--";; }else{ self.expensesValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.PersonCount]; } if (model.Salary == 0) { self.addPersonMoneyLabel.text = @"--";; }else{ self.addPersonMoneyLabel.text = [NSString stringWithFormat:@"%ld",(long)model.Salary]; } if (model.ComparedMonthCount == 0) { self.expensesScaleValueLabel.text = @"--";; self.expensesScaleValueImage.hidden = YES; }else{ self.expensesScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthCount]; if (model.ComparedMonthCount > 0) { self.expensesScaleValueImage.hidden = NO; }else{ self.expensesScaleValueImage.hidden = YES; } } if (model.ComparedMonthAmount == 0) { self.addPersonScaleImageView.hidden = YES; self.addPersonScaleValueLabel.text = @"--";; }else{ self.addPersonScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; if (model.ComparedMonthAmount > 0) { self.addPersonScaleImageView.hidden = NO; }else{ self.addPersonScaleImageView.hidden = YES; } } }break; default: break; } } - (void)updateProfitView:(VersionDataModel *)model{ NSMutableArray *xArray = [NSMutableArray array]; NSMutableArray *yArray = [NSMutableArray array]; for (VersionDataSub *tempModel in model.HumanAffairsChartDataResult) { [xArray addObject:[NSString stringWithFormat:@"%ld",(long)tempModel.NavigationNumber]]; [yArray addObject:@(tempModel.ResultParameter)]; } [self.profitEchartsView setOption:[VersionDataVC addOptionxArray:xArray withYArray:yArray]]; [self.profitEchartsView loadEcharts]; switch (self.pageType) { case 1: { if (model.ToDayIncome == 0) { self.profitValueLabel.text = @"--"; }else{ self.profitValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ToDayIncome]; } if (model.ComparedMonthAmount == 0) { self.profitScaleValueLabel.text = @"--"; self.profitScaleValueImage.hidden = YES; } else if (model.ComparedMonthAmount > 0){ self.profitScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.profitScaleValueImage.hidden = NO; } else{ self.profitScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthAmount]; self.profitScaleValueImage.hidden = YES; } }break; case 2:{ if (model.StorehouseAllCount == 0) { self.profitValueLabel.text = @"--"; }else{ self.profitValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.StorehouseAllCount]; } if (model.Monthcount == 0) { self.profitScaleValueLabel.text = @"--"; self.profitScaleValueImage.hidden = YES; }else{ self.profitScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.Monthcount]; if (model.Monthcount > 0) { self.profitScaleValueImage.hidden = NO; }else{ self.profitScaleValueImage.hidden = YES; } } if (model.ComparedMonthCount == 0) { self.storeLabel.text = @"--"; self.storeScaleImageView.hidden = YES; }else{ self.storeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthCount]; if (model.ComparedMonthCount > 0) { self.storeScaleImageView.hidden = NO; }else{ self.storeScaleImageView.hidden = YES; } } }break; case 3:{ if (model.PersonCount == 0) { self.profitValueLabel.text = @"--";; }else{ self.profitValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.PersonCount]; } if (model.Salary == 0) { self.movePersonLabel.text = @"--";; }else{ self.movePersonLabel.text = [NSString stringWithFormat:@"%ld",(long)model.Salary]; } if (model.ComparedMonthCount == 0) { self.profitScaleValueLabel.text = @"--";; self.profitScaleValueImage.hidden = YES; }else{ self.profitScaleValueLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ComparedMonthCount]; if (model.ComparedMonthCount > 0) { self.profitScaleValueImage.hidden = NO; }else{ self.profitScaleValueImage.hidden = YES; } } }break; default: break; } } #pragma mark - 网络访问 - (void)getData{ SHOWLOADING switch (self.pageType) { case 1: [self getMoneyData]; break; case 2: [self getVersionData]; break; case 3: [self getHumanData]; break; default: break; } } #pragma mark - 财务数据请求网络 - (void)getMoneyData{ [VersionDataVC getDataWithDataType:1 withDateType:1 success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"收入%@",self.incomeModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithDataType:2 withDateType:1 success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"支出%@",self.expensesModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithDataType:3 withDateType:1 success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"利润%@",self.profitModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; } + (void)getDataWithDataType:(NSInteger)DataType withDateType:(NSInteger)DateType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{ [[HttpManager sharedHttpManager ] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowlistData_Post] parameters:@{@"DataType":@(DataType),@"DateType":@(DateType)} responseStyle:JOSN success:^(id _Nonnull responseObject) { successful(responseObject); } failure:^(NSError * _Nonnull error) { failure(error); }]; } #pragma mark - 出版数据请求网络 - (void)getVersionData{ [VersionDataVC getDataWithVersisonType:1 withDateType:1 success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"出版%@",self.incomeModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithPublishType:2 withDateType:1 success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"发行%@",self.expensesModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithStoreType:3 withDateType:1 success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"库存%@",self.profitModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; } // 库存 + (void)getDataWithStoreType:(NSInteger)DataType withDateType:(NSInteger)DateType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{ [[HttpManager sharedHttpManager ] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowlistData_Store_Post] parameters:@{@"DateType":@(DateType)} responseStyle:JOSN success:^(id _Nonnull responseObject) { successful(responseObject); } failure:^(NSError * _Nonnull error) { failure(error); }]; } // 发行 + (void)getDataWithPublishType:(NSInteger)DataType withDateType:(NSInteger)DateType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{ [[HttpManager sharedHttpManager ] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowlistData_Store_Post] parameters:@{@"DateType":@(DateType)} responseStyle:JOSN success:^(id _Nonnull responseObject) { successful(responseObject); } failure:^(NSError * _Nonnull error) { failure(error); }]; } // 出版 + (void)getDataWithVersisonType:(NSInteger)DataType withDateType:(NSInteger)DateType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{ [[HttpManager sharedHttpManager ] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowlistData_Version_Post] parameters:@{@"DateType":@(DateType)} responseStyle:JOSN success:^(id _Nonnull responseObject) { successful(responseObject); } failure:^(NSError * _Nonnull error) { failure(error); }]; } #pragma mark - 人事数据请求网络 - (void)getHumanData{ [VersionDataVC getDataWithHumanType:1 withDateType:1 success:^(id _Nonnull responseObject) { self.incomeModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事数据%@",self.incomeModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateIncomeView:self.incomeModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithHumanType:2 withDateType:1 success:^(id _Nonnull responseObject) { self.expensesModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事数据 入职 %@",self.expensesModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateExpensesView:self.expensesModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; [VersionDataVC getDataWithHumanType:3 withDateType:1 success:^(id _Nonnull responseObject) { self.profitModel = [[VersionDataModel alloc]initWithDictionary:responseObject error:nil]; NSLog(@"人事数据 离职%@",self.profitModel); self.netFlag += 1; if (self.netFlag == 4) { REMOVESHOW } [self updateProfitView:self.profitModel]; } failure:^(NSError * _Nonnull error) { self.netFlag += 1; if (self.netFlag == 4) { SHOWERROR([ZYCTool handerResultData:error]) } }]; } + (void)getDataWithHumanType:(NSInteger)DataType withDateType:(NSInteger)DateType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{ [[HttpManager sharedHttpManager ] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowlistData_HR_Post] parameters:@{@"DataType":@(DataType),@"DateType":@(DateType)} responseStyle:JOSN success:^(id _Nonnull responseObject) { successful(responseObject); } failure:^(NSError * _Nonnull error) { failure(error); }]; } #pragma mark - 图表样式 + (PYOption *)addOptionxArray:(NSArray *)xArray withYArray:(NSArray *)yArray{ return [PYOption initPYOptionWithBlock:^(PYOption *option) { option.titleEqual([PYTitle initPYTitleWithBlock:^(PYTitle *title) { }]) .gridEqual([PYGrid initPYGridWithBlock:^(PYGrid *grid) { grid.xEqual(@40).x2Equal(@50) .yEqual(@10) .y2Equal(@30); }]) .addXAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) { axis.typeEqual(PYAxisTypeCategory) .addDataArr(xArray) .splitLine.showEqual(NO) ; }]) .addYAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) { axis.typeEqual(PYAxisTypeValue) .axisLabelEqual([PYAxisLabel initPYAxisLabelWithBlock:^(PYAxisLabel *axisLabel) { axisLabel.formatterEqual(@"{value}"); }]) .splitLine.showEqual(YES); }]) .addSeries([PYCartesianSeries initPYCartesianSeriesWithBlock:^(PYCartesianSeries *series) { series.symbolEqual(PYSymbolNone) .typeEqual(PYSeriesTypeLine) .itemStyleEqual([PYItemStyle initPYItemStyleWithBlock:^(PYItemStyle *itemStyle) { itemStyle.normalEqual([PYItemStyleProp initPYItemStylePropWithBlock:^(PYItemStyleProp *normal) { normal.lineStyleEqual([PYLineStyle initPYLineStyleWithBlock:^(PYLineStyle *lineStyle) { lineStyle.colorEqual([PYColor colorWithHexString:@"#5576AB"]); }]); }]).emphasisEqual([PYItemStyleProp initPYItemStylePropWithBlock:^(PYItemStyleProp *emphasis) { emphasis.labelEqual([PYLabel initPYLabelWithBlock:^(PYLabel *label) { label.showEqual(YES); }]); }]); }]) .dataEqual(yArray); }]); }]; } @end