// // PBTestViewController.m // IphoneBIMe // // Created by zjf on 2018/12/24. // Copyright © 2018 ProBIM. All rights reserved. // #import "PBTestViewController.h" #import "PBExamineAddModel.h" static NSString *const cellID = @"cellID"; @interface PBTestViewController () @property (nonatomic, strong) UITableView *tableView; @end @implementation PBTestViewController - (void)viewDidLoad { [super viewDidLoad]; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) { self.edgesForExtendedLayout = UIRectEdgeNone; } [self setupNav]; [self setupUI]; } - (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)setupUI { UILabel *titleL = [UILabel z_labelWithText:@"请选择检验批" Color:DescColor isBold:NO Font:12]; titleL.backgroundColor = PBColor(242, 242, 242); [self.view addSubview:titleL]; [titleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.right.equalTo(self.view); make.left.equalTo(self.view).offset(16); make.height.equalTo(@24); }]; self.view.backgroundColor = [UIColor whiteColor]; self.tableView = [[UITableView alloc] init]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.rowHeight = 42; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID]; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view).offset(24); make.right.bottom.equalTo(self.view); make.left.equalTo(self.view).offset(16); }]; } #pragma mark - UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _dataList.count + 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath]; if (indexPath.row == 0) { cell.textLabel.text = @"无检验批"; }else { NSDictionary *dict = self.dataList[indexPath.row - 1]; cell.textLabel.text = [dict valueForKey:@"name"]; } return cell; } #pragma mark - UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { [self setupData]; }else { self.examineArr[0].dataDict = self.divisionDict; self.examineArr[1].dataDict = self.itemizedDict; self.examineArr[2].dataDict = self.dataList[indexPath.row - 1]; } [PBNoteCenter postNotificationName:PBNoteCenterUpdateDivision object:nil]; [self.navigationController popToRootViewControllerAnimated:YES]; } - (void)setupData { NSDictionary *dict2 = @{ @"name" : @"<无检验批>", @"value" : @"", @"children" : @[] }; self.examineArr[0].dataDict = self.divisionDict; self.examineArr[1].dataDict = self.itemizedDict; self.examineArr[2].dataDict = dict2; } - (void)setDataList:(NSArray *)dataList { _dataList = dataList; } - (void)setExamineArr:(NSArray *)examineArr { _examineArr = examineArr; } - (void)setDivisionDict:(NSDictionary *)divisionDict { _divisionDict = divisionDict; } - (void)setItemizedDict:(NSDictionary *)itemizedDict { _itemizedDict = itemizedDict; } /* #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