MyTDTopicSelectExtentVC.m 24 KB

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