// // MyWorkWordVC.m // smartRhino // // Created by tederen on 2019/11/1. // Copyright © 2019 tederen. All rights reserved. // #import "MyWorkWordVC.h" #import "AutoLayoutScrollView.h" #import "MyWorkWordModel.h" #import "SelectTextCell.h" #import "InPutTextCell.h" #import "InPutGongWenCell.h" #import "AddFileTableViewCell.h" #import "AddPeopleToGongWenCell.h" #import "MOFSPickerManager.h" #import "SendInfoGroupVC.h" #import "LYLPhotoTailoringTool.h" #import "MyWorkAppApprovalCell.h" #import "AddLookUpUserSecondVC.h" #import "MailListVC.h" #import "AddPictureCell.h" #import "FWZFileGetTool.h" #import "TZImagePickerController.h" #import "TabBarController.h" #import "DrawerView.h" #import "DownFileViewController.h" #import "FWZGetNoteBookTool.h" #import "HomeDetailController.h" #import "ChatMsgNoticeDetailVC.h" #import "MyTDTopicDetailVC.h" #import "TDInterLeterDetailVC.h" #import "NoteBookDetailVC.h" #import "TDGroupInfoListVC.h" #import "WorkFlowDetailsController.h" #import "MyApprovalPageDetail.h" #import "MyFavoriteVC.h" #import "NoteBookVC.h" #import "CountDataVC.h" #import "WorkFlowDetailsController.h" @interface MyWorkWordVC (){ NSIndexPath *_currentIndexPath; } @property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) NSMutableArray*>* viewDataArray; @property (nonatomic, strong) NSMutableArray* viewDataArray2; @property (nonatomic, strong) NSMutableArray* attrArray; @property (nonatomic, strong) TDTableView *myTableView; @property (nonatomic, strong) UIView *footerview; @property (nonatomic, strong) MyWorkWordModel *model; @property (nonatomic, assign) NSInteger isTest; @property (nonatomic, assign) CGFloat rowH; @property (nonatomic, strong) NSMutableDictionary *reuqestParams; @property (nonatomic, strong) NSMutableArray *chaoSongRenArr; @property (nonatomic, strong) NSMutableArray *shenPiRenArr; @property (nonatomic, strong) DrawerView *drawerView; @property (nonatomic, assign) BOOL isShenPinRen; @end @implementation MyWorkWordVC - (DrawerView *)drawerView { if(!_drawerView) { _drawerView = [[DrawerView alloc] init]; } return _drawerView; } - (void)viewDidLoad { [super viewDidLoad]; self.myTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; self.view.backgroundColor = [UIColor colorWithHexString:@"EEEEEE"]; self.fd_prefersNavigationBarHidden = YES; self.isTest = 1; self.rowH = 120.f; [self.navigationController.navigationItem.leftBarButtonItem setImage:IMG(@"工作_返回")]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithBgColor:[UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0] alpha:1.0] forBarMetrics:UIBarMetricsDefault]; self.myTableView.backgroundColor = [UIColor colorWithHexString:@"EEEEEE"]; [self getData]; [self.view addSubview:self.myTableView]; self.footerview.frame = CGRectMake(0, 0, kGXScreenWidth,70); [self registerNotification]; self.fd_interactivePopDisabled = YES; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[IQKeyboardManager sharedManager] setEnable:NO]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [[IQKeyboardManager sharedManager] setEnable:YES]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; } - (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } - (void)backButtonAction2:(UIButton *)sender { [self secondBarButtonItems]; } - (void)secondBarButtonItems{ [[UtilsTools getWindow] addSubview:self.drawerView]; WS(weakSelf); self.drawerView.SelectDrawerBlock = ^(NSIndexPath * _Nonnull indexPath) { if ([weakSelf.navigationController.viewControllers count] > 1) { [weakSelf.navigationController popToRootViewControllerAnimated:NO]; } if (indexPath.section == 0) { [[TabBarController sharedTabBarController] setSelectedIndex:indexPath.row]; }else{ ///@"站内信", @"通知", @"收藏",@"笔记", @"设置" switch (indexPath.row) { case 0: { [[TabBarController sharedTabBarController] setSelectedIndex:2]; } break; case 1: { [[TabBarController sharedTabBarController] setSelectedIndex:2]; } break; default: { [[TabBarController sharedTabBarController] setSelectedIndex:3]; } break; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:DRAWERPUSHVC object:nil userInfo:@{VCINDEX:@(indexPath.row)}]; }); } }; self.drawerView.frame = CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT); } - (void)getData{ [self getOnlineData]; } - (void)getOnlineData{ SHOWLOADING WS(weakSelf); [self.attrArray removeAllObjects]; [self.shenPiRenArr removeAllObjects]; [self.chaoSongRenArr removeAllObjects]; [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,WorkFlowHomeData_Post,(long)self.indexID] parameters:@{@"id":@(self.indexID)} responseStyle:JOSN success:^(id _Nonnull responseObject) { REMOVESHOW NSDictionary *dic = responseObject; MyWorkWordModel *model = [[MyWorkWordModel alloc] initWithDictionary:dic error:nil]; weakSelf.model = model; if (weakSelf.detailsModel) { weakSelf.model.FormFields = self.detailsModel.FormFields; for (NSDictionary * dict in self.detailsModel.ApproverCheckUsers) { SelectModel * model = [[SelectModel alloc] init]; model.UserId = [dict[@"Id"] integerValue]; model.Name = dict[@"Name"]; model.UserName = dict[@"Name"]; model.Id = [dict[@"Id"] integerValue]; model.AvatarUrl = dict[@"AvatarUrl"]; [weakSelf.shenPiRenArr addObject:model]; } for (NSDictionary * dict in self.detailsModel.CarbonCopyUsers) { SelectModel * model = [[SelectModel alloc] init]; model.UserId = [dict[@"Id"] integerValue]; model.Name = dict[@"Name"]; model.UserName = dict[@"Name"]; model.Id = [dict[@"Id"] integerValue]; model.AvatarUrl = dict[@"AvatarUrl"]; [weakSelf.chaoSongRenArr addObject:model]; } [weakSelf.attrArray addObjectsFromArray:weakSelf.detailsModel.FlowAttachments]; if (weakSelf.attrArray.count > 0) { NSArray *cells = [weakSelf.myTableView visibleCells]; for (UITableViewCell * cell in cells) { if ([cell isKindOfClass:[AddPictureCell class]]) { AddPictureCell * aCell = (AddPictureCell *)cell; [aCell.mycollectionView reloadData]; } } } } //self.model.AllowApproverCheck = 1; NSLog(@"%@",model); weakSelf.viewDataArray2 = [NSMutableArray arrayWithArray:model.FormFields]; weakSelf.isTest = 2; dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.myTableView setTableFooterView:weakSelf.footerview]; [weakSelf.myTableView reloadData]; }); /****************处理重新提交流程bug***********/ //如果有其他页面需要处理 if (weakSelf.loadDataBlock) { weakSelf.loadDataBlock(); } //赋值 } failure:^(NSError * _Nonnull error) { REMOVESHOW SHOWERROR([ZYCTool handerResultData:error]); }]; } #pragma mark - UITableViewDelegate,UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ if (self.isTest == 1) { return self.viewDataArray.count; }else { return self.viewDataArray2.count + (self.model.AllowApproverCheck == 0 ? 0 : 1) + (self.model.AllowCarbonCopy == 0 ? 0 : 1); } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (self.isTest == 1) { return self.viewDataArray[section].count; }else{ return 1; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString * cellIdentifier1 = @"SelectTextCell"; SelectTextCell *selectTextCell = (SelectTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1]; NSString * cellIdentifier2 = @"InPutTextCell"; InPutTextCell *inPutTextCell = (InPutTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2]; NSString * cellIdentifier3 = @"InPutGongWenCell"; InPutGongWenCell *inPutGongWenCell = (InPutGongWenCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3]; // NSString * cellIdentifier4 = @"AddFileTableViewCell"; // AddFileTableViewCell *addFileTableViewCell = (AddFileTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier4]; //抄送人 NSString * cellIdentifier5 = @"AddPeopleToGongWenCell"; AddPeopleToGongWenCell *addPeopleToGongWenCell = (AddPeopleToGongWenCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier5]; //审批人 NSString * cellIdentifier6 = @"MyWorkAppApprovalCell"; MyWorkAppApprovalCell *myWorkAppApprovalCell = (MyWorkAppApprovalCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier6]; WS(weakSelf); NSString * cellIdentifier7 = @"AddPictureCell"; AddPictureCell *addPictureCell = (AddPictureCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier7]; if (self.model.AllowApproverCheck == 1) { if(indexPath.section == self.viewDataArray2.count){ // 审批人 myWorkAppApprovalCell.namelab.text = @"审批人"; myWorkAppApprovalCell.delegate = self; myWorkAppApprovalCell.approvalSection = self.shenPiRenArr; [myWorkAppApprovalCell.collectView reloadData]; return myWorkAppApprovalCell; } } if (self.model.AllowCarbonCopy == 1) { if(indexPath.section == (self.viewDataArray2.count + 1 )){ // 抄送人 addPeopleToGongWenCell.namelab.text = @"抄送人"; addPeopleToGongWenCell.haveNeedImageView.hidden = YES; addPeopleToGongWenCell.delegate = self; addPeopleToGongWenCell.approvalSection = self.chaoSongRenArr; return addPeopleToGongWenCell; } } FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section]; if (formFieldsModel.Value.length > 0) { formFieldsModel.paramString = formFieldsModel.Value; } if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本 { inPutTextCell.nameLab.text = formFieldsModel.Label; inPutTextCell.imageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.inputtextFeild.tag = indexPath.section + 10000; inPutTextCell.inputtextFeild.delegate = self; inPutTextCell.formFieldsModel = formFieldsModel; return inPutTextCell; } else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本 { inPutGongWenCell.namelab.text = formFieldsModel.Label; inPutGongWenCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutGongWenCell.gongwenContent.delegate = self; inPutGongWenCell.gongwenContent.tag = indexPath.section; inPutGongWenCell.gongwenContent.placeholder = formFieldsModel.Placeholder; inPutGongWenCell.formFieldsModel = formFieldsModel; return inPutGongWenCell; } else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字 { inPutTextCell.nameLab.text = formFieldsModel.Label; inPutTextCell.imageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.inputtextFeild.tag = indexPath.section; inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad; inPutTextCell.inputtextFeild.delegate = self; inPutTextCell.formFieldsModel = formFieldsModel; return inPutTextCell; } else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额 { inPutTextCell.nameLab.text = formFieldsModel.Label; inPutTextCell.imageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; inPutTextCell.inputtextFeild.tag = indexPath.section; inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad; inPutTextCell.inputtextFeild.delegate = self; inPutTextCell.formFieldsModel = formFieldsModel; return inPutTextCell; } else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期 { selectTextCell.nameLab.text = formFieldsModel.Label; selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; selectTextCell.selectButton.tag = indexPath.section; if (!ISEmptyString(formFieldsModel.paramString)) { [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal]; [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal]; } return selectTextCell; } else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选 { selectTextCell.nameLab.text = formFieldsModel.Label; selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1) ? NO : YES; selectTextCell.selectButton.tag = indexPath.section; if (!ISEmptyString(formFieldsModel.paramString)) { [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal]; [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal]; } return selectTextCell; } else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件 { addPictureCell.namelab.text = formFieldsModel.Label; if (self.pageType == Type_GongWen) { addPictureCell.placeholderImg = @"上传附件"; } addPictureCell.haveNeedImageView.hidden = YES; addPictureCell.approvalSection = self.attrArray; addPictureCell.index = indexPath; addPictureCell.delegate = self; addPictureCell.ClickCellBlock = ^(NSInteger index) { FlowAttachmentsModel * model = weakSelf.attrArray[index]; [weakSelf pushFileOpenWithModel:model]; }; return addPictureCell; } return selectTextCell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [MOFSPickerManager shareManger].pickView.toolBar.cancelBar.textColor = UIColorHex(#888888); [MOFSPickerManager shareManger].pickView.toolBar.commitBar.textColor = UIColorHex(#3979D3); if (self.isTest == 1){ }else{ FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section]; if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本 { } else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本 { } else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字 { } else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额 { } else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期 { [[MOFSPickerManager shareManger] showDatePickerWithTag:2 commitBlock:^(NSDate *date) { NSDateFormatter *dateformat = [[NSDateFormatter alloc]init]; dateformat.dateFormat = @"yyyy-MM-dd"; SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [cell.selectButton setTitle: [dateformat stringFromDate:date] forState:UIControlStateNormal]; cell.selectButton.tag = indexPath.section; [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal]; self.viewDataArray2[indexPath.section].paramString = [dateformat stringFromDate:date]; } cancelBlock:^{ }]; } else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选 { MOFSPickerManager *manager = [[MOFSPickerManager alloc] init]; [manager showPickerViewWithDataArray:formFieldsModel.Options tag:1 title:nil cancelTitle:@"取消" commitTitle:@"确定" commitBlock:^(NSString *string) { SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [cell.selectButton setTitle: string forState:UIControlStateNormal]; [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal]; self.viewDataArray2[indexPath.section].paramString = string; } cancelBlock:^{ }]; } else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件 { } } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (self.isTest == 1) { if (indexPath.section == 0) { return 45; } if (indexPath.section == 1) { return 45; } if (indexPath.section == 2) { return 120; } if (indexPath.section == 3) { return 120; } if (indexPath.section == 4) { return 120; } if (indexPath.section == 5) { return 120; } return 0; } else{ FormFieldsModel *formFieldsModel = self.viewDataArray2[indexPath.section]; if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本 { return 45; } else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本 { return self.rowH; } else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字 { return 45; } else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额 { return 45; } else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期 { return 60; } else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选 { return 60; } else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件 { return 120; } return 135.f; } } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { CGFloat H = 0.f; if (section == 0) { H = 20; } if (section == 1) { H = 0.5; } if (section == 2) { H = 0.5; } if (section == 3) { H = self.indexID == 11 ? 20 : 0.5; } if (section >= 4) { H = 20; } UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, H)]; view.backgroundColor = [UIColor colorWithHexString:@"EEEEEE"]; return view; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ if (self.isTest == 1) { if (section == 0) { return 10; } if (section == 1) { return 0.5; } if (section == 2) { return 0.5; } if (section == 3) { return 0.5; } if (section == 4) { return 10; } if (section == 5) { return 10; } return 0; } else{ if (section == 0) { return 20; } if (section == 1) { return 0.5; } if (section == 2) { return 0.5; } if (section == 3) { return self.indexID == 11 ? 20 : 0.5; } if (section >= 4) { return 20; } return 0; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (self.isTest == 1) { if (section == 0) { return 20; } if (section == 1) { return 20; } if (section == 2) { return 20; } if (section == 3) { return 20; } if (section == 4) { return 20; } if (section == 5) { return 20; } return 0; } else{ if (section == 0) { return 20.f; } return 0.01; } } #pragma mark - UITableViewDelegate,UITableViewDataSource - (NSMutableArray *> *)viewDataArray{ if (!_viewDataArray) { _viewDataArray = [NSMutableArray new]; } return _viewDataArray; } - (TDTableView *)myTableView{ if (!_myTableView) { _myTableView = [[TDTableView alloc]initWithFrame:CGRectMake(0,kNavigationHeight,kGXScreenWidth,kGXScreenHeigh -kNavigationHeight - kiphoneXBootomHeight)]; _myTableView.delegate = self; _myTableView.dataSource= self; _myTableView.bounces = NO; [_myTableView registerNib:[UINib nibWithNibName:@"SelectTextCell" bundle:nil] forCellReuseIdentifier:@"SelectTextCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"InPutTextCell" bundle:nil] forCellReuseIdentifier:@"InPutTextCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"AddFileTableViewCell" bundle:nil] forCellReuseIdentifier:@"AddFileTableViewCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"AddPeopleToGongWenCell" bundle:nil] forCellReuseIdentifier:@"AddPeopleToGongWenCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"MyWorkAppApprovalCell" bundle:nil] forCellReuseIdentifier:@"MyWorkAppApprovalCell"]; [_myTableView registerNib:[UINib nibWithNibName:@"AddPictureCell" bundle:nil] forCellReuseIdentifier:@"AddPictureCell"]; } return _myTableView; } - (UIView *)footerview{ if (!_footerview) { _footerview = [[UIView alloc]init]; _footerview.backgroundColor = [UIColor colorWithHexString:@"EEEEEE"]; TDButton *button = [[TDButton alloc]init]; [button setTitle:@"提交" forState:UIControlStateNormal]; [[button titleLabel] setFont: [UIFont systemFontOfSize:19]]; [button setTitleColor:UIColorHex(FFFFFF) forState:UIControlStateNormal]; button.backgroundColor = [UIColor colorWithHexString:@"457BC7"]; button.layer.cornerRadius = 5.f; button.layer.masksToBounds = YES; [_footerview addSubview:button]; [button addTarget:self action:@selector(commitGonwen:) forControlEvents:UIControlEventTouchDown]; [button mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.footerview.mas_centerX); make.centerY.equalTo(self.footerview.mas_centerY); make.width.mas_equalTo(kGXScreenWidth - 40); make.height.mas_equalTo(50); }]; } return _footerview; } - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{ WS(weakSelf); _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) { NSDictionary *dict = responseObject[0]; FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc]initWithDictionary:dict error:nil]; model.SoureId = [dict[@"FileId"] integerValue]; model.Url = dict[@"AbsolutePath"]; model.MinUrl = dict[@"MinAbsolutePath"]; model.Title = dict[@"FileName"]; model.SoureTypeId = CollectModel_file; 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) { [self.view endEditing:YES]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil]; [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){ leftButton.hidden = YES; }]; imagePickerVc.showSelectBtn = NO; imagePickerVc.allowCrop = YES; imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH); imagePickerVc.allowTakePicture = NO; imagePickerVc.allowTakeVideo = NO; [imagePickerVc setIsStatusBarDefault:YES]; [imagePickerVc setNaviTitleColor:[UIColor blackColor]]; [imagePickerVc setBarItemTextColor:[UIColor blackColor]]; [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { PHAsset *asset = assets.firstObject; switch (asset.mediaType) { case PHAssetMediaTypeVideo: { } break; case PHAssetMediaTypeImage: { [self didSelectImages:photos success:success withImgs:photos]; } break; case PHAssetMediaTypeAudio: break; case PHAssetMediaTypeUnknown: break; default: break; } }]; [self presentViewController:imagePickerVc animated:YES completion:nil]; }]; [alertvc addAction:action2]; [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"]; UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[FWZGetNoteBookTool sharedTool] WorkOpenCollectListChooseCollectBlock:^(NSMutableArray * _Nonnull collectArr) { NSLog(@"SmartBarCollection %@",collectArr); NSArray * array = [weakSelf disSelectCollect:collectArr]; success(array); }]; }]; [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"]; [alertvc addAction:action3]; UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[FWZGetNoteBookTool sharedTool] WorkOpenNoteBookListChooseNoteBookBlock:^(NSMutableArray * _Nonnull noteArr) { NSLog(@"SmartBarNotes %@",noteArr); NSArray * array = [weakSelf disSelectNoteBook:noteArr]; success(array); }]; }]; [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 - addNote - (NSArray *)disSelectNoteBook:(NSMutableArray*_Nonnull )noteArr{ NSMutableArray * array = [NSMutableArray array]; for (MyNoteBookSubModel *dataModel in noteArr ) { if (dataModel.AttributeValue == 1) { FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureId = dataModel.MiddleId; model.Url = dataModel.AvatarUrl; model.Author = dataModel.Name; model.Title = dataModel.Title; model.SoureTypeId = CollectModel_NoteBook; [array addObject:model]; } } return array; } #pragma mark - addCollect - (NSArray *)disSelectCollect:(NSMutableArray * _Nonnull) collectArr{ NSMutableArray * array = [NSMutableArray array]; for (MyFavoriteSubModel *dataModel in collectArr ) { if(dataModel.AttributeValue == 1) { FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureId = dataModel.CollectionDataId; model.Url = dataModel.Data.File; model.Size = dataModel.Data.FileSize; model.Author = dataModel.Data.Author; model.Title = dataModel.Title; model.MinUrl = dataModel.Data.MinFile; model.SoureTypeId = dataModel.CollectionType; [array addObject:model]; } } return array; } - (void)commitGonwen:(TDButton *)sender{ if (self.isTest == 1) { }else{ NSMutableArray *arr = [NSMutableArray array]; NSMutableArray * flowAttachmentsArray = [NSMutableArray array]; for (FormFieldsModel *model in self.viewDataArray2) { if ([model.Type isEqualToString:@"TextArea"]) { if ([model.paramString isEqualToString:@"请输入"]) { NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label]; SHOWERROR(errorString); return; } } if (ISEmptyString(model.paramString)) { if (model.Required){ NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label]; NSLog(@"%@",model); SHOWERROR(errorString); return; } }else{ NSMutableDictionary *dic = [NSMutableDictionary dictionary]; if (![model.Type isEqualToString:@"Attachment"]) { [dic setValue:model.paramString forKey:@"Value"]; } [dic setValue:model.Type forKey:@"Type"]; [dic setValue:@(model.Id) forKey:@"ID"]; [arr addObject:dic]; } } if (self.attrArray.count > 0) { for (FlowAttachmentsModel * tempModel in self.attrArray) { NSDictionary * AttachmentDict = @{@"SoureId":@(tempModel.SoureId), @"Url":tempModel.Url, @"Title":tempModel.Title, @"SoureTypeId":@(tempModel.SoureTypeId), @"Size":@(tempModel.Size), }; [flowAttachmentsArray addObject:AttachmentDict]; } } NSMutableDictionary *dic2 = [NSMutableDictionary dictionary]; [dic2 setValue:@(self.indexID) forKey:@"ProcessId"]; [dic2 setValue:arr forKey:@"Fields"]; //如果是公文类型,审批人也必填 if (self.pageType == Type_GongWen && self.model.AllowApproverCheck == 1) { if (self.shenPiRenArr.count < 1) { SHOWERROR(@"请选择审批人"); return; } } [dic2 setValue:flowAttachmentsArray forKey:@"flowAttachments"]; NSMutableArray *shenPiRenIDarray = [NSMutableArray array]; for (SelectModel *model in self.shenPiRenArr) { [shenPiRenIDarray addObject:@(model.UserId)]; } [dic2 setValue:shenPiRenIDarray forKey:@"ApproverCheckUserIds"]; NSMutableArray *chaoSongrenIDArray = [NSMutableArray array]; for (SelectModel *model in self.chaoSongRenArr ) { [chaoSongrenIDArray addObject:@(model.UserId)]; } [dic2 setValue:chaoSongrenIDArray forKey:@"CarbonCopyUserIds"]; [dic2 setValue:@(self.Id) forKey:@"Id"]; NSLog(@"成功成功成功成功%@",dic2); SHOWLOADING WS(weakSelf); [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowAddApproval_Post] parameters:dic2 responseStyle:DATA success:^(id _Nonnull responseObject) { REMOVESHOW NSLog(@"成功"); if (weakSelf.detailsModel && self.Id > 0) { for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) { if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyApprovalPageVC")] ) { [[NSNotificationCenter defaultCenter] postNotificationName:WORKREUPDATA object:nil]; [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES]; return; } } }else{ [weakSelf.navigationController popViewControllerAnimated:YES]; } } failure:^(NSError * _Nonnull error) { NSLog(@"失败"); SHOWERROR([ZYCTool handerResultData:error]); }]; } } -(void)gotoAddPeople{ SendInfoGroupVC *sendinfoVc = [[SendInfoGroupVC alloc] init]; [self.navigationController pushViewController:sendinfoVc animated:YES]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField{ if (_isTest == 2) { self.viewDataArray2[textField.tag].paramString = textField.text; } [textField resignFirstResponder]; return YES; } - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ return YES; } - (void)textViewDidChange:(UITextView *)textView{ self.viewDataArray2[textView.tag].paramString = textView.text; NSArray * cells = [self.myTableView visibleCells]; for (UITableViewCell * cell in cells) { if ([cell isKindOfClass:[InPutGongWenCell class]]) { InPutGongWenCell * inCell = (InPutGongWenCell *)cell; inCell.bgL.text = textView.text; CGFloat H = [inCell.bgL sizeThatFits:CGSizeMake(SCREEN_WIDTH - 20, 10)].height; if ((56 + H) >= 120) { self.rowH = 76 + H; [self.myTableView beginUpdates]; [self.myTableView endUpdates]; } } } } - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{ if (_isTest == 2) { self.viewDataArray2[textView.tag].paramString = textView.text; } return 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) { AddPictureCell *cell = [weakSelf.myTableView cellForRowAtIndexPath:index]; if ([responseObject isKindOfClass:[NSArray class]]) { [weakSelf.attrArray addObjectsFromArray:responseObject]; }else { [weakSelf.attrArray addObject:responseObject]; } [cell.mycollectionView reloadData]; REMOVESHOW; } failure:^(NSError * _Nonnull error ) { REMOVESHOW; SHOWERROR([ZYCTool handerResultData:error]); }]; } // 多张图片上传 - (void)didSelectImages:(NSArray *)images success:(void (^) (id _Nullable))successfulk withImgs:(NSArray *)imgs { NSMutableArray *imageArr = [NSMutableArray array]; for (UIImage *image in images) { [imageArr addObject:UIImageJPEGRepresentation(image,1.0f)]; } SHOWLOADING NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post]; [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:[imageArr copy] pictureKey:@"file" success:^(id _Nonnull responseObject) { REMOVESHOW NSLog(@"%@",responseObject); NSMutableArray * array = [NSMutableArray array]; for (NSDictionary * dict in responseObject) { FlowAttachmentsModel * model = [FlowAttachmentsModel modelWithDictionary:dict]; model.SoureId = [dict[@"FileId"] integerValue]; model.Url = dict[@"AbsolutePath"]; model.MinUrl = dict[@"MinAbsolutePath"]; model.Title = dict[@"FileName"]; model.SoureTypeId = CollectModel_file; [array addObject:model]; } successfulk(array); } 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.viewDataArray2[superIndex.section].paraImage removeObjectAtIndex:index.item]; // [self.myTableView reloadRowsAtIndexPaths:@[superIndex] withRowAnimation:UITableViewRowAnimationAutomatic]; } #pragma mark - AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate - (void)addLookUpPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{ NSLog(@"点击添加抄送人"); self.isShenPinRen = NO; Department *defaltGroupSetion = [[Department alloc]init]; defaltGroupSetion.Name = @"单位通讯录"; defaltGroupSetion.Id = 0; Department *myGroupSetion = [[Department alloc]init]; myGroupSetion.Name = @"自建通讯录"; defaltGroupSetion.Id = 0; AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init]; vc.notSearchChangeColor = YES; vc.titleStr = @"选人"; vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy; vc.isDefalutPage = 1; vc.isShow = NO; NSMutableArray * userArray = [NSMutableArray array]; for (SelectModel * model in self.chaoSongRenArr) { [userArray addObject:@(model.UserId)]; } [userArray addObject:@([AppUserModel sharedAppUserModel].Id)]; vc.UserIds = userArray; vc.delegate = self; [self.navigationController pushViewController:vc animated:YES]; } - (void)addApprovalPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{ NSLog(@"点击添加审批人"); self.isShenPinRen = YES; MailListVC *vc = [MailListVC initMailListVC]; vc.isCheck = YES; vc.isHiddenSearchView = YES; NSMutableArray * UserIds = [NSMutableArray array]; 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 - 注册通知 接受抄送人和审批人数据 - (void)registerNotification{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveApprovalRen:) name:NOTIFI_ApprovalRen object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil]; } - (void)recviveChaoSongRen:(NSNotification *)notification{ NSMutableArray * array = notification.userInfo[@"selectPeople"]; [self.chaoSongRenArr addObjectsFromArray:array]; [self.myTableView reloadData]; } - (void)recviveApprovalRen:(NSNotification *)notification{ SelectModel * model = [SelectModel modelWithDictionary:notification.userInfo]; if (self.isShenPinRen) { [self.shenPiRenArr addObject:model]; }else{ [self.chaoSongRenArr addObject:model]; } [self.myTableView reloadData]; } #pragma mark - setter - (NSMutableArray *)attrArray { if (!_attrArray) { _attrArray = [NSMutableArray array]; } return _attrArray; } - (NSMutableArray *)chaoSongRenArr{ if (!_chaoSongRenArr) { _chaoSongRenArr = [NSMutableArray array]; } return _chaoSongRenArr; } - (NSMutableArray *)shenPiRenArr{ if (!_shenPiRenArr) { _shenPiRenArr = [NSMutableArray array]; } return _shenPiRenArr; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)pushFileOpenWithModel:(FlowAttachmentsModel *)model { WS(weakSelf); switch (model.SoureTypeId) { case CollectModel_Group: { TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC]; vc.GroupId = model.SoureId; vc.titleStr = model.Title; [self.navigationController pushViewController:vc animated:YES]; } break; case CollectModel_file:{ DownFileViewController * vc = [[DownFileViewController alloc] init]; vc.model = model; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_Image:{ DownFileViewController * vc = [[DownFileViewController alloc] init]; vc.model = model; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_Aritle:{ SHOWLOADING [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)model.SoureId] parameters:@{} success:^(id _Nonnull responseObject) { REMOVESHOW; Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil]; HomeDetailController *homeDetail = [[HomeDetailController alloc] init]; [homeDetail loadCurrentModel:itemModel]; [weakSelf.navigationController pushViewController:homeDetail animated:YES]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; }break; case CollectModel_Notice:{ MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_Notice; vc.Id = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_Toipc:{ MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_Toipc; vc.Id = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_NewTopic:{ MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_NewTopic; vc.Id = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_NoteBook:{ MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_NoteBook; vc.Id = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_Collect:{ }break; case CollectModel_CollectFile:{ MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC]; vc.listType = MyFavoriteListLevelTypeB; vc.ParentId = 0; vc.FolderId = model.SoureId; vc.myTitle = model.Title; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_NoteFile:{ NoteBookVC *vc = [NoteBookVC initNoteBookVC]; vc.listType = MyFavoriteListLevelTypeB; vc.ParentId = 0; vc.FolderId = model.SoureId; vc.myTitle = model.Title; vc.VisitUserId = 0; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_InterMail:{ TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC]; vc.detailType = InterLeterDetialType_Sign; vc.interLeterID = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_work:{ MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init]; vc.pageType = Type_ONEC; vc.indexId = model.SoureId; vc.title = model.Title; vc.TodoId = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_meetDetail:{ WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:model.SoureId]; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_meetMian:{ MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_meetMian; vc.Id = model.SoureId; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_financeCount:{ CountDataVC *vc = [CountDataVC initCountDataVC]; vc.index = 0; vc.titleStr = @"财务统计"; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_affairsCount:{ CountDataVC *vc = [CountDataVC initCountDataVC]; vc.index = 1; vc.titleStr = @"人事统计"; [self.navigationController pushViewController:vc animated:YES]; }break; case CollectModel_publishCount:{ CountDataVC *vc = [CountDataVC initCountDataVC]; vc.index = 2; vc.titleStr = @"出版统计"; [self.navigationController pushViewController:vc animated:YES]; }break; default: break; } } @end