ChooseVendorViewController.m 3.56 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12
//
//  ChooseSupplierViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/8/23.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "ChooseVendorViewController.h"
#import "Vendor.h"
#define TopMargin 50
#define TableHeight 50
陈俊俊's avatar
陈俊俊 committed
13
@interface ChooseVendorViewController ()
陈俊俊's avatar
陈俊俊 committed
14 15
{
}
陈俊俊's avatar
陈俊俊 committed
16

陈俊俊's avatar
陈俊俊 committed
17 18 19 20 21 22
@end

@implementation ChooseVendorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
陈俊俊's avatar
陈俊俊 committed
23 24 25
    //记录更新时间
    self.tableView.header.lastUpdatedTimeKey = ChooseVendorUpdateDate;
    self.title = @"选择供应商";
陈俊俊's avatar
陈俊俊 committed
26
    [self fetchDataList:@"" tableStr:GXF_BASECLASS_VENDOR];
陈俊俊's avatar
陈俊俊 committed
27 28 29
}

- (void)getBaseDataFromServer{
n22's avatar
n22 committed
30 31 32 33 34
    __weak typeof(self)weakSelf = self;
    void(^succ)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        if (data) {
            __strong __typeof(weakSelf)strongSelf = weakSelf;
陈俊俊's avatar
陈俊俊 committed
35
            [strongSelf endRefreshing];
陈俊俊's avatar
陈俊俊 committed
36
            [strongSelf fetchDataList:@"" tableStr:GXF_BASECLASS_VENDOR];
n22's avatar
n22 committed
37 38 39 40 41 42 43 44 45 46
        }else{
            [IBTLoadingView showTips:data];
        }
    };
    void(^fail)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        [IBTLoadingView showTips:data];
    };
    [IBTLoadingView showProgressLabel:@"正在加载..."];
    [[ICRHTTPController sharedController] getVendorWithPage_number:0 page_size:100 success:succ failure:fail];
陈俊俊's avatar
陈俊俊 committed
47 48 49 50 51 52
}
#pragma mark - 协议方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"MaskCell";
    MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
freecui's avatar
freecui committed
53
        cell = [[MaskCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID totalWidth:ScreenSize.width totalHeight:SEARCH_TABLECELL_HEIGHT];
陈俊俊's avatar
陈俊俊 committed
54 55 56 57 58
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.Commitbtn.hidden = YES;
    }
    if (self.isMoreChose) {
陈俊俊's avatar
陈俊俊 committed
59
        if ([self isHaveIndexPath:indexPath]) {
陈俊俊's avatar
陈俊俊 committed
60 61 62 63 64
            cell.Commitbtn.hidden = NO;
        }else{
            cell.Commitbtn.hidden = YES;
        }
    }else{
陈俊俊's avatar
陈俊俊 committed
65 66
        if (self.currentIndexPath) {
            if (indexPath.row == self.currentIndexPath.row) {
陈俊俊's avatar
陈俊俊 committed
67 68 69 70 71 72 73 74 75
                cell.Commitbtn.hidden = NO;
            }else{
                cell.Commitbtn.hidden = YES;
            }
        }else{
            cell.Commitbtn.hidden = YES;
        }
    }
    if (self.dataArr.count > 0) {
陈俊俊's avatar
陈俊俊 committed
76 77 78 79 80 81 82 83 84
        if (indexPath.row == 0) {
            NSString *dateStr = [self.dataArr[indexPath.row] httpParameterString];
            cell.titleLabel.textColor = GXF_CONTENT_COLOR;
            [cell setTitleStr:[NSString stringWithFormat:@"上次更新时间:%@",dateStr]];
        }else{
            Vendor *vendor =  self.dataArr[indexPath.row];
            NSString *proStr = [NSString stringWithFormat:@"%@[%@]",vendor.name,vendor.code];
            [cell setTitleStr:proStr];
        }
陈俊俊's avatar
陈俊俊 committed
85 86 87
    }
    return cell;
}
陈俊俊's avatar
陈俊俊 committed
88 89
- (void)boxValueChanged:(NSNotification *)fication{
    NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
陈俊俊's avatar
陈俊俊 committed
90
    [self fetchDataList:tilkeStr tableStr:GXF_BASECLASS_VENDOR];
陈俊俊's avatar
陈俊俊 committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
}
- (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