CommomSearchVC.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. //
  2. // CommomSearchVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/1/17.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "CommomSearchVC.h"
  9. #import "CommonListCell.h"
  10. #import "MyFavoriteVC.h"
  11. #import "CommonNoteVC.h"
  12. #import "OtherFavoriteVC.h"
  13. #import "OtherNoteBookVC.h"
  14. #import "DownFileViewController.h"
  15. #import "WorkFlowDetailsController.h"
  16. #import "MyApprovalPageDetail.h"
  17. #import "CountDataVC.h"
  18. #import "CommomSearchVC.h"
  19. #import "MyFavoriteVC.h"
  20. #import "NoteBookVC.h"
  21. #import "OtherFavoriteVC.h"
  22. #import "OtherNoteBookVC.h"
  23. #import "DownFileViewController.h"
  24. #import "WorkFlowDetailsController.h"
  25. #import "MyApprovalPageDetail.h"
  26. #import "CountDataVC.h"
  27. #import "CommomSearchVC.h"
  28. #import "NoteBookShareVC.h"
  29. #import "MyTDGroupViewController.h"
  30. #import "TDGroupInfoListVC.h"
  31. #import "MailListVC.h"
  32. #import "ShareListVC.h"
  33. #import "BookWCDetailVC.h"
  34. #import "BookListenVC.h"
  35. #import "BookTeacherDetailVC.h"
  36. @interface CommomSearchVC ()<UITableViewDelegate,UITableViewDataSource>
  37. @property (nonatomic, copy) NSMutableArray *listArray;
  38. @end
  39. @implementation CommomSearchVC
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. self.fd_prefersNavigationBarHidden = YES;
  43. self.view.backgroundColor = RGB(255, 255, 255);
  44. self.tableView.delegate = self;
  45. self.tableView.dataSource = self;
  46. // [self.topNavSearch setBarPlaceholder:@"姓名/手机号/邮箱"];
  47. if (self.IsAddUser) {
  48. [self.cancelBtn setAttributedTitle:[[NSAttributedString alloc] initWithString:@"确定" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 15],NSForegroundColorAttributeName: UIColorHex(#3979D3)}] forState:UIControlStateNormal];
  49. WS(weakSelf);
  50. NSMutableArray * array = [NSMutableArray array];
  51. [self.cancelBtn setAction:^{
  52. for (SelectModel *model in weakSelf.listArray) {
  53. if (model.hadSelected) {
  54. [array addObject:model];
  55. }
  56. }
  57. if (array.count > 0) {
  58. [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":array}];
  59. [weakSelf back1];
  60. }
  61. }];
  62. }
  63. self.historySearchType = HistorySearchType_Common;
  64. [self addObserver:self forKeyPath:@"searchText" options:NSKeyValueObservingOptionNew context:nil];
  65. }
  66. - (void)dealloc
  67. {
  68. [[NSNotificationCenter defaultCenter] removeObserver:self];
  69. }
  70. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
  71. {
  72. id obj = [change objectForKey:@"new"];
  73. NSString * text = @"";
  74. if ([obj isKindOfClass:[NSString class]]) {
  75. text = obj;
  76. }else{
  77. text = [obj stringValue];
  78. }
  79. if (text.length > 0) {
  80. [self getData:text];
  81. }
  82. }
  83. - (void)getData:(NSString *)searchKey
  84. {
  85. [self.listArray removeAllObjects];
  86. WS(weakSelf);
  87. SHOWLOADING
  88. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Collection_List) parameters:@{@"FolderId":@(0),@"Page":@(1),@"PerPage":@(99999999),@"VisitUserId":@(0),@"SearchKey":searchKey} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  89. REMOVESHOW
  90. MyFavoriteModel *listModel = [[MyFavoriteModel alloc] initWithDictionary:responseObject error:nil];
  91. [weakSelf.listArray addObjectsFromArray:listModel.Items];
  92. for (MyFavoriteSubModel *model in weakSelf.listArray) {
  93. if (model.CollectionType == CollectModel_Text) {
  94. model.CollectionType = CollectModel_Aritle;
  95. }
  96. }
  97. dispatch_async(dispatch_get_main_queue(), ^{
  98. [weakSelf.tableView reloadData];
  99. });
  100. } failure:^(NSError * _Nonnull error) {
  101. REMOVESHOW
  102. }];
  103. }
  104. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  105. {
  106. return self.listArray.count;
  107. }
  108. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  109. {
  110. return UITableViewAutomaticDimension;
  111. }
  112. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  113. {
  114. CommonListCell *cell = [CommonListCell configCell1:tableView indexPath:indexPath];
  115. MyFavoriteSubModel * model = [self.listArray objectAtIndex:indexPath.row];
  116. if (model.CollectionType == CollectModel_TopicBooK) {
  117. CommonListCell *cell = [CommonListCell configCell2:tableView indexPath:indexPath];
  118. [cell setCellTopicBookData:model];
  119. WS(weakSelf);
  120. [cell.desBtn setAction:^{
  121. MyFavoriteVC * vc = [MyFavoriteVC initMyFavoriteVC];
  122. vc.listType = model.FolderId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  123. vc.FolderId = model.FolderId;
  124. vc.myTitle = model.FolderName;
  125. [weakSelf.navigationController pushViewController:vc animated:YES];
  126. }];
  127. return cell;
  128. }else{
  129. switch (model.CollectionType) {
  130. case CollectModel_Teacher:
  131. {
  132. CommonListCell *cell = [CommonListCell configCell2:tableView indexPath:indexPath];
  133. [cell setCellNoAuthorData:model withText:self.searchText];
  134. WS(weakSelf);
  135. [cell.desBtn setAction:^{
  136. MyFavoriteVC * vc = [MyFavoriteVC initMyFavoriteVC];
  137. vc.listType = model.FolderId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  138. vc.FolderId = model.FolderId;
  139. vc.myTitle = model.FolderName;
  140. [weakSelf.navigationController pushViewController:vc animated:YES];
  141. }];
  142. return cell;
  143. }
  144. break;
  145. default:
  146. {
  147. if (model.CollectionType != CollectModel_Toipc && model.Data.Author.length == 0) {
  148. CommonListCell *cell = [CommonListCell configCell2:tableView indexPath:indexPath];
  149. [cell setCellNoAuthorData:model withText:self.searchText];
  150. WS(weakSelf);
  151. [cell.desBtn setAction:^{
  152. MyFavoriteVC * vc = [MyFavoriteVC initMyFavoriteVC];
  153. vc.listType = model.FolderId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  154. vc.FolderId = model.FolderId;
  155. vc.myTitle = model.FolderName;
  156. [weakSelf.navigationController pushViewController:vc animated:YES];
  157. }];
  158. return cell;
  159. }else{
  160. CommonListCell *cell = [CommonListCell configCell1:tableView indexPath:indexPath];
  161. [cell setCellData:model withText:self.searchText];
  162. WS(weakSelf);
  163. [cell.desBtn setAction:^{
  164. MyFavoriteVC * vc = [MyFavoriteVC initMyFavoriteVC];
  165. vc.listType = model.FolderId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  166. vc.FolderId = model.FolderId;
  167. vc.myTitle = model.FolderName;
  168. [weakSelf.navigationController pushViewController:vc animated:YES];
  169. }];
  170. if (model.CollectionType == CollectModel_Toipc) {
  171. [cell.comeBtn setAction:^{
  172. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  173. vc.GroupId = model.Data.GroupId;
  174. vc.titleStr = model.Data.GroupName;
  175. [weakSelf.navigationController pushViewController:vc animated:YES];
  176. }];
  177. }
  178. return cell;
  179. }
  180. }
  181. break;
  182. }
  183. }
  184. }
  185. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  186. {
  187. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  188. MyFavoriteSubModel * model = [self.listArray objectAtIndex:indexPath.row];
  189. switch (model.CollectionType) {
  190. case CollectModel_Aritle:{
  191. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  192. vc.type = CollectModel_Aritle;
  193. vc.Id = model.CollectionDataId;
  194. [self.navigationController pushViewController:vc animated:YES];
  195. }break;
  196. case CollectModel_Toipc:
  197. {
  198. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  199. vc.type = CollectModel_Toipc;
  200. vc.Id = model.CollectionDataId;
  201. [self.navigationController pushViewController:vc animated:YES];
  202. }break;
  203. case CollectModel_NewTopic:
  204. {
  205. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  206. vc.type = CollectModel_NewTopic;
  207. vc.Id = model.CollectionDataId;
  208. [self.navigationController pushViewController:vc animated:YES];
  209. }break;
  210. case CollectModel_Collect:{
  211. }break;
  212. case CollectModel_NoteBook:{
  213. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  214. vc.type = CollectModel_NoteBook;
  215. vc.Id = model.CollectionDataId;
  216. vc.isNoteBook = YES;
  217. [self.navigationController pushViewController:vc animated:YES];
  218. }break;
  219. case CollectModel_CollectFile:{
  220. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id || model.SourceUserId == 0) {
  221. MyFavoriteVC * vc = [MyFavoriteVC initMyFavoriteVC];
  222. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  223. vc.FolderId = model.CollectionDataId;
  224. vc.myTitle = model.Title;
  225. [self.navigationController pushViewController:vc animated:YES];
  226. }else{
  227. OtherFavoriteVC * vc = [OtherFavoriteVC initOtherFavoriteVC];
  228. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  229. vc.FolderId = model.CollectionDataId;
  230. vc.CollectionDataId = model.CollectionDataId;
  231. vc.CollectionType = model.CollectionType;
  232. vc.Author = model.Data.Author;
  233. vc.myTitle = model.Title;
  234. vc.VisitUserId = model.SourceUserId;
  235. [self.navigationController pushViewController:vc animated:YES];
  236. }
  237. }break;
  238. case CollectModel_NoteFile: {
  239. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id || model.SourceUserId == 0) {
  240. NoteBookVC * vc = [NoteBookVC initNoteBookVC];
  241. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  242. vc.FolderId = model.CollectionDataId;
  243. vc.myTitle = model.Title;
  244. [self.navigationController pushViewController:vc animated:YES];
  245. }else{
  246. OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
  247. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  248. vc.FolderId = model.CollectionDataId;
  249. vc.CollectionDataId = model.CollectionDataId;
  250. vc.CollectionType = model.CollectionType;
  251. vc.Author = model.Data.Author;
  252. vc.myTitle = model.Title;
  253. vc.VisitUserId = model.SourceUserId;
  254. [self.navigationController pushViewController:vc animated:YES];
  255. }
  256. }break;
  257. case CollectModel_TopicBooK:{
  258. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id || model.SourceUserId == 0) {
  259. NoteBookVC * vc = [NoteBookVC initNoteBookVC];
  260. vc.listType = MyFavoriteListLevelTypeA;
  261. vc.FolderId = model.CollectionDataId;
  262. vc.TypeValue = 1;
  263. vc.myTitle = model.Title;
  264. [self.navigationController pushViewController:vc animated:YES];
  265. }else{
  266. OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
  267. vc.listType = MyFavoriteListLevelTypeA ;
  268. vc.FolderId = model.CollectionDataId;
  269. vc.CollectionDataId = model.CollectionDataId;
  270. vc.CollectionType = model.CollectionType;
  271. vc.Author = model.Data.Author;
  272. vc.TypeValue = 1;
  273. vc.myTitle = model.Title;
  274. vc.VisitUserId = model.SourceUserId;
  275. [self.navigationController pushViewController:vc animated:YES];
  276. }
  277. }break;
  278. case CollectModel_TopicSubBooK:{
  279. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id || model.SourceUserId == 0) {
  280. NoteBookVC * vc = [NoteBookVC initNoteBookVC];
  281. vc.listType = MyFavoriteListLevelTypeB;
  282. vc.FolderId = model.CollectionDataId;
  283. vc.TypeValue = 1;
  284. vc.myTitle = model.Title;
  285. [self.navigationController pushViewController:vc animated:YES];
  286. }else{
  287. OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
  288. vc.listType = MyFavoriteListLevelTypeB;
  289. vc.FolderId = model.CollectionDataId;
  290. vc.CollectionDataId = model.CollectionDataId;
  291. vc.CollectionType = model.CollectionType;
  292. vc.Author = model.Data.Author;
  293. vc.TypeValue = 1;
  294. vc.myTitle = model.Title;
  295. vc.VisitUserId = model.SourceUserId;
  296. [self.navigationController pushViewController:vc animated:YES];
  297. }
  298. }break;
  299. case CollectModel_Notice:{
  300. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  301. vc.type = CollectModel_Notice;
  302. vc.Id = model.CollectionDataId;
  303. [self.navigationController pushViewController:vc animated:YES];
  304. }break;
  305. case CollectModel_InterMail:{
  306. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  307. vc.type = CollectModel_InterMail;
  308. vc.Id = model.CollectionDataId;
  309. [self.navigationController pushViewController:vc animated:YES];
  310. }break;
  311. case CollectModel_file:{
  312. FlowAttachmentsModel *wMdoel = [[FlowAttachmentsModel alloc]init];
  313. wMdoel.Url = model.Data.File;
  314. wMdoel.MinUrl = model.Data.File;
  315. wMdoel.Title = model.Data.FileName;
  316. wMdoel.SoureId = model.Data.Id;
  317. wMdoel.SoureTypeId = CollectModel_file;
  318. wMdoel.Size = model.Data.FileSize;
  319. DownFileViewController *downFileViewController = [[DownFileViewController alloc]init];
  320. downFileViewController.model = wMdoel;
  321. [self.navigationController pushViewController:downFileViewController animated:YES];
  322. }break;
  323. case CollectModel_meetDetail:
  324. {
  325. WorkFlowDetailsController * vc = [[WorkFlowDetailsController alloc] initWithId:model.CollectionDataId];
  326. [self.navigationController pushViewController:vc animated:YES];
  327. }
  328. break;
  329. case CollectModel_work:
  330. {
  331. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  332. vc.pageType = Type_ONEC;
  333. vc.indexId = model.CollectionDataId;
  334. vc.title = model.Data.Title;
  335. vc.TodoId = model.CollectionDataId;
  336. [self.navigationController pushViewController:vc animated:YES];
  337. }
  338. case CollectModel_meetMian:{
  339. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  340. vc.Id = model.CollectionDataId;
  341. vc.type = CollectModel_meetMian;
  342. [self.navigationController pushViewController:vc animated:YES];
  343. }break;
  344. case CollectModel_StoreSound:
  345. {
  346. BookListenVC * vc = [BookListenVC initBookListenVC];
  347. vc.Id = model.CollectionDataId;
  348. vc.MediaType = MediaMusicType;
  349. [self.navigationController pushViewController:vc animated:YES];
  350. }
  351. break;
  352. case CollectModel_StoreVideo:
  353. {
  354. BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
  355. vc.Id = model.CollectionDataId;
  356. [self.navigationController pushViewController:vc animated:YES];
  357. }
  358. break;
  359. case CollectModel_Teacher:
  360. {
  361. BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
  362. vc.Id = model.CollectionDataId;
  363. [self.navigationController pushViewController:vc animated:YES];
  364. }
  365. break;
  366. case CollectModel_financeCount:{
  367. CountDataVC *vc = [CountDataVC initCountDataVC];
  368. vc.index = 0;
  369. vc.titleStr = @"财务统计";
  370. [self.navigationController pushViewController:vc animated:YES];
  371. }break;
  372. case CollectModel_affairsCount:{
  373. CountDataVC *vc = [CountDataVC initCountDataVC];
  374. vc.index = 1;
  375. vc.titleStr = @"人事统计";
  376. [self.navigationController pushViewController:vc animated:YES];
  377. }break;
  378. case CollectModel_publishCount:{
  379. CountDataVC *vc = [CountDataVC initCountDataVC];
  380. vc.index = 2;
  381. vc.titleStr = @"出版统计";
  382. [self.navigationController pushViewController:vc animated:YES];
  383. }break;
  384. default:
  385. {
  386. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  387. vc.Id = model.CollectionDataId;
  388. vc.type = CollectModel_Toipc;
  389. [self.navigationController pushViewController:vc animated:YES];
  390. }
  391. break;
  392. }
  393. }
  394. -(void)back1{
  395. for (NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  396. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CommonHomeVC")]) {
  397. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  398. return;
  399. }
  400. }
  401. }
  402. - (NSMutableArray *)listArray{
  403. if (!_listArray) {
  404. _listArray = [NSMutableArray new];
  405. }
  406. return _listArray;
  407. }
  408. @end