NextApprovalViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. //
  2. // NextApprovalViewController.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/8.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "NextApprovalViewController.h"
  9. #import "MyApprovalDetailCell.h"
  10. #import "MyApprovalDetailModel.h"
  11. #import "SendInfoGroupVC.h"
  12. #import "MyWorkAppApprovalCell.h"
  13. #import "InPutGongWenCell.h"
  14. #import "MailListVC.h"
  15. #import "AddPictureCell.h"
  16. #import "LYLPhotoTailoringTool.h"
  17. #import "FWZFileGetTool.h"
  18. #import "InputGongwenFileCell.h"
  19. #import "MyApprovalPageVC.h"
  20. #import "HomeViewController.h"
  21. #import "DownFileViewController.h"
  22. @interface NextApprovalViewController ()<UITableViewDelegate,UITableViewDataSource,MyWorkAppApprovalCellDelegate,UIImagePickerControllerDelegate>
  23. {
  24. NSIndexPath *_currentIndexPath;
  25. }
  26. @property (nonatomic, strong) TDTableView *mytableView;
  27. @property (nonatomic, strong) TDButton *commitSendButton;
  28. @property (nonatomic, strong) NSMutableArray * shenPiRenArr;
  29. @property (nonatomic, strong) UITextView *textView;
  30. @property (nonatomic, strong) NSMutableArray *fileSource;
  31. @end
  32. @implementation NextApprovalViewController
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.view.backgroundColor = UIColorHex(0xeeeeee);
  36. self.fileSource = [[NSMutableArray alloc] init];
  37. [self.view addSubview:self.mytableView];
  38. [self.view addSubview:self.commitSendButton];
  39. [self.mytableView registerNib:[UINib nibWithNibName:@"InputGongwenFileCell" bundle:nil] forCellReuseIdentifier:@"InputGongwenFileCell"];
  40. [self registerNotification];
  41. }
  42. #pragma mark - button hander
  43. - (void)commitSendButtonHadner:(TDButton *)button{
  44. if (self.shenPiRenArr.count == 0) {
  45. SHOWERROR(@"请选择审批人");
  46. return;
  47. }
  48. NSMutableArray *TransferUserIds = [NSMutableArray array];
  49. for (SelectModel *model in self.shenPiRenArr) {
  50. [TransferUserIds addObject:@(model.UserId)];
  51. }
  52. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  53. [dic setValue:TransferUserIds forKey:@"TransferUserIds"];
  54. [dic setValue:@(self.TodoId) forKey:@"TodoId"];
  55. [dic setValue:self.textView.text.length > 0 ? self.textView.text: @"" forKey:@"Message"];
  56. NSMutableArray *fileids = [[NSMutableArray alloc] initWithCapacity:self.fileSource.count];
  57. [self.fileSource enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  58. SelectImageModel *imageModel = obj;
  59. [fileids addObject:@(imageModel.FileId)];
  60. }];
  61. if (fileids.count > 0) {
  62. [dic setValue:fileids forKey:@"FileIds"];
  63. }
  64. SHOWLOADING
  65. WEAKSELF
  66. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowApproval_OtherPost] parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  67. REMOVESHOW
  68. STRONGSELF
  69. if (strongSelf.ActionSussBlock) {
  70. strongSelf.ActionSussBlock();
  71. }
  72. NSArray *viewControlers = [strongSelf.navigationController viewControllers];
  73. for (UIViewController *viewController in viewControlers) {
  74. if ([viewController isKindOfClass:[MyApprovalPageVC class]] || [viewController isKindOfClass:[HomeViewController class]]) {
  75. [strongSelf.navigationController popToViewController:viewController animated:YES];
  76. return;
  77. }
  78. }
  79. SHOWSUCCESS(@"转审成功");
  80. } failure:^(NSError * _Nonnull error) {
  81. SHOWERROR([ZYCTool handerResultData:error]);
  82. }];
  83. }
  84. - (void)back{
  85. [self.navigationController popViewControllerAnimated:true];
  86. }
  87. #pragma mark - UITableViewDelegate,UITableViewDataSource
  88. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  89. return 2;
  90. }
  91. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  92. return 1;
  93. }
  94. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  95. switch (indexPath.section) {
  96. case 0:
  97. return 140.f;
  98. case 1:
  99. return 214.f;
  100. default:
  101. return 0;
  102. }
  103. }
  104. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  105. // WS(weakSelf);
  106. if (indexPath.section == 0) {
  107. MyWorkAppApprovalCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyWorkAppApprovalCell"];
  108. cell.namelab.text = @"转审人";
  109. cell.delegate = self;
  110. cell.approvalSection = self.shenPiRenArr;
  111. return cell;
  112. }else{
  113. // InPutGongWenCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"InPutGongWenCell"];
  114. // cell2.namelab.text = @"审批意见";
  115. // cell2.haveNeedImageView.hidden = YES;
  116. // self.textView = cell2.gongwenContent;
  117. // return cell2;
  118. InputGongwenFileCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"InputGongwenFileCell" forIndexPath:indexPath];
  119. cell2.gongwenContent.placeholder = @"请输入...";
  120. cell2.redImageV.hidden = YES;
  121. self.textView = cell2.gongwenContent;
  122. cell2.mycollectionView.hidden = YES;
  123. // cell2.approvalSection = self.fileSource;
  124. // cell2.placeholderImg = @"上传附件";
  125. // cell2.redImageV.hidden = YES;
  126. // cell2.delegate = self;
  127. // cell2.ClickCellBlock = ^(NSInteger index) {
  128. // SelectImageModel *imgModel = weakSelf.fileSource[index];
  129. // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
  130. // mdoel.PreviewUrl = imgModel.AbsolutePath;
  131. // mdoel.DownloadUrl = imgModel.AbsolutePath;
  132. // DownFileViewController *vc = [[DownFileViewController alloc]init];
  133. // vc.title = [mdoel.PreviewUrl componentsSeparatedByString:@"/"].lastObject;
  134. // vc.model = mdoel;
  135. // [weakSelf.navigationController pushViewController:vc animated:YES];
  136. // };
  137. cell2.selectionStyle = UITableViewCellSelectionStyleNone;
  138. return cell2;
  139. }
  140. }
  141. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  142. return 20;
  143. }
  144. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  145. return section == 0 ? 20.f : 0.01f;
  146. }
  147. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  148. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, section == 0 ? 20.f : 0.01f)];
  149. view.backgroundColor = UIColorHex(0xEEEEEE);
  150. return view;
  151. }
  152. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  153. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20)];
  154. view.backgroundColor = UIColorHex(0xEEEEEE);
  155. return view;
  156. }
  157. #pragma mark - MyWorkAppApprovalCellDelegate
  158. - (void)registerNotification{
  159. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveApprovalRen:) name:NOTIFI_ApprovalRen object:nil];
  160. }
  161. - (void)recviveApprovalRen:(NSNotification *)notification{
  162. NSLog(@"审批人1%@",notification.userInfo);
  163. // SelectModel *model = [[SelectModel alloc]initWithDictionary:notification.userInfo error:nil];
  164. SelectModel * model = [SelectModel modelWithDictionary:notification.userInfo];
  165. [self.shenPiRenArr addObject:model];
  166. NSLog(@"审批人2%@",self.shenPiRenArr);
  167. MyWorkAppApprovalCell *cell = [self.mytableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
  168. cell.approvalSection = self.shenPiRenArr;
  169. [cell.collectionView reloadData];
  170. }
  171. - (void)addApprovalPeopleSuccess:(nullable void (^)( id _Nullable responseObject)) success failure:(nullable void (^)(NSError *error))failure{
  172. MailListVC *vc = [MailListVC initMailListVC];
  173. vc.isCheck = YES;
  174. vc.isHiddenSearchView = YES;
  175. NSMutableArray * UserIds = [NSMutableArray array];
  176. [UserIds addObjectsFromArray:self.userIds];
  177. for (SelectModel * model in self.shenPiRenArr) {
  178. [UserIds addObject:@(model.UserId)];
  179. }
  180. [UserIds addObject:@([AppUserModel sharedAppUserModel].Id)];
  181. vc.isShow = NO;
  182. vc.UserIds = UserIds;
  183. [self.navigationController pushViewController:vc animated:YES];
  184. }
  185. #pragma mark - AddPictureCellDelegate
  186. - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  187. WEAKSELF
  188. [self addFile:index Sucuss:^(id _Nullable responseObject) {
  189. STRONGSELF
  190. [strongSelf.fileSource addObject:responseObject];
  191. [strongSelf.mytableView reloadData];
  192. REMOVESHOW;
  193. } failure:^(NSError * _Nonnull error ) {
  194. REMOVESHOW;
  195. SHOWERROR([ZYCTool handerResultData:error]);
  196. }];
  197. }
  198. - (void)deletePictureWithCell:(NSIndexPath *)index SuperViewCellIndexPath:(NSIndexPath *)superIndex WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  199. [self.fileSource removeObjectAtIndex:index.item];
  200. [self.mytableView reloadData];
  201. }
  202. - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  203. _currentIndexPath = indexpath;
  204. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  205. picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  206. picker.delegate = self;
  207. picker.allowsEditing = YES;//取消白框
  208. UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  209. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  210. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  211. } choosImgBlock:^(UIImage *image) {
  212. SHOWLOADING
  213. [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
  214. NSArray *dic = responseObject;
  215. SelectImageModel *model = [[SelectImageModel alloc]initWithDictionary:dic[0] error:nil];
  216. model.image = image;
  217. success(model);
  218. } failure:^(NSError * _Nonnull error) {
  219. failure(error);
  220. }];
  221. }];
  222. }];
  223. [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  224. [alertvc addAction:action1];
  225. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  226. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  227. } choosImgBlock:^(UIImage *image) {
  228. SHOWLOADING
  229. [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
  230. NSArray *dic = responseObject;
  231. SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
  232. model.image = image;
  233. success(model);
  234. } failure:^(NSError * _Nonnull error) {
  235. failure(error);
  236. }];
  237. }];
  238. }];
  239. [alertvc addAction:action2];
  240. [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  241. UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  242. SHOWERROR(@"暂不支持,正在开发中");
  243. }];
  244. [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  245. [alertvc addAction:action3];
  246. UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  247. SHOWERROR(@"暂不支持,正在开发中");
  248. }];
  249. [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  250. [alertvc addAction:action4];
  251. UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  252. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  253. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  254. NSLog(@"%@",fileName);
  255. SHOWLOADING
  256. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  257. NSLog(@"上传成功的文件%@",responseObject);
  258. NSDictionary *dict = responseObject[0];
  259. FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc] initWithDictionary:dict error:nil];
  260. model.SoureTypeId = CollectModel_file;
  261. model.SoureId = [dict[@"FileId"] integerValue];
  262. model.Url = dict[@"AbsolutePath"];
  263. model.MinUrl = dict[@"MinAbsolutePath"];
  264. model.Title = dict[@"FileName"];
  265. model.Size = [dict[@"Size"] integerValue];
  266. success(model);
  267. } failure:^(NSError * _Nonnull error) {
  268. failure(error);
  269. }];
  270. }];
  271. }];
  272. [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  273. [alertvc addAction:action5];
  274. UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  275. }];
  276. [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  277. [alertvc addAction:action6];
  278. [self presentViewController:alertvc animated:YES completion:^{}];
  279. }
  280. #pragma mark - setter
  281. - (TDTableView *)mytableView{
  282. if (!_mytableView) {
  283. _mytableView = [[TDTableView alloc]init];
  284. _mytableView.frame = CGRectMake(0,kNavigationHeight,kGXScreenWidth, kGXScreenHeigh - kNavigationHeight) ;
  285. _mytableView.delegate = self;
  286. _mytableView.dataSource = self;
  287. _mytableView.backgroundColor = UIColorHex(0xeeeeee);
  288. _mytableView.sectionHeaderHeight = 0;
  289. [_mytableView registerNib:[UINib nibWithNibName:@"MyWorkAppApprovalCell" bundle:nil] forCellReuseIdentifier:@"MyWorkAppApprovalCell"];
  290. [_mytableView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
  291. }
  292. return _mytableView;
  293. }
  294. #pragma mark - setter
  295. - (TDButton *)commitSendButton{
  296. if (!_commitSendButton) {
  297. _commitSendButton = [[TDButton alloc] initWithFrame:CGRectMake(20, kGXScreenHeigh - 60, kGXScreenWidth -40, 50)];
  298. _commitSendButton.layer.cornerRadius = 5;
  299. _commitSendButton.layer.masksToBounds = YES;
  300. _commitSendButton.backgroundColor = UIColorHex(#457BC7);
  301. [_commitSendButton setTitle:@"提交" forState:UIControlStateNormal];
  302. [_commitSendButton setTitleColor:UIColorHex(#FFFFFF) forState:UIControlStateNormal];
  303. [[_commitSendButton titleLabel] setFont:[UIFont systemFontOfSize:18]];
  304. [_commitSendButton addTarget:self action:@selector(commitSendButtonHadner:) forControlEvents:UIControlEventTouchDown];
  305. }
  306. return _commitSendButton;
  307. }
  308. - (NSMutableArray *)shenPiRenArr{
  309. if (!_shenPiRenArr) {
  310. _shenPiRenArr = [NSMutableArray array];
  311. }
  312. return _shenPiRenArr;
  313. }
  314. - (void)dealloc
  315. {
  316. [[NSNotificationCenter defaultCenter] removeObserver:self];
  317. }
  318. @end