123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- //
- // NextApprovalViewController.m
- // smartRhino
- //
- // Created by tederen on 2019/11/8.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "NextApprovalViewController.h"
- #import "MyApprovalDetailCell.h"
- #import "MyApprovalDetailModel.h"
- #import "SendInfoGroupVC.h"
- #import "MyWorkAppApprovalCell.h"
- #import "InPutGongWenCell.h"
- #import "MailListVC.h"
- #import "AddPictureCell.h"
- #import "LYLPhotoTailoringTool.h"
- #import "FWZFileGetTool.h"
- #import "InputGongwenFileCell.h"
- #import "MyApprovalPageVC.h"
- #import "HomeViewController.h"
- #import "DownFileViewController.h"
- @interface NextApprovalViewController ()<UITableViewDelegate,UITableViewDataSource,MyWorkAppApprovalCellDelegate,UIImagePickerControllerDelegate>
- {
- NSIndexPath *_currentIndexPath;
- }
- @property (nonatomic, strong) TDTableView *mytableView;
- @property (nonatomic, strong) TDButton *commitSendButton;
- @property (nonatomic, strong) NSMutableArray * shenPiRenArr;
- @property (nonatomic, strong) UITextView *textView;
- @property (nonatomic, strong) NSMutableArray *fileSource;
- @end
- @implementation NextApprovalViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = UIColorHex(0xeeeeee);
- self.fileSource = [[NSMutableArray alloc] init];
- [self.view addSubview:self.mytableView];
- [self.view addSubview:self.commitSendButton];
- [self.mytableView registerNib:[UINib nibWithNibName:@"InputGongwenFileCell" bundle:nil] forCellReuseIdentifier:@"InputGongwenFileCell"];
- [self registerNotification];
- }
- #pragma mark - button hander
- - (void)commitSendButtonHadner:(TDButton *)button{
- if (self.shenPiRenArr.count == 0) {
- SHOWERROR(@"请选择审批人");
- return;
- }
- NSMutableArray *TransferUserIds = [NSMutableArray array];
- for (SelectModel *model in self.shenPiRenArr) {
- [TransferUserIds addObject:@(model.UserId)];
- }
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:TransferUserIds forKey:@"TransferUserIds"];
- [dic setValue:@(self.TodoId) forKey:@"TodoId"];
- [dic setValue:self.textView.text.length > 0 ? self.textView.text: @"" forKey:@"Message"];
- NSMutableArray *fileids = [[NSMutableArray alloc] initWithCapacity:self.fileSource.count];
- [self.fileSource enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- SelectImageModel *imageModel = obj;
- [fileids addObject:@(imageModel.FileId)];
- }];
- if (fileids.count > 0) {
- [dic setValue:fileids forKey:@"FileIds"];
- }
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowApproval_OtherPost] parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- STRONGSELF
- if (strongSelf.ActionSussBlock) {
- strongSelf.ActionSussBlock();
- }
- NSArray *viewControlers = [strongSelf.navigationController viewControllers];
- for (UIViewController *viewController in viewControlers) {
- if ([viewController isKindOfClass:[MyApprovalPageVC class]] || [viewController isKindOfClass:[HomeViewController class]]) {
- [strongSelf.navigationController popToViewController:viewController animated:YES];
- return;
- }
- }
- SHOWSUCCESS(@"转审成功");
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)back{
- [self.navigationController popViewControllerAnimated:true];
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- switch (indexPath.section) {
- case 0:
- return 140.f;
- case 1:
- return 214.f;
- default:
- return 0;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- // WS(weakSelf);
- if (indexPath.section == 0) {
- MyWorkAppApprovalCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyWorkAppApprovalCell"];
- cell.namelab.text = @"转审人";
- cell.delegate = self;
- cell.approvalSection = self.shenPiRenArr;
- return cell;
- }else{
- // InPutGongWenCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"InPutGongWenCell"];
- // cell2.namelab.text = @"审批意见";
- // cell2.haveNeedImageView.hidden = YES;
- // self.textView = cell2.gongwenContent;
- // return cell2;
- InputGongwenFileCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"InputGongwenFileCell" forIndexPath:indexPath];
- cell2.gongwenContent.placeholder = @"请输入...";
- cell2.redImageV.hidden = YES;
- self.textView = cell2.gongwenContent;
- cell2.mycollectionView.hidden = YES;
- // cell2.approvalSection = self.fileSource;
- // cell2.placeholderImg = @"上传附件";
- // cell2.redImageV.hidden = YES;
- // cell2.delegate = self;
- // cell2.ClickCellBlock = ^(NSInteger index) {
- // SelectImageModel *imgModel = weakSelf.fileSource[index];
- // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
- // mdoel.PreviewUrl = imgModel.AbsolutePath;
- // mdoel.DownloadUrl = imgModel.AbsolutePath;
- // DownFileViewController *vc = [[DownFileViewController alloc]init];
- // vc.title = [mdoel.PreviewUrl componentsSeparatedByString:@"/"].lastObject;
- // vc.model = mdoel;
- // [weakSelf.navigationController pushViewController:vc animated:YES];
- // };
- cell2.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell2;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 20;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return section == 0 ? 20.f : 0.01f;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, section == 0 ? 20.f : 0.01f)];
- view.backgroundColor = UIColorHex(0xEEEEEE);
- return view;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20)];
- view.backgroundColor = UIColorHex(0xEEEEEE);
- return view;
- }
- #pragma mark - MyWorkAppApprovalCellDelegate
- - (void)registerNotification{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveApprovalRen:) name:NOTIFI_ApprovalRen object:nil];
- }
- - (void)recviveApprovalRen:(NSNotification *)notification{
- NSLog(@"审批人1%@",notification.userInfo);
- // SelectModel *model = [[SelectModel alloc]initWithDictionary:notification.userInfo error:nil];
- SelectModel * model = [SelectModel modelWithDictionary:notification.userInfo];
- [self.shenPiRenArr addObject:model];
- NSLog(@"审批人2%@",self.shenPiRenArr);
- MyWorkAppApprovalCell *cell = [self.mytableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
- cell.approvalSection = self.shenPiRenArr;
- [cell.collectionView reloadData];
-
- }
- - (void)addApprovalPeopleSuccess:(nullable void (^)( id _Nullable responseObject)) success failure:(nullable void (^)(NSError *error))failure{
- MailListVC *vc = [MailListVC initMailListVC];
- vc.isCheck = YES;
- vc.isHiddenSearchView = YES;
- NSMutableArray * UserIds = [NSMutableArray array];
- [UserIds addObjectsFromArray:self.userIds];
- for (SelectModel * model in self.shenPiRenArr) {
- [UserIds addObject:@(model.UserId)];
- }
- [UserIds addObject:@([AppUserModel sharedAppUserModel].Id)];
- vc.isShow = NO;
- vc.UserIds = UserIds;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - AddPictureCellDelegate
- - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- WEAKSELF
- [self addFile:index Sucuss:^(id _Nullable responseObject) {
- STRONGSELF
- [strongSelf.fileSource addObject:responseObject];
- [strongSelf.mytableView reloadData];
- REMOVESHOW;
- } failure:^(NSError * _Nonnull error ) {
- REMOVESHOW;
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)deletePictureWithCell:(NSIndexPath *)index SuperViewCellIndexPath:(NSIndexPath *)superIndex WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- [self.fileSource removeObjectAtIndex:index.item];
- [self.mytableView reloadData];
- }
- - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- _currentIndexPath = indexpath;
-
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
-
- picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
-
- picker.delegate = self;
-
- picker.allowsEditing = YES;//取消白框
- UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-
- UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
-
- } choosImgBlock:^(UIImage *image) {
-
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
-
- NSArray *dic = responseObject;
- SelectImageModel *model = [[SelectImageModel alloc]initWithDictionary:dic[0] error:nil];
- model.image = image;
- success(model);
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action1];
- UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- } choosImgBlock:^(UIImage *image) {
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSArray *dic = responseObject;
- SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
- model.image = image;
- success(model);
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [alertvc addAction:action2];
- [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- SHOWERROR(@"暂不支持,正在开发中");
- }];
- [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action3];
- UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- SHOWERROR(@"暂不支持,正在开发中");
- }];
- [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action4];
- UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
-
- } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
- NSLog(@"%@",fileName);
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
- NSLog(@"上传成功的文件%@",responseObject);
- NSDictionary *dict = responseObject[0];
- FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc] initWithDictionary:dict error:nil];
- model.SoureTypeId = CollectModel_file;
- model.SoureId = [dict[@"FileId"] integerValue];
- model.Url = dict[@"AbsolutePath"];
- model.MinUrl = dict[@"MinAbsolutePath"];
- model.Title = dict[@"FileName"];
- model.Size = [dict[@"Size"] integerValue];
- success(model);
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
-
- }];
- }];
- [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action5];
- UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action6];
- [self presentViewController:alertvc animated:YES completion:^{}];
- }
- #pragma mark - setter
- - (TDTableView *)mytableView{
- if (!_mytableView) {
- _mytableView = [[TDTableView alloc]init];
- _mytableView.frame = CGRectMake(0,kNavigationHeight,kGXScreenWidth, kGXScreenHeigh - kNavigationHeight) ;
- _mytableView.delegate = self;
- _mytableView.dataSource = self;
- _mytableView.backgroundColor = UIColorHex(0xeeeeee);
- _mytableView.sectionHeaderHeight = 0;
- [_mytableView registerNib:[UINib nibWithNibName:@"MyWorkAppApprovalCell" bundle:nil] forCellReuseIdentifier:@"MyWorkAppApprovalCell"];
- [_mytableView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
- }
- return _mytableView;
- }
- #pragma mark - setter
- - (TDButton *)commitSendButton{
- if (!_commitSendButton) {
- _commitSendButton = [[TDButton alloc] initWithFrame:CGRectMake(20, kGXScreenHeigh - 60, kGXScreenWidth -40, 50)];
- _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;
- }
- - (NSMutableArray *)shenPiRenArr{
- if (!_shenPiRenArr) {
- _shenPiRenArr = [NSMutableArray array];
- }
- return _shenPiRenArr;
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- @end
|