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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
//  PBRoleViewController.m
//  IphoneBIMe
//
//  Created by zjf on 2021/1/6.
//  Copyright © 2021 ProBIM. All rights reserved.
//
 
#import "PBRoleViewController.h"
#import "PBProjectModel.h"
#import "PBPersonRoleTableViewCell.h"
#import "PBRolePersonViewController.h"
static NSString *const CellID = @"CellID";
@interface PBRoleViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataList;
@end
 
@implementation PBRoleViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    [self setupUI];
    [self loadData];
}
- (void)setupNav {
    self.title = @"请指定人员";
    UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Doc_preview_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backItemAction)];
    self.navigationItem.leftBarButtonItem = backNavItem;
}
- (void)backItemAction {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)setupUI {
    self.view.backgroundColor = PBColor(244, 245, 246);
    self.tableView = [[UITableView alloc] init];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.bounces = NO;
    self.tableView.rowHeight = 56;
    UITableView *footerV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    if (@available(iOS 15.0, *)) {
        footerV.sectionHeaderTopPadding = 0;
    };
    self.tableView.tableFooterView = footerV;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[PBPersonRoleTableViewCell class] forCellReuseIdentifier:CellID];
    [self.view addSubview:self.tableView];
    CGFloat bottomH = 0.f;
    if (IS_IPHONE_X) {
        bottomH = 0.f + IPHONE_X_BOTTOM;
    }
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-(bottomH));
    }];
//    self.tableView.tableHeaderView = [self setupTableHearderView];
}
- (UIView *)setupTableHearderView {
    UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 52)];
    bgV.backgroundColor = PBColor(244, 245, 246);
    UIButton *searchBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"Examine_search_background"]];
    [searchBtn addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside];
    [bgV addSubview:searchBtn];
    [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgV).offset(8);
        make.left.equalTo(bgV).offset(10);
        make.right.equalTo(bgV).offset(-10);
        make.height.equalTo(@36);
    }];
    return bgV;
}
- (void)searchAction {
    
    
}
- (void)loadData {
    [YJProgressHUD showProgress:@"" inView:self.view];
    [[PBNetworkTools sharedTools] GetProjectRolesAndUsersOrganizeID:self.projectModel.organizeid andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showMessage:@"加载失败" inView:self.view];
            NSLog(@"%@",error);
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"%@",str);
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
            [YJProgressHUD hide];
            self.dataList = [networkModel.Data valueForKey:@"List"];
            [self.tableView reloadData];
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];  
}
#pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PBPersonRoleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSDictionary *dict = self.dataList[indexPath.row];
    cell.roleDict = dict;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dict = self.dataList[indexPath.row];
    NSString *roleId = [dict valueForKey:@"RoleId"];
    PBRolePersonViewController *personListVC = [[PBRolePersonViewController alloc] init];
    personListVC.roleID = roleId;
    personListVC.projectModel = self.projectModel;
    personListVC.isMultiSelect = self.isMultiSelect;
    personListVC.selectList = self.selectList;
    [self.navigationController pushViewController:personListVC animated:YES]; 
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
- (void)setIsMultiSelect:(BOOL)isMultiSelect {
    _isMultiSelect = isMultiSelect;
}
- (void)setSelectList:(NSMutableArray *)selectList {
    _selectList = selectList;
}
/*
#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