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

#import "CostViewController.h"
#import "HeaderCell.h"
#import "FooterCell.h"
陈俊俊's avatar
陈俊俊 committed
12
#import "CostCell.h"
n22's avatar
n22 committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
@interface CostViewController ()<UITableViewDataSource,UITableViewDelegate,FooterCellDelegate>
{
    CGRect _tableFrame;
}
@end

@implementation CostViewController


- (void)viewDidLoad {
    self.view.backgroundColor  = XXFBgColor;
    [super viewDidLoad];
    _costArr = [NSMutableArray array];
    [self createView];
}
- (void)setViewFrame:(CGRect)viewFrame{
    _tableFrame = viewFrame;
}
- (void)createView{
    self.tableView = [[UITableView alloc]initWithFrame:_tableFrame style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
陈俊俊's avatar
陈俊俊 committed
36
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
n22's avatar
n22 committed
37 38
    [self.view addSubview:self.tableView];
    
陈俊俊's avatar
陈俊俊 committed
39
    NSArray *arr = @[@"费用",@"应付金额",@"已付金额",@"尾款"];
n22's avatar
n22 committed
40 41 42 43
    
    HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr];
    [self.view addSubview:headCell];
    self.tableView.tableHeaderView = headCell;
陈俊俊's avatar
陈俊俊 committed
44 45 46 47 48 49
    if (!self.isHiddenEdit) {
        FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加费用明细" isTwo:@""];
        [self.view addSubview:footCell];
        footCell.delegate = self;
        self.tableView.tableFooterView = footCell;
    }
n22's avatar
n22 committed
50 51 52
}

- (void)addClick{
陈俊俊's avatar
陈俊俊 committed
53
    [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddTransportCost object:nil];
n22's avatar
n22 committed
54
}
陈俊俊's avatar
陈俊俊 committed
55 56 57 58 59 60
- (void)editClick:(UIButton *)btn{
    FeeAcountDetail *fee = self.costArr[btn.tag];
    [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddTransportCost object:nil userInfo:@{@"indexPath":[NSIndexPath indexPathForRow:btn.tag inSection:0],@"feeAccountDetail":fee}];
}
#pragma mark footDelegate
- (void)choosePurchase{}
n22's avatar
n22 committed
61 62 63 64 65 66 67 68
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.costArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
陈俊俊's avatar
陈俊俊 committed
69 70
    static NSString *cellID = @"CostCell";
    CostCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
n22's avatar
n22 committed
71
    if (cell == nil) {
陈俊俊's avatar
陈俊俊 committed
72 73 74 75 76 77 78 79 80 81 82
        cell = [[CostCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (self.isHiddenEdit) {
            cell.editBtn.hidden = YES;
        }
    }
    cell.editBtn.tag = indexPath.row;
    [cell.editBtn addTarget:self action:@selector(editClick:) forControlEvents:UIControlEventTouchUpInside];
    if (self.costArr.count) {
        FeeAcountDetail *fee = self.costArr[indexPath.row];
        [cell setFeeCost:fee row:indexPath.row];
n22's avatar
n22 committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96
    }
    return cell;
}
/*
#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