JOHYQDXQViewController.m 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. //
  2. // JOHYQDXQViewController.m
  3. // shiku_im
  4. //
  5. // Created by 周兵 on 16/7/28.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JOHYQDXQViewController.h"
  9. #import "SegmentTapView.h"
  10. #import "UITableView+WFEmpty.h"
  11. @interface JOHYQDXQViewController ()<SegmentTapViewDelegate,UITableViewDataSource,UITableViewDelegate>
  12. {
  13. NSMutableArray * _qiandaole;
  14. NSMutableArray * _meiqiandao;
  15. NSMutableArray * _zhonjian;
  16. }
  17. @property (nonatomic, strong)SegmentTapView *segment;
  18. @property (nonatomic, strong)UITableView * tableView;
  19. @end
  20. @implementation JOHYQDXQViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. CGFloat height = 0;
  24. if (statusX) {
  25. height = 24;
  26. }
  27. self.view.backgroundColor=[UIColor whiteColor];
  28. _qiandaole=[[NSMutableArray alloc]init];
  29. _meiqiandao=[[NSMutableArray alloc]init];
  30. _zhonjian=[[NSMutableArray alloc]init];
  31. self.segment = [[SegmentTapView alloc] initWithFrame:CGRectMake(0,height, self_width, 40) withDataArray:[NSArray arrayWithObjects:Localized(@"UU_work_OA_MM_MeetingDetail_SignedIn"),Localized(@"UU_work_OA_MM_MeetingDetail_NoSignIn"), nil] withFont:15];
  32. self.segment.delegate = self;
  33. self.segment.lineColor = HexColor(@"#1084D1");
  34. self.segment.textSelectedColor = HexColor(@"#1084D1");
  35. self.segment.textNomalColor = [UIColor blackColor];
  36. self.segment.btnColor = BGKJ_COLOR;
  37. self.segment.selectIndex=1;
  38. [self.view addSubview:self.segment];
  39. UIImageView *line = [[UIImageView alloc]initWithFrame:CGRectMake(self_width/2, 10, 1, 20)];
  40. line.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.2];
  41. [self.segment addSubview:line];
  42. [self setNavi];
  43. [self getcanhuiranyuan];
  44. self.tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 104+height,self_width,self_height-104-height) style:UITableViewStylePlain];
  45. self.tableView.delegate=self;
  46. self.tableView.dataSource=self;
  47. [self.view addSubview:self.tableView];
  48. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.bottom.right.equalTo(self.view);
  50. make.top.equalTo(self.segment.mas_bottom);
  51. }];
  52. //这句代码可以去掉tableview多余分割线
  53. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  54. }
  55. - (void)selectedIndex:(NSInteger)index
  56. {
  57. DLog(@"选了第几个%ld",(long)index);
  58. if (index==1)
  59. {
  60. _zhonjian=_meiqiandao;
  61. }else if (index==0)
  62. {
  63. _zhonjian=_qiandaole;
  64. }
  65. [self.tableView reloadData];
  66. }
  67. - (void)backView
  68. {
  69. [self.navigationController popViewControllerAnimated:YES];
  70. }
  71. - (void)setNavi
  72. {
  73. //1设置title
  74. UILabel * titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,80,30)];
  75. titleLabel.text=Localized(@"UU_work_OA_MM_MeetingDetail_ConferencePunch");
  76. titleLabel.textColor=[UIColor whiteColor];
  77. self.navigationItem.titleView=titleLabel;
  78. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  79. btn2.frame = CGRectMake(0, 5, 22, 22);
  80. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  81. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  82. [btn2 addSubview:image];
  83. [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
  84. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  85. self.navigationItem.leftBarButtonItems = @[bbi2];
  86. self.navigationController.navigationBar.barTintColor = NB_COLOR;
  87. }
  88. /**获取参会人员*/
  89. - (void)getcanhuiranyuan
  90. {
  91. //1,创建一个网络请求管理对象
  92. UASNetworkManager *manager1 = [UASNetworkManager shareManager];
  93. manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
  94. //2,取出sessionID和IP
  95. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  96. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  97. NSString * ips=[UASUserInfo shareManager].urlIp;
  98. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  99. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  100. //3.拼接sessionID
  101. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  102. //4.设置cookie
  103. [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  104. //5,接口http://218.17.158.219:8090/ERP//mobile/crm/getMeetingDetailParticipants.action
  105. NSString * urlAddress=@"mobile/crm/getMeetingDetailParticipants.action";
  106. //6,Caller
  107. NSString * caller=@"Meetingroomapply";
  108. //formCondition=ma_id=
  109. NSString *url=[@"" stringByAppendingFormat:@"%@%@?caller=%@&formCondition=ma_id=%@&sessionId=%@&emcode=%@&gridCondition=ma_id=%@&ma_code=%@&master=%@&sessionUser=%@",ips,urlAddress,caller,_huiyiID,sessionId,userID,_huiyiID,_huiyiID,master,userID];
  110. DLog(@"url=%@",url);
  111. //7.二进制数据转换
  112. NSString *urlStringUTF8 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  113. [manager1 request:urlStringUTF8 method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  114. NSData *data = responseObject;
  115. //1,系统自带的nsjson解析数据
  116. id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  117. DLog(@"请求参会人员成功:%@",rootDic);
  118. if ([[rootDic allKeys] containsObject:@"sessionId"]==YES)
  119. {
  120. NSString * sessionId=[NSString stringWithFormat:@"%@",[rootDic objectForKey:@"sessionId"]];
  121. [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
  122. }
  123. NSDictionary * dict=[NSDictionary dictionary];
  124. dict=[rootDic objectForKey:@"participants"];
  125. NSDictionary * dicts=[NSDictionary changeType:dict];
  126. /**
  127. "EM_CODE" = L00010102002;
  128. "EM_DEFAULTHSNAME" = "\U4eba\U4e8b\U4e13\U5458";
  129. "EM_DEPART" = "\U4eba\U4e8b\U79d1";
  130. "EM_NAME" = "\U5218\U6770";
  131. */
  132. _qiandaole=[dicts objectForKey:@"confirmed"];
  133. _meiqiandao=[dicts objectForKey:@"unconfirmed"];
  134. // for (int i=0; i<_meiqiandao.count; i++)
  135. // {
  136. // DLog(@"%@ %@ %@",[_meiqiandao[i] objectForKey:@"EM_DEFAULTHSNAME"],[_meiqiandao[i] objectForKey:@"EM_DEPART"],[_meiqiandao[i] objectForKey:@"EM_NAME"]);
  137. // }
  138. _zhonjian=_qiandaole;
  139. if (_zhonjian.count == 0) {
  140. [self.tableView addEmptyViewWithImageName:@"crm_all_noData" title:nil];
  141. }
  142. [self.tableView reloadData];
  143. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  144. [self.tableView addEmptyViewWithImageName:@"crm_all_noData" title:nil];
  145. DLog(@"什么错误呀==%@",error);
  146. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:Localized(@"UU_work_OA_MM_MeetingDetail_title1")];
  147. }];
  148. }
  149. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  150. return _zhonjian.count;
  151. }
  152. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  153. static NSString * ID =@"JOBOR";
  154. UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:ID];
  155. cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  156. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  157. self.tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
  158. UILabel * label=[[UILabel alloc]init];
  159. label.frame=CGRectMake(15,5,100,20);
  160. label.font=FONT_SIZE(17);
  161. label.textColor=[UIColor blackColor];
  162. label.text=[_zhonjian[indexPath.row] objectForKey:@"EM_NAME"];
  163. [cell.contentView addSubview:label];
  164. UILabel * label2=[[UILabel alloc]init];
  165. label2.frame=CGRectMake(15,25,self_width,20);
  166. label2.font=FONT_SIZE(13);
  167. label2.textColor=[UIColor lightGrayColor];
  168. label2.text=[[_zhonjian[indexPath.row] objectForKey:@"EM_DEFAULTHSNAME"] stringByAppendingFormat:@"-%@",[_zhonjian[indexPath.row] objectForKey:@"EM_DEPART"]];
  169. [cell.contentView addSubview:label2];
  170. return cell ;
  171. }
  172. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  173. {
  174. return 50;
  175. }
  176. @end