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
//
//  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 ()<UITableViewDataSource, UITableViewDelegate>
@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