CustomerBalanceViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. //
  2. // CustomerBalanceViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/15.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "CustomerBalanceViewController.h"
  9. #import "CustomerBalanceDetailViewController.h"
  10. #import "CustomerBalanceSearchModel.h"
  11. #import "CustomerBalanceCell.h"
  12. @interface CustomerBalanceViewController ()<UITableViewDelegate,UITableViewDataSource>{
  13. //TableView对象
  14. UITableView *_vTableView;
  15. UIView *_headView;
  16. }
  17. /**
  18. 数据源高度数据
  19. */
  20. @property (strong, nonatomic) NSMutableDictionary *heights;
  21. /**
  22. 原始数据源
  23. */
  24. @property (strong, nonatomic) NSMutableArray *dataList;
  25. /**
  26. 请求数据对象
  27. */
  28. @property(nonatomic,strong) ASIDownManager *downManager;
  29. @end
  30. @implementation CustomerBalanceViewController
  31. #pragma mark - 公共函数
  32. /**
  33. viewDidLoad函数
  34. */
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. _isBalance = @"";
  38. //[self showTitle:@"客户往来余额表"];
  39. [self loadNavStyle];
  40. [self initUI];
  41. [self initSlideSlip];
  42. [self reloadData];
  43. }
  44. /**
  45. 安全区视图发生变化
  46. */
  47. -(void)viewSafeAreaInsetsDidChange{
  48. self.view.backgroundColor = [UIColor whiteColor];
  49. _vTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  50. [super viewSafeAreaInsetsDidChange];
  51. }
  52. /**
  53. didReceiveMemoryWarning函数
  54. */
  55. - (void)didReceiveMemoryWarning {
  56. [super didReceiveMemoryWarning];
  57. }
  58. /**
  59. dealloc
  60. */
  61. - (void)dealloc{
  62. self.dataList = nil;
  63. self.filterController = nil;
  64. }
  65. #pragma mark - 数据源list属性
  66. /**
  67. 高度
  68. @return <#return value description#>
  69. */
  70. - (NSMutableDictionary *)heights{
  71. if (_heights == nil){
  72. _heights = [NSMutableDictionary dictionary];
  73. }
  74. return _heights;
  75. }
  76. /**
  77. 原始数据源
  78. @return <#return value description#>
  79. */
  80. - (NSMutableArray *)dataList{
  81. if(_dataList== nil){
  82. _dataList = [NSMutableArray new];
  83. }
  84. return _dataList;
  85. }
  86. #pragma mark - 委托回调函数
  87. #pragma mark 委托接口回调函数
  88. /**
  89. 调用接口成功回调
  90. @param sender <#sender description#>
  91. */
  92. - (void)onLoadFinish:(ASIDownManager *)sender {
  93. // 服务器返回数据
  94. NSDictionary *dic = [sender.mWebStr JSONValue];
  95. [self Cancel];
  96. // 服务器返回数据是否正确
  97. if (dic && [dic isKindOfClass:[NSDictionary class]])
  98. {
  99. // 服务器返回数据状态值
  100. int iStatus = [[dic objectForKey:@"Status"] intValue];
  101. // 服务器返回数据消息
  102. NSString *message=[dic objectForKey:@"Message"];
  103. // 服务器返回数据状态值正确
  104. if (iStatus == 0)
  105. {
  106. NSArray *retArr =[dic objectForKey:@"Result"];
  107. [self.dataList removeAllObjects];
  108. // 返回结果
  109. if(retArr!=nil)
  110. {
  111. [self.dataList addObjectsFromArray:retArr];
  112. _vTableView.tableHeaderView = nil;
  113. _vTableView.backgroundView = nil;
  114. if(self.dataList.count==0)
  115. {
  116. //无数据 关宏厚2017-7-6
  117. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  118. UIView *noDataView=[[UIView alloc]init];
  119. noDataView.frame=_vTableView.bounds;
  120. UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
  121. [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
  122. [noDataView addSubview:nodataImgView];
  123. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
  124. label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
  125. label.text = @"无数据";
  126. label.numberOfLines = 2;
  127. label.textColor = [UIColor lightGrayColor];
  128. [noDataView addSubview:label];
  129. // 有刷新数据的时候
  130. if(self.dataList == nil || self.dataList.count==0){
  131. _vTableView.backgroundView =noDataView;
  132. [self showAlertViewBackText:@"未找到匹配结果"];
  133. }
  134. }else{
  135. _vTableView.tableHeaderView = _headView;
  136. float totalReceivableValue = 0;
  137. float totalDepositValue = 0;
  138. float totalEarnestValue = 0;
  139. for (int i = 0; i < self.dataList.count; i++) {
  140. NSDictionary *dicValue = self.dataList[i];
  141. totalReceivableValue = totalReceivableValue + [[dicValue objectForKey:@"AccountReceivable"] floatValue];
  142. totalDepositValue = totalDepositValue + [[dicValue objectForKey:@"DepositReceived"] floatValue];
  143. totalEarnestValue = totalEarnestValue + [[dicValue objectForKey:@"Earnest"] floatValue];
  144. }
  145. self.lblReceivable.text = [NSString stringWithFormat:@"¥%.2f",totalReceivableValue];
  146. self.lblDeposit.text = [NSString stringWithFormat:@"¥%.2f",totalDepositValue];
  147. self.lblEarnest.text = [NSString stringWithFormat:@"¥%.2f",totalEarnestValue];
  148. self.lblReceivableAndDepositAndEarnest.text = [NSString stringWithFormat:@"¥%.2f",totalReceivableValue-totalDepositValue-totalEarnestValue];
  149. }
  150. [_vTableView reloadData];
  151. }
  152. }
  153. // 服务器返回数据状态值异常
  154. else if(iStatus==ActionResultStatusAuthError
  155. ||iStatus==ActionResultStatusNoLogin
  156. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  157. [self showReLoginDialog:message];
  158. }
  159. else {
  160. [_vTableView reloadData];
  161. [self showAlertViewText:message];
  162. }
  163. }
  164. }
  165. /**
  166. 调用接口失败回调
  167. @param sender <#sender description#>
  168. */
  169. - (void)onLoadFail:(ASIDownManager *)sender {
  170. [self Cancel];
  171. [_vTableView reloadData];
  172. [self showAlertViewText:@"加载失败"];
  173. }
  174. #pragma mark 委托tablview回调函数
  175. /**
  176. 行数
  177. @param tableView tableView description
  178. @param section section description
  179. @return return value description
  180. */
  181. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  182. {
  183. return [_dataList count];
  184. }
  185. /**
  186. Sections数
  187. @param tableView <#tableView description#>
  188. @return <#return value description#>
  189. */
  190. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  191. return 1;
  192. }
  193. /**
  194. 高度
  195. @param tableView <#tableView description#>
  196. @param indexPath <#indexPath description#>
  197. @return <#return value description#>
  198. */
  199. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  200. return [self.heights[@(indexPath.row)]floatValue];
  201. }
  202. /**
  203. 预估高度
  204. @param tableView <#tableView description#>
  205. @param indexPath <#indexPath description#>
  206. @return <#return value description#>
  207. */
  208. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  209. return 170;
  210. }
  211. /**
  212. 单元格
  213. @param tableView <#tableView description#>
  214. @param indexPath <#indexPath description#>
  215. @return <#return value description#>
  216. */
  217. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  218. {
  219. static NSString *CellIdentifier = @"CustomerBalanceCell";
  220. CustomerBalanceCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  221. if (!cell) {
  222. cell=[[CustomerBalanceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  223. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  224. }
  225. else
  226. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  227. {
  228. while ([cell.contentView.subviews lastObject] != nil) {
  229. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  230. }
  231. }
  232. // CustomerBalanceCell *cell = [[ CustomerBalanceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CustomerBalanceCell"];
  233. // cell.selectionStyle = UITableViewCellSelectionStyleNone;//设置cell点击效果
  234. NSDictionary *dic= _dataList[indexPath.row];
  235. [cell initUI:dic];
  236. // if(dic!=nil)
  237. // {
  238. // cell.lblvaluecustomername.text=[dic objectForKey:@"CustomerName"];
  239. // cell.lblvaluestaff.text=[dic objectForKey:@"SalesManName"];
  240. // cell.lblvalueorg.text=[dic objectForKey:@"OrganizationName"];
  241. // float receivableValue = [[dic objectForKey:@"AccountReceivable"]floatValue];
  242. // float depositValue = [[dic objectForKey:@"DepositReceived"]floatValue];
  243. // float earnestValue = [[dic objectForKey:@"Earnest"]floatValue];
  244. // cell.lblvaluereceivable.text = [NSString stringWithFormat:@"¥%.2f",receivableValue ];
  245. // cell.lblvaluedeposit.text = [NSString stringWithFormat:@"¥%.2f", depositValue ];
  246. // cell.lblvalueearnest.text = [NSString stringWithFormat:@"¥%.2f", earnestValue ];
  247. // NSString *str = [NSString stringWithFormat:@"应收款-预收款-定金:¥%.2f",receivableValue-depositValue-earnestValue];
  248. // cell.lblreceivableAndDepositAndEarnest.text = str;
  249. // }
  250. // 存储高度
  251. self.heights[@(indexPath.row)] = @(cell.height);
  252. return cell;
  253. }
  254. /**
  255. 单元格选择事件
  256. @param tableView <#tableView description#>
  257. @param indexPath <#indexPath description#>
  258. */
  259. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  260. {
  261. NSDictionary *dic= _dataList[indexPath.row];
  262. if(dic!=nil)
  263. {
  264. NSString *customerid = [[dic objectForKey:@"CustomerID"] stringValue];
  265. if (customerid==nil || customerid.length==0) {
  266. return;
  267. }
  268. self.hidesBottomBarWhenPushed=YES;
  269. CustomerBalanceDetailViewController *detailVC =[[CustomerBalanceDetailViewController alloc]init];
  270. detailVC.sCustomerName=[dic objectForKey:@"CustomerName"];
  271. detailVC.sCustomerCode=[dic objectForKey:@"CustomerCode"];
  272. detailVC.sChannelName=[dic objectForKey:@"ChannelName"];
  273. detailVC.sAccountOrganizationName=[dic objectForKey:@"AccountOrganizationName"];
  274. detailVC.sOrganizationName=[dic objectForKey:@"OrganizationName"];
  275. detailVC.sDictionaryValue=[dic objectForKey:@"DictionaryValue"];
  276. detailVC.sStaffName=[dic objectForKey:@"SalesManName"];
  277. detailVC.sDistrictName=[dic objectForKey:@"DistrictName"];
  278. detailVC.sCreditLine=[NSString stringWithFormat:@"%.f",[[dic objectForKey:@"CreditLine"]floatValue]];
  279. detailVC.sAddress=[dic objectForKey:@"Address"];
  280. detailVC.sTelephone=[dic objectForKey:@"Telephone"];
  281. detailVC.sEarnest=[NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Earnest"]floatValue]];
  282. detailVC.sAmountReceivable=[NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"AccountReceivable"]floatValue]];
  283. detailVC.sDepositReceived=[NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"DepositReceived"]floatValue]];
  284. [self.navigationController pushViewController:detailVC animated:YES];
  285. }
  286. }
  287. #pragma mark - 私有函数
  288. /**
  289. 初始化ui
  290. */
  291. - (void)initUI {
  292. CGFloat height = 210;
  293. self.navigationItem.title=@"客户往来余额表";
  294. self.view.backgroundColor = [UIColor whiteColor];
  295. //分割线
  296. UIView *viewBackgroud = [UIView new];
  297. viewBackgroud.frame = CGRectMake(0, 0, Screen_Width, 0);
  298. viewBackgroud.backgroundColor = LineBackgroundColor;
  299. [self.view addSubview:viewBackgroud];
  300. _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
  301. _vTableView.rowHeight = UITableViewAutomaticDimension;
  302. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  303. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  304. _vTableView.backgroundColor = [UIColor whiteColor];
  305. _vTableView.delegate = self;
  306. _vTableView.dataSource=self;
  307. _vTableView.tableHeaderView = nil;
  308. [self.view addSubview:_vTableView];
  309. //头布局
  310. _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
  311. UIButton *btnHead=[UIButton buttonWithType:UIButtonTypeCustom];
  312. btnHead.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  313. CGFloat titleHeight = 50;
  314. CGFloat lblx = 20;
  315. CGFloat lblwidth = 130;
  316. CGFloat fontsize = 14;
  317. //CGFloat valuex = 125;
  318. CGFloat valuey = 10;
  319. CGFloat valuewidth = 200;
  320. CGFloat valueheight = 25;
  321. CGFloat heightLine =1;
  322. //总合计==================
  323. UIView *vtotal=[UIView new];
  324. vtotal.frame=CGRectMake(0, 0, Screen_Width, titleHeight);
  325. [_headView addSubview:vtotal];
  326. UILabel *lbtotal = [UILabel new];
  327. lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
  328. lbtotal.font = [UIFont boldSystemFontOfSize:fontsize];
  329. lbtotal.text=@"合计";
  330. [vtotal addSubview:lbtotal];
  331. //分割线
  332. viewBackgroud = [UIView new];
  333. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
  334. viewBackgroud.backgroundColor = LineBackgroundColor;
  335. [_headView addSubview:viewBackgroud];
  336. //应收款==================
  337. UIView *vtotalreceivable=[UIView new];
  338. vtotalreceivable.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  339. [_headView addSubview:vtotalreceivable];
  340. UIImageView *imgview = [UIImageView new];
  341. imgview.frame=CGRectMake(lblx, valuey+5, 21, 20);
  342. [imgview setImage:[UIImage imageNamed:@"balance_receivable"]];
  343. [vtotalreceivable addSubview:imgview];
  344. UILabel *lblText = [UILabel new];
  345. lblText.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey+3, lblwidth, valueheight);
  346. lblText.font = [UIFont systemFontOfSize:fontsize];
  347. lblText.text=@"应收款";
  348. [vtotalreceivable addSubview:lblText];
  349. self.lblReceivable = [UILabel new];
  350. self.lblReceivable.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey+3, valuewidth, valueheight);
  351. self.lblReceivable.font = [UIFont systemFontOfSize:fontsize];
  352. //lblreceivable = @"¥0";
  353. self.lblReceivable.textAlignment = NSTextAlignmentRight;
  354. [vtotalreceivable addSubview:self.lblReceivable];
  355. viewBackgroud = [UIView new];
  356. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalreceivable.frame), Screen_Width, heightLine);
  357. viewBackgroud.backgroundColor = LineBackgroundColor;
  358. [_headView addSubview:viewBackgroud];
  359. //预收款==================
  360. UIView *vtotaldeposit=[UIView new];
  361. vtotaldeposit.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  362. [_headView addSubview:vtotaldeposit];
  363. UIImageView *imgviewReceivable = [UIImageView new];
  364. imgviewReceivable.frame=CGRectMake(lblx, valuey+5, 20, 20);
  365. [imgviewReceivable setImage:[UIImage imageNamed:@"balance_deposit"]];
  366. [vtotaldeposit addSubview:imgviewReceivable];
  367. lblText = [UILabel new];
  368. lblText.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey+3, lblwidth, valueheight);
  369. lblText.font = [UIFont systemFontOfSize:fontsize];
  370. lblText.text=@"预收款";
  371. [vtotaldeposit addSubview:lblText];
  372. self.lblDeposit = [UILabel new];
  373. self.lblDeposit.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey+3, valuewidth, valueheight);
  374. self.lblDeposit.font = [UIFont systemFontOfSize:fontsize];
  375. //lbldeposit = @"¥0";
  376. self.lblDeposit.textAlignment = NSTextAlignmentRight;
  377. [vtotaldeposit addSubview:self.lblDeposit];
  378. viewBackgroud = [UIView new];
  379. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotaldeposit.frame), Screen_Width,heightLine);
  380. viewBackgroud.backgroundColor = LineBackgroundColor;
  381. [_headView addSubview:viewBackgroud];
  382. //定金==================
  383. UIView *vtotalearnest=[UIView new];
  384. vtotalearnest.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  385. [_headView addSubview:vtotalearnest];
  386. UIImageView *imgviewProfit = [UIImageView new];
  387. imgviewProfit.frame=CGRectMake(lblx, valuey+5, 20, 20);
  388. [imgviewProfit setImage:[UIImage imageNamed:@"balance_earnest"]];
  389. [vtotalearnest addSubview:imgviewProfit];
  390. lblText = [UILabel new];
  391. lblText.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey+3, lblwidth, valueheight);
  392. lblText.font = [UIFont systemFontOfSize:fontsize];
  393. lblText.text=@"定金";
  394. [vtotalearnest addSubview:lblText];
  395. self.lblEarnest = [UILabel new];
  396. self.lblEarnest.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey+3, valuewidth, valueheight);
  397. self.lblEarnest.font = [UIFont systemFontOfSize:fontsize];
  398. //lbtotalProfitValue = @"¥0";
  399. self.lblEarnest.textAlignment = NSTextAlignmentRight;
  400. [vtotalearnest addSubview:self.lblEarnest];
  401. viewBackgroud = [UIView new];
  402. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalearnest.frame), Screen_Width,heightLine);
  403. viewBackgroud.backgroundColor = LineBackgroundColor;
  404. [_headView addSubview:viewBackgroud];
  405. // 应收款-预存款-定金==================
  406. UIView *vreceivableAndDepositAndEarnest=[UIView new];
  407. vreceivableAndDepositAndEarnest.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  408. [_headView addSubview:vreceivableAndDepositAndEarnest];
  409. imgview = [UIImageView new];
  410. imgview.frame=CGRectMake(lblx, valuey+5, 20, 20);
  411. [imgview setImage:[UIImage imageNamed:@"order_sale_total"]];
  412. [vreceivableAndDepositAndEarnest addSubview:imgview];
  413. lblText = [UILabel new];
  414. lblText.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey+3, 200, valueheight);
  415. lblText.font = [UIFont systemFontOfSize:fontsize];
  416. lblText.text=@"应收款-预存款-定金";
  417. [vreceivableAndDepositAndEarnest addSubview:lblText];
  418. self.lblReceivableAndDepositAndEarnest = [UILabel new];
  419. self.lblReceivableAndDepositAndEarnest.frame=CGRectMake(CGRectGetMaxY(lblText.frame), valuey+3, Screen_Width - CGRectGetMaxY(lblText.frame) - lblx, valueheight);
  420. self.lblReceivableAndDepositAndEarnest.font = [UIFont systemFontOfSize:fontsize];
  421. //lbtotalProfitValue = @"¥0";
  422. self.lblReceivableAndDepositAndEarnest.textAlignment = NSTextAlignmentRight;
  423. [vreceivableAndDepositAndEarnest addSubview:self.lblReceivableAndDepositAndEarnest];
  424. // viewBackgroud = [UIView new];
  425. // viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalearnest.frame), Screen_Width, 10);
  426. // viewBackgroud.backgroundColor = LineBackgroundColor;
  427. //[headView addSubview:viewBackgroud];
  428. _headView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vreceivableAndDepositAndEarnest.frame));
  429. _vTableView.tableHeaderView = _headView;
  430. }
  431. /**
  432. 进度条隐藏
  433. */
  434. - (void)Cancel {
  435. [self stopLoading];
  436. }
  437. /**
  438. 加载数据
  439. */
  440. - (void)reloadData
  441. {
  442. [self startLoading];
  443. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  444. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  445. [dict setObject:@"GetCustomerBalanceIphone" forKey:@"Action"];
  446. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  447. [dict setObject:kkUserCode forKey:@"UserCode"];
  448. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  449. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  450. [dict setObject:self.sOrg forKeyedSubscript:@"OrganizationID"];
  451. [dict setObject:self.sStaff forKeyedSubscript:@"Reporter"];
  452. [dict setObject:self.sSummaryType forKeyedSubscript:@"SortType"];
  453. [dict setObject:self.isBalance forKeyedSubscript:@"IsBalance"];
  454. [dict setObject:self.customerCode forKeyedSubscript:@"CustomerCode"];
  455. [dict setObject:self.customerName forKeyedSubscript:@"CustomerName"];
  456. self.downManager = [[ASIDownManager alloc] init];
  457. self.downManager.delegate = self;
  458. self.downManager.OnImageDown = @selector(onLoadFinish:);
  459. self.downManager.OnImageFail = @selector(onLoadFail:);
  460. [self.downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  461. }
  462. /**
  463. 返回
  464. */
  465. - (void)GoBack
  466. {
  467. [self.navigationController popViewControllerAnimated:YES];
  468. }
  469. /**
  470. 导航按钮样式
  471. */
  472. -(void)loadNavStyle
  473. {
  474. //右边
  475. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 16)];
  476. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  477. [btnfilter addTarget:self action:@selector(search)
  478. forControlEvents:UIControlEventTouchUpInside];
  479. btnfilter.frame = CGRectMake(0, 0, 16, 16);
  480. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  481. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  482. forState:UIControlStateNormal];
  483. [v addSubview:btnfilter];
  484. UIButton *filterLbl=[[UIButton alloc]init];
  485. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  486. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  487. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  488. filterLbl.titleLabel.font=[UIFont systemFontOfSize:ButtonFontOfSize];
  489. [filterLbl addTarget:self action:@selector(search)
  490. forControlEvents:UIControlEventTouchUpInside];
  491. [v addSubview:filterLbl];
  492. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  493. self.navigationItem.rightBarButtonItem = menubtnAdd;
  494. //返回
  495. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  496. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  497. forState:UIControlStateNormal];
  498. [button addTarget:self action:@selector(GoBack)
  499. forControlEvents:UIControlEventTouchUpInside];
  500. button.frame = CGRectMake(0, 0, 15, 18);
  501. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  502. self.navigationItem.leftBarButtonItem = menuButton;
  503. }
  504. /**
  505. 抽屉弹出
  506. */
  507. - (void)search{
  508. [_filterController show];
  509. }
  510. /**
  511. 抽屉初始化
  512. */
  513. - (void)initSlideSlip{
  514. // 抽屉对象
  515. __weak typeof(self) weakself=self;
  516. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  517. for (SideSlipModel *model in dataList) {
  518. //selectedItem
  519. model.selectedItemList = nil;
  520. model.customDict = nil;
  521. }
  522. } commitBlock:^(NSArray *dataList) {
  523. // 查询条件
  524. SideSlipModel *serviceRegionModel = dataList[0];
  525. CustomerBalanceSearchModel *m = [serviceRegionModel.customDict objectForKey:CUSTOMER_BALANCE_SEARCH_RANGE_MODEL];
  526. //NSLog(@"%@--%@--%@--%@--%@",m.startDate,m.endDate,m.sCustomerName,m.sOrg,m.sStaff);
  527. self.sOrg = m.sOrg;
  528. self.sStaff = m.sStaff;
  529. self.sSummaryType = m.sSummaryType;
  530. self.isBalance = m.filter;
  531. self.customerCode=m.customerCode;
  532. self.customerName=m.customerName;
  533. self.isBalance=m.filter;
  534. [weakself.filterController dismiss];
  535. [self reloadData];
  536. }];
  537. _filterController.animationDuration = AnimationDuration;
  538. _filterController.hasHeadView = YES;
  539. _filterController.sideSlipLeading = UIScreenSideSlipLeading * [UIScreen mainScreen].bounds.size.width;
  540. _filterController.dataList = [self packageDataList];
  541. }
  542. /**
  543. 数据源
  544. @return <#return value description#>
  545. */
  546. - (NSArray *)packageDataList {
  547. NSMutableArray *dataArray = [NSMutableArray array];
  548. SideSlipModel *model = [[SideSlipModel alloc] init];
  549. model.containerCellClass = @"CustomerBalanceSearchCell";
  550. model.regionTitle = @"查询条件";
  551. [dataArray addObject:model];
  552. return [dataArray mutableCopy];
  553. }
  554. @end