RepDetailVC.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //
  2. // RepDetailVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/6/15.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "RepDetailVC.h"
  9. #import "RepairApplyVC.h"
  10. #import "RepDetailAllAppear.h"
  11. @interface RepDetailVC ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. UITableView *_tableView;
  14. NSArray *_keys;
  15. CGFloat _bottomBarH;
  16. }
  17. @end
  18. @implementation RepDetailVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [self setTitle:@"报修详情"];
  22. [self goBackByNavigation];
  23. _bottomBarH = 50;
  24. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-_bottomBarH-kNavOffSet-SafeAreaBottomHeight) style:0];
  25. _tableView.tableFooterView = [UIView new];
  26. _tableView.delegate = self;
  27. _tableView.dataSource = self;
  28. [self.view addSubview:_tableView];
  29. [self createBottomBarWithtoolTitles:@[@"取消报修",@"修改表单"]];
  30. _keys = @[
  31. @[@"车牌号",@"AR_CARNUM"],
  32. // @[@"AR_CONTACTS",@"AR_CONTACTS"],
  33. @[@"设备场厂",@"AR_FACTORY"],
  34. @[@"创建日期",@"AR_CRDATE"],
  35. @[@"故障等级",@"AR_LEVEL"],
  36. @[@"终端型号",@"AR_MODEL"],
  37. @[@"故障描述",@"AR_REASON"],
  38. @[@"其它说明",@"AR_REMARK"],
  39. @[@"AR_SERIAL_NUMBER",@"AR_SERIAL_NUMBER"],
  40. // @[@"AR_STATUS",@"AR_STATUS"],
  41. @[@"联系电话",@"AR_TELPHONE"],
  42. @[@"发生故障时间",@"AR_TIME"]
  43. ];
  44. }
  45. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  46. return _keys.count;
  47. }
  48. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  49. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  50. if (!cell) {
  51. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  52. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  53. }
  54. NSString * key = _keys[indexPath.row][1];
  55. cell.textLabel.text = _keys[indexPath.row][0];
  56. if ([key isEqualToString:@"AR_STATUS"]){
  57. NSString *status = [NSString stringWithFormat:@"%@",self.dic[key]];
  58. cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"已备案" : @"未备案" ;
  59. }else if ([key isEqualToString:@"AR_LEVEL"]){
  60. NSString *status = [NSString stringWithFormat:@"%@",self.dic[key]];
  61. switch ([status integerValue]) {
  62. case 1:
  63. cell.detailTextLabel.text = @"一级";
  64. break;
  65. case 2:
  66. cell.detailTextLabel.text = @"二级";
  67. break;
  68. case 3:
  69. cell.detailTextLabel.text = @"三级";
  70. break;
  71. default:
  72. break;
  73. }
  74. }else{
  75. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dic[key]];
  76. }
  77. NSArray * limitArr = @[@"故障描述",@"其它说明"];
  78. if ([limitArr containsObject:cell.textLabel.text]) {
  79. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  80. }
  81. return cell;
  82. }
  83. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  84. if (indexPath.row == 5 || indexPath.row == 6) {
  85. RepDetailAllAppear * vc = [[RepDetailAllAppear alloc]init];
  86. vc.str = self.dic[_keys[indexPath.row][1]];
  87. [self navPushHideTabbarToVC:vc];
  88. }
  89. }
  90. #pragma mark 创建BottomBarButton
  91. -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
  92. float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
  93. float HeightBth = _bottomBarH;
  94. for (int i=0; i<toolTitles.count; i++) {
  95. UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
  96. button.frame = CGRectMake(i*(widthBtn+1), kSize.height-kNavOffSet-HeightBth-SafeAreaBottomHeight, widthBtn, HeightBth);
  97. [button setTitle:toolTitles[i] forState:UIControlStateNormal];
  98. UIColor * color = defGreen;
  99. button.backgroundColor = color;
  100. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  101. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  102. button.tag = 100+i;
  103. [self.view addSubview:button];
  104. }
  105. }
  106. -(void)btnClick:(UIButton *)button{
  107. switch (button.tag) {
  108. case 100:
  109. {
  110. //删除
  111. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您确定要取消该设备报修吗?" preferredStyle:UIAlertControllerStyleAlert];
  112. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消报修" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  113. [self deleteRepair];
  114. }]];
  115. [alertFind addAction:[UIAlertAction actionWithTitle:@"继续报修" style:UIAlertActionStyleCancel handler:nil]];
  116. [self presentViewController:alertFind animated:true completion:nil];
  117. }
  118. break;
  119. case 101:
  120. {
  121. [self willupdateRepair];//修改
  122. }
  123. break;
  124. default:
  125. break;
  126. }
  127. }
  128. #pragma mark 网络请求
  129. -(void)deleteRepair{
  130. if (![NetManager connectedToNetWork]) {
  131. showMsgUnconnect();
  132. return;
  133. }
  134. NSMutableDictionary *mdic = [[NSMutableDictionary alloc]init];
  135. [mdic setValue:self.dic[@"AR_ID"] forKey:@"id"];
  136. NSString *method = @"deleteRepair";
  137. [MBProgressHUD showLoadToView:self.view];
  138. [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  139. [MBProgressHUD hideHUDForView:self.view];
  140. if (!root) {
  141. ShowErrorMsg(@"请求失败!");
  142. return;
  143. }
  144. if ([root[@"code"] isEqualToString:@"1"]) {
  145. ShowErrorMsg(root[@"msg"]);
  146. return;
  147. }
  148. ShowMsg(@"取消报修成功");
  149. if (self.blcok) {
  150. self.blcok();
  151. }
  152. [self.navigationController popViewControllerAnimated:YES];
  153. }];
  154. }
  155. -(void)willupdateRepair{
  156. RepairApplyVC *vc = [[RepairApplyVC alloc]init];
  157. vc.type = @"2";
  158. vc.theDic = self.dic;
  159. vc.blcok = ^{
  160. if (self.blcok) {
  161. self.blcok();
  162. }
  163. };
  164. [self navPushHideTabbarToVC:vc];
  165. }
  166. - (void)didReceiveMemoryWarning {
  167. [super didReceiveMemoryWarning];
  168. // Dispose of any resources that can be recreated.
  169. }
  170. /*
  171. #pragma mark - Navigation
  172. // In a storyboard-based application, you will often want to do a little preparation before navigation
  173. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  174. // Get the new view controller using [segue destinationViewController].
  175. // Pass the selected object to the new view controller.
  176. }
  177. */
  178. @end