OrderSalesApproveListVc.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. //
  2. // OrderSalesApproveListVc.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2019/4/12.
  6. // Copyright © 2019 elongtian. All rights reserved.
  7. //
  8. #import "OrderSalesApproveListVc.h"
  9. @interface OrderSalesApproveListVc ()
  10. {
  11. UIView *_headView;
  12. }
  13. @end
  14. @implementation OrderSalesApproveListVc
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. _dataList=[[NSMutableArray alloc]init];
  18. [self initSlideSlip];
  19. [self loadNavStyle];
  20. [self initUI];
  21. UIView *view = [self backGroundPromptViewByFrame:_vTableView.bounds promptStr:@"请筛选后查询"];
  22. _vTableView.tableHeaderView = nil;
  23. _vTableView.backgroundView = view;
  24. }
  25. /**
  26. 安全区视图发生变化
  27. */
  28. -(void)viewSafeAreaInsetsDidChange{
  29. _vTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  30. [super viewSafeAreaInsetsDidChange];
  31. }
  32. -(void)search{
  33. [_filterController show];
  34. }
  35. /**
  36. 导航按钮样式
  37. */
  38. - (void)loadNavStyle {
  39. self.navigationItem.title = @"订单销售审批报表";
  40. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  41. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  42. [button addTarget:self action:@selector(goBack)
  43. forControlEvents:UIControlEventTouchUpInside];
  44. button.frame = CGRectMake(0, 0,45,22);
  45. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  46. self.navigationItem.leftBarButtonItem = menuButton;
  47. // 右边
  48. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
  49. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  50. [btnfilter addTarget:self action:@selector(search)
  51. forControlEvents:UIControlEventTouchUpInside];
  52. btnfilter.frame = CGRectMake(0, 0,16, 16);
  53. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  54. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  55. forState:UIControlStateNormal];
  56. [v addSubview:btnfilter];
  57. UIButton *filterLbl = [[UIButton alloc]init];
  58. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  59. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  60. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  61. filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
  62. [filterLbl addTarget:self action:@selector(search)
  63. forControlEvents:UIControlEventTouchUpInside];
  64. [v addSubview:filterLbl];
  65. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  66. self.navigationItem.rightBarButtonItem = menubtnAdd;
  67. }
  68. -(void)goBack
  69. {
  70. [self.navigationController popViewControllerAnimated:YES];
  71. }
  72. -(void)initUI
  73. {
  74. _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
  75. _vTableView.rowHeight = UITableViewAutomaticDimension;
  76. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  77. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  78. _vTableView.backgroundColor = [UIColor whiteColor];
  79. _vTableView.delegate = self;
  80. _vTableView.dataSource=self;
  81. _vTableView.tableHeaderView = nil;
  82. [self.view addSubview:_vTableView];
  83. //头布局
  84. CGFloat height = 170;
  85. _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
  86. CGFloat titleHeight = 50;
  87. CGFloat lblx = 20;
  88. CGFloat lblwidth = 130;
  89. CGFloat fontsize = 14;
  90. //CGFloat valuex = 125;
  91. CGFloat valuey = 10;
  92. CGFloat valuewidth = 200;
  93. CGFloat valueheight = 25;
  94. CGFloat heightLine =1;
  95. //总合计 —————————
  96. UIView *vtotal = [UIView new];
  97. vtotal.frame=CGRectMake(0, 0, Screen_Width, titleHeight);
  98. [_headView addSubview:vtotal];
  99. UILabel *lbtotal = [UILabel new];
  100. lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
  101. lbtotal.font = [UIFont boldSystemFontOfSize:fontsize];
  102. lbtotal.text = @"合计";
  103. [vtotal addSubview:lbtotal];
  104. //分割线
  105. UIView *viewBackgroud = [UIView new];
  106. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
  107. viewBackgroud.backgroundColor = LineBackgroundColor;
  108. [_headView addSubview:viewBackgroud];
  109. //收入总额 —————————
  110. UIView *vtotalGoodsAmount= [UIView new];
  111. vtotalGoodsAmount.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  112. [_headView addSubview:vtotalGoodsAmount];
  113. UIImageView *imgview = [UIImageView new];
  114. imgview.frame=CGRectMake(lblx, valuey+5, 21, 16);
  115. [imgview setImage:[UIImage imageNamed:@"profit_income"]];
  116. [vtotalGoodsAmount addSubview:imgview];
  117. UILabel *lbtotalGoodsAmountTitle = [UILabel new];
  118. lbtotalGoodsAmountTitle.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey, lblwidth, valueheight);
  119. lbtotalGoodsAmountTitle.font = [UIFont systemFontOfSize:fontsize];
  120. lbtotalGoodsAmountTitle.text = @"货物总额";
  121. [vtotalGoodsAmount addSubview:lbtotalGoodsAmountTitle];
  122. self.lbtotalGoodsAmount= [UILabel new];
  123. self.lbtotalGoodsAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
  124. self.lbtotalGoodsAmount.font = [UIFont systemFontOfSize:fontsize];
  125. self.lbtotalGoodsAmount.textAlignment = NSTextAlignmentRight;
  126. [vtotalGoodsAmount addSubview:self.lbtotalGoodsAmount];
  127. viewBackgroud = [UIView new];
  128. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalGoodsAmount.frame), Screen_Width, heightLine);
  129. viewBackgroud.backgroundColor = LineBackgroundColor;
  130. [_headView addSubview:viewBackgroud];
  131. UIView *vtotalFeesAmount = [UIView new];
  132. vtotalFeesAmount.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
  133. [_headView addSubview:vtotalFeesAmount];
  134. UIImageView *imgviewReceivable = [UIImageView new];
  135. imgviewReceivable.frame=CGRectMake(lblx, valuey+1, 20, 20);
  136. [imgviewReceivable setImage:[UIImage imageNamed:@"profit_cost"]];
  137. [vtotalFeesAmount addSubview:imgviewReceivable];
  138. UILabel *lbtotalFeesAmount = [UILabel new];
  139. lbtotalFeesAmount.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
  140. lbtotalFeesAmount.font = [UIFont systemFontOfSize:fontsize];
  141. lbtotalFeesAmount.text = @"费用金额";
  142. [vtotalFeesAmount addSubview:lbtotalFeesAmount];
  143. self.lbtotalFeesAmount = [UILabel new];
  144. self.lbtotalFeesAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
  145. self.lbtotalFeesAmount.font = [UIFont systemFontOfSize:fontsize];
  146. self.lbtotalFeesAmount.textAlignment = NSTextAlignmentRight;
  147. [vtotalFeesAmount addSubview:self.lbtotalFeesAmount];
  148. _headView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vtotalFeesAmount.frame));
  149. }
  150. /**
  151. 抽屉初始化
  152. */
  153. - (void)initSlideSlip{
  154. // 抽屉对象
  155. __weak typeof(self) weakself=self;
  156. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  157. for (SideSlipModel *model in dataList) {
  158. model.selectedItemList = nil;
  159. model.customDict = nil;
  160. }
  161. } commitBlock:^(NSArray *dataList) {
  162. // 查询条件
  163. SideSlipModel *serviceRegionModel = dataList[0];
  164. self->_searchModel = [serviceRegionModel.customDict objectForKey:Order_SALES_APPROVE_SEARCH_MODEL];
  165. if(self->_dataList!=nil&&self->_dataList.count>0){
  166. [self->_dataList removeAllObjects];
  167. [self->_vTableView reloadData];
  168. }
  169. if([self->_searchModel.startDate isEqualToString:@"请选择开始日期"]){
  170. self->_searchModel.startDate=@"";
  171. }
  172. if([self->_searchModel.endDate isEqualToString:@"请选择结束日期"]){
  173. self->_searchModel.endDate=@"";
  174. }
  175. if(self->_searchModel.startDate.length>0&&self->_searchModel.endDate.length>0){
  176. NSUInteger result= [DateFormat compareDate:self->_searchModel.startDate withDate:self->_searchModel.endDate];
  177. if(result == -1){
  178. [self showAlertViewText:@"开始日期不能大于结束日期"];
  179. return;
  180. }
  181. NSDateFormatter *dateformater = [[NSDateFormatter alloc] init];
  182. [dateformater setDateFormat:@"yyyy-MM-dd"];
  183. NSDate *dta = [[NSDate alloc] init];
  184. NSDate *dtb = [[NSDate alloc] init];
  185. dta = [dateformater dateFromString:self->_searchModel.startDate];
  186. dtb = [dateformater dateFromString:self->_searchModel.endDate];
  187. NSInteger days=[DateFormat calculateDaysFromBegin:dta end:dtb];
  188. // if(days>31){
  189. // [self showAlertViewText:@"日期间隔不能超过31天"];
  190. // return;
  191. // }
  192. }
  193. [weakself.filterController dismiss];
  194. [self reloadData];
  195. }];
  196. _filterController.animationDuration = AnimationDuration;
  197. _filterController.hasHeadView = YES;
  198. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  199. _filterController.dataList = [self packageDataList];
  200. }
  201. /**
  202. 数据源
  203. @return <#return value description#>
  204. */
  205. - (NSArray *)packageDataList {
  206. NSMutableArray *dataArray = [NSMutableArray array];
  207. SideSlipModel *model = [[SideSlipModel alloc] init];
  208. model.containerCellClass = @"OrderSalesApproveSearchCell";
  209. model.regionTitle = @"查询条件";
  210. [dataArray addObject:model];
  211. return [dataArray mutableCopy];
  212. }
  213. /**
  214. 加载数据
  215. */
  216. - (void)reloadData
  217. {
  218. [self startLoading];
  219. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  220. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  221. [dict setObject:@"GetOrderSalesAuditIphone" forKey:@"Action"];
  222. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  223. [dict setObject:kkUserCode forKey:@"UserCode"];
  224. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  225. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  226. [dict setObject:_searchModel.invoiceNo==nil?@"":_searchModel.invoiceNo forKeyedSubscript:@"InvoiceNo"];
  227. [dict setObject:_searchModel.invoiceType==nil?@"0":_searchModel.invoiceType forKeyedSubscript:@"SalesFunctionID"];
  228. [dict setObject:_searchModel.reviewerName==nil?@"":_searchModel.reviewerName forKeyedSubscript:@"ReviewerName"];
  229. [dict setObject:_searchModel.customerAddress==nil?@"":_searchModel.customerAddress forKeyedSubscript:@"CustomerAddress"];
  230. [dict setObject:_searchModel.organizationCode==nil?@"":_searchModel.organizationCode forKeyedSubscript:@"OrganizationCode"];
  231. [dict setObject:_searchModel.staffId==nil?@"":_searchModel.staffId forKeyedSubscript:@"StaffID"];
  232. [dict setObject:_searchModel.startDate==nil?@"":_searchModel.startDate forKeyedSubscript:@"AccountDateFrom"];
  233. [dict setObject:_searchModel.endDate==nil?@"":_searchModel.endDate forKeyedSubscript:@"AccountDateTo"];
  234. [dict setObject:_searchModel.approveResult==nil?@"2":_searchModel.approveResult forKeyedSubscript:@"Result"];
  235. [dict setObject:_searchModel.customerCode==nil?@"":_searchModel.customerCode forKeyedSubscript:@"CustomerCode"];
  236. [dict setObject:_searchModel.customerName==nil?@"":_searchModel.customerName forKeyedSubscript:@"CustomerName"];
  237. [dict setObject:_searchModel.customerAddress==nil?@"":_searchModel.customerAddress forKeyedSubscript:@"CustomerAddress"];
  238. _downManager = [[ASIDownManager alloc] init];
  239. _downManager.delegate = self;
  240. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  241. _downManager.onRequestFail = @selector(onLoadFail:);
  242. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  243. }
  244. /**
  245. 调用接口成功回调
  246. @param sender <#sender description#>
  247. */
  248. - (void)onLoadFinish:(ASIDownManager *)sender {
  249. // 取消进度条
  250. [self cancel];
  251. // 服务器返回数据
  252. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  253. // 服务器返回数据状态值
  254. int iStatus = resultModel.status;
  255. // 服务器返回数据消息
  256. NSString *message = resultModel.message;
  257. _vTableView.backgroundView = nil;
  258. _vTableView.tableHeaderView = nil;
  259. // 服务器返回数据状态值正确
  260. if (iStatus == 0) {
  261. NSArray *infoArray = (NSArray *)resultModel.result;
  262. if(infoArray!=nil&&infoArray.count>0){
  263. _vTableView.tableHeaderView=_headView;
  264. double totalGoodsAmountValue = 0.0;
  265. double totalFeesAmountValue = 0.0;
  266. for(int i=0;i<infoArray.count;i++){
  267. NSDictionary *infoDic=[infoArray objectAtIndex:i];
  268. OrderSalesApproveListModel *model = [OrderSalesApproveListModel dk_modelWithDictionary:infoDic];
  269. totalGoodsAmountValue+=[model.goodsAmount doubleValue];
  270. totalFeesAmountValue+=[model.feeAmount doubleValue];
  271. [_dataList addObject:model];
  272. }
  273. // 合计信息
  274. self.lbtotalGoodsAmount.text = [NSString stringWithFormat:@"¥%.2f",totalGoodsAmountValue];
  275. self.lbtotalFeesAmount.text = [NSString stringWithFormat:@"¥%.2f",totalFeesAmountValue];
  276. [_vTableView reloadData];
  277. }
  278. else
  279. {
  280. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  281. // 未找到匹配结果
  282. if(_dataList == nil || _dataList.count == 0){
  283. _vTableView.backgroundView = [self noDataViewByFrame:_vTableView.bounds];
  284. [self showAlertViewBackText:@"未找到匹配结果"];
  285. }
  286. }
  287. }
  288. // 服务器返回数据状态值异常
  289. else if(iStatus == ActionResultStatusAuthError
  290. ||iStatus == ActionResultStatusNoLogin
  291. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  292. [self showReLoginDialog:message];
  293. }
  294. else{
  295. [self showAlertViewText:message];
  296. return;
  297. }
  298. }
  299. /**
  300. 调用接口失败回调
  301. @param sender <#sender description#>
  302. */
  303. - (void)onLoadFail:(ASIDownManager *)sender {
  304. [self cancel];
  305. [self showAlertViewText:@"网络异常"];
  306. }
  307. /**
  308. 单元格cell个数
  309. @param tableView <#tableView description#>
  310. @param section <#section description#>
  311. @return <#return value description#>
  312. */
  313. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  314. {
  315. return [_dataList count];
  316. }
  317. /**
  318. <#Description#>
  319. @param tableView <#tableView description#>
  320. @return <#return value description#>
  321. */
  322. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  323. return 1;
  324. }
  325. /**
  326. 高度
  327. @param tableView <#tableView description#>
  328. @param indexPath <#indexPath description#>
  329. @return <#return value description#>
  330. */
  331. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  332. return 301;
  333. }
  334. /**
  335. 每个单元格cell
  336. @param tableView <#tableView description#>
  337. @param indexPath <#indexPath description#>
  338. @return <#return value description#>
  339. */
  340. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  341. {
  342. static NSString *cellIdentifier = @"OrderSalesApproveListCell";
  343. OrderSalesApproveListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  344. if (!cell) {
  345. cell = [[OrderSalesApproveListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  346. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  347. }
  348. else
  349. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  350. {
  351. while ([cell.contentView.subviews lastObject] != nil) {
  352. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  353. }
  354. }
  355. OrderSalesApproveListModel *approveListModel= [_dataList objectAtIndex:indexPath.row];
  356. [cell setOrderSalesApproveListCell:approveListModel];
  357. return cell;
  358. }
  359. /**
  360. 点击单元格事件
  361. @param tableView tableView description
  362. @param indexPath indexPath description
  363. */
  364. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  365. {
  366. self.hidesBottomBarWhenPushed=YES;
  367. OrderSalesApproveListDetailVc *detailVc = [[OrderSalesApproveListDetailVc alloc] init];
  368. OrderSalesApproveListModel *approveListModel= [_dataList objectAtIndex:indexPath.row];
  369. detailVc.approveListModel=approveListModel;
  370. detailVc.invoiceId= approveListModel.invoiceId;
  371. [self.navigationController pushViewController:detailVc animated:YES];
  372. }
  373. /**
  374. 进度条隐藏
  375. */
  376. - (void)cancel {
  377. [self stopLoading];
  378. }
  379. @end