OrderSaleViewController.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. //
  2. // OrderSaleViewController.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/15.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:订单销售单控制器
  9. //
  10. #import "OrderSaleViewController.h"
  11. #import "OrderSaleTotalModel.h"
  12. #import "DateFormat.h"
  13. #import "OrderSaleListModel.h"
  14. #import "OrderSalesTableViewCell.h"
  15. #import "SideSlipModel.h"
  16. #import "OrderSalesSearchModel.h"
  17. #import "OrderSalesDetailViewController.h"
  18. @interface OrderSaleViewController ()
  19. @end
  20. @implementation OrderSaleViewController
  21. #pragma mark - 公共函数
  22. /**
  23. viewDidLoad函数
  24. */
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. [self showTitle:@"销售单订单"];
  28. // _mEndDate= [DateFormat getCurrentDate];
  29. // _mStartDate = [DateFormat getDateBefore:31];
  30. [self loadNavStyle];
  31. [self initUI];
  32. [self initSlideSlip];
  33. _arrStock = [[NSMutableArray alloc]init];
  34. _arrModels = [[NSMutableArray alloc]init];
  35. _correctStatus = @"1";
  36. UIView *view = [self backGroundPromptViewByFrame:_vCustomTableView.bounds promptStr:@"请筛选后查询"];
  37. _vCustomTableView.backgroundView = view;
  38. //[self reloadData];
  39. }
  40. /**
  41. 安全区视图发生变化
  42. */
  43. -(void)viewSafeAreaInsetsDidChange{
  44. _vCustomTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  45. [super viewSafeAreaInsetsDidChange];
  46. }
  47. /**
  48. 抽屉初始化
  49. */
  50. - (void)initSlideSlip{
  51. // 抽屉对象
  52. __weak typeof(self) weakself=self;
  53. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  54. for (SideSlipModel *model in dataList) {
  55. model.selectedItemList = nil;
  56. model.customDict = nil;
  57. }
  58. } commitBlock:^(NSArray *dataList) {
  59. // 查询条件
  60. SideSlipModel *model = dataList[0];
  61. OrderSalesSearchModel *m = [model.customDict objectForKey:SEARCH_RANGE_MODEL];
  62. weakself.mStartDate=m.startDate;
  63. weakself.mEndDate=m.endDate;
  64. weakself.mCustomerName=m.customerName;
  65. weakself.mTelephone=m.contactTelephone;
  66. weakself.mInvoiceType=m.invoiceTypeId;
  67. weakself.correctStatus=m.correctStatus;
  68. weakself.mCustomerAddress=m.customerAddress;
  69. weakself.mOrganizationCode=m.departmentCode;
  70. weakself.staffId = m.staffId;
  71. if(_mStartDate == nil){
  72. [self showAlertViewText:@"请选择开始日期"];
  73. return;
  74. }
  75. if(_mEndDate == nil){
  76. [self showAlertViewText:@"请选择结束日期"];
  77. return;
  78. }
  79. NSUInteger result= [DateFormat compareDate:_mStartDate withDate:_mEndDate];
  80. if(result == -1){
  81. [self showAlertViewText:@"开始日期不能大于结束日期"];
  82. return;
  83. }
  84. // NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
  85. // [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式,这里可以设置成自己需要的格式
  86. //
  87. // NSDate *startD = [dateFormat dateFromString:_mStartDate];
  88. // NSDate *endD = [dateFormat dateFromString:_mEndDate];
  89. // NSInteger days= [DateFormat calculateDaysFromBegin:startD end:endD];
  90. //
  91. // if(days > 31){
  92. // [self showAlertViewText:@"日期间隔天数不能大于31天"];
  93. // return;
  94. // }
  95. [weakself.filterController dismiss];
  96. [self reloadData];
  97. }];
  98. _filterController.animationDuration = AnimationDuration;
  99. _filterController.hasHeadView = YES;
  100. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  101. _filterController.dataList = [self packageDataList];
  102. }
  103. /**
  104. 数据源
  105. @return <#return value description#>
  106. */
  107. - (NSArray *)packageDataList {
  108. NSMutableArray *dataArray = [NSMutableArray array];
  109. SideSlipModel *model = [[SideSlipModel alloc] init];
  110. model.containerCellClass = @"OrderSalesSearchTableViewCell";
  111. model.regionTitle = @"查询条件";
  112. [dataArray addObject:model];
  113. return [dataArray mutableCopy];
  114. }
  115. #pragma mark - 代理函数
  116. /**
  117. Sections
  118. @param tableView <#tableView description#>
  119. @return <#return value description#>
  120. */
  121. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  122. return 1;
  123. }
  124. /**
  125. 头高
  126. @param tableView <#tableView description#>
  127. @param section <#section description#>
  128. @return <#return value description#>
  129. */
  130. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  131. {
  132. return 10;
  133. }
  134. /**
  135. 列表个数
  136. @param tableView <#tableView description#>
  137. @param section <#section description#>
  138. @return <#return value description#>
  139. */
  140. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  141. return _arrModels.count;
  142. }
  143. /**
  144. 行高
  145. @param tableView <#tableView description#>
  146. @param indexPath <#indexPath description#>
  147. @return <#return value description#>
  148. */
  149. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  150. return 235;
  151. }
  152. /**
  153. cell
  154. @param tableView <#tableView description#>
  155. @param indexPath <#indexPath description#>
  156. @return <#return value description#>
  157. */
  158. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  159. static NSString *CellIdentifier = @"OrderSalesTableViewCell";
  160. OrderSalesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  161. if (!cell) {
  162. cell = [[OrderSalesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  163. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  164. }
  165. else
  166. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  167. {
  168. while ([cell.contentView.subviews lastObject] != nil) {
  169. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  170. }
  171. }
  172. // 单元格ui布局
  173. OrderSaleListModel *model=_arrModels[indexPath.row];
  174. [cell parseOrderSalesInfo:model];
  175. return cell;
  176. }
  177. /**
  178. 单元格点击事件
  179. @param tableView <#tableView description#>
  180. @param indexPath <#indexPath description#>
  181. */
  182. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  183. self.hidesBottomBarWhenPushed=YES;
  184. OrderSalesDetailViewController *detailvc = [[OrderSalesDetailViewController alloc] init];
  185. OrderSaleListModel *m = _arrModels[indexPath.row];
  186. detailvc.invoiceNo = m.invoiceNo;
  187. [self.navigationController pushViewController:detailvc animated:YES];
  188. }
  189. #pragma mark - 私有函数
  190. /**
  191. 初始化ui
  192. */
  193. - (void)initUI{
  194. self.navigationItem.title = @"订单销售单列表";
  195. self.view.backgroundColor = [UIColor whiteColor];
  196. _vCustomTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
  197. _vCustomTableView.rowHeight = UITableViewAutomaticDimension;
  198. _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  199. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  200. _vCustomTableView.backgroundColor = [UIColor whiteColor];
  201. _vCustomTableView.delegate = self;
  202. _vCustomTableView.dataSource=self;
  203. [self.view addSubview:_vCustomTableView];
  204. }
  205. -(void)initHeadView:(NSString*)invoiceType
  206. {
  207. // 合计
  208. _headView = [[UIView alloc]initWithFrame:CGRectZero];
  209. CGFloat lblx = 20;
  210. CGFloat lblwidth = 130;
  211. CGFloat valuey = 10;
  212. CGFloat valuewidth = 200;
  213. CGFloat valueheight = 25;
  214. CGFloat heightLine =1;
  215. UILabel *lbtotal = [UILabel new];
  216. lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
  217. lbtotal.font = reportTextFont;
  218. lbtotal.text = @"合计";
  219. [_headView addSubview:lbtotal];
  220. UIView *topSeparator = [UIView new];
  221. topSeparator.frame = CGRectMake(0, CGRectGetMaxY(lbtotal.frame)+valuey, Screen_Width, heightLine);
  222. topSeparator.backgroundColor = LineBackgroundColor;
  223. [_headView addSubview:topSeparator];
  224. UIImageView *goodsimgview = [UIImageView new];
  225. UIImage *goodsImg= [UIImage imageNamed:@"goods_amount"];
  226. goodsimgview.frame=CGRectMake(lblx,CGRectGetMaxY(topSeparator.frame)+valuey,goodsImg.size.width,goodsImg.size.height);
  227. [goodsimgview setImage:goodsImg];
  228. [_headView addSubview:goodsimgview];
  229. //货款总额
  230. UILabel *lblTitleGoodsAmount = [UILabel new];
  231. lblTitleGoodsAmount.frame=CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(topSeparator.frame)+valuey-3, lblwidth, valueheight);
  232. lblTitleGoodsAmount.font = reportTextFont;
  233. lblTitleGoodsAmount.text = @"货款总额";
  234. [_headView addSubview:lblTitleGoodsAmount];
  235. _lblGoodsAmount = [UILabel new];
  236. _lblGoodsAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(topSeparator.frame)+valuey-3, valuewidth, valueheight);
  237. _lblGoodsAmount.font = reportTextFont;
  238. _lblGoodsAmount.textAlignment = NSTextAlignmentRight;
  239. [_headView addSubview:_lblGoodsAmount];
  240. UIView *goodsSeparator = [UIView new];
  241. goodsSeparator.frame = CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(goodsimgview.frame)+valuey, Screen_Width, heightLine);
  242. goodsSeparator.backgroundColor = LineBackgroundColor;
  243. [_headView addSubview:goodsSeparator];
  244. UIImageView *discountimgview = [UIImageView new];
  245. UIImage *discountAmountImg= [UIImage imageNamed:@"discount_amount"];
  246. discountimgview.frame=CGRectMake(lblx,CGRectGetMaxY(goodsSeparator.frame)+valuey,discountAmountImg.size.width,discountAmountImg.size.height);
  247. [discountimgview setImage:discountAmountImg];
  248. [_headView addSubview:discountimgview];
  249. // 舍零金额
  250. UILabel *lblTitleDiscountAmount = [UILabel new];
  251. lblTitleDiscountAmount.frame=CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(goodsSeparator.frame)+valuey, lblwidth, valueheight);
  252. lblTitleDiscountAmount.font = reportTextFont;
  253. lblTitleDiscountAmount.text = @"舍零金额";
  254. [_headView addSubview:lblTitleDiscountAmount];
  255. _lblDiscountAmount = [UILabel new];
  256. _lblDiscountAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(goodsSeparator.frame)+valuey, valuewidth, valueheight);
  257. _lblDiscountAmount.font = reportTextFont;
  258. _lblDiscountAmount.textAlignment = NSTextAlignmentRight;
  259. [_headView addSubview:_lblDiscountAmount];
  260. UIView *discountSeparator = [UIView new];
  261. discountSeparator.frame = CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(discountimgview.frame)+valuey, Screen_Width, heightLine);
  262. discountSeparator.backgroundColor = LineBackgroundColor;
  263. [_headView addSubview:discountSeparator];
  264. //合计金额
  265. UIImageView *totalimgview = [UIImageView new];
  266. UIImage *totalImg= [UIImage imageNamed:@"total_amount"];
  267. totalimgview.frame=CGRectMake(lblx,CGRectGetMaxY(discountSeparator.frame)+valuey,totalImg.size.width,totalImg.size.height);
  268. [totalimgview setImage:totalImg];
  269. [_headView addSubview:totalimgview];
  270. UILabel *lblTitleTotalAmount = [UILabel new];
  271. lblTitleTotalAmount.frame=CGRectMake(CGRectGetMaxX(totalimgview.frame)+5, CGRectGetMaxY(discountSeparator.frame)+valuey-3, lblwidth, valueheight);
  272. lblTitleTotalAmount.font = reportTextFont;
  273. lblTitleTotalAmount.text = @"合计金额";
  274. [_headView addSubview:lblTitleTotalAmount];
  275. _lblTotalAmount = [UILabel new];
  276. _lblTotalAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(discountSeparator.frame)+valuey-3, valuewidth, valueheight);
  277. _lblTotalAmount.font = reportTextFont;
  278. _lblTotalAmount.textAlignment = NSTextAlignmentRight;
  279. [_headView addSubview:_lblTotalAmount];
  280. if([invoiceType isEqualToString:@"2"]||[invoiceType isEqualToString:@"0"]){
  281. UIView *totalSeparator = [UIView new];
  282. totalSeparator.frame = CGRectMake(CGRectGetMaxX(totalimgview.frame)+5, CGRectGetMaxY(totalimgview.frame)+valuey, Screen_Width, heightLine);
  283. totalSeparator.backgroundColor = LineBackgroundColor;
  284. [_headView addSubview:totalSeparator];
  285. //出库额
  286. UIImageView *outamountimgview = [UIImageView new];
  287. UIImage *outAmountImg= [UIImage imageNamed:@"outamount"];
  288. outamountimgview.frame=CGRectMake(lblx,CGRectGetMaxY(totalSeparator.frame)+valuey,outAmountImg.size.width,outAmountImg.size.height);
  289. [outamountimgview setImage:outAmountImg];
  290. [_headView addSubview:outamountimgview];
  291. UILabel *lblTitleOutAmount = [UILabel new];
  292. lblTitleOutAmount.frame=CGRectMake(CGRectGetMaxX(outamountimgview.frame)+5, CGRectGetMaxY(totalSeparator.frame)+valuey-3, lblwidth, valueheight);
  293. lblTitleOutAmount.font = reportTextFont;
  294. lblTitleOutAmount.text = @"出库金额";
  295. [_headView addSubview:lblTitleOutAmount];
  296. _lblOutAmount = [UILabel new];
  297. _lblOutAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(totalSeparator.frame)+valuey-3, valuewidth, valueheight);
  298. _lblOutAmount.font = reportTextFont;
  299. _lblOutAmount.textAlignment = NSTextAlignmentRight;
  300. [_headView addSubview:_lblOutAmount];
  301. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_lblOutAmount.frame)+5, SCREENWIDTH, 10)];
  302. line.backgroundColor = LineBackgroundColor;
  303. [_headView addSubview:line];
  304. _headView.frame=CGRectMake(0,0, Screen_Width, CGRectGetMaxY(line.frame));
  305. }
  306. else{
  307. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_lblTotalAmount.frame)+5, SCREENWIDTH, 10)];
  308. line.backgroundColor = LineBackgroundColor;
  309. [_headView addSubview:line];
  310. _headView.frame=CGRectMake(0,0, Screen_Width, CGRectGetMaxY(line.frame));
  311. }
  312. }
  313. /**
  314. 导航菜单
  315. */
  316. - (void)loadNavStyle
  317. {
  318. // 右边
  319. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
  320. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  321. [btnfilter addTarget:self action:@selector(search)
  322. forControlEvents:UIControlEventTouchUpInside];
  323. btnfilter.frame = CGRectMake(0, 0,16, 16);
  324. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  325. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  326. forState:UIControlStateNormal];
  327. [v addSubview:btnfilter];
  328. UIButton *filterLbl = [[UIButton alloc]init];
  329. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  330. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  331. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  332. filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
  333. [filterLbl addTarget:self action:@selector(search)
  334. forControlEvents:UIControlEventTouchUpInside];
  335. [v addSubview:filterLbl];
  336. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  337. self.navigationItem.rightBarButtonItem = menubtnAdd;
  338. //返回
  339. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  340. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  341. [button addTarget:self action:@selector(goBack)
  342. forControlEvents:UIControlEventTouchUpInside];
  343. button.frame = CGRectMake(0, 0,45,22);
  344. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  345. self.navigationItem.leftBarButtonItem = menuButton;
  346. }
  347. /**
  348. 抽屉弹出
  349. */
  350. - (void)search{
  351. [_filterController show];
  352. }
  353. /**
  354. 头数据
  355. @param md md description
  356. */
  357. - (void)initUIData:(OrderSaleTotalModel *)model{
  358. _lblGoodsAmount.text = [NSString stringWithFormat:@"¥%@",model.goodsAmount];
  359. _lblDiscountAmount.text = [NSString stringWithFormat:@"¥%@",model.discountAmount];
  360. _lblTotalAmount.text = [NSString stringWithFormat:@"¥%@",model.totalAmount];
  361. if([model.invoiceType isEqualToString:@"2"]||[model.invoiceType isEqualToString:@"0"]){
  362. _lblOutAmount.text = [NSString stringWithFormat:@"¥%@",model.outAmount];
  363. }
  364. // 加载数据
  365. [self loadDetailData];
  366. }
  367. /**
  368. 加载数据
  369. */
  370. - (void)loadDetailData{
  371. [self startLoading];
  372. NSString *urlStr = ServerURL;
  373. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  374. [dict setObject:@"GetOrderSalesReportListIphone" forKey:@"Action"];
  375. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  376. [dict setObject:kkUserCode forKey:@"UserCode"];
  377. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  378. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  379. // 参数
  380. if(_mStartDate == nil){
  381. [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
  382. }
  383. else{
  384. [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
  385. }
  386. if(_mEndDate == nil){
  387. [dict setObject:@"" forKeyedSubscript:@"EndTime"];
  388. }
  389. else{
  390. [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
  391. }
  392. if(_mCustomerAddress==nil){
  393. [dict setObject:@"" forKeyedSubscript:@"Address"];
  394. }
  395. else{
  396. [dict setObject:_mCustomerAddress forKeyedSubscript:@"Address"];
  397. }
  398. if(_mCustomerName == nil){
  399. [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
  400. }
  401. else{
  402. [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
  403. }
  404. if(_mOrganizationCode == nil){
  405. [dict setObject:@"" forKeyedSubscript:@"OrganizationCode"];
  406. }
  407. else{
  408. [dict setObject:_mOrganizationCode forKeyedSubscript:@"OrganizationCode"];
  409. }
  410. if(_mInvoiceType == nil){
  411. [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
  412. }
  413. else{
  414. [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
  415. }
  416. if(_mTelephone == nil){
  417. [dict setObject:@"" forKeyedSubscript:@"Telephone"];
  418. }
  419. else{
  420. [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
  421. }
  422. if (_staffId == nil) {
  423. [dict setObject:@"" forKeyedSubscript:@"staffID"];
  424. }else{
  425. [dict setObject:_staffId forKeyedSubscript:@"staffID"];
  426. }
  427. [dict setObject:@"1" forKeyedSubscript:@"IsTotalFlg"];
  428. int correctStatus;
  429. if (_correctStatus) {
  430. correctStatus=1;
  431. }
  432. else{
  433. correctStatus=0;
  434. }
  435. [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
  436. _downManager = [[ASIDownManager alloc] init];
  437. _downManager.delegate = self;
  438. _downManager.onRequestSuccess = @selector(onLoadDetailFinish:);
  439. _downManager.onRequestFail = @selector(onLoadDetailFail:);
  440. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  441. }
  442. /**
  443. 加载合集数据
  444. */
  445. - (void)reloadData
  446. {
  447. [self startLoading];
  448. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  449. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  450. [dict setObject:@"GetOrderSalesReportTotalIphone" forKey:@"Action"];
  451. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  452. [dict setObject:kkUserCode forKey:@"UserCode"];
  453. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  454. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  455. if(_mOrganizationCode == nil){
  456. [dict setObject:@"" forKeyedSubscript:@"OrganizationCode"];
  457. }else{
  458. [dict setObject:_mOrganizationCode forKeyedSubscript:@"OrganizationCode"];
  459. }
  460. if(_mStartDate == nil){
  461. [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
  462. }
  463. else{
  464. [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
  465. }
  466. if(_mEndDate == nil){
  467. [dict setObject:@"" forKeyedSubscript:@"EndTime"];
  468. }
  469. else{
  470. [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
  471. }
  472. if(_mTelephone == nil){
  473. [dict setObject:@"" forKeyedSubscript:@"Telephone"];
  474. }
  475. else{
  476. [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
  477. }
  478. if(_mInvoiceType == nil){
  479. [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
  480. }
  481. else{
  482. [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
  483. }
  484. if(_mCustomerName == nil){
  485. [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
  486. }
  487. else{
  488. [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
  489. }
  490. if(_mCustomerAddress == nil){
  491. [dict setObject:@"" forKeyedSubscript:@"Address"];
  492. }
  493. else{
  494. [dict setObject:_mCustomerAddress forKeyedSubscript:@"Address"];
  495. }
  496. if (_staffId == nil) {
  497. [dict setObject:@"" forKey:@"staffID"];
  498. }else{
  499. [dict setObject:_staffId forKey:@"staffID"];
  500. }
  501. [dict setObject:@"0" forKeyedSubscript:@"IsTotalFlg"];
  502. [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
  503. _downManager = [[ASIDownManager alloc] init];
  504. _downManager.delegate = self;
  505. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  506. _downManager.onRequestFail = @selector(onLoadFail:);
  507. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  508. }
  509. #pragma mark - 代理函数
  510. /**
  511. * 查询正常数据
  512. *
  513. * @param sender <#sender description#>
  514. */
  515. - (void)onLoadFinish:(ASIDownManager *)sender {
  516. // 取消进度条
  517. [self cancel];
  518. // 服务器返回数据
  519. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  520. // 服务器返回数据状态值
  521. int iStatus = resultModel.status;
  522. // 服务器返回数据消息
  523. NSString *message = resultModel.message;
  524. // 服务器返回数据状态值正确
  525. if (iStatus == 0)
  526. {
  527. _vCustomTableView.tableHeaderView = nil;
  528. _vCustomTableView.backgroundView= nil;
  529. NSArray * approvArr = (NSArray *)resultModel.result;
  530. // 是否有数据
  531. if(approvArr != nil && approvArr.count > 0)
  532. {
  533. [_arrStock removeAllObjects];
  534. _vCustomTableView.tableHeaderView = nil;
  535. [_arrStock addObjectsFromArray:approvArr];
  536. [_arrModels removeAllObjects];
  537. [_vCustomTableView reloadData];
  538. NSDictionary *dic;
  539. if(_arrStock.count==1){
  540. dic =_arrStock[0];
  541. }
  542. else if(_arrStock.count>1){
  543. dic =_arrStock[1];
  544. }
  545. NSInteger recount = [[dic objectForKey:@"RecCount"]integerValue];
  546. // 是否有数据
  547. if(recount > 0){
  548. OrderSaleTotalModel *md = [OrderSaleTotalModel orderSaleWithDict:dic];
  549. [self initHeadView:md.invoiceType];
  550. _vCustomTableView.tableHeaderView=_headView;
  551. [self initUIData:md];
  552. }
  553. else{
  554. // 无数据的view
  555. UIView *noDataView = [self noDataViewByFrame:_vCustomTableView.bounds];
  556. _vCustomTableView.backgroundView=noDataView;
  557. [self showAlertViewText:@"未找到匹配结果"];
  558. return;
  559. }
  560. }
  561. }
  562. // 服务器返回数据状态值异常
  563. else if(iStatus == ActionResultStatusAuthError
  564. ||iStatus == ActionResultStatusNoLogin
  565. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  566. [self showReLoginDialog:message];
  567. return;
  568. }
  569. else {
  570. [_arrModels removeAllObjects];
  571. [_vCustomTableView reloadData];
  572. [self showAlertViewText:message];
  573. }
  574. }
  575. /**
  576. * 异常数据
  577. *
  578. * @param sender <#sender description#>
  579. */
  580. - (void)onLoadFail:(ASIDownManager *)sender {
  581. [self cancel];
  582. [self showAlertViewText:@"网络异常"];
  583. }
  584. /**
  585. * 列表数据
  586. *
  587. * @param sender <#sender description#>
  588. */
  589. - (void)onLoadDetailFinish:(ASIDownManager *)sender {
  590. // 取消进度条
  591. [self cancel];
  592. // 服务器返回数据
  593. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  594. // 服务器返回数据状态值
  595. int iStatus = resultModel.status;
  596. // 服务器返回数据消息
  597. NSString *message = resultModel.message;
  598. // 服务器返回数据状态值正确
  599. if (iStatus == 0)
  600. {
  601. // 返回结果
  602. NSArray * approvArr = (NSArray *)resultModel.result;
  603. if(approvArr != nil)
  604. {
  605. [_arrModels removeAllObjects];
  606. if(approvArr.count == 0){
  607. [self showAlertViewText:@"未找到匹配结果"];
  608. }
  609. else
  610. {
  611. NSMutableArray *arr = [NSMutableArray array];
  612. for (NSDictionary *dic in approvArr)
  613. {
  614. OrderSaleListModel *md = [OrderSaleListModel orderSaleDetailWithDict:dic];
  615. [arr addObject:md];
  616. }
  617. _arrModels = arr;
  618. [_vCustomTableView reloadData];
  619. }
  620. }
  621. }
  622. // 服务器返回数据状态值异常
  623. else if(iStatus == ActionResultStatusAuthError
  624. ||iStatus == ActionResultStatusNoLogin
  625. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
  626. {
  627. [self showReLoginDialog:message];
  628. return;
  629. }
  630. else
  631. {
  632. [self showAlertViewText:message];
  633. }
  634. }
  635. /**
  636. 加载失败
  637. @param sender <#sender description#>
  638. */
  639. - (void)onLoadDetailFail:(ASIDownManager *)sender {
  640. [self cancel];
  641. [self showAlertViewText:@"网络异常"];
  642. }
  643. /**
  644. * 隐藏进度条
  645. */
  646. - (void)cancel {
  647. [self stopLoading];
  648. }
  649. @end