MyTDTopicSelectExtentVC.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. //
  2. // MyTDTopicSelectExtentVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicSelectExtentVC.h"
  9. #import "MyTDTopicSelectExtentCell.h"
  10. #import "MyTDTSEModel.h"
  11. #import "YCMenuView.h"
  12. #import "MyFavoriteNewFindVC.h"
  13. @interface MyTDTopicSelectExtentVC ()<UITableViewDelegate, UITableViewDataSource>
  14. @property (weak, nonatomic) IBOutlet UIButton *addBtn;
  15. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  16. @property (weak, nonatomic) IBOutlet UIButton *menuBtn;
  17. @property (assign,nonatomic) OperationStateEnum operationStateEnum;
  18. @property (weak, nonatomic) IBOutlet UIButton *operationAllSelectButton;
  19. @property (strong,nonatomic) UIView *operationBottomBgView;
  20. @property (weak, nonatomic) IBOutlet UIView *noDataView;
  21. @property (weak, nonatomic) IBOutlet UIButton *noDataBtn;
  22. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  23. @property (strong, nonatomic) NSMutableArray *dataArray;
  24. @property (nonatomic, copy) NSArray *addListArray;
  25. @property (nonatomic, strong) UIButton *leftCloseBtn;
  26. @property (nonatomic, assign) BOOL iSViewEditor;
  27. @property (nonatomic, assign) BOOL isAllselect;
  28. @end
  29. @implementation MyTDTopicSelectExtentVC
  30. +(MyTDTopicSelectExtentVC *)initMyTDTopicSelectExtentVC
  31. {
  32. MyTDTopicSelectExtentVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicSelectExtentVC"];
  33. return controller;
  34. }
  35. - (void)viewWillAppear:(BOOL)animated
  36. {
  37. [super viewWillAppear:animated];
  38. [self getData];
  39. }
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. self.titleL.text = self.titleStr;
  43. self.iSViewEditor = NO;
  44. if (@available(iOS 11.0, *)) {
  45. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  46. }else {
  47. self.automaticallyAdjustsScrollViewInsets = NO;
  48. }
  49. self.fd_prefersNavigationBarHidden = YES;
  50. [self initBottomBgView];
  51. [self changeToOperation:NO];
  52. self.tableView.delegate = self;
  53. self.tableView.dataSource = self;
  54. WS(weakSelf);
  55. [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
  56. [self.operationAllSelectButton setAction:^{
  57. for (MyTDTSEModel * model in weakSelf.dataArray) {
  58. model.isSelect = !weakSelf.isAllselect;
  59. }
  60. [self.tableView reloadData];
  61. }];
  62. [self.noDataBtn setAction:^{
  63. MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
  64. vc.ParentId = weakSelf.folderId;
  65. vc.createFoldType = CreateNotesType;
  66. vc.modifyTye = CreateType;
  67. vc.fileType = NewTopicFileType;
  68. [weakSelf.navigationController pushViewController:vc animated:YES];
  69. }];
  70. }
  71. - (void)setOperationAllButton {
  72. // 设置导航栏全选按钮
  73. self.isAllselect = [self checkChatListArray];
  74. if (self.isAllselect) {
  75. [self.operationAllSelectButton setTitle:@"取消全选" forState:UIControlStateNormal];
  76. }else{
  77. [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
  78. }
  79. }
  80. - (BOOL)checkChatListArray
  81. {
  82. for (MyTDTSEModel * model in self.dataArray) {
  83. if (!model.isSelect) {
  84. return NO;
  85. }
  86. }
  87. return YES;
  88. }
  89. - (void)upDateAddBtn
  90. {
  91. WS(weakSelf);
  92. if (self.isSubVC) {
  93. self.addListArray = self.dataArray.count == 0 ? @[@"共享范围",@"建文件夹"] : @[@"共享范围",@"建文件夹",@"批量编辑"];
  94. }else{
  95. self.addListArray = self.dataArray.count == 0 ? @[@"建文件夹"] : @[@"建文件夹",@"批量编辑"];
  96. }
  97. [self.addBtn setAction:^{
  98. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
  99. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
  100. view.menuColor = RGB(255, 255, 255);
  101. view.separatorColor = RGB(234, 234, 234);
  102. view.textColor = RGB(102, 102, 102);
  103. view.textFont = [UIFont systemFontOfSize:16.0];
  104. view.menuCellHeight = 43.5;
  105. view.maxDisplayCount = 10;
  106. view.offset = -6;
  107. [view show];
  108. }];
  109. }
  110. -(NSMutableArray *)getMenuDataSource:(NSArray *)titleArray{
  111. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  112. for(int i = 0;i<titleArray.count;i++){
  113. NSString *titleStr = [titleArray objectAtIndex:i];
  114. WS(weakSelf);
  115. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  116. if([@"建文件夹" isEqualToString:action.title]){
  117. MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
  118. vc.ParentId = weakSelf.folderId;
  119. vc.createFoldType = CreateNotesType;
  120. vc.modifyTye = CreateType;
  121. vc.fileType = NewTopicFileType;
  122. [weakSelf.navigationController pushViewController:vc animated:YES];
  123. }else if ([@"批量编辑" isEqualToString:action.title]){
  124. [weakSelf changeToOperation:YES];
  125. }else if ([@"共享范围" isEqualToString:action.title]){
  126. MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
  127. vc.ParentId = weakSelf.ParentId;
  128. vc.createFoldType = CreateNotesType;
  129. vc.foldId = weakSelf.folderId;
  130. vc.modifyTye = ModifyType;
  131. vc.fileType = NewOtherFileType;
  132. vc.titleStr = @"修改文件夹";
  133. vc.fileName = self.fileName;
  134. [weakSelf.navigationController pushViewController:vc animated:YES];
  135. }
  136. }];
  137. [menuDataSourceArray addObject:actionMenu];
  138. }
  139. return menuDataSourceArray;
  140. }
  141. #pragma Mark 左滑按钮 iOS8以上
  142. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  143. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  144. WS(weakSelf);
  145. MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
  146. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  147. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  148. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  149. [weakSelf deleteFind:@[@(model.Id)]];
  150. }];
  151. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  152. }];
  153. [alert addAction:sureAction];
  154. [alert addAction:cancelAction];
  155. [weakSelf presentViewController:alert animated:YES completion:^{
  156. }];
  157. }];
  158. action1.backgroundColor = RGB(255, 59, 47);
  159. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"修改" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  160. MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
  161. vc.ParentId = model.Id;
  162. vc.foldId = model.Id;
  163. vc.createFoldType = CreateNotesType;
  164. vc.modifyTye = ModifyType;
  165. vc.fileType = NewOtherFileType;
  166. vc.fileName = self.fileName;
  167. [weakSelf.navigationController pushViewController:vc animated:YES];
  168. }];
  169. action2.backgroundColor = UIColorHex(#FF923A);
  170. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  171. [weakSelf topFind:model];
  172. }];
  173. action3.backgroundColor = UIColorHex(#9BA9CB);
  174. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2,action3]];
  175. actions.performsFirstActionWithFullSwipe = NO;
  176. return actions;
  177. }
  178. #else
  179. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  180. MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
  181. WEAKSELF
  182. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  183. [weakSelf deleteFind:@[@(model.Id)]];
  184. }];
  185. action1.backgroundColor = RGB(255, 59, 47);
  186. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"修改" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  187. MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
  188. vc.ParentId = model.Id;
  189. vc.foldId = model.Id;
  190. vc.createFoldType = CreateNotesType;
  191. vc.modifyTye = ModifyType;
  192. vc.fileType = NewOtherFileType;
  193. vc.fileName = self.fileName;
  194. [weakSelf.navigationController pushViewController:vc animated:YES];
  195. }];
  196. action2.backgroundColor = UIColorHex(#FF923A);
  197. UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  198. [weakSelf topFind:model];
  199. }];
  200. action3.backgroundColor = UIColorHex(#9BA9CB);
  201. return @[action1, action2, action3];
  202. }
  203. #endif
  204. -(void)initBottomBgView{
  205. self.leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  206. [self.leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal];
  207. [self.leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
  208. self.leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  209. [self.operationBottomBgView addSubview:self.leftCloseBtn];
  210. self.leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH, self.operationBottomBgView.height - 10);
  211. UIView *topLine = [[UIView alloc] init];
  212. topLine.backgroundColor = RGB(240, 239, 244);
  213. [self.operationBottomBgView addSubview:topLine];
  214. topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 10);
  215. WS(weakSelf);
  216. [self.leftCloseBtn setAction:^{
  217. NSMutableArray *selectIDArray = [NSMutableArray array];
  218. for (MyTDTSEModel * model in weakSelf.dataArray) {
  219. if (model.isSelect) {
  220. [selectIDArray addObject:@(model.Id)];
  221. }
  222. }
  223. if (selectIDArray.count == 0) {
  224. SHOWERROR(@"请选择要删除的通知");
  225. return ;
  226. }else{
  227. [weakSelf deleteFind:selectIDArray];
  228. }
  229. }];
  230. [[UtilsTools getWindow] addSubview:self.operationBottomBgView];
  231. }
  232. - (void)deleteFind:(NSArray *)array
  233. {
  234. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  235. [dic setValue:array forKey:@"MiddleIds"];
  236. [dic setValue:@(CreateNotesType) forKey:@"FolderType"];
  237. SHOWLOADING
  238. WEAKSELF
  239. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  240. STRONGSELF
  241. REMOVESHOW
  242. [strongSelf getData];
  243. } failure:^(NSError * _Nonnull error) {
  244. SHOWERROR([ZYCTool handerResultData:error]);
  245. }];
  246. }
  247. - (void)topFind:(MyTDTSEModel*)findModel{
  248. SHOWLOADING
  249. WEAKSELF
  250. [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_Find_Top,(long)findModel.Id] parameters:@{} success:^(id _Nonnull responseObject) {
  251. STRONGSELF
  252. REMOVESHOW
  253. [strongSelf getData];
  254. } failure:^(NSError * _Nonnull error) {
  255. SHOWERROR([ZYCTool handerResultData:error]);
  256. }];
  257. }
  258. -(UIView *)operationBottomBgView{
  259. if(!_operationBottomBgView){
  260. _operationBottomBgView = [[UIView alloc] init];
  261. CGFloat bottomBgViewH = self.tabBarController.tabBar.height + 10;
  262. _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
  263. _operationBottomBgView.backgroundColor = RGB(255, 255, 255);
  264. _operationBottomBgView.hidden = YES;
  265. }
  266. return _operationBottomBgView;
  267. }
  268. #pragma mark 批量操作与正常操作界面切换
  269. -(void)changeToOperation:(BOOL)operation{
  270. if(operation){
  271. self.iSViewEditor = YES;
  272. self.addBtn.hidden = YES;
  273. //默认操作状态为批量编辑状态
  274. self.menuBtn.hidden = YES;
  275. self.operationStateEnum = OperationStateEnum1;
  276. // self.operationBackButton.hidden = NO;
  277. self.operationAllSelectButton.hidden = NO;
  278. self.tabBarController.tabBar.hidden = YES;
  279. self.operationBottomBgView.hidden = NO;
  280. self.view.height -= self.tabBarController.tabBar.height;
  281. self.tableView.height -= self.tabBarController.tabBar.height;
  282. [self.view layoutIfNeeded];
  283. [self.tableView layoutIfNeeded];
  284. }else{
  285. self.addBtn.hidden = NO;
  286. self.iSViewEditor = NO;
  287. self.menuBtn.hidden = NO;
  288. //默认操作状态为无状态
  289. self.operationStateEnum = OperationStateEnum0;
  290. self.operationAllSelectButton.hidden = YES;
  291. self.tabBarController.tabBar.hidden = YES;
  292. self.tableView.height += self.tabBarController.tabBar.height;
  293. self.view.height += self.tabBarController.tabBar.height;
  294. [self.view layoutIfNeeded];
  295. [self.tableView layoutIfNeeded];
  296. self.operationBottomBgView.hidden = YES;
  297. }
  298. [self.tableView reloadData];
  299. }
  300. #pragma mark 移动 isEdit:当前是否为编辑状态
  301. -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{
  302. //移动
  303. if(move){
  304. //默认操作状态为移动状态
  305. self.operationStateEnum = OperationStateEnum2;
  306. self.addBtn.hidden = NO;
  307. [self resetRightBtnAction:NO];
  308. //隐藏tabBar - 并将TableView至底端
  309. self.tabBarController.tabBar.hidden = YES;
  310. self.view.height += self.tabBarController.tabBar.height;
  311. self.tableView.height += self.tabBarController.tabBar.height;
  312. [self.view layoutIfNeeded];
  313. [self.tableView layoutIfNeeded];
  314. //隐藏operationBottomBgView
  315. self.operationBottomBgView.hidden = YES;
  316. }
  317. else{
  318. //隐藏tabBar - 并将TableView至底端有tabBar.height的高
  319. self.tabBarController.tabBar.hidden = YES;
  320. self.view.height -= self.tabBarController.tabBar.height;
  321. self.tableView.height -= self.tabBarController.tabBar.height;
  322. [self.view layoutIfNeeded];
  323. [self.tableView layoutIfNeeded];
  324. //显示operationBottomBgView
  325. self.operationBottomBgView.hidden = NO;
  326. if(isEdit){
  327. self.operationStateEnum = OperationStateEnum1;
  328. self.addBtn.hidden = YES;
  329. [self resetRightBtnAction:YES];
  330. }else{
  331. [self changeToOperation:NO];
  332. }
  333. }
  334. [self.tableView reloadData];
  335. }
  336. -(void)resetRightBtnAction:(BOOL)isShowMenu{
  337. WS(weakSelf);
  338. if(isShowMenu){
  339. [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
  340. [self.addBtn setAction:^{
  341. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
  342. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
  343. view.menuColor = RGB(255, 255, 255);
  344. view.separatorColor = RGB(234, 234, 234);
  345. view.textColor = RGB(102, 102, 102);
  346. view.textFont = [UIFont systemFontOfSize:16.0];
  347. view.menuCellHeight = 43.5;
  348. view.maxDisplayCount = 10;
  349. view.offset = -6;
  350. [view show];
  351. }];
  352. }else{
  353. [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal];
  354. [self.addBtn setAction:^{
  355. [ShowtipTool showErrorWithStatus:@"未做"];
  356. }];
  357. }
  358. }
  359. - (void)backAction:(id)sender{
  360. if (self.iSViewEditor) {
  361. [self changeToOperation:NO];
  362. }else{
  363. [self.navigationController popViewControllerAnimated:true];
  364. }
  365. }
  366. - (void)menuAction:(id)sender{
  367. [super menuAction:sender];
  368. }
  369. - (void)getData
  370. {
  371. WS(weakSelf);
  372. [self.dataArray removeAllObjects];
  373. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  374. [dic setValue:@(self.ParentId) forKey:@"ParentId"];
  375. [dic setValue:@(CreateNotesType) forKey:@"TypeId"];
  376. [dic setValue:@[@(self.folderId)] forKey:@"FolderIds"];
  377. [[HttpManager sharedHttpManager] POSTWithUrl:Host(API_APP_Middle_Search_Note_Folder) parameters:dic success:^(id _Nonnull responseObject) {
  378. NSLog(@"文件夹数据%@",responseObject);
  379. for (NSDictionary * dict in responseObject) {
  380. MyTDTSEModel * model = [MyTDTSEModel modelWithDictionary:dict];
  381. [weakSelf.dataArray addObject:model];
  382. }
  383. if (weakSelf.dataArray.count == 0) {
  384. weakSelf.tableView.hidden = YES;
  385. weakSelf.noDataView.hidden = NO;
  386. }else{
  387. dispatch_async(dispatch_get_main_queue(), ^{
  388. weakSelf.tableView.hidden = NO;
  389. weakSelf.noDataView.hidden = YES;
  390. [weakSelf upDateAddBtn];
  391. [weakSelf.tableView reloadData];
  392. });
  393. }
  394. } failure:^(NSError * _Nonnull error) {
  395. SHOWERROR([ZYCTool handerResultData:error]);
  396. }];
  397. }
  398. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  399. {
  400. return 1;
  401. }
  402. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  403. {
  404. return self.dataArray.count;
  405. }
  406. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  407. {
  408. return 70.f;
  409. }
  410. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  411. {
  412. WS(weakSelf);
  413. [self setOperationAllButton];
  414. MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
  415. switch (self.operationStateEnum) {
  416. case OperationStateEnum0:
  417. {
  418. switch (model.RoleId) {
  419. case 1:
  420. {
  421. MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell0:tableView indexPath:indexPath];
  422. cell.NameL.text = model.Name;
  423. cell.fileImgV.image = IMG(@"find_1");
  424. cell.subNameL.text = @"公开";
  425. cell.IsTopImgV.hidden = !model.IsTop;
  426. [cell.comeBtn setAction:^{
  427. MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
  428. vc.ParentId = model.Id;
  429. vc.folderId = model.Id;
  430. vc.titleStr = model.Name;
  431. vc.isSubVC = YES;
  432. [weakSelf.navigationController pushViewController:vc animated:YES];
  433. }];
  434. return cell;
  435. }
  436. break;
  437. default:
  438. {
  439. MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell0:tableView indexPath:indexPath];
  440. cell.NameL.text = model.Name;
  441. cell.fileImgV.image = IMG(@"find_1");
  442. cell.subNameL.text = [NSString stringWithFormat:@"共享给:%@",model.EnjoyUser];
  443. cell.IsTopImgV.hidden = !model.IsTop;
  444. [cell.comeBtn setAction:^{
  445. MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
  446. vc.ParentId = model.Id;
  447. vc.folderId = model.Id;
  448. vc.titleStr = model.Name;
  449. vc.isSubVC = YES;
  450. [weakSelf.navigationController pushViewController:vc animated:YES];
  451. }];
  452. return cell;
  453. }
  454. break;
  455. }
  456. }
  457. break;
  458. default:
  459. {
  460. switch (model.RoleId) {
  461. case 1:
  462. {
  463. MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell1:tableView indexPath:indexPath];
  464. cell.NameL.text = model.Name;
  465. cell.fileImgV.image = IMG(@"find_1");
  466. cell.subNameL.text = @"公开";
  467. cell.IsTopImgV.hidden = !model.IsTop;
  468. cell.selectBtn.selected = model.isSelect;
  469. [cell.selectBtn setAction:^{
  470. model.isSelect = !model.isSelect;
  471. dispatch_async(dispatch_get_main_queue(), ^{
  472. [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
  473. });
  474. }];
  475. return cell;
  476. }
  477. break;
  478. default:
  479. {
  480. MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell1:tableView indexPath:indexPath];
  481. cell.NameL.text = model.Name;
  482. cell.fileImgV.image = IMG(@"find_1");
  483. cell.subNameL.text = [NSString stringWithFormat:@"共享给:%@",model.EnjoyUser];
  484. cell.selectBtn.selected = model.isSelect;
  485. [cell.selectBtn setAction:^{
  486. model.isSelect = !model.isSelect;
  487. dispatch_async(dispatch_get_main_queue(), ^{
  488. [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
  489. });
  490. }];
  491. return cell;
  492. }
  493. break;
  494. }
  495. }
  496. break;
  497. }
  498. }
  499. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  500. {
  501. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  502. MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
  503. switch (self.operationStateEnum) {
  504. case OperationStateEnum1:{
  505. NSLog(@"编辑状态的cell");
  506. model.isSelect = !model.isSelect;
  507. [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
  508. }break;
  509. default:{
  510. NSLog(@"正常状态的cell");
  511. NSDictionary * dict = @{@"Id":@(model.Id),@"Name":model.Name};
  512. [[NSNotificationCenter defaultCenter] postNotificationName:SELECTEXTENTSUCCESS object:nil userInfo:dict];
  513. [self backViewController];
  514. }break;
  515. }
  516. }
  517. -(void)backViewController
  518. {
  519. for ( int i = 0 ;i< self.navigationController.viewControllers.count;i++) {
  520. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicCreateVC")]) {
  521. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  522. return;
  523. }
  524. }
  525. }
  526. - (NSMutableArray *)dataArray
  527. {
  528. if (!_dataArray) {
  529. _dataArray = [NSMutableArray array];
  530. }
  531. return _dataArray;
  532. }
  533. @end