1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// 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 "HMSaleInputDetail.h"
#import "SaleInputDetailViewController.h"
#import "HMSaleInputQuery.h"
#import "JSDropDownMenu.h"
#import "SaleInputListViewModel.h"
#import "SaleInputHistoryViewController.h"
@interface SaleInputListViewController ()
@property (strong, nonatomic) SaleInputListViewModel *viewModel;
@end
@implementation SaleInputListViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.startPage = 1;
// Do any additional setup after loading the view.
self.title = @"销售录入记录";
[self refresh];
self.tableView.rowHeight = 159;
UIBarButtonItem *btnRight = [[UIBarButtonItem alloc] initWithTitle:@"历史" style:UIBarButtonItemStyleDone target:self action:@selector(actionGoHistory)];
self.navigationItem.rightBarButtonItem = btnRight;
self.btnAdd.hidden = !AppGlobal.permission.saleinput.newField;
[self configDropMenu];
}
- (void)configDropMenu {
JSDropDownMenu *menu = [[JSDropDownMenu alloc] initWithOrigin:CGPointMake(0, 0) andHeight:45];
menu.indicatorColor = [UIColor colorWithRed:175.0f / 255.0f green:175.0f / 255.0f blue:175.0f / 255.0f alpha:1.0];
menu.separatorColor = [UIColor colorWithRed:210.0f / 255.0f green:210.0f / 255.0f blue:210.0f / 255.0f alpha:1.0];
menu.textColor = [UIColor colorWithRed:83.f / 255.0f green:83.f / 255.0f blue:83.f / 255.0f alpha:1.0f];
menu.dataSource = self.viewModel;
menu.delegate = self.viewModel;
[self.view addSubview:menu];
WS(weakSelf);
self.viewModel.blockRequest = ^{
weakSelf.page = weakSelf.startPage;
[weakSelf httpRequest];
};
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.barTintColor = kMainBlueColor;
}
- (void)httpRequest {
self.viewModel.query.page = @(self.page);
self.viewModel.query.pageSize = @(self.pageSize);
WS(weakSelf);
[MBProgressHUD j_loading];
[ZJHttpManager POST:@"salesinput/query" parameters:self.viewModel.query.toDictionary complete:^(id responseObject, NSError *error) {
[MBProgressHUD j_hideLoadingView];
if (kIsResponse) {
if (weakSelf.page == 1) {
[weakSelf.arrData removeAllObjects];
}
NSMutableArray *arr = [HMSaleInputDetail modelsFromArray:responseObject[@"data"][@"records"]];
[weakSelf.arrData addObjectsFromArray:arr];
}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 {
HMSaleInputDetail *listModel = model;
SaleInputDetailViewController *detailVC = [SaleInputDetailViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
detailVC.listModel = listModel;
[self.navigationController pushViewController:detailVC animated:YES];
}
- (void)actionAdd:(UIButton *)sender {
SaleInputAddViewController *addVC = [SaleInputAddViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
WS(weakSelf);
addVC.commplete = ^{
weakSelf.page = weakSelf.startPage;
[weakSelf httpRequest];
};
[self listPushCustomAnimate:addVC];
}
/**
* 跳转查看历史界面
*/
- (void)actionGoHistory {
SaleInputHistoryViewController *historyVC = [SaleInputHistoryViewController viewControllerWithStoryBoardType:(STORYBOARD_TYPE_SALEINPUT)];
if (!AppGlobal.isMall) {
historyVC.contract = [HMSaleInputDetail_contract modelWithDic:[AppGlobal getTenantContract].toDictionary];
}
[self.navigationController pushViewController:historyVC animated:YES];
}
ZJLazy(SaleInputListViewModel, viewModel);
@end