SingleProfitViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. //
  2. // SingleProfitViewController.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/15.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:每单利润表控制器
  9. //
  10. #import "SingleProfitViewController.h"
  11. #import "SingleProfitDetailViewController.h"
  12. #import "SingleProfitSearchModel.h"
  13. #import "SingleProfitCell.h"
  14. #import "DateFormat.h"
  15. @interface SingleProfitViewController ()<UITableViewDelegate,UITableViewDataSource>{
  16. //TableView对象
  17. UITableView *_vTableView;
  18. // 头信息view
  19. UIView *_headView;
  20. }
  21. /**
  22. 原始数据源
  23. */
  24. @property (strong,nonatomic) NSMutableArray *arrDataList;
  25. /**
  26. 原始数据源
  27. */
  28. @property (strong,nonatomic) NSMutableArray *arrDataNewList;
  29. /**
  30. 请求数据对象
  31. */
  32. @property (nonatomic,strong) ASIDownManager *downManager;
  33. @end
  34. static CGFloat headerH = 188;
  35. @implementation SingleProfitViewController
  36. #pragma mark - 公共函数
  37. /**
  38. viewDidLoad函数
  39. */
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. //[self showTitle:@"每单利润表"];
  43. [self loadNavStyle];
  44. [self initUI];
  45. [self initSlideSlip];
  46. [self defaultInterfaceRequest];
  47. // UIView *view = [self backGroundPromptViewByFrame:_vTableView.bounds promptStr:@"请筛选后查询"];
  48. // _vTableView.tableHeaderView = nil;
  49. // _vTableView.backgroundView = view;
  50. // [self reloadData];
  51. }
  52. /**
  53. 安全区视图发生变化
  54. */
  55. -(void)viewSafeAreaInsetsDidChange{
  56. CGRect tblVFrame = self.view.safeAreaLayoutGuide.layoutFrame;
  57. tblVFrame.origin.y = headerH;
  58. _vTableView.frame=tblVFrame;
  59. //修改tableView尺寸(2019-06-10 yesen)
  60. // _vTableView.frame=self.view.safeAreaLayoutGuide.layoutFrame;
  61. [super viewSafeAreaInsetsDidChange];
  62. }
  63. #pragma mark - 数据源list属性
  64. /**
  65. 原始数据源
  66. @return <#return value description#>
  67. */
  68. - (NSMutableArray *)arrDataList{
  69. if(_arrDataList == nil){
  70. _arrDataList = [[NSMutableArray alloc]init];
  71. }
  72. return _arrDataList;
  73. }
  74. /**
  75. 新数据源
  76. @return <#return value description#>
  77. */
  78. - (NSMutableArray *)arrDataNewList{
  79. if(_arrDataNewList == nil){
  80. _arrDataNewList = [[NSMutableArray alloc]init];
  81. }
  82. return _arrDataNewList;
  83. }
  84. #pragma mark 委托接口回调函数
  85. /**
  86. 调用接口成功回调
  87. @param sender <#sender description#>
  88. */
  89. - (void)onLoadFinish:(ASIDownManager *)sender {
  90. // 取消进度条
  91. [self cancel];
  92. // 服务器返回数据
  93. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  94. // 服务器返回数据状态值
  95. int iStatus = resultModel.status;
  96. // 服务器返回数据消息
  97. NSString *message = resultModel.message;
  98. _vTableView.tableHeaderView = nil;
  99. _vTableView.backgroundView = nil;
  100. // 服务器返回数据状态值正确
  101. if (iStatus == 0) {
  102. // 服务器返回数据结果
  103. NSArray *approvArr = (NSArray *)resultModel.result;
  104. [self.arrDataList removeAllObjects];
  105. [self.arrDataNewList removeAllObjects];
  106. // 是否有数据
  107. if(approvArr != nil && approvArr.count > 0)
  108. {
  109. [self.arrDataList addObjectsFromArray:approvArr];
  110. double totalCostValue = 0.0;
  111. double totalIncometValue = 0.0;
  112. double totalProfitValue = 0.0;
  113. // 合计信息
  114. for (int i = 0; i < self.arrDataList.count; i++) {
  115. NSDictionary *dicValue = self.arrDataList[i];
  116. // 去除空数据
  117. if ([[dicValue objectForKey:@"InvoiceID"] intValue]>0) {
  118. // _vTableView.tableHeaderView = _headView;
  119. [self.arrDataNewList addObject:self.arrDataList[i]];
  120. totalCostValue+= [[dicValue objectForKey:@"CostAmount"] doubleValue];
  121. totalProfitValue+= [[dicValue objectForKey:@"MarginAmount"] doubleValue];
  122. totalIncometValue+= [[dicValue objectForKey:@"Amount"] doubleValue];
  123. }
  124. }
  125. if(self.arrDataNewList.count == 0){
  126. [self showNoData];
  127. }
  128. // 合计信息
  129. self.lbtotalCostValue.text =[Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalCostValue]];
  130. self.lbtotalIncometValue.text = [Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalIncometValue]];
  131. self.lbtotalProfitValue.text =[Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalProfitValue]];
  132. }
  133. else
  134. {
  135. [self showNoData];
  136. }
  137. // 属性数据源
  138. [_vTableView reloadData];
  139. }
  140. // 服务器返回数据状态值异常
  141. else if(iStatus == ActionResultStatusAuthError
  142. ||iStatus == ActionResultStatusNoLogin
  143. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  144. [self showReLoginDialog:message];
  145. }
  146. else {
  147. [_vTableView reloadData];
  148. [self showAlertViewText:message];
  149. }
  150. }
  151. -(void) showNoData{
  152. // 无数据的view
  153. UIView *noDataView = [self noDataViewByFrame:_vTableView.bounds];
  154. // 有刷新数据的时候
  155. _vTableView.backgroundView = noDataView;
  156. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  157. [self showAlertViewBackText:@"未找到匹配结果"];
  158. }
  159. /**
  160. 调用接口失败回调
  161. @param sender <#sender description#>
  162. */
  163. - (void)onLoadFail:(ASIDownManager *)sender {
  164. [self cancel];
  165. [_vTableView reloadData];
  166. [self showAlertViewText:@"网络异常"];
  167. }
  168. #pragma mark 委托tablview回调函数
  169. /**
  170. 行数
  171. @param tableView tableView description
  172. @param section section description
  173. @return return value description
  174. */
  175. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  176. {
  177. return [self.arrDataNewList count];
  178. }
  179. /**
  180. Sections数
  181. @param tableView <#tableView description#>
  182. @return <#return value description#>
  183. */
  184. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  185. return 1;
  186. }
  187. /**
  188. 高度
  189. @param tableView <#tableView description#>
  190. @param indexPath <#indexPath description#>
  191. @return <#return value description#>
  192. */
  193. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  194. return 185;
  195. }
  196. /**
  197. 单元格
  198. @param tableView <#tableView description#>
  199. @param indexPath <#indexPath description#>
  200. @return <#return value description#>
  201. */
  202. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  203. {
  204. static NSString *CellIdentifier = @"SingleProfitCell";
  205. SingleProfitCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  206. if (cell == nil) {
  207. cell = [[SingleProfitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  208. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  209. }
  210. // SingleProfitCell *cell = [[ SingleProfitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SingleProfitCell"];
  211. NSDictionary *dic = self.arrDataNewList[indexPath.row];
  212. if(dic != nil)
  213. {
  214. cell.lblValueCustomerName.text = [dic objectForKey:@"CustomerName"];
  215. // 格式化日期
  216. DateFormat *df = [DateFormat new];
  217. cell.lblValueCreateTime.text = [df dateFormat:[dic objectForKey:@"AccountDate"]];
  218. //业务类型
  219. cell.lblValueCustomerType.text = [dic objectForKey:@"InvoiceTypeName"];
  220. cell.lblValueStaff.text = [dic objectForKey:@"StaffName"];
  221. cell.lblValueOrg.text = [dic objectForKey:@"OrganizationName"];
  222. double amountValue= [[dic objectForKey:@"Amount"]doubleValue];
  223. NSString *amountStr= [NSString stringWithFormat:@"%.2f",amountValue];
  224. amountStr= [Util positiveFormat:amountStr];
  225. double costValue= [[dic objectForKey:@"CostAmount"]doubleValue];
  226. NSString *costStr= [NSString stringWithFormat:@"%.2f",costValue];
  227. costStr=[Util positiveFormat:costStr];
  228. double marginAmountValue= [[dic objectForKey:@"MarginAmount"]doubleValue];
  229. NSString *marginAmountStr= [NSString stringWithFormat:@"%.2f",marginAmountValue];
  230. marginAmountStr=[Util positiveFormat:marginAmountStr];
  231. NSString *str = [NSString stringWithFormat:@"收入%@;成本:%@;毛利:%@",amountStr,costStr,marginAmountStr];
  232. cell.lblValueIncomeAndCostAndProfit.text = str;
  233. }
  234. return cell;
  235. }
  236. /**
  237. 单元格选择事件
  238. @param tableView <#tableView description#>
  239. @param indexPath <#indexPath description#>
  240. */
  241. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  242. {
  243. NSDictionary *dic = self.arrDataNewList[indexPath.row];
  244. if(dic != nil)
  245. {
  246. self.hidesBottomBarWhenPushed=YES;
  247. SingleProfitDetailViewController *detailVC = [[SingleProfitDetailViewController alloc]init];
  248. detailVC.sInvoiceNo = [dic objectForKey:@"InvoiceNo"];
  249. detailVC.sInvoiceType = [dic objectForKey:@"InvoiceTypeName"];
  250. detailVC.sOrganizationCode = [dic objectForKey:@"OrganizationCode"];
  251. detailVC.sCustomerCode = [dic objectForKey:@"CustomerCode"];
  252. detailVC.sTelephone = [dic objectForKey:@"Telephone"];
  253. detailVC.sCustomerAddress = [dic objectForKey:@"CustomerAddress"];
  254. detailVC.sChannelName = [dic objectForKey:@"ChannelName"];
  255. detailVC.sRemarks = [dic objectForKey:@"Remarks"];
  256. detailVC.sCustomerName = [dic objectForKey:@"CustomerName"];
  257. // 格式化日期
  258. DateFormat *df = [DateFormat new];
  259. detailVC.sAccountDate = [df dateFormat:[dic objectForKey:@"AccountDate"]];
  260. detailVC.sCustomerTypeName = [dic objectForKey:@"CustomerTypeName"];
  261. detailVC.sStaffName = [dic objectForKey:@"StaffName"];
  262. detailVC.sOrganizationName = [dic objectForKey:@"OrganizationName"];
  263. detailVC.sMarginAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"MarginAmount"]floatValue]];
  264. detailVC.sIncomeAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"Amount"]floatValue]];
  265. detailVC.sCostAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"CostAmount"]floatValue]];;
  266. detailVC.sCustomerAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"CustomerAmount"]floatValue]];;
  267. detailVC.sStaffAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"StaffAmount"]floatValue]];;
  268. detailVC.sServiceAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"ServiceAmount"]floatValue]];;
  269. detailVC.sFeesAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"FeesAmount"]floatValue]];;
  270. detailVC.sProfitAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"ProfitAmount"]floatValue]];;
  271. [self.navigationController pushViewController:detailVC animated:YES];
  272. }
  273. }
  274. #pragma mark - 私有函数
  275. /**
  276. 初始化ui
  277. */
  278. - (void)initUI {
  279. CGFloat height = 188;
  280. self.navigationItem.title = @"每单利润表";
  281. self.view.backgroundColor = [UIColor whiteColor];
  282. //分割线
  283. UIView *viewBackgroud = [UIView new];
  284. viewBackgroud.frame = CGRectMake(0, 0, Screen_Width, 0);
  285. viewBackgroud.backgroundColor = LineBackgroundColor;
  286. [self.view addSubview:viewBackgroud];
  287. _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,height, Screen_Width, Screen_Height - height)];
  288. _vTableView.rowHeight = UITableViewAutomaticDimension;
  289. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  290. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  291. _vTableView.backgroundColor = [UIColor whiteColor];
  292. _vTableView.delegate = self;
  293. _vTableView.dataSource=self;
  294. // _vTableView.tableHeaderView = nil;
  295. [self.view addSubview:_vTableView];
  296. //头布局
  297. _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
  298. [self.view addSubview:_headView];
  299. UIButton *btnHead = [UIButton buttonWithType:UIButtonTypeCustom];
  300. btnHead.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  301. CGFloat titleHeight = 46;
  302. CGFloat lblx = 20;
  303. CGFloat lblwidth = 130;
  304. CGFloat fontsize = 14;
  305. //CGFloat valuex = 125;
  306. CGFloat valuey = 10;
  307. CGFloat valuewidth = 200;
  308. CGFloat valueheight = 25;
  309. CGFloat heightLine =1;
  310. //总合计 —————————
  311. UIView *vtotal = [UIView new];
  312. vtotal.frame=CGRectMake(0, 0, Screen_Width, titleHeight);
  313. [_headView addSubview:vtotal];
  314. UILabel *lbtotal = [UILabel new];
  315. lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
  316. lbtotal.font = [UIFont boldSystemFontOfSize:fontsize];
  317. lbtotal.text = @"合计";
  318. [vtotal addSubview:lbtotal];
  319. //分割线
  320. viewBackgroud = [UIView new];
  321. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
  322. viewBackgroud.backgroundColor = LineBackgroundColor;
  323. [_headView addSubview:viewBackgroud];
  324. //收入总额 —————————
  325. UIView *vtotalIncome = [UIView new];
  326. vtotalIncome.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  327. [_headView addSubview:vtotalIncome];
  328. UIImageView *imgview = [UIImageView new];
  329. imgview.frame=CGRectMake(lblx, valuey+5, 21, 16);
  330. [imgview setImage:[UIImage imageNamed:@"profit_income"]];
  331. [vtotalIncome addSubview:imgview];
  332. UILabel *lbtotalReceipt = [UILabel new];
  333. lbtotalReceipt.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey, lblwidth, valueheight);
  334. lbtotalReceipt.font = [UIFont systemFontOfSize:fontsize];
  335. lbtotalReceipt.text = @"收入";
  336. [vtotalIncome addSubview:lbtotalReceipt];
  337. self.lbtotalIncometValue = [UILabel new];
  338. self.lbtotalIncometValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
  339. self.lbtotalIncometValue.font = [UIFont systemFontOfSize:fontsize];
  340. //lbtotalIncometValue = @"¥0";
  341. self.lbtotalIncometValue.textAlignment = NSTextAlignmentRight;
  342. [vtotalIncome addSubview:self.lbtotalIncometValue];
  343. viewBackgroud = [UIView new];
  344. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalIncome.frame), Screen_Width, heightLine);
  345. viewBackgroud.backgroundColor = LineBackgroundColor;
  346. [_headView addSubview:viewBackgroud];
  347. //成本总额 —————————
  348. UIView *vtotalCost = [UIView new];
  349. vtotalCost.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  350. [_headView addSubview:vtotalCost];
  351. UIImageView *imgviewReceivable = [UIImageView new];
  352. imgviewReceivable.frame=CGRectMake(lblx, valuey+1, 20, 20);
  353. [imgviewReceivable setImage:[UIImage imageNamed:@"profit_cost"]];
  354. [vtotalCost addSubview:imgviewReceivable];
  355. UILabel *lbtotalReceivable = [UILabel new];
  356. lbtotalReceivable.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
  357. lbtotalReceivable.font = [UIFont systemFontOfSize:fontsize];
  358. lbtotalReceivable.text = @"成本";
  359. [vtotalCost addSubview:lbtotalReceivable];
  360. self.lbtotalCostValue = [UILabel new];
  361. self.lbtotalCostValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
  362. self.lbtotalCostValue.font = [UIFont systemFontOfSize:fontsize];
  363. //lbtotalCostValue = @"¥0";
  364. self.lbtotalCostValue.textAlignment = NSTextAlignmentRight;
  365. [vtotalCost addSubview:self.lbtotalCostValue];
  366. viewBackgroud = [UIView new];
  367. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalCost.frame), Screen_Width,heightLine);
  368. viewBackgroud.backgroundColor = LineBackgroundColor;
  369. [_headView addSubview:viewBackgroud];
  370. // —————————
  371. UIView *vtotalProfit = [UIView new];
  372. vtotalProfit.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  373. [_headView addSubview:vtotalProfit];
  374. UIImageView *imgviewProfit = [UIImageView new];
  375. imgviewProfit.frame=CGRectMake(lblx, valuey+1, 20, 20);
  376. [imgviewProfit setImage:[UIImage imageNamed:@"profit_value"]];
  377. [vtotalProfit addSubview:imgviewProfit];
  378. UILabel *lbtotalProfit = [UILabel new];
  379. lbtotalProfit.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
  380. lbtotalProfit.font = [UIFont systemFontOfSize:fontsize];
  381. lbtotalProfit.text = @"毛利";
  382. [vtotalProfit addSubview:lbtotalProfit];
  383. self.lbtotalProfitValue = [UILabel new];
  384. self.lbtotalProfitValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
  385. self.lbtotalProfitValue.font = [UIFont systemFontOfSize:fontsize];
  386. //lbtotalProfitValue = @"¥0";
  387. self.lbtotalProfitValue.textAlignment = NSTextAlignmentRight;
  388. [vtotalProfit addSubview:self.lbtotalProfitValue];
  389. viewBackgroud = [UIView new];
  390. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalProfit.frame), Screen_Width, 10);
  391. viewBackgroud.backgroundColor = LineBackgroundColor;
  392. //[headView addSubview:viewBackgroud];
  393. viewBackgroud = [UIView new];
  394. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalProfit.frame), Screen_Width, heightLine);
  395. viewBackgroud.backgroundColor = LineBackgroundColor;
  396. [_headView addSubview:viewBackgroud];
  397. _headView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vtotalProfit.frame));
  398. //头部改为固定 2019-06-10 (yesen)
  399. // _vTableView.tableHeaderView = _headView;
  400. //开始结束日期 初始值
  401. // 格式化日期
  402. // NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  403. // [dateFormatter setDateFormat:@"yyyy-MM-dd"];
  404. // NSTimeInterval time = 366 * 24 * 60 * 60; //31天的秒数
  405. // self.sEndDate = [dateFormatter stringFromDate:[NSDate new]];
  406. // self.sStartDate = [dateFormatter stringFromDate: [[NSDate new] dateByAddingTimeInterval:-time]];
  407. }
  408. /**
  409. 进度条隐藏
  410. */
  411. - (void)cancel {
  412. [self stopLoading];
  413. }
  414. - (void)defaultInterfaceRequest{
  415. //NSString *startDateStr = [DateFormat getDateBefore:365];
  416. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  417. [dateFormatter setDateFormat:@"YYYY-MM-dd"];
  418. NSString *endDateStr = [DateFormat getCurrentDate];
  419. NSDate *currentDate = [NSDate date];
  420. NSDate *startDate = [DateFormat getPriorLaterDateFromDate:currentDate withMonth:-12];
  421. self.sStartDate = [dateFormatter stringFromDate:startDate];
  422. self.sEndDate = endDateStr;
  423. self.sBusinessType=@"7";
  424. [self reloadData];
  425. }
  426. /**
  427. 加载数据
  428. */
  429. - (void)reloadData
  430. {
  431. [self startLoading];
  432. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  433. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  434. [dict setObject:@"GetSingleProfitIphone" forKey:@"Action"];
  435. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  436. [dict setObject:kkUserCode forKey:@"UserCode"];
  437. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  438. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  439. [dict setObject:self.sBusinessType forKeyedSubscript:@"BusinessType"];
  440. [dict setObject:self.sOrgCode forKeyedSubscript:@"OrganizationCode"];
  441. [dict setObject:self.sStaffName forKeyedSubscript:@"StaffName"];
  442. [dict setObject:self.sStartDate forKeyedSubscript:@"AccountDateFrom"];
  443. [dict setObject:self.sEndDate forKeyedSubscript:@"AccountDateTo"];
  444. [dict setObject:self.sCustomerName forKeyedSubscript:@"CustomerName"];
  445. [dict setObject:self.sCustomerAddress forKeyedSubscript:@"Address"];
  446. [dict setObject:self.sCustomerCode forKeyedSubscript:@"CustomerCode"];
  447. _downManager = [[ASIDownManager alloc] init];
  448. _downManager.delegate = self;
  449. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  450. _downManager.onRequestFail = @selector(onLoadFail:);
  451. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  452. }
  453. /**
  454. 返回
  455. */
  456. - (void)goBack
  457. {
  458. [self.navigationController popViewControllerAnimated:YES];
  459. }
  460. /**
  461. 导航按钮样式
  462. */
  463. - (void)loadNavStyle
  464. {
  465. //右边
  466. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 16)];
  467. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  468. [btnfilter addTarget:self action:@selector(search)
  469. forControlEvents:UIControlEventTouchUpInside];
  470. btnfilter.frame = CGRectMake(0, 0, 16, 16);
  471. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  472. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  473. forState:UIControlStateNormal];
  474. [v addSubview:btnfilter];
  475. UIButton *filterLbl = [[UIButton alloc]init];
  476. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  477. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  478. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  479. filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
  480. [filterLbl addTarget:self action:@selector(search)
  481. forControlEvents:UIControlEventTouchUpInside];
  482. [v addSubview:filterLbl];
  483. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  484. self.navigationItem.rightBarButtonItem = menubtnAdd;
  485. //返回
  486. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  487. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  488. [button addTarget:self action:@selector(goBack)
  489. forControlEvents:UIControlEventTouchUpInside];
  490. button.frame = CGRectMake(0, 0,45,22);
  491. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  492. self.navigationItem.leftBarButtonItem = menuButton;
  493. }
  494. /**
  495. 抽屉弹出
  496. */
  497. - (void)search{
  498. [_filterController show];
  499. }
  500. /**
  501. 抽屉初始化
  502. */
  503. - (void)initSlideSlip{
  504. // 抽屉对象
  505. __weak typeof(self) weakself=self;
  506. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  507. for (SideSlipModel *model in dataList) {
  508. //selectedItem
  509. model.selectedItemList = nil;
  510. model.customDict = nil;
  511. }
  512. } commitBlock:^(NSArray *dataList) {
  513. // 查询条件
  514. SideSlipModel *serviceRegionModel = dataList[0];
  515. SingleProfitSearchModel *m = [serviceRegionModel.customDict objectForKey:SINGLE_PROFIT_SEARCH_RANGE_MODEL];
  516. //NSLog(@"%@--%@--%@--%@--%@",m.startDate,m.endDate,m.sCustomerName,m.sOrg,m.sStaff);
  517. self.sOrgCode = m.sOrg;
  518. self.sStaffName = m.sStaff;
  519. self.sStartDate = m.sStartDate;
  520. self.sEndDate = m.sEndDate;
  521. self.sCustomerName = m.sCustomerName;
  522. self.sCustomerCode=m.sCustomerCode;
  523. self.sCustomerAddress=m.sCustomerAddress;
  524. self.sBusinessType=m.sBusinessType;
  525. if(self.sStartDate == nil || self.sStartDate.length == 0){
  526. [self showAlertViewText:@"请选择开始日期"];
  527. return;
  528. }
  529. if(self.sEndDate == nil || self.sEndDate.length == 0){
  530. [self showAlertViewText:@"请选择结束日期"];
  531. return;
  532. }
  533. NSUInteger result= [DateFormat compareDate:self.sStartDate withDate:self.sEndDate];
  534. if(result == -1){
  535. [self showAlertViewText:@"开始日期不能大于结束日期"];
  536. return;
  537. }
  538. // NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
  539. // [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式,这里可以设置成自己需要的格式
  540. //
  541. // NSDate *startD = [dateFormat dateFromString:self.sStartDate];
  542. // NSDate *endD = [dateFormat dateFromString:self.sEndDate];
  543. // NSInteger days= [DateFormat calculateDaysFromBegin:startD end:endD];
  544. //
  545. // if(days > 31){
  546. // [self showAlertViewText:@"日期间隔天数不能大于31天"];
  547. // return;
  548. // }
  549. [weakself.filterController dismiss];
  550. [self reloadData];
  551. }];
  552. _filterController.animationDuration = AnimationDuration;
  553. _filterController.hasHeadView = YES;
  554. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  555. _filterController.dataList = [self packageDataList];
  556. }
  557. /**
  558. 数据源
  559. @return <#return value description#>
  560. */
  561. - (NSArray *)packageDataList {
  562. NSMutableArray *dataArray = [NSMutableArray array];
  563. SideSlipModel *model = [[SideSlipModel alloc] init];
  564. model.containerCellClass = @"SingleProfitSearchCell";
  565. model.regionTitle = @"查询条件";
  566. [dataArray addObject:model];
  567. return [dataArray mutableCopy];
  568. }
  569. @end