AgreeApprovalViewControllerSub.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // AgreeApprovalViewControllerSub.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/8.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AgreeApprovalViewControllerSub.h"
  9. #import "UIPlaceHolderTextView.h"
  10. #import "MyApprovalPageVC.h"
  11. #import "HomeViewController.h"
  12. @interface AgreeApprovalViewControllerSub ()<UITextViewDelegate>
  13. @property (nonatomic, strong) TDButton *commitSendButton;
  14. @property (nonatomic, strong) UIPlaceHolderTextView *textView;
  15. @end
  16. @implementation AgreeApprovalViewControllerSub
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  20. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
  21. [self.view addSubview:self.textView];
  22. [self.view addSubview:self.commitSendButton];
  23. [self.commitSendButton mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.equalTo(self.view).offset(20);
  25. make.right.equalTo(self.view).offset(-20);
  26. make.height.offset(50);
  27. if (@available(iOS 11, *)) {
  28. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-25);
  29. } else {
  30. make.bottom.equalTo(self.view.mas_bottom).offset(-25);
  31. }
  32. }];
  33. _textView.text = _IsChecked ? @"同意" : @"驳回";
  34. }
  35. #pragma arguments
  36. #pragma mark - KeyBoard
  37. - (void)keyBoardWillShow:(NSNotification *)note
  38. {
  39. // 获取用户信息
  40. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  41. // 获取键盘高度
  42. CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
  43. CGFloat keyBoardHeight = keyBoardBounds.size.height;
  44. // 获取键盘动画时间
  45. // CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
  46. // 定义好动作
  47. WS(weakSelf);
  48. [self.commitSendButton mas_updateConstraints:^(MASConstraintMaker *make) {
  49. if (@available(iOS 11.0, *)) {
  50. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-(keyBoardHeight + 10.f));
  51. } else {
  52. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-(keyBoardHeight + 10.f));
  53. }
  54. }];
  55. }
  56. - (void)keyBoardWillHide:(NSNotification *)note
  57. {
  58. WS(weakSelf);
  59. [self.commitSendButton mas_updateConstraints:^(MASConstraintMaker *make) {
  60. if (@available(iOS 11.0, *)) {
  61. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  62. } else {
  63. make.bottom.equalTo(weakSelf.view.mas_bottom);
  64. }
  65. }];
  66. }
  67. #pragma mark - button hander
  68. - (void)commitSendButtonHadner:(TDButton *)button{
  69. [self aggreApproval];
  70. }
  71. #pragma mark - UITextViewDelegate
  72. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
  73. return YES;
  74. }
  75. - (void)textViewDidChange:(UITextView *)textView{
  76. }
  77. #pragma mark - setter
  78. - (TDButton *)commitSendButton{
  79. if (!_commitSendButton) {
  80. _commitSendButton = [[TDButton alloc]init];
  81. _commitSendButton.layer.cornerRadius = 5;
  82. _commitSendButton.layer.masksToBounds = YES;
  83. _commitSendButton.backgroundColor = UIColorHex(#457BC7);
  84. [_commitSendButton setTitle:@"确认发送" forState:UIControlStateNormal];
  85. [_commitSendButton setTitleColor:UIColorHex(#FFFFFF) forState:UIControlStateNormal];
  86. [[_commitSendButton titleLabel] setFont:[UIFont systemFontOfSize:18]];
  87. [_commitSendButton addTarget:self action:@selector(commitSendButtonHadner:) forControlEvents:UIControlEventTouchDown];
  88. }
  89. return _commitSendButton;
  90. }
  91. - (UIPlaceHolderTextView *)textView{
  92. if (!_textView) {
  93. _textView = [[UIPlaceHolderTextView alloc] init];
  94. _textView.frame = CGRectMake(0,kNavigationHeight + 11.f,kGXScreenWidth, 200);
  95. _textView.placeholder = @"请输入...";
  96. _textView.placeholderColor = RGB(102, 102, 102);
  97. _textView.font = [UIFont systemFontOfSize:16];
  98. _textView.textColor = [UIColor colorWithHexString:@"666666"];
  99. _textView.delegate = self;
  100. }
  101. return _textView;
  102. }
  103. - (void)aggreApproval{
  104. if (ISEmptyString(self.textView.text)) {
  105. SHOWERROR(@"请输入审批意见");
  106. return;
  107. }
  108. SHOWLOADING
  109. [[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) {
  110. REMOVESHOW
  111. NSLog(@"审批结果打印%@",responseObject);
  112. if (self.ActionSussBlock) {
  113. self.ActionSussBlock();
  114. }
  115. NSArray *viewControlers = [self.navigationController viewControllers];
  116. for (UIViewController *viewController in viewControlers) {
  117. if ([viewController isKindOfClass:[MyApprovalPageVC class]] || [viewController isKindOfClass:[HomeViewController class]]) {
  118. [self.navigationController popToViewController:viewController animated:YES];
  119. return;
  120. }
  121. }
  122. } failure:^(NSError * _Nonnull error) {
  123. SHOWERROR([ZYCTool handerResultData:error]);
  124. }];
  125. }
  126. @end