123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- //
- // RepDetailVC.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/6/15.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "RepDetailVC.h"
- #import "RepairApplyVC.h"
- #import "RepDetailAllAppear.h"
- @interface RepDetailVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- UITableView *_tableView;
- NSArray *_keys;
- CGFloat _bottomBarH;
- }
- @end
- @implementation RepDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self setTitle:@"报修详情"];
- [self goBackByNavigation];
-
- _bottomBarH = 50;
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet) style:0];
- _tableView.tableFooterView = [UIView new];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- [self.view addSubview:_tableView];
-
- if ([[NSString stringWithFormat:@"%@",_dic[@"AR_STATUS"]] isEqualToString:@"2"]) {
-
- }else{
- [self createBottomBarWithtoolTitles:@[@"取消报修",@"修改表单"]];
- }
-
-
- _keys = @[
- @[@"车牌号",@"AR_CARNUM"],
- // @[@"AR_CONTACTS",@"AR_CONTACTS"],
- @[@"设备场厂",@"AR_FACTORY"],
- @[@"创建日期",@"AR_CRDATE"],
- @[@"故障等级",@"AR_LEVEL"],
- @[@"终端型号",@"AR_MODEL"],
- @[@"故障描述",@"AR_REASON"],
- @[@"其它说明",@"AR_REMARK"],
- @[@"AR_SERIAL_NUMBER",@"AR_SERIAL_NUMBER"],
- // @[@"AR_STATUS",@"AR_STATUS"],
- @[@"联系电话",@"AR_TELPHONE"],
- @[@"发生故障时间",@"AR_TIME"]
- ];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _keys.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- NSString * key = _keys[indexPath.row][1];
- cell.textLabel.text = _keys[indexPath.row][0];
- if ([key isEqualToString:@"AR_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dic[key]];
-
- cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"已备案" : @"未备案" ;
- }else if ([key isEqualToString:@"AR_LEVEL"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dic[key]];
-
- switch ([status integerValue]) {
- case 1:
- cell.detailTextLabel.text = @"一级";
- break;
- case 2:
- cell.detailTextLabel.text = @"二级";
- break;
- case 3:
- cell.detailTextLabel.text = @"三级";
- break;
-
- default:
- break;
- }
- }else{
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dic[key]];
- }
-
- NSArray * limitArr = @[@"故障描述",@"其它说明"];
- if ([limitArr containsObject:cell.textLabel.text]) {
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
-
- }
-
- return cell;
-
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if (indexPath.row == 5 || indexPath.row == 6) {
- RepDetailAllAppear * vc = [[RepDetailAllAppear alloc]init];
- vc.str = self.dic[_keys[indexPath.row][1]];
- [self navPushHideTabbarToVC:vc];
- }
- }
- #pragma mark 创建BottomBarButton
- -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
-
- _tableView.height -= _bottomBarH+kSafeAreaBottomHeight;
-
- float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
- float HeightBth = _bottomBarH;
- for (int i=0; i<toolTitles.count; i++) {
- UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
- button.frame = CGRectMake(i*(widthBtn+1), kSize.height-kNavOffSet-HeightBth-kSafeAreaBottomHeight, widthBtn, HeightBth);
- [button setTitle:toolTitles[i] forState:UIControlStateNormal];
-
- UIColor * color = RQMianColor;
- button.backgroundColor = color;
- [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- button.tag = 100+i;
-
- [self.view addSubview:button];
- }
- }
- -(void)btnClick:(UIButton *)button{
-
- switch (button.tag) {
- case 100:
- {
- //删除
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"您确定要取消该设备报修吗?" message:nil alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"继续报修" otherButtonTitles:@[@"取消报修"] otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- [self deleteRepair];
- }
- }];
- }
- break;
- case 101:
- {
- [self willupdateRepair];//修改
- }
- break;
-
- default:
- break;
- }
-
-
- }
- #pragma mark 网络请求
- -(void)deleteRepair{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
-
- NSMutableDictionary *mdic = [[NSMutableDictionary alloc]init];
- [mdic setValue:self.dic[@"AR_ID"] forKey:@"id"];
- NSString *method = @"deleteRepair";
-
- [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowErrorMsg(@"请求失败!");
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowErrorMsg(root[@"msg"]);
- return;
- }
-
- ShowMsg(@"取消报修成功");
- if (self.blcok) {
- self.blcok();
- }
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- -(void)willupdateRepair{
-
- RepairApplyVC *vc = [[RepairApplyVC alloc]init];
- vc.type = @"2";
- vc.theDic = self.dic;
- vc.blcok = ^{
- if (self.blcok) {
- self.blcok();
- }
- };
- [self navPushHideTabbarToVC:vc];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|