12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844 |
- //
- // CreateInterLeterVC.m
- // smartRhino
- //
- // Created by taidi on 2019/12/25.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "CreateInterLeterVC.h"
- #import "AddLookUpUserSecondVC.h"
- #import "NoticeSelectCell.h"
- #import "YCMenuView.h"
- #import "ShowKeepNoticeAlert.h"
- #import "NewTopicCell.h"
- #import "SmartBar.h"
- #import "LYLPhotoTailoringTool.h"
- #import "FWZGetNoteBookTool.h"
- #import "FWZFileGetTool.h"
- #import "NoteBookDetailCell.h"
- #import "shoujianrenResultView.h"
- #define TextViewTag 1000
- #define BARHEIGHT 42.5f
- @interface CreateInterLeterVC ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UITextViewDelegate,SmartBarDelegate>
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (strong, nonatomic) NSMutableArray <SelectModel *>*shouJianArray;
- @property (strong, nonatomic) NSMutableArray <SelectModel *>*chaoShongArray;
- @property (weak, nonatomic) IBOutlet UICollectionView *shouJianCollectionView;
- @property (weak, nonatomic) IBOutlet UICollectionView *chaoSongColletionView;
- @property (weak, nonatomic) IBOutlet UIButton *shouJianBtn;
- @property (weak, nonatomic) IBOutlet UIButton *chaoSongBtn;
- @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
- @property (strong, nonatomic) NewTopicTextView *defualtView;
- @property (weak, nonatomic) IBOutlet NewTopicTextView *textView;
- @property (nonatomic,assign) Boolean isShouJianRen;
- @property (nonatomic,assign) Boolean isChaoSongRen;
- @property (weak, nonatomic) IBOutlet UIButton *titleBtn;
- @property (strong, nonatomic) NSMutableArray *taskActionArray;
- @property (weak, nonatomic) IBOutlet UIButton *rightAddBtn;
- @property (strong, nonatomic) NSMutableArray *dataArray;
- /// 编辑标题
- @property (strong, nonatomic) SmartBar *SmartBar;
- @property (assign, nonatomic) NSInteger InterLeterType;
- @property (weak, nonatomic) IBOutlet UITextField *shoujianrenTextField;
- @property (strong, nonatomic) shoujianrenResultView *resultView;
- @property (weak, nonatomic) IBOutlet UIView *shoujianrenView;
- @property (weak, nonatomic) IBOutlet UIView *headerView;
- @property (weak, nonatomic) IBOutlet UIView *inputTitleView;
- @property (weak, nonatomic) IBOutlet UIView *headerTopView;
- @end
- @implementation CreateInterLeterVC
- +(CreateInterLeterVC *)initCreateInterLeterVC{
- CreateInterLeterVC *controller = [StoryboardManager.shared.interLeterHome instantiateViewControllerWithIdentifier:@"CreateInterLeterVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [[IQKeyboardManager sharedManager] setEnable:YES];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.textView.placeholder = @"请输入标题";
- self.textView.delegate = self;
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = RGB(255, 255, 255);
- self.fd_interactivePopDisabled = YES;
- self.InterLeterType = 1;
- switch (self.interLeterHanderType) {
- case InterLeterHanderType_Create:
- {
- WS(weakSelf);
- [self.titleBtn setAction:^{
- weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected;
- //[weakSelf.titleBtn setImage:[UIImage imageNamed:@"chatmsg_notice_hideAll_icon"] forState:UIControlStateNormal];
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.taskActionArray];
- YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn];
- view.menuColor = RGB(255, 255, 255);
- view.separatorColor = RGB(234, 234, 234);
- view.textColor = RGB(102, 102, 102);
- view.textFont = [UIFont systemFontOfSize:16.0];
- view.menuCellHeight = 43.5;
- view.maxDisplayCount = 10;
- view.offset = -6;
- [view setDissmisBlock:^{
- weakSelf.titleBtn.selected = !weakSelf.titleBtn.selected;
- }];
- [view show];
- }];
- [self getInterLeterDataCreate];
- self.titleLabel.hidden = YES;
- }
- break;
- case InterLeterHanderType_Modify:
- {
- [self getData];
- self.titleLabel.hidden = YES;
- }
- break;
- case InterLeterHanderType_Replay:
- {
- self.titleBtn.hidden = YES;
- self.titleLabel.hidden = NO;
- [self getData];
- [self getInterLeterDataReplay];
- }
- break;
- }
-
- self.chaoSongColletionView.tag = 202;
- self.shouJianCollectionView.tag = 101;
- [self.chaoSongColletionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"];
- [self.shouJianCollectionView registerNib:[UINib nibWithNibName:@"NoticeSelectCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeSelectCell"];
- [self registerNotification];
- self.SmartBar.delegate = self;
- [self.view addSubview:self.SmartBar];
- [self.SmartBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.height.mas_offset(BARHEIGHT);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(self.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- //[self.textView addTarget:self action:@selector(shoujirenTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-
-
-
- [self.view addSubview:self.resultView];
- [self.resultView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.view);
- make.top.equalTo(self.shoujianrenView.mas_bottom);
- }];
- [self.resultView setHidden:YES];
- }
- - (void)getData
- {
- [self.dataArray removeAllObjects];
- WS(weakSelf)
- SHOWLOADING
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/missive/"),(long)self.interLeterId];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"通知正文%@",responseObject);
- REMOVESHOW
- for (NSDictionary * dic in responseObject[@"AddresseeUserMiddles"]) {
- SelectModel * model = [[SelectModel alloc] init];
- model.UserId = [[dic objectForKey:@"SourceId"] integerValue];
- model.UserName = [dic objectForKey:@"SourceName"];
- model.SourceId = [[dic objectForKey:@"SourceId"] integerValue];
- model.SourceType = [[dic objectForKey:@"SourceType"] integerValue];
- model.SourceName = [dic objectForKey:@"SourceName"];
- [weakSelf.shouJianArray addObject:model];
- }
- for (NSDictionary * dic in responseObject[@"CcUserMiddles"]) {
- SelectModel * model = [[SelectModel alloc] init];
- model.UserId = [[dic objectForKey:@"SourceId"] integerValue];
- model.UserName = [dic objectForKey:@"SourceName"];
- model.SourceId = [[dic objectForKey:@"SourceId"] integerValue];
- model.SourceType = [[dic objectForKey:@"SourceType"] integerValue];
- model.SourceName = [dic objectForKey:@"SourceName"];
- [weakSelf.chaoShongArray addObject:model];
- }
- if ([responseObject[@"Title"] length] > 0) {
- weakSelf.textView.text = responseObject[@"Title"];
- }
- for (NSDictionary * dict in responseObject[@"Data"]) {
- CreateInterLeterModel * model = [CreateInterLeterModel modelWithDictionary:dict];
- [weakSelf.dataArray addObject:model];
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- if ([weakSelf.shouJianArray count] > 0) {
- [weakSelf.shouJianCollectionView reloadData];
- }
- if ([weakSelf.chaoShongArray count] > 0) {
- [weakSelf.chaoSongColletionView reloadData];
- }
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)shoujirenTextFieldDidChange:(NSNotification *)notification {
- return;
- NSString *tmpStr = [self.shoujianrenTextField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- if (tmpStr.length) {
- // 显示搜索结果
- [self.resultView setHidden:NO];
- } else {
- // 不显示搜索结果
- [self.resultView setHidden:YES];
- }
- }
- - (SmartBar *)SmartBar{
- if (!_SmartBar) {
- _SmartBar = [[SmartBar alloc]init];
- _SmartBar.delegate = self;
- }
- return _SmartBar;
- }
- - (void)getInterLeterDataCreate{
- [self.dataArray removeAllObjects];
- CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init];
- titleModel.PlaceText = @"编辑内容";
- titleModel.Content = @"";
- titleModel.Type = CollectDataType_Text;
- if(self.interLeterHanderType == InterLeterHanderType_Replay){
- titleModel.Height = 55.5f * 3;
- }else{
- titleModel.Height = 55.5f;
- }
- [self.dataArray addObject:titleModel];
- [self.tableView reloadData];
-
- if (self.isFromOtherPeople) {
- self.shouJianArray = self.shouJianArrTemp;
- }
- }
- - (void)getInterLeterDataReplay{
- [self.dataArray removeAllObjects];
- CreateInterLeterModel * titleModel = [[CreateInterLeterModel alloc] init];
- titleModel.PlaceText = @"编辑内容";
- titleModel.Content = @"";
- titleModel.Type = CollectDataType_Text;
- if(self.interLeterHanderType == InterLeterHanderType_Replay){
- titleModel.Height = 55.5f * 3;
- }else{
- titleModel.Height = 55.5f;
- }
- [self.dataArray addObject:titleModel];
- [self.tableView reloadData];
- [self.shouJianArray removeAllObjects];
- for (NSDictionary * dict in self.replayDataArray) {
- SelectModel *model = [[SelectModel alloc] init];
- model.SourceType = 0;
- model.SourceId = [dict[@"Id"] integerValue];
- model.SourceName = dict[@"Name"];
- [self.shouJianArray addObject:model];
- }
- self.shouJianBtn.hidden =YES;
- [self.shouJianCollectionView reloadData];
- self.textView.text = [NSString stringWithFormat:@"Re:%@",self.replayTitle];
- }
- - (NSMutableArray *)dataArray{
- if(!_dataArray){
- _dataArray = [NSMutableArray new];
- }
- return _dataArray;
- }
- -(NSMutableArray *)taskActionArray{
- if(!_taskActionArray){
- _taskActionArray = [[NSMutableArray alloc] initWithObjects:@"写信件",@"匿名信", nil];
- }
- return _taskActionArray;
- }
- -(NSMutableArray *)getMenuDataSource:(NSMutableArray *)titleArray{
- NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
- for(int i=0;i<titleArray.count;i++){
- NSString *titleStr = [titleArray objectAtIndex:i];
- WS(weakSelf);
- YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
- [weakSelf.titleBtn setImage:[UIImage imageNamed:@"chatmsg_notice_showAll_icon"] forState:UIControlStateNormal];
- [self.titleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 45, 0, 0)];
- [self.titleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -45, 0, 0)];
- [self.titleBtn setTitle:action.title forState:UIControlStateNormal];
- if([@"写信件" isEqualToString:action.title]){
- weakSelf.InterLeterType =1;
- }
- else if ([@"匿名信" isEqualToString:action.title]){
- weakSelf.InterLeterType =2;
- }
- }];
- [menuDataSourceArray addObject:actionMenu];
- }
- return menuDataSourceArray;
- }
- #pragma mark - CollectionView 代理
- -(NSMutableArray<SelectModel *> *)shouJianArray{
- if(!_shouJianArray){
- _shouJianArray = [[NSMutableArray alloc] init];
- }
- return _shouJianArray;
- }
- -(NSMutableArray<SelectModel *> *)chaoShongArray{
- if(!_chaoShongArray){
- _chaoShongArray = [[NSMutableArray alloc] init];
- }
- return _chaoShongArray;
- }
- -(IBAction)userDidSelectShouJianAction:(id)sender{
- self.isShouJianRen = YES;
- self.isChaoSongRen = NO;
- [self selectPeople];
- }
- -(IBAction)userDidSelectChaoShongAction:(id)sender{
- self.isChaoSongRen = YES;
- self.isShouJianRen = NO;
- [self selectPeople];
- }
- - (void)selectPeople{
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
- vc.isAllSelected = YES;
- Department *defaltGroupSetion = [[Department alloc]init];
- defaltGroupSetion.Name = @"单位通讯录";
- defaltGroupSetion.Id = 0;
- defaltGroupSetion.SourceId = 0;
- defaltGroupSetion.SourceType = 1;
- defaltGroupSetion.SourceName = @"单位通讯录";
- defaltGroupSetion.MiddleType = 1;
- Department *myGroupSetion = [[Department alloc]init];
- myGroupSetion.Name = @"自建通讯录";
- myGroupSetion.Id = 0;
- myGroupSetion.MiddleType = 3;
- myGroupSetion.SourceType = 3;
- myGroupSetion.SourceId = 0;
- myGroupSetion.SourceName = @"自建通讯录";
-
- vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
- vc.isDefalutPage = 1;
- vc.titleStr = @"选人";
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)registerNotification{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shoujirenTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
- }
- - (void)recviveChaoSongRen:(NSNotification *)notification{
- if (self.isShouJianRen) {
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
- NSMutableArray <SelectModel *>* array0 = self.shouJianArray;
- NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
- if (array0.count == 0) {
- [self.shouJianArray addObjectsFromArray:array1];
- }else{
- for (NSInteger x = 0; x < array.count; x++) {
- for (NSInteger y = 0 ; y<array0.count; y++) {
- if (array[x].UserId == array0[y].UserId) {
- [array1 removeObjectAtIndex:x];
- }
- }
- }
- NSLog(@"结果数据组%@",array1);
- [self.shouJianArray addObjectsFromArray:array1];
- }
- [self.shouJianCollectionView reloadData];
- // if (self.shouJianArray.count) {
- // [self.shouJianCollectionView setHidden:NO];
- // [self.shoujianrenTextField setHidden:YES];
- // } else {
- // [self.shouJianCollectionView setHidden:YES];
- // [self.shoujianrenTextField setHidden:NO];
- // }
- self.isShouJianRen = NO;
- [self checkNoticData];
- }
-
- if (self.isChaoSongRen) {
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
- NSMutableArray <SelectModel *>* array0 = self.chaoShongArray;
- NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
- if (array0.count == 0) {
- [self.chaoShongArray addObjectsFromArray:array1];
- }else{
- for (NSInteger x = 0; x < array.count; x++) {
- for (NSInteger y = 0 ; y<array0.count; y++) {
- if (array[x].UserId == array0[y].UserId) {
- [array1 removeObjectAtIndex:x];
- }
- }
- }
- NSLog(@"结果数据组%@",array1);
- [self.chaoShongArray addObjectsFromArray:array1];
- }
- [self.chaoSongColletionView reloadData];
- self.isChaoSongRen = NO;
- }
-
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- if (collectionView.tag == 101) {
- return self.shouJianArray.count;
- }else{
- return self.chaoShongArray.count;
- }
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
- if (collectionView.tag == 101) {
- // 收件人
- if (self.isFromOtherPeople) {
-
- }else{
-
- }
- NoticeSelectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeSelectCell" forIndexPath:indexPath];
- cell.nameLabel.attributedText = [self textHander: [NSString stringWithFormat:@" %@ ",self.shouJianArray[indexPath.item].SourceName]];
- cell.nameLabel.layer.cornerRadius = 13;
- cell.nameLabel.layer.masksToBounds = YES;
- WEAKSELF
- [cell.delButton setAction:^{
- [weakSelf delShoujianrenAction:indexPath];
- }];
- return cell;
- }else{
- // 抄送人
- NoticeSelectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeSelectCell" forIndexPath:indexPath];
- cell.nameLabel.attributedText = [self textHander: [NSString stringWithFormat:@" %@ ",self.chaoShongArray[indexPath.item].SourceName]];
- cell.nameLabel.layer.cornerRadius = 13;
- cell.nameLabel.layer.masksToBounds = YES;
- WEAKSELF
- [cell.delButton setAction:^{
- [weakSelf delChaosongrenAction:indexPath];
- }];
- return cell;
- }
- }
- - (NSAttributedString *)textHander:(NSString *)labelString{
- NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
- paraStyle.alignment = NSTextAlignmentCenter;//对齐
- CGFloat emptylen = 12 * 8;
- paraStyle.headIndent = emptylen;//行首缩进
- //字体大小号字乘以2 即首行空出两个字符
- // paraStyle.firstLineHeadIndent = emptylen;//首行缩进
- paraStyle.tailIndent = emptylen ;//行尾缩进
- NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:labelString attributes:@{NSParagraphStyleAttributeName:paraStyle}];
- return attrText;
- }
- // 删除收件人
- - (void)delShoujianrenAction:(NSIndexPath *)indexPath {
- [self.shouJianArray removeObjectAtIndex:indexPath.row];
- [self.shouJianCollectionView reloadData];
- }
- // 删除抄送人
- - (void)delChaosongrenAction:(NSIndexPath *)indexPath {
- [self.chaoShongArray removeObjectAtIndex:indexPath.row];
- [self.chaoSongColletionView reloadData];
- }
- #pragma mark - tableView 代理
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- switch (self.interLeterHanderType) {
- case InterLeterHanderType_Create:
- return 1;
- case InterLeterHanderType_Modify:
- return 1;
- case InterLeterHanderType_Replay:
- return 1 + self.replayArray.count;
- }
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- switch (self.interLeterHanderType) {
- case InterLeterHanderType_Create:{
- return self.dataArray.count;
- }break;
- case InterLeterHanderType_Modify:{
- return self.dataArray.count;
- }break;
- case InterLeterHanderType_Replay:
- switch (section) {
- case 0:{
- return self.dataArray.count;
- }break;
- default:{
- InterLeterDetailSubModel *model = self.replayArray[section - 1];
- return model.Data.count + 2;// 第一条:固定的原信件内容,第二条:信件标题
- }break;
- }
- return self.dataArray.count;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- CreateInterLeterModel *model = [self.dataArray objectAtIndex:indexPath.row];
- if (indexPath.row == 0 && model.Type == CollectDataType_Text) {
- if(self.interLeterHanderType == InterLeterHanderType_Replay){
- return 55.5f * 3;
- }else{
- return UITableViewAutomaticDimension;
- }
- }
- return UITableViewAutomaticDimension;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- CreateInterLeterModel *model = [self.dataArray objectAtIndex:indexPath.row];
- // if (indexPath.row == 0) {
- // NewTopicCell *cell = [NewTopicCell configCell0:tableView indexPath:indexPath];
- // if (!self.defualtView) {
- // self.defualtView = cell.textView;
- // }
- // cell.textView.placeholder = model.Title;
- // cell.textView.text = model.Content;
- // cell.bgLabel.text = cell.textView.text;
- // cell.textView.tag = TextViewTag + indexPath.row;
- // cell.textView.delegate = self;
- // return cell;
- // }
- switch (model.Type) {
- case CollectDataType_Text:
- {
- NewTopicCell *cell = [NewTopicCell configCell1:tableView indexPath:indexPath];
- cell.textView.placeholder = model.Title;
- cell.textView.text = model.Content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- [cell.textView becomeFirstResponder];
- return cell;
- }
- break;
- case CollectDataType_File:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.cell2SubTitleL.text = model.FileSize;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- NSString * imageName = [ZYCTool getFileNameImage:model.File];
- if (imageName.length > 0) {
- cell.cell2ImagV.image = IMG(imageName);
- }else{
- [cell.cell2ImagV sd_setImageWithURL:[NSURL URLWithString:model.File] placeholderImage:IMG(@"icon_weizhiwenjian")];
- }
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_IMG:
- {
- NewTopicCell *cell = [NewTopicCell configCell3:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- [cell.cell3ImagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrl]];
-
- [cell.cell3CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_Collect:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.text = model.Content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2TitleL.text = model.FileName;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"收藏");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_Note:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"noteBook_icon");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_NoteFile:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记文件夹",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"find_1");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_CollectFile:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏文件夹",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"find_1");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Group:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@小组",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"笔记小组");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Topic:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"话题");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Notice:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的通知",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"通知图标");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_InterMail:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@站内信",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"站内信");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Meeting:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的会议",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"会议");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Article:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的文章",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"文章");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Approval:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的审批",model.Author] KeyString:model.Author];
- cell.cell2ImagV.image = IMG(@"审批");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- default:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.delegate = self;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.placeholder = @"";
- cell.textView.text = model.Content;
- cell.bgLabel.text = cell.textView.text;
-
- cell.cell2TitleL.text = model.FileName;
- cell.cell2SubTitleL.text = model.FileSize;
- NSString * imageName = [ZYCTool getFileNameImage:model.File];
- cell.cell2ImagV.image = IMG(imageName);
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- }
- }
- #pragma mark - KeyBoard
- - (void)keyBoardWillShow:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘高度
- CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGFloat keyBoardHeight = keyBoardBounds.size.height;
- // 获取键盘动画时间
- CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
-
-
- // 定义好动作
- WS(weakSelf);
- void (^animation)(void) = ^void(void) {
- [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-keyBoardHeight);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-keyBoardHeight);
- }
- }];
- };
-
- if (animationTime > 0) {
- [UIView animateWithDuration:animationTime animations:animation completion:^(BOOL finished) {
-
- }];
- } else {
- animation();
- }
- }
- - (void)keyBoardWillHide:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘动画时间
- CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
-
- // 定义好动作
- WS(weakSelf);
- void (^animation)(void) = ^void(void) {
- [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- };
-
- if (animationTime > 0) {
- [UIView animateWithDuration:animationTime animations:animation];
- } else {
- animation();
- }
- }
- #pragma -mark UItextViewDelegate
- - (void)textFieldDidChange:(UITextField *)textField{
- [self checkNoticData];
- }
- - (void)textViewDidBeginEditing:(UITextView *)textView
- {
- self.defualtView = (NewTopicTextView *)textView;
- }
- - (void)textViewDidChange:(UITextView *)textView
- {
- [self checkNoticData];
- self.defualtView = (NewTopicTextView *)textView;
- NSInteger index = textView.tag - TextViewTag;
- CreateInterLeterModel * model = [self.dataArray objectAtIndex:index];
- model.Content = textView.text;
-
- CGRect bounds = textView.bounds;
- CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX);
- CGSize newSize = [textView sizeThatFits:maxSize];
- if (model.Height != (newSize.height + 35.f)) {
- model.Height = newSize.height + 35.f;
- [self.tableView beginUpdates];
- [self.tableView endUpdates];
- }
-
- CGFloat H = 34.f;
- if (textView == self.textView) {
- CGRect bounds = textView.bounds;
- CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX);
- CGSize newSize = [textView sizeThatFits:maxSize];
- if (H < newSize.height) {
- H = newSize.height;
- [self.headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, H + 116)];
- [self.headerView updateConstraints];
- [self.headerView setNeedsLayout];
- [self.headerView layoutIfNeeded];
- [self.inputTitleView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.mas_equalTo(self.headerView);
- make.top.mas_equalTo(self.headerTopView.mas_bottom);
- }];
- [self.tableView setSectionHeaderHeight:H + 116];
- [self.tableView beginUpdates];
- [self.tableView endUpdates];
- [self.tableView layoutIfNeeded];
- }
- }
-
- }
- - (void)backAction:(id)sender{
- WS(weakSelf);
- [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
- [weakSelf handerNotice:self.InterLeterType withAddress:2]; /// 草稿
- } cancle:^(ShowKeepNoticeCloseType colseType) {
- if(colseType == ShowKeepNoticeCloseType1){
- [weakSelf.navigationController popViewControllerAnimated:YES];
- }
- }] show];
- }
- - (void)menuAction:(id)sender{
- [super menuAction:sender];
- }
- #pragma mark - 提交信息
- - (BOOL)checkNoticData {
-
- if (self.shouJianArray.count > 0 && (self.textView.text.length > 0 || self.dataArray.count > 0)) {
- self.rightAddBtn.enabled = YES;
- return YES;
- }
- self.rightAddBtn.enabled = NO;
- return NO;
- }
- - (IBAction)sendNoticManyPeople:(UIButton *)sender {
- ///1 正常 2 匿名
- [self handerNotice:self.InterLeterType withAddress:1];//发送
- }
- - (void)handerNotice:(NSInteger)NoticeType withAddress:(NSInteger)address{
- SHOWLOADING
- NSMutableArray * array = [NSMutableArray array];
- for (CreateInterLeterModel * model in self.dataArray) {
- switch (model.Type) {
- case CollectDataType_Text:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:dict];
- }
- break;
- case CollectDataType_IMG:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":@"",
- @"Type":@(CollectDataType_IMG),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_File:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_File),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Collect:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Collect),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Note:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Note),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_NoteFile:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_NoteFile),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_CollectFile:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_CollectFile),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Group:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Group),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Topic:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Topic),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Notice:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Notice),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_InterMail:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_InterMail),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Meeting:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Meeting),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Article:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Article),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Approval:
- {
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Approval),
- @"Author":model.Author,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.Text.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.Text,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- default:
- break;
- }
- }
- NSMutableDictionary * dic = [NSMutableDictionary dictionary];
- [dic setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setObject:[self arrayToJSONString:array] forKey:@"Content"];
- [dic setValue:self.textView.text forKey:@"Title"];
- if (self.isEdit) {
- [dic setValue:@(self.interLeterId) forKey:@"Id"];
- }
- [dic setValue:@(NoticeType) forKey:@"MissiveType"];
- [dic setValue:@(address) forKey:@"MissiveAttributeType"];
- switch (self.interLeterHanderType) {
- case InterLeterHanderType_Create:{
- [dic setValue:@(0) forKey:@"ParentId"];
- }break;
- case InterLeterHanderType_Modify:{
- [dic setValue:@(0) forKey:@"ParentId"];
- }case InterLeterHanderType_Replay:{
- [dic setValue:@(self.replayId) forKey:@"ParentId"];
- }
- default:
- break;
- }
-
- [dic setValue:@(0) forKey:@"FolderId"];
- // 收集收件人ID数组
- NSMutableArray *array1 = [NSMutableArray array];
- for (SelectModel *model in self.shouJianArray) {
- NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName};
- [array1 addObject:param];
- }
- [dic setValue:array1 forKey:@"AddresseeUserMiddles"];
-
- // 收集抄送人ID数组
- NSMutableArray *array2 = [NSMutableArray array];
- for (SelectModel *model in self.chaoShongArray) {
- NSDictionary *param = @{@"MiddleType":@"1",@"SourceType":@(model.SourceType),@"SourceId":@(model.SourceId),@"SourceName":model.SourceName};
- [array2 addObject:param];
- }
- [dic setValue:array2 forKey:@"CcUserMiddles"];
- NSLog(@"请求参数%@",dic);
- [self sentNoticeRequeast:dic withNoticeType:NoticeType];
- }
- - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
- WS(weakSelf);
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if(NoticeType == 1){
- SHOWSUCCESS(@"站内信已经发送");
- }else{
- SHOWSUCCESS(@"站内信已经存放草稿箱");
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (NSString *)arrayToJSONString:(NSArray *)array
- {
- NSError *error = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
- return jsonString;
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- #pragma mark - SmartBarDelegate
- - (void)didSelectBarWithType:(SmartBarType)type
- {
- WS(weakSelf);
- switch (type) {
- case SmartBarPhoto:
- {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
- } choosImgBlock:^(UIImage *image) {
- [weakSelf didSelectImage:image];
- }];
- }
- break;
- case SmartBarCamera:
- {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
- } choosImgBlock:^(UIImage *image) {
- [weakSelf didSelectImage:image];
- }];
- }
- break;
- case SmartBarNotes:
- {
- [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
- NSLog(@"SmartBarNotes %@",noteArr);
- [weakSelf disSelectNoteBook:noteArr];
- }];
- }
- break;
- case SmartBarCollection:
- {
- [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
- NSLog(@"SmartBarCollection %@",collectArr);
- [weakSelf disSelectCollect:collectArr];
- }];
- }
- break;
- case SmartBarFile:
- {
- WS(weakSelf);
- [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
-
- } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
- REMOVESHOW
- NSLog(@"上传成功的文件%@",responseObject);
- [weakSelf fileSizeWithData:fileData withDict:responseObject[0] withName:fileName];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }];
- }
- break;
- default:
- break;
- }
- }
- - (void)fileSizeWithData:(NSData *)fileData withDict:(NSDictionary *)dict withName:(NSString *)fileName
- {
- unsigned long long size = [fileData length];
- NSString * fileZise;
- if (size >= pow(10, 9)) { // size >= 1GB
- fileZise = [NSString stringWithFormat:@"%.2fGB", size / pow(10, 9)];
- } else if (size >= pow(10, 6)) { // 1GB > size >= 1MB
- fileZise = [NSString stringWithFormat:@"%.2fMB", size / pow(10, 6)];
- } else if (size >= pow(10, 3)) { // 1MB > size >= 1KB
- fileZise = [NSString stringWithFormat:@"%.2fKB", size / pow(10, 3)];
- } else { // 1KB > size
- fileZise = [NSString stringWithFormat:@"%lluB", size];
- }
- [self didSelectFile:dict withSize:fileZise withName:fileName];
- }
- - (void)didSelectImage:(UIImage *)image
- {
- WS(weakSelf);
- NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
- [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:@[UIImageJPEGRepresentation(image,1.0f)] pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- NSDictionary * dict = responseObject[0];
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.PlaceText = @"编辑内容";
- model.Content = @"";
- model.ImageUrl = dict[@"AbsolutePath"];
- model.FileId = [dict[@"FileId"] integerValue];
- model.FileName = dict[@"FileName"];
- model.Type = CollectDataType_IMG;
- CGFloat imgH = (SCREEN_WIDTH - 30) * 0.5 + 101.f;
- model.Height = imgH;
- [weakSelf.dataArray addObject:model];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadSection:0 withRowAnimation:UITableViewRowAnimationNone];
- if (weakSelf.tableView.contentOffset.y > SCREEN_HEIGHT) {
- [weakSelf.tableView performSelector:@selector(scrollToBottom) withObject:nil afterDelay:0.1];
- }
- });
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)didSelectFile:(NSDictionary *)dict withSize:(NSString *)fileSize withName:(NSString *)fileName
- {
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.Title = @"";
- model.Content = @"";
- if ([dict[@"AbsolutePath"] length] == 0) {
- if ([fileName hasSuffix:@".doc"]) {
- model.File = @"icon_word";
- }else if([fileName hasSuffix:@".xls"]){
- model.File = @"icon_excel";
- }else if([fileName hasSuffix:@".ppt"]){
- model.File = @"icon_ppt";
- }else if([fileName hasSuffix:@".pdf"]){
- model.File = @"icon_pdf";
- }else if([fileName hasSuffix:@".zip"]){
- model.File = @"icon_yasuowenjian";
- }else if([fileName hasSuffix:@".psd"]){
- model.File = @"icon_psd";
- }else if([fileName hasSuffix:@".ai"]){
- model.File = @"icon_ai";
- }else if([fileName hasSuffix:@".txt"]){
- model.File = @"icon_txt";
- }else if([fileName hasSuffix:@".html"]){
- model.File = @"icon_html";
- }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"]){
- model.File = dict[@"AbsolutePath"];
- }else{
- model.File = @"icon_weizhiwenjian";
- }
- }
- model.FileId = [dict[@"FileId"] integerValue];
- model.FileName = dict[@"FileName"];
- model.Type = CollectDataType_File;
- model.Height = 175.f;
- model.FileSize = fileSize;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }
- - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
- for (MyNoteBookSubModel *dataModel in noteArr ) {
- if (dataModel.AttributeValue == 1) {
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.Id = dataModel.MiddleId;
- model.FileId = dataModel.MiddleId;
- model.ImageUrl = dataModel.AvatarUrl;
- model.Author = dataModel.Name;
- model.FileName = dataModel.Title;
- model.Type = CollectDataType_Note;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }else{
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.Id = dataModel.Id;
- model.FileId = dataModel.Id;
- model.ImageUrl = dataModel.AvatarUrl;
- model.Author = [AppUserModel sharedAppUserModel].Name;
- model.FileName = dataModel.FolderName;
- model.Type = CollectDataType_NoteFile;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- }); }
- }
- }
- - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
- for (MyFavoriteSubModel *dataModel in collectArr ) {
- if(dataModel.AttributeValue == 1)
- {
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.Id = dataModel.CollectionDataId;
- model.FileId = dataModel.CollectionDataId;
- model.ImageUrl = dataModel.Data.AvatarUrl;
- model.Author = dataModel.Data.Author;
- model.FileName = dataModel.Title;
- model.Type = [ZYCTool returnDataType:dataModel.CollectionType];
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }else{
- CreateInterLeterModel * model = [[CreateInterLeterModel alloc] init];
- model.Id = dataModel.Id;
- model.FileId = dataModel.Id;
- model.ImageUrl = dataModel.Data.AvatarUrl;
- model.Author = [AppUserModel sharedAppUserModel].Name;
- model.FileName = dataModel.FolderName;
- model.Type = CollectDataType_CollectFile;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }
- }
-
- }
- - (void)didSelectBarKeyBtnIsShow:(BOOL)isShow
- {
- [self.view endEditing:YES];
- }
- - (void)didSelectBarAddBtnIsShow:(BOOL)isShow;{
- [self.view endEditing:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [[IQKeyboardManager sharedManager] setEnable:NO];
- WS(weakSelf);
- [self.view endEditing:YES];
- [self.SmartBar downBar];
- [self.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- }
- - (shoujianrenResultView *)resultView {
- if (!_resultView) {
- _resultView = [shoujianrenResultView new];
- }
- return _resultView;
- }
- - (NSString *)getFileNameImage:(NSString *)fileName
- {
- if ([fileName hasPrefix:@".doc"]) {
- return @"icon_word";
- }else if([fileName hasPrefix:@".xls"]){
- return @"icon_excel";
- }else if([fileName hasPrefix:@".ppt"]){
- return @"icon_ppt";
- }else if([fileName hasPrefix:@".pdf"]){
- return @"icon_pdf";
- }else if([fileName hasPrefix:@".zip"]){
- return @"icon_yasuowenjian";
- }else if([fileName hasPrefix:@".psd"]){
- return @"icon_psd";
- }else if([fileName hasPrefix:@".ai"]){
- return @"icon_ai";
- }else if([fileName hasPrefix:@".txt"]){
- return @"icon_txt";
- }else if([fileName hasPrefix:@".html"]){
- return @"icon_html";
- }else{
- return @"icon_weizhiwenjian";
- }
- }
- @end
|