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

#import "SurveyViewController.h"
#import "SurveyListCell.h"
#import "Survey.h"
#import "SortMaskView.h"
#import "BoltMaskView.h"
n22's avatar
n22 committed
14
#import "SurveyDetailViewController.h"
陈俊俊's avatar
陈俊俊 committed
15
#import "NewSurveyViewController.h"
n22's avatar
n22 committed
16
#import "QueryOrder.h"
n22's avatar
n22 committed
17
#import "MJRefresh.h"
陈俊俊's avatar
陈俊俊 committed
18 19 20 21 22 23 24 25 26 27 28 29 30

#define TopMargin 44
#define TableHeight 120
#define LeftMargin 20
#define BtnWidth 60
#define BtnHeight 24
#define BtnSize 16
typedef enum : NSUInteger {
    SortTag = 3000,
    BoltTag
  
} BtnTag;

陈俊俊's avatar
陈俊俊 committed
31
@interface SurveyViewController ()<UITableViewDataSource,UITableViewDelegate,BoltMaskViewDelegate,SortMaskViewDelegate,UIGestureRecognizerDelegate>
陈俊俊's avatar
陈俊俊 committed
32 33 34 35 36 37 38 39
{
    UIView *_maskView;
    UIButton *currentBtn;
    SortMaskView *_sortView;
    BoltMaskView *_boltView;
    UIBarButtonItem  *_sureBtn;
    UIButton *_sortBtn;
    UIButton *_boltBtn;
n22's avatar
n22 committed
40 41 42
    BOOL _isRefresh;
    BOOL _isLoadMore;
    NSInteger _currentPage;
陈俊俊's avatar
陈俊俊 committed
43
}
n22's avatar
n22 committed
44 45
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
陈俊俊's avatar
陈俊俊 committed
46 47 48 49 50
@property (nonatomic,strong)NSString *billNumberLike;
@property (nonatomic,strong)NSString *state;//未提交=initial已提交=submitted调研中=insurvey已完成=finished
@property (nonatomic,strong)NSString *titleLike;
@property (nonatomic,strong)NSString *orderDirection;//asc(升序),desc(降序)

n22's avatar
n22 committed
51

陈俊俊's avatar
陈俊俊 committed
52 53 54 55 56 57 58
@end

@implementation SurveyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"行情调研";
陈俊俊's avatar
陈俊俊 committed
59
    self.view.backgroundColor  = XXFBgColor;
n22's avatar
n22 committed
60
    [self createBackBtn];
陈俊俊's avatar
陈俊俊 committed
61
    [self initData];
陈俊俊's avatar
陈俊俊 committed
62 63
    [self createTableView];
    [self getData];
n22's avatar
n22 committed
64 65
    //刷新
    [self createRefresh];
陈俊俊's avatar
陈俊俊 committed
66 67
}
- (void)initData{
n22's avatar
n22 committed
68
    self.dataArr = [NSMutableArray array];
陈俊俊's avatar
陈俊俊 committed
69
}
n22's avatar
n22 committed
70

n22's avatar
n22 committed
71 72
- (void)createRefresh{
    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
n22's avatar
n22 committed
73
        if (_isRefresh) {
n22's avatar
n22 committed
74 75
            return ;
        }
n22's avatar
n22 committed
76
        _isRefresh = YES;
n22's avatar
n22 committed
77 78 79
        _currentPage = 0;
        [self getData];
    }];
陈俊俊's avatar
陈俊俊 committed
80 81
    self.tableView.header.lastUpdatedTimeKey = SurveyUpdateDate;
    
n22's avatar
n22 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        if (_isLoadMore) {
            return ;
        }
        _isLoadMore = YES;
        _currentPage ++;
        [self getData];
    } ];
}
#pragma mark - 结束刷新
- (void)endRefreshing{
    _isLoadMore = NO;
    _isRefresh = NO;
    [self.tableView.header endRefreshing];
    [self.tableView.footer endRefreshing];
}
n22's avatar
n22 committed
98 99
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
n22's avatar
n22 committed
100 101
    if ([ICRUserUtil sharedInstance].needFresh && self.tableView != nil) {
        [self.tableView.header beginRefreshing];
n22's avatar
n22 committed
102 103 104
    }
}

陈俊俊's avatar
陈俊俊 committed
105
- (void)getData{
n22's avatar
n22 committed
106
    [ICRUserUtil sharedInstance].needFresh = NO;
n22's avatar
n22 committed
107
    __weak typeof(self)weakSelf = self;
n22's avatar
n22 committed
108 109
    void(^succ)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
n22's avatar
n22 committed
110
        __strong __typeof(weakSelf)strongSelf = weakSelf;
陈俊俊's avatar
陈俊俊 committed
111
        [strongSelf fetchtSurveyList:data];
n22's avatar
n22 committed
112 113 114 115 116
    };
    void(^fail)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        [IBTLoadingView showTips:data];
    };
陈俊俊's avatar
陈俊俊 committed
117
    [IBTLoadingView showProgressLabel:@"正在加载..."];
陈俊俊's avatar
陈俊俊 committed
118
    ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
陈俊俊's avatar
陈俊俊 committed
119
    
陈俊俊's avatar
陈俊俊 committed
120
    NSMutableArray *orderArr =[NSMutableArray array];
n22's avatar
n22 committed
121
    if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
n22's avatar
n22 committed
122 123 124 125
        QueryOrder *order = [QueryOrder new];
        order.field = @"lastModified";
        order.direction = self.orderDirection;
        [orderArr addObject:[order dictForCommit]];
陈俊俊's avatar
陈俊俊 committed
126
    }
陈俊俊's avatar
陈俊俊 committed
127 128 129
    id billObject = [NSNull null];
    if (self.billNumberLike.length > 0) {
        billObject = self.billNumberLike;
n22's avatar
n22 committed
130
        if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
n22's avatar
n22 committed
131 132 133 134
            QueryOrder *order = [QueryOrder new];
            order.field = @"billNumber";
            order.direction = self.orderDirection;
            [orderArr addObject:[order dictForCommit]];
陈俊俊's avatar
陈俊俊 committed
135
        }
陈俊俊's avatar
陈俊俊 committed
136 137 138 139
    }
    id stateObject = [NSNull null];
    if (self.state.length > 0 && ![self.state isEqualToString:@"none"]) {
        stateObject = self.state;
n22's avatar
n22 committed
140
        if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
n22's avatar
n22 committed
141 142 143 144
            QueryOrder *order = [QueryOrder new];
            order.field = @"state";
            order.direction = self.orderDirection;
            [orderArr addObject:[order dictForCommit]];
陈俊俊's avatar
陈俊俊 committed
145
        }
陈俊俊's avatar
陈俊俊 committed
146 147 148
    }
    id titleObject = [NSNull null];
    if (self.titleLike.length > 0) {
n22's avatar
n22 committed
149
        titleObject = self.titleLike;
n22's avatar
n22 committed
150
        if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
n22's avatar
n22 committed
151 152 153 154
            QueryOrder *order = [QueryOrder new];
            order.field = @"title";
            order.direction = self.orderDirection;
            [orderArr addObject:[order dictForCommit]];
陈俊俊's avatar
陈俊俊 committed
155 156
        }
    }
n22's avatar
n22 committed
157 158 159 160 161 162 163
    if (orderArr.count == 0) {
        QueryOrder *order = [QueryOrder new];
        order.field = @"billNumber";
        order.direction = @"desc";
        [orderArr addObject:[order dictForCommit]];

    }
陈俊俊's avatar
陈俊俊 committed
164
    NSDictionary *dict = @{
陈俊俊's avatar
陈俊俊 committed
165 166 167
                           @"billNumberLike":billObject,
                           @"state":stateObject,
                           @"titleLike":titleObject,
n22's avatar
n22 committed
168
                           @"queryOrders":orderArr,
陈俊俊's avatar
陈俊俊 committed
169
                           @"userUuid":userUtil.userId,
n22's avatar
n22 committed
170 171
                           @"pageNumber":@(_currentPage),
                           @"pageSize":@(20)};
陈俊俊's avatar
陈俊俊 committed
172
    [[ICRHTTPController sharedController] querySurveyWithBillData:dict success:succ failure:fail];
陈俊俊's avatar
陈俊俊 committed
173
}
n22's avatar
n22 committed
174
#pragma mark -成功
陈俊俊's avatar
陈俊俊 committed
175 176 177 178 179
- (void)fetchtSurveyList:(id)data{
    if (data) {
        NSInteger success = [data[@"success"] integerValue];
        NSString *message  = data[@"message"] ;
        if (success == 1) {
n22's avatar
n22 committed
180 181 182 183
            if (_currentPage == 0) {
                if (self.dataArr.count > 0) {
                    [self.dataArr removeAllObjects];
                }
陈俊俊's avatar
陈俊俊 committed
184 185 186 187 188 189 190
            }
            NSArray *recodesArr = data[ @"data" ][ @"records" ];
            for (NSDictionary *surveyDict in recodesArr) {
                Survey *survey = [[Survey alloc]init];
                [survey setValuesForKeysWithDictionary:surveyDict];
                [self.dataArr addObject:survey];
            }
n22's avatar
n22 committed
191 192
            NSDictionary *pageDict = data[ @"data" ][ @"paging" ];
            NSInteger pageCount = [pageDict[@"pageCount"] integerValue];
陈俊俊's avatar
陈俊俊 committed
193
            [self.tableView reloadData];
n22's avatar
n22 committed
194 195 196 197
            [self endRefreshing];
            if (pageCount <= _currentPage) {
                [self.tableView.footer noticeNoMoreData];
            }
陈俊俊's avatar
陈俊俊 committed
198 199 200
            if (_currentPage == 0 && self.dataArr.count > 0) {
                [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
            }
陈俊俊's avatar
陈俊俊 committed
201 202 203 204 205
        }else{
            [IBTLoadingView showTips:message];
        }
    }else{
        [IBTLoadingView showTips:@"      无记录      "];
n22's avatar
n22 committed
206
    }
陈俊俊's avatar
陈俊俊 committed
207
}
n22's avatar
n22 committed
208

陈俊俊's avatar
陈俊俊 committed
209 210 211
- (void)createTableView
{
    _sureBtn = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
陈俊俊's avatar
陈俊俊 committed
212 213
    self.navigationItem.rightBarButtonItem = _sureBtn;

陈俊俊's avatar
陈俊俊 committed
214
    _sortBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, BtnWidth, BtnHeight) target:self sel:@selector(sortClick:) tag:SortTag image:@"black_arrow_down_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil];
陈俊俊's avatar
陈俊俊 committed
215 216 217
    _sortBtn.titleLabel.font = FontSize(BtnSize);
    [self.view addSubview:_sortBtn];
    
陈俊俊's avatar
陈俊俊 committed
218
    _boltBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(ScreenSize.width-BtnWidth - LeftMargin,10,BtnWidth, BtnHeight) target:self sel:@selector(sortClick:) tag:BoltTag image:@"black_filter_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil];
陈俊俊's avatar
陈俊俊 committed
219 220 221
    _boltBtn.titleLabel.font = FontSize(BtnSize);
    [self.view addSubview:_boltBtn];
    
n22's avatar
n22 committed
222 223 224 225
    self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
陈俊俊's avatar
陈俊俊 committed
226 227 228
    
    _maskView = [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, ScreenSize.height - 64- TopMargin)];
    _maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
陈俊俊's avatar
陈俊俊 committed
229 230 231
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenMaskView)];
    [_maskView addGestureRecognizer:tap];
    tap.delegate = self;
陈俊俊's avatar
陈俊俊 committed
232 233 234
    _maskView.hidden = YES;
    [self.view addSubview:_maskView];
}
陈俊俊's avatar
陈俊俊 committed
235 236 237 238 239 240 241 242 243 244 245 246
#pragma mark - 手势代理方法
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    // 输出点击的view的类名
    NSLog(@"%@", NSStringFromClass([touch.view class]));
    
    // 若为UITableViewCellContentView(即点击了tableViewCell),则不截获Touch事件
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return  YES;
}
n22's avatar
n22 committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
//检测排序的颜色
- (void)checkSortBtnColor{
    if (self.orderDirection.length > 0) {
        [_sortBtn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal];
    }else{
        [_sortBtn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal];

    }
}
- (void)checkBoltBtnColor{
    if (self.state.length > 0 || self.billNumberLike.length > 0 || self.titleLike.length > 0) {
        [_boltBtn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal];
    }else{
        [_boltBtn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal];

    }
}


陈俊俊's avatar
陈俊俊 committed
266 267
#pragma mark - 确定
- (void)sureClick{
陈俊俊's avatar
陈俊俊 committed
268 269 270 271 272 273 274 275 276 277 278 279 280
        [_boltView.titleFiled resignFirstResponder];
        [_boltView.billFiled resignFirstResponder];
        _currentPage = 0;
        
        //请求
        [self getData];
        //还原数据
        if (_sortView) {
            [self hiddenSortMaskView:YES];
        }
        if (_boltView) {
            [self hiddenBoltMaskView:YES];
        }
陈俊俊's avatar
陈俊俊 committed
281 282 283 284
}

#pragma mark -按钮事件
- (void)sortClick:(UIButton *)btn{
陈俊俊's avatar
陈俊俊 committed
285
    _maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
陈俊俊's avatar
陈俊俊 committed
286 287 288 289 290 291 292 293 294 295
    _maskView.hidden = NO;
    if (btn.tag == SortTag) {
        if(_boltView){
            [self hiddenBoltMaskView:NO];
        }
        if (currentBtn == btn) {
            [btn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal];
            [self hiddenSortMaskView:YES];
            currentBtn = nil;
        }else{
陈俊俊's avatar
陈俊俊 committed
296
            [btn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
297
            if (_sortView == nil) {
n22's avatar
n22 committed
298 299
                _sortView = [[SortMaskView alloc]initWithFrame:CGRectMake(0, -105, ScreenSize.width, 150) withOrderDirection:self.orderDirection];
                _sortView.dataArr = [[NSMutableArray alloc]initWithObjects:@"按时间顺序",@"按时间逆序",@"默认排序",nil];
陈俊俊's avatar
陈俊俊 committed
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
                _sortView.delegate = self;
                [_maskView addSubview:_sortView];
                [UIView animateWithDuration:0.25 animations:^{
                    CGRect sortFrame = _sortView.frame;
                    sortFrame.origin.y = 0;
                    _sortView.frame = sortFrame;
                }];
            }
            currentBtn = btn;
        }
    }else if(btn.tag == BoltTag){
        if (_sortView) {
            [self hiddenSortMaskView:NO];
        }
        if (currentBtn == btn) {
            [btn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal];
            [self hiddenBoltMaskView:YES];
            currentBtn = nil;

        }else{
            [btn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal];
            if (_boltView == nil) {
n22's avatar
n22 committed
322
                _boltView = [[BoltMaskView alloc]initWithFrame:CGRectMake(0, -105, ScreenSize.width, 274) state:self.state title:self.titleLike bill:self.billNumberLike];
陈俊俊's avatar
陈俊俊 committed
323
                _boltView.backgroundColor = XXFBgColor;
陈俊俊's avatar
陈俊俊 committed
324
                _boltView.delegate = self;
陈俊俊's avatar
陈俊俊 committed
325
                _boltView.dataArr = [[NSMutableArray alloc]initWithObjects:@"不限",@"未提交",@"已提交" ,@"调研中",nil];
陈俊俊's avatar
陈俊俊 committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339
                [_maskView addSubview:_boltView];
                [UIView animateWithDuration:0.25 animations:^{
                    CGRect sortFrame = _boltView.frame;
                    sortFrame.origin.y = 0;
                    _boltView.frame = sortFrame;
                }];
                currentBtn = btn;

            }
        }
    }
}

- (void)hiddenSortMaskView:(BOOL)isHide{
陈俊俊's avatar
陈俊俊 committed
340
    currentBtn = nil;
n22's avatar
n22 committed
341
    [self checkSortBtnColor];
陈俊俊's avatar
陈俊俊 committed
342 343 344 345 346 347 348 349
    if (isHide == NO) {
        [_sortView removeFromSuperview];
        _sortView = nil;
    }else{
        [UIView animateWithDuration:0.25 animations:^{
            CGRect sortFrame = _sortView.frame;
            sortFrame.origin.y = -105;
            _sortView.frame = sortFrame;
陈俊俊's avatar
陈俊俊 committed
350
            _maskView.backgroundColor = RGBA(0, 0, 0, 0);
陈俊俊's avatar
陈俊俊 committed
351 352 353 354 355 356 357 358
        }completion:^(BOOL finished) {
            [_sortView removeFromSuperview];
            _sortView = nil;
            _maskView.hidden = YES;
        }];
    }
}
- (void)hiddenBoltMaskView:(BOOL)isHide{
陈俊俊's avatar
陈俊俊 committed
359
    currentBtn = nil;
n22's avatar
n22 committed
360
    [self checkBoltBtnColor];
陈俊俊's avatar
陈俊俊 committed
361 362 363 364 365 366 367 368
    if (isHide == NO) {
        [_boltView removeFromSuperview];
        _boltView = nil;
    }else{
        [UIView animateWithDuration:0.25 animations:^{
            CGRect sortFrame = _boltView.frame;
            sortFrame.origin.y = -105;
            _boltView.frame = sortFrame;
陈俊俊's avatar
陈俊俊 committed
369
            _maskView.backgroundColor = RGBA(0, 0, 0, 0);
陈俊俊's avatar
陈俊俊 committed
370 371 372 373 374 375 376 377 378
        }completion:^(BOOL finished) {
            [_boltView removeFromSuperview];
            _boltView = nil;
            _maskView.hidden = YES;
        }];
    }
}
#pragma mark - sortDelegate
- (void)getSortValueSelectRow:(NSString *)state{
n22's avatar
n22 committed
379 380
    if (state.length > 0) {
        self.orderDirection = state;
n22's avatar
n22 committed
381
        CLog(@"%@",state);
n22's avatar
n22 committed
382
    }
陈俊俊's avatar
陈俊俊 committed
383
}
n22's avatar
n22 committed
384
#pragma mark - boltDelegate
陈俊俊's avatar
陈俊俊 committed
385
- (void)getBoltValueSelectRow:(NSString *)state{
陈俊俊's avatar
陈俊俊 committed
386
    self.state = state;
n22's avatar
n22 committed
387
    CLog(@"%@",state);
陈俊俊's avatar
陈俊俊 committed
388
}
陈俊俊's avatar
陈俊俊 committed
389
- (void)getTitleLike:(NSString *)titleLike{
陈俊俊's avatar
陈俊俊 committed
390
    
陈俊俊's avatar
陈俊俊 committed
391
    self.titleLike = titleLike;
n22's avatar
n22 committed
392
    CLog(@"%@",titleLike);
陈俊俊's avatar
陈俊俊 committed
393 394 395
}
- (void)getBillNumber:(NSString *)billNumber{
    self.billNumberLike = billNumber;
n22's avatar
n22 committed
396
    CLog(@"%@",billNumber);
陈俊俊's avatar
陈俊俊 committed
397
}
n22's avatar
n22 committed
398 399 400 401 402 403 404 405 406 407 408 409
- (void)clearBoltInformation{
    //清空所有条件
    if (self.billNumberLike.length > 0) {
        self.billNumberLike = @"";
    }
    if (self.titleLike.length > 0) {
        self.titleLike = @"";
    }
    if (self.state.length > 0) {
        self.state = @"";
    }
}
陈俊俊's avatar
陈俊俊 committed
410 411 412 413 414 415 416 417 418
#pragma mark - 隐藏maskView
- (void)hiddenMaskView{
    if (_sortView) {
        [self hiddenSortMaskView:YES];
    }
    if (_boltView) {
        [self hiddenBoltMaskView:YES];
    }
}
陈俊俊's avatar
陈俊俊 committed
419 420 421 422 423
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
n22's avatar
n22 committed
424
    return self.dataArr.count;
陈俊俊's avatar
陈俊俊 committed
425 426 427 428 429 430 431 432 433
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"SurveyID";
    SurveyListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[SurveyListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
n22's avatar
n22 committed
434 435
    if (self.dataArr.count > 0) {
        Survey *survey = self.dataArr[indexPath.row];
陈俊俊's avatar
陈俊俊 committed
436 437 438 439 440
        [cell setSurvey:survey];

    }
    return cell;
}
n22's avatar
n22 committed
441 442
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
陈俊俊's avatar
陈俊俊 committed
443
    Survey *survey = nil;
n22's avatar
n22 committed
444
    if (self.dataArr.count > 0) {
陈俊俊's avatar
陈俊俊 committed
445 446
       survey  = self.dataArr[indexPath.row];
    }
n22's avatar
n22 committed
447
    if ([survey.state isEqualToString:SURVEY_STATE_INITIAL]) {
陈俊俊's avatar
陈俊俊 committed
448 449
        NewSurveyViewController *nvc = [[NewSurveyViewController alloc]init];
        nvc.survey = survey;
陈俊俊's avatar
陈俊俊 committed
450
        nvc.navTitle = @"修改行情调研单";
陈俊俊's avatar
陈俊俊 committed
451 452
        [self PushViewController:nvc animated:YES];
        
n22's avatar
n22 committed
453
    }else if([survey.state isEqualToString:SURVEY_STATE_SUBMITTED] || [survey.state isEqualToString:SURVEY_STATE_INSURVEY]|| [survey.state isEqualToString:SURVEY_STATE_FINISHED]){
陈俊俊's avatar
陈俊俊 committed
454
        SurveyDetailViewController *svc = [SurveyDetailViewController new];
n22's avatar
n22 committed
455 456
        svc.survey = survey;
        svc.surveyUuid = survey.uuid;
陈俊俊's avatar
陈俊俊 committed
457
        [self PushViewController:svc animated:YES];
n22's avatar
n22 committed
458 459
    }
}
n22's avatar
n22 committed
460 461 462 463 464 465 466 467 468 469 470
- (void)createBackBtn{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    btn.frame  = CGRectMake(0, 0, 12, 20);
    [btn addTarget:self action:@selector(backRV) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithCustomView:btn];
    self.navigationItem.leftBarButtonItem = back;
}
- (void)backRV{
    [self PopToRootViewControllerAnimated:YES];
}
n22's avatar
n22 committed
471

陈俊俊's avatar
陈俊俊 committed
472 473 474 475
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return TableHeight;
}

n22's avatar
n22 committed
476

陈俊俊's avatar
陈俊俊 committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#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