123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // AgreeApprovalViewControllerSub.m
- // smartRhino
- //
- // Created by tederen on 2019/11/8.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "AgreeApprovalViewControllerSub.h"
- #import "UIPlaceHolderTextView.h"
- #import "MyApprovalPageVC.h"
- #import "HomeViewController.h"
- @interface AgreeApprovalViewControllerSub ()<UITextViewDelegate>
- @property (nonatomic, strong) TDButton *commitSendButton;
- @property (nonatomic, strong) UIPlaceHolderTextView *textView;
- @end
- @implementation AgreeApprovalViewControllerSub
- - (void)viewDidLoad {
- [super viewDidLoad];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- [self.view addSubview:self.textView];
-
- [self.view addSubview:self.commitSendButton];
- [self.commitSendButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(20);
- make.right.equalTo(self.view).offset(-20);
- make.height.offset(50);
- if (@available(iOS 11, *)) {
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-25);
- } else {
- make.bottom.equalTo(self.view.mas_bottom).offset(-25);
- }
- }];
- _textView.text = _IsChecked ? @"同意" : @"驳回";
- }
- #pragma arguments
- #pragma mark - KeyBoard
- - (void)keyBoardWillShow:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘高度
- CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGFloat keyBoardHeight = keyBoardBounds.size.height;
- // 获取键盘动画时间
- // CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
- // 定义好动作
- WS(weakSelf);
- [self.commitSendButton mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-(keyBoardHeight + 10.f));
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-(keyBoardHeight + 10.f));
- }
- }];
- }
- - (void)keyBoardWillHide:(NSNotification *)note
- {
- WS(weakSelf);
- [self.commitSendButton mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom);
- }
- }];
- }
- #pragma mark - button hander
- - (void)commitSendButtonHadner:(TDButton *)button{
- [self aggreApproval];
- }
- #pragma mark - UITextViewDelegate
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- return YES;
- }
- - (void)textViewDidChange:(UITextView *)textView{
-
- }
- #pragma mark - setter
- - (TDButton *)commitSendButton{
- if (!_commitSendButton) {
- _commitSendButton = [[TDButton alloc]init];
- _commitSendButton.layer.cornerRadius = 5;
- _commitSendButton.layer.masksToBounds = YES;
- _commitSendButton.backgroundColor = UIColorHex(#457BC7);
- [_commitSendButton setTitle:@"确认发送" forState:UIControlStateNormal];
- [_commitSendButton setTitleColor:UIColorHex(#FFFFFF) forState:UIControlStateNormal];
- [[_commitSendButton titleLabel] setFont:[UIFont systemFontOfSize:18]];
- [_commitSendButton addTarget:self action:@selector(commitSendButtonHadner:) forControlEvents:UIControlEventTouchDown];
-
- }
- return _commitSendButton;
- }
- - (UIPlaceHolderTextView *)textView{
- if (!_textView) {
- _textView = [[UIPlaceHolderTextView alloc] init];
- _textView.frame = CGRectMake(0,kNavigationHeight + 11.f,kGXScreenWidth, 200);
- _textView.placeholder = @"请输入...";
- _textView.placeholderColor = RGB(102, 102, 102);
- _textView.font = [UIFont systemFontOfSize:16];
- _textView.textColor = [UIColor colorWithHexString:@"666666"];
- _textView.delegate = self;
- }
- return _textView;
- }
- - (void)aggreApproval{
- if (ISEmptyString(self.textView.text)) {
- SHOWERROR(@"请输入审批意见");
- return;
- }
- SHOWLOADING
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowApproval_Post] parameters:@{@"FlowId":@(self.FlowId),@"TodoId":@(self.TodoId),@"IsChecked":@(self.IsChecked),@"Message":self.textView.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- NSLog(@"审批结果打印%@",responseObject);
- if (self.ActionSussBlock) {
- self.ActionSussBlock();
- }
-
- NSArray *viewControlers = [self.navigationController viewControllers];
- for (UIViewController *viewController in viewControlers) {
- if ([viewController isKindOfClass:[MyApprovalPageVC class]] || [viewController isKindOfClass:[HomeViewController class]]) {
- [self.navigationController popToViewController:viewController animated:YES];
- return;
- }
- }
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- @end
|