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
//
//  PBScheduleListViewController.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2022/8/18.
//  Copyright © 2022 ProBIM. All rights reserved.
//
 
#import "PBScheduleListViewController.h"
#import "PBDropdownMenu.h"
#import "PBIssueSearchController.h"
#import "PBNavigationController.h"
#import "PBSchedulePlanViewController.h"
#import "PBProjectPower.h"
#import "PBSchedulePlanModel.h"
#define IssueModuleName @"IssueTracking"
 
@interface PBScheduleListViewController ()<PBDropdownMenuDelegate>
@property (nonatomic, strong) NSArray *archiveArr;
@property (nonatomic, strong) NSArray *statusArr;
@end
 
@implementation PBScheduleListViewController
 
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    [self.tableView.mj_header beginRefreshing];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
//    for (PBProjectPower *power in self.powerArr) {
//        if ([power.Bm_EnCode isEqualToString:IssueModuleName]) {
//            if ([power.checkstate isEqualToString:@"1"]) {
//                //有权限
//                self.promptView.hidden = YES;
                [self loadTypeAndStatus];
                [self.tableView.mj_header beginRefreshing];
//                for (NSDictionary *obj in power.Bmbs) {
//                    if ([[obj valueForKey:@"Bmb_FullName"] isEqualToString:@"新增问题"]) {
//                        if ([[obj valueForKey:@"checkstate"] isEqualToString:@"1"]) {
//                            self.navigationItem.rightBarButtonItem.enabled = YES;
//                        }
//                    }
//                }
//                return;
//            }else {
//                //无权限
//                self.promptView.textL.text = @"暂无权限";
//                self.promptView.hidden = NO;
//                return;
//            }
//        }
//    }
//    //无权限
//    self.promptView.textL.text = @"暂无权限";
//    self.promptView.hidden = NO;
}
#pragma mark - PBDropdownMenuDelegate
- (void)dropdownMenu:(UIButton *)clickBtn selectedCellNumber:(NSInteger)number {
    NSInteger index = clickBtn.tag -100;
    switch (index) {
        case 0:
            self.statusSelectIndex = number;
            [self.tableView.mj_header beginRefreshing];
            break;
        case 1:
            self.archiveSelectIndex = number;
            [self.tableView.mj_header beginRefreshing];
            break;
        default:
            break;
    }
}
 
- (void)loadTypeAndStatus {
    [[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];
            NSMutableArray *planArrM = [[NSMutableArray alloc] init];
            for (NSDictionary *obj in networkModel.Data) {
                PBSchedulePlanModel *model = [PBSchedulePlanModel yy_modelWithDictionary:obj];
                PBIssueNavModel *navModel = [[PBIssueNavModel alloc] init];
                navModel.ItemName = model.Name;
                navModel.ItemDetailId = model.UID;
                [planArrM addObject:navModel];
            }
            PBIssueNavModel *typeNavModel = [[PBIssueNavModel alloc] init];
            typeNavModel.ItemDetailId = @"";
            typeNavModel.ItemName = @"全部计划";
            [planArrM insertObject:typeNavModel atIndex:0];
            self.archiveArr = planArrM.copy;
//            [self.dropdownMenuArrM addObject:self.statusArr];
            [self.dropdownMenuArrM addObject:self.archiveArr];
            [self setupDropdownMenuView];
            [self.tableView.mj_header beginRefreshing];
 
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];
  
}
- (void)setupDropdownMenuView {
    float dropdownMenuW = MainScreenWidth / self.dropdownMenuArrM.count;
    PBDropdownMenu *dropdownMenu = [[PBDropdownMenu alloc] initWithFrame:CGRectMake(0, 0, self.dropdownMenuArrM.count * dropdownMenuW, 40) andArr:self.dropdownMenuArrM];
    dropdownMenu.delegate = self;
    [self.view addSubview:dropdownMenu];
}
 
- (void)setupNav {
    self.title = self.projectModel.fullname;
    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 *addIssueItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Issue_list_add"] style:UIBarButtonItemStylePlain target:self action:@selector(addSchedule)];
    self.navigationItem.rightBarButtonItem = addIssueItem;
}
- (void)addSchedule {
    PBSchedulePlanViewController *schedulePlanVC = [[PBSchedulePlanViewController alloc] init];
    schedulePlanVC.projectModel = self.projectModel;
    schedulePlanVC.SaveSuccessBlock = ^{
        [self.tableView.mj_header beginRefreshing];
    };
    [self.navigationController pushViewController:schedulePlanVC animated:YES];
}
- (void)backItemAction {
//    [PBNoteCenter postNotificationName: PBNoteCenterDismissTabBarController object:nil];
    [self.navigationController popViewControllerAnimated:YES];
}
 
- (NSArray *)archiveArr {
    if (_archiveArr == nil) {
        PBIssueNavModel *issueNavModel = [[PBIssueNavModel alloc] init];
        issueNavModel.ItemDetailId = @"";
        issueNavModel.ItemName = @"计划";
        _archiveArr = @[issueNavModel];
    }
    return _archiveArr;
}
- (NSArray *)statusArr {
    if (_statusArr == nil) {
        PBIssueNavModel *issueNavModel = [[PBIssueNavModel alloc] init];
        issueNavModel.ItemDetailId = @"";
        issueNavModel.ItemName = @"全部状态";
        
        PBIssueNavModel *issueNavModel1 = [[PBIssueNavModel alloc] init];
        issueNavModel1.ItemDetailId = @"待提交";
        issueNavModel1.ItemName = @"待提交";
        
        PBIssueNavModel *issueNavModel2 = [[PBIssueNavModel alloc] init];
        issueNavModel2.ItemDetailId = @"待审核";
        issueNavModel2.ItemName = @"待审核";
        
        PBIssueNavModel *issueNavModel3 = [[PBIssueNavModel alloc] init];
        issueNavModel3.ItemDetailId = @"驳回待提交";
        issueNavModel3.ItemName = @"驳回待提交";
        
        PBIssueNavModel *issueNavModel4 = [[PBIssueNavModel alloc] init];
        issueNavModel4.ItemDetailId = @"已审核";
        issueNavModel4.ItemName = @"已审核";
 
        _statusArr = @[issueNavModel, issueNavModel1, issueNavModel2, issueNavModel3, issueNavModel4];
    }
    return _statusArr;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#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