TDInterLeterHomeViewController.m 73 KB

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