TDInterLeterHomeViewController.m 73 KB

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