// // PBSchedulePlanViewController.m // IphoneBIMe // // Created by ZhangJF on 2022/8/22. // Copyright © 2022 ProBIM. All rights reserved. // #import "PBSchedulePlanViewController.h" #import "PBSchedulePlanTableViewCell.h" #import "PBProjectModel.h" #import "PBSchedulePlanModel.h" #import "PBScheduleModuleViewController.h" static NSString *const CellID = @"CellID"; @interface PBSchedulePlanViewController () @property (nonatomic, strong) NSMutableArray *dataListM; @property (nonatomic, strong) UITableView *tableView; @end @implementation PBSchedulePlanViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) { self.edgesForExtendedLayout = UIRectEdgeNone; self.navigationController.interactivePopGestureRecognizer.enabled = NO; //让rootView禁止滑动 } } - (void)viewDidLoad { [super viewDidLoad]; [self setupUI]; [self loadData]; [self setupNav]; } - (void)setupNav { self.title = @"选择一个进度计划"; PBBackNavItem *backNav = [PBBackNavItem backNacItem]; backNav.title = @"取消"; [backNav addTarget:self action:@selector(backItemAction) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithCustomView:backNav]; self.navigationItem.leftBarButtonItem = backNavItem; } - (void)backItemAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)loadData { // 加载进度计划列表 [YJProgressHUD showProgress:@"" inView:self.view]; [[PBNetworkTools sharedTools] GetSchedualTreeWithOrganizeId:self.projectModel.bimcomposerid andUid:@"" andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) { if (error) { NSLog(@"%@",error); [YJProgressHUD showMessage:@"加载失败" inView:self.view]; return; } NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str]; if (networkModel.Ret == 1) { [YJProgressHUD hide]; for (NSDictionary *obj in networkModel.Data) { PBSchedulePlanModel *model = [PBSchedulePlanModel yy_modelWithDictionary:obj]; [self.dataListM addObject:model]; } [self.tableView reloadData]; }else { [YJProgressHUD showMessage:networkModel.Msg inView:self.view]; } }]; } - (void)setupUI { self.view.backgroundColor = [UIColor z_colorWithR:243 G:243 B:244]; self.tableView = [[UITableView alloc] init]; self.tableView.backgroundColor = PBColor(243, 243, 244); self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.rowHeight = 72.f; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[PBSchedulePlanTableViewCell class] forCellReuseIdentifier:CellID]; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.equalTo(self.view); }]; } #pragma mark - Table view data source - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataListM.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PBSchedulePlanTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath]; cell.planModel = self.dataListM[indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { PBSchedulePlanModel *planModel = self.dataListM[indexPath.row]; PBScheduleModuleViewController *moduleVC = [[PBScheduleModuleViewController alloc] init]; moduleVC.isAdd = YES; moduleVC.schedulePlanModel = planModel; moduleVC.projectModel = self.projectModel; [self.navigationController pushViewController:moduleVC animated:YES]; } - (void)setProjectModel:(PBProjectModel *)projectModel { _projectModel = projectModel; } - (NSMutableArray *)dataListM { if (_dataListM == nil) { _dataListM = [[NSMutableArray alloc] init]; } return _dataListM; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end