//
|
// 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
|