123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797 |
- //
- // WorkFlowOrderController.m
- // smartRhino
- //
- // Created by Android on 2019/12/19.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "WorkFlowOrderController.h"
- #import "InPutGongWenCell.h"
- #import "AddPictureCell.h"
- #import "AddPeopleToGongWenCell.h"
- #import "WorkFlowOrderCell.h"
- #import "TimeSourceModel.h"
- #import "NSDate+JKExtension.h"
- #import "WorkFlowOrderModel.h"
- #import "WorkFlowOrderInputCell.h"
- #import "LYLPhotoTailoringTool.h"
- #import "FWZFileGetTool.h"
- #import "AddLookUpUserSecondVC.h"
- #import "SelectedTimeModel.h"
- #import "DownFileViewController.h"
- #import "FWZGetNoteBookTool.h"
- #import "SelectedTimeSourceModel.h"
- @interface WorkFlowOrderController ()<UITableViewDelegate,
- UITableViewDataSource,
- UITextFieldDelegate,
- UITextViewDelegate,
- UINavigationControllerDelegate,
- UIImagePickerControllerDelegate,
- AddPictureCellDelegate,
- AddPeopleToGongWenCellDelegate,AddLookUpUserSecondVCDelegate>
- {
-
- }
- @property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
- @property (weak, nonatomic) IBOutlet UILabel *titleLbl;
- @property (strong, nonatomic) NSArray *timeDataSource;
- @property (assign, nonatomic) CGFloat orderCellHeight;
- @property (strong, nonatomic) NSArray *selectedTimeSource;
- @property (strong, nonatomic) NSArray *selectedTimeList;
- @property (strong, nonatomic) NSMutableArray * timeList;
- @property (strong, nonatomic) NSMutableArray * timeSource;
- @property (strong, nonatomic) WorkFlowOrderModel *orderModel;
- @property (strong, nonatomic) NSMutableArray *fileSource;
- @property (nonatomic, strong) NSMutableArray *chaoSongRenArr;
- @property (nonatomic, strong) NSString * titleStr;
- @property (nonatomic, strong) NSString * contentStr;
- @property (assign, nonatomic) NSInteger refreshCount;
- @end
- @implementation WorkFlowOrderController
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (instancetype)initWithRID:(NSString *)rid {
- if (self = [super init]) {
- self.rid = rid;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- NSLog(@"%@",self.meetingModel.Orders);
- [self registerNotification];
- self.refreshCount = 0;
- self.confirmBtn.clipsToBounds = YES;
- self.confirmBtn.layer.cornerRadius = 5.f;
- self.view.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
- self.fd_prefersNavigationBarHidden = YES;
- self.infoTabView.dataSource = self;
- self.infoTabView.delegate = self;
- self.infoTabView.tableFooterView = [UIView new];
- self.infoTabView.separatorStyle=UITableViewCellSeparatorStyleNone;
- self.infoTabView.separatorColor = [UIColor colorWithHexString:@"EEEEEE"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderTopCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderTopCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderInputCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderInputCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"AddPictureCell" bundle:nil] forCellReuseIdentifier:@"AddPictureCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"AddPeopleToGongWenCell" bundle:nil] forCellReuseIdentifier:@"AddPeopleToGongWenCell"];
- [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderSelectedTimeCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderSelectedTimeCell"];
- if (self.isEdit) {
- [self.infoTabView.mj_header endRefreshing];
- [self.infoTabView.mj_footer endRefreshing];
- self.titleLbl.text = self.meetingModel.MeetingRoom[@"Name"];
- for (NSDictionary * dict in self.meetingModel.MeetingUserResults) {
- SelectModel * model = [[SelectModel alloc] init];
- model.UserId = [dict[@"Id"] integerValue];
- model.UserName = dict[@"Name"];
- model.Id = [dict[@"Id"] integerValue];
- model.Name = dict[@"Name"];
- model.AvatarUrl = dict[@"AvatarUrl"];
- [self.chaoSongRenArr addObject:model];
- }
- for (NSDictionary * dict in self.meetingModel.FlowAttachments) {
- FlowAttachmentsModel * model = [FlowAttachmentsModel modelWithDictionary:dict];
- [self.fileSource addObject:model];
- }
- for (TimeSourceModel * model in self.timeDataSource) {
- for (NSDictionary * dict in self.meetingModel.OrderList) {
- if ([dict[@"TimeKey"] integerValue] == [model.notSignDate integerValue]) {
- for (id value in dict[@"TimeValues"]) {
- NSIndexPath * indexPath = [NSIndexPath indexPathForItem:([value integerValue] - 7) inSection:0];
- [self addSelectedTimeWithDate:model time:[self oneTimeToTwoTime:[value integerValue]] indexPath:indexPath];
- }
- }
- }
- }
- self.titleStr = self.meetingModel.Name;
- [self.infoTabView reloadData];
- }else{
- self.titleLbl.text = self.mettingTitle;
- self.titleStr = @"";
- [self getData];
- }
- }
- - (NSArray *)getMonthDate
- {
- //获取日期格式化对象
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- //获取当前完整日期
- NSString *today = [dateFormatter stringFromDate:[NSDate date]];
- //获取当天日期号
- NSString *day = [[today componentsSeparatedByString:@"-"] lastObject];
- //记住当前时间戳
- long long times = [NSDate date].timeIntervalSince1970;
- TimeSourceModel *sourceModel = [[TimeSourceModel alloc] init];
- sourceModel.timeDate = today;
- sourceModel.timeWeek = [[NSDate date] jk_dayFromWeekday];
- //创建日期接纳数组、将当天传进去
- NSMutableArray *marray = [NSMutableArray arrayWithObject:sourceModel];
- //循环遍历、一个月最大31天,所以i<32
- for (int i = 0; i < 32; i++) {
- //从今天的时间戳加 每回加一天
- times += 24 * 60 * 60;
- // NSDateFormatter *strDateFormatter = [[NSDateFormatter alloc] init];
- // [strDateFormatter setDateFormat:@"MM月dd日"];
- // NSString *dataDate = [strDateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:times]];
- //获取出完整日期
- NSString *dateStr = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:times]];
- //获取单独日期
- NSString *tempDay = [[dateStr componentsSeparatedByString:@"-"] lastObject];
- TimeSourceModel *sourceModel = [[TimeSourceModel alloc] init];
- sourceModel.timeDate = dateStr;
- sourceModel.timeWeek = [[NSDate dateWithTimeIntervalSince1970:times] jk_dayFromWeekday];
- //加入数组
- [marray addObject:sourceModel];
- //比较日期相同季结束循环 如从 2019-07-01 到 2019-08-01结束循环
- if ([tempDay isEqualToString:day]) {
- break;
- }
- }
- return marray;
- }
- #pragma mark - reloaddata
- - (void)getData {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%@/%@",BaseUrl,MeetingList,self.rid] parameters:@{} success:^(id _Nonnull responseObject) {
- [weakSelf.infoTabView.mj_header endRefreshing];
- [weakSelf.infoTabView.mj_header removeFromSuperview];
- weakSelf.orderModel = [WorkFlowOrderModel modelWithDictionary:responseObject];
- [weakSelf.infoTabView reloadData];
- NSLog(@"获取的数据:%@",responseObject);
- } failure:^(NSError * _Nonnull error) {
- [weakSelf.infoTabView.mj_header endRefreshing];
- [weakSelf.infoTabView.mj_header removeFromSuperview];
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - table delegate
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if ([cell respondsToSelector:@selector(setSeparatorInset:)])
- {
- [cell setSeparatorInset:UIEdgeInsetsZero];
- }
- if ([cell respondsToSelector:@selector(setLayoutMargins:)])
- {
- [cell setLayoutMargins:UIEdgeInsetsZero];
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 45.f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 0) {
- return 35.f;
- }else if (indexPath.section == 1) {
- return 476.f;
- }else if (indexPath.section == 2) {
- self.orderCellHeight = self.selectedTimeSource.count * (20 + 3) + 30.f;
- if (self.orderCellHeight < 50.f) {
- return 50.f;
- }
- return self.orderCellHeight;
- } else {
- if (indexPath.row == 0) {
- return 45.f;
- }else if(indexPath.row == 1){
- return UITableViewAutomaticDimension;
- }
- return 140.f;
- }
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 4;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 3) {
- return 4;
- }
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 0.1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- if (section == 1) {
- return 0.1f;
- }
- return 20.f;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- WS(weakSelf);
- TDTableViewCell *cell;
- if (indexPath.section == 0) {
- cell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderTopCell" forIndexPath:indexPath];
- }else if (indexPath.section == 1) {
- WorkFlowOrderCell *orderCell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderCell" forIndexPath:indexPath];
- if (!orderCell) {
- orderCell = [[WorkFlowOrderCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"WorkFlowOrderCell"];
- }
- orderCell.selectedTimeDataSource = [NSMutableArray arrayWithArray:self.selectedTimeSource];
- orderCell.selectedTimeList = [NSMutableArray arrayWithArray:self.selectedTimeList];
- if (self.isEdit) {
- if (self.refreshCount < 1) {
- [orderCell setCellData:self.timeDataSource orderAll:self.meetingModel.OrderAllList order:self.meetingModel.OrderList];
- [orderCell CollectionReloadData];
- self.refreshCount ++;
- }
- }else{
- if (self.refreshCount < 2) {
- [orderCell setCellData:self.timeDataSource orderAll:self.orderModel.OrderList order:@[]];
- [orderCell CollectionReloadData];
- self.refreshCount ++;
- }
- }
- orderCell.upDataBlock = ^(NSArray * _Nonnull listArray) {
- weakSelf.meetingModel.OrderList = listArray;
- dispatch_async(dispatch_get_main_queue(), ^{
- NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:1];
- [weakSelf.infoTabView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
- });
- };
- [orderCell setSelectedTimeBlock:^(NSArray * _Nonnull selecteds,NSArray * _Nonnull timeList) {
- weakSelf.selectedTimeSource = selecteds;
- weakSelf.selectedTimeList = timeList;
- dispatch_async(dispatch_get_main_queue(), ^{
- NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:2];
- [weakSelf.infoTabView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
- });
- }];
- cell = orderCell;
- }else if (indexPath.section == 2) {
- cell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderSelectedTimeCell" forIndexPath:indexPath];
- [cell setCellData:self.selectedTimeSource];
- }else {
- if (indexPath.row == 0) {
- WorkFlowOrderInputCell *inputCell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderInputCell" forIndexPath:indexPath];
- [inputCell.inputTxt addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- inputCell.inputTxt.returnKeyType = UIReturnKeyDone;
- inputCell.inputTxt.delegate = self;
- if (self.isEdit) {
- inputCell.inputTxt.text = self.meetingModel.Name;
- }
- [inputCell setCellData:self.orderModel.title line:YES];
- cell = inputCell;
- }else if (indexPath.row == 1) {
- InPutGongWenCell *inPutGongWenCell = [tableView dequeueReusableCellWithIdentifier:@"InPutGongWenCell" forIndexPath:indexPath];
- inPutGongWenCell.namelab.text = @"会议描述";
- if (self.isEdit) {
- inPutGongWenCell.gongwenContent.text = self.meetingModel.Description;
- }
- inPutGongWenCell.haveNeedImageView.hidden = YES;
- inPutGongWenCell.gongwenContent.delegate = self;
- inPutGongWenCell.gongwenContent.tag = indexPath.section;
- cell = inPutGongWenCell;
- }else if (indexPath.row == 2) {
- AddPictureCell *addPictureCell = [tableView dequeueReusableCellWithIdentifier:@"AddPictureCell" forIndexPath:indexPath];
- addPictureCell.namelab.text = @"上传附件";
- addPictureCell.haveNeedImageView.hidden = YES;
- addPictureCell.approvalSection = self.fileSource;
- addPictureCell.delegate = self;
- addPictureCell.index = indexPath;
- addPictureCell.ClickCellBlock = ^(NSInteger index) {
- FlowAttachmentsModel * imgModel = weakSelf.fileSource[index];
- DownFileViewController *vc = [[DownFileViewController alloc]init];
- vc.model = imgModel;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- };
- cell = addPictureCell;
- }else {
- AddPeopleToGongWenCell *addPeopleToGongWenCell = [tableView dequeueReusableCellWithIdentifier:@"AddPeopleToGongWenCell" forIndexPath:indexPath];
- addPeopleToGongWenCell.namelab.text = @"参会人员";
- addPeopleToGongWenCell.haveNeedImageView.hidden = YES;
- addPeopleToGongWenCell.delegate = self;
- addPeopleToGongWenCell.approvalSection = self.chaoSongRenArr;
- cell = addPeopleToGongWenCell;
- }
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- #pragma mark - textfile / textviewdelegate
- - (void)textViewDidChange:(UITextView *)textView{
- self.contentStr = textView.text;
- NSArray * cells = [self.infoTabView visibleCells];
- for (UITableViewCell * cell in cells) {
- if ([cell isKindOfClass:[InPutGongWenCell class]]) {
- InPutGongWenCell * inCell = (InPutGongWenCell *)cell;
- inCell.bgL.text = textView.text;
- [self.infoTabView beginUpdates];
- [self.infoTabView endUpdates];
- }
- }
- }
- - (void)textFieldDidChange:(UITextField *)textField {
- self.titleStr = textField.text;
- }
- #pragma mark - AddPictureCellDelegate
- - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- WEAKSELF
- [self addFile:index Sucuss:^(id _Nullable responseObject) {
- STRONGSELF
- AddPictureCell *cell = [strongSelf.infoTabView cellForRowAtIndexPath:index];
- if ([responseObject isKindOfClass:[NSArray class]]) {
- [strongSelf.fileSource addObjectsFromArray:responseObject];
- }else {
- [strongSelf.fileSource addObject:responseObject];
- }
- [cell.mycollectionView reloadData];
- REMOVESHOW;
- } failure:^(NSError * _Nonnull error ) {
- REMOVESHOW;
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- WS(weakSelf);
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
- picker.delegate = self;
- picker.allowsEditing = YES;//取消白框
- UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- } choosImgBlock:^(UIImage *image) {
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSDictionary *dict = responseObject[0];
- FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc]init];
- model.SoureId = [dict[@"FileId"] integerValue];
- model.SoureTypeId = CollectModel_file;
- model.Url = dict[@"AbsolutePath"];
- model.MinUrl = dict[@"MinAbsolutePath"];
- model.Title = dict[@"FileName"];
- model.Size = [dict[@"Size"] integerValue];
- success(model);
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action1];
- UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self.view endEditing:YES];
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil];
- [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
- leftButton.hidden = YES;
- }];
- imagePickerVc.showSelectBtn = NO;
- imagePickerVc.allowCrop = YES;
- imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
- imagePickerVc.allowTakePicture = NO;
- imagePickerVc.allowTakeVideo = NO;
- [imagePickerVc setIsStatusBarDefault:YES];
- [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
- [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- PHAsset *asset = assets.firstObject;
- switch (asset.mediaType) {
- case PHAssetMediaTypeVideo: {
- } break;
- case PHAssetMediaTypeImage: {
- [self didSelectImages:photos success:success withImgs:photos];
- } break;
- case PHAssetMediaTypeAudio:
- break;
- case PHAssetMediaTypeUnknown:
- break;
- default: break;
- }
- }];
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }];
- [alertvc addAction:action2];
- [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[FWZGetNoteBookTool sharedTool] WorkOpenCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
- NSLog(@"SmartBarCollection %@",collectArr);
- NSArray * array = [weakSelf disSelectCollect:collectArr];
- success(array);
- }];
- }];
- [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action3];
- UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[FWZGetNoteBookTool sharedTool] WorkOpenNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
- NSLog(@"SmartBarNotes %@",noteArr);
- NSArray * array = [weakSelf disSelectNoteBook:noteArr];
- success(array);
- }];
- }];
- [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action4];
- UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
- } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
- NSLog(@"%@",fileName);
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
- NSLog(@"上传成功的文件%@",responseObject);
- NSDictionary *dict = responseObject[0];
- FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc] initWithDictionary:dict error:nil];
- model.SoureTypeId = CollectModel_file;
- model.SoureId = [dict[@"FileId"] integerValue];
- model.Url = dict[@"AbsolutePath"];
- model.MinUrl = dict[@"MinAbsolutePath"];
- model.Title = dict[@"FileName"];
- model.Size = [dict[@"Size"] integerValue];
- success(model);
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action5];
- UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- }];
- [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action6];
- [self presentViewController:alertvc animated:YES completion:^{}];
- }
- #pragma mark - addNote
- - (NSArray *)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
- NSMutableArray * array = [NSMutableArray array];
- for (MyNoteBookSubModel *dataModel in noteArr ) {
- if (dataModel.AttributeValue == 1) {
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = dataModel.MiddleId;
- model.Url = dataModel.AvatarUrl;
- model.Author = dataModel.Name;
- model.Title = dataModel.Title;
- model.SoureTypeId = CollectModel_NoteBook;
- [array addObject:model];
- }
- }
- return array;
- }
- #pragma mark - addCollect
- - (NSArray *)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
- NSMutableArray * array = [NSMutableArray array];
- for (MyFavoriteSubModel *dataModel in collectArr ) {
- if(dataModel.AttributeValue == 1)
- {
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = dataModel.CollectionDataId;
- model.Url = dataModel.Data.File;
- model.Size = dataModel.Data.FileSize;
- model.Author = dataModel.Data.Author;
- model.Title = dataModel.Title;
- model.MinUrl = dataModel.Data.MinFile;
- model.SoureTypeId = dataModel.CollectionType;
- [array addObject:model];
- }
- }
- return array;
- }
- // 多张图片上传
- - (void)didSelectImages:(NSArray<UIImage *> *)images success:(void (^) (id _Nullable))successfulk withImgs:(NSArray *)imgs {
- NSMutableArray *imageArr = [NSMutableArray array];
- for (UIImage *image in images) {
- [imageArr addObject:UIImageJPEGRepresentation(image,1.0f)];
- }
- SHOWLOADING
- NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
- [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:[imageArr copy] pictureKey:@"file" success:^(id _Nonnull responseObject) {
- REMOVESHOW
- NSLog(@"%@",responseObject);
- NSMutableArray * array = [NSMutableArray array];
- for (NSDictionary * dict in responseObject) {
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = [dict[@"FileId"] integerValue];
- model.SoureTypeId = CollectModel_file;
- model.Url = dict[@"AbsolutePath"];
- model.MinUrl = dict[@"MinAbsolutePath"];
- model.Title = dict[@"FileName"];
- model.Size = [dict[@"Size"] integerValue];
- [array addObject:model];
- }
- successfulk(array);
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate
- - (void)addLookUpPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- NSLog(@"点击添加抄送人");
- Department *defaltGroupSetion = [[Department alloc]init];
- defaltGroupSetion.Name = @"单位通讯录";
- defaltGroupSetion.Id = 0;
- Department *myGroupSetion = [[Department alloc]init];
- myGroupSetion.Name = @"自建通讯录";
- defaltGroupSetion.Id = 0;
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
- vc.isAllSelected = NO;
- vc.notSearchChangeColor = YES;
- vc.titleStr = @"选人";
- vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
- vc.isDefalutPage = 1;
- vc.isShow = NO;
- NSMutableArray * userArray = [NSMutableArray array];
- for (SelectModel * model in self.chaoSongRenArr) {
- [userArray addObject:@(model.UserId)];
- }
- [userArray addObject:@([AppUserModel sharedAppUserModel].Id)];
- vc.UserIds = userArray;
- vc.delegate = self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - 注册通知 接受抄送人和审批人数据
- - (void)registerNotification{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
- }
- - (void)recviveChaoSongRen:(NSNotification *)notification{
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
- [self.chaoSongRenArr addObjectsFromArray:array];
- [self.infoTabView reloadRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:3] withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- #pragma mark - private
- - (IBAction)orderBtn_Click:(id)sender {
- //判断是否选择时间
- if (self.selectedTimeList.count == 0) {
- SHOWERROR(@"请选择会议时间");
- return;
- }
- //是否输入标题
- if (self.titleStr.length < 1) {
- SHOWERROR(@"请输入标题");
- return;
- }
- // //是否输入内容
- // if (self.orderModel.content.length < 1) {
- // SHOWERROR(@"请输入会议描述");
- // return;
- // }
- // //是否选择参会人员
- // if (self.chaoSongRenArr.count < 1) {
- // SHOWERROR(@"请选择参会人员");
- // return;
- // }
- //组成请求参数
- NSInteger meetId = 0;
- if (self.meetingModel.Id.length > 0) {
- meetId = [self.meetingModel.Id integerValue];
- }
- NSDictionary *requestParam = @{@"Orders": [self createSelectedTimeParam],
- @"Name":self.titleStr,
- @"Description":self.contentStr.length > 0 ? self.contentStr : @"",
- @"flowAttachments":[self createFileIDParam],
- @"UserIds":[self createUserIDParam],
- @"MeetingId":@(meetId),
- @"FileIds":@[]
- };
- SHOWLOADING
- NSString * roomId = self.rid;
- if (self.isEdit) {
- roomId = [NSString stringWithFormat:@"%ld",(long)[self.meetingModel.MeetingRoom[@"Id"] integerValue]];
- }
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTWithUrl:Host(ActionMeeting(roomId)) parameters:requestParam success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if (weakSelf.isEdit) {
- SHOWSUCCESS(@"修改成功");
- if (weakSelf.ChangeSuccessBlock) {
- weakSelf.ChangeSuccessBlock();
- }
- }else{
- SHOWSUCCESS(@"预订成功");
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (NSArray *)createSelectedTimeParam {
- NSMutableArray *times = [[NSMutableArray alloc] initWithCapacity:self.selectedTimeList.count];
- for (SelectedTimeModel *timeModel in self.selectedTimeList) {
- NSString *timeStr = [NSString stringWithFormat:@"%@ %@:00",timeModel.yearAndMonthAndDay,timeModel.time];
- [times addObject:timeStr];
- }
- return times;
- }
- - (NSArray *)createFileIDParam {
- NSMutableArray *fileid = [[NSMutableArray alloc] initWithCapacity:self.fileSource.count];
- for (FlowAttachmentsModel *model in self.fileSource) {
- NSDictionary * AttachmentDict = @{@"SoureId":@(model.SoureId),
- @"Url":model.Url,
- @"Title":model.Title,
- @"SoureTypeId":@(model.SoureTypeId),
- @"Size":@(model.Size),
- };
- [fileid addObject:AttachmentDict];
- }
- return fileid;
- }
- - (NSArray *)createUserIDParam {
- NSMutableArray *userId = [[NSMutableArray alloc] initWithCapacity:self.chaoSongRenArr.count];
- for (SelectModel *userModel in self.chaoSongRenArr) {
- [userId addObject:[NSString stringWithFormat:@"%ld",(long)userModel.UserId]];
- }
- return userId;
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
- [textField resignFirstResponder];
- return YES;
- }
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- }
- #pragma mark - get/set
- - (NSMutableArray *)fileSource {
- if (!_fileSource) {
- _fileSource = [[NSMutableArray alloc] init];
- }
- return _fileSource;
- }
- - (NSMutableArray *)chaoSongRenArr{
- if (!_chaoSongRenArr) {
- _chaoSongRenArr = [NSMutableArray array];
- }
- return _chaoSongRenArr;
- }
- - (NSMutableArray *)timeList{
- if (!_timeList) {
- _timeList = [NSMutableArray array];
- }
- return _timeList;
- }
- - (NSMutableArray *)timeSource{
- if (!_timeSource) {
- _timeSource = [NSMutableArray array];
- }
- return _timeSource;
- }
- - (NSArray *)timeDataSource {
- if (!_timeDataSource) {
- _timeDataSource = [self getMonthDate];
- }
- return _timeDataSource;
- }
- - (CGFloat)orderCellHeight {
- if (_orderCellHeight < 50.f ) {
- return 50.f;
- }
- return _orderCellHeight;
- }
- -(void)addSelectedTimeWithDate:(TimeSourceModel *)date time:(NSString *)time indexPath:(NSIndexPath *)indexPath{
- SelectedTimeModel *timeModel = [[SelectedTimeModel alloc] init];
- timeModel.date = date.timeDate;
- timeModel.yearAndMonthAndDay = date.monthAndDay;
- timeModel.yearAndMonthAndDay = date.timeDate;
- timeModel.time = time;
- timeModel.indexPath = indexPath;
- [self.timeList addObject:timeModel];
- [self screenTime];
- }
- - (void)screenTime {
- //循环每天日期是否有预约的会议
- [self.timeSource removeAllObjects];
- for (TimeSourceModel *time in self.timeDataSource) {
- //判断选中集合当中是否有预约这一天的会议
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date == %@", time.timeDate];
- NSArray *filteredArray = [self.timeList filteredArrayUsingPredicate:predicate];
- if (filteredArray.count > 0) { //有此日期的预约会议
- NSArray *sortArray = [filteredArray sortedArrayUsingSelector:@selector(compareIndex:)];
- //第一个选择的时间
- SelectedTimeModel *firstObject = [sortArray firstObject];
- //第一个出现的index
- __block NSInteger index = firstObject.indexPath.item;
- //创建时间模型
- __block SelectedTimeSourceModel *timeModel = [[SelectedTimeSourceModel alloc] init];
- timeModel.dateTime = time.timeWeek;
- timeModel.yearAndMonthAndDayTime = time.timeDate;
- timeModel.beginTime = firstObject.time;
- //如果只有一个的情况下
- if (sortArray.count == 1) {
- //将上一个添加到数组中
- [self.timeSource addObject:timeModel];
- continue;
- }
- //循环数组找和index连续的时间
- [sortArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- if (idx > 0) {
- SelectedTimeModel *tmpTimeModel = obj;
- //是否和第一个相差1
- if ((tmpTimeModel.indexPath.item - index) == 1) {
- //记录结束时间
- timeModel.endTime = tmpTimeModel.time;
- }else {
- //将上一个添加到数组中
- [self.timeSource addObject:timeModel];
- //重新创建一个时间模型
- timeModel = [[SelectedTimeSourceModel alloc] init];
- timeModel.yearAndMonthAndDayTime = time.timeDate;
- timeModel.dateTime = time.timeWeek;
- timeModel.beginTime = tmpTimeModel.time;
- }
- if (idx == (sortArray.count - 1)) {
- //如果是最后一个也需要将时间添加到数组中
- [self.timeSource addObject:timeModel];
- }
- //重新计算index
- index = tmpTimeModel.indexPath.item;
- }
- }];
- }
- }
- if (self.timeList.count > 0) {
- self.selectedTimeSource = self.timeSource;
- self.selectedTimeList = self.timeList;
- }
- }
- - (NSString *)oneTimeToTwoTime:(NSInteger)time;
- {
- NSString * reTime = @"";
- if (time < 10) {
- reTime = [NSString stringWithFormat:@"0%ld:00",time];
- }else{
- reTime = [NSString stringWithFormat:@"%ld:00",time];
- }
- return reTime;
- }
- @end
|