MyTDTopicCreateVC.m 70 KB

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