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
//
//  PBDocListController.m
//  IphoneBIMe
//
//  Created by zjf on 2018/8/1.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBDocListController.h"
#import "PBDocModel.h"
#import "PBDocSearchController.h"
#import "PBNavigationController.h"
#import "PBProjectPower.h"
#define DocModuleName @"Document"
@interface PBDocListController ()<UIGestureRecognizerDelegate>
 
@end
 
@implementation PBDocListController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
       self.edgesForExtendedLayout = UIRectEdgeNone;
       self.navigationController.interactivePopGestureRecognizer.enabled = YES;
       self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
    if (!_isOther) {
       [self setupNav];
//        for (PBProjectPower *power in self.powerArr) {
//            if ([power.Bm_EnCode isEqualToString:DocModuleName]) {
//                if ([power.checkstate isEqualToString:@"1"]) {
                    //有权限
                    self.promptView.hidden = YES;
                    [self loadDocList];
//                    return;
//                }else {
//                    //无权限
//                    self.navigationItem.rightBarButtonItem.enabled = NO;
//                    self.promptView.textL.text = @"暂无权限";
//                    self.promptView.hidden = NO;
//                    return;
//                }
//            }
//        }
//        //无权限
//        self.navigationItem.rightBarButtonItem.enabled = NO;
//        self.promptView.textL.text = @"暂无权限";
//        self.promptView.hidden = NO;
    }else {
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Project_nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    }
    
}
- (void)setupNav {
    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 *searchItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Doc_list_searchItem"] style:UIBarButtonItemStylePlain target:self action:@selector(searchBarAction)];
    self.navigationItem.rightBarButtonItem = searchItem;
}
- (void)searchBarAction {
    PBDocSearchController *docSearchVC = [[PBDocSearchController alloc] init];
    docSearchVC.projectModel = self.projectModel;
    PBNavigationController *navigationController = [[PBNavigationController alloc] initWithRootViewController:docSearchVC];
    [self.navigationController presentViewController:navigationController animated:NO completion:nil];
}
- (void)backAction {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)backItemAction {
    [PBNoteCenter postNotificationName: PBNoteCenterDismissTabBarController object:nil];
}
 
- (void)loadDocList {
    [[PBNetworkTools sharedTools] RequestGetAllFolderAndFileByProjectIDWithProjectID:self.projectModel.bimcomposerid andLikeName:@"" andNormalOrDrawings:@"Normal" andRoleId:@"" andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
            [YJProgressHUD showMessage:@"加载文档列表失败" inView:self.view];
            return;
        }
        [YJProgressHUD hide];
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSArray<PBDocModel *>*arr = [NSArray yy_modelArrayWithClass:[PBDocModel class] json:str];
        self.docList = arr.mutableCopy;
        [self.tableView reloadData];
        if (self.docList.count == 0) {
            self.promptView.hidden = NO;
        }else {
            self.promptView.hidden = YES;
        }
    }];
}
 
- (void)setIsOther:(BOOL)isOther {
    _isOther = isOther;
}
 
@end