FollowUpRecordViewController.m 3.96 KB
Newer Older
zhu's avatar
zhu committed
1 2 3 4 5 6 7 8 9 10 11
//
//  FollowUpRecordViewController.m
//  XFFruit
//
//  Created by mac on 15/9/16.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "FollowUpRecordViewController.h"
#import "NotuceRecordCell.h"
#import "NoticeRecord.h"
陈俊俊's avatar
陈俊俊 committed
12
#define TableHeight 130
zhu's avatar
zhu committed
13 14 15 16 17 18 19 20 21 22 23 24
@interface FollowUpRecordViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>

@end

@implementation FollowUpRecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bulidLayout];
    [self getDataFromServer];
}
- (void)bulidLayout{
陈俊俊's avatar
陈俊俊 committed
25
    self.dataArr=[[NSMutableArray alloc]init];
zhu's avatar
zhu committed
26
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height) style:(UITableViewStylePlain)];
陈俊俊's avatar
陈俊俊 committed
27
    self.tableView.backgroundColor = [UIColor clearColor];
zhu's avatar
zhu committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
}
- (void)getDataFromServer{
//    __weak typeof(self)weakSelf = self;
    void(^succ)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
//        __strong __typeof(weakSelf)strongSelf = weakSelf;
        if (data) {
            NSInteger success = [data[@"success"] integerValue];
            NSString *message  = data[@"message"] ;
            if (success == 1) {
陈俊俊's avatar
陈俊俊 committed
42 43 44 45 46 47
                NSArray *dataArr  = data[@"data"];
                for (NSDictionary *dataDict in dataArr) {
                    NoticeRecord *noticeRecord = [[NoticeRecord alloc]init];
                    [noticeRecord setValuesForKeysWithDictionary:dataDict];
                    [self.dataArr addObject:noticeRecord];
                }
zhu's avatar
zhu committed
48 49 50 51 52 53 54 55 56 57 58 59 60
                [self.tableView reloadData];
            }else{
                [IBTLoadingView showTips:message];
            }
        }else{
            [IBTLoadingView showTips:@"     无记录     "];
        }
    };
    void(^fail)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        [IBTLoadingView showTips:data];
    };
    [IBTLoadingView showProgressLabel:@"正在加载..."];
陈俊俊's avatar
陈俊俊 committed
61
    //5a7417014fdfc13a014fe5b890d8000e
陈俊俊's avatar
陈俊俊 committed
62
    [[ICRHTTPController sharedController] getPurchaseNoticeRecodWithData:self.purchaseNotice.uuid success:succ failure:fail];
zhu's avatar
zhu committed
63 64 65 66 67 68 69 70
}

#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   
陈俊俊's avatar
陈俊俊 committed
71
    return self.dataArr.count;
zhu's avatar
zhu committed
72 73
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
陈俊俊's avatar
陈俊俊 committed
74 75
    static NSString *cellID = @"NotuceRecordCell";
    NotuceRecordCell*notuceRecordCell = [tableView dequeueReusableCellWithIdentifier:cellID];
zhu's avatar
zhu committed
76
    
陈俊俊's avatar
陈俊俊 committed
77 78 79 80 81
    if (notuceRecordCell == nil) {
        notuceRecordCell = [[NotuceRecordCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        notuceRecordCell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
陈俊俊's avatar
陈俊俊 committed
82 83
    if (self.dataArr.count > 0) {
        NoticeRecord *recode = self.dataArr[indexPath.row];
陈俊俊's avatar
陈俊俊 committed
84 85
//        notuceRecordCell.noticeRecode = recode;
        [notuceRecordCell setNoticeRecode:recode withNumber:self.purchaseNotice.billnumber];
陈俊俊's avatar
陈俊俊 committed
86
    }
陈俊俊's avatar
陈俊俊 committed
87
    return notuceRecordCell;
zhu's avatar
zhu committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
       return TableHeight;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  }


- (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