JOOAEmergencyViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. //
  2. // JOOAEmergencyViewController.m
  3. // shiku_im
  4. //
  5. // Created by jobor Zhou on 2016/10/10.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JOOAEmergencyViewController.h"
  9. #import "AFNetworking.h"
  10. #import "LYAlerterView.h"
  11. @interface JOOAEmergencyViewController ()
  12. @end
  13. @implementation JOOAEmergencyViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self setupNav];
  17. [self setUpData];
  18. [self setExtraCellLineHidden:self.tableView];
  19. }
  20. /**
  21. * 设置导航栏内容
  22. */
  23. - (void)setupNav
  24. {
  25. //1,设置标题
  26. UILabel * laebl=[[UILabel alloc]initWithFrame:CGRectMake(0,0,200,40)];
  27. laebl.text=@"请选择";
  28. laebl.font=FONT_SIZE(18);
  29. laebl.textAlignment=1;
  30. laebl.textColor=[UIColor whiteColor];
  31. self.navigationItem.titleView=laebl;
  32. //2设置导航栏背景颜色
  33. //2设置导航栏背景颜色
  34. if (statusX) {
  35. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newbg3"] forBarMetrics:UIBarMetricsDefault];
  36. }else{
  37. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newbg2"] forBarMetrics:UIBarMetricsDefault];
  38. }
  39. //3设置导航栏左右按钮
  40. // UIButton * quxiao=[UIButton buttonWithType:UIButtonTypeCustom];
  41. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  42. btn2.frame = CGRectMake(0, 5, 22, 22);
  43. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  44. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  45. [btn2 addSubview:image];
  46. [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
  47. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  48. [self.navigationItem setLeftBarButtonItem:bbi2];
  49. self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
  50. UIButton *rigntBtn = [UIButton new];
  51. rigntBtn.frame = CGRectMake(0, 0, 20, 20);
  52. UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
  53. imageView.image = [UIImage imageNamed:@"crm_main_add"];
  54. [rigntBtn addSubview:imageView];
  55. [rigntBtn addTarget:self action:@selector(createHYB) forControlEvents:UIControlEventTouchUpInside];
  56. UIBarButtonItem *creatBtn = [[UIBarButtonItem alloc]initWithCustomView:rigntBtn];
  57. self.navigationItem.rightBarButtonItems = @[creatBtn];
  58. }
  59. - (void)createHYB
  60. {
  61. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"请输入" message:@"" delegate:self cancelButtonTitle:Localized(@"UU_custom_cancle") otherButtonTitles:@"确定", nil];
  62. [alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
  63. UITextField *txtName = [alert textFieldAtIndex:0];
  64. txtName.placeholder = @"请输入";
  65. [alert show];
  66. }
  67. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  68. if (buttonIndex == 1) {
  69. UITextField *txt = [alertView textFieldAtIndex:0];
  70. [self.navigationController dismissViewControllerAnimated:YES completion:^{
  71. self.selectDegree(txt.text);
  72. }];
  73. }
  74. }
  75. - (void)backView
  76. {
  77. [self dismissViewControllerAnimated:YES completion:nil];
  78. }
  79. - (void)backAddressName:(backDegree)selectDegree
  80. {
  81. self.selectDegree=selectDegree;
  82. }
  83. - (void)setUpData
  84. {
  85. if (self.dataArray.count==0)
  86. {
  87. self.dataArray=[[NSMutableArray alloc]initWithArray:@[@"紧急",@"非常紧急",@"一般",@"不急"]];
  88. [self.tableView reloadData];
  89. }else{
  90. if (!g_B2BUser)
  91. {
  92. [self getShangjiState];
  93. }
  94. }
  95. }
  96. -(void)getShangjiState //获取商机阶段数据
  97. {
  98. NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  99. NSString *ip=[UASUserInfo shareManager].urlIp;
  100. NSString *master = [[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  101. NSString *sessionUser = [[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  102. NSString *url = [NSString stringWithFormat:@"%@mobile/crm/getBusinessChanceStage.action?sessionId=%@&master=%@&sessionUser=%@",ip,sessionId,master,sessionUser];
  103. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  104. UASNetworkManager *manager = [UASNetworkManager shareManager];
  105. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  106. //拼接sessionID
  107. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  108. //设置cookie
  109. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  110. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  111. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  112. DLog(@"------:%@",responseObject);
  113. NSString *sessionId = [NSString stringWithFormat:@"%@",responseObject[@"sessionId"]];
  114. if (![sessionId isEqualToString:@"(null)"]) {
  115. [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
  116. }
  117. NSMutableArray * arr=[[NSMutableArray alloc]init];
  118. for (id obj in responseObject[@"stages"]) {
  119. [arr addObject:[obj objectForKey:@"BS_NAME"]];
  120. }
  121. for (int i=0; i<self.dataArray.count; i++)
  122. {
  123. [arr insertObject:self.dataArray[i] atIndex:0];
  124. }
  125. self.dataArray=nil;
  126. self.dataArray=[[NSMutableArray alloc]initWithArray:arr];
  127. [self.tableView reloadData];
  128. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  129. DLog(@"请求失败:%@",error);
  130. [JOShowMessageFromNavi showDropViewWithMessage:@"商机阶段数据请求失败" ToNavi:self.navigationController withColor:nil];
  131. }];
  132. }
  133. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  134. {
  135. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  136. [self.navigationController dismissViewControllerAnimated:YES completion:^{
  137. self.selectDegree(self.dataArray[indexPath.row]);
  138. }];
  139. }
  140. - (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  141. {
  142. return self.dataArray.count;
  143. }
  144. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  145. {
  146. static NSString *identifier = @"cell";
  147. UITableViewCell * cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  148. //cell.selectionStyle = UITableViewCellSelectionStyleNone;
  149. cell.backgroundColor=[UIColor whiteColor];
  150. cell.textLabel.text=self.dataArray[indexPath.row];
  151. cell.textLabel.font = FONT_SIZE(15);
  152. return cell;
  153. }
  154. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  155. {
  156. return 40 + cellScale;
  157. }
  158. /**
  159. 去掉分割线
  160. */
  161. - (void)setExtraCellLineHidden: (UITableView *)tableView
  162. {
  163. UIView *view = [UIView new];
  164. view.backgroundColor = [UIColor clearColor];
  165. [tableView setTableFooterView:view];
  166. }
  167. @end