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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//
//  PBScheduleModuleViewController.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2022/8/23.
//  Copyright © 2022 ProBIM. All rights reserved.
//
 
#import "PBScheduleModuleViewController.h"
#import "PBProjectModel.h"
#import "PBSchedulePlanModel.h"
#import "PBModuleTableViewCell.h"
#import "PBTaskScheduleViewController.h"
#import "PBSitePerViewController.h"
#import "PBSiteMechanicalViewController.h"
#import "PBSiteMaterialViewController.h"
#import "PBSafetyViewController.h"
#import "PBSuperviseViewController.h"
#import "PBScheduleListModel.h"
#import "PBPreScheduleViewController.h"
 
static NSString *const CellID = @"CellID";
@interface PBScheduleModuleViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *dataList;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSDictionary *completeState;
@property (nonatomic, weak) UIButton *previewBtn;
@end
 
@implementation PBScheduleModuleViewController
 
- (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.completeState = @{
        @"Progress_MobileState": @"未提交",
        @"MobileUserDetial_state": @"未提交",
        @"MaterialsDetial_state": @"未提交",
        @"MachineDetial_State": @"未提交",
        @"MobileSafe_state": @"未提交",
        @"MobileSupervise_state": @"未提交"
    };
    if (self.isAdd) {
        [self loadData];
    }else {
        [self loadData];
        [self loadStatus];
    }
    [self setupUI];
    [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 {
    self.dataList = @[ @{@"key": @"schedule", @"icon": @"schedule", @"name": @"任务进度", @"completeKey": @"Progress_MobileState", @"complete": @"未提交"},
//                       @{@"key": @"personnel", @"icon": @"personnel", @"name": @"现场人员", @"completeKey": @"MobileUserDetial_state", @"complete": @"未提交"},
//                       @{@"key": @"mechanical", @"icon": @"mechanical", @"name": @"现场机械", @"completeKey": @"MaterialsDetial_state", @"complete": @"未提交"},
//                       @{@"key": @"Material", @"icon": @"Material", @"name": @"现场材料", @"completeKey": @"MachineDetial_State", @"complete": @"未提交"},
//                       @{@"key": @"safety", @"icon": @"safety", @"name": @"质量安全", @"completeKey": @"MobileSafe_state", @"complete": @"未提交"},
//                       @{@"key": @"supervise", @"icon": @"supervise", @"name": @"督导会", @"completeKey": @"MobileSupervise_state", @"complete": @"未提交"},
                     ];
}
- (void)loadStatus {
    [[PBNetworkTools sharedTools] GetSearchstateWithPlanId:self.scheduleListModel.MobilePA_ProjectID andUnittime:self.scheduleListModel.MobilePA_Unittime andCreateuserid:self.scheduleListModel.MobilePA_Createuserid 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) {
            self.completeState = networkModel.Data;
            [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 = 88.f;
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[PBModuleTableViewCell class] forCellReuseIdentifier:CellID];
    [self.view addSubview:self.tableView];
    CGFloat bottomH = 64.f;
    if (IS_IPHONE_X) {
        bottomH = 64.f + IPHONE_X_BOTTOM;
    }
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-bottomH);
    }];
//    UIButton *previewBtn = [[UIButton alloc] init];
//    [previewBtn setImage:[UIImage imageNamed:@"preview_dis"] forState:UIControlStateDisabled];
//    [previewBtn setImage:[UIImage imageNamed:@"preview"] forState:UIControlStateNormal];
//    [previewBtn addTarget:self action:@selector(previewAction) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:previewBtn];
//    [previewBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.tableView.mas_bottom).offset(7);
//        make.left.equalTo(self.view).offset(10);
//        make.right.equalTo(self.view).offset(-10);
//        make.height.equalTo(@48);
//    }];
//    if (self.isAdd) {
//        previewBtn.enabled = NO;
//    }else {
//        previewBtn.enabled = YES;
//    }
//    self.previewBtn = previewBtn;
}
- (void)previewAction {
    PBPreScheduleViewController * preVC = [[PBPreScheduleViewController alloc] init];
    preVC.projectModel = self.projectModel;
    preVC.scheduleListModel = self.scheduleListModel;
    [self.navigationController pushViewController:preVC animated:YES];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataList.count;
}
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PBModuleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
    NSDictionary *dict = self.dataList[indexPath.row];
    NSMutableDictionary *dictM = dict.mutableCopy;
    NSString *iscomplete = [self.completeState valueForKey:[dict valueForKey:@"completeKey"]];
    [dictM setValue:iscomplete forKey:@"complete"];
    cell.dict = dictM.copy;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dict = self.dataList[indexPath.row];
    NSString *type = [dict valueForKey:@"key"];
    if ([type isEqualToString:@"schedule"]) { // 任务进度
        PBTaskScheduleViewController *moduleVC = [[PBTaskScheduleViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
            if (self.isAdd) {
                self.isAdd = false;
                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
            }
            [self loadStatus];
        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    } else if ([type isEqualToString:@"personnel"]) { // 现场人员
        PBSitePerViewController *moduleVC = [[PBSitePerViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
//        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
//            if (self.isAdd) {
//                self.isAdd = false;
//                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
//            }
//            [self loadStatus];
//        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    } else if ([type isEqualToString:@"mechanical"]) { // 现场机械
        PBSiteMechanicalViewController *moduleVC = [[PBSiteMechanicalViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
            if (self.isAdd) {
                self.isAdd = false;
                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
            }
            [self loadStatus];
        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    } else if ([type isEqualToString:@"Material"]) { // 现场材料
        PBSiteMaterialViewController *moduleVC = [[PBSiteMaterialViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
            if (self.isAdd) {
                self.isAdd = false;
                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
            }
            [self loadStatus];
        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    } else if ([type isEqualToString:@"safety"]) { // 质量安全
        PBSafetyViewController *moduleVC = [[PBSafetyViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
            if (self.isAdd) {
                self.isAdd = false;
                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
            }
            [self loadStatus];
        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    } else if ([type isEqualToString:@"supervise"]) { // 督导会
        PBSuperviseViewController *moduleVC = [[PBSuperviseViewController alloc] init];
        moduleVC.projectModel = self.projectModel;
        if (self.isAdd) {
            moduleVC.schedulePlanModel = self.schedulePlanModel;
        }else {
            moduleVC.scheduleListModel = self.scheduleListModel;
        }
        moduleVC.AddSuccessBlock = ^(PBScheduleListModel * _Nonnull listModel) {
            if (self.isAdd) {
                self.isAdd = false;
                self.scheduleListModel = listModel;
//                self.previewBtn.enabled = YES;
            }
            [self loadStatus];
        };
        [self.navigationController pushViewController:moduleVC animated:YES];
    }
}
- (void)setScheduleModel:(PBSchedulePlanModel *)schedulePlanModel {
    _schedulePlanModel = schedulePlanModel;
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
- (void)setScheduleListModel:(PBScheduleListModel *)scheduleListModel {
    _scheduleListModel = scheduleListModel;
}
- (void)setIsAdd:(BOOL)isAdd {
    _isAdd = isAdd;
}
 
/*
#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