MyWorkCarVC.m 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. //
  2. // MyWorkCarVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/26.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyWorkCarVC.h"
  9. #import "AutoLayoutScrollView.h"
  10. #import "MyWorkWordModel.h"
  11. #import "SelectTextCell.h"
  12. #import "InPutTextCell.h"
  13. #import "InPutGongWenCell.h"
  14. #import "AddFileTableViewCell.h"
  15. #import "AddPeopleToGongWenCell.h"
  16. #import "MOFSPickerManager.h"
  17. #import "SendInfoGroupVC.h"
  18. #import "LYLPhotoTailoringTool.h"
  19. #import "MyWorkAppApprovalCell.h"
  20. #import "AddLookUpUserSecondVC.h"
  21. #import "MailListVC.h"
  22. #import "AddPictureCell.h"
  23. #import "FWZFileGetTool.h"
  24. #import "WaitTimePicker.h"
  25. #import "DownFileViewController.h"
  26. @interface MyWorkCarVC ()<UITableViewDelegate,UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate,UITextFieldDelegate,UITextViewDelegate,AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate,AddLookUpUserSecondVCDelegate,AddPictureCellDelegate,UIDocumentPickerDelegate>{
  27. NSIndexPath *_currentIndexPath;
  28. }
  29. @property (nonatomic, strong) UIScrollView *scrollView;
  30. @property (nonatomic, strong) NSMutableArray<NSMutableArray<MyWorkWordModel*>*>* viewDataArray;
  31. @property (nonatomic, strong) NSMutableArray<FormFieldsModel*>* viewDataArray2;
  32. @property (nonatomic, strong) TDTableView *myTableView;
  33. @property (nonatomic, strong) UIView *footerview;
  34. @property (nonatomic, strong) MyWorkWordModel *model;
  35. @property (nonatomic, assign) NSInteger isTest;
  36. @property (nonatomic, strong) NSMutableDictionary *reuqestParams;
  37. @property (nonatomic, strong) NSMutableArray *chaoSongRenArr;
  38. @property (nonatomic, strong) NSMutableArray *shenPiRenArr;
  39. @property (nonatomic, assign) NSInteger carTypeId;
  40. @property (nonatomic, assign) BOOL isShenPinRen;
  41. @end
  42. @implementation MyWorkCarVC
  43. - (void)viewDidLoad {
  44. [super viewDidLoad];
  45. self.fd_prefersNavigationBarHidden = YES;
  46. self.isTest = 1;
  47. [self.navigationController.navigationItem.leftBarButtonItem setImage:IMG(@"工作_返回")];
  48. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithBgColor:[UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0] alpha:1.0] forBarMetrics:UIBarMetricsDefault];
  49. [self getData];
  50. [self.view addSubview:self.myTableView];
  51. self.footerview.frame = CGRectMake(0, 0, kGXScreenWidth,70);
  52. [self registerNotification];
  53. self.fd_interactivePopDisabled = YES;
  54. }
  55. - (void)viewWillAppear:(BOOL)animated{
  56. [super viewWillAppear:animated];
  57. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
  58. }
  59. - (void)viewWillDisappear:(BOOL)animated{
  60. [super viewWillDisappear:animated];
  61. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  62. }
  63. - (UIStatusBarStyle)preferredStatusBarStyle{
  64. return UIStatusBarStyleLightContent;
  65. }
  66. - (void)getData{
  67. [self getOnlineData];
  68. }
  69. - (void)getOnlineData{
  70. SHOWLOADING
  71. WS(weakSelf);
  72. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,WorkFlowHomeData_Post,(long)self.indexID] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  73. NSDictionary *dic = responseObject;
  74. MyWorkWordModel *model = [[MyWorkWordModel alloc]initWithDictionary:dic error:nil];
  75. weakSelf.model = model;
  76. NSLog(@"%@",model);
  77. weakSelf.viewDataArray2 = [NSMutableArray arrayWithArray:model.FormFields];
  78. weakSelf.isTest = 2;
  79. dispatch_async(dispatch_get_main_queue(), ^{
  80. [weakSelf.myTableView setTableFooterView:weakSelf.footerview];
  81. [weakSelf.myTableView reloadData];
  82. });
  83. REMOVESHOW
  84. } failure:^(NSError * _Nonnull error) {
  85. REMOVESHOW
  86. SHOWERROR([ZYCTool handerResultData:error]);
  87. }];
  88. }
  89. #pragma mark - UITableViewDelegate,UITableViewDataSource
  90. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  91. if (self.isTest == 1) {
  92. return self.viewDataArray.count;
  93. }else{
  94. return self.viewDataArray2.count;
  95. }
  96. }
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  98. if (self.isTest == 1) {
  99. return self.viewDataArray[section].count;
  100. }else{
  101. return 1;
  102. }
  103. }
  104. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  105. WS(weakSelf);
  106. NSString * cellIdentifier1 = @"SelectTextCell";
  107. SelectTextCell *selectTextCell = (SelectTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
  108. NSString * cellIdentifier2 = @"InPutTextCell";
  109. InPutTextCell *inPutTextCell = (InPutTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
  110. NSString * cellIdentifier3 = @"InPutGongWenCell";
  111. InPutGongWenCell *inPutGongWenCell = (InPutGongWenCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
  112. NSString * cellIdentifier7 = @"AddPictureCell";
  113. AddPictureCell *addPictureCell = (AddPictureCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier7];
  114. if (self.isTest == 1) {
  115. return selectTextCell;
  116. }
  117. else{
  118. FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
  119. if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
  120. {
  121. inPutTextCell.nameLab.text = formFieldsModel.Label;
  122. inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  123. inPutTextCell.inputtextFeild.tag = indexPath.section;
  124. inPutTextCell.inputtextFeild.delegate = self;
  125. inPutTextCell.inputtextFeild.returnKeyType = UIReturnKeyDone;
  126. if (!ISEmptyString(formFieldsModel.paramString)) {
  127. inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
  128. }
  129. return inPutTextCell;
  130. }
  131. else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
  132. {
  133. inPutGongWenCell.namelab.text = formFieldsModel.Label;
  134. inPutGongWenCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  135. inPutGongWenCell.gongwenContent.delegate = self;
  136. inPutGongWenCell.gongwenContent.tag = indexPath.section;
  137. inPutGongWenCell.gongwenContent.text = formFieldsModel.paramString;
  138. return inPutGongWenCell;
  139. }
  140. else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
  141. {
  142. inPutTextCell.nameLab.text = formFieldsModel.Label;
  143. inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  144. inPutTextCell.inputtextFeild.tag = indexPath.section;
  145. inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad;
  146. inPutTextCell.inputtextFeild.delegate = self;
  147. if (!ISEmptyString(formFieldsModel.paramString)) {
  148. inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
  149. }
  150. return inPutTextCell;
  151. }
  152. else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
  153. {
  154. inPutTextCell.nameLab.text = formFieldsModel.Label;
  155. inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  156. inPutTextCell.inputtextFeild.tag = indexPath.section;
  157. inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad;
  158. inPutTextCell.inputtextFeild.delegate = self;
  159. if (!ISEmptyString(formFieldsModel.paramString)) {
  160. inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
  161. }
  162. return inPutTextCell;
  163. }
  164. else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
  165. {
  166. selectTextCell.nameLab.text = formFieldsModel.Label;
  167. selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  168. selectTextCell.selectButton.tag = indexPath.section;
  169. if (!ISEmptyString(formFieldsModel.paramString)) {
  170. [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal];
  171. [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal];
  172. }
  173. return selectTextCell;
  174. }
  175. else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
  176. {
  177. selectTextCell.nameLab.text = formFieldsModel.Label;
  178. selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  179. selectTextCell.selectButton.tag = indexPath.section;
  180. if (!ISEmptyString(formFieldsModel.paramString)) {
  181. [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal];
  182. [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal];
  183. }
  184. return selectTextCell;
  185. }
  186. else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
  187. {
  188. // addPictureCell.namelab.text = formFieldsModel.Label;
  189. // addPictureCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  190. // addPictureCell.approvalSection = formFieldsModel.paraImage;
  191. // addPictureCell.delegate = self;
  192. // addPictureCell.index = indexPath;
  193. // addPictureCell.ClickCellBlock = ^(NSInteger index) {
  194. // SelectImageModel * imgModel = formFieldsModel.paraImage[index];
  195. // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
  196. // mdoel.PreviewUrl = imgModel.FileUrl;
  197. // mdoel.DownloadUrl = imgModel.FileUrl;
  198. // mdoel.titleStr = imgModel.FileName;
  199. // DownFileViewController *vc = [[DownFileViewController alloc]init];
  200. // vc.model = mdoel;
  201. // [weakSelf.navigationController pushViewController:vc animated:YES];
  202. // };
  203. return addPictureCell;
  204. }
  205. else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
  206. {
  207. // addPictureCell.namelab.text = formFieldsModel.Label;
  208. // addPictureCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
  209. // addPictureCell.approvalSection = formFieldsModel.paraImage;
  210. // addPictureCell.index = indexPath;
  211. // addPictureCell.delegate = self;
  212. // addPictureCell.ClickCellBlock = ^(NSInteger index) {
  213. // SelectImageModel * imgModel = formFieldsModel.paraImage[index];
  214. // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
  215. // mdoel.PreviewUrl = imgModel.FileUrl;
  216. // mdoel.DownloadUrl = imgModel.FileUrl;
  217. // DownFileViewController *vc = [[DownFileViewController alloc]init];
  218. // vc.title = [mdoel.PreviewUrl componentsSeparatedByString:@"/"].lastObject;
  219. // vc.model = mdoel;
  220. // [weakSelf.navigationController pushViewController:vc animated:YES];
  221. // };
  222. return addPictureCell;
  223. }
  224. return selectTextCell;
  225. }
  226. }
  227. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  228. WS(weakSelf);
  229. [MOFSPickerManager shareManger].pickView.toolBar.cancelBar.textColor = UIColorHex(#888888);
  230. [MOFSPickerManager shareManger].pickView.toolBar.commitBar.textColor = UIColorHex(#3979D3);
  231. if (self.isTest == 1){
  232. }else{
  233. FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
  234. if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
  235. {
  236. }
  237. else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
  238. {
  239. }
  240. else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
  241. {
  242. }
  243. else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
  244. {
  245. }
  246. else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
  247. {
  248. WaitTimePicker * picker = [[WaitTimePicker alloc] init];
  249. [picker setCusDateMode:UIDatePickerModeDateAndTime locale:@"zh_CN"];
  250. [picker showDatePickerViewWithFirstDate: [NSDate date] commit:^(NSDate * _Nonnull date) {
  251. NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
  252. dateformat.dateFormat = @"yyyy-MM-dd HH:mm";
  253. SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  254. [cell.selectButton setTitle: [dateformat stringFromDate:date] forState:UIControlStateNormal];
  255. cell.selectButton.tag = indexPath.section;
  256. [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
  257. self.viewDataArray2[indexPath.section].paramString = [dateformat stringFromDate:date];
  258. } cancel:^{
  259. }];
  260. }
  261. else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
  262. {
  263. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowApp_Car_Type_Get) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  264. NSLog(@"%@",responseObject);
  265. NSMutableArray * nameArray = [NSMutableArray array];
  266. for (NSDictionary * dict in responseObject) {
  267. NSString * name = [dict objectForKey:@"Name"];
  268. [nameArray addObject:name];
  269. }
  270. [[MOFSPickerManager shareManger] showPickerViewWithDataArray:nameArray tag:1 title:nil cancelTitle:@"取消" commitTitle:@"确定" commitBlock:^(NSString *string) {
  271. SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  272. [cell.selectButton setTitle: string forState:UIControlStateNormal];
  273. [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
  274. weakSelf.viewDataArray2[indexPath.section].paramString = string;
  275. for (NSDictionary * dict in responseObject) {
  276. if ([[dict objectForKey:@"Name"] isEqualToString:string]) {
  277. weakSelf.carTypeId = [[dict objectForKey:@"Id"] integerValue];
  278. }
  279. }
  280. } cancelBlock:^{
  281. }];
  282. } failure:^(NSError * _Nonnull error) {
  283. }];
  284. }
  285. else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
  286. {
  287. }
  288. else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
  289. {
  290. }
  291. }
  292. }
  293. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  294. if (self.isTest == 1) {
  295. if (indexPath.section == 0) {
  296. return 45;
  297. }
  298. if (indexPath.section == 1) {
  299. return 45;
  300. }
  301. if (indexPath.section == 2) {
  302. return 120;
  303. }
  304. if (indexPath.section == 3) {
  305. return 120;
  306. }
  307. if (indexPath.section == 4) {
  308. return 120;
  309. }
  310. if (indexPath.section == 5) {
  311. return 120;
  312. }
  313. return 0;
  314. }
  315. else{
  316. FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
  317. if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
  318. {
  319. return 45;
  320. }
  321. else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
  322. {
  323. return 120;
  324. }
  325. else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
  326. {
  327. return 45;
  328. }
  329. else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
  330. {
  331. return 45;
  332. }
  333. else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
  334. {
  335. return 60;
  336. }
  337. else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
  338. {
  339. return 60;
  340. }
  341. else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
  342. {
  343. return 120;
  344. }
  345. else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
  346. {
  347. return 120;
  348. }
  349. return 120;
  350. }
  351. }
  352. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  353. if (self.isTest == 1) {
  354. if (section == 0) {
  355. return 10;
  356. }
  357. if (section == 1) {
  358. return 10;
  359. }
  360. if (section == 2) {
  361. return 10;
  362. }
  363. if (section == 3) {
  364. return 10;
  365. }
  366. if (section == 4) {
  367. return 10;
  368. }
  369. if (section == 5) {
  370. return 10;
  371. }
  372. return 0;
  373. }
  374. else{
  375. return 15;
  376. }
  377. }
  378. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  379. if (self.isTest == 1) {
  380. if (section == 0) {
  381. return 20;
  382. }
  383. if (section == 1) {
  384. return 10;
  385. }
  386. if (section == 2) {
  387. return 10;
  388. }
  389. if (section == 3) {
  390. return 10;
  391. }
  392. if (section == 4) {
  393. return 10;
  394. }
  395. if (section == 5) {
  396. return 10;
  397. }
  398. return 0;
  399. }
  400. else{
  401. return 0.01;
  402. }
  403. }
  404. #pragma mark - UITableViewDelegate,UITableViewDataSource
  405. - (NSMutableArray<NSMutableArray<MyWorkWordModel *> *> *)viewDataArray{
  406. if (!_viewDataArray) {
  407. _viewDataArray = [NSMutableArray new];
  408. }
  409. return _viewDataArray;
  410. }
  411. - (TDTableView *)myTableView{
  412. if (!_myTableView) {
  413. _myTableView = [[TDTableView alloc]initWithFrame:CGRectMake(0,kNavigationHeight,kGXScreenWidth,kGXScreenHeigh -kNavigationHeight)];
  414. _myTableView.delegate = self;
  415. _myTableView.dataSource= self;
  416. _myTableView.bounces = NO;
  417. [_myTableView registerNib:[UINib nibWithNibName:@"SelectTextCell" bundle:nil] forCellReuseIdentifier:@"SelectTextCell"];
  418. [_myTableView registerNib:[UINib nibWithNibName:@"InPutTextCell" bundle:nil] forCellReuseIdentifier:@"InPutTextCell"];
  419. [_myTableView registerNib:[UINib nibWithNibName:@"AddFileTableViewCell" bundle:nil] forCellReuseIdentifier:@"AddFileTableViewCell"];
  420. [_myTableView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
  421. [_myTableView registerNib:[UINib nibWithNibName:@"AddPeopleToGongWenCell" bundle:nil] forCellReuseIdentifier:@"AddPeopleToGongWenCell"];
  422. [_myTableView registerNib:[UINib nibWithNibName:@"MyWorkAppApprovalCell" bundle:nil] forCellReuseIdentifier:@"MyWorkAppApprovalCell"];
  423. [_myTableView registerNib:[UINib nibWithNibName:@"AddPictureCell" bundle:nil] forCellReuseIdentifier:@"AddPictureCell"];
  424. }
  425. return _myTableView;
  426. }
  427. - (UIView *)footerview{
  428. if (!_footerview) {
  429. _footerview = [[UIView alloc]init];
  430. _footerview.backgroundColor = UIColorHex(EEEEEE);
  431. TDButton *button = [[TDButton alloc]init];
  432. [button setTitle:@"提交" forState:UIControlStateNormal];
  433. [[button titleLabel] setFont: [UIFont systemFontOfSize:19]];
  434. [button setTitleColor:UIColorHex(FFFFFF) forState:UIControlStateNormal];
  435. button.backgroundColor = UIColorHex(457BC7);
  436. button.layer.cornerRadius = 5.f;
  437. button.layer.masksToBounds = YES;
  438. [_footerview addSubview:button];
  439. [button addTarget:self action:@selector(commitGonwen:) forControlEvents:UIControlEventTouchDown];
  440. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  441. make.centerX.equalTo(self.footerview.mas_centerX);
  442. make.centerY.equalTo(self.footerview.mas_centerY);
  443. make.width.mas_equalTo(kGXScreenWidth - 40);
  444. make.height.mas_equalTo(50);
  445. }];
  446. }
  447. return _footerview;
  448. }
  449. - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  450. _currentIndexPath = indexpath;
  451. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  452. picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  453. picker.delegate = self;
  454. picker.allowsEditing = YES;//取消白框
  455. UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  456. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  457. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  458. } choosImgBlock:^(UIImage *image) {
  459. SHOWLOADING
  460. [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
  461. NSArray *dic = responseObject;
  462. SelectImageModel *model = [[SelectImageModel alloc]initWithDictionary:dic[0] error:nil];
  463. model.image = image;
  464. if (self->_isTest == 2) {
  465. success(model);
  466. }
  467. } failure:^(NSError * _Nonnull error) {
  468. failure(error);
  469. }];
  470. }];
  471. }];
  472. [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  473. [alertvc addAction:action1];
  474. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  475. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  476. } choosImgBlock:^(UIImage *image) {
  477. SHOWLOADING
  478. [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
  479. NSArray *dic = responseObject;
  480. SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
  481. model.image = image;
  482. if (self->_isTest == 2) {
  483. success(model);
  484. }
  485. } failure:^(NSError * _Nonnull error) {
  486. failure(error);
  487. }];
  488. }];
  489. }];
  490. [alertvc addAction:action2];
  491. [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  492. UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  493. SHOWERROR(@"暂不支持,正在开发中");
  494. }];
  495. [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  496. [alertvc addAction:action3];
  497. UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  498. SHOWERROR(@"暂不支持,正在开发中");
  499. }];
  500. [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  501. [alertvc addAction:action4];
  502. UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  503. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  504. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  505. NSLog(@"%@",fileName);
  506. SHOWLOADING
  507. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  508. NSLog(@"上传成功的文件%@",responseObject);
  509. NSArray *dic = responseObject;
  510. SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
  511. if (self->_isTest) {
  512. success(model);
  513. }
  514. } failure:^(NSError * _Nonnull error) {
  515. failure(error);
  516. }];
  517. }];
  518. }];
  519. [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  520. [alertvc addAction:action5];
  521. UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  522. }];
  523. [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  524. [alertvc addAction:action6];
  525. [self presentViewController:alertvc animated:YES completion:^{}];
  526. }
  527. #pragma mark - 提交
  528. - (void)commitGonwen:(TDButton *)sender{
  529. if (self.isTest == 1) {
  530. }else{
  531. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  532. for (FormFieldsModel *model in self.viewDataArray2) {
  533. if ([model.Type isEqualToString:@"TextArea"]) {
  534. if ([model.paramString isEqualToString:@"请输入"]) {
  535. NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label];
  536. SHOWERROR(errorString);
  537. return;
  538. }
  539. }
  540. if (ISEmptyString(model.paramString)) {
  541. if (model.Required){
  542. NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label];
  543. NSLog(@"%@",model);
  544. SHOWERROR(errorString);
  545. return;
  546. }
  547. }else{
  548. if ([model.Type isEqualToString:@"TextArea"]) {
  549. [dic setValue:model.paramString forKey:@"Reasons"];
  550. }
  551. if ([model.Type isEqualToString:@"Radio"]) {
  552. [dic setValue:model.paramString forKey:@"Destination"];
  553. }
  554. if ([[dic objectForKey:@"StartDate"] length] > 0) {
  555. if ([model.Type isEqualToString:@"DateTime"]) {
  556. [dic setValue:model.paramString forKey:@"EndDate"];
  557. }
  558. }else{
  559. if ([model.Type isEqualToString:@"DateTime"]) {
  560. [dic setValue:model.paramString forKey:@"StartDate"];
  561. }
  562. }
  563. if ([model.Type isEqualToString:@"Text"]) {
  564. [dic setValue:@([model.paramString integerValue]) forKey:@"Hour"];
  565. }
  566. }
  567. }
  568. [dic setValue:@(self.carTypeId) forKey:@"TypeId"];
  569. NSLog(@"成功成功成功成功%@",dic);
  570. SHOWLOADING
  571. WS(weakSelf);
  572. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowApp_Car_Actions_Order] parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  573. REMOVESHOW
  574. SHOWSUCCESS(@"申请成功");
  575. [weakSelf.navigationController popViewControllerAnimated:YES];
  576. } failure:^(NSError * _Nonnull error) {
  577. REMOVESHOW
  578. SHOWERROR([ZYCTool handerResultData:error]);
  579. }];
  580. }
  581. }
  582. -(void)gotoAddPeople{
  583. SendInfoGroupVC *sendinfoVc = [[SendInfoGroupVC alloc] init];
  584. [self.navigationController pushViewController:sendinfoVc animated:YES];
  585. }
  586. - (BOOL)textFieldShouldReturn:(UITextField *)textField{
  587. if (_isTest == 2) {
  588. self.viewDataArray2[textField.tag].paramString = textField.text;
  589. }
  590. [textField resignFirstResponder];
  591. return YES;
  592. }
  593. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
  594. return YES;
  595. }
  596. - (void)textViewDidChange:(UITextView *)textView{
  597. if (_isTest == 2) {
  598. self.viewDataArray2[textView.tag].paramString = textView.text;
  599. }
  600. }
  601. - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
  602. if (_isTest == 2) {
  603. self.viewDataArray2[textView.tag].paramString = textView.text;
  604. }
  605. return YES;
  606. }
  607. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  608. if ([string isEqualToString:@""] || [string isEqualToString:@"\n"]) {
  609. return YES;
  610. }
  611. if(self.isTest == 2) {
  612. self.viewDataArray2[textField.tag].paramString = textField.text;
  613. }
  614. return YES;
  615. }
  616. #pragma mark - AddPictureCellDelegate
  617. - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  618. WEAKSELF
  619. [self addFile:index Sucuss:^(id _Nullable responseObject) {
  620. STRONGSELF
  621. AddPictureCell *cell = [strongSelf.myTableView cellForRowAtIndexPath:index];
  622. [cell.mycollectionView reloadData];
  623. [strongSelf.viewDataArray2[index.section].paraImage addObject:responseObject];
  624. strongSelf.viewDataArray2[index.section].paramString = @"ssas";
  625. NSLog(@"%@",strongSelf.viewDataArray2[index.section]);
  626. REMOVESHOW;
  627. } failure:^(NSError * _Nonnull error ) {
  628. REMOVESHOW;
  629. SHOWERROR([ZYCTool handerResultData:error]);
  630. }];
  631. }
  632. - (void)deletePictureWithCell:(NSIndexPath *)index SuperViewCellIndexPath:(NSIndexPath *)superIndex WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  633. [self.viewDataArray2[superIndex.section].paraImage removeObjectAtIndex:index.item];
  634. }
  635. #pragma mark - AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate
  636. - (void)addLookUpPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  637. NSLog(@"点击添加抄送人");
  638. self.isShenPinRen = NO;
  639. Department *defaltGroupSetion = [[Department alloc]init];
  640. defaltGroupSetion.Name = @"单位通讯录";
  641. defaltGroupSetion.Id = 0;
  642. Department *myGroupSetion = [[Department alloc]init];
  643. myGroupSetion.Name = @"自建通讯录";
  644. defaltGroupSetion.Id = 0;
  645. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  646. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  647. vc.isDefalutPage = 1;
  648. vc.delegate = self;
  649. [self.navigationController pushViewController:vc animated:YES];
  650. }
  651. - (void)addApprovalPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
  652. NSLog(@"点击添加抄送人");
  653. self.isShenPinRen = YES;
  654. Department *defaltGroupSetion = [[Department alloc]init];
  655. defaltGroupSetion.Name = @"单位通讯录";
  656. defaltGroupSetion.Id = 0;
  657. Department *myGroupSetion = [[Department alloc]init];
  658. myGroupSetion.Name = @"自建通讯录";
  659. defaltGroupSetion.Id = 0;
  660. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  661. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  662. vc.isDefalutPage = 1;
  663. vc.delegate = self;
  664. [self.navigationController pushViewController:vc animated:YES];
  665. }
  666. #pragma mark - 注册通知 接受抄送人和审批人数据
  667. - (void)registerNotification{
  668. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  669. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveApprovalRen:) name:NOTIFI_ApprovalRen object:nil];
  670. }
  671. - (void)recviveApprovalRen:(NSNotification *)notification{
  672. NSLog(@"审批人1%@",notification.userInfo);
  673. // SelectModel *model = [[SelectModel alloc]initWithDictionary:notification.userInfo error:nil];
  674. SelectModel * model = [[SelectModel alloc] initDict:notification.userInfo];
  675. [self.shenPiRenArr addObject:model];
  676. NSLog(@"审批人2%@",self.shenPiRenArr);
  677. [self.myTableView reloadSection:self.viewDataArray2.count withRowAnimation:UITableViewRowAnimationAutomatic];
  678. }
  679. - (void)recviveChaoSongRen:(NSNotification *)notification{
  680. if (self.isShenPinRen) {
  681. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  682. NSMutableArray <SelectModel *>* array0 = self.shenPiRenArr;
  683. NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
  684. if (array0.count == 0) {
  685. [self.shenPiRenArr addObjectsFromArray:array];
  686. }else{
  687. for (NSInteger x = 0; x < array.count; x++) {
  688. for (NSInteger y = 0 ; y<array0.count; y++) {
  689. if (array[x].UserId == array0[y].UserId) {
  690. [array1 removeObjectAtIndex:x];
  691. }
  692. }
  693. }
  694. NSLog(@"结果数据组%@",array1);
  695. [self.shenPiRenArr addObjectsFromArray:array1];
  696. }
  697. }else{
  698. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  699. NSMutableArray <SelectModel *>* array0 = self.chaoSongRenArr;
  700. NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
  701. if (array0.count == 0) {
  702. [self.chaoSongRenArr addObjectsFromArray:array];
  703. }else{
  704. for (NSInteger x = 0; x < array.count; x++) {
  705. for (NSInteger y = 0 ; y<array0.count; y++) {
  706. if (array[x].UserId == array0[y].UserId) {
  707. [array1 removeObjectAtIndex:x];
  708. }
  709. }
  710. }
  711. NSLog(@"结果数据组%@",array1);
  712. [self.chaoSongRenArr addObjectsFromArray:array1];
  713. }
  714. }
  715. [self.myTableView reloadData];
  716. }
  717. #pragma mark - setter
  718. - (NSMutableArray *)chaoSongRenArr{
  719. if (!_chaoSongRenArr) {
  720. _chaoSongRenArr = [NSMutableArray array];
  721. }
  722. return _chaoSongRenArr;
  723. }
  724. - (NSMutableArray *)shenPiRenArr{
  725. if (!_shenPiRenArr) {
  726. _shenPiRenArr = [NSMutableArray array];
  727. }
  728. return _shenPiRenArr;
  729. }
  730. - (void)dealloc
  731. {
  732. [[NSNotificationCenter defaultCenter] removeObserver:self];
  733. }
  734. @end