// // CreateInterLeterVC.m // smartRhino // // Created by taidi on 2019/12/25. // Copyright © 2019 tederen. All rights reserved. // #import "CreateInterLeterVC.h" #import "AddLookUpUserSecondVC.h" #import "NoticeSelectCell.h" #import "YCMenuView.h" #import "ShowKeepNoticeAlert.h" #import "NewTopicCell.h" #import "SmartBar.h" #import "LYLPhotoTailoringTool.h" #import "FWZGetNoteBookTool.h" #import "FWZFileGetTool.h" #import "NoteBookDetailCell.h" #import "shoujianrenResultView.h" #define TextViewTag 1000 #define BARHEIGHT 42.5f @interface CreateInterLeterVC () @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (strong, nonatomic) NSMutableArray *shouJianArray; @property (strong, nonatomic) NSMutableArray *chaoShongArray; @property (weak, nonatomic) IBOutlet UICollectionView *shouJianCollectionView; @property (weak, nonatomic) IBOutlet UICollectionView *chaoSongColletionView; @property (weak, nonatomic) IBOutlet UIButton *shouJianBtn; @property (weak, nonatomic) IBOutlet UIButton *chaoSongBtn; @property (weak, nonatomic) IBOutlet UILabel *titleLabel; @property (strong, nonatomic) NewTopicTextView *defualtView; @property (weak, nonatomic) IBOutlet NewTopicTextView *textView; @property (nonatomic,assign) Boolean isShouJianRen; @property (nonatomic,assign) Boolean isChaoSongRen; @property (weak, nonatomic) IBOutlet UIButton *titleBtn; @property (strong, nonatomic) NSMutableArray *taskActionArray; @property (weak, nonatomic) IBOutlet UIButton *rightAddBtn; @property (strong, nonatomic) NSMutableArray *dataArray; /// 编辑标题 @property (strong, nonatomic) SmartBar *SmartBar; @property (assign, nonatomic) NSInteger InterLeterType; @property (weak, nonatomic) IBOutlet UITextField *shoujianrenTextField; @property (strong, nonatomic) shoujianrenResultView *resultView; @property (weak, nonatomic) IBOutlet UIView *shoujianrenView; @property (weak, nonatomic) IBOutlet UIView *headerView; @property (weak, nonatomic) IBOutlet UIView *inputTitleView; @property (weak, nonatomic) IBOutlet UIView *headerTopView; @end @implementation CreateInterLeterVC +(CreateInterLeterVC *)initCreateInterLeterVC{ CreateInterLeterVC *controller = [StoryboardManager.shared.interLeterHome instantiateViewControllerWithIdentifier:@"CreateInterLeterVC"]; return controller; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[IQKeyboardManager sharedManager] setEnable:YES]; } - (void)viewDidLoad { [super viewDidLoad]; self.textView.placeholder = @"请输入标题"; self.textView.delegate = self; self.fd_prefersNavigationBarHidden = YES; self.view.backgroundColor = RGB(255, 255, 255); self.fd_interactivePopDisabled = YES; self.InterLeterType = 1; switch (self.interLeterHanderType) { case InterLeterHanderType_Create: { WS(weakSelf); [self.titleBtn setAction:^{ weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected; //[weakSelf.titleBtn setImage:[UIImage imageNamed:@"chatmsg_notice_hideAll_icon"] forState:UIControlStateNormal]; NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray]; YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn]; view.menuColor = RGB(255, 255, 255); view.separatorColor = RGB(234, 234, 234); view.textColor = RGB(102, 102, 102); view.textFont = [UIFont systemFontOfSize:16.0]; view.menuCellHeight = 43.5; view.maxDisplayCount = 10; view.offset = -6; [view setDissmisBlock:^{ weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected; }]; [view show]; }]; [self getInterLeterDataCreate]; self.titleLabel.hidden = YES; } break; case InterLeterHanderType_Modify: { [self getData]; self.titleLabel.hidden = YES; } break; case InterLeterHanderType_Replay: { self.titleBtn.hidden = YES; self.titleLabel.hidden = NO; [self getData]; [self getInterLeterDataReplay]; } break; } self.chaoSongColletionView.tag = 202; self.shouJianCollectionView.tag = 101; [self.chaoSongColletionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"]; [self.shouJianCollectionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"]; [self registerNotification]; self.SmartBar.delegate = self; [self.view addSubview:self.SmartBar]; [self.SmartBar mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.view); make.height.mas_offset(BARHEIGHT); if (@available(iOS 11.0, *)) { make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT); } else { make.bottom.equalTo(self.view.mas_bottom).offset(BARHEIGHT); } }]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil]; //[self.textView addTarget:self action:@selector(shoujirenTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; [self.view addSubview:self.resultView]; [self.resultView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(self.view); make.top.equalTo(self.shoujianrenView.mas_bottom); }]; [self.resultView setHidden:YES]; } - (void)getData { [self.dataArray removeAllObjects]; WS(weakSelf) SHOWLOADING NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/missive/"),(long)self.interLeterId]; [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSLog(@"通知正文%@",responseObject); REMOVESHOW for (NSDictionary * dic in responseObject[@"AddresseeUserMiddles"]) { SelectModel * model = [[SelectModel alloc] init]; model.UserId = [[dic objectForKey:@"SourceId"] integerValue]; model.UserName = [dic objectForKey:@"SourceName"]; model.SourceId = [[dic objectForKey:@"SourceId"] integerValue]; model.SourceType = [[dic objectForKey:@"SourceType"] integerValue]; model.SourceName = [dic objectForKey:@"SourceName"]; [weakSelf.shouJianArray addObject:model]; } for (NSDictionary * dic in responseObject[@"CcUserMiddles"]) { SelectModel * model = [[SelectModel alloc] init]; model.UserId = [[dic objectForKey:@"SourceId"] integerValue]; model.UserName = [dic objectForKey:@"SourceName"]; model.SourceId = [[dic objectForKey:@"SourceId"] integerValue]; model.SourceType = [[dic objectForKey:@"SourceType"] integerValue]; model.SourceName = [dic objectForKey:@"SourceName"]; [weakSelf.chaoShongArray addObject:model]; } if ([responseObject[@"Title"] length] > 0) { weakSelf.textView.text = responseObject[@"Title"]; } for (NSDictionary * dict in responseObject[@"Data"]) { CreateInterLeterModel * model = [CreateInterLeterModel modelWithDictionary:dict]; [weakSelf.dataArray addObject:model]; } dispatch_async(dispatch_get_main_queue(), ^{ if ([weakSelf.shouJianArray count] > 0) { [weakSelf.shouJianCollectionView reloadData]; } if ([weakSelf.chaoShongArray count] > 0) { [weakSelf.chaoSongColletionView reloadData]; } [weakSelf.tableView reloadData]; }); } failure:^(NSError * _Nonnull error) { REMOVESHOW SHOWERROR([ZYCTool handerResultData:error]); }]; } - (void)shoujirenTextFieldDidChange:(NSNotification *)notification { return; NSString *tmpStr = [self.shoujianrenTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""]; if (tmpStr.length) { // 显示搜索结果 [self.resultView setHidden:NO]; } else { // 不显示搜索结果 [self.resultView setHidden:YES]; } } - (SmartBar *)SmartBar{ if (!_SmartBar) { _SmartBar = [[SmartBar alloc]init]; _SmartBar.delegate = self; } return _SmartBar; } - (void)getInterLeterDataCreate{ [self.dataArray removeAllObjects]; CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init]; titleModel.PlaceText = @"编辑内容"; titleModel.Content = @""; titleModel.Type = CollectDataType_Text; if(self.interLeterHanderType == InterLeterHanderType_Replay){ titleModel.Height = 55.5f * 3; }else{ titleModel.Height = 55.5f; } [self.dataArray addObject:titleModel]; [self.tableView reloadData]; if (self.isFromOtherPeople) { self.shouJianArray = self.shouJianArrTemp; } } - (void)getInterLeterDataReplay{ [self.dataArray removeAllObjects]; CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init]; titleModel.PlaceText = @"编辑内容"; titleModel.Content = @""; titleModel.Type = CollectDataType_Text; if(self.interLeterHanderType == InterLeterHanderType_Replay){ titleModel.Height = 55.5f * 3; }else{ titleModel.Height = 55.5f; } [self.dataArray addObject:titleModel]; [self.tableView reloadData]; [self.shouJianArray removeAllObjects]; for (NSDictionary * dict in self.replayDataArray) { SelectModel *model = [[SelectModel alloc] init]; model.SourceType = 0; model.SourceId = [dict[@"Id"] integerValue]; model.SourceName = dict[@"Name"]; [self.shouJianArray addObject:model]; } self.shouJianBtn.hidden =YES; [self.shouJianCollectionView reloadData]; self.textView.text = [NSString stringWithFormat:@"Re:%@",self.replayTitle]; } - (NSMutableArray *)dataArray{ if(!_dataArray){ _dataArray = [NSMutableArray new]; } return _dataArray; } -(NSMutableArray *)taskActionArray{ if(!_taskActionArray){ _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"写信件",@"匿名信", nil]; } return _taskActionArray; } -(NSMutableArray *)getMenuDataSource:(NSMutableArray *)titleArray{ NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init]; for(int i=0;i *)shouJianArray{ if(!_shouJianArray){ _shouJianArray = [[NSMutableArray alloc] init]; } return _shouJianArray; } -(NSMutableArray *)chaoShongArray{ if(!_chaoShongArray){ _chaoShongArray = [[NSMutableArray alloc] init]; } return _chaoShongArray; } -(IBAction)userDidSelectShouJianAction:(id)sender{ self.isShouJianRen = YES; self.isChaoSongRen = NO; [self selectPeople]; } -(IBAction)userDidSelectChaoShongAction:(id)sender{ self.isChaoSongRen = YES; self.isShouJianRen = NO; [self selectPeople]; } - (void)selectPeople{ AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init]; vc.isAllSelected = YES; Department *defaltGroupSetion = [[Department alloc]init]; defaltGroupSetion.Name = @"单位通讯录"; defaltGroupSetion.Id = 0; defaltGroupSetion.SourceId = 0; defaltGroupSetion.SourceType = 1; defaltGroupSetion.SourceName = @"单位通讯录"; defaltGroupSetion.MiddleType = 1; Department *myGroupSetion = [[Department alloc]init]; myGroupSetion.Name = @"自建通讯录"; myGroupSetion.Id = 0; myGroupSetion.MiddleType = 3; myGroupSetion.SourceType = 3; myGroupSetion.SourceId = 0; myGroupSetion.SourceName = @"自建通讯录"; vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy; vc.isDefalutPage = 1; vc.titleStr = @"选人"; [self.navigationController pushViewController:vc animated:YES]; } - (void)registerNotification{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shoujirenTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil]; } - (void)recviveChaoSongRen:(NSNotification *)notification{ if (self.isShouJianRen) { NSMutableArray * array = notification.userInfo[@"selectPeople"]; NSMutableArray * array0 = self.shouJianArray; NSMutableArray * array1 = notification.userInfo[@"selectPeople"]; if (array0.count == 0) { [self.shouJianArray addObjectsFromArray:array1]; }else{ for (NSInteger x = 0; x < array.count; x++) { for (NSInteger y = 0 ; y* array = notification.userInfo[@"selectPeople"]; NSMutableArray * array0 = self.chaoShongArray; NSMutableArray * array1 = notification.userInfo[@"selectPeople"]; if (array0.count == 0) { [self.chaoShongArray addObjectsFromArray:array1]; }else{ for (NSInteger x = 0; x < array.count; x++) { for (NSInteger y = 0 ; y 0) { cell.cell2ImagV.image = IMG(imageName); }else{ [cell.cell2ImagV sd_setImageWithURL:[NSURL URLWithString:model.File] placeholderImage:IMG(@"icon_weizhiwenjian")]; } [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; } break; case CollectDataType_IMG: { NewTopicCell *cell = [NewTopicCell configCell3:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; [cell.cell3ImagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrl]]; [cell.cell3CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; } break; case CollectDataType_Collect: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.text = model.Content; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2TitleL.text = model.FileName; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"收藏"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; } break; case CollectDataType_Note: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"noteBook_icon"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; } break; case CollectDataType_NoteFile: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记文件夹",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"find_1"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_CollectFile: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏文件夹",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"find_1"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Group: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@小组",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"笔记小组"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Topic: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"话题"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Notice: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的通知",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"通知图标"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_InterMail: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@站内信",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"站内信"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Meeting: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的会议",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"会议"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Article: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的文章",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"文章"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; case CollectDataType_Approval: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.cell2TitleL.text = model.FileName; cell.bgLabel.text = cell.textView.text; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.delegate = self; cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的审批",model.Author] KeyString:model.Author]; cell.cell2ImagV.image = IMG(@"审批"); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; }break; default: { NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath]; cell.textView.delegate = self; cell.textView.tag = TextViewTag + indexPath.row; cell.textView.placeholder = @""; cell.textView.text = model.Content; cell.bgLabel.text = cell.textView.text; cell.cell2TitleL.text = model.FileName; cell.cell2SubTitleL.text = model.FileSize; NSString * imageName = [ZYCTool getFileNameImage:model.File]; cell.cell2ImagV.image = IMG(imageName); [cell.cell2CloseBtn setAction:^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf.dataArray removeObjectAtIndex:indexPath.row]; [weakSelf.tableView reloadData]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; return cell; } break; } } #pragma mark - KeyBoard - (void)keyBoardWillShow:(NSNotification *)note { // 获取用户信息 NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo]; // 获取键盘高度 CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGFloat keyBoardHeight = keyBoardBounds.size.height; // 获取键盘动画时间 CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; // 定义好动作 WS(weakSelf); void (^animation)(void) = ^void(void) { [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) { if (@available(iOS 11.0, *)) { make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-keyBoardHeight); } else { make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-keyBoardHeight); } }]; }; if (animationTime > 0) { [UIView animateWithDuration:animationTime animations:animation completion:^(BOOL finished) { }]; } else { animation(); } } - (void)keyBoardWillHide:(NSNotification *)note { // 获取用户信息 NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo]; // 获取键盘动画时间 CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; // 定义好动作 WS(weakSelf); void (^animation)(void) = ^void(void) { [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) { if (@available(iOS 11.0, *)) { make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT); } else { make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT); } }]; }; if (animationTime > 0) { [UIView animateWithDuration:animationTime animations:animation]; } else { animation(); } } #pragma -mark UItextViewDelegate - (void)textFieldDidChange:(UITextField *)textField{ [self checkNoticData]; } - (void)textViewDidBeginEditing:(UITextView *)textView { self.defualtView = (NewTopicTextView *)textView; } - (void)textViewDidChange:(UITextView *)textView { [self checkNoticData]; self.defualtView = (NewTopicTextView *)textView; NSInteger index = textView.tag - TextViewTag; CreateInterLeterModel * model = [self.dataArray objectAtIndex:index]; model.Content = textView.text; CGRect bounds = textView.bounds; CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX); CGSize newSize = [textView sizeThatFits:maxSize]; if (model.Height != (newSize.height + 35.f)) { model.Height = newSize.height + 35.f; [self.tableView beginUpdates]; [self.tableView endUpdates]; } CGFloat H = 34.f; if (textView == self.textView) { CGRect bounds = textView.bounds; CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX); CGSize newSize = [textView sizeThatFits:maxSize]; if (H < newSize.height) { H = newSize.height; [self.headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, H + 116)]; [self.headerView updateConstraints]; [self.headerView setNeedsLayout]; [self.headerView layoutIfNeeded]; [self.inputTitleView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.bottom.right.mas_equalTo(self.headerView); make.top.mas_equalTo(self.headerTopView.mas_bottom); }]; [self.tableView setSectionHeaderHeight:H + 116]; [self.tableView beginUpdates]; [self.tableView endUpdates]; [self.tableView layoutIfNeeded]; } } } - (void)backAction:(id)sender{ WS(weakSelf); [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{ [weakSelf handerNotice:self.InterLeterType withAddress:2]; /// 草稿 } cancle:^(ShowKeepNoticeCloseType colseType) { if(colseType == ShowKeepNoticeCloseType1){ [weakSelf.navigationController popViewControllerAnimated:YES]; } }] show]; } - (void)menuAction:(id)sender{ [super menuAction:sender]; } #pragma mark - 提交信息 - (BOOL)checkNoticData { if (self.shouJianArray.count > 0 && (self.textView.text.length > 0 || self.dataArray.count > 0)) { self.rightAddBtn.enabled = YES; return YES; } self.rightAddBtn.enabled = NO; return NO; } - (IBAction)sendNoticManyPeople:(UIButton *)sender { ///1 正常 2 匿名 [self handerNotice:self.InterLeterType withAddress:1];//发送 } - (void)handerNotice:(NSInteger)NoticeType withAddress:(NSInteger)address{ SHOWLOADING NSMutableArray * array = [NSMutableArray array]; for (CreateInterLeterModel * model in self.dataArray) { switch (model.Type) { case CollectDataType_Text: { NSDictionary * dict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Content, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:dict]; } break; case CollectDataType_IMG: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":@"", @"Type":@(CollectDataType_IMG), @"Author":@"", @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_File: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_File), @"Author":@"", @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Collect: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":@"", @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Collect), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Note: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Note), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_NoteFile: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_NoteFile), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_CollectFile: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_CollectFile), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Group: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Group), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Topic: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Topic), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Notice: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Notice), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_InterMail: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_InterMail), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Meeting: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Meeting), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Article: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Article), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; case CollectDataType_Approval: { NSDictionary * dict = @{@"TextType":@"", @"File":model.File, @"FileName":model.FileName, @"Text":@"", @"Title":model.FileName, @"Type":@(CollectDataType_Approval), @"Author":model.Author, @"Content":@"", @"Id":@(model.FileId), @"CreatedData":@"" }; [array addObject:dict]; if (model.Text.length > 0) { NSDictionary * subDict = @{@"TextType":@"", @"File":@"", @"FileName":@"", @"Text":model.Text, @"Title":@"", @"Type":@(CollectDataType_Text), @"Author":@"", @"Content":@"", @"Id":@(0), @"CreatedData":@"" }; [array addObject:subDict]; } }break; default: break; } } NSMutableDictionary * dic = [NSMutableDictionary dictionary]; [dic setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"]; [dic setObject:[self arrayToJSONString:array] forKey:@"Content"]; [dic setValue:self.textView.text forKey:@"Title"]; if (self.isEdit) { [dic setValue:@(self.interLeterId) forKey:@"Id"]; } [dic setValue:@(NoticeType) forKey:@"MissiveType"]; [dic setValue:@(address) forKey:@"MissiveAttributeType"]; switch (self.interLeterHanderType) { case InterLeterHanderType_Create:{ [dic setValue:@(0) forKey:@"ParentId"]; }break; case InterLeterHanderType_Modify:{ [dic setValue:@(0) forKey:@"ParentId"]; }case InterLeterHanderType_Replay:{ [dic setValue:@(self.replayId) forKey:@"ParentId"]; } default: break; } [dic setValue:@(0) forKey:@"FolderId"]; // 收集收件人ID数组 NSMutableArray *array1 = [NSMutableArray array]; for (SelectModel *model in self.shouJianArray) { NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName}; [array1 addObject:param]; } [dic setValue:array1 forKey:@"AddresseeUserMiddles"]; // 收集抄送人ID数组 NSMutableArray *array2 = [NSMutableArray array]; for (SelectModel *model in self.chaoShongArray) { NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName}; [array2 addObject:param]; } [dic setValue:array2 forKey:@"CcUserMiddles"]; NSLog(@"请求参数%@",dic); [self sentNoticeRequeast:dic withNoticeType:NoticeType]; } - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{ WS(weakSelf); [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) { REMOVESHOW if(NoticeType == 1){ SHOWSUCCESS(@"站内信已经发送"); }else{ SHOWSUCCESS(@"站内信已经存放草稿箱"); } [weakSelf.navigationController popViewControllerAnimated:YES]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } - (NSString *)arrayToJSONString:(NSArray *)array { NSError *error = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; return jsonString; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } #pragma mark - SmartBarDelegate - (void)didSelectBarWithType:(SmartBarType)type { WS(weakSelf); switch (type) { case SmartBarPhoto: { [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) { } choosImgBlock:^(UIImage *image) { [weakSelf didSelectImage:image]; }]; } break; case SmartBarCamera: { [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) { } choosImgBlock:^(UIImage *image) { [weakSelf didSelectImage:image]; }]; } break; case SmartBarNotes: { [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray * _Nonnull noteArr) { NSLog(@"SmartBarNotes %@",noteArr); [weakSelf disSelectNoteBook:noteArr]; }]; } break; case SmartBarCollection: { [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray * _Nonnull collectArr) { NSLog(@"SmartBarCollection %@",collectArr); [weakSelf disSelectCollect:collectArr]; }]; } break; case SmartBarFile: { WS(weakSelf); [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) { } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) { SHOWLOADING [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) { REMOVESHOW NSLog(@"上传成功的文件%@",responseObject); [weakSelf fileSizeWithData:fileData withDict:responseObject[0] withName:fileName]; } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; }]; } break; default: break; } } - (void)fileSizeWithData:(NSData *)fileData withDict:(NSDictionary *)dict withName:(NSString *)fileName { unsigned long long size = [fileData length]; NSString * fileZise; if (size >= pow(10, 9)) { // size >= 1GB fileZise = [NSString stringWithFormat:@"%.2fGB", size / pow(10, 9)]; } else if (size >= pow(10, 6)) { // 1GB > size >= 1MB fileZise = [NSString stringWithFormat:@"%.2fMB", size / pow(10, 6)]; } else if (size >= pow(10, 3)) { // 1MB > size >= 1KB fileZise = [NSString stringWithFormat:@"%.2fKB", size / pow(10, 3)]; } else { // 1KB > size fileZise = [NSString stringWithFormat:@"%lluB", size]; } [self didSelectFile:dict withSize:fileZise withName:fileName]; } - (void)didSelectImage:(UIImage *)image { WS(weakSelf); NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post]; [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:@[UIImageJPEGRepresentation(image,1.0f)] pictureKey:@"file" success:^(id _Nonnull responseObject) { NSLog(@"%@",responseObject); NSDictionary * dict = responseObject[0]; CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.PlaceText = @"编辑内容"; model.Content = @""; model.ImageUrl = dict[@"AbsolutePath"]; model.FileId = [dict[@"FileId"] integerValue]; model.FileName = dict[@"FileName"]; model.Type = CollectDataType_IMG; CGFloat imgH = (SCREEN_WIDTH - 30) * 0.5 + 101.f; model.Height = imgH; [weakSelf.dataArray addObject:model]; dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadSection:0 withRowAnimation:UITableViewRowAnimationNone]; if (weakSelf.tableView.contentOffset.y > SCREEN_HEIGHT) { [weakSelf.tableView performSelector:@selector(scrollToBottom) withObject:nil afterDelay:0.1]; } }); } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } - (void)didSelectFile:(NSDictionary *)dict withSize:(NSString *)fileSize withName:(NSString *)fileName { CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.Title = @""; model.Content = @""; if ([dict[@"AbsolutePath"] length] == 0) { if ([fileName hasSuffix:@".doc"]) { model.File = @"icon_word"; }else if([fileName hasSuffix:@".xls"]){ model.File = @"icon_excel"; }else if([fileName hasSuffix:@".ppt"]){ model.File = @"icon_ppt"; }else if([fileName hasSuffix:@".pdf"]){ model.File = @"icon_pdf"; }else if([fileName hasSuffix:@".zip"]){ model.File = @"icon_yasuowenjian"; }else if([fileName hasSuffix:@".psd"]){ model.File = @"icon_psd"; }else if([fileName hasSuffix:@".ai"]){ model.File = @"icon_ai"; }else if([fileName hasSuffix:@".txt"]){ model.File = @"icon_txt"; }else if([fileName hasSuffix:@".html"]){ model.File = @"icon_html"; }else if([fileName hasSuffix:@".png"] || [fileName hasSuffix:@".JPG"] || [fileName hasSuffix:@".JPEG"] || [fileName hasSuffix:@".jpg"] || [fileName hasSuffix:@".jpeg"] || [fileName hasSuffix:@".PNG"] || [fileName hasSuffix:@".bmp"] || [fileName hasSuffix:@".BMP"]){ model.File = dict[@"AbsolutePath"]; }else{ model.File = @"icon_weizhiwenjian"; } } model.FileId = [dict[@"FileId"] integerValue]; model.FileName = dict[@"FileName"]; model.Type = CollectDataType_File; model.Height = 175.f; model.FileSize = fileSize; [self.dataArray addObject:model]; WS(weakSelf); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO]; }); }); } - (void)disSelectNoteBook:(NSMutableArray*_Nonnull )noteArr{ for (MyNoteBookSubModel *dataModel in noteArr ) { if (dataModel.AttributeValue == 1) { CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.Id = dataModel.MiddleId; model.FileId = dataModel.MiddleId; model.ImageUrl = dataModel.AvatarUrl; model.Author = dataModel.Name; model.FileName = dataModel.Title; model.Type = CollectDataType_Note; [self.dataArray addObject:model]; WS(weakSelf); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO]; }); }); }else{ CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.Id = dataModel.Id; model.FileId = dataModel.Id; model.ImageUrl = dataModel.AvatarUrl; model.Author = [AppUserModel sharedAppUserModel].Name; model.FileName = dataModel.FolderName; model.Type = CollectDataType_NoteFile; [self.dataArray addObject:model]; WS(weakSelf); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO]; }); }); } } } - (void)disSelectCollect:(NSMutableArray * _Nonnull) collectArr{ for (MyFavoriteSubModel *dataModel in collectArr ) { if(dataModel.AttributeValue == 1) { CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.Id = dataModel.CollectionDataId; model.FileId = dataModel.CollectionDataId; model.ImageUrl = dataModel.Data.AvatarUrl; model.Author = dataModel.Data.Author; model.FileName = dataModel.Title; model.Type = [ZYCTool returnDataType:dataModel.CollectionType]; [self.dataArray addObject:model]; WS(weakSelf); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO]; }); }); }else{ CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init]; model.Id = dataModel.Id; model.FileId = dataModel.Id; model.ImageUrl = dataModel.Data.AvatarUrl; model.Author = [AppUserModel sharedAppUserModel].Name; model.FileName = dataModel.FolderName; model.Type = CollectDataType_CollectFile; [self.dataArray addObject:model]; WS(weakSelf); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO]; }); }); } } } - (void)didSelectBarKeyBtnIsShow:(BOOL)isShow { [self.view endEditing:YES]; } - (void)didSelectBarAddBtnIsShow:(BOOL)isShow;{ [self.view endEditing:YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[IQKeyboardManager sharedManager] setEnable:NO]; WS(weakSelf); [self.view endEditing:YES]; [self.SmartBar downBar]; [self.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) { if (@available(iOS 11.0, *)) { make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT); } else { make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT); } }]; } - (shoujianrenResultView *)resultView { if (!_resultView) { _resultView = [shoujianrenResultView new]; } return _resultView; } - (NSString *)getFileNameImage:(NSString *)fileName { if ([fileName hasPrefix:@".doc"]) { return @"icon_word"; }else if([fileName hasPrefix:@".xls"]){ return @"icon_excel"; }else if([fileName hasPrefix:@".ppt"]){ return @"icon_ppt"; }else if([fileName hasPrefix:@".pdf"]){ return @"icon_pdf"; }else if([fileName hasPrefix:@".zip"]){ return @"icon_yasuowenjian"; }else if([fileName hasPrefix:@".psd"]){ return @"icon_psd"; }else if([fileName hasPrefix:@".ai"]){ return @"icon_ai"; }else if([fileName hasPrefix:@".txt"]){ return @"icon_txt"; }else if([fileName hasPrefix:@".html"]){ return @"icon_html"; }else{ return @"icon_weizhiwenjian"; } } @end