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
//
//  PBPreScheduleViewController.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2022/9/13.
//  Copyright © 2022 ProBIM. All rights reserved.
//
 
#import "PBPreScheduleViewController.h"
#import "PBScheduleListViewController.h"
#import "PBScheduleListModel.h"
#import "PBProjectModel.h"
#import <WebKit/WebKit.h>
 
@interface PBPreScheduleViewController ()<WKUIDelegate, WKNavigationDelegate>
@property (nonatomic, strong) WKWebView *webView;
@end
 
@implementation PBPreScheduleViewController
- (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 setupNav];
    [self setupUI];
}
- (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;
//    if ([self.scheduleListModel.MobilePA_state isEqualToString:@"待提交"] || [self.scheduleListModel.MobilePA_state isEqualToString:@"驳回待提交"]){
//        UIBarButtonItem *publishItem = [[UIBarButtonItem alloc] initWithTitle:@"发布" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction)];
//        self.navigationItem.rightBarButtonItem = publishItem;
//    }
}
- (void)setupUI {
    self.view.backgroundColor = [UIColor whiteColor];
//    CGFloat bottomH = 0.f;
//    if ([self.scheduleListModel.MobilePA_state isEqualToString:@"待审核"]){
//        bottomH = 64.f;
//        if (IS_IPHONE_X) {
//            bottomH = 64.f + IPHONE_X_BOTTOM;
//        }
//    }
   
    self.webView = [[WKWebView alloc] init];
    self.webView.scrollView.bounces = NO;
    self.webView.navigationDelegate = self;
    self.webView.UIDelegate = self;
    [self.view addSubview:self.webView];
    self.webView.backgroundColor = [UIColor whiteColor];
    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.view);
//        make.bottom.equalTo(self.view).offset(-bottomH);
    }];
//    NSString *url = [NSString stringWithFormat:@"http://newweb.biaddti.com/#/Home/ProjectBoot/ProgressReportingDaily/2799f5aa-290f-49a8-95aa-c48bb07697f9/a3fb839e-90fa-43c0-a705-fb5469a649a6/8a0f9c1c-05d7-4968-ab7e-47c434fd78c9/2022-09-07"];
//    /#/Home/ProjectBoot/ProgressReportingDaily
//    后面传递参数organizeId/ProjectID/CreateuserId/Unittime
    
    NSString *url = [NSString stringWithFormat:@"%@/#/Home/ProjectBoot/ProgressReportingDaily/%@/%@/%@/%@", WebUrl, self.projectModel.organizeid, self.scheduleListModel.MobilePA_ProjectID, self.scheduleListModel.MobilePA_Createuserid, self.scheduleListModel.MobilePA_Unittime];
    NSLog(@"url:%@",url);
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    
//    if ([self.scheduleListModel.MobilePA_state isEqualToString:@"待审核"]){
//        UIButton *bohuiBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"overrule"]];
//        [bohuiBtn addTarget:self action:@selector(bohui) forControlEvents:UIControlEventTouchUpInside];
//        [self.view addSubview:bohuiBtn];
//        [bohuiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.webView.mas_bottom).offset(7);
//            make.left.equalTo(self.view);
//            make.height.equalTo(@48);
//            make.width.equalTo(@140);
//        }];
//        UIButton *tongguoBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"pass"]];
//        [tongguoBtn addTarget:self action:@selector(tongguo) forControlEvents:UIControlEventTouchUpInside];
//        [self.view addSubview:tongguoBtn];
//        [tongguoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.webView.mas_bottom).offset(7);
//            make.left.equalTo(bohuiBtn.mas_right);
//            make.right.equalTo(self.view);
//            make.height.equalTo(@48);
//        }];
//    }
 
}
- (void)backItemAction {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)publish {
    
}
- (void)setScheduleListModel:(PBScheduleListModel *)scheduleListModel {
    _scheduleListModel = scheduleListModel;
    
    
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
 
#pragma mark - WKWKNavigationDelegate Methods
//开始加载
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
    [YJProgressHUD showProgress:@"" inView:self.view];
}
 
//加载完成
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    [YJProgressHUD hide];
}
 
//加载失败
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
    [YJProgressHUD showFailed:@"加载失败" inview:self.view];
}
 
- (void)rightAction {
    [self updateStatus:@"待审核"];
}
- (void)bohui {
    [self updateStatus:@"驳回待提交"];
}
- (void)tongguo {
    [self updateStatus:@"已审核"];
}
- (void)updateStatus:(NSString *)status {
    [YJProgressHUD showProgress:@"正在发布..." inView:self.view];
    [[PBNetworkTools sharedTools] UpdateStatesWithPlanId:self.scheduleListModel.MobilePA_ProjectID andUnittime:self.scheduleListModel.MobilePA_Unittime andCreateUserId:self.scheduleListModel.MobilePA_Createuserid andStatus:status andOrganizeId:self.projectModel.organizeid 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];
            [self backAction];
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];
}
- (void)backAction{
    UINavigationController *navVC = self.navigationController;
    NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
    for (UIViewController *vc in [navVC viewControllers]) {
        [viewControllers addObject:vc];
        if ([vc isKindOfClass:[PBScheduleListViewController class]]) {
            break;
         }
    }
    [navVC setViewControllers:viewControllers animated:YES];
}
/*
#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