DispatchRequirementDetailController.m 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. //
  2. // DeliveryRequirementDetailControllerViewController.m
  3. // IBOSSHSH
  4. //
  5. // Created by ssl on 2018/1/16.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "DispatchRequirementDetailController.h"
  9. #import "DeliveryImg.h"
  10. #import "XHImageViewer.h"
  11. #import "AlbumPhotoCollectionViewCell.h"
  12. #import "NSString+Tools.h"
  13. #import "DispatchRequirementDetailHeadModel.h"
  14. #import "DateFormat.h"
  15. #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  16. @implementation DispatchRequirementDetailController
  17. @synthesize scroll;
  18. @synthesize contentView;
  19. @synthesize mHeight;
  20. #pragma mark - 公共函数
  21. - (void)viewDidLoad
  22. {
  23. [super viewDidLoad];
  24. mHeight = 31;
  25. [self initUI];
  26. [self initData];
  27. }
  28. /**
  29. 安全区视图发生变化
  30. */
  31. -(void)viewSafeAreaInsetsDidChange{
  32. self.tableView.frame=CGRectMake(10,10, self.view.frame.size.width-20,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50) ;
  33. _btnCancel.frame = CGRectMake(0,
  34. self.view.safeAreaLayoutGuide.layoutFrame.size.height -40,
  35. Screen_Width,
  36. 40);
  37. [super viewSafeAreaInsetsDidChange];
  38. }
  39. #pragma mark - 回调函数
  40. /**
  41. 数据加载完成方法
  42. @param sender <#sender description#>
  43. */
  44. - (void)onLoadFinish:(ASIDownManager *)sender {
  45. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  46. [self cancel];
  47. // 服务器返回数据状态值
  48. int iStatus = resultModel.status;
  49. // 服务器返回数据消息
  50. NSString *message = resultModel.message;
  51. if (iStatus == 0) {
  52. NSDictionary * approvArr=(NSDictionary *)resultModel.result;
  53. if(approvArr != nil&&approvArr.count>0)
  54. {
  55. NSArray *arr = [approvArr objectForKey:@"Table"];
  56. NSArray *arr1 = [approvArr objectForKey:@"Table1"];
  57. NSArray *arr2=[approvArr objectForKey:@"Table2"];
  58. if(arr != nil&&arr.count>0){
  59. NSDictionary *dicValue = arr[0];
  60. DispatchRequirementDetailHeadModel *model = [DispatchRequirementDetailHeadModel dk_modelWithDictionary:dicValue];
  61. _lblDispatchNo.text = model.arrangementNo;
  62. _lblCustomerCode.text=model.customerCode;
  63. _lblDeliveryArea.text=model.deliveryArea;
  64. _lblCustomerTelephone.text=model.telephone;
  65. _lblDeliveryTime.text=model.deliveryPeriod;
  66. _lblChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.receivables doubleValue]];
  67. _lblDeliveryChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.deliveryReceivables doubleValue]];
  68. _lblInstallChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.installationReceivables doubleValue]];
  69. _lblCollectionAmount.text=[NSString stringWithFormat:@"%.2f",[model.deliveryReceiptAmount doubleValue]];
  70. _receiptNo.text = model.receiptNo;
  71. _deliveryNo.text = model.deliveryNo;
  72. _customerName.text = model.customerName;
  73. _contacts.text = model.contacts;
  74. _telephone.text = model.telephone;
  75. _lbRemarks.text = model.remarks == nil?@"":model.remarks;
  76. _lbAccountDate.text = model.accountDate;
  77. _lbCreatetime.text = model.createTime;
  78. _lblCreater.text=model.createUserName;
  79. _lbTruckNumber.text=model.truckNumber;
  80. _deliveryAddress.text = model.deliveryAddress;
  81. _nextDeliveryDate.text = [DateFormat dateFormatSplit: model.deliveryDate];
  82. }
  83. if(arr1 != nil){
  84. for (int i = 0; i < [arr1 count]; i++) {
  85. NSDictionary *infoDic=arr1[i];
  86. DispatchRequirementListDetailModel *info = [DispatchRequirementListDetailModel dk_modelWithDictionary:infoDic];
  87. [_infoList addObject:info];
  88. }
  89. }
  90. if(arr2 != nil&&[arr2 count] > 0){
  91. if(_photoList==nil){
  92. _photoList = [[NSMutableArray alloc]init];
  93. }
  94. if(_signList==nil)
  95. {
  96. _signList= [[NSMutableArray alloc]init];
  97. }
  98. for (int i = 0; i < [arr2 count]; i++) {
  99. NSDictionary *imgDic = arr2[i];
  100. int receiptType=[[imgDic objectForKey:@"ReceiptType"]intValue];
  101. NSString *imgPath = [imgDic objectForKey:@"ThumbnailPath"];
  102. if(receiptType==1)
  103. {
  104. DeliveryImg *img = [DeliveryImg new];
  105. img.imageName = imgPath;
  106. [_photoList addObject:img];
  107. }
  108. if(receiptType==2)
  109. {
  110. DeliveryImg *img = [DeliveryImg new];
  111. img.imageName = imgPath;
  112. [_signList addObject:img];
  113. }
  114. }
  115. }
  116. if(arr1 != nil){
  117. self.tableView.frame=CGRectMake(10,10, self.view.frame.size.width - 20,self.view.frame.size.height-90) ;
  118. [self.tableView reloadData];
  119. }
  120. if(_photoList != nil&&[_photoList count] > 0){
  121. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  122. flowLayout.itemSize = CGSizeMake(85, 85);
  123. flowLayout.minimumInteritemSpacing = 5;
  124. flowLayout.minimumLineSpacing = 10;
  125. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  126. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  127. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10,0, self.view.bounds.size.width - 20, [Util getPhotoCollectionViewHeightWithPhotos:self.photoList]) collectionViewLayout:flowLayout];
  128. self.collectionView.backgroundColor = [UIColor clearColor];
  129. self.collectionView.dataSource = self;
  130. self.collectionView.delegate = self;
  131. self.collectionView.scrollEnabled = NO;
  132. [self.collectionView registerClass:[AlbumPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"PhotoCollectionViewCellIdentifier"];
  133. [_footerView addSubview:self.collectionView];
  134. _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(self.collectionView.frame)+10);
  135. if(_signList!=nil&&_signList.count>0)
  136. {
  137. _signImgView=[[UIImageView alloc]init];
  138. _signImgView.frame=CGRectMake(15, CGRectGetMaxY(self.collectionView.frame)+10, 150, 150);
  139. [_footerView addSubview:_signImgView];
  140. _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(_signImgView.frame)+10);
  141. DeliveryImg *signImg= [_signList objectAtIndex:0];
  142. NSString *signPath= signImg.imageName;
  143. if(signPath != nil && [signPath length] > 0){
  144. NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,signPath];
  145. NSURL *url = [NSURL URLWithString:imageUrl];
  146. [_signImgView setImageWithURL:url placeholderImage:nil];
  147. }
  148. }
  149. _tableView.tableFooterView=_footerView;
  150. }
  151. else
  152. {
  153. if(_signList!=nil&&_signList.count>0)
  154. {
  155. _signImgView=[[UIImageView alloc]init];
  156. _signImgView.frame=CGRectMake(15, 10, 150, 150);
  157. [_footerView addSubview:_signImgView];
  158. _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(_signImgView.frame)+10);
  159. _tableView.tableFooterView=_footerView;
  160. DeliveryImg *signImg= [_signList objectAtIndex:0];
  161. NSString *signPath= signImg.imageName;
  162. if(signPath != nil && [signPath length] > 0){
  163. NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,signPath];
  164. NSURL *url = [NSURL URLWithString:imageUrl];
  165. [_signImgView setImageWithURL:url placeholderImage:nil];
  166. }
  167. }
  168. }
  169. }
  170. }
  171. else if(iStatus == ActionResultStatusAuthError
  172. ||iStatus == ActionResultStatusNoLogin
  173. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  174. [self showReLoginDialog:message];
  175. return;
  176. }
  177. else {
  178. [self.tableView reloadData];
  179. [self showAlertViewText:message];
  180. }
  181. }
  182. /**
  183. 数据加载失败方法
  184. @param sender <#sender description#>
  185. */
  186. - (void)onLoadFail:(ASIDownManager *)sender {
  187. [self cancel];
  188. [self.tableView reloadData];
  189. [self showAlertViewText:@"网络异常"];
  190. }
  191. /**
  192. 请求撤销回执
  193. @param receiptID <#receiptID description#>
  194. */
  195. -(void) requestCancelDeliveryReceipt:(NSString *) receiptID{
  196. [self startLoading];
  197. NSString *urlStr = ServerURL;
  198. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  199. [dict setObject:@"CancelInstallationDemandReceiptIphone" forKey:@"Action"];
  200. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  201. [dict setObject:kkUserCode forKey:@"UserCode"];
  202. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  203. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  204. [dict setObject:kkLicenseCode forKey:@"LicenseCode"];
  205. [dict setObject:receiptID forKeyedSubscript:@"ReceiptID"];
  206. self.mDownManager = [[ASIDownManager alloc] init];
  207. _mDownManager.delegate = self;
  208. _mDownManager.onRequestSuccess = @selector(onRequestCancelReceiptFinish:);
  209. _mDownManager.onRequestFail = @selector(onRequestCancelReceiptFail:);
  210. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  211. }
  212. /**
  213. 请求成功
  214. @param sender <#sender description#>
  215. */
  216. - (void)onRequestCancelReceiptFinish:(ASIDownManager *) sender{
  217. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  218. [self cancel];
  219. int iNewCount = 0;
  220. int iStatus = resultModel.status;
  221. NSString *message = resultModel.message;
  222. if (iStatus == 0) {
  223. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"撤销成功!" preferredStyle:UIAlertControllerStyleAlert ];
  224. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  225. if([self.refreshDelegate respondsToSelector:@selector(refreshData)])
  226. {
  227. [self.refreshDelegate refreshData];
  228. [self.navigationController popViewControllerAnimated:YES];
  229. }
  230. }]];
  231. // 3.显示alertController:presentViewController
  232. [self presentViewController:alert animated:YES completion:nil];
  233. }
  234. else if(iStatus == ActionResultStatusAuthError
  235. ||iStatus == ActionResultStatusNoLogin
  236. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  237. [self showReLoginDialog:message];
  238. return;
  239. }
  240. else{
  241. [self showAlertViewText:message];
  242. return;
  243. }
  244. }
  245. /**
  246. 请求失败
  247. @param sender <#sender description#>
  248. */
  249. - (void)onRequestCancelReceiptFail:(ASIDownManager *) sender{
  250. [self cancel];
  251. [self showAlertViewText:@"请求失败"];
  252. }
  253. /**
  254. tableview的分区数
  255. @param tableView <#tableView description#>
  256. @return <#return value description#>
  257. */
  258. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  259. {
  260. return [_infoList count];
  261. }
  262. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  263. return 832;
  264. }
  265. /**
  266. tableview 分区的间隔高度
  267. @param tableView <#tableView description#>
  268. @param section <#section description#>
  269. @return <#return value description#>
  270. */
  271. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  272. {
  273. return 10;
  274. }
  275. /**
  276. tableview的分区视图
  277. @param tableView <#tableView description#>
  278. @param section <#section description#>
  279. @return <#return value description#>
  280. */
  281. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  282. {
  283. UIView* myView = [[UIView alloc]init];
  284. myView.backgroundColor = [UIColor clearColor];
  285. return myView;
  286. }
  287. /**
  288. tableview每个分区的行数
  289. @param tableView <#tableView description#>
  290. @param section <#section description#>
  291. @return <#return value description#>
  292. */
  293. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  294. {
  295. return 1;
  296. }
  297. /**
  298. 获取tableview cell
  299. @param tableView <#tableView description#>
  300. @param indexPath <#indexPath description#>
  301. @return <#return value description#>
  302. */
  303. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  304. {
  305. NSString *cellIdentifier = @"DispatchRequirementDetailListCell";
  306. DispatchRequirementDetailListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  307. if(cell==nil)
  308. {
  309. NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:cellIdentifier owner:nil options:nil];
  310. cell = [nibs lastObject];
  311. }
  312. NSMutableArray *dataArray = _infoList;
  313. DispatchRequirementListDetailModel *model = [dataArray objectAtIndex:indexPath.section];
  314. cell.layer.cornerRadius = CornerRadius;
  315. cell.layer.backgroundColor = [UIColor whiteColor].CGColor;
  316. cell.layer.masksToBounds = YES;
  317. cell.brandName.text = model.brandName;
  318. cell.seriesName.text= model.seriesName;
  319. cell.sourceNo.text=model.invoiceNo;
  320. cell.package.text= model.package;
  321. cell.acreage.text= model.acreage;
  322. cell.sourceFromName.text= model.sourceFromName;
  323. if([model.installationReceiptFlag intValue] == 0){
  324. cell.installationReceiptFlag.text= @"否";
  325. }else{
  326. cell.installationReceiptFlag.text= @"是";
  327. }
  328. cell.deliveryQuantity.text= model.deliveryQuantity;
  329. cell.gradeName.text= model.gradeName;
  330. cell.weight.text= model.weight;
  331. if([model.installationReceiptType intValue] == 1){
  332. cell.installationReceiptType.text= @"完成";
  333. }else if([model.installationReceiptType intValue] == 5){
  334. cell.installationReceiptType.text= @"再安装";
  335. }
  336. cell.warehouseName.text= model.warehouseName;
  337. cell.code.text= model.code;
  338. cell.kindName.text= model.kindName;
  339. cell.lblUnit.text=model.unitName;
  340. cell.lblDispatchType.text=model.requirementTypeName;
  341. cell.colorNumber.text= model.colorNumber;
  342. cell.installationQuantity.text= model.installationQuantity;
  343. cell.installationReceiptQuantity.text= model.installationReceiptQuantity;
  344. cell.returnQuantity.text= model.returnQuantity;
  345. cell.onlyCode.text= model.onlyCode;;
  346. cell.positionNumber.text= model.positionNumber;;
  347. if([model.circulateType intValue] == 1){
  348. cell.circulateType.text= @"按整数流通";
  349. }else if([model.circulateType intValue] == 2){
  350. cell.circulateType.text= @"按平米流通";
  351. }else if([model.circulateType intValue] == 3){
  352. cell.circulateType.text= @"按延米流通";
  353. }
  354. cell.outQuantity.text= model.outQuantity;;
  355. cell.recoverQuantity.text=model.recoverQuantity;
  356. cell.deliveryReceiptQuantity.text= model.deliveryReceiptQuantity;;
  357. if([model.deliveryReceiptFlag intValue] == 0){
  358. cell.deliveryReceiptFlag.text= @"否";
  359. }else{
  360. cell.deliveryReceiptFlag.text= @"是";
  361. }
  362. cell.remarks.text= (model.remarks == nil || [model.remarks isEqualToString: @""])?@" ":model.remarks;
  363. cell.goodsName.text= model.goodsName;
  364. cell.specification.text= model.specification;
  365. int type2 = [model.deliveryReceiptType intValue];
  366. switch (type2) {
  367. case 1:
  368. cell.deliveryReceiptType.text = @"完成";
  369. break;
  370. case 2:
  371. cell.deliveryReceiptType.text = @"再送";
  372. break;
  373. default:
  374. break;
  375. }
  376. return cell;
  377. }
  378. /**
  379. cellection view的列表项
  380. @param collectionView <#collectionView description#>
  381. @param section <#section description#>
  382. @return <#return value description#>
  383. */
  384. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  385. return self.photoList.count;
  386. }
  387. /**
  388. collection view的cell
  389. @param collectionView <#collectionView description#>
  390. @param indexPath <#indexPath description#>
  391. @return <#return value description#>
  392. */
  393. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  394. static NSString *PhotoCollectionViewCellIdentifier = @"PhotoCollectionViewCellIdentifier";
  395. AlbumPhotoCollectionViewCell *cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath];
  396. NSArray *Infoarray = _photoList;
  397. cell1.indexPath = indexPath;
  398. DeliveryImg *image1 = [Infoarray objectAtIndex:indexPath.row];
  399. NSString *imagepath = [image1 imageName];
  400. if(imagepath != nil && [imagepath length] > 0){
  401. NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,imagepath];
  402. NSURL *url = [NSURL URLWithString:imageUrl];
  403. [cell1.photoImageView setImageWithURL:url placeholderImage:nil];
  404. }
  405. return cell1;
  406. };
  407. /**
  408. 定义collectionview cell的大小
  409. @param collectionView <#collectionView description#>
  410. @param collectionViewLayout <#collectionViewLayout description#>
  411. @param indexPath <#indexPath description#>
  412. @return <#return value description#>
  413. */
  414. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  415. {
  416. return CGSizeMake(85, 85);
  417. }
  418. /**
  419. 定义每个collectionview cell的间距
  420. @param collectionView <#collectionView description#>
  421. @param collectionViewLayout <#collectionViewLayout description#>
  422. @param section <#section description#>
  423. @return <#return value description#>
  424. */
  425. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  426. {
  427. return UIEdgeInsetsMake(5, 5, 5, 5);
  428. }
  429. /**
  430. 放大图片
  431. @param collectionView <#collectionView description#>
  432. @param indexPath <#indexPath description#>
  433. */
  434. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  435. [self showImageViewerAtIndexPath:indexPath];
  436. }
  437. /**
  438. 放大图片委托
  439. @param indexPath <#indexPath description#>
  440. */
  441. - (void)showImageViewerAtIndexPath:(NSIndexPath *)indexPath {
  442. AlbumPhotoCollectionViewCell *cell = (AlbumPhotoCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  443. NSMutableArray *imageViews = [NSMutableArray array];
  444. NSArray *visibleCell = [self.collectionView visibleCells];
  445. NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"indexPath" ascending:YES];
  446. visibleCell = [visibleCell sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
  447. [visibleCell enumerateObjectsUsingBlock:^(AlbumPhotoCollectionViewCell *cell, NSUInteger idx, BOOL *stop) {
  448. [imageViews addObject:[[cell.contentView subviews] lastObject]];
  449. }];
  450. XHImageViewer *imageViewer = [[XHImageViewer alloc] init];
  451. [imageViewer showWithImageViews:imageViews selectedView:[[cell.contentView subviews] lastObject]];
  452. }
  453. /**
  454. 返回collection view是否可以被选择
  455. @param collectionView <#collectionView description#>
  456. @param indexPath <#indexPath description#>
  457. @return <#return value description#>
  458. */
  459. - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
  460. {
  461. return YES;
  462. }
  463. #pragma mark - 私有函数
  464. /**
  465. 返回函数
  466. */
  467. - (void)goBack
  468. {
  469. [self.navigationController popViewControllerAnimated:YES];
  470. }
  471. /**
  472. 初始化ui
  473. */
  474. - (void)initUI{
  475. self.navigationItem.title = @"派工回执明细";
  476. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  477. [button setBackgroundImage:[UIImage imageNamed:@"icon_back.png"]
  478. forState:UIControlStateNormal];
  479. [button addTarget:self action:@selector(goBack)
  480. forControlEvents:UIControlEventTouchUpInside];
  481. button.frame = CGRectMake(0, 0,15,18);
  482. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  483. self.navigationItem.leftBarButtonItem = menuButton;
  484. self.tableView = [UITableView new];
  485. self.tableView.rowHeight = UITableViewAutomaticDimension;
  486. self.tableView.dataSource = self;
  487. self.tableView.delegate = self;
  488. self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  489. self.tableView.backgroundColor = [UIColor clearColor];
  490. self.tableView.scrollEnabled = YES;
  491. self.tableView.estimatedRowHeight = 44.0f;
  492. self.tableView.frame = CGRectZero;
  493. [self.view addSubview:self.tableView];
  494. _headerView = [[UIView alloc]init];
  495. _headerView.frame = CGRectZero;
  496. _headerView.layer.cornerRadius = CornerRadius;
  497. _headerView.backgroundColor = [UIColor whiteColor];
  498. _footerView = [[UIView alloc]init];
  499. _footerView.frame = CGRectZero;
  500. // _footerView.layer.cornerRadius = CornerRadius;
  501. // _footerView.backgroundColor = [UIColor whiteColor];
  502. //回执单号--------------
  503. UIView *vReceiptNoName = [UIView new];
  504. vReceiptNoName.frame = CGRectMake(0, 1, Screen_Width, 51);
  505. [_headerView addSubview:vReceiptNoName];
  506. UILabel *lblTxtCast = [UILabel new];
  507. lblTxtCast.frame = CGRectMake(10, 16,70, 25);
  508. lblTxtCast.text = @"回执单号:";
  509. lblTxtCast.font = kTextFont;
  510. [vReceiptNoName addSubview:lblTxtCast];
  511. _receiptNo = [UILabel new];
  512. _receiptNo.frame = CGRectMake(CGRectGetMaxX(lblTxtCast.frame), 16, 200, 25);
  513. _receiptNo.font = kTextFont;
  514. [vReceiptNoName addSubview:_receiptNo];
  515. UIImageView *separatorImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,50,Screen_Width, 1)];
  516. [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]];
  517. [vReceiptNoName addSubview:separatorImg];
  518. UIView *vTruckNumber = [UIView new];
  519. vTruckNumber.frame = CGRectMake(0,CGRectGetMaxY(vReceiptNoName.frame), Screen_Width, mHeight);
  520. [_headerView addSubview:vTruckNumber];
  521. UILabel *lblTruckNumberTitle = [UILabel new];
  522. lblTruckNumberTitle.frame = CGRectMake(10,3, 70, 25);
  523. lblTruckNumberTitle.text = @"车 牌 号:";
  524. lblTruckNumberTitle.font = kTextFont;
  525. [vTruckNumber addSubview:lblTruckNumberTitle];
  526. _lbTruckNumber = [UILabel new];
  527. _lbTruckNumber.frame = CGRectMake(CGRectGetMaxX(lblTruckNumberTitle.frame),3, 200, 25);
  528. _lbTruckNumber.font = kTextFont;
  529. [vTruckNumber addSubview:_lbTruckNumber];
  530. //送货单号--------------
  531. UIView *vDispatchNo = [UIView new];
  532. vDispatchNo.frame = CGRectMake(0,CGRectGetMaxY(vTruckNumber.frame), Screen_Width, mHeight);
  533. [_headerView addSubview:vDispatchNo];
  534. UILabel *lblDispatchNoTitle = [UILabel new];
  535. lblDispatchNoTitle.frame = CGRectMake(10,3, 70, 25);
  536. lblDispatchNoTitle.text = @"派工单号:";
  537. lblDispatchNoTitle.font = kTextFont;
  538. [vDispatchNo addSubview:lblDispatchNoTitle];
  539. _lblDispatchNo = [UILabel new];
  540. _lblDispatchNo.frame = CGRectMake(CGRectGetMaxX(lblDispatchNoTitle.frame),3, 200, 25);
  541. _lblDispatchNo.font = kTextFont;
  542. [vDispatchNo addSubview:_lblDispatchNo];
  543. UIView *vCustomerCode = [UIView new];
  544. vCustomerCode.frame = CGRectMake(0,CGRectGetMaxY(vDispatchNo.frame), Screen_Width, mHeight);
  545. [_headerView addSubview:vCustomerCode];
  546. UILabel *lblCustomerCodeTitle = [UILabel new];
  547. lblCustomerCodeTitle.frame = CGRectMake(10,3, 70, 25);
  548. lblCustomerCodeTitle.text = @"客户编码:";
  549. lblCustomerCodeTitle.font = kTextFont;
  550. [vCustomerCode addSubview:lblCustomerCodeTitle];
  551. _lblCustomerCode = [UILabel new];
  552. _lblCustomerCode.font = kTextFont;
  553. _lblCustomerCode.frame = CGRectMake(CGRectGetMaxX(lblCustomerCodeTitle.frame),3, 200, 25);
  554. [vCustomerCode addSubview:_lblCustomerCode];
  555. //客户名称--------------
  556. UIView *vCustomerName = [UIView new];
  557. vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vCustomerCode.frame), Screen_Width, mHeight);
  558. [_headerView addSubview:vCustomerName];
  559. UILabel *lblCustomerName = [UILabel new];
  560. lblCustomerName.frame = CGRectMake(10,3, 70, 25);
  561. lblCustomerName.text = @"客户名称:";
  562. lblCustomerName.font = kTextFont;
  563. [vCustomerName addSubview:lblCustomerName];
  564. _customerName = [UILabel new];
  565. _customerName.font = kTextFont;
  566. _customerName.frame = CGRectMake(CGRectGetMaxX(lblCustomerName.frame),3, 200, 25);
  567. [vCustomerName addSubview:_customerName];
  568. UIView *vCustomerTelephone = [UIView new];
  569. vCustomerTelephone.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, mHeight);
  570. [_headerView addSubview:vCustomerTelephone];
  571. UILabel *lblCustomerTelephoneTitle = [UILabel new];
  572. lblCustomerTelephoneTitle.frame = CGRectMake(10,3, 70, 25);
  573. lblCustomerTelephoneTitle.text = @"客户电话:";
  574. lblCustomerTelephoneTitle.font = kTextFont;
  575. [vCustomerTelephone addSubview:lblCustomerTelephoneTitle];
  576. _lblCustomerTelephone = [UILabel new];
  577. _lblCustomerTelephone.font = kTextFont;
  578. _lblCustomerTelephone.frame = CGRectMake(CGRectGetMaxX(lblCustomerTelephoneTitle.frame),3, 200, 25);
  579. [vCustomerTelephone addSubview:_lblCustomerTelephone];
  580. UIView *vDeliveryArea = [UIView new];
  581. vDeliveryArea.frame = CGRectMake(0,CGRectGetMaxY(vCustomerTelephone.frame), Screen_Width, mHeight);
  582. [_headerView addSubview:vDeliveryArea];
  583. UILabel *lblDeliveryAreaTitle = [UILabel new];
  584. lblDeliveryAreaTitle.frame = CGRectMake(10,3, 70, 25);
  585. lblDeliveryAreaTitle.text = @"送货区域:";
  586. lblDeliveryAreaTitle.font = kTextFont;
  587. [vDeliveryArea addSubview:lblDeliveryAreaTitle];
  588. _lblDeliveryArea= [UILabel new];
  589. _lblDeliveryArea.font = kTextFont;
  590. _lblDeliveryArea.frame = CGRectMake(CGRectGetMaxX(lblDeliveryAreaTitle.frame),3, 200, 25);
  591. [vDeliveryArea addSubview:_lblDeliveryArea];
  592. //地址--------------
  593. UIView *vDeliveryAddress = [UIView new];
  594. vDeliveryAddress.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryArea.frame), Screen_Width, mHeight);
  595. [_headerView addSubview:vDeliveryAddress];
  596. UILabel *lblvDeliveryAddress = [UILabel new];
  597. lblvDeliveryAddress.frame = CGRectMake(10,3,70, 25);
  598. lblvDeliveryAddress.text = @"送货地址:";
  599. lblvDeliveryAddress.font = kTextFont;
  600. [vDeliveryAddress addSubview:lblvDeliveryAddress];
  601. _deliveryAddress = [UILabel new];
  602. _deliveryAddress.frame = CGRectMake(CGRectGetMaxX(lblvDeliveryAddress.frame),3, 200, 25);
  603. _deliveryAddress.font = kTextFont;
  604. [vDeliveryAddress addSubview:_deliveryAddress];
  605. //推迟送货日期--------------
  606. UIView *vNextDeliveryDate = [UIView new];
  607. vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAddress.frame), Screen_Width, mHeight);
  608. [_headerView addSubview:vNextDeliveryDate];
  609. UILabel *lblvNextDeliveryDate = [UILabel new];
  610. lblvNextDeliveryDate.frame = CGRectMake(10,3, 70, 25);
  611. lblvNextDeliveryDate.text = @"推迟日期:";
  612. lblvNextDeliveryDate.font = kTextFont;
  613. [vNextDeliveryDate addSubview:lblvNextDeliveryDate];
  614. _nextDeliveryDate = [UILabel new];
  615. _nextDeliveryDate.font = kTextFont;
  616. _nextDeliveryDate.frame = CGRectMake(CGRectGetMaxX(lblvNextDeliveryDate.frame),3, 200, 25);
  617. [vNextDeliveryDate addSubview:_nextDeliveryDate];
  618. UIView *vDeliveryTime = [UIView new];
  619. vDeliveryTime.frame = CGRectMake(0,CGRectGetMaxY(vNextDeliveryDate.frame), Screen_Width, mHeight);
  620. [_headerView addSubview:vDeliveryTime];
  621. UILabel *lblDeliveryTimeTitle = [UILabel new];
  622. lblDeliveryTimeTitle.frame = CGRectMake(10,3, 72, 25);
  623. lblDeliveryTimeTitle.text = @"配送时段:";
  624. lblDeliveryTimeTitle.font = kTextFont;
  625. [vDeliveryTime addSubview:lblDeliveryTimeTitle];
  626. _lblDeliveryTime = [UILabel new];
  627. _lblDeliveryTime.font = kTextFont;
  628. _lblDeliveryTime.frame = CGRectMake(CGRectGetMaxX(lblDeliveryTimeTitle.frame),3, 200, 25);
  629. [vDeliveryTime addSubview:_lblDeliveryTime];
  630. UIView *vChargeAmount = [UIView new];
  631. vChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryTime.frame), Screen_Width, mHeight);
  632. [_headerView addSubview:vChargeAmount];
  633. UILabel *lblChargeAmountTitle = [UILabel new];
  634. lblChargeAmountTitle.frame = CGRectMake(10,3, 72, 25);
  635. lblChargeAmountTitle.text = @"收费金额:";
  636. lblChargeAmountTitle.font = kTextFont;
  637. [vChargeAmount addSubview:lblChargeAmountTitle];
  638. _lblChargeAmount = [UILabel new];
  639. _lblChargeAmount.font = kTextFont;
  640. _lblChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblChargeAmountTitle.frame),3, 200, 25);
  641. [vChargeAmount addSubview:_lblChargeAmount];
  642. UIView *vDeliveryChargeAmount = [UIView new];
  643. vDeliveryChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vChargeAmount.frame), Screen_Width, mHeight);
  644. [_headerView addSubview:vDeliveryChargeAmount];
  645. UILabel *lblDeliveryChargeAmountTitle = [UILabel new];
  646. lblDeliveryChargeAmountTitle.frame = CGRectMake(10,3,90, 25);
  647. lblDeliveryChargeAmountTitle.text = @"送货收费金额:";
  648. lblDeliveryChargeAmountTitle.font = kTextFont;
  649. [vDeliveryChargeAmount addSubview:lblDeliveryChargeAmountTitle];
  650. _lblDeliveryChargeAmount = [UILabel new];
  651. _lblDeliveryChargeAmount.font = kTextFont;
  652. _lblDeliveryChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblDeliveryChargeAmountTitle.frame),3, 200, 25);
  653. [vDeliveryChargeAmount addSubview:_lblDeliveryChargeAmount];
  654. UIView *vInstallChargeAmount = [UIView new];
  655. vInstallChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryChargeAmount.frame), Screen_Width, mHeight);
  656. [_headerView addSubview:vInstallChargeAmount];
  657. UILabel *lblInstallChargeAmountTitle = [UILabel new];
  658. lblInstallChargeAmountTitle.frame = CGRectMake(10,3, 90, 25);
  659. lblInstallChargeAmountTitle.text = @"安装收费金额:";
  660. lblInstallChargeAmountTitle.font = kTextFont;
  661. [vInstallChargeAmount addSubview:lblInstallChargeAmountTitle];
  662. _lblInstallChargeAmount = [UILabel new];
  663. _lblInstallChargeAmount.font = kTextFont;
  664. _lblInstallChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblInstallChargeAmountTitle.frame),3, 200, 25);
  665. [vInstallChargeAmount addSubview:_lblInstallChargeAmount];
  666. UIView *vCollectionAmount = [UIView new];
  667. vCollectionAmount.frame = CGRectMake(0,CGRectGetMaxY(vInstallChargeAmount.frame), Screen_Width, mHeight);
  668. [_headerView addSubview:vCollectionAmount];
  669. UILabel *lblCollectionAmountTitle = [UILabel new];
  670. lblCollectionAmountTitle.frame = CGRectMake(10,3, 72, 25);
  671. lblCollectionAmountTitle.text = @"收款金额:";
  672. lblCollectionAmountTitle.font = kTextFont;
  673. [vCollectionAmount addSubview:lblCollectionAmountTitle];
  674. _lblCollectionAmount = [UILabel new];
  675. _lblCollectionAmount.font = kTextFont;
  676. _lblCollectionAmount.frame = CGRectMake(CGRectGetMaxX(lblCollectionAmountTitle.frame),3, 200, 25);
  677. [vCollectionAmount addSubview:_lblCollectionAmount];
  678. UIView *vAccountDate = [UIView new];
  679. vAccountDate.frame = CGRectMake(0,CGRectGetMaxY(vCollectionAmount.frame), Screen_Width, mHeight);
  680. [_headerView addSubview:vAccountDate];
  681. UILabel *lblAccountDateTitle= [UILabel new];
  682. lblAccountDateTitle.frame = CGRectMake(10,3,70, 25);
  683. lblAccountDateTitle.text = @"账务日期:";
  684. lblAccountDateTitle.font = kTextFont;
  685. [vAccountDate addSubview:lblAccountDateTitle];
  686. _lbAccountDate = [UILabel new];
  687. _lbAccountDate.font = kTextFont;
  688. _lbAccountDate.frame = CGRectMake(CGRectGetMaxX(lblAccountDateTitle.frame),3, 200, 25);
  689. [vAccountDate addSubview:_lbAccountDate];
  690. UIView *vRemarks = [UIView new];
  691. vRemarks.frame = CGRectMake(0,CGRectGetMaxY(vAccountDate.frame), Screen_Width, mHeight);
  692. [_headerView addSubview:vRemarks];
  693. UILabel *lblRemarksTitle= [UILabel new];
  694. lblRemarksTitle.frame = CGRectMake(10,3,70, 25);
  695. lblRemarksTitle.text = @"备 注:";
  696. lblRemarksTitle.font = kTextFont;
  697. [vRemarks addSubview:lblRemarksTitle];
  698. _lbRemarks = [UILabel new];
  699. _lbRemarks.font = kTextFont;
  700. _lbRemarks.frame = CGRectMake(CGRectGetMaxX(lblRemarksTitle.frame),3, 200, 25);
  701. [vRemarks addSubview:_lbRemarks];
  702. UIView *vCreater = [UIView new];
  703. vCreater.frame = CGRectMake(0,CGRectGetMaxY(vRemarks.frame), Screen_Width, mHeight);
  704. [_headerView addSubview:vCreater];
  705. UILabel *lblCreaterTitle= [UILabel new];
  706. lblCreaterTitle.frame = CGRectMake(10,3,70, 25);
  707. lblCreaterTitle.text = @"创 建 者:";
  708. lblCreaterTitle.font = kTextFont;
  709. [vCreater addSubview:lblCreaterTitle];
  710. _lblCreater = [UILabel new];
  711. _lblCreater.font = kTextFont;
  712. _lblCreater.frame = CGRectMake(CGRectGetMaxX(lblCreaterTitle.frame),3, 200, 25);
  713. [vCreater addSubview:_lblCreater];
  714. UIView *vCreateTime = [UIView new];
  715. vCreateTime.frame = CGRectMake(0,CGRectGetMaxY(vCreater.frame), Screen_Width, mHeight);
  716. [_headerView addSubview:vCreateTime];
  717. UILabel *lblCreateTimeTitle= [UILabel new];
  718. lblCreateTimeTitle.frame = CGRectMake(10,3,70, 25);
  719. lblCreateTimeTitle.text = @"创建时间:";
  720. lblCreateTimeTitle.font = kTextFont;
  721. [vCreateTime addSubview:lblCreateTimeTitle];
  722. _lbCreatetime = [UILabel new];
  723. _lbCreatetime.font = kTextFont;
  724. _lbCreatetime.frame = CGRectMake(CGRectGetMaxX(lblCreateTimeTitle.frame),3, 200, 25);
  725. [vCreateTime addSubview:_lbCreatetime];
  726. _headerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(vCreateTime.frame)+10);
  727. _tableView.tableHeaderView = _headerView;
  728. _btnCancel = [UIButton buttonWithType:UIButtonTypeCustom];
  729. _btnCancel.frame=CGRectMake(0, Screen_Height- 40- rectStatusHeight-rectNavHeight, Screen_Width,40) ;
  730. [_btnCancel setTitle:@"撤销" forState:UIControlStateNormal];
  731. [_btnCancel setBackgroundColor:NavigationBarColor];
  732. [_btnCancel addTarget:self action:@selector(cancelReceipt) forControlEvents:UIControlEventTouchUpInside];
  733. [self.view addSubview:_btnCancel];
  734. if([_receiptTypeFlag intValue]!=1)
  735. {
  736. _btnCancel.enabled=YES;
  737. }
  738. else{
  739. _btnCancel.enabled=NO;
  740. }
  741. if(!_infoList){
  742. _infoList = [[NSMutableArray alloc]init];
  743. }
  744. }
  745. -(void)cancelReceipt
  746. {
  747. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"
  748. message:@"是否要撤销回执?" preferredStyle:UIAlertControllerStyleAlert];
  749. UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定"
  750. style:UIAlertActionStyleDefault
  751. handler:^(UIAlertAction *action){
  752. [self requestCancelDeliveryReceipt: _receiptID];
  753. }];
  754. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
  755. style:UIAlertActionStyleDefault
  756. handler:^(UIAlertAction *action){
  757. }];
  758. UIColor *cancelColor = [UIColor blackColor];
  759. UIColor *sureColor = [UIColor redColor];
  760. [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
  761. [okAction setValue:sureColor forKey:@"titleTextColor"];
  762. [alert addAction:okAction];
  763. [alert addAction:cancelAction];
  764. [self presentViewController:alert animated:YES completion:nil];
  765. }
  766. /**
  767. 数据加载
  768. */
  769. - (void)initData{
  770. [self startLoading];
  771. NSString *urlStr = ServerURL;
  772. NSMutableDictionary *dict = [NSMutableDictionary new];
  773. [dict setObject:@"GetInstallationDemandReceiptDetailIphone" forKey:@"Action"];
  774. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  775. [dict setObject:kkUserCode forKey:@"UserCode"];
  776. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  777. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  778. [dict setObject:_receiptID forKey:@"ReceiptID"];
  779. self.mDownManager = [[ASIDownManager alloc] init];
  780. _mDownManager.delegate = self;
  781. _mDownManager.onRequestSuccess = @selector(onLoadFinish:);
  782. _mDownManager.onRequestFail = @selector(onLoadFail:);
  783. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  784. }
  785. /**
  786. 取消进度条
  787. */
  788. - (void)cancel {
  789. [self stopLoading];
  790. }
  791. /**
  792. 获取tableview的高度
  793. @param Array <#Array description#>
  794. @return <#return value description#>
  795. */
  796. - (CGFloat)getArrayViewHeight:(NSArray *)Array {
  797. // 上下间隔已经在frame上做了
  798. NSInteger row = Array.count;
  799. CGFloat allheight = 0;
  800. for (int i = 0; i < Array.count; i++) {
  801. CGFloat height=832;
  802. allheight += height;
  803. }
  804. return allheight;
  805. }
  806. @end