DocumentDetailVC.m 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  1. //
  2. // DocumentDetailVC.m
  3. // shiku_im
  4. //
  5. // Created by huangyp-pc on 16/11/25.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "DocumentDetailVC.h"
  9. #import "AFNetworking.h"
  10. #import "LYSPModel.h"
  11. #import "LYJournalBOSSCell.h"
  12. #import "DocumentListVC.h"
  13. #import "UpdateDocumentVC.h"
  14. #import "EmployeeModel.h"
  15. #import "LYYReimbursementVC.h"
  16. #import "LYYFuJianModel.h"
  17. #import "LYYReadingVC.h"
  18. #import "LYYBigImageVC.h"
  19. #import "LYYPageManyImageVC.h"
  20. #import "BusinessTravelServiceVC.h"
  21. @interface DocumentDetailVC () <UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
  22. @property (nonatomic,strong) UITableView *tableView;
  23. @property (nonatomic,strong) UIScrollView *scrollV;
  24. @property (strong , nonatomic) NSMutableArray *letterOfName;
  25. @property (strong , nonatomic) NSMutableArray *fd_dataArr;
  26. @end
  27. @implementation DocumentDetailVC
  28. {
  29. MBProgressHUD *HUD;
  30. UIView *_firstView;
  31. UIView *_secondView;
  32. int _height;
  33. NSMutableArray *_formconfigs; //第一模块属性的数组
  34. NSMutableArray *_formdata; //第一模块全部数据的数组
  35. NSMutableArray *_dataArr; //tableview的数组(审批流)
  36. UIButton *_upLoadAgain; //重新提交按钮
  37. UIButton *_deleteBtn; //删除键
  38. }
  39. - (void)viewDidLoad {
  40. [super viewDidLoad];
  41. self.title = @"详情";
  42. [self.view removeAllSubviews];
  43. _fd_dataArr = [NSMutableArray array];
  44. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  45. btn2.frame = CGRectMake(0, 5, 22, 22);
  46. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  47. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  48. [btn2 addSubview:image];
  49. [btn2 addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  50. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  51. self.navigationItem.leftBarButtonItems = @[bbi2];
  52. self.view.backgroundColor = Color(235, 233, 233, 1);
  53. NSString * companyName=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_function"];
  54. companyName=[companyName stringByReplacingOccurrencesOfString:@"(" withString:@""];
  55. companyName=[companyName stringByReplacingOccurrencesOfString:@")" withString:@""];
  56. if ([_caller isEqualToString:@"FeePlease!CCSQ!new"]) {
  57. [self setrightView];
  58. }
  59. _scrollV = [[UIScrollView alloc]init];
  60. _scrollV.showsHorizontalScrollIndicator = NO;
  61. _scrollV.showsVerticalScrollIndicator = NO;
  62. _scrollV.scrollsToTop = YES;
  63. _scrollV.backgroundColor = Color(235, 233, 233, 1);
  64. [self.view addSubview:_scrollV];
  65. [_scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.top.right.equalTo(self.view);
  67. make.bottom.equalTo(self.view).offset(-40);
  68. }];
  69. if (self.serverId.length > 0 && self.serverId != nil) {
  70. [_scrollV mas_updateConstraints:^(MASConstraintMaker *make) {
  71. make.left.top.right.equalTo(self.view);
  72. make.bottom.equalTo(self.view);
  73. }];
  74. }
  75. @weakify(self)
  76. [self selectTableNameWithtableName:companyName completed:^(NSArray *array) {
  77. @strongify(self)
  78. _letterOfName=[[NSMutableArray alloc]initWithArray:array];
  79. HUD = [[MBProgressHUD alloc]initWithView:self.view];
  80. HUD.dimBackground = YES;
  81. HUD.mode = MBProgressHUDModeIndeterminate;
  82. [HUD show:YES];
  83. [self.view addSubview:HUD];
  84. _height = 0;
  85. _formconfigs = [[NSMutableArray alloc]init];
  86. _formdata = [[NSMutableArray alloc]init];
  87. _dataArr = [[NSMutableArray alloc]init];
  88. [self buildFirstView];
  89. [self getDataFromServerWithCaller];
  90. if ((companyName==nil || [companyName isEqualToString:@""])&&self.serverId == nil)
  91. {
  92. [JOShowMessageFromNavi showDropViewWithMessage:@"ERP未登录" ToNavi:self.navigationController withColor:nil];
  93. return;
  94. }
  95. if (![_danjuStatus isEqualToString:@"已审核"] && ![_pushOrPop isEqualToString:@"push1221"]) {
  96. [self buildUnderButton];
  97. }else{
  98. CGRect frame = _scrollV.frame;
  99. frame.size.height = SCREEN_HEIGHT;
  100. _scrollV.frame=frame;
  101. }
  102. }];
  103. }
  104. -(void)setrightView{
  105. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  106. btn.frame = CGRectMake(0, 5, 60, 22);
  107. CGFloat imageY = 0;
  108. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0) {
  109. imageY = 5;
  110. }
  111. UILabel *image = [[UILabel alloc]initWithFrame:CGRectMake(0, imageY, 60, 22)];
  112. image.text = @"去预定";
  113. image.textColor = [UIColor whiteColor];
  114. [btn addSubview:image];
  115. [btn addTarget:self action:@selector(backAction11) forControlEvents:UIControlEventTouchUpInside];
  116. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn];
  117. self.navigationItem.rightBarButtonItems = @[bbi2];
  118. }
  119. - (void)backAction11{
  120. BusinessTravelServiceVC *BTvc = [BusinessTravelServiceVC new];
  121. [self.navigationController pushViewController:BTvc animated:YES];
  122. }
  123. #pragma mark--获取附件
  124. - (void)getImageData:(NSString *)str
  125. {
  126. if (self.serverId!= nil && self.serverId.length > 0) {//产城表单详情
  127. [_fd_dataArr removeAllObjects];
  128. NSString *mustString = FORMAT(@"master=%@&sessionUser=%@&emcode=%@&sessionId=%@",g_master,g_sessionUser,g_emcode,g_sessionId);
  129. NSString *urlStr = [NSString stringWithFormat:@"%@api/serve/getFilePaths.action?field=fb_attach&id=%@",ccIp,str];
  130. urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  131. UASNetworkManager *manager = [UASNetworkManager manager];
  132. manager.requestSerializer = [AFHTTPRequestSerializer serializer];
  133. manager.responseSerializer = [AFHTTPResponseSerializer serializer];
  134. [manager.requestSerializer setValue:FORMAT(@"%@",g_sessionUser) forHTTPHeaderField:@"sessionUser"];
  135. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:b2bSession]] forHTTPHeaderField:@"Cookie"];
  136. [manager request:urlStr method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  137. NSDictionary *dict = nil;
  138. if ([responseObject isKindOfClass:[NSData class]]) {
  139. dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
  140. }else{
  141. dict = responseObject;
  142. }
  143. NSArray *arr = dict[@"files"];
  144. for (NSDictionary *dic in arr) {
  145. LYYFuJianModel *model =[[LYYFuJianModel alloc] init];
  146. model.nameStr = dic[@"fp_name"];
  147. model.pathStr =dic[@"fp_path"];
  148. [_fd_dataArr addObject:model];
  149. }
  150. if (_formdata.count != 0) {
  151. [self changeShowDataUI];
  152. }
  153. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  154. if (error.code==-1009)
  155. {
  156. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  157. }else if (error.code==-1001)
  158. {
  159. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  160. }
  161. else{
  162. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  163. }
  164. }];
  165. }else{
  166. [_fd_dataArr removeAllObjects];
  167. NSString *mustString = FORMAT(@"master=%@&sessionUser=%@&emcode=%@&sessionId=%@",g_master,g_sessionUser,g_emcode,g_sessionId);
  168. [LYHTTPRequest Get:BXD_GET_IMAGE page:0 condition:str Completion:^(id ObjectData, NSError *error) {
  169. if (error == 0) {
  170. DLog(@"%@ ",ObjectData);
  171. NSArray *arr = ObjectData[@"files"];
  172. for (NSDictionary *dic in arr) {
  173. DLog(@"%@",FORMAT(@"%@common/download.action?path=%@&%@",g_id,dic[@"fp_path"],mustString));
  174. // NSURL *url = [NSURL URLWithString:FORMAT(@"%@common/download.action?path=%@",g_id,dic[@"fp_path"])];
  175. NSString *ip=[UASUserInfo shareManager].urlIp;
  176. NSString *urlStr = FORMAT(@"%@common/download.action?path=%@&%@",ip,dic[@"fp_path"],mustString);
  177. urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  178. NSURL *url = [NSURL URLWithString:urlStr];
  179. NSData *data = [NSData dataWithContentsOfURL:url];
  180. UIImage *image = [[UIImage alloc] initWithData:data];
  181. // if (image) {
  182. LYYFuJianModel *model =[[LYYFuJianModel alloc] init];
  183. model.nameStr = dic[@"fp_name"];
  184. model.image1 =image;
  185. model.pathStr =dic[@"fp_path"];
  186. [_fd_dataArr addObject:model];
  187. // }
  188. }
  189. if (_formdata.count != 0) {
  190. [self changeShowDataUI];
  191. }
  192. }else{
  193. DLog(@"%@",error);
  194. if (error.code==-1009)
  195. {
  196. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  197. }else if (error.code==-1001)
  198. {
  199. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  200. }
  201. else{
  202. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  203. }
  204. }
  205. }];
  206. }
  207. }
  208. -(void)buildFirstView
  209. {
  210. _firstView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-100)];
  211. _firstView.backgroundColor = Color(250, 249, 249, 1);
  212. [_scrollV addSubview:_firstView];
  213. UIImageView *headImageV = [[UIImageView alloc]initWithFrame:CGRectMake(10, 11, 40, 40)];
  214. headImageV.layer.cornerRadius = 4;
  215. headImageV.layer.masksToBounds = YES;
  216. [g_server getHeadImageSmall:g_server.myself.userId imageView:headImageV];
  217. // [g_server getPersonHeadImage:g_server.myself.userId imageView:headImageV];
  218. [_firstView addSubview:headImageV];
  219. DLog(@"savboaebo:%@",g_server.myself.userId);
  220. UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(headImageV.frame)+15, 11, 100, 20)];
  221. name.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
  222. name.textColor = Color(87, 87, 87, 1);
  223. name.font = FONT_SIZE(15);
  224. [_firstView addSubview:name];
  225. UILabel *depart = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(headImageV.frame)+15, CGRectGetMaxY(name.frame), 300, 20)];
  226. depart.text = [NSString stringWithFormat:@"%@ > %@",[[NSUserDefaults standardUserDefaults] stringForKey:@"personDepartment"],[[NSUserDefaults standardUserDefaults] stringForKey:@"personPosition"]];
  227. depart.textColor = Color(87, 87, 87, 1);
  228. depart.font = FONT_SIZE(12);
  229. [_firstView addSubview:depart];
  230. UIImageView *line = [[UIImageView alloc]initWithFrame:CGRectMake(5, 63.5, SCREEN_WIDTH-5, 0.5)];
  231. line.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  232. [_firstView addSubview:line];
  233. UILabel *status = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-70, 11, 60, 20)];
  234. status.text = _danjuStatus;
  235. if ([_danjuStatus isEqualToString:@"已审核"]) {
  236. status.textColor = Color(38, 133, 9, 1);
  237. }else{
  238. status.textColor = [UIColor redColor];
  239. }
  240. status.textAlignment = NSTextAlignmentRight;
  241. status.font = FONT_SIZE(12);
  242. [_firstView addSubview:status];
  243. _height += 64;
  244. }
  245. -(void)buildTableView
  246. {
  247. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_firstView.frame)+10, SCREEN_WIDTH, _dataArr.count * 60)];
  248. _tableView.delegate = self;
  249. _tableView.dataSource = self;
  250. _tableView.backgroundColor = [UIColor colorWithRed:235/255.0 green:233/255.0 blue:233/255.0 alpha:1.0];
  251. _tableView.rowHeight = 60;
  252. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  253. _tableView.showsVerticalScrollIndicator = NO;
  254. _tableView.showsHorizontalScrollIndicator = NO;
  255. _tableView.scrollEnabled = NO;
  256. [_scrollV addSubview:_tableView];
  257. _scrollV.contentSize = CGSizeMake(SCREEN_WIDTH, CGRectGetMaxY(_tableView.frame)+10);
  258. }
  259. -(void)buildUnderButton
  260. {
  261. _upLoadAgain = [UIButton buttonWithType:UIButtonTypeCustom];
  262. _upLoadAgain.backgroundColor = Color(250, 249, 249, 1);
  263. [_upLoadAgain setTitle:Localized(@"UU_work_OA_DailyWork_Resubmit") forState:UIControlStateNormal];
  264. [_upLoadAgain setTitleColor:Color(47, 149, 221, 1) forState:UIControlStateNormal];
  265. _upLoadAgain.titleLabel.font = FONT_SIZE(15);
  266. [_upLoadAgain addTarget:self action:@selector(upLoadAgainBackToView) forControlEvents:UIControlEventTouchUpInside];
  267. [self.view addSubview:_upLoadAgain];
  268. [_upLoadAgain mas_makeConstraints:^(MASConstraintMaker *make) {
  269. make.left.bottom.equalTo(self.view);
  270. make.width.mas_equalTo(self_width/2);
  271. make.height.mas_equalTo(40);
  272. }];
  273. _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  274. _deleteBtn.backgroundColor = Color(250, 249, 249, 1);
  275. [_deleteBtn setTitle:Localized(@"UU_custom_delete") forState:UIControlStateNormal];
  276. [_deleteBtn setTitleColor:Color(47, 149, 221, 1) forState:UIControlStateNormal];
  277. _deleteBtn.titleLabel.font = FONT_SIZE(15);
  278. [_deleteBtn addTarget:self action:@selector(deleteThisDataForm) forControlEvents:UIControlEventTouchUpInside];
  279. [self.view addSubview:_deleteBtn];
  280. [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  281. make.right.bottom.equalTo(self.view);
  282. make.width.mas_equalTo(self_width/2);
  283. make.height.mas_equalTo(40);
  284. }];
  285. UIView *line1 = [UIView new];
  286. line1.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  287. [_upLoadAgain addSubview:line1];
  288. UIView *line2 = [UIView new];
  289. line2.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  290. [_upLoadAgain addSubview:line2];
  291. UIView *line3 = [UIView new];
  292. line3.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  293. [_deleteBtn addSubview:line3];
  294. [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
  295. make.left.top.right.equalTo(_upLoadAgain);
  296. make.height.mas_equalTo(0.5);
  297. }];
  298. [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
  299. make.right.equalTo(_upLoadAgain);
  300. make.top.equalTo(_upLoadAgain).offset(10);
  301. make.bottom.equalTo(_upLoadAgain.mas_bottom).offset(-10);
  302. make.width.mas_equalTo(0.5);
  303. }];
  304. [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
  305. make.left.top.right.equalTo(_deleteBtn);
  306. make.height.mas_equalTo(0.5);
  307. }];
  308. if (self.serverId.length > 0 && self.serverId != nil) {
  309. _upLoadAgain.hidden = YES;
  310. _deleteBtn.hidden = YES;
  311. }
  312. }
  313. -(void)getDataFromServerWithCaller
  314. {
  315. [_formdata removeAllObjects];
  316. [_formconfigs removeAllObjects];
  317. NSString *ip = [UASUserInfo shareManager].urlIp;
  318. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  319. NSString *url = [NSString stringWithFormat:@"%@mobile/common/getformandgriddata.action?caller=%@&id=%@&sessionId=%@&isprocess=1",ip,_caller,_dan_id,sessionId];
  320. //21655,Ask4Leave
  321. UASNetworkManager *manager = [UASNetworkManager shareManager];
  322. manager.requestSerializer = [AFHTTPRequestSerializer serializer];
  323. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  324. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  325. //设置cookie
  326. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  327. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  328. if (self.serverId.length > 0 && self.serverId != nil) {
  329. url = [NSString stringWithFormat:@"%@api/serve/config.action?serve_id=%@&id=%@&sessionId=%@",ccIp,self.serverId,_dan_id,sessionId];
  330. NSString *session = [[NSUserDefaults standardUserDefaults] stringForKey:b2bSession];
  331. NSString *sessionId=[@"" stringByAppendingFormat:@"%@",session];
  332. //设置cookie
  333. [manager.requestSerializer setValue:sessionId forHTTPHeaderField:@"Cookie"];
  334. }
  335. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  336. //拼接sessionID
  337. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  338. NSString *fb_attachName;
  339. SLog(@"adfssadvfad:%@",responseObject);
  340. responseObject = [NSDictionary changeType:responseObject];
  341. NSArray *arr = responseObject[@"datas"][@"formdata"];
  342. //主表的属性数组
  343. NSMutableArray *formconfigsArr = [[NSMutableArray alloc]init];
  344. for (id obj in responseObject[@"datas"][@"formconfigs"]) {
  345. if ([[obj objectForKey:@"FD_CAPTION"] isEqualToString:@"附件"]) {
  346. fb_attachName=[obj objectForKey:@"FD_FIELD"];
  347. }
  348. NSString *isDefault = [NSString stringWithFormat:@"%@",obj[@"MFD_ISDEFAULT"]];
  349. if ([isDefault isEqualToString:@"-1"]) {
  350. [formconfigsArr addObject:obj];
  351. }
  352. }
  353. [_formconfigs addObject:formconfigsArr];
  354. //从表的属性数组
  355. NSMutableArray *gridconfigsArr = [[NSMutableArray alloc]init];
  356. for (id obj in responseObject[@"datas"][@"gridconfigs"]) {
  357. NSString *isDefault = [NSString stringWithFormat:@"%@",obj[@"MDG_ISDEFAULT"]];
  358. if ([isDefault isEqualToString:@"-1"]) {
  359. [gridconfigsArr addObject:obj];
  360. }
  361. }
  362. //主表的值数组
  363. for (id obj in responseObject[@"datas"][@"formdata"]) {
  364. [_formdata addObject:obj];
  365. }
  366. //从表的值数组
  367. for (id obj in responseObject[@"datas"][@"griddata"]) {
  368. [_formdata addObject:obj];
  369. [_formconfigs addObject:gridconfigsArr];
  370. }
  371. _formdata = [NSDictionary changeType:_formdata];
  372. _formconfigs = [NSDictionary changeType:_formconfigs];
  373. DLog(@"总的值数组:%@",_formdata);
  374. DLog(@"总的属性数组:%@",_formconfigs);
  375. NSString *fb_attach;
  376. if (arr.count != 0) {
  377. NSDictionary *dic =[NSDictionary changeType:responseObject[@"datas"][@"formdata"][0]];
  378. fb_attach = dic[fb_attachName];
  379. }else{
  380. fb_attach = @"";
  381. }
  382. #pragma mark -- 获取附件
  383. if (fb_attach.length == 0) {
  384. [HUD hide:YES];
  385. if (_formdata.count != 0) {
  386. [self changeShowDataUI];
  387. }
  388. }else{
  389. [self getImageData:fb_attach];
  390. }
  391. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  392. DLog(@"请求失败:%@",error);
  393. [HUD hide:YES];
  394. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  395. if (returnData) {
  396. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  397. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  398. DLog(@"错误的原因:%@",errorStr);
  399. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  400. }else{
  401. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  402. }
  403. }];
  404. }
  405. - (UIButton *)createFuJianLabel:(NSString *)nameStr withtag:(int)tag
  406. {
  407. UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];
  408. but.frame = CGRectMake(40, _height, self_width-80, 15);
  409. but.titleLabel.font = FONT_SIZE(12);
  410. but.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  411. // // NSDictionary *attributeDict = [NSDictionary dictionaryWithObjectsAndKeys:
  412. // [UIFont systemFontOfSize:12.0],NSFontAttributeName,
  413. // Color(47, 149, 211, 1.0),NSForegroundColorAttributeName,
  414. // NSUnderlineStyleAttributeName,NSUnderlineStyleSingle,nil];
  415. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:nameStr];
  416. NSRange strRange = {0,[str length]};
  417. [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
  418. [str addAttribute:NSForegroundColorAttributeName value:Color(47, 149, 211, 1.0) range:strRange];
  419. [str addAttribute:NSFontAttributeName value:FONT_SIZE(12) range:strRange];
  420. [but setAttributedTitle:str forState:UIControlStateNormal];
  421. but.tag = tag;
  422. [but addTarget:self action:@selector(openUrletext:) forControlEvents:UIControlEventTouchUpInside];
  423. return but;
  424. }
  425. #pragma mark -- 打开附件
  426. - (void)openUrletext:(UIButton *)sender
  427. {
  428. if (self.serverId != nil && self.serverId.length > 0) {
  429. NSMutableArray *array = [NSMutableArray array];
  430. for (int i = 0; i < _fd_dataArr.count; i++) {
  431. LYYFuJianModel *model = _fd_dataArr[i];
  432. [array addObject:model.pathStr];
  433. }
  434. NSInteger tagIndex = sender.tag -89;
  435. LYYPageManyImageVC *imageVC = [LYYPageManyImageVC new];
  436. imageVC.URLArr = array;
  437. imageVC.index = tagIndex;
  438. [self presentViewController:imageVC animated:YES completion:nil];
  439. }else{
  440. LYYReadingVC *vc1 = [[LYYReadingVC alloc] init];
  441. LYYFuJianModel *model = _fd_dataArr[sender.tag -89];
  442. LYYBigImageVC *vc = [[LYYBigImageVC alloc] init];
  443. vc.image11 = model.image1;
  444. vc.title = @"附件";
  445. vc1.title = @"附件";
  446. vc1.urlStr = model.pathStr;
  447. NSArray *arr = [model.pathStr componentsSeparatedByString:@"."];
  448. NSString *str = [arr lastObject];
  449. if ([str isEqualToString:@"png"] || [str isEqualToString:@"jpg"] ||[str isEqualToString:@"jpeg"]) {
  450. [self.navigationController pushViewController:vc animated:YES];
  451. }else
  452. [self.navigationController pushViewController:vc1 animated:YES];
  453. }
  454. }
  455. -(void)changeShowDataUI
  456. {
  457. for (int i = 0; i<_formconfigs.count; i++) {
  458. // DLog(@"aaaa:%@",_formconfigs[i]);
  459. if (i == 0) {
  460. NSArray *a = _formconfigs[i];
  461. NSDictionary *b = _formdata[i];
  462. for (int j = 0; j < a.count; j++) {
  463. NSDictionary *c = a[j];
  464. NSString *upStr = [c objectForKey:@"FD_FIELD"];
  465. // upStr = [upStr uppercaseString];
  466. NSString *str11;
  467. if ([FORMAT(@"%@",[c objectForKey:@"FD_CAPTION"]) isEqualToString:@"报销总额"]) {
  468. str11 =[NSString getkCFNumberFormatterCurrencyStyle:[NSString stringWithFormat:@"%.2f",[[b objectForKey:upStr] doubleValue]]] ;
  469. }
  470. else{
  471. str11 = [NSString stringWithFormat:@"%@",[b objectForKey:upStr]];
  472. }
  473. UILabel *rightLbl = [self creatRightLabelWithHeight:j text:str11];
  474. [_firstView addSubview:rightLbl];
  475. CGSize size = [self getSizeWithText:[NSString stringWithFormat:@"%@",str11]];
  476. CGSize size1 = [self getleftWithText:[c objectForKey:@"FD_CAPTION"]];
  477. UILabel *letfLbl = [self creatLeftLabelWithHeight:j text:[c objectForKey:@"FD_CAPTION"] withHeight:size.height+5];
  478. [_firstView addSubview:letfLbl];
  479. if (size.height < size1.height) {
  480. letfLbl.height = size1.height;
  481. _height += size1.height+5;
  482. }else{
  483. _height += size.height+5;
  484. }
  485. }
  486. }
  487. else{
  488. UIImageView *line = [[UIImageView alloc]initWithFrame:CGRectMake(5, _height, SCREEN_WIDTH-5, 0.5)];
  489. line.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  490. [_firstView addSubview:line];
  491. UILabel *title = [self creatDetailLabelWithText:[NSString stringWithFormat:@"明细"]];
  492. [_firstView addSubview:title];
  493. _height += 30;
  494. NSArray *a = _formconfigs[i];
  495. NSDictionary *b = @{};
  496. if (_formdata.count > i) {
  497. b = _formdata[i];
  498. }
  499. for (int j = 0; j < a.count; j++) {
  500. NSDictionary *c = a[j];
  501. NSString *upStr = [c objectForKey:@"DG_FIELD"];
  502. //
  503. NSString *str;
  504. // if([_caller isEqualToString:URL_REIMBURSEMENT_CALLER] && j == 1)
  505. // {
  506. // str =[NSString getkCFNumberFormatterCurrencyStyle:FORMAT(@"%.2f",[[b objectForKey:upStr] doubleValue]]);
  507. //
  508. // }else{
  509. str = [b objectForKey:upStr];
  510. // }
  511. upStr = [upStr uppercaseString];
  512. UILabel *rightLbl = [self creatRightLabelWithHeight:j text:str];
  513. [_firstView addSubview:rightLbl];
  514. // rightLbl.numberOfLines = 1;
  515. CGSize size = [self getSizeWithText:[NSString stringWithFormat:@"%@",str]];
  516. SLog(@"这是什么东:%f -- %@",size.height,str);
  517. CGSize size1 = [self getleftWithText:[c objectForKey:@"DG_CAPTION"]];
  518. UILabel *letfLbl = [self creatLeftLabelWithHeight:j text:[c objectForKey:@"DG_CAPTION"] withHeight:size.height+5];
  519. [_firstView addSubview:letfLbl];
  520. if (size.height < size1.height) {
  521. letfLbl.height = size1.height;
  522. _height += size1.height+5;
  523. }else{
  524. _height += size.height+5;
  525. }
  526. }
  527. }
  528. }
  529. if (_fd_dataArr.count != 0)
  530. {
  531. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, _height, self_width, 10)];
  532. view.backgroundColor = BGB_COLOR;
  533. [_firstView addSubview:view];
  534. _height += 10;
  535. [_firstView addSubview:[self creatDetailLabelWithText:[NSString stringWithFormat:@"附件"]]];
  536. _height += 30;
  537. int i = 88;
  538. for(LYYFuJianModel *model in _fd_dataArr)
  539. {
  540. i ++;
  541. [_firstView addSubview:[self createFuJianLabel:model.nameStr withtag:i]];
  542. _height += 20;
  543. }
  544. }
  545. CGRect frame = _firstView.frame;
  546. frame.size.height = _height;
  547. _firstView.frame=frame;
  548. _scrollV.contentSize = frame.size;
  549. CGRect frame1 = _tableView.frame;
  550. frame1.origin.y = CGRectGetMaxY(_firstView.frame) + 10;
  551. _tableView.frame = frame1;
  552. [self getShenPiLiuDataFromServer];
  553. }
  554. -(void)getShenPiLiuDataFromServer
  555. {
  556. if (self.serverId!= nil && self.serverId.length > 0) {
  557. [_dataArr removeAllObjects];
  558. NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:b2bSession];
  559. NSString *url = [NSString stringWithFormat:@"%@api/serve/getProcesses.action?serve_id=%@&id=%@&client_type=cc",ccIp,self.serverId,_dan_id];
  560. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  561. UASNetworkManager *manager = [UASNetworkManager shareManager];
  562. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  563. DLog(@"%@",url);
  564. //拼接sessionID
  565. NSString *paramSessionId=[@"" stringByAppendingFormat:@"%@",sessionId];
  566. //设置cookie
  567. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  568. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  569. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  570. [HUD hide:YES];
  571. NSDictionary *dict = nil;
  572. if([responseObject isKindOfClass:[NSData class]]){
  573. dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
  574. }else{
  575. dict = responseObject;
  576. }
  577. if(![dict[@"success"] boolValue]){
  578. return;
  579. }
  580. NSDictionary *dic11 = [NSDictionary changeType:dict];
  581. NSArray *arr = [dic11 objectForKey:@"process"];
  582. for(int i = (arr.count - 1); i>=0;i--){
  583. NSDictionary *dic = arr[i];
  584. LYSPModel *model = [[LYSPModel alloc] init];
  585. model.jp_launchTime = dic[@"time"];
  586. model.jp_nodeDealManName = dic[@"status"];
  587. if((![model.jp_launchTime isKindOfClass:[NSNull class]]) && model.jp_launchTime.length > 0 ){
  588. model.jp_status = @"已通过";
  589. }
  590. [_dataArr addObject:model];
  591. }
  592. if (_dataArr.count != 0) {
  593. [self buildTableView];
  594. }
  595. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  596. [HUD hide:YES];
  597. if (error.code==-1009)
  598. {
  599. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  600. }else if (error.code==-1001)
  601. {
  602. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  603. }
  604. else{
  605. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  606. }
  607. }];
  608. }else{
  609. [_dataArr removeAllObjects];
  610. NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  611. NSString *ip=[UASUserInfo shareManager].urlIp;
  612. NSString *url = [NSString stringWithFormat:@"%@common/getCurrentJnodes.action?master=%@&sessionUser=%@&emcode=%@&caller=%@&sessionId=%@&keyValue=%@&_noc=1",ip,g_master,g_sessionUser,[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"],_caller,sessionId,_dan_id];
  613. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  614. UASNetworkManager *manager = [UASNetworkManager shareManager];
  615. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  616. DLog(@"%@",url);
  617. //拼接sessionID
  618. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  619. //设置cookie
  620. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  621. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  622. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  623. [HUD hide:YES];
  624. NSDictionary *dic11 = [NSDictionary changeType:responseObject];
  625. SLog(@"审批流数据:%@",dic11);
  626. NSArray *arr = [dic11 objectForKey:@"data"];
  627. NSArray *arr1 = [dic11 objectForKey:@"processs"];
  628. NSArray *arr2 = [dic11 objectForKey:@"nodes"];
  629. for (int i = 0; i < arr.count; i ++) {
  630. NSDictionary *dic = arr[i];
  631. LYSPModel *model = [[LYSPModel alloc] init];
  632. model.JP_NODEDEALMAN = dic[@"JP_NODEDEALMAN"];
  633. model.JP_NODEDEALMANNAME = dic[@"JP_NODEDEALMANNAME"];
  634. model.JP_ID = dic[@"JP_ID"];
  635. model.JP_NODENAME = dic[@"JP_NODENAME"];
  636. model.jn_dealManName = @"";
  637. model.jp_nodeDealMan = @"";
  638. NSInteger jja = 999;
  639. for (NSInteger j = 0; j < _dataArr.count; j ++) {
  640. LYSPModel *model1 = _dataArr[j];
  641. if ([model1.jp_status isEqualToString:@"待审批"]) {
  642. jja = j;
  643. }
  644. }
  645. // LYSPModel *model = _dataArr[i];
  646. if (arr1.count >= i +1) {
  647. for (NSInteger i = 0; i < arr1.count; i ++) {
  648. NSDictionary *dic12 = arr1[i];
  649. if ([model.JP_NODENAME isEqualToString:dic12[@"jp_nodeName"]]) {
  650. NSString *str1 =[dic12 objectForKey:@"jp_status"];
  651. if (str1.length >0) {
  652. if ([[dic12 objectForKey:@"jp_status"] isEqualToString:@"待审批"]) {
  653. model.jp_status = [dic12 objectForKey:@"jp_status"];
  654. }
  655. model.jp_nodeDealMan = [dic12 objectForKey:@"jp_nodeDealMan"];
  656. model.jp_nodeDealManName = [dic12 objectForKey:@"jp_nodeDealManName"];
  657. model.jp_launchTime = [NSString timeWithTimeIntervalString:[dic12 objectForKey:@"jp_launchTime"] geshi:@"yyyy-MM-dd HH:mm"];
  658. }
  659. }
  660. }
  661. }
  662. if (![model.jp_status isEqualToString:@"待审批"] && jja >= i) {
  663. if (arr2.count >= i+1) {
  664. for (NSInteger j = 0; j <arr2.count; j ++) {
  665. DLog(@"%@ %@",model.jp_nodeDealMan,[arr2[j] objectForKey:@"jn_dealManId"] );
  666. if ( [model.JP_NODENAME isEqualToString:[arr2[j] objectForKey:@"jn_name"]] && ![[arr2[j] objectForKey:@"jn_dealResult"] isEqualToString:@"变更处理人"]) {
  667. NSString * str2 =[arr2[j] objectForKey:@"jn_dealTime"];
  668. if (str2.length > 0) {
  669. model.jn_dealTime = [arr2[j] objectForKey:@"jn_dealTime"];
  670. model.jn_dealManName = [arr2[j] objectForKey:@"jn_dealManName"];
  671. model.jn_nodeDescription = [arr2[j] objectForKey:@"jn_nodeDescription"];
  672. model.jn_dealManId = [arr2[j] objectForKey:@"jn_dealManId"];
  673. model.jp_status = [arr2[j] objectForKey:@"jn_dealResult"];
  674. }
  675. }
  676. }
  677. }
  678. }
  679. //判断是否是单个人审批 如过不是取第一个“,”之前的数据
  680. NSString *dealman;
  681. /*当多人审核没有审核时,显示为第一个人头像*/
  682. if (model.jp_nodeDealMan.length != 0) {
  683. dealman = model.jp_nodeDealMan;
  684. }else if ([model.JP_NODEDEALMAN containsString:@","]){
  685. NSArray *arr = [FORMAT(@"%@",model.JP_NODEDEALMAN) componentsSeparatedByString:@","];
  686. dealman = arr[0];
  687. }else{
  688. dealman = model.JP_NODEDEALMAN;
  689. }
  690. // SLog(@"adada:%@",dealman);
  691. for (EmployeeModel *model1 in _letterOfName) {
  692. if ([dealman isEqualToString:model1.em_code]) {
  693. model.im_id = model1.em_imid;
  694. }
  695. }
  696. [_dataArr addObject:model];
  697. }
  698. if (_dataArr.count != 0) {
  699. [self buildTableView];
  700. }
  701. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  702. [HUD hide:YES];
  703. if (error.code==-1009)
  704. {
  705. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  706. }else if (error.code==-1001)
  707. {
  708. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  709. }
  710. else{
  711. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  712. }
  713. }];
  714. }
  715. }
  716. #pragma mark -- UITableViewDelegate / DataSource
  717. // 每组多少行
  718. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  719. {
  720. return _dataArr.count;
  721. }
  722. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  723. {
  724. if (self.serverId.length > 0 && self.serverId != nil) {
  725. LYJournalBOSSCell *cell = [LYJournalBOSSCell cellWithTableView:tableView];
  726. LYSPModel *model = _dataArr[indexPath.row];
  727. cell.ccModel = model;
  728. if (_dataArr.count-1-indexPath.row == 0) {
  729. cell.yesshouge = YES;
  730. }
  731. else{
  732. cell.yesshouge = NO;
  733. }
  734. if (_dataArr.count-1-indexPath.row == _dataArr.count -1) {
  735. cell.yesmowei = YES;
  736. }
  737. else{
  738. cell.yesmowei = NO;
  739. }
  740. return cell;
  741. }else{
  742. LYJournalBOSSCell *cell = [LYJournalBOSSCell cellWithTableView:tableView];
  743. LYSPModel *model = _dataArr[indexPath.row];
  744. if (model.jp_status.length > 0) {
  745. cell.str111 = model.jp_status;
  746. }
  747. if (_dataArr.count == 1) {
  748. cell.sttr11 = @"待审批";
  749. }
  750. if (_dataArr.count-1-indexPath.row == 0) {
  751. cell.yesshouge = YES;
  752. }
  753. else{
  754. cell.yesshouge = NO;
  755. }
  756. if (_dataArr.count-1-indexPath.row == _dataArr.count -1) {
  757. cell.yesmowei = YES;
  758. }
  759. else{
  760. cell.yesmowei = NO;
  761. }
  762. cell.model = _dataArr[_dataArr.count-1-indexPath.row];
  763. cell.backgroundColor = Color(250, 249, 249, 1.0);
  764. return cell;
  765. }
  766. }
  767. -(UILabel *)creatLeftLabelWithHeight:(int)hang text:(NSString *)text withHeight:(float)high
  768. {
  769. UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(10, _height, 90, high)];
  770. lbl.textColor = Color(87, 87, 87, 1);
  771. if ([text isKindOfClass:[NSNull class]]) {
  772. text = @"";
  773. }
  774. lbl.numberOfLines = 0;
  775. lbl.text = text;
  776. lbl.font = FONT_SIZE(12);
  777. return lbl;
  778. }
  779. -(UILabel *)creatRightLabelWithHeight:(int)hang text:(NSString *)text
  780. {
  781. CGSize size = [self getSizeWithText:text];
  782. UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(100, _height, size.width, size.height+5)];
  783. lbl.textColor = Color(150, 149, 149, 1);
  784. if ([FORMAT(@"%@",text) isEqualToString:@"(null)"]) {
  785. text = @"";
  786. }
  787. lbl.text = FORMAT(@"%@",text);
  788. lbl.font = FONT_SIZE(12);
  789. lbl.numberOfLines = 0;
  790. SLog(@"anivbr:%f",size.height);
  791. return lbl;
  792. }
  793. -(UILabel *)creatDetailLabelWithText:(NSString *)text
  794. {
  795. UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(10, _height, SCREEN_WIDTH-10, 30)];
  796. lbl.textColor = Color(250, 85, 4, 1);
  797. if ([text isEqualToString:@"(null)"]) {
  798. text = @"";
  799. }
  800. lbl.text = text;
  801. lbl.font = FONT_SIZE(14);
  802. return lbl;
  803. }
  804. //自动获取文本高度
  805. - (CGSize)getSizeWithText:(NSString *)text
  806. {
  807. /**
  808. 参数1:Size 文本显示的最大区域
  809. 参数2:options 用什么来的换行模式来计算
  810. 参数3:attributes 文字的大小
  811. 参数4:context 上下文
  812. */
  813. return [FORMAT(@"%@",text) boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 100, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : FONT_SIZE(12)} context:NULL].size;
  814. }
  815. - (CGSize)getleftWithText:(NSString *)text
  816. {
  817. /**
  818. 参数1:Size 文本显示的最大区域
  819. 参数2:options 用什么来的换行模式来计算
  820. 参数3:attributes 文字的大小
  821. 参数4:context 上下文
  822. */
  823. return [FORMAT(@"%@",text) boundingRectWithSize:CGSizeMake(90, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : FONT_SIZE(12)} context:NULL].size;
  824. }
  825. -(void)backAction
  826. {
  827. if ([_pushOrPop isEqualToString:@"push"]) {
  828. DocumentListVC *listVC = [[DocumentListVC alloc]init];
  829. listVC.serveId = self.serverId;
  830. if(self.nameStr){
  831. listVC.nameStr = self.nameStr;
  832. }
  833. listVC.caller = _caller;
  834. listVC.pushOrPop = @"push";
  835. [self.navigationController pushViewController:listVC animated:YES];
  836. }
  837. else{
  838. if ([_pushOrPop isEqualToString:@"customer"]) {
  839. if (self.navigationController.childViewControllers.count > 1) {
  840. [self.navigationController popToViewController:self.navigationController.childViewControllers[1] animated:YES];
  841. }else{
  842. [self.navigationController popViewControllerAnimated:YES];
  843. }
  844. }else{
  845. [self.navigationController popViewControllerAnimated:YES];
  846. }
  847. }
  848. }
  849. -(void)upLoadAgainBackToView
  850. {
  851. [HUD show:YES];
  852. //重新提交需要清除审批流和更改单据状态
  853. NSString *ip = [UASUserInfo shareManager].urlIp;
  854. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  855. NSString *url = [NSString stringWithFormat:@"%@mobile/commonres.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId];
  856. if ([_caller isEqualToString:@"ExtraWork$"]) {
  857. url = FORMAT(@"%@hr/attendance/resSubmitExtraWork.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId);
  858. }else if ([_caller isEqualToString:URL_REIMBURSEMENT_CALLER])
  859. {
  860. url = FORMAT(@"%@oa/fee/resSubmitFeePlease.action?caller=%@&id=%@",ip,_caller,_dan_id);
  861. }
  862. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  863. UASNetworkManager *manager = [UASNetworkManager shareManager];
  864. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  865. //拼接sessionID
  866. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  867. //设置cookie
  868. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  869. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  870. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  871. [HUD hide:YES];
  872. if ([_caller isEqualToString:URL_REIMBURSEMENT_CALLER]) {
  873. LYYReimbursementVC *vc = (LYYReimbursementVC *)[self.navigationController.viewControllers objectAtIndex:2];
  874. if(![vc isKindOfClass:[LYYReimbursementVC class]]){
  875. vc = (LYYReimbursementVC *)[self.navigationController.viewControllers objectAtIndex:1];
  876. }
  877. vc.mobile_id = FORMAT(@"%@",self.dan_id);
  878. vc.nameLabel = @"";
  879. [self.navigationController popToViewController:vc animated:YES];
  880. }else{
  881. DLog(@"adfssadvfad:%@",responseObject);
  882. [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshDocumenDanJuList" object:nil];
  883. UpdateDocumentVC *updateVC = [[UpdateDocumentVC alloc]init];
  884. updateVC.listid = _dan_id;
  885. updateVC.caller = _caller;
  886. updateVC.howManyPush = @"2";
  887. updateVC.nameStr = @"更新";
  888. updateVC.cModel = _cModel;
  889. if ([_pushOrPop isEqualToString:@"push"]) {
  890. updateVC.howManyPush = @"3";
  891. }
  892. updateVC.block = ^{
  893. [_firstView removeFromSuperview];
  894. [_tableView removeFromSuperview];
  895. _height = 0;
  896. [self buildFirstView];
  897. [self getDataFromServerWithCaller];
  898. };
  899. [self.navigationController pushViewController:updateVC animated:YES];
  900. }
  901. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  902. DLog(@"请求失败:%@",error);
  903. [HUD hide:YES];
  904. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  905. if (returnData) {
  906. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  907. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  908. DLog(@"错误的原因:%@",errorStr);
  909. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  910. }
  911. else{
  912. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  913. }
  914. }];
  915. }
  916. - (void)backView1
  917. {
  918. LYYReimbursementVC *vc = (LYYReimbursementVC *)[self.navigationController.viewControllers objectAtIndex:2];
  919. if(![vc isKindOfClass:[LYYReimbursementVC class]]){
  920. vc = (LYYReimbursementVC *)[self.navigationController.viewControllers objectAtIndex:1];
  921. }
  922. vc.mobile_id = _dan_id;
  923. [self.navigationController popToViewController:vc animated:YES];
  924. }
  925. -(void)deleteThisDataForm //考勤单据删除之前,调用了反提交接口
  926. {
  927. [UASAlertView showWithTitle:nil content:@"确认删除该条单据?" sureTitle:Localized(@"UU_custom_sure") cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
  928. if (index == 2) {
  929. [HUD show:YES];
  930. NSString *ip = [UASUserInfo shareManager].urlIp;
  931. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  932. NSString *url = [NSString stringWithFormat:@"%@mobile/commonres.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId];
  933. if ([_caller isEqualToString:@"ExtraWork$"]) {
  934. url = FORMAT(@"%@hr/attendance/resSubmitExtraWork.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId);
  935. }else if ([_caller isEqualToString:URL_REIMBURSEMENT_CALLER])
  936. {
  937. url = FORMAT(@"%@oa/fee/resSubmitFeePlease.action?caller=%@&id=%@",ip,_caller,_dan_id);
  938. }
  939. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  940. UASNetworkManager *manager = [UASNetworkManager shareManager];
  941. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  942. //拼接sessionID
  943. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  944. //设置cookie
  945. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  946. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  947. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  948. [self deleteDataToServer];
  949. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  950. DLog(@"请求失败:%@",error);
  951. [HUD hide:YES];
  952. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  953. if (returnData) {
  954. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  955. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  956. DLog(@"错误的原因:%@",errorStr);
  957. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  958. }
  959. else{
  960. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  961. }
  962. }];
  963. }
  964. }];
  965. }
  966. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  967. {
  968. DLog(@"扫vbaov:%ld",(long)buttonIndex);
  969. if (buttonIndex == 1) {
  970. [HUD show:YES];
  971. NSString *ip = [UASUserInfo shareManager].urlIp;
  972. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  973. NSString *url = [NSString stringWithFormat:@"%@mobile/commonres.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId];
  974. if ([_caller isEqualToString:@"ExtraWork$"]) {
  975. url = FORMAT(@"%@hr/attendance/resSubmitExtraWork.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId);
  976. }else if ([_caller isEqualToString:URL_REIMBURSEMENT_CALLER])
  977. {
  978. url = FORMAT(@"%@oa/fee/resSubmitFeePlease.action?caller=%@&id=%@",ip,_caller,_dan_id);
  979. }
  980. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  981. UASNetworkManager *manager = [UASNetworkManager shareManager];
  982. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  983. //拼接sessionID
  984. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  985. //设置cookie
  986. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  987. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  988. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  989. [self deleteDataToServer];
  990. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  991. DLog(@"请求失败:%@",error);
  992. [HUD hide:YES];
  993. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  994. if (returnData) {
  995. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  996. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  997. DLog(@"错误的原因:%@",errorStr);
  998. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  999. }
  1000. else{
  1001. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  1002. }
  1003. }];
  1004. }
  1005. }
  1006. -(void)deleteDataToServer //删除单据
  1007. {
  1008. NSString *ip = [UASUserInfo shareManager].urlIp;
  1009. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  1010. NSString *url = [NSString stringWithFormat:@"%@mobile/commondelete.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId];
  1011. if ([_caller isEqualToString:@"ExtraWork$"]) {
  1012. url = FORMAT(@"%@hr/attendance/deleteExtraWork.action?caller=%@&id=%@&sessionId=%@",ip,_caller,_dan_id,sessionId);
  1013. }else if ([_caller isEqualToString:URL_REIMBURSEMENT_PSOT])
  1014. {
  1015. url = FORMAT(@"%@/oa/fee/deleteFeePlease.action?caller=%@&id=%@",ip,URL_REIMBURSEMENT_CALLER,_dan_id);
  1016. }
  1017. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  1018. UASNetworkManager *manager = [UASNetworkManager shareManager];
  1019. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  1020. //拼接sessionID
  1021. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  1022. //设置cookie
  1023. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  1024. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  1025. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  1026. [HUD hide:YES];
  1027. DLog(@"adfssadvfad:%@",responseObject);
  1028. if ([_pushOrPop isEqualToString:@"push"]) {
  1029. DocumentListVC *listVC = [[DocumentListVC alloc]init];
  1030. listVC.caller = _caller;
  1031. listVC.pushOrPop = @"push";
  1032. listVC.cModel = _cModel;
  1033. [self.navigationController pushViewController:listVC animated:YES];
  1034. }
  1035. else if ([_pushOrPop isEqualToString:@"pop"]) {
  1036. if (self.block) {
  1037. self.block();
  1038. }
  1039. if (self.scheduleBlock) {
  1040. self.scheduleBlock();
  1041. }
  1042. [self.navigationController popViewControllerAnimated:YES];
  1043. }
  1044. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  1045. DLog(@"请求失败:%@",error);
  1046. [HUD hide:YES];
  1047. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  1048. if (returnData) {
  1049. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  1050. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  1051. DLog(@"错误的原因:%@",errorStr);
  1052. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  1053. }
  1054. else{
  1055. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  1056. }
  1057. }];
  1058. }
  1059. -(void)selectTableNameWithtableName:(NSString *)tableName completed:(completedBlock)completed{
  1060. [[TIFmdbManager shareManager] createOrOpenDatabasaWithDbName:TONGXUNLUDATA completed:^(BOOL result) {
  1061. if(result){
  1062. NSMutableArray *dataArr = [NSMutableArray new];
  1063. [[TIFmdbManager shareManager] executeWithDb:TONGXUNLUDATA excuteDbBlock:^(FMDatabase *db) {
  1064. NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@",tableName];
  1065. FMResultSet *rs = [db executeQuery:sql];
  1066. while ([rs next])
  1067. {
  1068. EmployeeModel *model = [[EmployeeModel alloc] init];
  1069. model.em_name = [rs stringForColumn:_em_name];
  1070. model.em_code = [rs stringForColumn:_em_code];
  1071. model.em_imid = [[rs stringForColumn:_em_imid] integerValue];
  1072. [dataArr addObject:model];
  1073. }
  1074. } completed:^{
  1075. if(completed){
  1076. completed(dataArr);
  1077. }
  1078. }];
  1079. }
  1080. }];
  1081. }
  1082. - (void)didReceiveMemoryWarning {
  1083. [super didReceiveMemoryWarning];
  1084. // Dispose of any resources that can be recreated.
  1085. }
  1086. @end