TDInterLeterHomeViewController.m 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  1. //
  2. // TDInterLeterHomeViewController.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/9.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "TDInterLeterHomeViewController.h"
  9. #import "ChatMsgNoticeCell.h"
  10. #import "YCMenuView.h"
  11. #import "ShowNewGroupAlert.h"
  12. #import "TDInterLeterTypeVC.h"
  13. #import "TDInterLeterSearchVC.h"
  14. #import "NoticeNewGroupVC.h"
  15. #import "MoveViewController.h"
  16. #import "CreateInterLeterVC.h"
  17. #import "MyTDTopicCreateVC.h"
  18. #import "MyTDTopicDetailVC.h"
  19. #import "NSDate+Extension.h"
  20. #import "ShowBtn.h"
  21. #import "MyTDGroupView.h"
  22. @interface TDInterLeterHomeViewController ()<UITableViewDelegate,UITableViewDataSource,TDInterLeterTypeVCDelegate>
  23. //@property (weak, nonatomic) IBOutlet UITableView *tableView;
  24. @property (strong, nonatomic) UITableView *tableView;
  25. @property (weak, nonatomic) IBOutlet ShowBtn *titleBtn;
  26. @property (weak, nonatomic) IBOutlet UIButton *rightAddBtn;
  27. @property (weak, nonatomic) IBOutlet UIButton *rightEditBtn;
  28. @property (weak, nonatomic) IBOutlet UILabel *titleLable;
  29. @property (weak, nonatomic) IBOutlet UIButton *deleteSelectBtn;
  30. @property (weak, nonatomic) IBOutlet UIView *NavBar;
  31. @property (weak, nonatomic) IBOutlet UIView *HeadView;
  32. @property (strong, nonatomic) MyTDGroupView *SearchView;
  33. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *HeadHight;
  34. @property (strong, nonatomic) UIButton *leftCloseBtn;
  35. @property (strong, nonatomic) UIButton *rightMoveBtn;
  36. @property (strong, nonatomic) UILabel *LineL;
  37. @property (strong, nonatomic) NSMutableArray *taskActionArray;
  38. @property (strong, nonatomic) TDInterLeterTypeVC *tDInterLeterTypeVC;
  39. @property (assign, nonatomic) PageTypeFromTitleBtn pageType;
  40. @property (assign, nonatomic) NSUInteger currentPage;
  41. @property (assign, nonatomic) BOOL isFresh;
  42. @property (assign, nonatomic) NSInteger totalRecord;
  43. @property (strong, nonatomic) NSMutableArray<InterLeterSubModel * >*interLetterArray;
  44. //界面操作状态参数
  45. @property (assign,nonatomic) OperationStateEnum operationStateEnum;
  46. //界面操作视图
  47. @property (strong,nonatomic) UIView *operationBottomBgView;
  48. @property (weak, nonatomic) IBOutlet UIButton *operationAllSelectButton;
  49. @property (nonatomic, assign) BOOL iSViewEditor;
  50. @property (strong,nonatomic) UIButton *opearateLeftBtn;
  51. @property (strong,nonatomic) UIButton *opearateRightBtn;
  52. @property (assign,nonatomic) BOOL isAllselect;
  53. @property (assign,nonatomic) BOOL addTableH;
  54. @property (assign,nonatomic) BOOL removeTableH;
  55. @property (strong,nonatomic) UIView *deleteView;
  56. @end
  57. @implementation TDInterLeterHomeViewController
  58. +(TDInterLeterHomeViewController *)initChatMsgNoticeVC{
  59. TDInterLeterHomeViewController *controller = [StoryboardManager.shared.interLeterHome instantiateViewControllerWithIdentifier:@"TDInterLeterHome"];
  60. return controller;
  61. }
  62. - (void)viewWillAppear:(BOOL)animated{
  63. [super viewWillAppear:animated];
  64. [self headRefresh];
  65. }
  66. - (MyTDGroupView *)SearchView
  67. {
  68. if (!_SearchView) {
  69. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  70. }
  71. return _SearchView;
  72. }
  73. - (UITableView *)tableView
  74. {
  75. if (!_tableView) {
  76. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  77. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  78. }
  79. return _tableView;
  80. }
  81. - (void)autoSizeBtn:(NSString *)title
  82. {
  83. [self.titleBtn setLabelTitle:title];
  84. }
  85. - (void)viewDidLoad {
  86. [super viewDidLoad];
  87. self.fd_prefersNavigationBarHidden = YES;
  88. self.fd_interactivePopDisabled = YES;
  89. self.view.backgroundColor = RGB(255, 255, 255);
  90. if (@available(iOS 11.0, *)) {
  91. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  92. } else {
  93. self.automaticallyAdjustsScrollViewInsets = NO;
  94. }
  95. [self.HeadView addSubview:self.SearchView];
  96. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.top.mas_offset(6);
  98. make.left.right.mas_equalTo(self.HeadView);
  99. make.height.mas_offset(36);
  100. }];
  101. WS(weakSelf);
  102. [self.SearchView.button setAction:^{
  103. TDInterLeterSearchVC *vc = [[TDInterLeterSearchVC alloc] init];
  104. vc.FolderId = weakSelf.interLeterFolderId;
  105. vc.type = weakSelf.pageType;
  106. [weakSelf.navigationController pushViewController:vc animated:YES];
  107. }];
  108. [self.view addSubview:self.tableView];
  109. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.left.right.mas_equalTo(self.view);
  111. make.top.mas_equalTo(self.HeadView.mas_bottom);
  112. if (@available(iOS 11.0, *)) {
  113. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  114. } else {
  115. make.bottom.equalTo(self.view.mas_bottom);
  116. }
  117. }];
  118. self.tableView.delegate = self;
  119. self.tableView.dataSource = self;
  120. self.tableView.backgroundColor = [UIColor clearColor];
  121. self.pageType = PageTypeFromTitleAll;
  122. [self autoSizeBtn:@"全部"];
  123. [self.titleBtn setAction:^{
  124. weakSelf.tDInterLeterTypeVC.view.hidden = !weakSelf.tDInterLeterTypeVC.view.hidden;
  125. if(weakSelf.tDInterLeterTypeVC.view.hidden){
  126. [weakSelf.titleBtn dismiss];
  127. }else{
  128. [weakSelf.titleBtn show];
  129. }
  130. }];
  131. [self.rightAddBtn setAction:^{
  132. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray];
  133. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.rightAddBtn];
  134. view.menuColor = RGB(255, 255, 255);
  135. view.separatorColor = RGB(234, 234, 234);
  136. view.textColor = RGB(102, 102, 102);
  137. view.textFont = [UIFont systemFontOfSize:16.0];
  138. view.menuCellHeight = 43.5;
  139. view.maxDisplayCount = 10;
  140. view.offset = -6;
  141. [view show];
  142. }];
  143. [self.rightEditBtn setAction:^{
  144. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  145. vc.type = CollectModel_InterMail;
  146. vc.replayType = MailReplayCreate;
  147. vc.FolderId = weakSelf.interLeterFolderId;
  148. vc.upDateBlock = ^{
  149. [weakSelf headRefresh];
  150. };
  151. [weakSelf.navigationController pushViewController:vc animated:YES];
  152. }];
  153. [self.deleteSelectBtn setAction:^{
  154. [weakSelf changeToOperation:YES];
  155. }];
  156. [self.view addSubview:self.tDInterLeterTypeVC.view];
  157. [self initBottomBgView];
  158. [self initDeleteView];
  159. [self changeToOperation:NO];
  160. self.iSViewEditor = NO;
  161. }
  162. #pragma mark - 批量编辑
  163. -(UIView *)deleteView{
  164. if(!_deleteView){
  165. _deleteView = [[UIView alloc] init];
  166. CGFloat bottomBgViewH = self.tabBarController.tabBar.height;
  167. _deleteView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
  168. _deleteView.backgroundColor = RGB(255, 255, 255);
  169. _deleteView.hidden = YES;
  170. }
  171. return _deleteView;
  172. }
  173. -(void)initDeleteView
  174. {
  175. UIButton *leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  176. [leftCloseBtn setTitle:@"全部删除" forState:UIControlStateNormal];
  177. [leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
  178. leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  179. [self.deleteView addSubview:leftCloseBtn];
  180. leftCloseBtn.frame = CGRectMake(0, 0, SCREEN_WIDTH/2, self.deleteView.height);
  181. UIButton *rightMoveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  182. [rightMoveBtn setTitle:@"全部恢复" forState:UIControlStateNormal];
  183. [rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
  184. rightMoveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  185. [self.deleteView addSubview:rightMoveBtn];
  186. rightMoveBtn.frame = CGRectMake(SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, self.deleteView.height);
  187. UILabel * topLine = [[UILabel alloc] init];
  188. topLine.backgroundColor = RGB(240, 239, 244);
  189. [self.deleteView addSubview:topLine];
  190. topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 0.5);
  191. UILabel *line = [[UILabel alloc] init];
  192. line.backgroundColor = RGB(240, 239, 244);
  193. [self.deleteView addSubview:line];
  194. line.frame = CGRectMake(SCREEN_WIDTH/2, 0, .5, self.deleteView.height);
  195. WS(weakSelf);
  196. [leftCloseBtn setAction:^{
  197. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认全部删除" preferredStyle:UIAlertControllerStyleAlert];
  198. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  199. }];
  200. [ok setValue:k9 forKey:@"_titleTextColor"];
  201. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  202. SHOWLOADING
  203. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_Find_DeleteRecord_All),5];
  204. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  205. REMOVESHOW
  206. [weakSelf headRefresh];
  207. } failure:^(NSError * _Nonnull error) {
  208. SHOWERROR([ZYCTool handerResultData:error]);
  209. }];
  210. }];
  211. [alertVC addAction:ok];
  212. [alertVC addAction:noOk];
  213. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  214. }];
  215. [rightMoveBtn setAction:^{
  216. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认全部恢复" preferredStyle:UIAlertControllerStyleAlert];
  217. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  218. }];
  219. [ok setValue:k9 forKey:@"_titleTextColor"];
  220. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  221. SHOWLOADING
  222. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_Find_Recover_All),5];
  223. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  224. REMOVESHOW
  225. [weakSelf headRefresh];
  226. } failure:^(NSError * _Nonnull error) {
  227. SHOWERROR([ZYCTool handerResultData:error]);
  228. }];
  229. }];
  230. [alertVC addAction:ok];
  231. [alertVC addAction:noOk];
  232. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  233. }];
  234. [[UtilsTools getWindow] addSubview:self.deleteView];
  235. }
  236. - (void)changeBarBtn:(BOOL)isHidden
  237. {
  238. self.rightAddBtn.hidden = isHidden;
  239. self.rightEditBtn.hidden = isHidden;
  240. self.deleteSelectBtn.hidden = !isHidden;
  241. self.deleteView.hidden = !isHidden;
  242. if(self.pageType == PageTypeFromTitleDeleted){
  243. if (!self.removeTableH) {
  244. self.addTableH = YES;
  245. self.removeTableH = YES;
  246. self.view.height -= self.tabBarController.tabBar.height;
  247. self.tableView.height -= self.tabBarController.tabBar.height;
  248. [self.view layoutIfNeeded];
  249. [self.tableView layoutIfNeeded];
  250. }
  251. }else{
  252. if (self.addTableH) {
  253. self.addTableH = NO;
  254. self.removeTableH = NO;
  255. self.tableView.height += self.tabBarController.tabBar.height;
  256. self.view.height += self.tabBarController.tabBar.height;
  257. [self.view layoutIfNeeded];
  258. [self.tableView layoutIfNeeded];
  259. }
  260. }
  261. }
  262. - (void)addRefresh
  263. {
  264. WS(weakSelf);
  265. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  266. [weakSelf headRefresh];
  267. }];
  268. // self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  269. // [weakSelf footerRefresh];
  270. // }];
  271. }
  272. - (void)removeRefresh
  273. {
  274. [self.tableView.mj_header endRefreshing];
  275. [self.tableView.mj_header removeFromSuperview];
  276. [self.tableView.mj_footer endRefreshing];
  277. [self.tableView.mj_footer removeFromSuperview];
  278. }
  279. - (void)headRefresh{
  280. self.currentPage = 1;
  281. self.totalRecord = 0;
  282. [self.interLetterArray removeAllObjects];
  283. [self getInterListData];
  284. }
  285. - (void)footerRefresh{
  286. self.currentPage += 1;
  287. if (self.totalRecord == self.interLetterArray.count) {
  288. [self.tableView.mj_footer endRefreshing];
  289. return ;
  290. }
  291. [self getInterListData];
  292. }
  293. - (void)getInterListData{
  294. NSLog(@"%@",@"刷新数据");
  295. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  296. NSUInteger deleteType = 0;
  297. switch (self.pageType) {
  298. case PageTypeFromTitleAll:
  299. {
  300. [self changeBarBtn:NO];
  301. deleteType = 1;
  302. }
  303. break;
  304. case PageTypeFromTitleMy:
  305. {
  306. [self changeBarBtn:NO];
  307. deleteType = 2;
  308. }
  309. break;
  310. case PageTypeFromTitleDraftBox:
  311. {
  312. [self changeBarBtn:NO];
  313. deleteType = 3;
  314. }
  315. break;
  316. case PageTypeFromTitleDeleted:
  317. {
  318. [self changeBarBtn:YES];
  319. deleteType = 4;
  320. }
  321. break;
  322. default:
  323. {
  324. [self changeBarBtn:NO];
  325. deleteType = 5;
  326. }
  327. break;
  328. }
  329. [dict setObject:@(self.currentPage) forKey:@"Page"];
  330. // [dict setObject:@"20" forKey:@"PerPage"];
  331. [dict setObject:@"99999999" forKey:@"PerPage"];
  332. [dict setObject:@(deleteType) forKey:@"SearchType"];
  333. [dict setObject:@"" forKey:@"Key"];
  334. [dict setObject:@(self.interLeterFolderId) forKey:@"FolderId"];
  335. WS(weakSelf);
  336. [[HttpManager sharedHttpManager] POSTUrl:Host(API_InterLetter) parameters:dict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  337. NSLog(@"站内信返回数据%@",responseObject);
  338. InterLeterModel *listModel = [[InterLeterModel alloc] initWithDictionary:responseObject error:nil];
  339. [weakSelf.tableView.mj_header endRefreshing];
  340. [weakSelf.tableView.mj_footer endRefreshing];
  341. weakSelf.totalRecord = listModel.Total;
  342. [weakSelf.interLetterArray addObjectsFromArray:listModel.Items];
  343. if (weakSelf.totalRecord == weakSelf.interLetterArray.count) {
  344. [weakSelf.tableView.mj_footer resetNoMoreData];
  345. [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  346. }
  347. [weakSelf.tableView reloadData];
  348. } failure:^(NSError * _Nonnull error) {
  349. SHOWERROR([ZYCTool handerResultData:error]);
  350. [weakSelf.tableView.mj_header endRefreshing];
  351. [weakSelf.tableView.mj_footer endRefreshing];
  352. }];
  353. }
  354. - (TDInterLeterTypeVC *)tDInterLeterTypeVC{
  355. if (_tDInterLeterTypeVC == nil) {
  356. _tDInterLeterTypeVC = [TDInterLeterTypeVC initTDInterLeterTypeVC];
  357. [_tDInterLeterTypeVC.view setFrame:CGRectMake(0, kNavigationHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kNavigationHeight)];
  358. [_tDInterLeterTypeVC.view setHidden:YES];
  359. _tDInterLeterTypeVC.delegate = self;
  360. }
  361. return _tDInterLeterTypeVC;
  362. }
  363. -(void)userSelectType:(NSString *)typeName{
  364. self.tDInterLeterTypeVC.view.hidden = !self.tDInterLeterTypeVC.view.hidden;
  365. if(self.tDInterLeterTypeVC.view.hidden){
  366. [self.titleBtn dismiss];
  367. }else{
  368. [self.titleBtn show];
  369. }
  370. if(typeName.length > 0){
  371. [self autoSizeBtn:typeName];
  372. if([@"全部" isEqualToString:typeName]){
  373. self.pageType = PageTypeFromTitleAll;
  374. }else if([@"我发出的" isEqualToString:typeName]){
  375. self.pageType = PageTypeFromTitleMy;
  376. }else if([@"草稿箱" isEqualToString:typeName]){
  377. self.pageType = PageTypeFromTitleDraftBox;
  378. }else if([@"已删除" isEqualToString:typeName]){
  379. self.pageType = PageTypeFromTitleDeleted;
  380. }else if([@"匿名信" isEqualToString:typeName]){
  381. self.pageType = PageTypeFromTitleNoSign;
  382. }
  383. [self headRefresh];
  384. }
  385. }
  386. #pragma Mark 左滑按钮 iOS8以上
  387. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  388. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  389. InterLeterSubModel *model = self.interLetterArray[indexPath.row];
  390. WS(weakSelf);
  391. switch (self.pageType) {
  392. case PageTypeFromTitleAll:{
  393. switch (model.AttributeValue) {
  394. case 2:{
  395. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  396. [tableView setEditing:NO animated:YES];
  397. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  398. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  399. }];
  400. [ok setValue:k9 forKey:@"_titleTextColor"];
  401. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  402. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:NO];
  403. }];
  404. [alertVC addAction:ok];
  405. [alertVC addAction:noOk];
  406. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  407. }];
  408. action1.backgroundColor = RGB(255, 59, 47);
  409. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  410. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
  411. NSLog(@"%@",groupName);
  412. [weakSelf reNameFind:model withReNameString:groupName];
  413. } cancle:^{
  414. }] show];
  415. }];
  416. action2.backgroundColor = RGB(255, 149, 3);
  417. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  418. [weakSelf topFind:model];
  419. }];
  420. action3.backgroundColor = RGB(197, 201, 204);
  421. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
  422. actions.performsFirstActionWithFullSwipe = NO;
  423. return actions;
  424. }break;
  425. case 3:{
  426. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  427. [weakSelf topFind:model];
  428. }];
  429. action1.backgroundColor = RGB(197, 201, 204);
  430. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
  431. actions.performsFirstActionWithFullSwipe = NO;
  432. return actions;
  433. }break;
  434. default:{
  435. WEAKSELF
  436. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  437. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  438. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  439. }];
  440. [ok setValue:k9 forKey:@"_titleTextColor"];
  441. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  442. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:NO];
  443. }];
  444. [alertVC addAction:ok];
  445. [alertVC addAction:noOk];
  446. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  447. }];
  448. action1.backgroundColor = RGB(255, 59, 47);
  449. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"移动" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  450. STRONGSELF
  451. [strongSelf launchMoveVC:@[@(model.Id)].mutableCopy];
  452. }];
  453. action2.backgroundColor = UIColorHex(0x589AF1);
  454. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  455. STRONGSELF
  456. [strongSelf topFind:model];
  457. }];
  458. action3.backgroundColor = RGB(197, 201, 204);
  459. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
  460. actions.performsFirstActionWithFullSwipe = NO;
  461. return actions;
  462. }
  463. break;
  464. }
  465. }break;
  466. case PageTypeFromTitleDeleted:
  467. {
  468. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"彻底删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  469. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  470. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  471. }];
  472. [ok setValue:k9 forKey:@"_titleTextColor"];
  473. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  474. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:YES];
  475. }];
  476. [alertVC addAction:ok];
  477. [alertVC addAction:noOk];
  478. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  479. }];
  480. action1.backgroundColor = RGB(255, 59, 47);
  481. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
  482. actions.performsFirstActionWithFullSwipe = NO;
  483. return actions;
  484. }
  485. break;
  486. default:
  487. {
  488. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  489. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  490. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  491. }];
  492. [ok setValue:k9 forKey:@"_titleTextColor"];
  493. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  494. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:NO];
  495. }];
  496. [alertVC addAction:ok];
  497. [alertVC addAction:noOk];
  498. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  499. }];
  500. action1.backgroundColor = RGB(255, 59, 47);
  501. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  502. [weakSelf topFind:model];
  503. }];
  504. action2.backgroundColor = RGB(197, 201, 204);
  505. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
  506. actions.performsFirstActionWithFullSwipe = NO;
  507. return actions;
  508. }
  509. break;
  510. }
  511. }
  512. #else
  513. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  514. InterLeterSubModel *model = self.interLetterArray[indexPath.row];
  515. switch (self.pageType) {
  516. case PageTypeFromTitleAll:{
  517. switch (model.AttributeValue) {
  518. case 2:{
  519. WEAKSELF
  520. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  521. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  522. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  523. }];
  524. [ok setValue:k9 forKey:@"_titleTextColor"];
  525. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  526. [weakSelf deleteFind:@[model].mutableCopy];
  527. }];
  528. [alertVC addAction:ok];
  529. [alertVC addAction:noOk];
  530. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  531. }];
  532. action1.backgroundColor = RGB(255, 59, 47);
  533. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"重命名" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  534. WEAKSELF
  535. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
  536. NSLog(@"%@",groupName);
  537. STRONGSELF
  538. [strongSelf reNameFind:model withReNameString:groupName];
  539. } cancle:^{
  540. }] show];
  541. }];
  542. action2.backgroundColor = RGB(255, 149, 3);
  543. UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  544. STRONGSELF
  545. [strongSelf topFind:model];
  546. }];
  547. action3.backgroundColor = RGB(197, 201, 204);
  548. return @[action1, action2, action3];
  549. }break;
  550. case 3:{
  551. WEAKSELF
  552. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  553. STRONGSELF
  554. [strongSelf topFind:model];
  555. }];
  556. action1.backgroundColor = RGB(197, 201, 204);
  557. return @[action1];
  558. }break;
  559. default:{
  560. WEAKSELF
  561. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  562. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  563. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  564. }];
  565. [ok setValue:k9 forKey:@"_titleTextColor"];
  566. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  567. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:NO];
  568. }];
  569. [alertVC addAction:ok];
  570. [alertVC addAction:noOk];
  571. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  572. }];
  573. action1.backgroundColor = RGB(255, 59, 47);
  574. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"移动" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  575. STRONGSELF
  576. [strongSelf launchMoveVC:@[@(model.Id)].mutableCopy];
  577. }];
  578. action2.backgroundColor = UIColorHex(0x589AF1);
  579. UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  580. STRONGSELF
  581. [strongSelf topFind:model];
  582. }];
  583. action3.backgroundColor = RGB(197, 201, 204);
  584. return @[action1, action2, action3];
  585. }
  586. break;
  587. }
  588. }break;
  589. case PageTypeFromTitleDeleted:
  590. {
  591. WEAKSELF
  592. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"彻底删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  593. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  594. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  595. }];
  596. [ok setValue:k9 forKey:@"_titleTextColor"];
  597. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  598. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:YES];
  599. }];
  600. [alertVC addAction:ok];
  601. [alertVC addAction:noOk];
  602. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  603. }];
  604. action1.backgroundColor = RGB(255, 59, 47);
  605. return @[action1];
  606. }
  607. break;
  608. default:
  609. {
  610. WEAKSELF
  611. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  612. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  613. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  614. }];
  615. [ok setValue:k9 forKey:@"_titleTextColor"];
  616. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  617. [weakSelf thoroughDelete:@[model].mutableCopy isDelete:NO];
  618. }];
  619. [alertVC addAction:ok];
  620. [alertVC addAction:noOk];
  621. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  622. }];
  623. action1.backgroundColor = RGB(255, 59, 47);
  624. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  625. STRONGSELF
  626. [strongSelf topFind:model];
  627. }];
  628. action2.backgroundColor = RGB(197, 201, 204);
  629. return @[action1, action2];
  630. }
  631. break;
  632. }
  633. }
  634. #endif
  635. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  636. return 1;
  637. }
  638. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  639. return self.interLetterArray.count;
  640. }
  641. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  642. InterLeterSubModel *model = self.interLetterArray[indexPath.row];
  643. switch (model.AttributeValue) {
  644. case 1:
  645. return [ChatMsgNoticeCell configCell2Height];
  646. case 2:
  647. return [ChatMsgNoticeCell configCell1Height];
  648. default:
  649. return 0;
  650. }
  651. }
  652. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  653. // if (indexPath.section == 0) {
  654. // ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell0:tableView indexPath:indexPath];
  655. // WS(weakSelf);
  656. // [cell.cell0SearchBtn setAction:^{
  657. // TDInterLeterSearchVC *vc = [[TDInterLeterSearchVC alloc] init];
  658. // vc.FolderId = weakSelf.interLeterFolderId;
  659. // vc.type = weakSelf.pageType;
  660. // [weakSelf.navigationController pushViewController:vc animated:YES];
  661. // }];
  662. // return cell;
  663. // }
  664. InterLeterSubModel *model = self.interLetterArray[indexPath.row];
  665. switch (self.operationStateEnum) {
  666. case OperationStateEnum0:{
  667. switch (model.AttributeValue) {
  668. case 1:{
  669. switch (self.pageType) {
  670. case PageTypeFromTitleAll:{
  671. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  672. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  673. cell.cell2TitleLabel.text = model.Title;
  674. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  675. cell.cell2TimeLabel.text = [NSDate getTimeStringAutoShort2:model.CreatedDate];
  676. cell.IsTopImgV.hidden = !model.IsTop;
  677. cell.cell2RedBgView.hidden = model.IsRead;
  678. return cell;
  679. }
  680. break;
  681. case PageTypeFromTitleMy:
  682. {
  683. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  684. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  685. cell.cell2TitleLabel.text = model.Title;
  686. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  687. cell.cell2TimeLabel.text = [NSDate getTimeStringAutoShort2:model.CreatedDate];
  688. cell.cell2RedBgView.hidden = model.IsRead;
  689. cell.IsTopImgV.hidden = !model.IsTop;
  690. return cell;
  691. }
  692. break;
  693. case PageTypeFromTitleDraftBox:
  694. {
  695. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  696. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  697. cell.cell2TitleLabel.text = model.Title;
  698. cell.cell2UnReadNumberLbl.hidden = YES;
  699. if (model.MissiveType == 2) {
  700. cell.cell2IntroLabel.text = @"匿名";
  701. }else{
  702. if (model.EnjoyUser.length == 0) {
  703. cell.cell2IntroLabel.hidden = YES;
  704. }else{
  705. if (model.EnjoyUser.length > 13) {
  706. NSRange range1 = NSMakeRange(10, (model.EnjoyUser.length - 10));
  707. NSString *resultStr1 = [model.EnjoyUser stringByReplacingCharactersInRange:range1 withString:@"..."];
  708. cell.cell2IntroLabel.text = [NSString stringWithFormat:@"收件人:%@",resultStr1];
  709. }else{
  710. cell.cell2IntroLabel.text = [NSString stringWithFormat:@"收件人:%@",model.EnjoyUser];
  711. }
  712. }
  713. }
  714. cell.cell2EditBtn.hidden = NO;
  715. WS(weakSelf);
  716. [cell.cell2EditBtn setAction:^{
  717. NSLog(@"编辑草稿箱站内信");
  718. [weakSelf editorButtonHander:indexPath];
  719. }];
  720. cell.cell2RedBgView.hidden = model.IsRead;
  721. cell.cell2TimeLabel.hidden = YES;
  722. return cell;
  723. }
  724. break;
  725. case PageTypeFromTitleDeleted:
  726. {
  727. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  728. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  729. cell.cell2TitleLabel.text = model.Title;
  730. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  731. cell.cell2EditBtn.hidden = NO;
  732. cell.cell2RedBgView.hidden = YES;
  733. cell.cell2TimeLabel.hidden = YES;
  734. [cell.cell2EditBtn setTitle:@"恢复" forState:UIControlStateNormal];
  735. WS(weakSelf);
  736. [cell.cell2EditBtn setAction:^{
  737. NSLog(@"恢复已删除站内信");
  738. [weakSelf reDoDeleteFind:@[model].mutableCopy];
  739. }];
  740. return cell;
  741. }break;
  742. default:
  743. {
  744. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  745. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  746. cell.cell2TitleLabel.text = model.Title;
  747. //cell.cell2IntroLabel.text = @"匿名";
  748. cell.IsTopImgV.hidden = !model.IsTop;
  749. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  750. cell.cell2RedBgView.hidden = model.IsRead;
  751. return cell;
  752. }
  753. break;
  754. }
  755. }break;
  756. case 2:{
  757. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell1:tableView indexPath:indexPath];
  758. cell.cell1TitleLabel.text = model.FolderName;
  759. cell.IsTopImgV.hidden = !model.IsTop;
  760. cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount];
  761. return cell;
  762. }break;
  763. default:{
  764. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  765. return cell;
  766. }
  767. break;
  768. }
  769. }break;
  770. case OperationStateEnum1:{
  771. self.isAllselect = [self checkNoticeArray];
  772. [self setingMoveButton];
  773. [self.operationAllSelectButton setTitle:self.isAllselect ? @"取消全选": @"全选" forState:UIControlStateNormal];
  774. switch (model.AttributeValue) {
  775. case 1:{
  776. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell20:tableView indexPath:indexPath];
  777. cell.cell2UserImgView.image = [UIImage imageNamed:@"站内信图"];
  778. cell.cell2TitleLabel.text = model.Title;
  779. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  780. cell.cell2TimeLabel.hidden = YES;
  781. cell.cell1TimeLabel.hidden = YES;
  782. cell.enterBtn.hidden = YES;
  783. cell.cell2SelectButton.selected = model.IsSelect;
  784. [cell.cell2SelectButton setAction:^{
  785. model.IsSelect = !model.IsSelect;
  786. [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  787. }];
  788. return cell;
  789. }break;
  790. case 2:{
  791. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell10:tableView indexPath:indexPath];
  792. cell.cell1TitleLabel.text = model.FolderName;
  793. cell.cell2TimeLabel.hidden = YES;
  794. cell.cell1TimeLabel.hidden = YES;
  795. cell.enterBtn.hidden = YES;
  796. cell.IsTopImgV.hidden = YES;
  797. [self setIntroLabelWithModel:model introLabel:cell.cell2IntroLabel unreadNumberLabel:cell.cell2UnReadNumberLbl];
  798. cell.cell1SelectButton.selected = model.IsSelect;
  799. [cell.cell2SelectButton setAction:^{
  800. model.IsSelect = !model.IsSelect;
  801. [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  802. }];
  803. return cell;
  804. }break;
  805. default:{
  806. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  807. return cell;
  808. }
  809. break;
  810. }
  811. }break;
  812. default:
  813. {
  814. ChatMsgNoticeCell *cell = [ChatMsgNoticeCell configCell2:tableView indexPath:indexPath];
  815. cell.cell2RedBgView.hidden = YES;
  816. return cell;
  817. }
  818. break;
  819. }
  820. }
  821. - (BOOL)checkNoticeArray
  822. {
  823. BOOL isFloder = NO;
  824. for (InterLeterSubModel * model in self.interLetterArray) {
  825. if (model.AttributeValue == 2) {
  826. if (model.IsSelect) {
  827. SHOWERROR(@"文件夹不能移动");
  828. isFloder = YES;
  829. }
  830. }
  831. }
  832. [self.rightMoveBtn setEnabled:!isFloder];
  833. if(self.interLetterArray.count == 0)
  834. {
  835. return NO;
  836. }else{
  837. for (InterLeterSubModel * model in self.interLetterArray) {
  838. if (model.AttributeValue == 1 || model.AttributeValue == 2) {
  839. if (!model.IsSelect) {
  840. return NO;
  841. }
  842. }
  843. }
  844. return YES;
  845. }
  846. }
  847. - (void)setIntroLabelWithModel:(InterLeterSubModel *)model introLabel:(UILabel *)introLabel unreadNumberLabel:(UILabel *)unreadNumberLabel {
  848. //判断是否匿名
  849. if (model.IsAdmin == YES) {
  850. if (model.EnjoyUser.length > 10) {
  851. NSRange range1 = NSMakeRange(10, (model.EnjoyUser.length - 10));
  852. NSString *resultStr1 = [model.EnjoyUser stringByReplacingCharactersInRange:range1 withString:@"..."];
  853. introLabel.text = [NSString stringWithFormat:@"收件人:%@",resultStr1];
  854. }else{
  855. introLabel.text = [NSString stringWithFormat:@"收件人:%@",model.EnjoyUser];
  856. }
  857. unreadNumberLabel.text = [NSString stringWithFormat:@"已读:%ld/%ld",(long)model.ReadCount,(long)model.AllCount];
  858. }else {
  859. if (model.MissiveType == 2) {
  860. introLabel.text = @"匿名";
  861. unreadNumberLabel.text = nil;
  862. }else {
  863. introLabel.text = model.SendName;
  864. unreadNumberLabel.text = [NSString stringWithFormat:@"已读:%ld/%ld",(long)model.ReadCount,(long)model.AllCount];
  865. }
  866. }
  867. }
  868. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  869. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  870. InterLeterSubModel *model = self.interLetterArray[indexPath.row];
  871. switch (self.operationStateEnum) {
  872. case OperationStateEnum0:
  873. {
  874. switch (model.AttributeValue) {
  875. case 2:{
  876. TDInterLeterHomeViewController *vc = [TDInterLeterHomeViewController initChatMsgNoticeVC];
  877. vc.interLeterFolderId = model.Id;
  878. vc.interLeterFoldName = model.FolderName;
  879. [self.navigationController pushViewController:vc animated:YES];
  880. }break;
  881. default:{
  882. if (self.pageType == PageTypeFromTitleDraftBox) {
  883. [self editorButtonHander:indexPath];
  884. }else{
  885. switch (model.MissiveType) {
  886. case 1:
  887. {
  888. MyTDTopicDetailVC *vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  889. // vc.detailType = (model.MissiveType == 1)? InterLeterDetialType_Sign : InterLeterDetialType_NoSign;
  890. vc.Id = model.MiddleId;
  891. vc.type = CollectModel_InterMail;
  892. [self.navigationController pushViewController:vc animated:YES];
  893. }break;
  894. case 2:{
  895. MyTDTopicDetailVC *vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  896. vc.Id = model.MiddleId;
  897. vc.type = CollectModel_InterMail;
  898. [self.navigationController pushViewController:vc animated:YES];
  899. }break;
  900. default:
  901. {
  902. MyTDTopicDetailVC *vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  903. // vc.detailType = (model.MissiveType == 1)? InterLeterDetialType_Sign : InterLeterDetialType_NoSign;
  904. vc.Id = model.MiddleId;
  905. vc.type = CollectModel_InterMail;
  906. [self.navigationController pushViewController:vc animated:YES];
  907. }break;
  908. }
  909. }
  910. }break;
  911. }
  912. }break;
  913. default:{
  914. model.IsSelect = !model.IsSelect;
  915. [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
  916. return;
  917. }break;
  918. }
  919. }
  920. #pragma mark - 设置 移动按钮 样式
  921. - (void)setingMoveButton{
  922. NSInteger flag = 1;
  923. for (InterLeterSubModel *model in self.interLetterArray) {
  924. if (model.IsSelect) {
  925. if (model.AttributeValue == 2) {
  926. flag += 1;
  927. }
  928. }
  929. }
  930. if (flag == 1) {
  931. self.opearateRightBtn.enabled = YES;
  932. }else{
  933. self.opearateRightBtn.enabled = NO;
  934. }
  935. }
  936. -(NSMutableArray *)getMenuDataSource:(NSMutableArray *)titleArray{
  937. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  938. for(int i=0;i<titleArray.count;i++){
  939. NSString *titleStr = [titleArray objectAtIndex:i];
  940. WS(weakSelf);
  941. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  942. if([@"建文件夹" isEqualToString:action.title]){
  943. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"建文件夹" placeholder:@"请输入文件夹名称" confirm:^(NSString * _Nonnull groupName) {
  944. NSLog(@"%@",groupName);
  945. [weakSelf addFind:groupName];
  946. } cancle:^{
  947. }] show];
  948. }
  949. else if ([@"批量编辑" isEqualToString:action.title]){
  950. [weakSelf changeToOperation:YES];
  951. }
  952. }];
  953. [menuDataSourceArray addObject:actionMenu];
  954. }
  955. return menuDataSourceArray;
  956. }
  957. -(NSMutableArray *)taskActionArray{
  958. if(!_taskActionArray){
  959. if (self.isHome) {
  960. _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"建文件夹",@"批量编辑", nil];
  961. }else{
  962. _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"批量编辑", nil];
  963. }
  964. }
  965. return _taskActionArray;
  966. }
  967. - (NSMutableArray<InterLeterSubModel *> *)interLetterArray{
  968. if (!_interLetterArray) {
  969. _interLetterArray = [NSMutableArray array];
  970. }
  971. return _interLetterArray;
  972. }
  973. #pragma mark - 批量编辑
  974. -(void)initBottomBgView{
  975. UIButton *leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  976. [leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal];
  977. [leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
  978. leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  979. [self.operationBottomBgView addSubview:leftCloseBtn];
  980. leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10);
  981. self.opearateLeftBtn = leftCloseBtn;
  982. UIButton *rightMoveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  983. [rightMoveBtn setTitle:@"移动" forState:UIControlStateNormal];
  984. [rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
  985. [rightMoveBtn setTitleColor:UIColorHex(#BBBBBB) forState:UIControlStateDisabled];
  986. rightMoveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  987. [self.operationBottomBgView addSubview:rightMoveBtn];
  988. rightMoveBtn.frame = CGRectMake(SCREEN_WIDTH/2, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10);
  989. self.opearateRightBtn = rightMoveBtn;
  990. UILabel *line = [[UILabel alloc] init];
  991. line.backgroundColor = RGB(240, 239, 244);
  992. [self.operationBottomBgView addSubview:line];
  993. line.frame = CGRectMake(SCREEN_WIDTH/2, 0, .5, self.operationBottomBgView.height);
  994. self.leftCloseBtn = leftCloseBtn;
  995. self.rightMoveBtn = rightMoveBtn;
  996. self.LineL = line;
  997. WS(weakSelf);
  998. [leftCloseBtn setAction:^{
  999. NSMutableArray *selectIDArray = [NSMutableArray array];
  1000. for (InterLeterSubModel * model in weakSelf.interLetterArray) {
  1001. if (model.IsSelect) {
  1002. [selectIDArray addObject:model];
  1003. }
  1004. }
  1005. if (selectIDArray.count == 0) {
  1006. SHOWERROR(@"请选择要删除的站内信");
  1007. return ;
  1008. }else{
  1009. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  1010. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1011. }];
  1012. [ok setValue:k9 forKey:@"_titleTextColor"];
  1013. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1014. [weakSelf thoroughDelete:selectIDArray isDelete:NO];
  1015. }];
  1016. [alertVC addAction:ok];
  1017. [alertVC addAction:noOk];
  1018. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  1019. }
  1020. }];
  1021. [rightMoveBtn setAction:^{
  1022. NSMutableArray *selectIDArray = [NSMutableArray array];
  1023. for (InterLeterSubModel * model in weakSelf.interLetterArray) {
  1024. if (model.IsSelect) {
  1025. [selectIDArray addObject:@(model.Id)];
  1026. }
  1027. }
  1028. if (selectIDArray.count == 0) {
  1029. SHOWERROR(@"请选择要移动的站内信或者文件夹");
  1030. return ;
  1031. }
  1032. [weakSelf launchMoveVC:selectIDArray];
  1033. }];
  1034. [[UtilsTools getWindow] addSubview:self.operationBottomBgView];
  1035. }
  1036. - (void)launchMoveVC:(NSMutableArray<NSNumber*>*)selectIDArray{
  1037. MoveViewController * vc = [MoveViewController initMoveViewController];
  1038. vc.TypeId = CreateCommonType;
  1039. vc.collectType = CollectHanderType_Move;
  1040. vc.ParentId = 0;
  1041. vc.titleStr = @"移动到";
  1042. vc.FolderIds = selectIDArray;
  1043. [self.navigationController pushViewController:vc animated:YES];
  1044. [self changeToOperation:NO];
  1045. }
  1046. -(UIView *)operationBottomBgView{
  1047. if(!_operationBottomBgView){
  1048. _operationBottomBgView = [[UIView alloc] init];
  1049. CGFloat bottomBgViewH = self.tabBarController.tabBar.height;
  1050. _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
  1051. _operationBottomBgView.backgroundColor = RGB(255, 255, 255);
  1052. _operationBottomBgView.hidden = YES;
  1053. }
  1054. return _operationBottomBgView;
  1055. }
  1056. #pragma mark 批量操作与正常操作界面切换
  1057. -(void)changeToOperation:(BOOL)operation{
  1058. WS(weakSelf);
  1059. if(self.pageType == PageTypeFromTitleDeleted){
  1060. [self.rightMoveBtn setTitle:@"恢复" forState:UIControlStateNormal];
  1061. [self.rightMoveBtn setAction:^{
  1062. NSMutableArray *MiddleIds = [NSMutableArray array];
  1063. for (InterLeterSubModel *model in weakSelf.interLetterArray) {
  1064. if (model.IsSelect) {
  1065. [MiddleIds addObject:@(model.Id)];
  1066. }
  1067. }
  1068. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  1069. [dic setValue:MiddleIds forKey:@"MiddleIds"];
  1070. [dic setValue:@(5) forKey:@"FolderType"];
  1071. [dic setValue:@(1) forKey:@"IsDelete"];
  1072. [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1073. SHOWLOADING
  1074. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1075. REMOVESHOW
  1076. [weakSelf headRefresh];
  1077. } failure:^(NSError * _Nonnull error) {
  1078. SHOWERROR([ZYCTool handerResultData:error]);
  1079. }];
  1080. }];
  1081. }else{
  1082. [self.rightMoveBtn setTitle:@"移动" forState:UIControlStateNormal];
  1083. [self.rightMoveBtn setAction:^{
  1084. NSMutableArray *selectIDArray = [NSMutableArray array];
  1085. for (InterLeterSubModel * model in weakSelf.interLetterArray) {
  1086. if (model.IsSelect) {
  1087. [selectIDArray addObject:@(model.Id)];
  1088. }
  1089. }
  1090. if (selectIDArray.count == 0) {
  1091. SHOWERROR(@"请选择要移动的站内信或者文件夹");
  1092. return ;
  1093. }
  1094. [weakSelf launchMoveVC:selectIDArray];
  1095. }];
  1096. }
  1097. if(operation){
  1098. self.deleteView.hidden = YES;
  1099. self.iSViewEditor = YES;
  1100. self.HeadHight.constant = 0.f;
  1101. self.rightAddBtn.hidden = YES;
  1102. self.rightEditBtn.hidden = YES;
  1103. //默认操作状态为批量编辑状态
  1104. [self removeRefresh];
  1105. self.operationStateEnum = OperationStateEnum1;
  1106. self.operationAllSelectButton.hidden = NO;
  1107. [self.operationAllSelectButton setTitleColor:UIColorHex(#0F88EB) forState:UIControlStateNormal];
  1108. [self.operationAllSelectButton setImage:nil forState:UIControlStateNormal];
  1109. WS(weakSelf);
  1110. self.isAllselect = [self checkNoticeArray];
  1111. self.titleLable.text = @"批量编辑";
  1112. self.titleLable.hidden = NO;
  1113. self.titleBtn.hidden = YES;
  1114. [self.operationAllSelectButton setTitle:self.isAllselect ? @"取消全选": @"全选" forState:UIControlStateNormal];
  1115. [self.operationAllSelectButton setAction:^{
  1116. for (InterLeterSubModel *model in self.interLetterArray) {
  1117. model.IsSelect = !weakSelf.isAllselect;
  1118. }
  1119. [weakSelf.tableView reloadData];
  1120. }];
  1121. self.operationBottomBgView.hidden = NO;
  1122. if(self.pageType != PageTypeFromTitleDeleted){
  1123. self.tabBarController.tabBar.hidden = YES;
  1124. self.view.height -= self.tabBarController.tabBar.height;
  1125. self.tableView.height -= self.tabBarController.tabBar.height;
  1126. [self.view layoutIfNeeded];
  1127. [self.tableView layoutIfNeeded];
  1128. }else{
  1129. self.deleteSelectBtn.hidden = YES;
  1130. }
  1131. }else{
  1132. [self addRefresh];
  1133. if(self.pageType == PageTypeFromTitleDeleted){
  1134. self.deleteView.hidden = NO;
  1135. self.rightAddBtn.hidden = YES;
  1136. self.rightEditBtn.hidden = YES;
  1137. self.deleteSelectBtn.hidden = NO;
  1138. }else{
  1139. self.deleteView.hidden = YES;
  1140. self.rightAddBtn.hidden = NO;
  1141. self.rightEditBtn.hidden = NO;
  1142. self.deleteSelectBtn.hidden = YES;
  1143. self.tabBarController.tabBar.hidden = YES;
  1144. self.tableView.height += self.tabBarController.tabBar.height;
  1145. self.view.height += self.tabBarController.tabBar.height;
  1146. [self.view layoutIfNeeded];
  1147. [self.tableView layoutIfNeeded];
  1148. }
  1149. self.operationBottomBgView.hidden = YES;
  1150. self.iSViewEditor = NO;
  1151. self.HeadHight.constant = 46.f;
  1152. //默认操作状态为无状态
  1153. self.operationStateEnum = OperationStateEnum0;
  1154. self.operationAllSelectButton.hidden = NO;
  1155. if (self.isHome) {
  1156. self.titleBtn.hidden = NO;
  1157. self.titleLable.hidden = YES;
  1158. }else{
  1159. self.titleLable.hidden = NO;
  1160. self.titleBtn.hidden = YES;
  1161. self.titleLable.text = self.interLeterFoldName;
  1162. }
  1163. [self.operationAllSelectButton setImage:IMG(@"menu_black_icon") forState:UIControlStateNormal];
  1164. [self.operationAllSelectButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
  1165. }
  1166. [self.tableView reloadData];
  1167. }
  1168. #pragma mark 移动 isEdit:当前是否为编辑状态
  1169. -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{
  1170. //移动
  1171. if(move){
  1172. //默认操作状态为移动状态
  1173. self.operationStateEnum = OperationStateEnum2;
  1174. self.rightAddBtn.hidden = NO;
  1175. [self resetRightBtnAction:NO];
  1176. //隐藏tabBar - 并将TableView至底端
  1177. self.tabBarController.tabBar.hidden = YES;
  1178. self.view.height += self.tabBarController.tabBar.height;
  1179. self.tableView.height += self.tabBarController.tabBar.height;
  1180. [self.view layoutIfNeeded];
  1181. [self.tableView layoutIfNeeded];
  1182. //隐藏operationBottomBgView
  1183. self.operationBottomBgView.hidden = YES;
  1184. }
  1185. else{
  1186. //隐藏tabBar - 并将TableView至底端有tabBar.height的高
  1187. self.tabBarController.tabBar.hidden = YES;
  1188. self.view.height -= self.tabBarController.tabBar.height;
  1189. self.tableView.height -= self.tabBarController.tabBar.height;
  1190. [self.view layoutIfNeeded];
  1191. [self.tableView layoutIfNeeded];
  1192. //显示operationBottomBgView
  1193. self.operationBottomBgView.hidden = NO;
  1194. if(isEdit){
  1195. self.operationStateEnum = OperationStateEnum1;
  1196. self.rightAddBtn.hidden = YES;
  1197. [self resetRightBtnAction:YES];
  1198. }else{
  1199. [self changeToOperation:NO];
  1200. }
  1201. }
  1202. [self.tableView reloadData];
  1203. }
  1204. - (void)reSettingIsSelect{
  1205. for (InterLeterSubModel *model in self.interLetterArray) {
  1206. model.IsSelect = NO;
  1207. }
  1208. }
  1209. -(void)resetRightBtnAction:(BOOL)isShowMenu{
  1210. WS(weakSelf);
  1211. if(isShowMenu){
  1212. [self.rightAddBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
  1213. [self.rightAddBtn setAction:^{
  1214. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray];
  1215. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.rightAddBtn];
  1216. view.menuColor = RGB(255, 255, 255);
  1217. view.separatorColor = RGB(234, 234, 234);
  1218. view.textColor = RGB(102, 102, 102);
  1219. view.textFont = [UIFont systemFontOfSize:16.0];
  1220. view.menuCellHeight = 43.5;
  1221. view.maxDisplayCount = 10;
  1222. view.offset = -6;
  1223. [view show];
  1224. }];
  1225. }else{
  1226. [self.rightAddBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal];
  1227. [self.rightAddBtn setAction:^{
  1228. [ShowtipTool showErrorWithStatus:@"未做"];
  1229. }];
  1230. }
  1231. }
  1232. - (void)backAction:(id)sender{
  1233. [self changeBarBtn:NO];
  1234. self.deleteView.hidden = YES;
  1235. if (self.iSViewEditor) {
  1236. [self headRefresh];
  1237. [self changeSelectStatus];
  1238. [self changeToOperation:NO];
  1239. }else{
  1240. [self.navigationController popViewControllerAnimated:true];
  1241. }
  1242. }
  1243. - (void)changeSelectStatus
  1244. {
  1245. for (InterLeterSubModel * model in self.interLetterArray) {
  1246. model.IsSelect = NO;
  1247. }
  1248. }
  1249. - (void)menuAction:(id)sender{
  1250. switch (self.operationStateEnum) {
  1251. case OperationStateEnum1:
  1252. {
  1253. for (InterLeterSubModel *model in self.interLetterArray) {
  1254. model.IsSelect = !self.isAllselect;
  1255. }
  1256. [self.tableView reloadData];
  1257. [self setingMoveButton];
  1258. }
  1259. break;
  1260. default:
  1261. [super menuAction:sender];
  1262. break;
  1263. }
  1264. }
  1265. #pragma mark - 文件夹操作 创建 | 修改 | 置顶 | 取消置顶 | 删除 | 恢复已删除 | 移动
  1266. /// 创建文件夹
  1267. - (void)addFind:(NSString *)groupname{
  1268. SHOWLOADING
  1269. WEAKSELF
  1270. [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Middle_Add_Folder) parameters:@{@"FolderName":groupname,@"ParentId":@(self.interLeterFolderId),@"TypeId":@(5)} success:^(id _Nonnull responseObject) {
  1271. STRONGSELF
  1272. REMOVESHOW
  1273. [strongSelf headRefresh];
  1274. } failure:^(NSError * _Nonnull error) {
  1275. SHOWERROR([ZYCTool handerResultData:error]);
  1276. }];
  1277. }
  1278. /// 修改文件夹名称
  1279. - (void)reNameFind:(InterLeterSubModel*)findModel withReNameString:(NSString *)renameString{
  1280. SHOWLOADING
  1281. WEAKSELF
  1282. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_ReName) parameters:@{@"FolderName":renameString,@"Id":@(findModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1283. STRONGSELF
  1284. REMOVESHOW
  1285. [strongSelf headRefresh];
  1286. } failure:^(NSError * _Nonnull error) {
  1287. SHOWERROR([ZYCTool handerResultData:error]);
  1288. }];
  1289. }
  1290. /// 文件夹 置顶 和 取消置顶
  1291. - (void)topFind:(InterLeterSubModel*)findModel{
  1292. NSLog(@"文件夹---%@%@",findModel.IsTop ? @"置顶":@"取消置顶",findModel.FolderName);
  1293. SHOWLOADING
  1294. WEAKSELF
  1295. [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_Find_Top,(long)findModel.Id] parameters:@{} success:^(id _Nonnull responseObject) {
  1296. REMOVESHOW
  1297. [weakSelf reCreateTable];
  1298. } failure:^(NSError * _Nonnull error) {
  1299. SHOWERROR([ZYCTool handerResultData:error]);
  1300. }];
  1301. }
  1302. - (void)reCreateTable
  1303. {
  1304. self.currentPage = 1;
  1305. self.totalRecord = 0;
  1306. [self.interLetterArray removeAllObjects];
  1307. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  1308. NSUInteger deleteType = 0;
  1309. switch (self.pageType) {
  1310. case PageTypeFromTitleAll:
  1311. {
  1312. [self changeBarBtn:NO];
  1313. deleteType = 1;
  1314. }
  1315. break;
  1316. case PageTypeFromTitleMy:
  1317. {
  1318. [self changeBarBtn:NO];
  1319. deleteType = 2;
  1320. }
  1321. break;
  1322. case PageTypeFromTitleDraftBox:
  1323. {
  1324. [self changeBarBtn:NO];
  1325. deleteType = 3;
  1326. }
  1327. break;
  1328. case PageTypeFromTitleDeleted:
  1329. {
  1330. [self changeBarBtn:YES];
  1331. deleteType = 4;
  1332. }
  1333. break;
  1334. default:
  1335. {
  1336. [self changeBarBtn:NO];
  1337. deleteType = 5;
  1338. }
  1339. break;
  1340. }
  1341. [dict setObject:@(self.currentPage) forKey:@"Page"];
  1342. [dict setObject:@"20" forKey:@"PerPage"];
  1343. [dict setObject:@(deleteType) forKey:@"SearchType"];
  1344. [dict setObject:@"" forKey:@"Key"];
  1345. [dict setObject:@(self.interLeterFolderId) forKey:@"FolderId"];
  1346. WS(weakSelf);
  1347. [[HttpManager sharedHttpManager] POSTUrl:Host(API_InterLetter) parameters:dict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1348. NSLog(@"站内信返回数据%@",responseObject);
  1349. InterLeterModel *listModel = [[InterLeterModel alloc] initWithDictionary:responseObject error:nil];
  1350. [weakSelf.tableView.mj_header endRefreshing];
  1351. [weakSelf.tableView.mj_footer endRefreshing];
  1352. weakSelf.totalRecord = listModel.Total;
  1353. [weakSelf.interLetterArray addObjectsFromArray:listModel.Items];
  1354. if (weakSelf.totalRecord == weakSelf.interLetterArray.count) {
  1355. [weakSelf.tableView.mj_footer resetNoMoreData];
  1356. [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  1357. }
  1358. dispatch_async(dispatch_get_main_queue(), ^{
  1359. [weakSelf.tableView removeFromSuperview];
  1360. weakSelf.tableView = nil;
  1361. [weakSelf.view addSubview:weakSelf.tableView];
  1362. weakSelf.tableView.delegate = weakSelf;
  1363. weakSelf.tableView.dataSource = weakSelf;
  1364. weakSelf.tableView.backgroundColor = [UIColor clearColor];
  1365. [weakSelf.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  1366. make.left.right.mas_equalTo(weakSelf.view);
  1367. make.top.mas_equalTo(weakSelf.NavBar.mas_bottom);
  1368. if (@available(iOS 11.0, *)) {
  1369. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  1370. } else {
  1371. make.bottom.equalTo(weakSelf.view.mas_bottom);
  1372. }
  1373. }];
  1374. [weakSelf.tableView reloadData];
  1375. });
  1376. } failure:^(NSError * _Nonnull error) {
  1377. SHOWERROR([ZYCTool handerResultData:error]);
  1378. [weakSelf.tableView.mj_header endRefreshing];
  1379. [weakSelf.tableView.mj_footer endRefreshing];
  1380. }];
  1381. }
  1382. /// 删除文件夹
  1383. //- (void)deleteFind:(NSMutableArray<InterLeterSubModel *>*)findModelArray{
  1384. // NSMutableArray *MiddleIds = [NSMutableArray array];
  1385. //
  1386. // for (InterLeterSubModel *model in findModelArray) {
  1387. // [MiddleIds addObject:@(model.Id)];
  1388. // }
  1389. // NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  1390. // [dic setValue:MiddleIds forKey:@"MiddleIds"];
  1391. // [dic setValue:@(5) forKey:@"FolderType"];
  1392. // [dic setValue:@(0) forKey:@"IsDelete"];
  1393. // [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1394. //
  1395. // SHOWLOADING
  1396. // WEAKSELF
  1397. // [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1398. // STRONGSELF
  1399. // REMOVESHOW
  1400. // [strongSelf headRefresh];
  1401. // } failure:^(NSError * _Nonnull error) {
  1402. // SHOWERROR([ZYCTool handerResultData:error]);
  1403. // }];
  1404. //
  1405. //}
  1406. - (void)thoroughDelete:(NSMutableArray<InterLeterSubModel *>*)array isDelete:(BOOL)isDelete
  1407. {
  1408. NSMutableArray * addArray = [NSMutableArray array];
  1409. for (InterLeterSubModel *model in array) {
  1410. [addArray addObject:@(model.Id)];
  1411. }
  1412. NSDictionary * dict = @{@"MiddleIds":addArray,
  1413. @"FolderType":@(5), ///1 通知
  1414. @"IsDelete":@(isDelete)
  1415. };
  1416. WS(weakSelf);
  1417. SHOWLOADING
  1418. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1419. REMOVESHOW
  1420. SHOWSUCCESS(@"删除成功");
  1421. // [weakSelf changeToOperation:NO];
  1422. [weakSelf.interLetterArray removeObjectsInArray:array];
  1423. dispatch_async(dispatch_get_main_queue(), ^{
  1424. [weakSelf.tableView reloadData];
  1425. });
  1426. } failure:^(NSError * _Nonnull error) {
  1427. REMOVESHOW
  1428. }];
  1429. }
  1430. /// 恢复文件夹
  1431. - (void)reDoDeleteFind:(NSMutableArray<InterLeterSubModel *>*)findModelArray{
  1432. NSMutableArray *MiddleIds = [NSMutableArray array];
  1433. for (InterLeterSubModel *model in findModelArray) {
  1434. [MiddleIds addObject:@(model.Id)];
  1435. }
  1436. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  1437. [dic setValue:MiddleIds forKey:@"MiddleIds"];
  1438. [dic setValue:@(5) forKey:@"FolderType"];
  1439. [dic setValue:@(0) forKey:@"IsDelete"];
  1440. [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1441. SHOWLOADING
  1442. WEAKSELF
  1443. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord_Redo) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1444. STRONGSELF
  1445. REMOVESHOW
  1446. [strongSelf headRefresh];
  1447. } failure:^(NSError * _Nonnull error) {
  1448. SHOWERROR([ZYCTool handerResultData:error]);
  1449. }];
  1450. }
  1451. /// 移动文件夹
  1452. - (void)moveFind:(NSMutableArray<InterLeterSubModel *>*)findModelArray withSuperModel:(NoticeModel *)supermodel{
  1453. NSMutableArray *MiddleIds = [NSMutableArray array];
  1454. for (InterLeterSubModel *model in findModelArray) {
  1455. [MiddleIds addObject:@(model.Id)];
  1456. }
  1457. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  1458. [dic setValue:MiddleIds forKey:@"Ids"];
  1459. [dic setValue:@(0) forKey:@"ParentId"];
  1460. SHOWLOADING
  1461. WEAKSELF
  1462. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1463. STRONGSELF
  1464. REMOVESHOW
  1465. [strongSelf headRefresh];
  1466. } failure:^(NSError * _Nonnull error) {
  1467. SHOWERROR([ZYCTool handerResultData:error]);
  1468. }];
  1469. }
  1470. - (void)editorButtonHander:(NSIndexPath *)indexpath{
  1471. WS(weakSelf);
  1472. InterLeterSubModel *model = self.interLetterArray[indexpath.row];
  1473. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  1474. vc.type = CollectModel_InterMail;
  1475. vc.isEdit = YES;
  1476. vc.replayType = MailReplayEdit;
  1477. vc.Id = model.MiddleId;
  1478. vc.isFromDraft = (model.SourceId == 0 ? YES : NO);
  1479. vc.MailType = model.MissiveType;
  1480. vc.upDateBlock = ^{
  1481. [weakSelf headRefresh];
  1482. };
  1483. [self.navigationController pushViewController:vc animated:YES];
  1484. }
  1485. - (void)viewDidDisappear:(BOOL)animated
  1486. {
  1487. [super viewDidDisappear:animated];
  1488. [self changeBarBtn:NO];
  1489. self.deleteView.hidden = YES;
  1490. self.operationBottomBgView.hidden = YES;
  1491. }
  1492. @end