CreateInterLeterVC.m 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844
  1. //
  2. // CreateInterLeterVC.m
  3. // smartRhino
  4. //
  5. // Created by taidi on 2019/12/25.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "CreateInterLeterVC.h"
  9. #import "AddLookUpUserSecondVC.h"
  10. #import "NoticeSelectCell.h"
  11. #import "YCMenuView.h"
  12. #import "ShowKeepNoticeAlert.h"
  13. #import "NewTopicCell.h"
  14. #import "SmartBar.h"
  15. #import "LYLPhotoTailoringTool.h"
  16. #import "FWZGetNoteBookTool.h"
  17. #import "FWZFileGetTool.h"
  18. #import "NoteBookDetailCell.h"
  19. #import "shoujianrenResultView.h"
  20. #define TextViewTag 1000
  21. #define BARHEIGHT 42.5f
  22. @interface CreateInterLeterVC ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UITextViewDelegate,SmartBarDelegate>
  23. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  24. @property (strong, nonatomic) NSMutableArray <SelectModel *>*shouJianArray;
  25. @property (strong, nonatomic) NSMutableArray <SelectModel *>*chaoShongArray;
  26. @property (weak, nonatomic) IBOutlet UICollectionView *shouJianCollectionView;
  27. @property (weak, nonatomic) IBOutlet UICollectionView *chaoSongColletionView;
  28. @property (weak, nonatomic) IBOutlet UIButton *shouJianBtn;
  29. @property (weak, nonatomic) IBOutlet UIButton *chaoSongBtn;
  30. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  31. @property (strong, nonatomic) NewTopicTextView *defualtView;
  32. @property (weak, nonatomic) IBOutlet NewTopicTextView *textView;
  33. @property (nonatomic,assign) Boolean isShouJianRen;
  34. @property (nonatomic,assign) Boolean isChaoSongRen;
  35. @property (weak, nonatomic) IBOutlet UIButton *titleBtn;
  36. @property (strong, nonatomic) NSMutableArray *taskActionArray;
  37. @property (weak, nonatomic) IBOutlet UIButton *rightAddBtn;
  38. @property (strong, nonatomic) NSMutableArray *dataArray;
  39. /// 编辑标题
  40. @property (strong, nonatomic) SmartBar *SmartBar;
  41. @property (assign, nonatomic) NSInteger InterLeterType;
  42. @property (weak, nonatomic) IBOutlet UITextField *shoujianrenTextField;
  43. @property (strong, nonatomic) shoujianrenResultView *resultView;
  44. @property (weak, nonatomic) IBOutlet UIView *shoujianrenView;
  45. @property (weak, nonatomic) IBOutlet UIView *headerView;
  46. @property (weak, nonatomic) IBOutlet UIView *inputTitleView;
  47. @property (weak, nonatomic) IBOutlet UIView *headerTopView;
  48. @end
  49. @implementation CreateInterLeterVC
  50. +(CreateInterLeterVC *)initCreateInterLeterVC{
  51. CreateInterLeterVC *controller = [StoryboardManager.shared.interLeterHome instantiateViewControllerWithIdentifier:@"CreateInterLeterVC"];
  52. return controller;
  53. }
  54. - (void)viewWillAppear:(BOOL)animated
  55. {
  56. [super viewWillAppear:animated];
  57. [[IQKeyboardManager sharedManager] setEnable:YES];
  58. }
  59. - (void)viewDidLoad {
  60. [super viewDidLoad];
  61. self.textView.placeholder = @"请输入标题";
  62. self.textView.delegate = self;
  63. self.fd_prefersNavigationBarHidden = YES;
  64. self.view.backgroundColor = RGB(255, 255, 255);
  65. self.fd_interactivePopDisabled = YES;
  66. self.InterLeterType = 1;
  67. switch (self.interLeterHanderType) {
  68. case InterLeterHanderType_Create:
  69. {
  70. WS(weakSelf);
  71. [self.titleBtn setAction:^{
  72. weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected;
  73. //[weakSelf.titleBtn setImage:[UIImage imageNamed:@"chatmsg_notice_hideAll_icon"] forState:UIControlStateNormal];
  74. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray];
  75. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn];
  76. view.menuColor = RGB(255, 255, 255);
  77. view.separatorColor = RGB(234, 234, 234);
  78. view.textColor = RGB(102, 102, 102);
  79. view.textFont = [UIFont systemFontOfSize:16.0];
  80. view.menuCellHeight = 43.5;
  81. view.maxDisplayCount = 10;
  82. view.offset = -6;
  83. [view setDissmisBlock:^{
  84. weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected;
  85. }];
  86. [view show];
  87. }];
  88. [self getInterLeterDataCreate];
  89. self.titleLabel.hidden = YES;
  90. }
  91. break;
  92. case InterLeterHanderType_Modify:
  93. {
  94. [self getData];
  95. self.titleLabel.hidden = YES;
  96. }
  97. break;
  98. case InterLeterHanderType_Replay:
  99. {
  100. self.titleBtn.hidden = YES;
  101. self.titleLabel.hidden = NO;
  102. [self getData];
  103. [self getInterLeterDataReplay];
  104. }
  105. break;
  106. }
  107. self.chaoSongColletionView.tag = 202;
  108. self.shouJianCollectionView.tag = 101;
  109. [self.chaoSongColletionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"];
  110. [self.shouJianCollectionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"];
  111. [self registerNotification];
  112. self.SmartBar.delegate = self;
  113. [self.view addSubview:self.SmartBar];
  114. [self.SmartBar mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.right.mas_equalTo(self.view);
  116. make.height.mas_offset(BARHEIGHT);
  117. if (@available(iOS 11.0, *)) {
  118. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
  119. } else {
  120. make.bottom.equalTo(self.view.mas_bottom).offset(BARHEIGHT);
  121. }
  122. }];
  123. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  124. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
  125. //[self.textView addTarget:self action:@selector(shoujirenTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  126. [self.view addSubview:self.resultView];
  127. [self.resultView mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.left.right.bottom.equalTo(self.view);
  129. make.top.equalTo(self.shoujianrenView.mas_bottom);
  130. }];
  131. [self.resultView setHidden:YES];
  132. }
  133. - (void)getData
  134. {
  135. [self.dataArray removeAllObjects];
  136. WS(weakSelf)
  137. SHOWLOADING
  138. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/missive/"),(long)self.interLeterId];
  139. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  140. NSLog(@"通知正文%@",responseObject);
  141. REMOVESHOW
  142. for (NSDictionary * dic in responseObject[@"AddresseeUserMiddles"]) {
  143. SelectModel * model = [[SelectModel alloc] init];
  144. model.UserId = [[dic objectForKey:@"SourceId"] integerValue];
  145. model.UserName = [dic objectForKey:@"SourceName"];
  146. model.SourceId = [[dic objectForKey:@"SourceId"] integerValue];
  147. model.SourceType = [[dic objectForKey:@"SourceType"] integerValue];
  148. model.SourceName = [dic objectForKey:@"SourceName"];
  149. [weakSelf.shouJianArray addObject:model];
  150. }
  151. for (NSDictionary * dic in responseObject[@"CcUserMiddles"]) {
  152. SelectModel * model = [[SelectModel alloc] init];
  153. model.UserId = [[dic objectForKey:@"SourceId"] integerValue];
  154. model.UserName = [dic objectForKey:@"SourceName"];
  155. model.SourceId = [[dic objectForKey:@"SourceId"] integerValue];
  156. model.SourceType = [[dic objectForKey:@"SourceType"] integerValue];
  157. model.SourceName = [dic objectForKey:@"SourceName"];
  158. [weakSelf.chaoShongArray addObject:model];
  159. }
  160. if ([responseObject[@"Title"] length] > 0) {
  161. weakSelf.textView.text = responseObject[@"Title"];
  162. }
  163. for (NSDictionary * dict in responseObject[@"Data"]) {
  164. CreateInterLeterModel * model = [CreateInterLeterModel modelWithDictionary:dict];
  165. [weakSelf.dataArray addObject:model];
  166. }
  167. dispatch_async(dispatch_get_main_queue(), ^{
  168. if ([weakSelf.shouJianArray count] > 0) {
  169. [weakSelf.shouJianCollectionView reloadData];
  170. }
  171. if ([weakSelf.chaoShongArray count] > 0) {
  172. [weakSelf.chaoSongColletionView reloadData];
  173. }
  174. [weakSelf.tableView reloadData];
  175. });
  176. } failure:^(NSError * _Nonnull error) {
  177. REMOVESHOW
  178. SHOWERROR([ZYCTool handerResultData:error]);
  179. }];
  180. }
  181. - (void)shoujirenTextFieldDidChange:(NSNotification *)notification {
  182. return;
  183. NSString *tmpStr = [self.shoujianrenTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  184. if (tmpStr.length) {
  185. // 显示搜索结果
  186. [self.resultView setHidden:NO];
  187. } else {
  188. // 不显示搜索结果
  189. [self.resultView setHidden:YES];
  190. }
  191. }
  192. - (SmartBar *)SmartBar{
  193. if (!_SmartBar) {
  194. _SmartBar = [[SmartBar alloc]init];
  195. _SmartBar.delegate = self;
  196. }
  197. return _SmartBar;
  198. }
  199. - (void)getInterLeterDataCreate{
  200. [self.dataArray removeAllObjects];
  201. CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init];
  202. titleModel.PlaceText = @"编辑内容";
  203. titleModel.Content = @"";
  204. titleModel.Type = CollectDataType_Text;
  205. if(self.interLeterHanderType == InterLeterHanderType_Replay){
  206. titleModel.Height = 55.5f * 3;
  207. }else{
  208. titleModel.Height = 55.5f;
  209. }
  210. [self.dataArray addObject:titleModel];
  211. [self.tableView reloadData];
  212. if (self.isFromOtherPeople) {
  213. self.shouJianArray = self.shouJianArrTemp;
  214. }
  215. }
  216. - (void)getInterLeterDataReplay{
  217. [self.dataArray removeAllObjects];
  218. CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init];
  219. titleModel.PlaceText = @"编辑内容";
  220. titleModel.Content = @"";
  221. titleModel.Type = CollectDataType_Text;
  222. if(self.interLeterHanderType == InterLeterHanderType_Replay){
  223. titleModel.Height = 55.5f * 3;
  224. }else{
  225. titleModel.Height = 55.5f;
  226. }
  227. [self.dataArray addObject:titleModel];
  228. [self.tableView reloadData];
  229. [self.shouJianArray removeAllObjects];
  230. for (NSDictionary * dict in self.replayDataArray) {
  231. SelectModel *model = [[SelectModel alloc] init];
  232. model.SourceType = 0;
  233. model.SourceId = [dict[@"Id"] integerValue];
  234. model.SourceName = dict[@"Name"];
  235. [self.shouJianArray addObject:model];
  236. }
  237. self.shouJianBtn.hidden =YES;
  238. [self.shouJianCollectionView reloadData];
  239. self.textView.text = [NSString stringWithFormat:@"Re:%@",self.replayTitle];
  240. }
  241. - (NSMutableArray *)dataArray{
  242. if(!_dataArray){
  243. _dataArray = [NSMutableArray new];
  244. }
  245. return _dataArray;
  246. }
  247. -(NSMutableArray *)taskActionArray{
  248. if(!_taskActionArray){
  249. _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"写信件",@"匿名信", nil];
  250. }
  251. return _taskActionArray;
  252. }
  253. -(NSMutableArray *)getMenuDataSource:(NSMutableArray *)titleArray{
  254. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  255. for(int i=0;i<titleArray.count;i++){
  256. NSString *titleStr = [titleArray objectAtIndex:i];
  257. WS(weakSelf);
  258. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  259. [weakSelf.titleBtn setImage:[UIImage imageNamed:@"chatmsg_notice_showAll_icon"] forState:UIControlStateNormal];
  260. [self.titleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 45, 0, 0)];
  261. [self.titleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -45, 0, 0)];
  262. [self.titleBtn setTitle:action.title forState:UIControlStateNormal];
  263. if([@"写信件" isEqualToString:action.title]){
  264. weakSelf.InterLeterType =1;
  265. }
  266. else if ([@"匿名信" isEqualToString:action.title]){
  267. weakSelf.InterLeterType =2;
  268. }
  269. }];
  270. [menuDataSourceArray addObject:actionMenu];
  271. }
  272. return menuDataSourceArray;
  273. }
  274. #pragma mark - CollectionView 代理
  275. -(NSMutableArray<SelectModel *> *)shouJianArray{
  276. if(!_shouJianArray){
  277. _shouJianArray = [[NSMutableArray alloc] init];
  278. }
  279. return _shouJianArray;
  280. }
  281. -(NSMutableArray<SelectModel *> *)chaoShongArray{
  282. if(!_chaoShongArray){
  283. _chaoShongArray = [[NSMutableArray alloc] init];
  284. }
  285. return _chaoShongArray;
  286. }
  287. -(IBAction)userDidSelectShouJianAction:(id)sender{
  288. self.isShouJianRen = YES;
  289. self.isChaoSongRen = NO;
  290. [self selectPeople];
  291. }
  292. -(IBAction)userDidSelectChaoShongAction:(id)sender{
  293. self.isChaoSongRen = YES;
  294. self.isShouJianRen = NO;
  295. [self selectPeople];
  296. }
  297. - (void)selectPeople{
  298. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  299. vc.isAllSelected = YES;
  300. Department *defaltGroupSetion = [[Department alloc]init];
  301. defaltGroupSetion.Name = @"单位通讯录";
  302. defaltGroupSetion.Id = 0;
  303. defaltGroupSetion.SourceId = 0;
  304. defaltGroupSetion.SourceType = 1;
  305. defaltGroupSetion.SourceName = @"单位通讯录";
  306. defaltGroupSetion.MiddleType = 1;
  307. Department *myGroupSetion = [[Department alloc]init];
  308. myGroupSetion.Name = @"自建通讯录";
  309. myGroupSetion.Id = 0;
  310. myGroupSetion.MiddleType = 3;
  311. myGroupSetion.SourceType = 3;
  312. myGroupSetion.SourceId = 0;
  313. myGroupSetion.SourceName = @"自建通讯录";
  314. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  315. vc.isDefalutPage = 1;
  316. vc.titleStr = @"选人";
  317. [self.navigationController pushViewController:vc animated:YES];
  318. }
  319. - (void)registerNotification{
  320. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  321. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shoujirenTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
  322. }
  323. - (void)recviveChaoSongRen:(NSNotification *)notification{
  324. if (self.isShouJianRen) {
  325. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  326. NSMutableArray <SelectModel *>* array0 = self.shouJianArray;
  327. NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
  328. if (array0.count == 0) {
  329. [self.shouJianArray addObjectsFromArray:array1];
  330. }else{
  331. for (NSInteger x = 0; x < array.count; x++) {
  332. for (NSInteger y = 0 ; y<array0.count; y++) {
  333. if (array[x].UserId == array0[y].UserId) {
  334. [array1 removeObjectAtIndex:x];
  335. }
  336. }
  337. }
  338. NSLog(@"结果数据组%@",array1);
  339. [self.shouJianArray addObjectsFromArray:array1];
  340. }
  341. [self.shouJianCollectionView reloadData];
  342. // if (self.shouJianArray.count) {
  343. // [self.shouJianCollectionView setHidden:NO];
  344. // [self.shoujianrenTextField setHidden:YES];
  345. // } else {
  346. // [self.shouJianCollectionView setHidden:YES];
  347. // [self.shoujianrenTextField setHidden:NO];
  348. // }
  349. self.isShouJianRen = NO;
  350. [self checkNoticData];
  351. }
  352. if (self.isChaoSongRen) {
  353. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  354. NSMutableArray <SelectModel *>* array0 = self.chaoShongArray;
  355. NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
  356. if (array0.count == 0) {
  357. [self.chaoShongArray addObjectsFromArray:array1];
  358. }else{
  359. for (NSInteger x = 0; x < array.count; x++) {
  360. for (NSInteger y = 0 ; y<array0.count; y++) {
  361. if (array[x].UserId == array0[y].UserId) {
  362. [array1 removeObjectAtIndex:x];
  363. }
  364. }
  365. }
  366. NSLog(@"结果数据组%@",array1);
  367. [self.chaoShongArray addObjectsFromArray:array1];
  368. }
  369. [self.chaoSongColletionView reloadData];
  370. self.isChaoSongRen = NO;
  371. }
  372. }
  373. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  374. if (collectionView.tag == 101) {
  375. return self.shouJianArray.count;
  376. }else{
  377. return self.chaoShongArray.count;
  378. }
  379. }
  380. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  381. return 1;
  382. }
  383. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  384. if (collectionView.tag == 101) {
  385. // 收件人
  386. if (self.isFromOtherPeople) {
  387. }else{
  388. }
  389. NoticeSelectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeSelectCell" forIndexPath:indexPath];
  390. cell.nameLabel.attributedText = [self textHander: [NSString stringWithFormat:@" %@ ",self.shouJianArray[indexPath.item].SourceName]];
  391. cell.nameLabel.layer.cornerRadius = 13;
  392. cell.nameLabel.layer.masksToBounds = YES;
  393. WEAKSELF
  394. [cell.delButton setAction:^{
  395. [weakSelf delShoujianrenAction:indexPath];
  396. }];
  397. return cell;
  398. }else{
  399. // 抄送人
  400. NoticeSelectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeSelectCell" forIndexPath:indexPath];
  401. cell.nameLabel.attributedText = [self textHander: [NSString stringWithFormat:@" %@ ",self.chaoShongArray[indexPath.item].SourceName]];
  402. cell.nameLabel.layer.cornerRadius = 13;
  403. cell.nameLabel.layer.masksToBounds = YES;
  404. WEAKSELF
  405. [cell.delButton setAction:^{
  406. [weakSelf delChaosongrenAction:indexPath];
  407. }];
  408. return cell;
  409. }
  410. }
  411. - (NSAttributedString *)textHander:(NSString *)labelString{
  412. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
  413. paraStyle.alignment = NSTextAlignmentCenter;//对齐
  414. CGFloat emptylen = 12 * 8;
  415. paraStyle.headIndent = emptylen;//行首缩进
  416. //字体大小号字乘以2 即首行空出两个字符
  417. // paraStyle.firstLineHeadIndent = emptylen;//首行缩进
  418. paraStyle.tailIndent = emptylen ;//行尾缩进
  419. NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:labelString attributes:@{NSParagraphStyleAttributeName:paraStyle}];
  420. return attrText;
  421. }
  422. // 删除收件人
  423. - (void)delShoujianrenAction:(NSIndexPath *)indexPath {
  424. [self.shouJianArray removeObjectAtIndex:indexPath.row];
  425. [self.shouJianCollectionView reloadData];
  426. }
  427. // 删除抄送人
  428. - (void)delChaosongrenAction:(NSIndexPath *)indexPath {
  429. [self.chaoShongArray removeObjectAtIndex:indexPath.row];
  430. [self.chaoSongColletionView reloadData];
  431. }
  432. #pragma mark - tableView 代理
  433. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  434. switch (self.interLeterHanderType) {
  435. case InterLeterHanderType_Create:
  436. return 1;
  437. case InterLeterHanderType_Modify:
  438. return 1;
  439. case InterLeterHanderType_Replay:
  440. return 1 + self.replayArray.count;
  441. }
  442. return 1;
  443. }
  444. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  445. switch (self.interLeterHanderType) {
  446. case InterLeterHanderType_Create:{
  447. return self.dataArray.count;
  448. }break;
  449. case InterLeterHanderType_Modify:{
  450. return self.dataArray.count;
  451. }break;
  452. case InterLeterHanderType_Replay:
  453. switch (section) {
  454. case 0:{
  455. return self.dataArray.count;
  456. }break;
  457. default:{
  458. InterLeterDetailSubModel *model = self.replayArray[section - 1];
  459. return model.Data.count + 2;// 第一条:固定的原信件内容,第二条:信件标题
  460. }break;
  461. }
  462. return self.dataArray.count;
  463. }
  464. }
  465. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  466. {
  467. CreateInterLeterModel *model = [self.dataArray objectAtIndex:indexPath.row];
  468. if (indexPath.row == 0 && model.Type == CollectDataType_Text) {
  469. if(self.interLeterHanderType == InterLeterHanderType_Replay){
  470. return 55.5f * 3;
  471. }else{
  472. return UITableViewAutomaticDimension;
  473. }
  474. }
  475. return UITableViewAutomaticDimension;
  476. }
  477. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  478. {
  479. WS(weakSelf);
  480. CreateInterLeterModel *model = [self.dataArray objectAtIndex:indexPath.row];
  481. // if (indexPath.row == 0) {
  482. // NewTopicCell *cell = [NewTopicCell configCell0:tableView indexPath:indexPath];
  483. // if (!self.defualtView) {
  484. // self.defualtView = cell.textView;
  485. // }
  486. // cell.textView.placeholder = model.Title;
  487. // cell.textView.text = model.Content;
  488. // cell.bgLabel.text = cell.textView.text;
  489. // cell.textView.tag = TextViewTag + indexPath.row;
  490. // cell.textView.delegate = self;
  491. // return cell;
  492. // }
  493. switch (model.Type) {
  494. case CollectDataType_Text:
  495. {
  496. NewTopicCell *cell = [NewTopicCell configCell1:tableView indexPath:indexPath];
  497. cell.textView.placeholder = model.Title;
  498. cell.textView.text = model.Content;
  499. cell.bgLabel.text = cell.textView.text;
  500. cell.textView.tag = TextViewTag + indexPath.row;
  501. cell.textView.delegate = self;
  502. [cell.textView becomeFirstResponder];
  503. return cell;
  504. }
  505. break;
  506. case CollectDataType_File:
  507. {
  508. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  509. cell.textView.placeholder = @"";
  510. cell.textView.text = model.Content;
  511. cell.cell2TitleL.text = model.FileName;
  512. cell.cell2SubTitleL.text = model.FileSize;
  513. cell.bgLabel.text = cell.textView.text;
  514. cell.textView.tag = TextViewTag + indexPath.row;
  515. cell.textView.delegate = self;
  516. NSString * imageName = [ZYCTool getFileNameImage:model.File];
  517. if (imageName.length > 0) {
  518. cell.cell2ImagV.image = IMG(imageName);
  519. }else{
  520. [cell.cell2ImagV sd_setImageWithURL:[NSURL URLWithString:model.File] placeholderImage:IMG(@"icon_weizhiwenjian")];
  521. }
  522. [cell.cell2CloseBtn setAction:^{
  523. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  524. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  525. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  526. [weakSelf.tableView reloadData];
  527. }];
  528. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  529. }];
  530. [alert addAction:sureAction];
  531. [alert addAction:cancelAction];
  532. [weakSelf presentViewController:alert animated:YES completion:^{
  533. }];
  534. }];
  535. return cell;
  536. }
  537. break;
  538. case CollectDataType_IMG:
  539. {
  540. NewTopicCell *cell = [NewTopicCell configCell3:tableView indexPath:indexPath];
  541. cell.textView.placeholder = @"";
  542. cell.textView.text = model.Content;
  543. cell.bgLabel.text = cell.textView.text;
  544. cell.textView.tag = TextViewTag + indexPath.row;
  545. cell.textView.delegate = self;
  546. [cell.cell3ImagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrl]];
  547. [cell.cell3CloseBtn setAction:^{
  548. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  549. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  550. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  551. [weakSelf.tableView reloadData];
  552. }];
  553. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  554. }];
  555. [alert addAction:sureAction];
  556. [alert addAction:cancelAction];
  557. [weakSelf presentViewController:alert animated:YES completion:^{
  558. }];
  559. }];
  560. return cell;
  561. }
  562. break;
  563. case CollectDataType_Collect:
  564. {
  565. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  566. cell.textView.text = model.Content;
  567. cell.bgLabel.text = cell.textView.text;
  568. cell.textView.tag = TextViewTag + indexPath.row;
  569. cell.textView.delegate = self;
  570. cell.cell2TitleL.text = model.FileName;
  571. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",model.Author] KeyString:model.Author];
  572. cell.cell2ImagV.image = IMG(@"收藏");
  573. [cell.cell2CloseBtn setAction:^{
  574. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  575. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  576. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  577. [weakSelf.tableView reloadData];
  578. }];
  579. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  580. }];
  581. [alert addAction:sureAction];
  582. [alert addAction:cancelAction];
  583. [weakSelf presentViewController:alert animated:YES completion:^{
  584. }];
  585. }];
  586. return cell;
  587. }
  588. break;
  589. case CollectDataType_Note:
  590. {
  591. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  592. cell.textView.placeholder = @"";
  593. cell.textView.text = model.Content;
  594. cell.cell2TitleL.text = model.FileName;
  595. cell.bgLabel.text = cell.textView.text;
  596. cell.textView.tag = TextViewTag + indexPath.row;
  597. cell.textView.delegate = self;
  598. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",model.Author] KeyString:model.Author];
  599. cell.cell2ImagV.image = IMG(@"noteBook_icon");
  600. [cell.cell2CloseBtn setAction:^{
  601. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  602. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  603. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  604. [weakSelf.tableView reloadData];
  605. }];
  606. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  607. }];
  608. [alert addAction:sureAction];
  609. [alert addAction:cancelAction];
  610. [weakSelf presentViewController:alert animated:YES completion:^{
  611. }];
  612. }];
  613. return cell;
  614. }
  615. break;
  616. case CollectDataType_NoteFile:
  617. {
  618. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  619. cell.textView.placeholder = @"";
  620. cell.textView.text = model.Content;
  621. cell.cell2TitleL.text = model.FileName;
  622. cell.bgLabel.text = cell.textView.text;
  623. cell.textView.tag = TextViewTag + indexPath.row;
  624. cell.textView.delegate = self;
  625. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记文件夹",model.Author] KeyString:model.Author];
  626. cell.cell2ImagV.image = IMG(@"find_1");
  627. [cell.cell2CloseBtn setAction:^{
  628. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  629. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  630. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  631. [weakSelf.tableView reloadData];
  632. }];
  633. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  634. }];
  635. [alert addAction:sureAction];
  636. [alert addAction:cancelAction];
  637. [weakSelf presentViewController:alert animated:YES completion:^{
  638. }];
  639. }];
  640. return cell;
  641. }break;
  642. case CollectDataType_CollectFile:
  643. {
  644. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  645. cell.textView.placeholder = @"";
  646. cell.textView.text = model.Content;
  647. cell.cell2TitleL.text = model.FileName;
  648. cell.bgLabel.text = cell.textView.text;
  649. cell.textView.tag = TextViewTag + indexPath.row;
  650. cell.textView.delegate = self;
  651. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏文件夹",model.Author] KeyString:model.Author];
  652. cell.cell2ImagV.image = IMG(@"find_1");
  653. [cell.cell2CloseBtn setAction:^{
  654. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  655. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  656. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  657. [weakSelf.tableView reloadData];
  658. }];
  659. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  660. }];
  661. [alert addAction:sureAction];
  662. [alert addAction:cancelAction];
  663. [weakSelf presentViewController:alert animated:YES completion:^{
  664. }];
  665. }];
  666. return cell;
  667. }break;
  668. case CollectDataType_Group:
  669. {
  670. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  671. cell.textView.placeholder = @"";
  672. cell.textView.text = model.Content;
  673. cell.cell2TitleL.text = model.FileName;
  674. cell.bgLabel.text = cell.textView.text;
  675. cell.textView.tag = TextViewTag + indexPath.row;
  676. cell.textView.delegate = self;
  677. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@小组",model.Author] KeyString:model.Author];
  678. cell.cell2ImagV.image = IMG(@"笔记小组");
  679. [cell.cell2CloseBtn setAction:^{
  680. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  681. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  682. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  683. [weakSelf.tableView reloadData];
  684. }];
  685. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  686. }];
  687. [alert addAction:sureAction];
  688. [alert addAction:cancelAction];
  689. [weakSelf presentViewController:alert animated:YES completion:^{
  690. }];
  691. }];
  692. return cell;
  693. }break;
  694. case CollectDataType_Topic:
  695. {
  696. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  697. cell.textView.placeholder = @"";
  698. cell.textView.text = model.Content;
  699. cell.cell2TitleL.text = model.FileName;
  700. cell.bgLabel.text = cell.textView.text;
  701. cell.textView.tag = TextViewTag + indexPath.row;
  702. cell.textView.delegate = self;
  703. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@",model.Author] KeyString:model.Author];
  704. cell.cell2ImagV.image = IMG(@"话题");
  705. [cell.cell2CloseBtn setAction:^{
  706. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  707. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  708. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  709. [weakSelf.tableView reloadData];
  710. }];
  711. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  712. }];
  713. [alert addAction:sureAction];
  714. [alert addAction:cancelAction];
  715. [weakSelf presentViewController:alert animated:YES completion:^{
  716. }];
  717. }];
  718. return cell;
  719. }break;
  720. case CollectDataType_Notice:
  721. {
  722. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  723. cell.textView.placeholder = @"";
  724. cell.textView.text = model.Content;
  725. cell.cell2TitleL.text = model.FileName;
  726. cell.bgLabel.text = cell.textView.text;
  727. cell.textView.tag = TextViewTag + indexPath.row;
  728. cell.textView.delegate = self;
  729. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的通知",model.Author] KeyString:model.Author];
  730. cell.cell2ImagV.image = IMG(@"通知图标");
  731. [cell.cell2CloseBtn setAction:^{
  732. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  733. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  734. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  735. [weakSelf.tableView reloadData];
  736. }];
  737. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  738. }];
  739. [alert addAction:sureAction];
  740. [alert addAction:cancelAction];
  741. [weakSelf presentViewController:alert animated:YES completion:^{
  742. }];
  743. }];
  744. return cell;
  745. }break;
  746. case CollectDataType_InterMail:
  747. {
  748. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  749. cell.textView.placeholder = @"";
  750. cell.textView.text = model.Content;
  751. cell.cell2TitleL.text = model.FileName;
  752. cell.bgLabel.text = cell.textView.text;
  753. cell.textView.tag = TextViewTag + indexPath.row;
  754. cell.textView.delegate = self;
  755. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@站内信",model.Author] KeyString:model.Author];
  756. cell.cell2ImagV.image = IMG(@"站内信");
  757. [cell.cell2CloseBtn setAction:^{
  758. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  759. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  760. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  761. [weakSelf.tableView reloadData];
  762. }];
  763. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  764. }];
  765. [alert addAction:sureAction];
  766. [alert addAction:cancelAction];
  767. [weakSelf presentViewController:alert animated:YES completion:^{
  768. }];
  769. }];
  770. return cell;
  771. }break;
  772. case CollectDataType_Meeting:
  773. {
  774. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  775. cell.textView.placeholder = @"";
  776. cell.textView.text = model.Content;
  777. cell.cell2TitleL.text = model.FileName;
  778. cell.bgLabel.text = cell.textView.text;
  779. cell.textView.tag = TextViewTag + indexPath.row;
  780. cell.textView.delegate = self;
  781. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的会议",model.Author] KeyString:model.Author];
  782. cell.cell2ImagV.image = IMG(@"会议");
  783. [cell.cell2CloseBtn setAction:^{
  784. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  785. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  786. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  787. [weakSelf.tableView reloadData];
  788. }];
  789. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  790. }];
  791. [alert addAction:sureAction];
  792. [alert addAction:cancelAction];
  793. [weakSelf presentViewController:alert animated:YES completion:^{
  794. }];
  795. }];
  796. return cell;
  797. }break;
  798. case CollectDataType_Article:
  799. {
  800. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  801. cell.textView.placeholder = @"";
  802. cell.textView.text = model.Content;
  803. cell.cell2TitleL.text = model.FileName;
  804. cell.bgLabel.text = cell.textView.text;
  805. cell.textView.tag = TextViewTag + indexPath.row;
  806. cell.textView.delegate = self;
  807. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的文章",model.Author] KeyString:model.Author];
  808. cell.cell2ImagV.image = IMG(@"文章");
  809. [cell.cell2CloseBtn setAction:^{
  810. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  811. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  812. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  813. [weakSelf.tableView reloadData];
  814. }];
  815. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  816. }];
  817. [alert addAction:sureAction];
  818. [alert addAction:cancelAction];
  819. [weakSelf presentViewController:alert animated:YES completion:^{
  820. }];
  821. }];
  822. return cell;
  823. }break;
  824. case CollectDataType_Approval:
  825. {
  826. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  827. cell.textView.placeholder = @"";
  828. cell.textView.text = model.Content;
  829. cell.cell2TitleL.text = model.FileName;
  830. cell.bgLabel.text = cell.textView.text;
  831. cell.textView.tag = TextViewTag + indexPath.row;
  832. cell.textView.delegate = self;
  833. cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的审批",model.Author] KeyString:model.Author];
  834. cell.cell2ImagV.image = IMG(@"审批");
  835. [cell.cell2CloseBtn setAction:^{
  836. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  837. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  838. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  839. [weakSelf.tableView reloadData];
  840. }];
  841. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  842. }];
  843. [alert addAction:sureAction];
  844. [alert addAction:cancelAction];
  845. [weakSelf presentViewController:alert animated:YES completion:^{
  846. }];
  847. }];
  848. return cell;
  849. }break;
  850. default:
  851. {
  852. NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
  853. cell.textView.delegate = self;
  854. cell.textView.tag = TextViewTag + indexPath.row;
  855. cell.textView.placeholder = @"";
  856. cell.textView.text = model.Content;
  857. cell.bgLabel.text = cell.textView.text;
  858. cell.cell2TitleL.text = model.FileName;
  859. cell.cell2SubTitleL.text = model.FileSize;
  860. NSString * imageName = [ZYCTool getFileNameImage:model.File];
  861. cell.cell2ImagV.image = IMG(imageName);
  862. [cell.cell2CloseBtn setAction:^{
  863. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  864. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  865. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  866. [weakSelf.tableView reloadData];
  867. }];
  868. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  869. }];
  870. [alert addAction:sureAction];
  871. [alert addAction:cancelAction];
  872. [weakSelf presentViewController:alert animated:YES completion:^{
  873. }];
  874. }];
  875. return cell;
  876. }
  877. break;
  878. }
  879. }
  880. #pragma mark - KeyBoard
  881. - (void)keyBoardWillShow:(NSNotification *)note
  882. {
  883. // 获取用户信息
  884. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  885. // 获取键盘高度
  886. CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
  887. CGFloat keyBoardHeight = keyBoardBounds.size.height;
  888. // 获取键盘动画时间
  889. CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
  890. // 定义好动作
  891. WS(weakSelf);
  892. void (^animation)(void) = ^void(void) {
  893. [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
  894. if (@available(iOS 11.0, *)) {
  895. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-keyBoardHeight);
  896. } else {
  897. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-keyBoardHeight);
  898. }
  899. }];
  900. };
  901. if (animationTime > 0) {
  902. [UIView animateWithDuration:animationTime animations:animation completion:^(BOOL finished) {
  903. }];
  904. } else {
  905. animation();
  906. }
  907. }
  908. - (void)keyBoardWillHide:(NSNotification *)note
  909. {
  910. // 获取用户信息
  911. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  912. // 获取键盘动画时间
  913. CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
  914. // 定义好动作
  915. WS(weakSelf);
  916. void (^animation)(void) = ^void(void) {
  917. [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
  918. if (@available(iOS 11.0, *)) {
  919. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
  920. } else {
  921. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
  922. }
  923. }];
  924. };
  925. if (animationTime > 0) {
  926. [UIView animateWithDuration:animationTime animations:animation];
  927. } else {
  928. animation();
  929. }
  930. }
  931. #pragma -mark UItextViewDelegate
  932. - (void)textFieldDidChange:(UITextField *)textField{
  933. [self checkNoticData];
  934. }
  935. - (void)textViewDidBeginEditing:(UITextView *)textView
  936. {
  937. self.defualtView = (NewTopicTextView *)textView;
  938. }
  939. - (void)textViewDidChange:(UITextView *)textView
  940. {
  941. [self checkNoticData];
  942. self.defualtView = (NewTopicTextView *)textView;
  943. NSInteger index = textView.tag - TextViewTag;
  944. CreateInterLeterModel * model = [self.dataArray objectAtIndex:index];
  945. model.Content = textView.text;
  946. CGRect bounds = textView.bounds;
  947. CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX);
  948. CGSize newSize = [textView sizeThatFits:maxSize];
  949. if (model.Height != (newSize.height + 35.f)) {
  950. model.Height = newSize.height + 35.f;
  951. [self.tableView beginUpdates];
  952. [self.tableView endUpdates];
  953. }
  954. CGFloat H = 34.f;
  955. if (textView == self.textView) {
  956. CGRect bounds = textView.bounds;
  957. CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX);
  958. CGSize newSize = [textView sizeThatFits:maxSize];
  959. if (H < newSize.height) {
  960. H = newSize.height;
  961. [self.headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, H + 116)];
  962. [self.headerView updateConstraints];
  963. [self.headerView setNeedsLayout];
  964. [self.headerView layoutIfNeeded];
  965. [self.inputTitleView mas_remakeConstraints:^(MASConstraintMaker *make) {
  966. make.left.bottom.right.mas_equalTo(self.headerView);
  967. make.top.mas_equalTo(self.headerTopView.mas_bottom);
  968. }];
  969. [self.tableView setSectionHeaderHeight:H + 116];
  970. [self.tableView beginUpdates];
  971. [self.tableView endUpdates];
  972. [self.tableView layoutIfNeeded];
  973. }
  974. }
  975. }
  976. - (void)backAction:(id)sender{
  977. WS(weakSelf);
  978. [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
  979. [weakSelf handerNotice:self.InterLeterType withAddress:2]; /// 草稿
  980. } cancle:^(ShowKeepNoticeCloseType colseType) {
  981. if(colseType == ShowKeepNoticeCloseType1){
  982. [weakSelf.navigationController popViewControllerAnimated:YES];
  983. }
  984. }] show];
  985. }
  986. - (void)menuAction:(id)sender{
  987. [super menuAction:sender];
  988. }
  989. #pragma mark - 提交信息
  990. - (BOOL)checkNoticData {
  991. if (self.shouJianArray.count > 0 && (self.textView.text.length > 0 || self.dataArray.count > 0)) {
  992. self.rightAddBtn.enabled = YES;
  993. return YES;
  994. }
  995. self.rightAddBtn.enabled = NO;
  996. return NO;
  997. }
  998. - (IBAction)sendNoticManyPeople:(UIButton *)sender {
  999. ///1 正常 2 匿名
  1000. [self handerNotice:self.InterLeterType withAddress:1];//发送
  1001. }
  1002. - (void)handerNotice:(NSInteger)NoticeType withAddress:(NSInteger)address{
  1003. SHOWLOADING
  1004. NSMutableArray * array = [NSMutableArray array];
  1005. for (CreateInterLeterModel * model in self.dataArray) {
  1006. switch (model.Type) {
  1007. case CollectDataType_Text:
  1008. {
  1009. NSDictionary * dict = @{@"TextType":@"",
  1010. @"File":@"",
  1011. @"FileName":@"",
  1012. @"Text":model.Content,
  1013. @"Title":@"",
  1014. @"Type":@(CollectDataType_Text),
  1015. @"Author":@"",
  1016. @"Content":@"",
  1017. @"Id":@(0),
  1018. @"CreatedData":@""
  1019. };
  1020. [array addObject:dict];
  1021. }
  1022. break;
  1023. case CollectDataType_IMG:
  1024. {
  1025. NSDictionary * dict = @{@"TextType":@"",
  1026. @"File":model.File,
  1027. @"FileName":model.FileName,
  1028. @"Text":@"",
  1029. @"Title":@"",
  1030. @"Type":@(CollectDataType_IMG),
  1031. @"Author":@"",
  1032. @"Content":@"",
  1033. @"Id":@(model.FileId),
  1034. @"CreatedData":@""
  1035. };
  1036. [array addObject:dict];
  1037. if (model.Text.length > 0) {
  1038. NSDictionary * subDict = @{@"TextType":@"",
  1039. @"File":@"",
  1040. @"FileName":@"",
  1041. @"Text":model.Text,
  1042. @"Title":@"",
  1043. @"Type":@(CollectDataType_Text),
  1044. @"Author":@"",
  1045. @"Content":@"",
  1046. @"Id":@(0),
  1047. @"CreatedData":@""
  1048. };
  1049. [array addObject:subDict];
  1050. }
  1051. }break;
  1052. case CollectDataType_File:
  1053. {
  1054. NSDictionary * dict = @{@"TextType":@"",
  1055. @"File":model.File,
  1056. @"FileName":model.FileName,
  1057. @"Text":@"",
  1058. @"Title":model.FileName,
  1059. @"Type":@(CollectDataType_File),
  1060. @"Author":@"",
  1061. @"Content":@"",
  1062. @"Id":@(model.FileId),
  1063. @"CreatedData":@""
  1064. };
  1065. [array addObject:dict];
  1066. if (model.Text.length > 0) {
  1067. NSDictionary * subDict = @{@"TextType":@"",
  1068. @"File":@"",
  1069. @"FileName":@"",
  1070. @"Text":model.Text,
  1071. @"Title":@"",
  1072. @"Type":@(CollectDataType_Text),
  1073. @"Author":@"",
  1074. @"Content":@"",
  1075. @"Id":@(0),
  1076. @"CreatedData":@""
  1077. };
  1078. [array addObject:subDict];
  1079. }
  1080. }break;
  1081. case CollectDataType_Collect:
  1082. {
  1083. NSDictionary * dict = @{@"TextType":@"",
  1084. @"File":model.File,
  1085. @"FileName":@"",
  1086. @"Text":@"",
  1087. @"Title":model.FileName,
  1088. @"Type":@(CollectDataType_Collect),
  1089. @"Author":model.Author,
  1090. @"Content":@"",
  1091. @"Id":@(model.FileId),
  1092. @"CreatedData":@""
  1093. };
  1094. [array addObject:dict];
  1095. if (model.Text.length > 0) {
  1096. NSDictionary * subDict = @{@"TextType":@"",
  1097. @"File":@"",
  1098. @"FileName":@"",
  1099. @"Text":model.Text,
  1100. @"Title":@"",
  1101. @"Type":@(CollectDataType_Text),
  1102. @"Author":@"",
  1103. @"Content":@"",
  1104. @"Id":@(0),
  1105. @"CreatedData":@""
  1106. };
  1107. [array addObject:subDict];
  1108. }
  1109. }break;
  1110. case CollectDataType_Note:
  1111. {
  1112. NSDictionary * dict = @{@"TextType":@"",
  1113. @"File":model.File,
  1114. @"FileName":model.FileName,
  1115. @"Text":@"",
  1116. @"Title":model.FileName,
  1117. @"Type":@(CollectDataType_Note),
  1118. @"Author":model.Author,
  1119. @"Content":@"",
  1120. @"Id":@(model.FileId),
  1121. @"CreatedData":@""
  1122. };
  1123. [array addObject:dict];
  1124. if (model.Text.length > 0) {
  1125. NSDictionary * subDict = @{@"TextType":@"",
  1126. @"File":@"",
  1127. @"FileName":@"",
  1128. @"Text":model.Text,
  1129. @"Title":@"",
  1130. @"Type":@(CollectDataType_Text),
  1131. @"Author":@"",
  1132. @"Content":@"",
  1133. @"Id":@(0),
  1134. @"CreatedData":@""
  1135. };
  1136. [array addObject:subDict];
  1137. }
  1138. }break;
  1139. case CollectDataType_NoteFile:
  1140. {
  1141. NSDictionary * dict = @{@"TextType":@"",
  1142. @"File":model.File,
  1143. @"FileName":model.FileName,
  1144. @"Text":@"",
  1145. @"Title":model.FileName,
  1146. @"Type":@(CollectDataType_NoteFile),
  1147. @"Author":model.Author,
  1148. @"Content":@"",
  1149. @"Id":@(model.FileId),
  1150. @"CreatedData":@""
  1151. };
  1152. [array addObject:dict];
  1153. if (model.Text.length > 0) {
  1154. NSDictionary * subDict = @{@"TextType":@"",
  1155. @"File":@"",
  1156. @"FileName":@"",
  1157. @"Text":model.Text,
  1158. @"Title":@"",
  1159. @"Type":@(CollectDataType_Text),
  1160. @"Author":@"",
  1161. @"Content":@"",
  1162. @"Id":@(0),
  1163. @"CreatedData":@""
  1164. };
  1165. [array addObject:subDict];
  1166. }
  1167. }break;
  1168. case CollectDataType_CollectFile:
  1169. {
  1170. NSDictionary * dict = @{@"TextType":@"",
  1171. @"File":model.File,
  1172. @"FileName":model.FileName,
  1173. @"Text":@"",
  1174. @"Title":model.FileName,
  1175. @"Type":@(CollectDataType_CollectFile),
  1176. @"Author":model.Author,
  1177. @"Content":@"",
  1178. @"Id":@(model.FileId),
  1179. @"CreatedData":@""
  1180. };
  1181. [array addObject:dict];
  1182. if (model.Text.length > 0) {
  1183. NSDictionary * subDict = @{@"TextType":@"",
  1184. @"File":@"",
  1185. @"FileName":@"",
  1186. @"Text":model.Text,
  1187. @"Title":@"",
  1188. @"Type":@(CollectDataType_Text),
  1189. @"Author":@"",
  1190. @"Content":@"",
  1191. @"Id":@(0),
  1192. @"CreatedData":@""
  1193. };
  1194. [array addObject:subDict];
  1195. }
  1196. }break;
  1197. case CollectDataType_Group:
  1198. {
  1199. NSDictionary * dict = @{@"TextType":@"",
  1200. @"File":model.File,
  1201. @"FileName":model.FileName,
  1202. @"Text":@"",
  1203. @"Title":model.FileName,
  1204. @"Type":@(CollectDataType_Group),
  1205. @"Author":model.Author,
  1206. @"Content":@"",
  1207. @"Id":@(model.FileId),
  1208. @"CreatedData":@""
  1209. };
  1210. [array addObject:dict];
  1211. if (model.Text.length > 0) {
  1212. NSDictionary * subDict = @{@"TextType":@"",
  1213. @"File":@"",
  1214. @"FileName":@"",
  1215. @"Text":model.Text,
  1216. @"Title":@"",
  1217. @"Type":@(CollectDataType_Text),
  1218. @"Author":@"",
  1219. @"Content":@"",
  1220. @"Id":@(0),
  1221. @"CreatedData":@""
  1222. };
  1223. [array addObject:subDict];
  1224. }
  1225. }break;
  1226. case CollectDataType_Topic:
  1227. {
  1228. NSDictionary * dict = @{@"TextType":@"",
  1229. @"File":model.File,
  1230. @"FileName":model.FileName,
  1231. @"Text":@"",
  1232. @"Title":model.FileName,
  1233. @"Type":@(CollectDataType_Topic),
  1234. @"Author":model.Author,
  1235. @"Content":@"",
  1236. @"Id":@(model.FileId),
  1237. @"CreatedData":@""
  1238. };
  1239. [array addObject:dict];
  1240. if (model.Text.length > 0) {
  1241. NSDictionary * subDict = @{@"TextType":@"",
  1242. @"File":@"",
  1243. @"FileName":@"",
  1244. @"Text":model.Text,
  1245. @"Title":@"",
  1246. @"Type":@(CollectDataType_Text),
  1247. @"Author":@"",
  1248. @"Content":@"",
  1249. @"Id":@(0),
  1250. @"CreatedData":@""
  1251. };
  1252. [array addObject:subDict];
  1253. }
  1254. }break;
  1255. case CollectDataType_Notice:
  1256. {
  1257. NSDictionary * dict = @{@"TextType":@"",
  1258. @"File":model.File,
  1259. @"FileName":model.FileName,
  1260. @"Text":@"",
  1261. @"Title":model.FileName,
  1262. @"Type":@(CollectDataType_Notice),
  1263. @"Author":model.Author,
  1264. @"Content":@"",
  1265. @"Id":@(model.FileId),
  1266. @"CreatedData":@""
  1267. };
  1268. [array addObject:dict];
  1269. if (model.Text.length > 0) {
  1270. NSDictionary * subDict = @{@"TextType":@"",
  1271. @"File":@"",
  1272. @"FileName":@"",
  1273. @"Text":model.Text,
  1274. @"Title":@"",
  1275. @"Type":@(CollectDataType_Text),
  1276. @"Author":@"",
  1277. @"Content":@"",
  1278. @"Id":@(0),
  1279. @"CreatedData":@""
  1280. };
  1281. [array addObject:subDict];
  1282. }
  1283. }break;
  1284. case CollectDataType_InterMail:
  1285. {
  1286. NSDictionary * dict = @{@"TextType":@"",
  1287. @"File":model.File,
  1288. @"FileName":model.FileName,
  1289. @"Text":@"",
  1290. @"Title":model.FileName,
  1291. @"Type":@(CollectDataType_InterMail),
  1292. @"Author":model.Author,
  1293. @"Content":@"",
  1294. @"Id":@(model.FileId),
  1295. @"CreatedData":@""
  1296. };
  1297. [array addObject:dict];
  1298. if (model.Text.length > 0) {
  1299. NSDictionary * subDict = @{@"TextType":@"",
  1300. @"File":@"",
  1301. @"FileName":@"",
  1302. @"Text":model.Text,
  1303. @"Title":@"",
  1304. @"Type":@(CollectDataType_Text),
  1305. @"Author":@"",
  1306. @"Content":@"",
  1307. @"Id":@(0),
  1308. @"CreatedData":@""
  1309. };
  1310. [array addObject:subDict];
  1311. }
  1312. }break;
  1313. case CollectDataType_Meeting:
  1314. {
  1315. NSDictionary * dict = @{@"TextType":@"",
  1316. @"File":model.File,
  1317. @"FileName":model.FileName,
  1318. @"Text":@"",
  1319. @"Title":model.FileName,
  1320. @"Type":@(CollectDataType_Meeting),
  1321. @"Author":model.Author,
  1322. @"Content":@"",
  1323. @"Id":@(model.FileId),
  1324. @"CreatedData":@""
  1325. };
  1326. [array addObject:dict];
  1327. if (model.Text.length > 0) {
  1328. NSDictionary * subDict = @{@"TextType":@"",
  1329. @"File":@"",
  1330. @"FileName":@"",
  1331. @"Text":model.Text,
  1332. @"Title":@"",
  1333. @"Type":@(CollectDataType_Text),
  1334. @"Author":@"",
  1335. @"Content":@"",
  1336. @"Id":@(0),
  1337. @"CreatedData":@""
  1338. };
  1339. [array addObject:subDict];
  1340. }
  1341. }break;
  1342. case CollectDataType_Article:
  1343. {
  1344. NSDictionary * dict = @{@"TextType":@"",
  1345. @"File":model.File,
  1346. @"FileName":model.FileName,
  1347. @"Text":@"",
  1348. @"Title":model.FileName,
  1349. @"Type":@(CollectDataType_Article),
  1350. @"Author":model.Author,
  1351. @"Content":@"",
  1352. @"Id":@(model.FileId),
  1353. @"CreatedData":@""
  1354. };
  1355. [array addObject:dict];
  1356. if (model.Text.length > 0) {
  1357. NSDictionary * subDict = @{@"TextType":@"",
  1358. @"File":@"",
  1359. @"FileName":@"",
  1360. @"Text":model.Text,
  1361. @"Title":@"",
  1362. @"Type":@(CollectDataType_Text),
  1363. @"Author":@"",
  1364. @"Content":@"",
  1365. @"Id":@(0),
  1366. @"CreatedData":@""
  1367. };
  1368. [array addObject:subDict];
  1369. }
  1370. }break;
  1371. case CollectDataType_Approval:
  1372. {
  1373. NSDictionary * dict = @{@"TextType":@"",
  1374. @"File":model.File,
  1375. @"FileName":model.FileName,
  1376. @"Text":@"",
  1377. @"Title":model.FileName,
  1378. @"Type":@(CollectDataType_Approval),
  1379. @"Author":model.Author,
  1380. @"Content":@"",
  1381. @"Id":@(model.FileId),
  1382. @"CreatedData":@""
  1383. };
  1384. [array addObject:dict];
  1385. if (model.Text.length > 0) {
  1386. NSDictionary * subDict = @{@"TextType":@"",
  1387. @"File":@"",
  1388. @"FileName":@"",
  1389. @"Text":model.Text,
  1390. @"Title":@"",
  1391. @"Type":@(CollectDataType_Text),
  1392. @"Author":@"",
  1393. @"Content":@"",
  1394. @"Id":@(0),
  1395. @"CreatedData":@""
  1396. };
  1397. [array addObject:subDict];
  1398. }
  1399. }break;
  1400. default:
  1401. break;
  1402. }
  1403. }
  1404. NSMutableDictionary * dic = [NSMutableDictionary dictionary];
  1405. [dic setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1406. [dic setObject:[self arrayToJSONString:array] forKey:@"Content"];
  1407. [dic setValue:self.textView.text forKey:@"Title"];
  1408. if (self.isEdit) {
  1409. [dic setValue:@(self.interLeterId) forKey:@"Id"];
  1410. }
  1411. [dic setValue:@(NoticeType) forKey:@"MissiveType"];
  1412. [dic setValue:@(address) forKey:@"MissiveAttributeType"];
  1413. switch (self.interLeterHanderType) {
  1414. case InterLeterHanderType_Create:{
  1415. [dic setValue:@(0) forKey:@"ParentId"];
  1416. }break;
  1417. case InterLeterHanderType_Modify:{
  1418. [dic setValue:@(0) forKey:@"ParentId"];
  1419. }case InterLeterHanderType_Replay:{
  1420. [dic setValue:@(self.replayId) forKey:@"ParentId"];
  1421. }
  1422. default:
  1423. break;
  1424. }
  1425. [dic setValue:@(0) forKey:@"FolderId"];
  1426. // 收集收件人ID数组
  1427. NSMutableArray *array1 = [NSMutableArray array];
  1428. for (SelectModel *model in self.shouJianArray) {
  1429. NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName};
  1430. [array1 addObject:param];
  1431. }
  1432. [dic setValue:array1 forKey:@"AddresseeUserMiddles"];
  1433. // 收集抄送人ID数组
  1434. NSMutableArray *array2 = [NSMutableArray array];
  1435. for (SelectModel *model in self.chaoShongArray) {
  1436. NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName};
  1437. [array2 addObject:param];
  1438. }
  1439. [dic setValue:array2 forKey:@"CcUserMiddles"];
  1440. NSLog(@"请求参数%@",dic);
  1441. [self sentNoticeRequeast:dic withNoticeType:NoticeType];
  1442. }
  1443. - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  1444. WS(weakSelf);
  1445. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1446. REMOVESHOW
  1447. if(NoticeType == 1){
  1448. SHOWSUCCESS(@"站内信已经发送");
  1449. }else{
  1450. SHOWSUCCESS(@"站内信已经存放草稿箱");
  1451. }
  1452. [weakSelf.navigationController popViewControllerAnimated:YES];
  1453. } failure:^(NSError * _Nonnull error) {
  1454. SHOWERROR([ZYCTool handerResultData:error]);
  1455. }];
  1456. }
  1457. - (NSString *)arrayToJSONString:(NSArray *)array
  1458. {
  1459. NSError *error = nil;
  1460. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1461. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1462. return jsonString;
  1463. }
  1464. - (void)dealloc
  1465. {
  1466. [[NSNotificationCenter defaultCenter] removeObserver:self];
  1467. }
  1468. #pragma mark - SmartBarDelegate
  1469. - (void)didSelectBarWithType:(SmartBarType)type
  1470. {
  1471. WS(weakSelf);
  1472. switch (type) {
  1473. case SmartBarPhoto:
  1474. {
  1475. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  1476. } choosImgBlock:^(UIImage *image) {
  1477. [weakSelf didSelectImage:image];
  1478. }];
  1479. }
  1480. break;
  1481. case SmartBarCamera:
  1482. {
  1483. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  1484. } choosImgBlock:^(UIImage *image) {
  1485. [weakSelf didSelectImage:image];
  1486. }];
  1487. }
  1488. break;
  1489. case SmartBarNotes:
  1490. {
  1491. [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
  1492. NSLog(@"SmartBarNotes %@",noteArr);
  1493. [weakSelf disSelectNoteBook:noteArr];
  1494. }];
  1495. }
  1496. break;
  1497. case SmartBarCollection:
  1498. {
  1499. [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
  1500. NSLog(@"SmartBarCollection %@",collectArr);
  1501. [weakSelf disSelectCollect:collectArr];
  1502. }];
  1503. }
  1504. break;
  1505. case SmartBarFile:
  1506. {
  1507. WS(weakSelf);
  1508. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  1509. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  1510. SHOWLOADING
  1511. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  1512. REMOVESHOW
  1513. NSLog(@"上传成功的文件%@",responseObject);
  1514. [weakSelf fileSizeWithData:fileData withDict:responseObject[0] withName:fileName];
  1515. } failure:^(NSError * _Nonnull error) {
  1516. REMOVESHOW
  1517. }];
  1518. }];
  1519. }
  1520. break;
  1521. default:
  1522. break;
  1523. }
  1524. }
  1525. - (void)fileSizeWithData:(NSData *)fileData withDict:(NSDictionary *)dict withName:(NSString *)fileName
  1526. {
  1527. unsigned long long size = [fileData length];
  1528. NSString * fileZise;
  1529. if (size >= pow(10, 9)) { // size >= 1GB
  1530. fileZise = [NSString stringWithFormat:@"%.2fGB", size / pow(10, 9)];
  1531. } else if (size >= pow(10, 6)) { // 1GB > size >= 1MB
  1532. fileZise = [NSString stringWithFormat:@"%.2fMB", size / pow(10, 6)];
  1533. } else if (size >= pow(10, 3)) { // 1MB > size >= 1KB
  1534. fileZise = [NSString stringWithFormat:@"%.2fKB", size / pow(10, 3)];
  1535. } else { // 1KB > size
  1536. fileZise = [NSString stringWithFormat:@"%lluB", size];
  1537. }
  1538. [self didSelectFile:dict withSize:fileZise withName:fileName];
  1539. }
  1540. - (void)didSelectImage:(UIImage *)image
  1541. {
  1542. WS(weakSelf);
  1543. NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
  1544. [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:@[UIImageJPEGRepresentation(image,1.0f)] pictureKey:@"file" success:^(id _Nonnull responseObject) {
  1545. NSLog(@"%@",responseObject);
  1546. NSDictionary * dict = responseObject[0];
  1547. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1548. model.PlaceText = @"编辑内容";
  1549. model.Content = @"";
  1550. model.ImageUrl = dict[@"AbsolutePath"];
  1551. model.FileId = [dict[@"FileId"] integerValue];
  1552. model.FileName = dict[@"FileName"];
  1553. model.Type = CollectDataType_IMG;
  1554. CGFloat imgH = (SCREEN_WIDTH - 30) * 0.5 + 101.f;
  1555. model.Height = imgH;
  1556. [weakSelf.dataArray addObject:model];
  1557. dispatch_async(dispatch_get_main_queue(), ^{
  1558. [weakSelf.tableView reloadSection:0 withRowAnimation:UITableViewRowAnimationNone];
  1559. if (weakSelf.tableView.contentOffset.y > SCREEN_HEIGHT) {
  1560. [weakSelf.tableView performSelector:@selector(scrollToBottom) withObject:nil afterDelay:0.1];
  1561. }
  1562. });
  1563. } failure:^(NSError * _Nonnull error) {
  1564. SHOWERROR([ZYCTool handerResultData:error]);
  1565. }];
  1566. }
  1567. - (void)didSelectFile:(NSDictionary *)dict withSize:(NSString *)fileSize withName:(NSString *)fileName
  1568. {
  1569. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1570. model.Title = @"";
  1571. model.Content = @"";
  1572. if ([dict[@"AbsolutePath"] length] == 0) {
  1573. if ([fileName hasSuffix:@".doc"]) {
  1574. model.File = @"icon_word";
  1575. }else if([fileName hasSuffix:@".xls"]){
  1576. model.File = @"icon_excel";
  1577. }else if([fileName hasSuffix:@".ppt"]){
  1578. model.File = @"icon_ppt";
  1579. }else if([fileName hasSuffix:@".pdf"]){
  1580. model.File = @"icon_pdf";
  1581. }else if([fileName hasSuffix:@".zip"]){
  1582. model.File = @"icon_yasuowenjian";
  1583. }else if([fileName hasSuffix:@".psd"]){
  1584. model.File = @"icon_psd";
  1585. }else if([fileName hasSuffix:@".ai"]){
  1586. model.File = @"icon_ai";
  1587. }else if([fileName hasSuffix:@".txt"]){
  1588. model.File = @"icon_txt";
  1589. }else if([fileName hasSuffix:@".html"]){
  1590. model.File = @"icon_html";
  1591. }else if([fileName hasSuffix:@".png"] || [fileName hasSuffix:@".JPG"] || [fileName hasSuffix:@".JPEG"] || [fileName hasSuffix:@".jpg"] || [fileName hasSuffix:@".jpeg"] || [fileName hasSuffix:@".PNG"] || [fileName hasSuffix:@".bmp"] || [fileName hasSuffix:@".BMP"]){
  1592. model.File = dict[@"AbsolutePath"];
  1593. }else{
  1594. model.File = @"icon_weizhiwenjian";
  1595. }
  1596. }
  1597. model.FileId = [dict[@"FileId"] integerValue];
  1598. model.FileName = dict[@"FileName"];
  1599. model.Type = CollectDataType_File;
  1600. model.Height = 175.f;
  1601. model.FileSize = fileSize;
  1602. [self.dataArray addObject:model];
  1603. WS(weakSelf);
  1604. dispatch_async(dispatch_get_main_queue(), ^{
  1605. [weakSelf.tableView reloadData];
  1606. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1607. [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
  1608. });
  1609. });
  1610. }
  1611. - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
  1612. for (MyNoteBookSubModel *dataModel in noteArr ) {
  1613. if (dataModel.AttributeValue == 1) {
  1614. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1615. model.Id = dataModel.MiddleId;
  1616. model.FileId = dataModel.MiddleId;
  1617. model.ImageUrl = dataModel.AvatarUrl;
  1618. model.Author = dataModel.Name;
  1619. model.FileName = dataModel.Title;
  1620. model.Type = CollectDataType_Note;
  1621. [self.dataArray addObject:model];
  1622. WS(weakSelf);
  1623. dispatch_async(dispatch_get_main_queue(), ^{
  1624. [weakSelf.tableView reloadData];
  1625. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1626. [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
  1627. });
  1628. });
  1629. }else{
  1630. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1631. model.Id = dataModel.Id;
  1632. model.FileId = dataModel.Id;
  1633. model.ImageUrl = dataModel.AvatarUrl;
  1634. model.Author = [AppUserModel sharedAppUserModel].Name;
  1635. model.FileName = dataModel.FolderName;
  1636. model.Type = CollectDataType_NoteFile;
  1637. [self.dataArray addObject:model];
  1638. WS(weakSelf);
  1639. dispatch_async(dispatch_get_main_queue(), ^{
  1640. [weakSelf.tableView reloadData];
  1641. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1642. [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
  1643. });
  1644. }); }
  1645. }
  1646. }
  1647. - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
  1648. for (MyFavoriteSubModel *dataModel in collectArr ) {
  1649. if(dataModel.AttributeValue == 1)
  1650. {
  1651. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1652. model.Id = dataModel.CollectionDataId;
  1653. model.FileId = dataModel.CollectionDataId;
  1654. model.ImageUrl = dataModel.Data.AvatarUrl;
  1655. model.Author = dataModel.Data.Author;
  1656. model.FileName = dataModel.Title;
  1657. model.Type = [ZYCTool returnDataType:dataModel.CollectionType];
  1658. [self.dataArray addObject:model];
  1659. WS(weakSelf);
  1660. dispatch_async(dispatch_get_main_queue(), ^{
  1661. [weakSelf.tableView reloadData];
  1662. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1663. [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
  1664. });
  1665. });
  1666. }else{
  1667. CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
  1668. model.Id = dataModel.Id;
  1669. model.FileId = dataModel.Id;
  1670. model.ImageUrl = dataModel.Data.AvatarUrl;
  1671. model.Author = [AppUserModel sharedAppUserModel].Name;
  1672. model.FileName = dataModel.FolderName;
  1673. model.Type = CollectDataType_CollectFile;
  1674. [self.dataArray addObject:model];
  1675. WS(weakSelf);
  1676. dispatch_async(dispatch_get_main_queue(), ^{
  1677. [weakSelf.tableView reloadData];
  1678. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1679. [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
  1680. });
  1681. });
  1682. }
  1683. }
  1684. }
  1685. - (void)didSelectBarKeyBtnIsShow:(BOOL)isShow
  1686. {
  1687. [self.view endEditing:YES];
  1688. }
  1689. - (void)didSelectBarAddBtnIsShow:(BOOL)isShow;{
  1690. [self.view endEditing:YES];
  1691. }
  1692. - (void)viewWillDisappear:(BOOL)animated
  1693. {
  1694. [super viewWillDisappear:animated];
  1695. [[IQKeyboardManager sharedManager] setEnable:NO];
  1696. WS(weakSelf);
  1697. [self.view endEditing:YES];
  1698. [self.SmartBar downBar];
  1699. [self.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
  1700. if (@available(iOS 11.0, *)) {
  1701. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
  1702. } else {
  1703. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
  1704. }
  1705. }];
  1706. }
  1707. - (shoujianrenResultView *)resultView {
  1708. if (!_resultView) {
  1709. _resultView = [shoujianrenResultView new];
  1710. }
  1711. return _resultView;
  1712. }
  1713. - (NSString *)getFileNameImage:(NSString *)fileName
  1714. {
  1715. if ([fileName hasPrefix:@".doc"]) {
  1716. return @"icon_word";
  1717. }else if([fileName hasPrefix:@".xls"]){
  1718. return @"icon_excel";
  1719. }else if([fileName hasPrefix:@".ppt"]){
  1720. return @"icon_ppt";
  1721. }else if([fileName hasPrefix:@".pdf"]){
  1722. return @"icon_pdf";
  1723. }else if([fileName hasPrefix:@".zip"]){
  1724. return @"icon_yasuowenjian";
  1725. }else if([fileName hasPrefix:@".psd"]){
  1726. return @"icon_psd";
  1727. }else if([fileName hasPrefix:@".ai"]){
  1728. return @"icon_ai";
  1729. }else if([fileName hasPrefix:@".txt"]){
  1730. return @"icon_txt";
  1731. }else if([fileName hasPrefix:@".html"]){
  1732. return @"icon_html";
  1733. }else{
  1734. return @"icon_weizhiwenjian";
  1735. }
  1736. }
  1737. @end