123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- //
- // CommonToolVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/4/28.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "CommonToolVC.h"
- #import "WorkFLowModel.h"
- #import "WorkFLowCell.h"
- #import "myApprovalPageVC.h"
- #import "WorkFlowTabbarController.h"
- #import "MyWorkWordVC.h"
- #import "CountDataVC.h"
- #import "CommonToolMoveVC.h"
- @interface CommonToolVC ()<UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
- @property (weak, nonatomic) IBOutlet UIButton *setBtn;
- @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
- /// 协同工作
- @property (nonatomic, strong) NSMutableArray<WorkFLowModel*> *cooperativeWorkArray;
- /// 数据报表
- @property (nonatomic, strong) NSMutableArray <WorkFLowModel*>*dataReportArray;
- @property (nonatomic, strong) WorkNumberModel *numberDic;
- @property (nonatomic,assign) NSInteger loadFlag;
- @end
- @implementation CommonToolVC
- +(CommonToolVC *)initCommonToolVC{
- CommonToolVC *controller = [StoryboardManager.shared.Common instantiateViewControllerWithIdentifier:@"CommonToolVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- [self.view setBackgroundColor:UIColorHex(0xf7f7f7)];
- [self createCollectionView];
- WS(weakSelf);
- [self.setBtn setAction:^{
- CommonToolMoveVC * vc = [CommonToolMoveVC initCommonToolMoveVC];
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [self.collectionView reloadData];
- }
- #pragma mark - 数据加载
- - (void)getData{
- [self.cooperativeWorkArray removeAllObjects];
- [self.dataReportArray removeAllObjects];
- // [self testData];
- self.loadFlag = 1;
- [[HttpManager sharedHttpManager] GETUrl: [NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData_Post]parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSArray *array = responseObject;
- NSMutableArray *arr = [NSMutableArray array];
- for (NSDictionary *dic in array) {
- WorkFLowModel *mode = [[WorkFLowModel alloc] initWithDictionary:dic error:nil];
- [self.cooperativeWorkArray addObject:mode];
- }
- [self.cooperativeWorkArray addObjectsFromArray:arr];
- self.loadFlag += 1;
- if (self.loadFlag == 3) {
- REMOVESHOW
- [self.collectionView reloadData];
- }
- } failure:^(NSError * _Nonnull error) {
- }];
-
- //获取我审批和我发起以及抄送我的未读数
- // [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/user/user-uread-count"] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- // NSDictionary *dic = responseObject;
- // self.numberDic = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
- // self.navigationController.tabBarItem.badgeValue = [self.numberDic allNumber];
- // /// 我的审批未读数
- // self.cooperativeWorkArray.firstObject.workNumber = [dic[@"FlowAuditUReadCount"] integerValue];
- // for (WorkFLowModel *model in self.cooperativeWorkArray) {
- // if ([model.Name isEqualToString:@"我发起的"]) {
- // model.workNumber = [dic[@"FlowSendUReadCount"] integerValue];
- // }
- // if ([model.Name isEqualToString:@"抄送我的"]) {
- // model.workNumber = [dic[@"FlowCcUReadCount"] integerValue];
- // }
- // }
- // self.loadFlag += 1;
- // if (self.loadFlag == 4) {
- // REMOVESHOW
- // [self.collectionView reloadData];
- // }
- // } failure:^(NSError * _Nonnull error) {
- // }];
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData2_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSArray *array = responseObject;
- NSLog(@"%@",responseObject);
- for (NSDictionary *dic in array) {
- WorkFLowModel *mode = [[WorkFLowModel alloc]initWithDictionary:dic error:nil];
- [self.dataReportArray addObject:mode];
- }
- self.loadFlag += 1;
- if (self.loadFlag == 3) {
- REMOVESHOW
- [self.collectionView reloadData];
- }
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- - (void)testData{
- WorkFLowModel *mode1 = [[WorkFLowModel alloc] init];
- mode1.Name = @"我的审批";
- mode1.iconImage = IMG(@"work_flow_approvalme");
- mode1.workNumber = 0;
- [self.cooperativeWorkArray addObject:mode1];
-
- WorkFLowModel *mode2 = [[WorkFLowModel alloc] init];
- mode2.Name = @"我发起的";
- mode2.iconImage = IMG(@"work_flow_fromme");
- mode2.workNumber = 0;
- [self.cooperativeWorkArray addObject:mode2];
-
- WorkFLowModel *mode3 = [[WorkFLowModel alloc] init];
- mode3.Name = @"抄送我的";
- mode3.iconImage = IMG(@"work_flow_forme");
- mode3.workNumber = 0;
- [self.cooperativeWorkArray addObject:mode3];
-
-
-
-
- //
- // WorkFLowModel *mode13 = [[WorkFLowModel alloc] init];
- // mode13.Name = @"财务数据";
- // mode13.iconImage = IMG(@"work_flow_money_data");
- // mode13.workNumber = 0;
- // [self.dataReportArray addObject:mode13];
- //
- // WorkFLowModel *mode14 = [[WorkFLowModel alloc] init];
- // mode14.Name = @"出版数据";
- // mode14.iconImage = IMG(@"work_flow_version_data");
- // mode14.workNumber = 0;
- // [self.dataReportArray addObject:mode14];
- //
- // WorkFLowModel *mode15 = [[WorkFLowModel alloc] init];
- // mode15.Name = @"人事数据";
- // mode15.iconImage = IMG(@"work_flow_hr_data");
- // mode15.workNumber = 0;
- // [self.dataReportArray addObject:mode15];
-
-
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- return 15;
- }
- //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
- // return CGSizeMake(kGXScreenWidth-14, 39);
- //}
- //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
- // return CGSizeMake(kGXScreenWidth-14, 20);
- //}
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
- return CGSizeMake((kGXScreenWidth -14)/3 ,(kGXScreenWidth -14)/3);
- }
- -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(0, 0, 0, 0);
- }
- //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
- // return UIEdgeInsetsZero
- //}
- //
- // func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
- // return 1
- //}
- //
- //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
- // return 5
- //}
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- WorkFLowCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WorkFLowCellID" forIndexPath:indexPath];
- // WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
- // if (model.workNumber > 0) {
- // NSString * count = [NSString stringWithFormat:@"%ld",(long)model.workNumber];
- // UILabel * label = [UILabel new];
- // label.font = [UIFont systemFontOfSize:12];
- // label.text = count;
- // CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
- // cell.workNumberLab.layer.cornerRadius = 8;
- // cell.workNumberLab.layer.masksToBounds = YES;
- // if ((width + 5) < 16) {
- // cell.width.constant = 16;
- // }else{
- // cell.width.constant = width + 8;
- // }
- // cell.workNumberLab.text = count;
- // }
- // if (model.workNumber == 0 ) {
- // cell.workNumberLab.hidden = YES;
- // cell.workNumberLab.layer.cornerRadius = 10;
- // cell.workNumberLab.layer.masksToBounds = YES;
- // }else{
- // cell.workNumberLab.hidden = NO;
- // }
- cell.workNumberLab.hidden = YES;
- cell.titleLabel.text = [NSString stringWithFormat:@"工具%ld",indexPath.row + 1];
- cell.iconImageView.image = IMG(@"img_placeHolder");
- cell.leftLine.hidden = NO;
- cell.rightLine.hidden = NO;
- cell.bottomLine.hidden= NO;
- cell.topLine.hidden = NO;
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- [collectionView deselectItemAtIndexPath:indexPath animated:YES];
- // WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
- // if (indexPath.section == 0) {
- // // if (indexPath.item == 0 || indexPath.item == 1 || indexPath.item == 2) {
- // // MyApprovalPageVC *myApprovalPageVC = [[MyApprovalPageVC alloc]init];
- // // myApprovalPageVC.title = model.Name;
- // // if (indexPath.item == 0) {
- // // myApprovalPageVC.pageType = Type_ONEA;
- // // }
- // // if (indexPath.item == 1) {
- // // myApprovalPageVC.pageType = Type_ONEB;
- // // }
- // // if (indexPath.item == 2) {
- // // myApprovalPageVC.pageType = Type_ONEC;
- // // }
- // // myApprovalPageVC.numberDic = self.numberDic;
- // // [self.navigationController pushViewController:myApprovalPageVC animated:YES];
- // // }else{
- // // if ([model.Name isEqualToString:@"会议"]) {
- // // [self.navigationController pushViewController:[[WorkFlowTabbarController alloc] init] animated:YES];
- // // } else {
- // // MyWorkWordVC *workWordVC = [[MyWorkWordVC alloc]init];
- // // workWordVC.title = model.Name;
- // // workWordVC.pageType = Type_GongWen;
- // // workWordVC.indexID = model.Id;
- // // [self.navigationController pushViewController:workWordVC animated:YES];
- // // }
- // // }
- // if ([model.Name isEqualToString:@"会议"]) {
- // [self.navigationController pushViewController:[[WorkFlowTabbarController alloc] init] animated:YES];
- // } else {
- // MyWorkWordVC *workWordVC = [[MyWorkWordVC alloc]init];
- // workWordVC.title = model.Name;
- // workWordVC.pageType = Type_GongWen;
- // workWordVC.indexID = model.Id;
- // [self.navigationController pushViewController:workWordVC animated:YES];
- // }
- // }
- // if (indexPath.section == 1) {
- // WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
- // if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
- // CountDataVC *vc = [CountDataVC initCountDataVC];
- // vc.index = 0;
- // vc.titleStr = @"财务统计";
- // [self.navigationController pushViewController:vc animated:YES];
- // }
- // if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
- // CountDataVC *vc = [CountDataVC initCountDataVC];
- // vc.index = 1;
- // vc.titleStr = @"人事统计";
- // [self.navigationController pushViewController:vc animated:YES];
- // }
- // if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
- // CountDataVC *vc = [CountDataVC initCountDataVC];
- // vc.index = 2;
- // vc.titleStr = @"出版统计";
- // [self.navigationController pushViewController:vc animated:YES];
- // }
- //// WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
- //// if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
- //// VersionDataVC *vc = [VersionDataVC initVersionDataVC];
- //// vc.pageType = 1;
- //// [self.navigationController pushViewController:vc animated:YES];
- //// }
- //// if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
- //// VersionDataVC *vc = [VersionDataVC initVersionData3VC];
- //// vc.pageType = 3;
- //// [self.navigationController pushViewController:vc animated:YES];
- //// }
- //// if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
- //// VersionDataVC *vc = [VersionDataVC initVersionData2VC];
- //// vc.pageType = 2;
- //// [self.navigationController pushViewController:vc animated:YES];
- //// }
- // }
- }
- #pragma mark - Setter
- - (NSMutableArray<WorkFLowModel*> *)cooperativeWorkArray{
- if (!_cooperativeWorkArray) {
- _cooperativeWorkArray = [NSMutableArray new];
- }
- return _cooperativeWorkArray;
- }
- - (NSMutableArray<WorkFLowModel *> *)dataReportArray{
- if (!_dataReportArray) {
- _dataReportArray = [NSMutableArray new];
- }
- return _dataReportArray;
- }
- - (void)createCollectionView {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.minimumLineSpacing = 0;
- layout.minimumInteritemSpacing = 0;
- [self.collectionView setCollectionViewLayout:layout];
- self.collectionView.dataSource = self;
- self.collectionView.delegate = self;
- self.collectionView.layer.cornerRadius = 2;
- self.collectionView.layer.masksToBounds = YES;
- self.collectionView.backgroundColor = UIColorHex(F7F7F7);
- [self.collectionView registerNib:[UINib nibWithNibName:@"WorkFLowCell" bundle:nil] forCellWithReuseIdentifier:@"WorkFLowCellID"];
- [self.collectionView registerNib:[UINib nibWithNibName:@"MyChanelCollectionReusableViewTop" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyChanelCollectionReusableViewTop"];
- [self.collectionView registerNib:[UINib nibWithNibName:@"FootCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FootCollectionReusableView"];
- self.collectionView.backgroundColor = [UIColor whiteColor];
- [self.collectionView setShowsVerticalScrollIndicator:NO];
- [self.collectionView setShowsHorizontalScrollIndicator:NO];
- [self.view addSubview:self.collectionView];
-
- self.collectionView.backgroundColor = UIColorHex(F7F7F7);
-
- }
- @end
|