NextApprovalViewController.m 16 KB

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