RepDetailVC.m 6.7 KB

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