WorkFlowOrderController.m 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. //
  2. // WorkFlowOrderController.m
  3. // smartRhino
  4. //
  5. // Created by Android on 2019/12/19.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "WorkFlowOrderController.h"
  9. #import "InPutGongWenCell.h"
  10. #import "AddPictureCell.h"
  11. #import "AddPeopleToGongWenCell.h"
  12. #import "WorkFlowOrderCell.h"
  13. #import "TimeSourceModel.h"
  14. #import "NSDate+JKExtension.h"
  15. #import "WorkFlowOrderModel.h"
  16. #import "WorkFlowOrderInputCell.h"
  17. #import "LYLPhotoTailoringTool.h"
  18. #import "FWZFileGetTool.h"
  19. #import "AddLookUpUserSecondVC.h"
  20. #import "SelectedTimeModel.h"
  21. #import "DownFileViewController.h"
  22. #import "FWZGetNoteBookTool.h"
  23. #import "SelectedTimeSourceModel.h"
  24. @interface WorkFlowOrderController ()<UITableViewDelegate,
  25. UITableViewDataSource,
  26. UITextFieldDelegate,
  27. UITextViewDelegate,
  28. UINavigationControllerDelegate,
  29. UIImagePickerControllerDelegate,
  30. AddPictureCellDelegate,
  31. AddPeopleToGongWenCellDelegate,AddLookUpUserSecondVCDelegate>
  32. {
  33. }
  34. @property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
  35. @property (weak, nonatomic) IBOutlet UILabel *titleLbl;
  36. @property (strong, nonatomic) NSArray *timeDataSource;
  37. @property (assign, nonatomic) CGFloat orderCellHeight;
  38. @property (strong, nonatomic) NSArray *selectedTimeSource;
  39. @property (strong, nonatomic) NSArray *selectedTimeList;
  40. @property (strong, nonatomic) NSMutableArray * timeList;
  41. @property (strong, nonatomic) NSMutableArray * timeSource;
  42. @property (strong, nonatomic) WorkFlowOrderModel *orderModel;
  43. @property (strong, nonatomic) NSMutableArray *fileSource;
  44. @property (nonatomic, strong) NSMutableArray *chaoSongRenArr;
  45. @property (nonatomic, strong) NSString * titleStr;
  46. @property (nonatomic, strong) NSString * contentStr;
  47. @property (assign, nonatomic) NSInteger refreshCount;
  48. @end
  49. @implementation WorkFlowOrderController
  50. - (void)dealloc {
  51. [[NSNotificationCenter defaultCenter] removeObserver:self];
  52. }
  53. - (instancetype)initWithRID:(NSString *)rid {
  54. if (self = [super init]) {
  55. self.rid = rid;
  56. }
  57. return self;
  58. }
  59. - (void)viewDidLoad {
  60. [super viewDidLoad];
  61. NSLog(@"%@",self.meetingModel.Orders);
  62. [self registerNotification];
  63. self.refreshCount = 0;
  64. self.confirmBtn.clipsToBounds = YES;
  65. self.confirmBtn.layer.cornerRadius = 5.f;
  66. self.view.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  67. self.fd_prefersNavigationBarHidden = YES;
  68. self.infoTabView.dataSource = self;
  69. self.infoTabView.delegate = self;
  70. self.infoTabView.tableFooterView = [UIView new];
  71. self.infoTabView.separatorStyle=UITableViewCellSeparatorStyleNone;
  72. self.infoTabView.separatorColor = [UIColor colorWithHexString:@"EEEEEE"];
  73. [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderTopCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderTopCell"];
  74. [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderCell"];
  75. [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderInputCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderInputCell"];
  76. [self.infoTabView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
  77. [self.infoTabView registerNib:[UINib nibWithNibName:@"AddPictureCell" bundle:nil] forCellReuseIdentifier:@"AddPictureCell"];
  78. [self.infoTabView registerNib:[UINib nibWithNibName:@"AddPeopleToGongWenCell" bundle:nil] forCellReuseIdentifier:@"AddPeopleToGongWenCell"];
  79. [self.infoTabView registerNib:[UINib nibWithNibName:@"WorkFlowOrderSelectedTimeCell" bundle:nil] forCellReuseIdentifier:@"WorkFlowOrderSelectedTimeCell"];
  80. if (self.isEdit) {
  81. [self.infoTabView.mj_header endRefreshing];
  82. [self.infoTabView.mj_footer endRefreshing];
  83. self.titleLbl.text = self.meetingModel.MeetingRoom[@"Name"];
  84. for (NSDictionary * dict in self.meetingModel.MeetingUserResults) {
  85. SelectModel * model = [[SelectModel alloc] init];
  86. model.UserId = [dict[@"Id"] integerValue];
  87. model.UserName = dict[@"Name"];
  88. model.Id = [dict[@"Id"] integerValue];
  89. model.Name = dict[@"Name"];
  90. model.AvatarUrl = dict[@"AvatarUrl"];
  91. [self.chaoSongRenArr addObject:model];
  92. }
  93. for (NSDictionary * dict in self.meetingModel.FlowAttachments) {
  94. FlowAttachmentsModel * model = [FlowAttachmentsModel modelWithDictionary:dict];
  95. [self.fileSource addObject:model];
  96. }
  97. for (TimeSourceModel * model in self.timeDataSource) {
  98. for (NSDictionary * dict in self.meetingModel.OrderList) {
  99. if ([dict[@"TimeKey"] integerValue] == [model.notSignDate integerValue]) {
  100. for (id value in dict[@"TimeValues"]) {
  101. NSIndexPath * indexPath = [NSIndexPath indexPathForItem:([value integerValue] - 7) inSection:0];
  102. [self addSelectedTimeWithDate:model time:[self oneTimeToTwoTime:[value integerValue]] indexPath:indexPath];
  103. }
  104. }
  105. }
  106. }
  107. self.titleStr = self.meetingModel.Name;
  108. [self.infoTabView reloadData];
  109. }else{
  110. self.titleLbl.text = self.mettingTitle;
  111. self.titleStr = @"";
  112. [self getData];
  113. }
  114. }
  115. - (NSArray *)getMonthDate
  116. {
  117. //获取日期格式化对象
  118. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  119. [dateFormatter setDateFormat:@"yyyy-MM-dd"];
  120. //获取当前完整日期
  121. NSString *today = [dateFormatter stringFromDate:[NSDate date]];
  122. //获取当天日期号
  123. NSString *day = [[today componentsSeparatedByString:@"-"] lastObject];
  124. //记住当前时间戳
  125. long long times = [NSDate date].timeIntervalSince1970;
  126. TimeSourceModel *sourceModel = [[TimeSourceModel alloc] init];
  127. sourceModel.timeDate = today;
  128. sourceModel.timeWeek = [[NSDate date] jk_dayFromWeekday];
  129. //创建日期接纳数组、将当天传进去
  130. NSMutableArray *marray = [NSMutableArray arrayWithObject:sourceModel];
  131. //循环遍历、一个月最大31天,所以i<32
  132. for (int i = 0; i < 32; i++) {
  133. //从今天的时间戳加 每回加一天
  134. times += 24 * 60 * 60;
  135. // NSDateFormatter *strDateFormatter = [[NSDateFormatter alloc] init];
  136. // [strDateFormatter setDateFormat:@"MM月dd日"];
  137. // NSString *dataDate = [strDateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:times]];
  138. //获取出完整日期
  139. NSString *dateStr = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:times]];
  140. //获取单独日期
  141. NSString *tempDay = [[dateStr componentsSeparatedByString:@"-"] lastObject];
  142. TimeSourceModel *sourceModel = [[TimeSourceModel alloc] init];
  143. sourceModel.timeDate = dateStr;
  144. sourceModel.timeWeek = [[NSDate dateWithTimeIntervalSince1970:times] jk_dayFromWeekday];
  145. //加入数组
  146. [marray addObject:sourceModel];
  147. //比较日期相同季结束循环 如从 2019-07-01 到 2019-08-01结束循环
  148. if ([tempDay isEqualToString:day]) {
  149. break;
  150. }
  151. }
  152. return marray;
  153. }
  154. #pragma mark - reloaddata
  155. - (void)getData {
  156. WS(weakSelf);
  157. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%@/%@",BaseUrl,MeetingList,self.rid] parameters:@{} success:^(id _Nonnull responseObject) {
  158. [weakSelf.infoTabView.mj_header endRefreshing];
  159. [weakSelf.infoTabView.mj_header removeFromSuperview];
  160. weakSelf.orderModel = [WorkFlowOrderModel modelWithDictionary:responseObject];
  161. [weakSelf.infoTabView reloadData];
  162. NSLog(@"获取的数据:%@",responseObject);
  163. } failure:^(NSError * _Nonnull error) {
  164. [weakSelf.infoTabView.mj_header endRefreshing];
  165. [weakSelf.infoTabView.mj_header removeFromSuperview];
  166. SHOWERROR([ZYCTool handerResultData:error]);
  167. }];
  168. }
  169. #pragma mark - table delegate
  170. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  171. {
  172. if ([cell respondsToSelector:@selector(setSeparatorInset:)])
  173. {
  174. [cell setSeparatorInset:UIEdgeInsetsZero];
  175. }
  176. if ([cell respondsToSelector:@selector(setLayoutMargins:)])
  177. {
  178. [cell setLayoutMargins:UIEdgeInsetsZero];
  179. }
  180. }
  181. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
  182. return 45.f;
  183. }
  184. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  185. if (indexPath.section == 0) {
  186. return 35.f;
  187. }else if (indexPath.section == 1) {
  188. return 476.f;
  189. }else if (indexPath.section == 2) {
  190. self.orderCellHeight = self.selectedTimeSource.count * (20 + 3) + 30.f;
  191. if (self.orderCellHeight < 50.f) {
  192. return 50.f;
  193. }
  194. return self.orderCellHeight;
  195. } else {
  196. if (indexPath.row == 0) {
  197. return 45.f;
  198. }else if(indexPath.row == 1){
  199. return UITableViewAutomaticDimension;
  200. }
  201. return 140.f;
  202. }
  203. }
  204. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  205. return 4;
  206. }
  207. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  208. if (section == 3) {
  209. return 4;
  210. }
  211. return 1;
  212. }
  213. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  214. return 0.1;
  215. }
  216. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  217. if (section == 1) {
  218. return 0.1f;
  219. }
  220. return 20.f;
  221. }
  222. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  223. WS(weakSelf);
  224. TDTableViewCell *cell;
  225. if (indexPath.section == 0) {
  226. cell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderTopCell" forIndexPath:indexPath];
  227. }else if (indexPath.section == 1) {
  228. WorkFlowOrderCell *orderCell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderCell" forIndexPath:indexPath];
  229. if (!orderCell) {
  230. orderCell = [[WorkFlowOrderCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"WorkFlowOrderCell"];
  231. }
  232. orderCell.selectedTimeDataSource = [NSMutableArray arrayWithArray:self.selectedTimeSource];
  233. orderCell.selectedTimeList = [NSMutableArray arrayWithArray:self.selectedTimeList];
  234. if (self.isEdit) {
  235. if (self.refreshCount < 1) {
  236. [orderCell setCellData:self.timeDataSource orderAll:self.meetingModel.OrderAllList order:self.meetingModel.OrderList];
  237. [orderCell CollectionReloadData];
  238. self.refreshCount ++;
  239. }
  240. }else{
  241. if (self.refreshCount < 2) {
  242. [orderCell setCellData:self.timeDataSource orderAll:self.orderModel.OrderList order:@[]];
  243. [orderCell CollectionReloadData];
  244. self.refreshCount ++;
  245. }
  246. }
  247. orderCell.upDataBlock = ^(NSArray * _Nonnull listArray) {
  248. weakSelf.meetingModel.OrderList = listArray;
  249. dispatch_async(dispatch_get_main_queue(), ^{
  250. NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:1];
  251. [weakSelf.infoTabView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
  252. });
  253. };
  254. [orderCell setSelectedTimeBlock:^(NSArray * _Nonnull selecteds,NSArray * _Nonnull timeList) {
  255. weakSelf.selectedTimeSource = selecteds;
  256. weakSelf.selectedTimeList = timeList;
  257. dispatch_async(dispatch_get_main_queue(), ^{
  258. NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:2];
  259. [weakSelf.infoTabView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
  260. });
  261. }];
  262. cell = orderCell;
  263. }else if (indexPath.section == 2) {
  264. cell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderSelectedTimeCell" forIndexPath:indexPath];
  265. [cell setCellData:self.selectedTimeSource];
  266. }else {
  267. if (indexPath.row == 0) {
  268. WorkFlowOrderInputCell *inputCell = [tableView dequeueReusableCellWithIdentifier:@"WorkFlowOrderInputCell" forIndexPath:indexPath];
  269. [inputCell.inputTxt addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  270. inputCell.inputTxt.returnKeyType = UIReturnKeyDone;
  271. inputCell.inputTxt.delegate = self;
  272. if (self.isEdit) {
  273. inputCell.inputTxt.text = self.meetingModel.Name;
  274. }
  275. [inputCell setCellData:self.orderModel.title line:YES];
  276. cell = inputCell;
  277. }else if (indexPath.row == 1) {
  278. InPutGongWenCell *inPutGongWenCell = [tableView dequeueReusableCellWithIdentifier:@"InPutGongWenCell" forIndexPath:indexPath];
  279. inPutGongWenCell.namelab.text = @"会议描述";
  280. if (self.isEdit) {
  281. inPutGongWenCell.gongwenContent.text = self.meetingModel.Description;
  282. }
  283. inPutGongWenCell.haveNeedImageView.hidden = YES;
  284. inPutGongWenCell.gongwenContent.delegate = self;
  285. inPutGongWenCell.gongwenContent.tag = indexPath.section;
  286. cell = inPutGongWenCell;
  287. }else if (indexPath.row == 2) {
  288. AddPictureCell *addPictureCell = [tableView dequeueReusableCellWithIdentifier:@"AddPictureCell" forIndexPath:indexPath];
  289. addPictureCell.namelab.text = @"上传附件";
  290. addPictureCell.haveNeedImageView.hidden = YES;
  291. addPictureCell.approvalSection = self.fileSource;
  292. addPictureCell.delegate = self;
  293. addPictureCell.index = indexPath;
  294. addPictureCell.ClickCellBlock = ^(NSInteger index) {
  295. FlowAttachmentsModel * imgModel = weakSelf.fileSource[index];
  296. DownFileViewController *vc = [[DownFileViewController alloc]init];
  297. vc.model = imgModel;
  298. [weakSelf.navigationController pushViewController:vc animated:YES];
  299. };
  300. cell = addPictureCell;
  301. }else {
  302. AddPeopleToGongWenCell *addPeopleToGongWenCell = [tableView dequeueReusableCellWithIdentifier:@"AddPeopleToGongWenCell" forIndexPath:indexPath];
  303. addPeopleToGongWenCell.namelab.text = @"参会人员";
  304. addPeopleToGongWenCell.haveNeedImageView.hidden = YES;
  305. addPeopleToGongWenCell.delegate = self;
  306. addPeopleToGongWenCell.approvalSection = self.chaoSongRenArr;
  307. cell = addPeopleToGongWenCell;
  308. }
  309. }
  310. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  311. return cell;
  312. }
  313. #pragma mark - textfile / textviewdelegate
  314. - (void)textViewDidChange:(UITextView *)textView{
  315. self.contentStr = textView.text;
  316. NSArray * cells = [self.infoTabView visibleCells];
  317. for (UITableViewCell * cell in cells) {
  318. if ([cell isKindOfClass:[InPutGongWenCell class]]) {
  319. InPutGongWenCell * inCell = (InPutGongWenCell *)cell;
  320. inCell.bgL.text = textView.text;
  321. [self.infoTabView beginUpdates];
  322. [self.infoTabView endUpdates];
  323. }
  324. }
  325. }
  326. - (void)textFieldDidChange:(UITextField *)textField {
  327. self.titleStr = textField.text;
  328. }
  329. #pragma mark - AddPictureCellDelegate
  330. - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  331. WEAKSELF
  332. [self addFile:index Sucuss:^(id _Nullable responseObject) {
  333. STRONGSELF
  334. AddPictureCell *cell = [strongSelf.infoTabView cellForRowAtIndexPath:index];
  335. if ([responseObject isKindOfClass:[NSArray class]]) {
  336. [strongSelf.fileSource addObjectsFromArray:responseObject];
  337. }else {
  338. [strongSelf.fileSource addObject:responseObject];
  339. }
  340. [cell.mycollectionView reloadData];
  341. REMOVESHOW;
  342. } failure:^(NSError * _Nonnull error ) {
  343. REMOVESHOW;
  344. SHOWERROR([ZYCTool handerResultData:error]);
  345. }];
  346. }
  347. - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  348. WS(weakSelf);
  349. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  350. picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  351. picker.delegate = self;
  352. picker.allowsEditing = YES;//取消白框
  353. UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  354. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  355. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  356. } choosImgBlock:^(UIImage *image) {
  357. SHOWLOADING
  358. [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
  359. NSDictionary *dict = responseObject[0];
  360. FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc]init];
  361. model.SoureId = [dict[@"FileId"] integerValue];
  362. model.SoureTypeId = CollectModel_file;
  363. model.Url = dict[@"AbsolutePath"];
  364. model.MinUrl = dict[@"MinAbsolutePath"];
  365. model.Title = dict[@"FileName"];
  366. model.Size = [dict[@"Size"] integerValue];
  367. success(model);
  368. } failure:^(NSError * _Nonnull error) {
  369. failure(error);
  370. }];
  371. }];
  372. }];
  373. [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  374. [alertvc addAction:action1];
  375. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  376. [self.view endEditing:YES];
  377. TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil];
  378. [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
  379. leftButton.hidden = YES;
  380. }];
  381. imagePickerVc.showSelectBtn = NO;
  382. imagePickerVc.allowCrop = YES;
  383. imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
  384. imagePickerVc.allowTakePicture = NO;
  385. imagePickerVc.allowTakeVideo = NO;
  386. [imagePickerVc setIsStatusBarDefault:YES];
  387. [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
  388. [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
  389. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  390. PHAsset *asset = assets.firstObject;
  391. switch (asset.mediaType) {
  392. case PHAssetMediaTypeVideo: {
  393. } break;
  394. case PHAssetMediaTypeImage: {
  395. [self didSelectImages:photos success:success withImgs:photos];
  396. } break;
  397. case PHAssetMediaTypeAudio:
  398. break;
  399. case PHAssetMediaTypeUnknown:
  400. break;
  401. default: break;
  402. }
  403. }];
  404. [self presentViewController:imagePickerVc animated:YES completion:nil];
  405. }];
  406. [alertvc addAction:action2];
  407. [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  408. UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  409. [[FWZGetNoteBookTool sharedTool] WorkOpenCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
  410. NSLog(@"SmartBarCollection %@",collectArr);
  411. NSArray * array = [weakSelf disSelectCollect:collectArr];
  412. success(array);
  413. }];
  414. }];
  415. [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  416. [alertvc addAction:action3];
  417. UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  418. [[FWZGetNoteBookTool sharedTool] WorkOpenNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
  419. NSLog(@"SmartBarNotes %@",noteArr);
  420. NSArray * array = [weakSelf disSelectNoteBook:noteArr];
  421. success(array);
  422. }];
  423. }];
  424. [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  425. [alertvc addAction:action4];
  426. UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  427. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  428. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  429. NSLog(@"%@",fileName);
  430. SHOWLOADING
  431. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  432. NSLog(@"上传成功的文件%@",responseObject);
  433. NSDictionary *dict = responseObject[0];
  434. FlowAttachmentsModel *model = [[FlowAttachmentsModel alloc] initWithDictionary:dict error:nil];
  435. model.SoureTypeId = CollectModel_file;
  436. model.SoureId = [dict[@"FileId"] integerValue];
  437. model.Url = dict[@"AbsolutePath"];
  438. model.MinUrl = dict[@"MinAbsolutePath"];
  439. model.Title = dict[@"FileName"];
  440. model.Size = [dict[@"Size"] integerValue];
  441. success(model);
  442. } failure:^(NSError * _Nonnull error) {
  443. failure(error);
  444. }];
  445. }];
  446. }];
  447. [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  448. [alertvc addAction:action5];
  449. UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  450. }];
  451. [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  452. [alertvc addAction:action6];
  453. [self presentViewController:alertvc animated:YES completion:^{}];
  454. }
  455. #pragma mark - addNote
  456. - (NSArray *)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
  457. NSMutableArray * array = [NSMutableArray array];
  458. for (MyNoteBookSubModel *dataModel in noteArr ) {
  459. if (dataModel.AttributeValue == 1) {
  460. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  461. model.SoureId = dataModel.MiddleId;
  462. model.Url = dataModel.AvatarUrl;
  463. model.Author = dataModel.Name;
  464. model.Title = dataModel.Title;
  465. model.SoureTypeId = CollectModel_NoteBook;
  466. [array addObject:model];
  467. }
  468. }
  469. return array;
  470. }
  471. #pragma mark - addCollect
  472. - (NSArray *)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
  473. NSMutableArray * array = [NSMutableArray array];
  474. for (MyFavoriteSubModel *dataModel in collectArr ) {
  475. if(dataModel.AttributeValue == 1)
  476. {
  477. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  478. model.SoureId = dataModel.CollectionDataId;
  479. model.Url = dataModel.Data.File;
  480. model.Size = dataModel.Data.FileSize;
  481. model.Author = dataModel.Data.Author;
  482. model.Title = dataModel.Title;
  483. model.MinUrl = dataModel.Data.MinFile;
  484. model.SoureTypeId = dataModel.CollectionType;
  485. [array addObject:model];
  486. }
  487. }
  488. return array;
  489. }
  490. // 多张图片上传
  491. - (void)didSelectImages:(NSArray<UIImage *> *)images success:(void (^) (id _Nullable))successfulk withImgs:(NSArray *)imgs {
  492. NSMutableArray *imageArr = [NSMutableArray array];
  493. for (UIImage *image in images) {
  494. [imageArr addObject:UIImageJPEGRepresentation(image,1.0f)];
  495. }
  496. SHOWLOADING
  497. NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
  498. [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:[imageArr copy] pictureKey:@"file" success:^(id _Nonnull responseObject) {
  499. REMOVESHOW
  500. NSLog(@"%@",responseObject);
  501. NSMutableArray * array = [NSMutableArray array];
  502. for (NSDictionary * dict in responseObject) {
  503. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  504. model.SoureId = [dict[@"FileId"] integerValue];
  505. model.SoureTypeId = CollectModel_file;
  506. model.Url = dict[@"AbsolutePath"];
  507. model.MinUrl = dict[@"MinAbsolutePath"];
  508. model.Title = dict[@"FileName"];
  509. model.Size = [dict[@"Size"] integerValue];
  510. [array addObject:model];
  511. }
  512. successfulk(array);
  513. } failure:^(NSError * _Nonnull error) {
  514. REMOVESHOW
  515. SHOWERROR([ZYCTool handerResultData:error]);
  516. }];
  517. }
  518. #pragma mark - AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate
  519. - (void)addLookUpPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  520. NSLog(@"点击添加抄送人");
  521. Department *defaltGroupSetion = [[Department alloc]init];
  522. defaltGroupSetion.Name = @"单位通讯录";
  523. defaltGroupSetion.Id = 0;
  524. Department *myGroupSetion = [[Department alloc]init];
  525. myGroupSetion.Name = @"自建通讯录";
  526. defaltGroupSetion.Id = 0;
  527. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  528. vc.isAllSelected = NO;
  529. vc.notSearchChangeColor = YES;
  530. vc.titleStr = @"选人";
  531. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  532. vc.isDefalutPage = 1;
  533. vc.isShow = NO;
  534. NSMutableArray * userArray = [NSMutableArray array];
  535. for (SelectModel * model in self.chaoSongRenArr) {
  536. [userArray addObject:@(model.UserId)];
  537. }
  538. [userArray addObject:@([AppUserModel sharedAppUserModel].Id)];
  539. vc.UserIds = userArray;
  540. vc.delegate = self;
  541. [self.navigationController pushViewController:vc animated:YES];
  542. }
  543. #pragma mark - 注册通知 接受抄送人和审批人数据
  544. - (void)registerNotification{
  545. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  546. }
  547. - (void)recviveChaoSongRen:(NSNotification *)notification{
  548. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  549. [self.chaoSongRenArr addObjectsFromArray:array];
  550. [self.infoTabView reloadRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:3] withRowAnimation:UITableViewRowAnimationAutomatic];
  551. }
  552. #pragma mark - private
  553. - (IBAction)orderBtn_Click:(id)sender {
  554. //判断是否选择时间
  555. if (self.selectedTimeList.count == 0) {
  556. SHOWERROR(@"请选择会议时间");
  557. return;
  558. }
  559. //是否输入标题
  560. if (self.titleStr.length < 1) {
  561. SHOWERROR(@"请输入标题");
  562. return;
  563. }
  564. // //是否输入内容
  565. // if (self.orderModel.content.length < 1) {
  566. // SHOWERROR(@"请输入会议描述");
  567. // return;
  568. // }
  569. // //是否选择参会人员
  570. // if (self.chaoSongRenArr.count < 1) {
  571. // SHOWERROR(@"请选择参会人员");
  572. // return;
  573. // }
  574. //组成请求参数
  575. NSInteger meetId = 0;
  576. if (self.meetingModel.Id.length > 0) {
  577. meetId = [self.meetingModel.Id integerValue];
  578. }
  579. NSDictionary *requestParam = @{@"Orders": [self createSelectedTimeParam],
  580. @"Name":self.titleStr,
  581. @"Description":self.contentStr.length > 0 ? self.contentStr : @"",
  582. @"flowAttachments":[self createFileIDParam],
  583. @"UserIds":[self createUserIDParam],
  584. @"MeetingId":@(meetId),
  585. @"FileIds":@[]
  586. };
  587. SHOWLOADING
  588. NSString * roomId = self.rid;
  589. if (self.isEdit) {
  590. roomId = [NSString stringWithFormat:@"%ld",(long)[self.meetingModel.MeetingRoom[@"Id"] integerValue]];
  591. }
  592. WS(weakSelf);
  593. [[HttpManager sharedHttpManager] POSTWithUrl:Host(ActionMeeting(roomId)) parameters:requestParam success:^(id _Nonnull responseObject) {
  594. REMOVESHOW
  595. if (weakSelf.isEdit) {
  596. SHOWSUCCESS(@"修改成功");
  597. if (weakSelf.ChangeSuccessBlock) {
  598. weakSelf.ChangeSuccessBlock();
  599. }
  600. }else{
  601. SHOWSUCCESS(@"预订成功");
  602. }
  603. [weakSelf.navigationController popViewControllerAnimated:YES];
  604. } failure:^(NSError * _Nonnull error) {
  605. REMOVESHOW
  606. SHOWERROR([ZYCTool handerResultData:error]);
  607. }];
  608. }
  609. - (NSArray *)createSelectedTimeParam {
  610. NSMutableArray *times = [[NSMutableArray alloc] initWithCapacity:self.selectedTimeList.count];
  611. for (SelectedTimeModel *timeModel in self.selectedTimeList) {
  612. NSString *timeStr = [NSString stringWithFormat:@"%@ %@:00",timeModel.yearAndMonthAndDay,timeModel.time];
  613. [times addObject:timeStr];
  614. }
  615. return times;
  616. }
  617. - (NSArray *)createFileIDParam {
  618. NSMutableArray *fileid = [[NSMutableArray alloc] initWithCapacity:self.fileSource.count];
  619. for (FlowAttachmentsModel *model in self.fileSource) {
  620. NSDictionary * AttachmentDict = @{@"SoureId":@(model.SoureId),
  621. @"Url":model.Url,
  622. @"Title":model.Title,
  623. @"SoureTypeId":@(model.SoureTypeId),
  624. @"Size":@(model.Size),
  625. };
  626. [fileid addObject:AttachmentDict];
  627. }
  628. return fileid;
  629. }
  630. - (NSArray *)createUserIDParam {
  631. NSMutableArray *userId = [[NSMutableArray alloc] initWithCapacity:self.chaoSongRenArr.count];
  632. for (SelectModel *userModel in self.chaoSongRenArr) {
  633. [userId addObject:[NSString stringWithFormat:@"%ld",(long)userModel.UserId]];
  634. }
  635. return userId;
  636. }
  637. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  638. {
  639. [textField resignFirstResponder];
  640. return YES;
  641. }
  642. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  643. {
  644. [self.view endEditing:YES];
  645. }
  646. #pragma mark - get/set
  647. - (NSMutableArray *)fileSource {
  648. if (!_fileSource) {
  649. _fileSource = [[NSMutableArray alloc] init];
  650. }
  651. return _fileSource;
  652. }
  653. - (NSMutableArray *)chaoSongRenArr{
  654. if (!_chaoSongRenArr) {
  655. _chaoSongRenArr = [NSMutableArray array];
  656. }
  657. return _chaoSongRenArr;
  658. }
  659. - (NSMutableArray *)timeList{
  660. if (!_timeList) {
  661. _timeList = [NSMutableArray array];
  662. }
  663. return _timeList;
  664. }
  665. - (NSMutableArray *)timeSource{
  666. if (!_timeSource) {
  667. _timeSource = [NSMutableArray array];
  668. }
  669. return _timeSource;
  670. }
  671. - (NSArray *)timeDataSource {
  672. if (!_timeDataSource) {
  673. _timeDataSource = [self getMonthDate];
  674. }
  675. return _timeDataSource;
  676. }
  677. - (CGFloat)orderCellHeight {
  678. if (_orderCellHeight < 50.f ) {
  679. return 50.f;
  680. }
  681. return _orderCellHeight;
  682. }
  683. -(void)addSelectedTimeWithDate:(TimeSourceModel *)date time:(NSString *)time indexPath:(NSIndexPath *)indexPath{
  684. SelectedTimeModel *timeModel = [[SelectedTimeModel alloc] init];
  685. timeModel.date = date.timeDate;
  686. timeModel.yearAndMonthAndDay = date.monthAndDay;
  687. timeModel.yearAndMonthAndDay = date.timeDate;
  688. timeModel.time = time;
  689. timeModel.indexPath = indexPath;
  690. [self.timeList addObject:timeModel];
  691. [self screenTime];
  692. }
  693. - (void)screenTime {
  694. //循环每天日期是否有预约的会议
  695. [self.timeSource removeAllObjects];
  696. for (TimeSourceModel *time in self.timeDataSource) {
  697. //判断选中集合当中是否有预约这一天的会议
  698. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date == %@", time.timeDate];
  699. NSArray *filteredArray = [self.timeList filteredArrayUsingPredicate:predicate];
  700. if (filteredArray.count > 0) { //有此日期的预约会议
  701. NSArray *sortArray = [filteredArray sortedArrayUsingSelector:@selector(compareIndex:)];
  702. //第一个选择的时间
  703. SelectedTimeModel *firstObject = [sortArray firstObject];
  704. //第一个出现的index
  705. __block NSInteger index = firstObject.indexPath.item;
  706. //创建时间模型
  707. __block SelectedTimeSourceModel *timeModel = [[SelectedTimeSourceModel alloc] init];
  708. timeModel.dateTime = time.timeWeek;
  709. timeModel.yearAndMonthAndDayTime = time.timeDate;
  710. timeModel.beginTime = firstObject.time;
  711. //如果只有一个的情况下
  712. if (sortArray.count == 1) {
  713. //将上一个添加到数组中
  714. [self.timeSource addObject:timeModel];
  715. continue;
  716. }
  717. //循环数组找和index连续的时间
  718. [sortArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  719. if (idx > 0) {
  720. SelectedTimeModel *tmpTimeModel = obj;
  721. //是否和第一个相差1
  722. if ((tmpTimeModel.indexPath.item - index) == 1) {
  723. //记录结束时间
  724. timeModel.endTime = tmpTimeModel.time;
  725. }else {
  726. //将上一个添加到数组中
  727. [self.timeSource addObject:timeModel];
  728. //重新创建一个时间模型
  729. timeModel = [[SelectedTimeSourceModel alloc] init];
  730. timeModel.yearAndMonthAndDayTime = time.timeDate;
  731. timeModel.dateTime = time.timeWeek;
  732. timeModel.beginTime = tmpTimeModel.time;
  733. }
  734. if (idx == (sortArray.count - 1)) {
  735. //如果是最后一个也需要将时间添加到数组中
  736. [self.timeSource addObject:timeModel];
  737. }
  738. //重新计算index
  739. index = tmpTimeModel.indexPath.item;
  740. }
  741. }];
  742. }
  743. }
  744. if (self.timeList.count > 0) {
  745. self.selectedTimeSource = self.timeSource;
  746. self.selectedTimeList = self.timeList;
  747. }
  748. }
  749. - (NSString *)oneTimeToTwoTime:(NSInteger)time;
  750. {
  751. NSString * reTime = @"";
  752. if (time < 10) {
  753. reTime = [NSString stringWithFormat:@"0%ld:00",time];
  754. }else{
  755. reTime = [NSString stringWithFormat:@"%ld:00",time];
  756. }
  757. return reTime;
  758. }
  759. @end