//
//  SaleInputListViewController.m
//  RealEstateManagement
//
//  Created by Javen on 2016/11/2.
//  Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//

#import "SaleInputListViewController.h"
#import "SaleInputAddViewController.h"
#import "SaleInputListTableViewCell.h"
//#import "SaleInputDetailModel.h"
//#import "SaleInputDetailViewController.h"
#import "HMSaleInputQuery.h"
@interface SaleInputListViewController ()
@property (strong, nonatomic) HMSaleInputQuery *query;
@end

@implementation SaleInputListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"销售录入记录";
    [self refresh];
    self.btnAdd.hidden = !AppGlobal.permission.saleinput.newField;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.barTintColor = kMainBlueColor;
}

- (void)httpRequest {
    self.query.contracts = [AppGlobal getUserContractUuids];
    self.query.page = @(self.page);
    self.query.pageSize = @(self.pageSize);
    self.query.dateRange = [HMSaleInputQuery_dateRange new];
    self.query.dateRange.beginDate = @"2016-07-12";
    self.query.dateRange.endDate = @"2017-07-13";
    WS(weakSelf);
    [ZJHttpManager POST:@"hdmall/api/sale/getList" parameters:self.query.toDictionary complete:^(id responseObject, NSError *error) {
        if (kIsResponse) {
            
        }else{
            kFalseHttpTips;
            self.page--;
        }
        
        [weakSelf listTableViewReloadData];
    }];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SaleInputListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SaleInputListTableViewCell" forIndexPath:indexPath];
    [cell configCellWithArray:self.arrData indexPath:indexPath];
    return cell;
}

- (void)listDidSelect:(id)model {
//    SaleInputDetailModel *listModel = model;
//    SaleInputDetailViewController *detailVC = [SaleInputDetailViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
//    detailVC.detailType = SaleInputDetailTypeReadOnly;
//    detailVC.listModel = listModel;
//    [self.navigationController pushViewController:detailVC animated:YES];
}

- (void)actionAdd:(UIButton *)sender {
    SaleInputAddViewController *addVC = [SaleInputAddViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];

    [self listPushCustomAnimate:addVC];
}

ZJLazy(HMSaleInputQuery, query);

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