MyTDTopicCreateVC.m 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658
  1. //
  2. // MyTDTopicCreateVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicCreateVC.h"
  9. #import "LYLPhotoTailoringTool.h"
  10. #import "FWZFileGetTool.h"
  11. #import "FWZGetNoteBookTool.h"
  12. #import "RichTextEditViewController.h"
  13. #import "AddLookUpUserSecondVC.h"
  14. #import "MyTDTopicSelectExtentVC.h"
  15. #import "FecordJoinWorkFlowListController.h"
  16. #import "_NoInputAccessoryView.h"
  17. #import "SelectSaveVC.h"
  18. #import "ShowBtn.h"
  19. #import "HomeDetailController.h"
  20. #import "ChatMsgNoticeDetailVC.h"
  21. #import "NoteBookDetailVC.h"
  22. #import "MyFavoriteVC.h"
  23. #import "NoteBookVC.h"
  24. #import "TDInterLeterDetailVC.h"
  25. #import "FileOpenViewController.h"
  26. #import "EMChatFileShowVC.h"
  27. #import "NoticeUnreadVC.h"
  28. #import "TDGroupInfoListVC.h"
  29. #import "DownFileViewController.h"
  30. #import "CountDataVC.h"
  31. #import "WorkFlowDetailsController.h"
  32. #import "MyTDGroupViewController.h"
  33. #import "MoveViewController.h"
  34. #import "ShowKeepNoticeAlert.h"
  35. #import "YCMenuView.h"
  36. #import "MyApprovalPageDetail.h"
  37. #import "OtherNoteBookVC.h"
  38. #import "OtherFavoriteVC.h"
  39. #import "TopicShowListView.h"
  40. #import "MyTDTopicBookVC.h"
  41. #import <objc/runtime.h>
  42. @interface MyTDTopicCreateVC ()<WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
  43. @property (weak, nonatomic) IBOutlet UIView *NavBarV;
  44. @property (weak, nonatomic) IBOutlet UIButton *DoneBtn;
  45. @property (nonatomic,strong) WKWebView *webView;
  46. @property (weak, nonatomic) IBOutlet UILabel *TitleL;
  47. @property (nonatomic,assign) CGFloat keyBoardH;
  48. @property (nonatomic,assign) BOOL isShoujianren;
  49. @property (nonatomic,assign) BOOL isChaosongren;
  50. @property (nonatomic,assign) BOOL isNull;
  51. @property (nonatomic,assign) NSInteger meetingId;
  52. @property (nonatomic,assign) NSInteger shouType;
  53. @property (nonatomic,strong) NSMutableArray <SelectModel *> *chaoShongArray;
  54. @property (nonatomic,strong) NSMutableArray <SelectModel *> *shouJianArray;
  55. @property (nonatomic,strong) NSMutableArray * MeetingArray;
  56. @property (strong, nonatomic) ShowBtn * titleBtn;
  57. @property (strong, nonatomic) TopicShowListView * menuListView;
  58. @property (assign, nonatomic) BOOL menuIsShow;
  59. @property (copy, nonatomic) NSDictionary * H5JsonDict;
  60. @end
  61. @implementation MyTDTopicCreateVC
  62. + (MyTDTopicCreateVC *)initMyTDTopicCreateVC{
  63. MyTDTopicCreateVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicCreateVC"];
  64. return controller;
  65. }
  66. - (TopicShowListView *)menuListView
  67. {
  68. if (!_menuListView) {
  69. _menuListView = [TopicShowListView share:self.NavBarV];
  70. }
  71. return _menuListView;
  72. }
  73. - (void)viewWillDisappear:(BOOL)animated
  74. {
  75. [super viewWillDisappear:animated];
  76. [self.titleBtn dismiss];
  77. self.menuIsShow = NO;
  78. [self.menuListView dismiss];
  79. }
  80. - (ShowBtn *)titleBtn
  81. {
  82. if (!_titleBtn) {
  83. _titleBtn = [[ShowBtn alloc] init];
  84. }
  85. return _titleBtn;
  86. }
  87. - (void)setShowData
  88. {
  89. self.menuIsShow = NO;
  90. WS(weakSelf);
  91. [self.titleBtn setAction:^{
  92. if (!weakSelf.menuIsShow) {
  93. [weakSelf.menuListView show];
  94. [weakSelf.titleBtn show];
  95. weakSelf.menuListView.ClickRowBlock = ^(BOOL isPush, NSInteger Id, NSString * _Nonnull Name) {
  96. [weakSelf.titleBtn dismiss];
  97. [weakSelf.menuListView dismiss];
  98. if (isPush) {
  99. MyTDTopicBookVC * vc = [MyTDTopicBookVC initMyTDTopicBookVC];
  100. vc.isSelect = YES;
  101. [weakSelf.navigationController pushViewController:vc animated:YES];
  102. }else{
  103. weakSelf.FolderId = Id;
  104. weakSelf.FolderName = Name;
  105. [weakSelf setSelectTopicBook:Name];
  106. }
  107. };
  108. weakSelf.menuListView.dismissBlock = ^{
  109. [weakSelf.titleBtn dismiss];
  110. };
  111. weakSelf.menuIsShow = YES;
  112. }else{
  113. weakSelf.menuIsShow = NO;
  114. [weakSelf.titleBtn dismiss];
  115. [weakSelf.menuListView dismiss];
  116. }
  117. }];
  118. }
  119. -(NSMutableArray *)getMenuDataSource{
  120. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  121. NSArray * titleArray = @[@"写通知",@"写信件",@"匿名信"];
  122. for(int i = 0;i < titleArray.count;i ++){
  123. NSString *titleStr = [titleArray objectAtIndex:i];
  124. WS(weakSelf);
  125. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  126. [weakSelf autoSizeBtn:action.title];
  127. if([@"写通知" isEqualToString:action.title]){
  128. weakSelf.MailType = 3;
  129. weakSelf.type = CollectModel_Notice;
  130. weakSelf.shouType = 5;
  131. }else if([@"写信件" isEqualToString:action.title]){
  132. weakSelf.MailType = 1;
  133. weakSelf.type = CollectModel_InterMail;
  134. weakSelf.shouType = 6;
  135. }else{
  136. weakSelf.MailType = 2;
  137. weakSelf.type = CollectModel_InterMail;
  138. weakSelf.shouType = 18;
  139. }
  140. }];
  141. [menuDataSourceArray addObject:actionMenu];
  142. }
  143. return menuDataSourceArray;
  144. }
  145. - (void)autoSizeBtn:(NSString *)title
  146. {
  147. if (title.length > 8) {
  148. NSRange range1 = NSMakeRange(8, title.length - 8);
  149. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  150. [self.titleBtn setLabelTitle:resultStr1];
  151. }else{
  152. [self.titleBtn setLabelTitle:title];
  153. }
  154. WS(weakSelf);
  155. [self.titleBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  156. make.center.mas_equalTo(weakSelf.NavBarV);
  157. }];
  158. [self.NavBarV layoutIfNeeded];
  159. }
  160. - (void)viewDidLoad {
  161. [super viewDidLoad];
  162. [self.DoneBtn setEnabled:NO];
  163. self.fd_prefersNavigationBarHidden = YES;
  164. WS(weakSelf);
  165. [self.DoneBtn setAction:^{
  166. [weakSelf submit];
  167. }];
  168. [self.NavBarV addSubview:self.titleBtn];
  169. [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.center.mas_equalTo(weakSelf.NavBarV);
  171. }];
  172. [self.view addSubview:self.webView];
  173. [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
  174. make.top.mas_equalTo(weakSelf.NavBarV.mas_bottom);
  175. make.left.right.mas_equalTo(weakSelf.view);
  176. if (@available(iOS 11.0, *)) {
  177. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  178. } else {
  179. make.bottom.equalTo(weakSelf.view.mas_bottom);
  180. }
  181. }];
  182. self.webView.UIDelegate = self;
  183. self.shouType = 5;
  184. // 导航代理
  185. self.webView.navigationDelegate = self;
  186. self.webView.scrollView.delegate = self;
  187. // self.automaticallyAdjustsScrollViewInsets = YES;
  188. NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/mobile/editor")];
  189. // NSURL *pathUrl = [NSURL URLWithString:@"http://192.168.0.111:8080/admin/mobile/editor"];
  190. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  191. [self.webView loadRequest:request];
  192. // [self hideWKWebviewKeyboardShortcutBar:self.webView];
  193. switch (self.type) {
  194. case CollectModel_Notice:
  195. {
  196. self.TitleL.hidden = YES;
  197. self.titleBtn.hidden = NO;
  198. // self.TitleL.text = @"写通知";
  199. [self selectMailType];
  200. switch (self.MailType) {
  201. case 1:
  202. {
  203. [self autoSizeBtn:@"写信件"];
  204. self.MailType = 1;
  205. }
  206. break;
  207. case 2:
  208. {
  209. [self autoSizeBtn:@"匿名信"];
  210. self.MailType = 2;
  211. }
  212. break;
  213. default:
  214. {
  215. [self autoSizeBtn:@"写通知"];
  216. self.MailType = 3;
  217. }
  218. break;
  219. }
  220. NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/mobile/editor")];
  221. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  222. [self.webView loadRequest:request];
  223. }
  224. break;
  225. case CollectModel_Toipc:
  226. {
  227. self.TitleL.hidden = NO;
  228. self.titleBtn.hidden = YES;
  229. self.TitleL.text = @"新建话题";
  230. }
  231. break;
  232. case CollectModel_NewTopic:
  233. {
  234. [self setShowData];
  235. self.TitleL.hidden = YES;
  236. self.titleBtn.hidden = NO;
  237. if (self.FolderName.length > 0) {
  238. [self autoSizeBtn:self.FolderName];
  239. }else{
  240. [self getTopicDefault];
  241. }
  242. }
  243. break;
  244. case CollectModel_NoteBook:
  245. {
  246. [self selectFold];
  247. self.TitleL.hidden = YES;
  248. self.titleBtn.hidden = NO;
  249. if (self.FolderId > 0) {
  250. [self autoSizeBtn:self.FolderName];
  251. }else{
  252. [self getNoteDefault];
  253. }
  254. }
  255. break;
  256. case CollectModel_Group:
  257. {
  258. self.TitleL.hidden = NO;
  259. self.titleBtn.hidden = YES;
  260. self.TitleL.text = @"新建话题";
  261. }
  262. break;
  263. case CollectModel_InterMail:
  264. {
  265. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  266. self.TitleL.hidden = NO;
  267. self.titleBtn.hidden = YES;
  268. self.TitleL.text = @"回复信函";
  269. }else{
  270. self.TitleL.hidden = YES;
  271. self.titleBtn.hidden = NO;
  272. [self selectMailType];
  273. switch (self.MailType) {
  274. case 1:
  275. {
  276. [self autoSizeBtn:@"写信件"];
  277. self.MailType = 1;
  278. }
  279. break;
  280. case 2:
  281. {
  282. [self autoSizeBtn:@"匿名信"];
  283. self.MailType = 2;
  284. }
  285. break;
  286. default:
  287. {
  288. [self autoSizeBtn:@"写通知"];
  289. self.MailType = 3;
  290. }
  291. break;
  292. }
  293. NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/mobile/editor")];
  294. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  295. [self.webView loadRequest:request];
  296. }
  297. }
  298. break;
  299. case CollectModel_meetMian:
  300. {
  301. self.TitleL.hidden = NO;
  302. self.titleBtn.hidden = YES;
  303. self.TitleL.text = @"会议纪要";
  304. }
  305. break;
  306. default:
  307. break;
  308. }
  309. if (self.isEdit) {
  310. if (self.isFromDraft) {
  311. [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
  312. }else{
  313. [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
  314. }
  315. }else{
  316. if (self.type == CollectModel_NewTopic || self.type == CollectModel_Toipc || self.type == CollectModel_NoteBook) {
  317. [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
  318. }else{
  319. [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
  320. }
  321. }
  322. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangeTopicBookBtn:) name:SELECTETOPICBOOK object:nil];
  323. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangetitleBtn:) name:SELECTEXTENTSUCCESS object:nil];
  324. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectMeetSearch:) name:SELECTMEETFECORD object:nil];
  325. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  326. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
  327. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  328. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectFolder:) name:NOTIFI_SELECTCREATENOTEFOLDER object:nil];
  329. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newFileSuccess:) name:NEWFILESUCCESS object:nil];
  330. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(SaveNoteBook:) name:NOTEBOOKSAVE object:nil];
  331. }
  332. - (void)selectMailType
  333. {
  334. WS(weakSelf);
  335. [self.titleBtn setAction:^{
  336. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource];
  337. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn];
  338. view.menuColor = RGB(255, 255, 255);
  339. view.separatorColor = RGB(234, 234, 234);
  340. view.textColor = RGB(102, 102, 102);
  341. view.textFont = [UIFont systemFontOfSize:16.0];
  342. view.menuCellHeight = 43.5;
  343. view.maxDisplayCount = 10;
  344. view.offset = -6;
  345. [view show];
  346. }];
  347. }
  348. - (void)upDateAction:(NSString *)action
  349. {
  350. [self.webView evaluateJavaScript:action completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  351. NSLog(@"data=====%@",data);
  352. NSLog(@"error=====%@",error);
  353. }];
  354. }
  355. - (void)getTopicDefault
  356. {
  357. WS(weakSelf);
  358. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),-4];
  359. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  360. dispatch_async(dispatch_get_main_queue(), ^{
  361. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  362. if (MiddleId > 0) {
  363. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  364. [weakSelf setSelectTopicBook:[responseObject objectForKey:@"FolderName"]];
  365. }else{
  366. weakSelf.FolderId = 0;
  367. [weakSelf autoSizeBtn:@"公开"];
  368. }
  369. });
  370. } failure:^(NSError * _Nonnull error) {
  371. }];
  372. }
  373. - (void)getNoteDefault
  374. {
  375. WS(weakSelf);
  376. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),4];
  377. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  378. dispatch_async(dispatch_get_main_queue(), ^{
  379. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  380. if (MiddleId > 0) {
  381. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  382. [weakSelf autoSizeBtn:[responseObject objectForKey:@"FolderName"]];
  383. }else{
  384. weakSelf.FolderId = 0;
  385. [weakSelf autoSizeBtn:@"根目录"];
  386. }
  387. });
  388. } failure:^(NSError * _Nonnull error) {
  389. }];
  390. }
  391. - (void)selectFold{
  392. WS(weakSelf);
  393. [self.titleBtn setAction:^{
  394. SelectSaveVC * vc = [SelectSaveVC initSelectSaveVC];
  395. vc.isFromCreateBookVc = YES;
  396. vc.TypeId = CreateNotesType;
  397. vc.ParentId = 0;
  398. vc.FolderIds = @[].mutableCopy;
  399. vc.titleStr = @"选择存入范围";
  400. [weakSelf.navigationController pushViewController:vc animated:YES];
  401. }];
  402. }
  403. - (void)newFileSuccess:(NSNotification *)noti
  404. {
  405. NSDictionary * dict = noti.userInfo;
  406. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  407. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  408. if (title.length > 0) {
  409. [self setSelectTopicBook:title];
  410. }
  411. }
  412. //- (void)SaveNoteBook:(NSNotification *)noti
  413. //{
  414. // NSLog(@"SaveNoteBook");
  415. //}
  416. - (void)selectFolder:(NSNotification *)noti
  417. {
  418. NSDictionary * dict = noti.userInfo;
  419. if (dict) {
  420. [self autoSizeBtn:[dict objectForKey:@"FolderName"]];
  421. self.FolderId = [[dict objectForKey:@"FolderId"] integerValue];
  422. }
  423. }
  424. - (void)ChangeTopicBookBtn:(NSNotification *)notification
  425. {
  426. NSDictionary * dict = notification.userInfo;
  427. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  428. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  429. if (title.length > 0) {
  430. [self setSelectTopicBook:title];
  431. }
  432. }
  433. - (void)ChangetitleBtn:(NSNotification *)notification
  434. {
  435. NSDictionary * dict = notification.userInfo;
  436. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  437. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  438. if (title.length > 0) {
  439. [self setSelectExtentText:title];
  440. }
  441. }
  442. - (void)setDowntitleBtn
  443. {
  444. WS(weakSelf);
  445. [self.titleBtn setAction:^{
  446. MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
  447. vc.isSubVC = NO;
  448. vc.isNoteBook = weakSelf.type == CollectModel_NoteBook ? YES : NO;
  449. vc.titleStr = @"选择发布范围";
  450. [weakSelf.navigationController pushViewController:vc animated:YES];
  451. }];
  452. }
  453. - (void)setSelectTopicBook:(NSString *)title
  454. {
  455. if (title.length > 8) {
  456. NSRange range1 = NSMakeRange(8, title.length - 8);
  457. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  458. NSString * title = [NSString stringWithFormat:@"%@",resultStr1];
  459. [self autoSizeBtn:title];
  460. }else{
  461. NSString * cusTitle = [NSString stringWithFormat:@"%@",title];
  462. [self autoSizeBtn:cusTitle];
  463. }
  464. }
  465. - (void)setSelectExtentText:(NSString *)title
  466. {
  467. if (title.length > 5) {
  468. NSRange range1 = NSMakeRange(5, title.length - 5);
  469. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  470. NSString * title = [NSString stringWithFormat:@"发布范围:%@",resultStr1];
  471. [self autoSizeBtn:title];
  472. }else{
  473. NSString * cusTitle = [NSString stringWithFormat:@"发布范围:%@",title];
  474. [self autoSizeBtn:cusTitle];
  475. }
  476. }
  477. #pragma mark - layload
  478. - (WKWebView *)webView
  479. {
  480. if (!_webView) {
  481. WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
  482. // 实例化对象
  483. WKUserContentController* userContent = [[WKUserContentController alloc] init];
  484. [userContent addScriptMessageHandler:self name:@"chosePic"];
  485. [userContent addScriptMessageHandler:self name:@"toPZ"];
  486. [userContent addScriptMessageHandler:self name:@"toBJ"];
  487. [userContent addScriptMessageHandler:self name:@"toSC"];
  488. [userContent addScriptMessageHandler:self name:@"toWJ"];
  489. [userContent addScriptMessageHandler:self name:@"keyBoard"];
  490. [userContent addScriptMessageHandler:self name:@"approverCheckUsers"];
  491. [userContent addScriptMessageHandler:self name:@"carbonCopyUsers"];
  492. [userContent addScriptMessageHandler:self name:@"changeState"];
  493. [userContent addScriptMessageHandler:self name:@"getType"];
  494. [userContent addScriptMessageHandler:self name:@"to"];
  495. [userContent addScriptMessageHandler:self name:@"getJp"];
  496. [userContent addScriptMessageHandler:self name:@"postH"];
  497. configuration.userContentController = userContent;
  498. WKPreferences *preferences = [WKPreferences new];
  499. preferences.javaScriptCanOpenWindowsAutomatically = YES;
  500. preferences.minimumFontSize = 10.0;
  501. configuration.preferences = preferences;
  502. // 初始化WKWebView
  503. _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
  504. _NoInputAccessoryView *noInputView = [[_NoInputAccessoryView alloc] init];
  505. [noInputView removeInputAccessoryViewFromWKWebView:_webView];
  506. // UI代理
  507. }
  508. return _webView;
  509. }
  510. -(NSMutableArray<SelectModel *> *)shouJianArray{
  511. if(!_shouJianArray){
  512. _shouJianArray = [[NSMutableArray alloc] init];
  513. }
  514. return _shouJianArray;
  515. }
  516. -(NSMutableArray<SelectModel *> *)chaoShongArray{
  517. if(!_chaoShongArray){
  518. _chaoShongArray = [[NSMutableArray alloc] init];
  519. }
  520. return _chaoShongArray;
  521. }
  522. #pragma mark - KeyBoard
  523. - (void)keyBoardWillShow:(NSNotification *)note
  524. {
  525. // 获取用户信息
  526. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  527. // 获取键盘高度
  528. CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
  529. if (IS_IPHONEX) {
  530. self.keyBoardH = keyBoardBounds.size.height - 34;
  531. }else{
  532. self.keyBoardH = keyBoardBounds.size.height;
  533. }
  534. WS(weakSelf);
  535. [self.webView evaluateJavaScript:@"textFocus()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  536. if (weakSelf.shouModel) {
  537. NSDictionary * dict = @{@"SourceId":@(weakSelf.shouModel.SourceId),@"SourceName":weakSelf.shouModel.SourceName};
  538. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[weakSelf arrayToJSONModel:@[dict]]];
  539. [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  540. NSLog(@"%@",error);
  541. }];
  542. }
  543. NSLog(@"keyShow");
  544. }];
  545. }
  546. - (void)keyBoardWillHide:(NSNotification *)note
  547. {
  548. self.keyBoardH = 0.f;
  549. [self.webView evaluateJavaScript:@"textBlur()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  550. NSLog(@"keyHidden");
  551. }];
  552. }
  553. #pragma mark - WKScriptMessageHandler
  554. - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
  555. WS(weakSelf);
  556. NSLog(@"messageName:%@",message.name);
  557. if ([message.name isEqualToString:@"chosePic"]) {
  558. [self chatBarDidPhotoAction];
  559. }
  560. if ([message.name isEqualToString:@"toPZ"]) {
  561. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  562. } choosImgBlock:^(UIImage *image) {
  563. [weakSelf didSelectImage:@[image]];
  564. }];
  565. }
  566. if ([message.name isEqualToString:@"toBJ"]) {
  567. [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
  568. NSLog(@"SmartBarNotes %@",noteArr);
  569. [weakSelf disSelectNoteBook:noteArr];
  570. }];
  571. }
  572. if ([message.name isEqualToString:@"toSC"]) {
  573. [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
  574. NSLog(@"SmartBarCollection %@",collectArr);
  575. [weakSelf disSelectCollect:collectArr];
  576. }];
  577. }
  578. if ([message.name isEqualToString:@"toWJ"]) {
  579. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  580. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  581. SHOWLOADING
  582. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  583. REMOVESHOW
  584. NSDictionary * dict = responseObject[0];
  585. if ([dict[@"FileType"] isEqualToString:@"image"]) {
  586. 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];
  587. [weakSelf upDateAction:jsonString];
  588. }else{
  589. 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];
  590. [weakSelf upDateAction:jsonString];
  591. }
  592. } failure:^(NSError * _Nonnull error) {
  593. REMOVESHOW
  594. }];
  595. }];
  596. }
  597. if ([message.name isEqualToString:@"keyBoard"]) {
  598. NSString *jsonString = [NSString stringWithFormat:@"getIosKeyBorad('%f')",self.keyBoardH];
  599. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  600. }];
  601. }
  602. if ([message.name isEqualToString:@"changeState"]) {
  603. NSLog(@"msgBody:%@",message.body);
  604. NSInteger status = [message.body integerValue];
  605. if (status == 1) {
  606. self.isNull = NO;
  607. [self.DoneBtn setEnabled:YES];
  608. }else{
  609. self.isNull = YES;
  610. [self.DoneBtn setEnabled:NO];
  611. }
  612. }
  613. if ([message.name isEqualToString:@"approverCheckUsers"]) {
  614. if (self.type == CollectModel_meetMian) {
  615. [self selectMeeting];
  616. }else{
  617. self.isShoujianren = YES;
  618. self.isChaosongren = NO;
  619. [self selectPeopleWithType:1];
  620. }
  621. }
  622. if ([message.name isEqualToString:@"getJp"]) {
  623. [self allowDisplayingKeyboardWithoutUserAction];
  624. }
  625. if ([message.name isEqualToString:@"carbonCopyUsers"]) {
  626. self.isShoujianren = NO;
  627. self.isChaosongren = YES;
  628. [self selectPeopleWithType:2];
  629. }
  630. if ([message.name isEqualToString:@"getType"]) {
  631. NSString *jsonString = [NSString stringWithFormat:@"getType('%d','%d','%ld','%@','%ld')",self.type,self.isEdit,(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.replayType];
  632. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  633. if (weakSelf.isReturn) {
  634. FlowAttachmentsModel * model = weakSelf.sendModel;
  635. NSInteger fileType = model.SoureTypeId;
  636. if (fileType == CollectModel_file) {
  637. if (model.MinUrl.length > 0) {
  638. fileType = CollectModel_Image;
  639. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",model.Url,model.Title,(long)[self returnType:model.Url]];
  640. [weakSelf upDateAction:jsonString];
  641. }else{
  642. 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)weakSelf.sendModel.SourceUserId];
  643. [weakSelf upDateAction:jsonString];
  644. }
  645. }else if(fileType == CollectModel_Text){
  646. [weakSelf.webView paste:weakSelf.sendModel.Title];
  647. }else if(fileType == CollectModel_Image){
  648. [weakSelf didSelectImage:@[weakSelf.sendImage]];
  649. }else{
  650. 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)weakSelf.sendModel.SourceUserId];
  651. [weakSelf upDateAction:jsonString];
  652. }
  653. }
  654. }];
  655. }
  656. if ([message.name isEqualToString:@"to"]) {
  657. NSLog(@"msgBody:%@",message.body);
  658. NSDictionary * dict = (NSDictionary *)message.body;
  659. [self pushVCWithDict:dict];
  660. }
  661. if ([message.name isEqualToString:@"postH"]) {
  662. NSInteger H = [message.body integerValue];
  663. if (H < 0) {
  664. [self.webView mas_updateConstraints:^(MASConstraintMaker *make) {
  665. if (@available(iOS 11.0, *)) {
  666. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(H);
  667. } else {
  668. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(H);
  669. }
  670. }];
  671. }else{
  672. [self.webView mas_updateConstraints:^(MASConstraintMaker *make) {
  673. if (@available(iOS 11.0, *)) {
  674. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  675. } else {
  676. make.bottom.equalTo(weakSelf.view.mas_bottom);
  677. }
  678. }];
  679. }
  680. [self.view setNeedsLayout];
  681. [self.view layoutIfNeeded];
  682. }
  683. }
  684. - (void)pushVCWithDict:(NSDictionary *)dict
  685. {
  686. NSInteger Id = [dict[@"id"] integerValue];
  687. NSInteger userId = [dict[@"userId"] integerValue];
  688. NSString * title = dict[@"title"];
  689. WS(weakSelf);
  690. switch ([dict[@"type"] integerValue]) {
  691. case CollectModel_Group:
  692. {
  693. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  694. vc.GroupId = Id;
  695. vc.titleStr = title;
  696. [self.navigationController pushViewController:vc animated:YES];
  697. }break;
  698. case CollectModel_file:{
  699. DownFileViewController * vc = [[DownFileViewController alloc] init];
  700. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  701. model.Title = title;
  702. model.SoureId = Id;
  703. model.Url = dict[@"bigurl"];
  704. model.MinUrl = dict[@"smallurl"];
  705. vc.model = model;
  706. [self.navigationController pushViewController:vc animated:YES];
  707. }break;
  708. case CollectModel_Image:{
  709. DownFileViewController * vc = [[DownFileViewController alloc] init];
  710. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  711. model.Title = title;
  712. model.SoureId = Id;
  713. model.Url = dict[@"bigurl"];
  714. model.MinUrl = dict[@"smallurl"];
  715. vc.model = model;
  716. [self.navigationController pushViewController:vc animated:YES];
  717. }break;
  718. case CollectModel_Aritle:{
  719. SHOWLOADING
  720. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] parameters:@{} success:^(id _Nonnull responseObject) {
  721. REMOVESHOW;
  722. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  723. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  724. // [homeDetail loadCurrentModel:itemModel];
  725. // [weakSelf.navigationController pushViewController:homeDetail animated:YES];
  726. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  727. vc.type = CollectModel_Aritle;
  728. vc.Id = itemModel.Id;
  729. [weakSelf.navigationController pushViewController:vc animated:YES];
  730. } failure:^(NSError * _Nonnull error) {
  731. SHOWERROR([ZYCTool handerResultData:error]);
  732. }];
  733. }break;
  734. case CollectModel_Notice:{
  735. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  736. vc.type = CollectModel_Notice;
  737. vc.Id = Id;
  738. [self.navigationController pushViewController:vc animated:YES];
  739. }break;
  740. case CollectModel_Toipc:{
  741. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  742. vc.type = CollectModel_Toipc;
  743. vc.Id = Id;
  744. [self.navigationController pushViewController:vc animated:YES];
  745. }break;
  746. case CollectModel_NewTopic:{
  747. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  748. vc.type = CollectModel_NewTopic;
  749. vc.Id = Id;
  750. [self.navigationController pushViewController:vc animated:YES];
  751. }break;
  752. case CollectModel_NoteBook:{
  753. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  754. vc.type = CollectModel_NoteBook;
  755. vc.Id = Id;
  756. [self.navigationController pushViewController:vc animated:YES];
  757. }break;
  758. case CollectModel_Collect:{
  759. }break;
  760. case CollectModel_CollectFile:{
  761. if (userId == [AppUserModel sharedAppUserModel].Id) {
  762. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  763. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  764. vc.ParentId = 0;
  765. vc.FolderId = Id;
  766. vc.myTitle = title;
  767. [self.navigationController pushViewController:vc animated:YES];
  768. }else{
  769. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  770. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  771. vc.ParentId = 0;
  772. vc.FolderId = Id;
  773. vc.myTitle = title;
  774. vc.VisitUserId = userId;
  775. [self.navigationController pushViewController:vc animated:YES];
  776. }
  777. }break;
  778. case CollectModel_NoteFile:{
  779. if (userId == [AppUserModel sharedAppUserModel].Id) {
  780. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  781. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  782. vc.ParentId = 0;
  783. vc.FolderId = Id;
  784. vc.myTitle = title;
  785. vc.VisitUserId = 0;
  786. [self.navigationController pushViewController:vc animated:YES];
  787. }else{
  788. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  789. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  790. vc.ParentId = 0;
  791. vc.FolderId = Id;
  792. vc.myTitle = title;
  793. vc.VisitUserId = userId;
  794. [self.navigationController pushViewController:vc animated:YES];
  795. }
  796. }break;
  797. case CollectModel_InterMail:{
  798. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  799. vc.type = CollectModel_InterMail;
  800. vc.Id = Id;
  801. [self.navigationController pushViewController:vc animated:YES];
  802. }break;
  803. case CollectModel_meetDetail:{
  804. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  805. [self.navigationController pushViewController:vc animated:YES];
  806. }break;
  807. case CollectModel_work:{
  808. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  809. vc.pageType = Type_ONEC;
  810. vc.indexId = Id;
  811. vc.title = title;
  812. vc.TodoId = Id;
  813. [self.navigationController pushViewController:vc animated:YES];
  814. }break;
  815. case CollectModel_meetMian:{
  816. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  817. vc.type = CollectModel_meetMian;
  818. vc.Id = Id;
  819. [self.navigationController pushViewController:vc animated:YES];
  820. }break;
  821. case CollectModel_financeCount:{
  822. CountDataVC *vc = [CountDataVC initCountDataVC];
  823. vc.index = 0;
  824. vc.titleStr = @"财务统计";
  825. [self.navigationController pushViewController:vc animated:YES];
  826. }break;
  827. case CollectModel_affairsCount:{
  828. CountDataVC *vc = [CountDataVC initCountDataVC];
  829. vc.index = 1;
  830. vc.titleStr = @"人事统计";
  831. [self.navigationController pushViewController:vc animated:YES];
  832. }break;
  833. case CollectModel_publishCount:{
  834. CountDataVC *vc = [CountDataVC initCountDataVC];
  835. vc.index = 2;
  836. vc.titleStr = @"出版统计";
  837. [self.navigationController pushViewController:vc animated:YES];
  838. }break;
  839. default:
  840. break;
  841. }
  842. }
  843. #pragma mark - 选择关联会议
  844. - (void)selectMeeting
  845. {
  846. WS(weakSelf);
  847. FecordJoinWorkFlowListController *vc = [[FecordJoinWorkFlowListController alloc] init];
  848. [vc setSelectedMeetingBlock:^(NSString * _Nonnull mid, NSString * _Nonnull meetingName) {
  849. weakSelf.meetingId = [mid integerValue];
  850. NSDictionary * dict = @{@"SourceId":mid,@"SourceName":meetingName};
  851. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[dict]]];
  852. [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  853. NSLog(@"data:%@",data);
  854. NSLog(@"error:%@",error);
  855. }];
  856. }];
  857. vc.IsSelect = YES;
  858. [self.navigationController pushViewController:vc animated:YES];
  859. }
  860. - (void)selectMeetSearch:(NSNotification *)notification
  861. {
  862. NSDictionary * dict = notification.userInfo;
  863. self.meetingId = [[dict objectForKey:@"Id"] integerValue];
  864. NSDictionary * paraDict = @{@"SourceId":[dict objectForKey:@"Id"],@"SourceName":[dict objectForKey:@"Name"]};
  865. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[paraDict]]];
  866. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  867. NSLog(@"data:%@",data);
  868. NSLog(@"error:%@",error);
  869. }];
  870. }
  871. - (void)selectPeopleWithType:(NSInteger)type {
  872. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  873. vc.isAllSelected = YES;
  874. Department *defaltGroupSetion = [[Department alloc]init];
  875. defaltGroupSetion.Name = @"单位通讯录";
  876. defaltGroupSetion.Id = 0;
  877. defaltGroupSetion.SourceId = 0;
  878. defaltGroupSetion.SourceType = 1;
  879. defaltGroupSetion.SourceName = @"单位通讯录";
  880. defaltGroupSetion.MiddleType = type;
  881. Department *myGroupSetion = [[Department alloc]init];
  882. myGroupSetion.Name = @"自建通讯录";
  883. myGroupSetion.Id = 0;
  884. myGroupSetion.MiddleType = type;
  885. myGroupSetion.SourceType = 3;
  886. myGroupSetion.SourceId = 0;
  887. myGroupSetion.SourceName = @"自建通讯录";
  888. vc.isAllSelected = YES;
  889. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  890. vc.isDefalutPage = 1;
  891. vc.titleStr = self.type == CollectModel_meetMian ? @"发送范围" : @"选人";
  892. USERDEFAULTSSET([NSMutableArray array], MAILSELECT);
  893. [self.navigationController pushViewController:vc animated:YES];
  894. }
  895. - (void)recviveChaoSongRen:(NSNotification *)notification{
  896. if (self.isShoujianren) {
  897. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  898. if (array.count > 0) {
  899. NSLog(@"shouJianArray结果数据组%@",array);
  900. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:array]];
  901. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  902. NSLog(@"data:%@",data);
  903. NSLog(@"error:%@",error);
  904. }];
  905. }
  906. }
  907. if (self.isChaosongren) {
  908. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  909. if (array.count > 0) {
  910. NSLog(@"chaoShongArray结果数据组%@",array);
  911. NSString *jsonString = [NSString stringWithFormat:@"getCarbonCopyUsersList('%@')",[self arrayToJSONModel:array]];
  912. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  913. NSLog(@"data:%@",data);
  914. NSLog(@"error:%@",error);
  915. }];
  916. }
  917. }
  918. }
  919. #pragma mark - 选择图片
  920. - (void)chatBarDidPhotoAction
  921. {
  922. WS(weakSelf);
  923. [self.view endEditing:YES];
  924. TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil];
  925. [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
  926. leftButton.hidden = YES;
  927. }];
  928. imagePickerVc.showSelectBtn = NO;
  929. imagePickerVc.allowCrop = YES;
  930. imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
  931. imagePickerVc.allowTakePicture = NO;
  932. imagePickerVc.allowTakeVideo = NO;
  933. imagePickerVc.allowPickingOriginalPhoto = NO;
  934. imagePickerVc.allowPickingGif = NO;
  935. [imagePickerVc setIsStatusBarDefault:YES];
  936. [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
  937. [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
  938. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  939. PHAsset *asset = assets.firstObject;
  940. switch (asset.mediaType) {
  941. case PHAssetMediaTypeVideo: {
  942. } break;
  943. case PHAssetMediaTypeImage: {
  944. [weakSelf didSelectImage:photos];
  945. } break;
  946. case PHAssetMediaTypeAudio:
  947. break;
  948. case PHAssetMediaTypeUnknown:
  949. break;
  950. default: break;
  951. }
  952. }];
  953. [self presentViewController:imagePickerVc animated:YES completion:nil];
  954. }
  955. - (void)didSelectImage:(NSArray *)images
  956. {
  957. NSMutableArray * array = [NSMutableArray array];
  958. for (UIImage * image in images) {
  959. NSData *data = UIImageJPEGRepresentation(image, 1);
  960. [array addObject:data];
  961. }
  962. WS(weakSelf);
  963. NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
  964. [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:array pictureKey:@"file" success:^(id _Nonnull responseObject) {
  965. NSLog(@"%@",responseObject);
  966. for (NSDictionary * dict in responseObject) {
  967. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",dict[@"AbsolutePath"],dict[@"FileName"],(long)CollectModel_Image];
  968. [weakSelf upDateAction:jsonString];
  969. }
  970. } failure:^(NSError * _Nonnull error) {
  971. }];
  972. }
  973. #pragma mark - 选择笔记
  974. - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
  975. for (MyNoteBookSubModel *dataModel in noteArr ) {
  976. if (dataModel.AttributeValue == 1) {
  977. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteBook,dataModel.Title,(long)dataModel.MiddleId,dataModel.Name,@"",@"",(long)dataModel.UserId];
  978. [self upDateAction:jsonString];
  979. }else{
  980. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)dataModel.UserId];
  981. [self upDateAction:jsonString];
  982. }
  983. }
  984. }
  985. #pragma mark - 选择收藏
  986. - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
  987. for (MyFavoriteSubModel *dataModel in collectArr ) {
  988. if(dataModel.AttributeValue == 1)
  989. {
  990. NSString * author = @"";
  991. switch (dataModel.CollectionType) {
  992. case CollectModel_file:
  993. {
  994. if (dataModel.Data.MinFile.length > 0) {
  995. dataModel.CollectionType = CollectModel_Image;
  996. }
  997. }
  998. break;
  999. case CollectModel_Text:///1
  1000. {
  1001. dataModel.CollectionType = CollectModel_Aritle;
  1002. }
  1003. break;
  1004. case CollectModel_CollectFile:
  1005. {
  1006. dataModel.CollectionType = CollectModel_Aritle;
  1007. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的收藏",dataModel.Data.Author] : @"";
  1008. }
  1009. break;
  1010. case CollectModel_NoteFile:
  1011. {
  1012. dataModel.CollectionType = CollectModel_Aritle;
  1013. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的笔记",dataModel.Data.Author] : @"";
  1014. }
  1015. break;
  1016. default:
  1017. {
  1018. author = dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"";
  1019. }
  1020. break;
  1021. }
  1022. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)dataModel.CollectionType,dataModel.Title,(long)dataModel.CollectionDataId,author,dataModel.Data.MinFile,dataModel.Data.File,(long)(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId)];
  1023. [self upDateAction:jsonString];
  1024. }else{
  1025. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_CollectFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId)];
  1026. [self upDateAction:jsonString];
  1027. }
  1028. }
  1029. }
  1030. #pragma mark - WKScriptMessageHandler
  1031. -(NSString *)convertToJson:(NSDictionary *)dict
  1032. {
  1033. NSError *error;
  1034. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
  1035. NSString *jsonString;
  1036. if (!jsonData) {
  1037. NSLog(@"%@",error);
  1038. }else{
  1039. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  1040. }
  1041. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1042. NSRange range = {0,jsonString.length};
  1043. //去掉字符串中的空格
  1044. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  1045. NSRange range2 = {0,mutStr.length};
  1046. //去掉字符串中的换行符
  1047. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  1048. return mutStr;
  1049. }
  1050. #pragma mark - WKUIDelegete
  1051. - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
  1052. {
  1053. NSLog(@"%@",message);
  1054. completionHandler();
  1055. }
  1056. - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler
  1057. {
  1058. NSLog(@"223123");
  1059. completionHandler(YES);
  1060. }
  1061. - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(nonnull NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(NSString * _Nullable))completionHandler
  1062. {
  1063. NSLog(@"323123");
  1064. completionHandler(@"111");
  1065. }
  1066. #pragma mark - 提交富文本
  1067. - (void)submit
  1068. {
  1069. NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
  1070. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  1071. NSLog(@"submit:%@",data);
  1072. NSDictionary * dict = (NSDictionary *)data;
  1073. switch (self.type) {
  1074. case CollectModel_Notice:
  1075. {
  1076. [self submitNotice:dict];
  1077. }
  1078. break;
  1079. case CollectModel_Toipc:
  1080. {
  1081. if (self.isEdit) {
  1082. [self changeTopic:dict];
  1083. }else{
  1084. [self submitTopic:dict];
  1085. }
  1086. }
  1087. break;
  1088. case CollectModel_NewTopic:
  1089. {
  1090. if (self.isEdit) {
  1091. [self changeNoteBook:dict];
  1092. }else{
  1093. [self submitNoteBook:dict];
  1094. }
  1095. }
  1096. break;
  1097. case CollectModel_Group:
  1098. {
  1099. if (self.isEdit) {
  1100. [self changeTopic:dict];
  1101. }else{
  1102. [self submitTopic:dict];
  1103. }
  1104. }
  1105. break;
  1106. case CollectModel_meetMian:
  1107. {
  1108. if (self.isEdit) {
  1109. [self changeMeeting:dict];
  1110. }else{
  1111. [self submitMeeting:dict];
  1112. }
  1113. }
  1114. break;
  1115. case CollectModel_NoteBook:
  1116. {
  1117. if (self.isEdit) {
  1118. [self changeNoteBook:dict];
  1119. }else{
  1120. [self submitNoteBook:dict];
  1121. }
  1122. }
  1123. break;
  1124. case CollectModel_InterMail:
  1125. {
  1126. [self submitNotice:dict];
  1127. }
  1128. break;
  1129. default:
  1130. break;
  1131. }
  1132. }];
  1133. }
  1134. #pragma mark - 提交通知
  1135. - (void)submitNotice:(NSDictionary *)dict
  1136. {
  1137. self.H5JsonDict = dict;
  1138. NSString * html = dict[@"html"];
  1139. NSArray * jsonArray = dict[@"json"];
  1140. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1141. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1142. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1143. [paraDict setValue:self.isDraft ? @(2) : @(1) forKey:@"NoticeType"];
  1144. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1145. [paraDict setObject:html forKey:@"HtmlContent"];
  1146. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  1147. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1148. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  1149. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  1150. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  1151. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  1152. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  1153. [self.H5JsonDict[@"html"] length] == 0 &&
  1154. addArray.count == 0 &&
  1155. ccArray.count == 0) {
  1156. SHOWERROR(@"请填写标题或内容");
  1157. return;
  1158. }
  1159. if (self.isEdit) {
  1160. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1161. [self sentChangeNotice:paraDict withNoticeType:self.isDraft ? 2 : 1];
  1162. }else{
  1163. [self sentNoticeRequeast:paraDict withNoticeType:self.isDraft ? 2 : 1];
  1164. }
  1165. }
  1166. - (void)sentChangeNotice:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  1167. WS(weakSelf);
  1168. [[HttpManager sharedHttpManager] POSTUrl:Host(API_NOTICE_EDIT) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1169. REMOVESHOW
  1170. if(NoticeType == 1){
  1171. SHOWSUCCESS(@"通知已经发送");
  1172. if (weakSelf.upDateBlock) {
  1173. weakSelf.upDateBlock();
  1174. }
  1175. }else{
  1176. SHOWSUCCESS(@"通知已经存放草稿箱");
  1177. }
  1178. [weakSelf.navigationController popViewControllerAnimated:YES];
  1179. } failure:^(NSError * _Nonnull error) {
  1180. SHOWERROR([ZYCTool handerResultData:error]);
  1181. }];
  1182. }
  1183. - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  1184. WS(weakSelf);
  1185. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:dic success:^(id _Nonnull responseObject) {
  1186. REMOVESHOW
  1187. if(NoticeType == 1){
  1188. SHOWSUCCESS(@"通知已经发送");
  1189. if (weakSelf.upDateBlock) {
  1190. weakSelf.upDateBlock();
  1191. }
  1192. }else{
  1193. SHOWSUCCESS(@"通知已经存放草稿箱");
  1194. }
  1195. [weakSelf.navigationController popViewControllerAnimated:YES];
  1196. } failure:^(NSError * _Nonnull error) {
  1197. SHOWERROR([ZYCTool handerResultData:error]);
  1198. }];
  1199. }
  1200. #pragma mark - 提交话题
  1201. - (void)submitTopic:(NSDictionary *)dict
  1202. {
  1203. NSString * html = dict[@"html"];
  1204. NSArray * jsonArray = dict[@"json"];
  1205. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1206. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1207. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1208. [paraDict setObject:@(self.Id) forKey:@"GroupId"];
  1209. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1210. [paraDict setObject:html forKey:@"HtmlContent"];
  1211. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1212. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1213. SHOWERROR(@"请填写标题或内容");
  1214. return;
  1215. }
  1216. SHOWLOADING
  1217. WS(weakSelf);
  1218. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1219. NSLog(@"%@",responseObject);
  1220. REMOVESHOW
  1221. SHOWSUCCESS(@"创建成功");
  1222. if (weakSelf.upDateBlock) {
  1223. weakSelf.upDateBlock();
  1224. }
  1225. [weakSelf back1];
  1226. } failure:^(NSError * _Nonnull error) {
  1227. REMOVESHOW
  1228. SHOWERROR([ZYCTool handerResultData:error])
  1229. }];
  1230. }
  1231. #pragma mark - 修改话题
  1232. - (void)changeTopic:(NSDictionary *)dict
  1233. {
  1234. NSString * html = dict[@"html"];
  1235. NSArray * jsonArray = dict[@"json"];
  1236. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1237. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1238. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1239. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1240. [paraDict setObject:html forKey:@"HtmlContent"];
  1241. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1242. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1243. SHOWERROR(@"请填写标题或内容");
  1244. return;
  1245. }
  1246. WS(weakSelf);
  1247. SHOWLOADING
  1248. [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Topic_Update) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1249. NSLog(@"%@",responseObject);
  1250. REMOVESHOW
  1251. SHOWSUCCESS(@"创建成功");
  1252. if (weakSelf.upDateBlock) {
  1253. weakSelf.upDateBlock();
  1254. }
  1255. [weakSelf.navigationController popViewControllerAnimated:YES];
  1256. } failure:^(NSError * _Nonnull error) {
  1257. REMOVESHOW
  1258. }];
  1259. }
  1260. #pragma mark - 提交会议纪要
  1261. - (void)submitMeeting:(NSDictionary *)dict
  1262. {
  1263. NSString * html = dict[@"html"];
  1264. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1265. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1266. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1267. if (self.meetingId > 0) {
  1268. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1269. }
  1270. [paraDict setObject:html forKey:@"Content"];
  1271. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1272. SHOWERROR(@"请填写标题或内容");
  1273. return;
  1274. }
  1275. SHOWLOADING
  1276. WS(weakSelf);
  1277. [[HttpManager sharedHttpManager] POSTUrl:Host(MeetingSummary) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1278. REMOVESHOW
  1279. SHOWSUCCESS(@"创建成功");
  1280. if (weakSelf.upDateBlock) {
  1281. weakSelf.upDateBlock();
  1282. }
  1283. [weakSelf.navigationController popViewControllerAnimated:YES];
  1284. } failure:^(NSError * _Nonnull error) {
  1285. REMOVESHOW
  1286. SHOWERROR([ZYCTool handerResultData:error]);
  1287. }];
  1288. }
  1289. - (void)changeMeeting:(NSDictionary *)dict
  1290. {
  1291. NSString * html = dict[@"html"];
  1292. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1293. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1294. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1295. if (self.meetingId > 0) {
  1296. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1297. }
  1298. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1299. SHOWERROR(@"请填写标题或内容");
  1300. return;
  1301. }
  1302. [paraDict setObject:html forKey:@"Content"];
  1303. SHOWLOADING
  1304. WS(weakSelf);
  1305. NSString * meetId = [NSString stringWithFormat:@"%ld",(long)self.Id];
  1306. [[HttpManager sharedHttpManager] PUTUrl:Host(UpdateMeeting(meetId)) parameters:paraDict success:^(id _Nonnull responseObject) {
  1307. REMOVESHOW
  1308. SHOWSUCCESS(@"修改会议纪要成功");
  1309. if (weakSelf.upDateBlock) {
  1310. weakSelf.upDateBlock();
  1311. }
  1312. [weakSelf.navigationController popViewControllerAnimated:YES];
  1313. } failure:^(NSError * _Nonnull error) {
  1314. REMOVESHOW
  1315. SHOWERROR([ZYCTool handerResultData:error]);
  1316. }];
  1317. }
  1318. #pragma mark - 提交笔记
  1319. - (void)submitNoteBook:(NSDictionary *)dict
  1320. {
  1321. WS(weakSelf);
  1322. NSString * html = dict[@"html"];
  1323. NSArray * jsonArray = dict[@"json"];
  1324. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1325. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1326. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1327. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1328. [paraDict setObject:html forKey:@"HtmlContent"];
  1329. [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
  1330. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1331. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1332. SHOWERROR(@"请填写标题或内容");
  1333. return;
  1334. }
  1335. // if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1336. // SHOWERROR(@"请选择发布范围");
  1337. // return;
  1338. // }
  1339. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict success:^(id _Nonnull responseObject) {
  1340. NSLog(@"%@",responseObject);
  1341. SHOWSUCCESS(@"创建成功");
  1342. if (weakSelf.upDateBlock) {
  1343. weakSelf.upDateBlock();
  1344. }
  1345. [weakSelf back1];
  1346. } failure:^(NSError * _Nonnull error) {
  1347. SHOWERROR([ZYCTool handerResultData:error]);
  1348. }];
  1349. }
  1350. - (void)changeNoteBook:(NSDictionary *)dict
  1351. {
  1352. WS(weakSelf);
  1353. NSString * html = dict[@"html"];
  1354. NSArray * jsonArray = dict[@"json"];
  1355. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1356. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1357. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1358. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1359. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1360. [paraDict setObject:html forKey:@"HtmlContent"];
  1361. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1362. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1363. SHOWERROR(@"请填写标题或内容");
  1364. return;
  1365. }
  1366. // if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1367. // SHOWERROR(@"请选择发布范围");
  1368. // return;
  1369. // }
  1370. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NoteBook_Modify) parameters:paraDict success:^(id _Nonnull responseObject) {
  1371. NSLog(@"%@",responseObject);
  1372. if (weakSelf.upDateBlock) {
  1373. weakSelf.upDateBlock();
  1374. }
  1375. SHOWSUCCESS(@"修改成功");
  1376. [weakSelf.navigationController popViewControllerAnimated:YES];
  1377. } failure:^(NSError * _Nonnull error) {
  1378. SHOWERROR([ZYCTool handerResultData:error]);
  1379. }];
  1380. }
  1381. #pragma mark - 提交站内信
  1382. - (void)submitMail:(NSDictionary *)dict
  1383. {
  1384. self.H5JsonDict = dict;
  1385. NSString * html = dict[@"html"];
  1386. NSArray * jsonArray = dict[@"json"];
  1387. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1388. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1389. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1390. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1391. [paraDict setObject:html forKey:@"HtmlContent"];
  1392. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1393. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  1394. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  1395. [paraDict setObject:@(self.MailType) forKey:@"MissiveType"];///1 正常 2 匿名
  1396. [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
  1397. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  1398. [paraDict setObject:@(self.isDraft ? 2 : 1) forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  1399. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  1400. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  1401. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  1402. [self.H5JsonDict[@"html"] length] == 0 &&
  1403. addArray.count == 0 &&
  1404. ccArray.count == 0) {
  1405. SHOWERROR(@"请填写标题或内容");
  1406. return;
  1407. }
  1408. if (self.isEdit) {
  1409. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  1410. }else{
  1411. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1412. }
  1413. }
  1414. [self sentMailRequeast:paraDict];
  1415. }
  1416. - (void)sentMailRequeast:(NSMutableDictionary *)dic
  1417. {
  1418. WS(weakSelf);
  1419. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic success:^(id _Nonnull responseObject) {
  1420. if(weakSelf.isDraft){
  1421. SHOWSUCCESS(@"站内信已经存放草稿箱");
  1422. }else{
  1423. SHOWSUCCESS(@"站内信已经发送");
  1424. }
  1425. if (weakSelf.replayType == MailReplayOne || weakSelf.replayType == MailReplayAll) {
  1426. [weakSelf backMailList];
  1427. }else{
  1428. [weakSelf.navigationController popViewControllerAnimated:YES];
  1429. }
  1430. } failure:^(NSError * _Nonnull error) {
  1431. SHOWERROR([ZYCTool handerResultData:error]);
  1432. }];
  1433. }
  1434. - (NSString *)arrayToJSONModel:(NSArray *)array
  1435. {
  1436. NSMutableArray * mArray = [NSMutableArray array];
  1437. for (SelectModel * model in array) {
  1438. NSDictionary * dict = [model modelToJSONObject];
  1439. [mArray addObject:@{@"SourceType":dict[@"SourceType"],@"SourceId":dict[@"SourceId"],@"SourceName":dict[@"SourceName"],@"MiddleType":@(self.type)}];
  1440. }
  1441. return [self arrayToJSONString:mArray];
  1442. }
  1443. - (NSString *)arrayTosumbitString:(NSArray *)array
  1444. {
  1445. NSError *error = nil;
  1446. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1447. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1448. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1449. return mutStr;
  1450. }
  1451. - (NSString *)arrayToJSONString:(NSArray *)array
  1452. {
  1453. NSError *error = nil;
  1454. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1455. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1456. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1457. NSRange range = {0,jsonString.length};
  1458. //去掉字符串中的空格
  1459. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  1460. NSRange range2 = {0,mutStr.length};
  1461. //去掉字符串中的换行符
  1462. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  1463. return mutStr;
  1464. }
  1465. - (void)dealloc {
  1466. [self.webView stopLoading];
  1467. self.webView.UIDelegate = nil;
  1468. self.webView.navigationDelegate = nil;
  1469. self.webView.scrollView.delegate = nil;
  1470. [self.webView removeFromSuperview];
  1471. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  1472. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  1473. completionHandler:^(NSArray * __nonnull records) {
  1474. for (WKWebsiteDataRecord *record in records)
  1475. {
  1476. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  1477. forDataRecords:@[record]
  1478. completionHandler:^{
  1479. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  1480. }];
  1481. }
  1482. }];
  1483. WKUserContentController *userCC = self.webView.configuration.userContentController;
  1484. [userCC removeScriptMessageHandlerForName:@"chosePic"];
  1485. [userCC removeScriptMessageHandlerForName:@"toPZ"];
  1486. [userCC removeScriptMessageHandlerForName:@"toBJ"];
  1487. [userCC removeScriptMessageHandlerForName:@"getJp"];
  1488. [userCC removeScriptMessageHandlerForName:@"toSC"];
  1489. [userCC removeScriptMessageHandlerForName:@"toWJ"];
  1490. [userCC removeScriptMessageHandlerForName:@"keyBoard"];
  1491. [userCC removeScriptMessageHandlerForName:@"getType"];
  1492. [userCC removeScriptMessageHandlerForName:@"approverCheckUsers"];
  1493. [userCC removeScriptMessageHandlerForName:@"carbonCopyUsers"];
  1494. [userCC removeScriptMessageHandlerForName:@"changeState"];
  1495. [userCC removeScriptMessageHandlerForName:@"to"];
  1496. [userCC removeScriptMessageHandlerForName:@"postH"];
  1497. [userCC removeAllUserScripts];
  1498. [[NSNotificationCenter defaultCenter] removeObserver:self];
  1499. }
  1500. //- (void)hideWKWebviewKeyboardShortcutBar:(WKWebView *)webView {
  1501. // UIView *targetView;
  1502. //
  1503. // for (UIView *view in webView.scrollView.subviews) {
  1504. // if([[view.class description] hasPrefix:@"WKContent"]) {
  1505. // targetView = view;
  1506. // }
  1507. // }
  1508. // if (!targetView) {
  1509. // return;
  1510. // }
  1511. // NSString *noInputAccessoryViewClassName = [NSString stringWithFormat:@"%@_NoInputAccessoryView", targetView.class.superclass];
  1512. // Class newClass = NSClassFromString(noInputAccessoryViewClassName);
  1513. //
  1514. // if(newClass == nil) {
  1515. // newClass = objc_allocateClassPair(targetView.class, [noInputAccessoryViewClassName cStringUsingEncoding:NSASCIIStringEncoding], 0);
  1516. // if(!newClass) {
  1517. // return;
  1518. // }
  1519. //
  1520. // Method method = class_getInstanceMethod([_NoInputAccessoryView class], @selector(inputAccessoryView));
  1521. //
  1522. // class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
  1523. //
  1524. // objc_registerClassPair(newClass);
  1525. // }
  1526. //
  1527. // object_setClass(targetView, newClass);
  1528. //}
  1529. - (CollectModelType)returnType:(NSString *)url
  1530. {
  1531. NSString * name = [[url pathExtension] lowercaseString];
  1532. if([name hasSuffix:@"png"] || [name hasSuffix:@"jpg"] || [name hasSuffix:@"jpeg"] || [name hasSuffix:@"bmp"]){
  1533. return CollectModel_Image;
  1534. }else{
  1535. return CollectModel_file;
  1536. }
  1537. }
  1538. #pragma mark - 通知存草稿箱
  1539. - (void)backAction:(id)sender{
  1540. if (self.type == CollectModel_Notice || self.type == CollectModel_InterMail) {
  1541. if (self.isNull) {
  1542. [super backAction:sender];
  1543. }else{
  1544. [self saveToDraftBox];
  1545. }
  1546. }else{
  1547. [super backAction:sender];
  1548. }
  1549. }
  1550. - (void)saveToDraftBox
  1551. {
  1552. WS(weakSelf);
  1553. [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
  1554. weakSelf.isDraft = YES;
  1555. [weakSelf submit];
  1556. } cancle:^(ShowKeepNoticeCloseType colseType) {
  1557. if(colseType == ShowKeepNoticeCloseType1){
  1558. [weakSelf.navigationController popViewControllerAnimated:YES];
  1559. }
  1560. }] show];
  1561. }
  1562. - (void)backMailList
  1563. {
  1564. for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  1565. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
  1566. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  1567. return;
  1568. }
  1569. }
  1570. }
  1571. - (void)back1
  1572. {
  1573. if (self.isReturn) {
  1574. for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  1575. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CountDataVC")]
  1576. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyApprovalPageDetail")]
  1577. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
  1578. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowDetailsController")]
  1579. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDGroupInfoListVC")]
  1580. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"OtherNoteBookVC")]
  1581. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"OtherFavoriteVC")]
  1582. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"NoteBookVC")]
  1583. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"EMChatViewController")]
  1584. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyFavoriteVC")]
  1585. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"HomeDetailController")]
  1586. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicDetailVC")]) {
  1587. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  1588. return;
  1589. }
  1590. }
  1591. }else{
  1592. [self.navigationController popViewControllerAnimated:YES];
  1593. }
  1594. }
  1595. #pragma mark - JS调起键盘
  1596. - (void)allowDisplayingKeyboardWithoutUserAction {
  1597. Class class = NSClassFromString(@"WKContentView");
  1598. NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
  1599. NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
  1600. NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
  1601. char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1602. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
  1603. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:";
  1604. } else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
  1605. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1606. }
  1607. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
  1608. SEL selector = sel_getUid(methodSignature);
  1609. Method method = class_getInstanceMethod(class, selector);
  1610. IMP original = method_getImplementation(method);
  1611. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
  1612. ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
  1613. });
  1614. method_setImplementation(method, override);
  1615. } else {
  1616. SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
  1617. Method method = class_getInstanceMethod(class, selector);
  1618. IMP original = method_getImplementation(method);
  1619. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
  1620. ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
  1621. });
  1622. method_setImplementation(method, override);
  1623. }
  1624. }
  1625. @end