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
//
//  PBStructureViewController.m
//  IphoneBIMe
//
//  Created by ZJF on 2020/4/2.
//  Copyright © 2020 ProBIM. All rights reserved.
//
 
#import "PBStructureViewController.h"
#import "PBStructureTableViewCell.h"
#import "PBProjectModel.h"
#import "PBExamineAddModel.h"
static NSString *const cellID = @"cellID";
@interface PBStructureViewController ()<UITableViewDataSource, UITableViewDelegate, UIGestureRecognizerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataList;
@end
 
@implementation PBStructureViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
    [self setupNav];
    [self setupUI];
    [self loadData];
}
- (void)loadData {
    [YJProgressHUD showProgress:@"" inView:self.view];
    if (self.structureId == nil || [self.structureId isEqualToString:@""]) {
        self.structureId = @"";
    }
    [[PBNetworkTools sharedTools] RequestGetQualitySafeCategoriesWithOrganizeId:self.projectModel.organizeid andType:@"quality" andLikepara:self.structureId andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (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];
            self.dataList = networkModel.Data;
            [self.tableView reloadData];
            if (self.dataList.count == 0) {
                [YJProgressHUD showMessage:@"暂无内容,请返回上级选择" inView:self.view];
            }
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];
}
- (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;
//    UIBarButtonItem *saveNavItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction)];
//    self.navigationItem.rightBarButtonItem = saveNavItem;
}
//- (void) saveAction{
//
//}
- (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:[PBStructureTableViewCell class] forCellReuseIdentifier:cellID];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(24);
        make.left.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;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PBStructureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
    NSDictionary *dict = self.dataList[indexPath.row];
    cell.dict = dict;
    cell.NextLevelBlock = ^{
        PBStructureViewController *vc = [[PBStructureViewController alloc] init];
        vc.projectModel = self.projectModel;
        vc.examineAddModel = self.examineAddModel;
        vc.structureId = [dict valueForKey:@"ec_code"];
        [self.navigationController pushViewController:vc animated:YES];
    };
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dict = self.dataList[indexPath.row];
    PBStructureViewController *vc = [[PBStructureViewController alloc] init];
    vc.projectModel = self.projectModel;
    vc.examineAddModel = self.examineAddModel;
    vc.structureId = [dict valueForKey:@"ec_code"];
    [self.navigationController pushViewController:vc animated:YES];
}
 
- (void)setStructureId:(NSString *)structureId {
    _structureId = structureId;
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
- (void)setExamineAddModel:(PBExamineAddModel *)examineAddModel {
    _examineAddModel = examineAddModel;
}
/*
#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