zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
//  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 ()<UITableViewDataSource, UITableViewDelegate>
@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<PBExamineAddModel *> *)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