JOHYRWLBViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. //
  2. // JOHYRWLBViewController.m
  3. // shiku_im
  4. //
  5. // Created by 周兵 on 16/8/29.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JOHYRWLBViewController.h"
  9. #import "MJExtension.h"
  10. #import "JOXZHYRWViewController.h"
  11. #import "JOHYRWLBTableViewCell.h"
  12. #import "HandleTaskViewController.h"
  13. #import "UITableView+WFEmpty.h"
  14. @interface JOHYRWLBViewController ()<UITableViewDelegate,UITableViewDataSource>
  15. {
  16. UITableView * _tableview;
  17. UIView * _manbottomView;
  18. NSMutableArray * _dataArray;
  19. }
  20. @end
  21. @implementation JOHYRWLBViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.view.backgroundColor=[UIColor whiteColor];
  25. _manbottomView=[[UIView alloc]initWithFrame:self.view.bounds];
  26. _manbottomView.backgroundColor=Color(160,160,160,0.1);
  27. [self.view addSubview:_manbottomView];
  28. [_manbottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.top.left.right.bottom.equalTo(self.view);
  30. }];
  31. [self setNavi];
  32. // [self getHYDataFromSever];
  33. _tableview=[[UITableView alloc]initWithFrame:CGRectMake(0,0,self_width, self_height) style:UITableViewStylePlain];
  34. _tableview.delegate=self;
  35. _tableview.dataSource=self;
  36. _tableview.backgroundColor = BGKJ_COLOR;
  37. //这句代码可以去掉tableview多余分割线
  38. _tableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  39. [_manbottomView addSubview:_tableview];
  40. [_tableview mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.left.right.bottom.equalTo(_manbottomView);
  42. }];
  43. _dataArray=[[NSMutableArray alloc]init];
  44. }
  45. - (void)setNavi
  46. {
  47. //1设置title
  48. UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,80,30)];
  49. titleLabel.text = Localized(@"UU_work_OA_MM_MeetingDetail_MeetingTask");
  50. titleLabel.textColor = [UIColor whiteColor];
  51. titleLabel.font = FONT_SIZE(18);
  52. self.navigationItem.titleView=titleLabel;
  53. // UIBarButtonItem * left=[[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"oa_backView2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleBordered target:self action:@selector(backView)];
  54. // self.navigationItem.leftBarButtonItem=left;
  55. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  56. btn2.frame = CGRectMake(0, 5, 22, 22);
  57. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  58. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  59. [btn2 addSubview:image];
  60. [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
  61. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  62. self.navigationItem.leftBarButtonItems = @[bbi2];
  63. UIButton *rigntBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  64. rigntBtn.frame = CGRectMake(0, 10, 20, 20);
  65. UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"crm_main_add"]];
  66. imageView.frame = CGRectMake(0, 5, 20, 20);
  67. [rigntBtn addSubview:imageView];
  68. [rigntBtn addTarget:self action:@selector(createHYRW) forControlEvents:UIControlEventTouchUpInside];
  69. UIBarButtonItem *creatBtn = [[UIBarButtonItem alloc]initWithCustomView:rigntBtn];
  70. [self.navigationItem setRightBarButtonItem:creatBtn];
  71. self.navigationController.navigationBar.barTintColor = NB_COLOR;
  72. }
  73. - (void)viewWillAppear:(BOOL)animated
  74. {
  75. [self getHYDataFromSever];
  76. }
  77. - (void)backView
  78. {
  79. [self.navigationController popViewControllerAnimated:YES];
  80. }
  81. - (void)createHYRW
  82. {
  83. JOXZHYRWViewController * vc=[[JOXZHYRWViewController alloc]init];
  84. vc.huiyiName=self.huiyiName;
  85. vc.huiyiCode= self.huiyiCode;
  86. [self presentViewController:vc animated:YES completion:nil];
  87. }
  88. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  89. return _dataArray.count;
  90. }
  91. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  92. JOHYRWLBTableViewCell * cell=[JOHYRWLBTableViewCell cellWithTableView:tableView];
  93. cell.hyrwModel=_dataArray[indexPath.row];
  94. return cell;
  95. }
  96. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  97. {
  98. return 140;
  99. }
  100. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  101. {
  102. JOHYRWModel * model=[[JOHYRWModel alloc]init];
  103. model=_dataArray[indexPath.row];
  104. HandleTaskViewController *handleTaskViewController=[[HandleTaskViewController alloc] init];
  105. handleTaskViewController.hidesBottomBarWhenPushed=YES;
  106. /*
  107. handleTaskViewController.launchPerson=model.recorder;
  108. handleTaskViewController.acceptPerson=model.handler;
  109. handleTaskViewController.taskName=model.name;
  110. handleTaskViewController.status=model.status;
  111. handleTaskViewController.startDate=model.startdate;
  112. handleTaskViewController.endDate=model.enddate;
  113. handleTaskViewController.describ=model.descriptions;
  114. handleTaskViewController.taskcode=model.taskcode;
  115. handleTaskViewController.ra_id=model.ra_id;
  116. handleTaskViewController.taskid=model.ra_taskid;
  117. handleTaskViewController.audioIdArrayStr=@"";
  118. */
  119. handleTaskViewController.launchPerson=model.recorder;
  120. handleTaskViewController.acceptPerson=model.ra_resourcename;
  121. handleTaskViewController.taskName=model.ra_taskname;
  122. handleTaskViewController.status=model.ra_status;
  123. handleTaskViewController.startDate=model.ra_startdate;
  124. handleTaskViewController.endDate=model.ra_enddate;
  125. handleTaskViewController.describ=model.descriptions;
  126. handleTaskViewController.taskcode=model.taskcode;
  127. handleTaskViewController.ra_id=model.ra_id;
  128. handleTaskViewController.taskid=model.ra_taskid;
  129. handleTaskViewController.audioIdArrayStr=@"";
  130. //先判断是不是执行人
  131. NSString * myName = [[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
  132. if([model.resourcename rangeOfString:myName].location == NSNotFound)
  133. {
  134. //不包含
  135. handleTaskViewController.type=HandleTaskTypeForFinish1;
  136. }else{
  137. //包含
  138. handleTaskViewController.type=HandleTaskTypeForStart1;//执行人回复界面
  139. }
  140. if ([model.ra_status isEqualToString:@"待确认"])
  141. {
  142. handleTaskViewController.type=HandleTaskTypeForWaitVerify1;//提出人回复界面
  143. }
  144. if ([model.ra_status isEqualToString:@"已完成"]||[model.ra_status isEqualToString:@"已审核"])
  145. {
  146. handleTaskViewController.type=HandleTaskTypeForFinish1;
  147. }
  148. [self.navigationController pushViewController:handleTaskViewController
  149. animated:NO];
  150. }
  151. /**
  152. 获得会议任务列表
  153. */
  154. - (void)getHYDataFromSever
  155. {
  156. [_dataArray removeAllObjects];
  157. //1,创建一个网络请求管理对象
  158. UASNetworkManager *manager1 = [UASNetworkManager shareManager];
  159. manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
  160. //2,取出sessionID和IP和员工编号
  161. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  162. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  163. NSString * ips=[UASUserInfo shareManager].urlIp;
  164. //NSString * myName=[userDefault objectForKey:MY_USER_ID];
  165. NSString * myName = [[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
  166. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  167. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  168. // DLog(@"userID=%@",userID);
  169. //3.拼接sessionID
  170. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  171. //4.设置cookie
  172. [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  173. //5,接口
  174. NSString * urlAddress=@"common/datalist/data.action";
  175. //6,Caller
  176. NSString * caller=@"ResourceAssignment";
  177. //7,condition
  178. //MA_STATUSCODE='AUDITED' //1=1
  179. //NSString * condition=@"";
  180. // int page=1;
  181. // int pagesize=100;
  182. NSString *currentMaster=[[userDefault objectForKey:@"masterDic"] objectForKey:@"ma_user"];
  183. NSString *url=[@"" stringByAppendingFormat:@"%@%@",ips,urlAddress];
  184. NSDictionary * dic11 = @{
  185. @"emcode":userID,
  186. @"condition":[NSString stringWithFormat:@"(ra_resourcecode='%@' or recorder='%@') and (taskorschedule='MTask') and ra_taskname='%@%@'",userID,myName,self.huiyiName,self.huiyiCode],
  187. @"sessionId":sessionId,
  188. @"page":@"1",
  189. @"pageSize":@"100",
  190. @"caller":caller,
  191. @"currentMaster":currentMaster,
  192. @"master":master,
  193. @"sessionUser":userID,
  194. };
  195. DLog(@"url=%@",url);
  196. //7.二进制数据转换
  197. NSString *urlStringUTF8 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  198. [manager1 request:urlStringUTF8 method:GET parameters:dic11 progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  199. NSData *data=responseObject;
  200. //1,系统自带的nsjson解析数据
  201. id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  202. // NSDictionary *rootDic = responseObject;
  203. SLog(@"请求成功%@",rootDic);
  204. if ([[rootDic allKeys] containsObject:@"sessionId"]==YES)
  205. {
  206. NSString * sessionId=[NSString stringWithFormat:@"%@",[rootDic objectForKey:@"sessionId"]];
  207. [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
  208. }
  209. NSDictionary * dict=[NSDictionary changeType:rootDic];
  210. NSMutableArray * arr=[dict objectForKey:@"data"];
  211. for (int i=0; i<arr.count; i++)
  212. {
  213. NSString * str=[arr[i] objectForKey:@"description"];
  214. DLog(@"%@",str);
  215. JOHYRWModel * model=[JOHYRWModel mj_objectWithKeyValues:arr[i]];
  216. model.descriptions=str;
  217. [_dataArray addObject:model];
  218. }
  219. if (_dataArray.count == 0) {
  220. [_tableview addEmptyViewWithImageName:@"crm_all_noData" title:@""];
  221. }
  222. [_tableview reloadData];
  223. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  224. DLog(@"请求失败%@",error);
  225. // [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:@"会议任务列表获取失败,请联系管理员"];
  226. if (error.code==-1009)
  227. {
  228. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  229. }else if (error.code==-1001)
  230. {
  231. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  232. }
  233. else{
  234. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  235. }
  236. }];
  237. }
  238. @end