12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433 |
- //
- // MyTDTopicCreateVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/20.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyTDTopicCreateVC.h"
- #import "LYLPhotoTailoringTool.h"
- #import "FWZFileGetTool.h"
- #import "FWZGetNoteBookTool.h"
- #import "RichTextEditViewController.h"
- #import "AddLookUpUserSecondVC.h"
- #import "MyTDTopicSelectExtentVC.h"
- #import "FecordJoinWorkFlowListController.h"
- #import "_NoInputAccessoryView.h"
- #import "SelectSaveVC.h"
- #import "ShowBtn.h"
- #import "HomeDetailController.h"
- #import "ChatMsgNoticeDetailVC.h"
- #import "NoteBookDetailVC.h"
- #import "MyFavoriteVC.h"
- #import "NoteBookVC.h"
- #import "TDGroupInfoListVC.h"
- #import "TDInterLeterDetailVC.h"
- #import "FileOpenViewController.h"
- #import "EMChatFileShowVC.h"
- #import "MyTDTopicCreateVC.h"
- #import "NoticeUnreadVC.h"
- #import "DownFileViewController.h"
- #import "CountDataVC.h"
- #import "WorkFlowDetailsController.h"
- #import "MyTDGroupViewController.h"
- #import "MoveViewController.h"
- #import "ShowKeepNoticeAlert.h"
- #import "YCMenuView.h"
- #import "MyApprovalPageDetail.h"
- #import "OtherFavoriteVC.h"
- #import <objc/runtime.h>
- @interface MyTDTopicCreateVC ()<WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
- @property (weak, nonatomic) IBOutlet UIView *NavBarV;
- @property (weak, nonatomic) IBOutlet UIButton *DoneBtn;
- @property (nonatomic,strong) WKWebView *webView;
- @property (weak, nonatomic) IBOutlet UILabel *TitleL;
- @property (nonatomic,assign) CGFloat keyBoardH;
- @property (nonatomic,assign) BOOL isShoujianren;
- @property (nonatomic,assign) BOOL isChaosongren;
- @property (nonatomic,assign) NSInteger meetingId;
- @property (nonatomic,strong) NSMutableArray <SelectModel *> *chaoShongArray;
- @property (nonatomic,strong) NSMutableArray <SelectModel *> *shouJianArray;
- @property (nonatomic,strong) NSMutableArray * MeetingArray;
- @property (strong, nonatomic) ShowBtn * titleBtn;
- @property (copy, nonatomic) NSDictionary * H5JsonDict;
- @end
- @implementation MyTDTopicCreateVC
- + (MyTDTopicCreateVC *)initMyTDTopicCreateVC{
- MyTDTopicCreateVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicCreateVC"];
- return controller;
- }
- - (ShowBtn *)titleBtn
- {
- if (!_titleBtn) {
- _titleBtn = [[ShowBtn alloc] init];
- }
- return _titleBtn;
- }
- -(NSMutableArray *)getMenuDataSource{
- NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
- NSArray * titleArray = @[@"写信件",@"匿名信"];
- for(int i = 0;i < titleArray.count;i ++){
- NSString *titleStr = [titleArray objectAtIndex:i];
- WS(weakSelf);
- YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
- [weakSelf autoSizeBtn:action.title];
- if([@"写信件" isEqualToString:action.title]){
- weakSelf.MailType = 1;
- }
- else if ([@"匿名信" isEqualToString:action.title]){
- weakSelf.MailType = 2;
- }else{
- weakSelf.MailType = 1;
- }
- }];
- [menuDataSourceArray addObject:actionMenu];
- }
- return menuDataSourceArray;
- }
- - (void)autoSizeBtn:(NSString *)title
- {
- if (title.length > 9) {
- NSRange range1 = NSMakeRange(9, title.length - 9);
- NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
- [self.titleBtn setLabelTitle:resultStr1];
- }else{
- [self.titleBtn setLabelTitle:title];
- }
- WS(weakSelf);
- [self.titleBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.center.mas_equalTo(weakSelf.NavBarV);
- }];
- [self.NavBarV layoutIfNeeded];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.DoneBtn setEnabled:NO];
- self.fd_prefersNavigationBarHidden = YES;
- WS(weakSelf);
- [self.DoneBtn setAction:^{
- [weakSelf submit];
- }];
- [self.NavBarV addSubview:self.titleBtn];
- [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.mas_equalTo(weakSelf.NavBarV);
- }];
- [self.view addSubview:self.webView];
- [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(weakSelf.NavBarV.mas_bottom);
- make.left.right.mas_equalTo(weakSelf.view);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom);
- }
- }];
- self.webView.UIDelegate = self;
- // 导航代理
- self.webView.navigationDelegate = self;
- self.webView.scrollView.delegate = self;
- self.automaticallyAdjustsScrollViewInsets = YES;
- // NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/#/mobile/editor")];
- NSURL *pathUrl = [NSURL URLWithString:@"http://192.168.0.119:8080/#/mobile/editor"];
- NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
- [self.webView loadRequest:request];
- // [self hideWKWebviewKeyboardShortcutBar:self.webView];
-
- switch (self.type) {
- case CollectModel_Notice:
- {
- self.TitleL.hidden = NO;
- self.titleBtn.hidden = YES;
- self.TitleL.text = @"写通知";
- }
- break;
- case CollectModel_Toipc:
- {
- self.TitleL.hidden = NO;
- self.titleBtn.hidden = YES;
- self.TitleL.text = @"新建话题";
- }
- break;
- case CollectModel_NewTopic:
- {
- [self setDowntitleBtn];
- self.TitleL.hidden = YES;
- self.titleBtn.hidden = NO;
- if (self.FolderName.length > 0 && self.FolderId > 0) {
- [self autoSizeBtn:self.FolderName];
- }else{
- [self getTopicDefault];
- }
- }
- break;
- case CollectModel_NoteBook:
- {
- [self selectFold];
- self.TitleL.hidden = YES;
- self.titleBtn.hidden = NO;
- if (self.FolderName.length > 0 && self.FolderId > 0) {
- [self autoSizeBtn:self.FolderName];
- }else{
- [self getNoteDefault];
- }
- }
- break;
- case CollectModel_Group:
- {
- self.TitleL.hidden = NO;
- self.titleBtn.hidden = YES;
- self.TitleL.text = @"新建话题";
- }
- break;
- case CollectModel_InterMail:
- {
- if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
- self.TitleL.hidden = NO;
- self.titleBtn.hidden = YES;
- self.TitleL.text = @"回复信函";
- }else{
- self.TitleL.hidden = YES;
- self.titleBtn.hidden = NO;
- [self selectMailType];
- if (self.MailType == 2) {
- [self autoSizeBtn:@"匿名信"];
- }else{
- [self autoSizeBtn:@"写信件"];
- self.MailType = 1;
- }
- }
- }
- break;
- case CollectModel_meetMian:
- {
- self.TitleL.hidden = NO;
- self.titleBtn.hidden = YES;
- self.TitleL.text = @"会议纪要";
- }
- break;
- default:
- break;
- }
- if (self.isEdit) {
- if (self.isFromDraft) {
- [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
- }else{
- [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
- }
- }else{
- [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
- }
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangetitleBtn:) name:SELECTEXTENTSUCCESS object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectFolder:) name:NOTIFI_SELECTCREATENOTEFOLDER object:nil];
- }
- - (void)selectMailType
- {
- WS(weakSelf);
- [self.titleBtn setAction:^{
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource];
- 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 show];
- }];
- }
- - (void)upDateAction:(NSString *)action
- {
- [self.webView evaluateJavaScript:action completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data=====%@",data);
- NSLog(@"error=====%@",error);
- }];
- }
- - (void)getTopicDefault
- {
- WS(weakSelf);
- NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),21];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- dispatch_async(dispatch_get_main_queue(), ^{
- NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
- if (MiddleId > 0) {
- weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
- [weakSelf setSelectExtentText:[responseObject objectForKey:@"FolderName"]];
- }else{
- weakSelf.FolderId = 0;
- [weakSelf autoSizeBtn:@"选择发布范围"];
- }
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)getNoteDefault
- {
- WS(weakSelf);
- NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),4];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- dispatch_async(dispatch_get_main_queue(), ^{
- NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
- if (MiddleId > 0) {
- weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
- [weakSelf autoSizeBtn:[responseObject objectForKey:@"FolderName"]];
- }else{
- weakSelf.FolderId = 0;
- [weakSelf autoSizeBtn:@"根目录"];
- }
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)selectFold{
- WS(weakSelf);
- [self.titleBtn setAction:^{
- SelectSaveVC * vc = [SelectSaveVC initSelectSaveVC];
- vc.isFromCreateBookVc = YES;
- vc.TypeId = CreateNotesType;
- vc.ParentId = 0;
- vc.FolderIds = @[].mutableCopy;
- vc.titleStr = @"选择存入范围";
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- }
- - (void)selectFolder:(NSNotification *)noti
- {
- NSDictionary * dict = noti.userInfo;
- [self autoSizeBtn:[dict objectForKey:@"FolderName"]];
- self.FolderId = [[dict objectForKey:@"FolderId"] integerValue];
- }
- - (void)ChangetitleBtn:(NSNotification *)notification
- {
- NSDictionary * dict = notification.userInfo;
- NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
- self.FolderId = [[dict objectForKey:@"Id"] integerValue];
- if (title.length > 0) {
- [self setSelectExtentText:title];
- }
- }
- - (void)setDowntitleBtn
- {
- WS(weakSelf);
- [self.titleBtn setAction:^{
- MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
- vc.isSubVC = NO;
- vc.titleStr = @"选择发布范围";
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- }
- - (void)setSelectExtentText:(NSString *)title
- {
- if (title.length > 5) {
- NSRange range1 = NSMakeRange(5, title.length - 5);
- NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
- NSString * title = [NSString stringWithFormat:@"发布范围:%@",resultStr1];
- [self autoSizeBtn:title];
- }else{
- NSString * cusTitle = [NSString stringWithFormat:@"发布范围:%@",title];
- [self autoSizeBtn:cusTitle];
- }
- }
- #pragma mark - layload
- - (WKWebView *)webView
- {
- if (!_webView) {
- WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
- // 实例化对象
- WKUserContentController* userContent = [[WKUserContentController alloc] init];
- [userContent addScriptMessageHandler:self name:@"chosePic"];
- [userContent addScriptMessageHandler:self name:@"toPZ"];
- [userContent addScriptMessageHandler:self name:@"toBJ"];
- [userContent addScriptMessageHandler:self name:@"toSC"];
- [userContent addScriptMessageHandler:self name:@"toWJ"];
- [userContent addScriptMessageHandler:self name:@"keyBoard"];
- [userContent addScriptMessageHandler:self name:@"approverCheckUsers"];
- [userContent addScriptMessageHandler:self name:@"carbonCopyUsers"];
- [userContent addScriptMessageHandler:self name:@"changeState"];
- [userContent addScriptMessageHandler:self name:@"getType"];
- [userContent addScriptMessageHandler:self name:@"to"];
- [userContent addScriptMessageHandler:self name:@"getJp"];
- configuration.userContentController = userContent;
- WKPreferences *preferences = [WKPreferences new];
- preferences.javaScriptCanOpenWindowsAutomatically = YES;
- preferences.minimumFontSize = 10.0;
- configuration.preferences = preferences;
- // 初始化WKWebView
- _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
- _NoInputAccessoryView *noInputView = [[_NoInputAccessoryView alloc] init];
- [noInputView removeInputAccessoryViewFromWKWebView:_webView];
- // UI代理
- }
- return _webView;
- }
- -(NSMutableArray<SelectModel *> *)shouJianArray{
- if(!_shouJianArray){
- _shouJianArray = [[NSMutableArray alloc] init];
- }
- return _shouJianArray;
- }
- -(NSMutableArray<SelectModel *> *)chaoShongArray{
- if(!_chaoShongArray){
- _chaoShongArray = [[NSMutableArray alloc] init];
- }
- return _chaoShongArray;
- }
- #pragma mark - KeyBoard
- - (void)keyBoardWillShow:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘高度
- CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- if (IS_IPHONEX) {
- self.keyBoardH = keyBoardBounds.size.height - 34;
- }else{
- self.keyBoardH = keyBoardBounds.size.height;
- }
- [self.webView evaluateJavaScript:@"textFocus()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"keyShow");
- }];
- }
- - (void)keyBoardWillHide:(NSNotification *)note
- {
- self.keyBoardH = 0.f;
- [self.webView evaluateJavaScript:@"textBlur()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"keyHidden");
- }];
- }
- #pragma mark - WKScriptMessageHandler
- - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
- WS(weakSelf);
- NSLog(@"messageName:%@",message.name);
- if ([message.name isEqualToString:@"chosePic"]) {
- [self chatBarDidPhotoAction];
- }
- if ([message.name isEqualToString:@"toPZ"]) {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- } choosImgBlock:^(UIImage *image) {
- [weakSelf didSelectImage:@[image]];
- }];
- }
- if ([message.name isEqualToString:@"toBJ"]) {
- [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
- NSLog(@"SmartBarNotes %@",noteArr);
- [weakSelf disSelectNoteBook:noteArr];
- }];
- }
- if ([message.name isEqualToString:@"toSC"]) {
- [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
- NSLog(@"SmartBarCollection %@",collectArr);
- [weakSelf disSelectCollect:collectArr];
- }];
- }
- if ([message.name isEqualToString:@"toWJ"]) {
- [[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
- NSDictionary * dict = responseObject[0];
- if ([dict[@"FileType"] isEqualToString:@"image"]) {
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_Image,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
- [weakSelf upDateAction:jsonString];
- }else{
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_file,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
- [weakSelf upDateAction:jsonString];
- }
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }];
- }
- if ([message.name isEqualToString:@"keyBoard"]) {
- NSString *jsonString = [NSString stringWithFormat:@"getIosKeyBorad('%f')",self.keyBoardH];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- }];
- }
- if ([message.name isEqualToString:@"changeState"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger status = [message.body integerValue];
- if (status == 1) {
- // [self.DoneBtn setTitleColor:UIColorHex(0x3979D3) forState:UIControlStateNormal];
- [self.DoneBtn setEnabled:YES];
- }else{
- // [self.DoneBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
- [self.DoneBtn setEnabled:NO];
- }
- }
- if ([message.name isEqualToString:@"approverCheckUsers"]) {
- if (self.type == CollectModel_meetMian) {
- [self selectMeeting];
- }else{
- self.isShoujianren = YES;
- self.isChaosongren = NO;
- [self selectPeopleWithType:1];
- }
- }
- if ([message.name isEqualToString:@"getJp"]) {
- [self allowDisplayingKeyboardWithoutUserAction];
- }
- if ([message.name isEqualToString:@"carbonCopyUsers"]) {
- self.isShoujianren = NO;
- self.isChaosongren = YES;
- [self selectPeopleWithType:2];
- }
- if ([message.name isEqualToString:@"getType"]) {
- NSString *jsonString = [NSString stringWithFormat:@"getType('%d','%d','%ld','%@','%ld')",self.type,self.isEdit,(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.replayType];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- if (weakSelf.isReturn) {
- FlowAttachmentsModel * model = weakSelf.sendModel;
- NSInteger fileType = model.SoureTypeId;
- if (fileType == CollectModel_file) {
- if (model.MinUrl.length > 0) {
- fileType = CollectModel_Image;
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",model.Url,model.Title,(long)[self returnType:model.Url]];
- [weakSelf upDateAction:jsonString];
- }else{
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,(long)[AppUserModel sharedAppUserModel].Id];
- [weakSelf upDateAction:jsonString];
- }
- }else{
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,(long)[AppUserModel sharedAppUserModel].Id];
- [weakSelf upDateAction:jsonString];
- }
- }
- }];
- }
- if ([message.name isEqualToString:@"to"]) {
- NSLog(@"msgBody:%@",message.body);
- NSDictionary * dict = (NSDictionary *)message.body;
- [self pushVCWithDict:dict];
- }
- }
- - (void)pushVCWithDict:(NSDictionary *)dict
- {
- NSInteger Id = [dict[@"id"] integerValue];
- NSInteger userId = [dict[@"userId"] integerValue];
- NSString * title = dict[@"title"];
- WS(weakSelf);
- switch ([dict[@"type"] integerValue]) {
- case CollectModel_Group:
- {
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.GroupId = Id;
- vc.titleStr = title;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_file:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Image:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Aritle:{
- SHOWLOADING
- [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] 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 = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Toipc:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Toipc;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NewTopic:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NewTopic;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NoteBook:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NoteBook;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Collect:{
-
- }break;
- case CollectModel_CollectFile:{
- if (userId == [AppUserModel sharedAppUserModel].Id) {
- MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
- vc.listType = MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
- vc.listType = MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }break;
- case CollectModel_NoteFile:{
- NoteBookVC *vc = [NoteBookVC initNoteBookVC];
- vc.listType = MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = 0;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_InterMail:{
- TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
- vc.detailType = InterLeterDetialType_Sign;
- vc.interLeterID = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_meetDetail:{
- WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_work:{
- MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
- vc.pageType = Type_ONEC;
- vc.indexId = Id;
- vc.title = title;
- vc.TodoId = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_meetMian:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_meetMian;
- vc.Id = Id;
- [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;
- }
- }
- #pragma mark - 选择关联会议
- - (void)selectMeeting
- {
- WS(weakSelf);
- FecordJoinWorkFlowListController *vc = [[FecordJoinWorkFlowListController alloc] init];
- [vc setSelectedMeetingBlock:^(NSString * _Nonnull mid, NSString * _Nonnull meetingName) {
- weakSelf.meetingId = [mid integerValue];
- NSDictionary * dict = @{@"SourceId":mid,@"SourceName":meetingName};
- NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[dict]]];
- [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- }];
- vc.IsSelect = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)selectPeopleWithType:(NSInteger)type {
- 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 = type;
- Department *myGroupSetion = [[Department alloc]init];
- myGroupSetion.Name = @"我的分组";
- myGroupSetion.Id = 0;
- myGroupSetion.MiddleType = type;
- myGroupSetion.SourceType = 3;
- myGroupSetion.SourceId = 0;
- myGroupSetion.SourceName = @"我的分组";
- vc.isAllSelected = YES;
- vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
- vc.isDefalutPage = 1;
- vc.titleStr = self.type == CollectModel_meetMian ? @"发送范围" : @"选人";
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)recviveChaoSongRen:(NSNotification *)notification{
- if (self.isShoujianren) {
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
- if (array.count > 0) {
- NSLog(@"shouJianArray结果数据组%@",array);
- NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:array]];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- }
- }
- if (self.isChaosongren) {
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
- if (array.count > 0) {
- NSLog(@"chaoShongArray结果数据组%@",array);
- NSString *jsonString = [NSString stringWithFormat:@"getCarbonCopyUsersList('%@')",[self arrayToJSONModel:array]];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- }
- }
- }
- #pragma mark - 选择图片
- - (void)chatBarDidPhotoAction
- {
- WS(weakSelf);
- [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.allowPickingOriginalPhoto = NO;
- imagePickerVc.allowPickingGif = NO;
- [imagePickerVc setIsStatusBarDefault:YES];
- [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
- [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- PHAsset *asset = assets.firstObject;
- switch (asset.mediaType) {
- case PHAssetMediaTypeVideo: {
-
- } break;
- case PHAssetMediaTypeImage: {
- [weakSelf didSelectImage:photos];
- } break;
- case PHAssetMediaTypeAudio:
- break;
- case PHAssetMediaTypeUnknown:
- break;
- default: break;
- }
- }];
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }
- - (void)didSelectImage:(NSArray *)images
- {
- NSMutableArray * array = [NSMutableArray array];
- for (UIImage * image in images) {
- NSData *data = UIImageJPEGRepresentation(image, 1);
- [array addObject:data];
- }
- WS(weakSelf);
- NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
- [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:array pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- for (NSDictionary * dict in responseObject) {
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",dict[@"AbsolutePath"],dict[@"FileName"],(long)CollectModel_Image];
- [weakSelf upDateAction:jsonString];
- }
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- #pragma mark - 选择笔记
- - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
- for (MyNoteBookSubModel *dataModel in noteArr ) {
- if (dataModel.AttributeValue == 1) {
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteBook,dataModel.Title,(long)dataModel.MiddleId,dataModel.Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
- [self upDateAction:jsonString];
- }else{
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
- [self upDateAction:jsonString];
- }
- }
- }
- #pragma mark - 选择收藏
- - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
- for (MyFavoriteSubModel *dataModel in collectArr ) {
- if(dataModel.AttributeValue == 1)
- {
- if (dataModel.CollectionType == CollectModel_file) {
- if (dataModel.Data.MinFile.length > 0) {
- dataModel.CollectionType = CollectModel_Image;
- }
- }
- if (dataModel.CollectionType == 1) {
- dataModel.CollectionType = CollectModel_Aritle;
- }
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)dataModel.CollectionType,dataModel.Title,(long)dataModel.CollectionDataId,dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"" ,dataModel.Data.MinFile,dataModel.Data.File,(long)[AppUserModel sharedAppUserModel].Id];
- [self upDateAction:jsonString];
- }else{
- NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_CollectFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
- [self upDateAction:jsonString];
- }
- }
- }
- #pragma mark - WKScriptMessageHandler
- -(NSString *)convertToJson:(NSDictionary *)dict
- {
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString;
- if (!jsonData) {
- NSLog(@"%@",error);
- }else{
- jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
- NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
- NSRange range = {0,jsonString.length};
- //去掉字符串中的空格
- [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
- NSRange range2 = {0,mutStr.length};
- //去掉字符串中的换行符
- [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
- return mutStr;
- }
- #pragma mark - WKUIDelegete
- - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
- {
- NSLog(@"%@",message);
- completionHandler();
- }
- - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler
- {
- NSLog(@"223123");
- completionHandler(YES);
- }
- - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(nonnull NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(NSString * _Nullable))completionHandler
- {
- NSLog(@"323123");
- completionHandler(@"111");
- }
- #pragma mark - 提交富文本
- - (void)submit
- {
- NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"submit:%@",data);
- NSDictionary * dict = (NSDictionary *)data;
- switch (self.type) {
- case CollectModel_Notice:
- {
- [self submitNotice:dict];
- }
- break;
- case CollectModel_Toipc:
- {
- if (self.isEdit) {
- [self changeTopic:dict];
- }else{
- [self submitTopic:dict];
- }
- }
- break;
- case CollectModel_NewTopic:
- {
- if (self.isEdit) {
- [self changeNoteBook:dict];
- }else{
- [self submitNoteBook:dict];
- }
- }
- break;
- case CollectModel_Group:
- {
- if (self.isEdit) {
- [self changeTopic:dict];
- }else{
- [self submitTopic:dict];
- }
- }
- break;
- case CollectModel_meetMian:
- {
- if (self.isEdit) {
- [self changeMeeting:dict];
- }else{
- [self submitMeeting:dict];
- }
- }
- break;
- case CollectModel_NoteBook:
- {
- if (self.isEdit) {
- [self changeNoteBook:dict];
- }else{
- [self submitNoteBook:dict];
- }
- }
- break;
- case CollectModel_InterMail:
- {
- [self submitMail:dict];
- }
- break;
- default:
- break;
- }
- }];
- }
- #pragma mark - 提交通知
- - (void)submitNotice:(NSDictionary *)dict
- {
- self.H5JsonDict = dict;
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
-
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setValue:self.isDraft ? @(2) : @(1) forKey:@"NoticeType"];
- [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
- [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
- [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
- NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
- NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
- if ([self.H5JsonDict[@"Title"] length] == 0 &&
- [self.H5JsonDict[@"html"] length] == 0 &&
- addArray.count == 0 &&
- ccArray.count == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- if (self.isEdit) {
- [paraDict setObject:@(self.Id) forKey:@"Id"];
- [self sentChangeNotice:paraDict withNoticeType:self.isDraft ? 2 : 1];
- }else{
- [self sentNoticeRequeast:paraDict withNoticeType:self.isDraft ? 2 : 1];
- }
- }
- - (void)sentChangeNotice:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_NOTICE_EDIT) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if(NoticeType == 1){
- SHOWSUCCESS(@"通知已经发送");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- }else{
- SHOWSUCCESS(@"通知已经存放草稿箱");
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
- WS(weakSelf);
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:dic success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if(NoticeType == 1){
- SHOWSUCCESS(@"通知已经发送");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- }else{
- SHOWSUCCESS(@"通知已经存放草稿箱");
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - 提交话题
- - (void)submitTopic:(NSDictionary *)dict
- {
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
-
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setObject:@(self.Id) forKey:@"GroupId"];
- [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- SHOWLOADING
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- SHOWSUCCESS(@"创建成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf back1];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- #pragma mark - 修改话题
- - (void)changeTopic:(NSDictionary *)dict
- {
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
-
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@(self.Id) forKey:@"Id"];
- [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- WS(weakSelf);
- SHOWLOADING
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Topic_Update) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- SHOWSUCCESS(@"创建成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
-
- }];
- }
- #pragma mark - 提交会议纪要
- - (void)submitMeeting:(NSDictionary *)dict
- {
- NSString * html = dict[@"html"];
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
- if (self.meetingId > 0) {
- [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
- }
- [paraDict setObject:html forKey:@"Content"];
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- SHOWLOADING
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(MeetingSummary) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"创建成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)changeMeeting:(NSDictionary *)dict
- {
- NSString * html = dict[@"html"];
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
- if (self.meetingId > 0) {
- [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
- }
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- [paraDict setObject:html forKey:@"Content"];
- SHOWLOADING
- WS(weakSelf);
- NSString * meetId = [NSString stringWithFormat:@"%ld",(long)self.Id];
- [[HttpManager sharedHttpManager] PUTUrl:Host(UpdateMeeting(meetId)) parameters:paraDict success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"修改会议纪要成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - 提交笔记
- - (void)submitNoteBook:(NSDictionary *)dict
- {
- WS(weakSelf);
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
- [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
- SHOWERROR(@"请选择发布范围");
- return;
- }
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- SHOWSUCCESS(@"创建成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf back1];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)changeNoteBook:(NSDictionary *)dict
- {
- WS(weakSelf);
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setObject:@(self.Id) forKey:@"Id"];
- [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
- if ([dict[@"Title"] length] == 0 && html.length == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
- SHOWERROR(@"请选择发布范围");
- return;
- }
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_NoteBook_Modify) parameters:paraDict success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- SHOWSUCCESS(@"修改成功");
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - 提交站内信
- - (void)submitMail:(NSDictionary *)dict
- {
- self.H5JsonDict = dict;
- NSString * html = dict[@"html"];
- NSArray * jsonArray = dict[@"json"];
-
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- [paraDict setObject:dict[@"Title"] forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
- [paraDict setObject:html forKey:@"HtmlContent"];
- [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
- [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
- [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
- [paraDict setObject:@(self.MailType) forKey:@"MissiveType"];///1 正常 2 匿名
- [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
- [paraDict setObject:@(self.isDraft ? 2 : 1) forKey:@"MissiveAttributeType"];///1 发送 2 草稿
- NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
- NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
- if ([self.H5JsonDict[@"Title"] length] == 0 &&
- [self.H5JsonDict[@"html"] length] == 0 &&
- addArray.count == 0 &&
- ccArray.count == 0) {
- SHOWERROR(@"请填写标题或内容");
- return;
- }
- if (self.isEdit) {
- if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
-
- }else{
- [paraDict setObject:@(self.Id) forKey:@"Id"];
- }
- }
- [self sentMailRequeast:paraDict];
- }
- - (void)sentMailRequeast:(NSMutableDictionary *)dic
- {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic success:^(id _Nonnull responseObject) {
- if(weakSelf.isDraft){
- SHOWSUCCESS(@"站内信已经存放草稿箱");
- }else{
- SHOWSUCCESS(@"站内信已经发送");
- }
- if (weakSelf.replayType == MailReplayOne || weakSelf.replayType == MailReplayAll) {
- [weakSelf backMailList];
- }else{
- [weakSelf.navigationController popViewControllerAnimated:YES];
- }
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (NSString *)arrayToJSONModel:(NSArray *)array
- {
- NSMutableArray * mArray = [NSMutableArray array];
- for (SelectModel * model in array) {
- NSDictionary * dict = [model modelToJSONObject];
- [mArray addObject:@{@"SourceType":dict[@"SourceType"],@"SourceId":dict[@"SourceId"],@"SourceName":dict[@"SourceName"],@"MiddleType":@(self.type)}];
- }
- return [self arrayToJSONString:mArray];
- }
- - (NSString *)arrayTosumbitString:(NSArray *)array
- {
- NSError *error = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
- return mutStr;
- }
- - (NSString *)arrayToJSONString:(NSArray *)array
- {
- NSError *error = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
- NSRange range = {0,jsonString.length};
- //去掉字符串中的空格
- [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
- NSRange range2 = {0,mutStr.length};
- //去掉字符串中的换行符
- [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
- return mutStr;
- }
- - (void)dealloc {
- [self.webView stopLoading];
- self.webView.UIDelegate = nil;
- self.webView.navigationDelegate = nil;
- self.webView.scrollView.delegate = nil;
- [self.webView removeFromSuperview];
- WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
- [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
- completionHandler:^(NSArray * __nonnull records) {
- for (WKWebsiteDataRecord *record in records)
- {
- [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
- forDataRecords:@[record]
- completionHandler:^{
- NSLog(@"Cookies for %@ deleted successfully",record.displayName);
- }];
- }
- }];
- WKUserContentController *userCC = self.webView.configuration.userContentController;
- [userCC removeScriptMessageHandlerForName:@"chosePic"];
- [userCC removeScriptMessageHandlerForName:@"toPZ"];
- [userCC removeScriptMessageHandlerForName:@"toBJ"];
- [userCC removeScriptMessageHandlerForName:@"getJp"];
- [userCC removeScriptMessageHandlerForName:@"toSC"];
- [userCC removeScriptMessageHandlerForName:@"toWJ"];
- [userCC removeScriptMessageHandlerForName:@"keyBoard"];
- [userCC removeScriptMessageHandlerForName:@"getType"];
- [userCC removeScriptMessageHandlerForName:@"approverCheckUsers"];
- [userCC removeScriptMessageHandlerForName:@"carbonCopyUsers"];
- [userCC removeScriptMessageHandlerForName:@"changeState"];
- [userCC removeScriptMessageHandlerForName:@"to"];
- [userCC removeAllUserScripts];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- //- (void)hideWKWebviewKeyboardShortcutBar:(WKWebView *)webView {
- // UIView *targetView;
- //
- // for (UIView *view in webView.scrollView.subviews) {
- // if([[view.class description] hasPrefix:@"WKContent"]) {
- // targetView = view;
- // }
- // }
- // if (!targetView) {
- // return;
- // }
- // NSString *noInputAccessoryViewClassName = [NSString stringWithFormat:@"%@_NoInputAccessoryView", targetView.class.superclass];
- // Class newClass = NSClassFromString(noInputAccessoryViewClassName);
- //
- // if(newClass == nil) {
- // newClass = objc_allocateClassPair(targetView.class, [noInputAccessoryViewClassName cStringUsingEncoding:NSASCIIStringEncoding], 0);
- // if(!newClass) {
- // return;
- // }
- //
- // Method method = class_getInstanceMethod([_NoInputAccessoryView class], @selector(inputAccessoryView));
- //
- // class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
- //
- // objc_registerClassPair(newClass);
- // }
- //
- // object_setClass(targetView, newClass);
- //}
- - (CollectModelType)returnType:(NSString *)url
- {
- NSString * name = [[url pathExtension] lowercaseString];
- if([name hasSuffix:@"png"] || [name hasSuffix:@"jpg"] || [name hasSuffix:@"jpeg"] || [name hasSuffix:@"bmp"]){
- return CollectModel_Image;
- }else{
- return CollectModel_file;
- }
- }
- #pragma mark - 通知存草稿箱
- - (void)backAction:(id)sender{
- if (self.type == CollectModel_Notice || self.type == CollectModel_InterMail) {
- WS(weakSelf);
- NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"submit:%@",data);
- NSDictionary * dict = (NSDictionary *)data;
- NSArray * addArray = dict[@"AddresseeUserMiddles"];
- NSArray * ccArray = dict[@"CcUserMiddles"];
- if ([dict[@"Title"] length] == 0 &&
- [dict[@"html"] length] == 0 &&
- addArray.count == 0 &&
- ccArray.count == 0) {
- [super backAction:sender];
- }else{
- [weakSelf saveToDraftBox];
- }
- }];
-
- }else{
- [super backAction:sender];
- }
- }
- - (void)saveToDraftBox
- {
- WS(weakSelf);
- [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
- weakSelf.isDraft = YES;
- [weakSelf submit];
- } cancle:^(ShowKeepNoticeCloseType colseType) {
- if(colseType == ShowKeepNoticeCloseType1){
- [weakSelf.navigationController popViewControllerAnimated:YES];
- }
- }] show];
- }
- - (void)backMailList
- {
- for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
- if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
- [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
- return;
- }
- }
- }
- - (void)back1
- {
- if (self.isReturn) {
- for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
- if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CountDataVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyApprovalPageDetail")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowDetailsController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDGroupInfoListVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"HomeDetailController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicDetailVC")]) {
- [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
- return;
- }
- }
- }else{
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- #pragma mark - JS调起键盘
- - (void)allowDisplayingKeyboardWithoutUserAction {
- Class class = NSClassFromString(@"WKContentView");
- NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
- NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
- NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
- char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
-
- if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
- methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:";
- } else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
- methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
- }
-
- if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
- SEL selector = sel_getUid(methodSignature);
- Method method = class_getInstanceMethod(class, selector);
- IMP original = method_getImplementation(method);
- IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
- ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
- });
- method_setImplementation(method, override);
- } else {
- SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
- Method method = class_getInstanceMethod(class, selector);
- IMP original = method_getImplementation(method);
- IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
- ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
- });
- method_setImplementation(method, override);
- }
- }
- @end
|