DeliveryListDetailVC.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. //
  2. // DeliveryListDetail.m
  3. // IBOSS
  4. //
  5. // Created by Dongke on 16/1/12.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. // 功能描述:回执明细控制器
  8. #import "DeliveryListDetailVC.h"
  9. #import "DeliveryListDetailModel.h"
  10. #import "DeliveryImg.h"
  11. #import "XHImageViewer.h"
  12. #import "AlbumPhotoCollectionViewCell.h"
  13. #import "NSString+Tools.h"
  14. #import "DeliveryListDetailHeadModel.h"
  15. #import "DateFormat.h"
  16. #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  17. @implementation DeliveryListDetailVC
  18. @synthesize scroll;
  19. @synthesize contentView;
  20. @synthesize mHeight;
  21. #pragma mark - 公共函数
  22. - (void)viewDidLoad
  23. {
  24. [super viewDidLoad];
  25. mHeight = 31;
  26. [self initUI];
  27. [self initData];
  28. }
  29. /**
  30. 安全区视图发生变化
  31. */
  32. -(void)viewSafeAreaInsetsDidChange{
  33. scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  34. [super viewSafeAreaInsetsDidChange];
  35. }
  36. #pragma mark - 回调函数
  37. /**
  38. 数据加载完成方法
  39. @param sender <#sender description#>
  40. */
  41. - (void)onLoadFinish:(ASIDownManager *)sender {
  42. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  43. [self cancel];
  44. // 服务器返回数据状态值
  45. int iStatus = resultModel.status;
  46. // 服务器返回数据消息
  47. NSString *message = resultModel.message;
  48. if (iStatus == 0) {
  49. NSDictionary * approvArr=(NSDictionary *)resultModel.result;
  50. if(approvArr != nil&&approvArr.count>0)
  51. {
  52. NSArray *arr = [approvArr objectForKey:@"Table"];
  53. NSArray *arr1 = [approvArr objectForKey:@"Table1"];
  54. NSArray *imagePathArr = [approvArr objectForKey:@"ImagePath"];
  55. NSArray *positionArr = [approvArr objectForKey:@"Position"];
  56. if(arr != nil&&arr.count>0){
  57. NSDictionary *dicValue = arr[0];
  58. DeliveryListDetailHeadModel *model = [DeliveryListDetailHeadModel dk_modelWithDictionary:dicValue];
  59. _arrangementNo.text = model.arrangementNo;
  60. _receiptNo.text = model.receiptNo;
  61. _deliveryNo.text = model.deliveryNo;
  62. _recReceiptType.text = model.recReceiptType;
  63. _customerName.text = model.customerName;
  64. _contacts.text = model.contacts;
  65. _telephone.text = model.telephone;
  66. _receiptTime.text = model.receiptTime;
  67. _deliveryDate.text = model.deliveryDate;
  68. _deliveryAddress.text = model.deliveryAddress;
  69. _lblSign.text=model.signFlag;
  70. _lblDeliveryAttribute.text=model.deliveryAttribute;
  71. _lblGoodsAttribute.text=model.goodsAttribute;
  72. _receivables.text = [NSString stringWithFormat:@"%.2f",[model.receivables doubleValue]];
  73. _completeReceivables.text = [NSString stringWithFormat:@"%.2f",[model.completeReceivables doubleValue]];
  74. _receiptAmount.text = [NSString stringWithFormat:@"%.2f",[model.receiptAmount doubleValue]];
  75. _receivablesType.text = model.receivablesType;
  76. _receiptFlag.text = model.receiptFlag;
  77. _receiptType.text = model.receiptType;
  78. _nextDeliveryDate.text = [DateFormat dateFormatSplit: model.nextDeliveryDate];
  79. _recoverFlag.text = model.recoverFlag;
  80. }
  81. if(arr1 != nil){
  82. for (int i = 0; i < [arr1 count]; i++) {
  83. NSDictionary *infoDic=arr1[i];
  84. DeliveryListDetailModel *info = [DeliveryListDetailModel dk_modelWithDictionary:infoDic];
  85. [_infoList addObject:info];
  86. }
  87. }
  88. if(imagePathArr != nil&&[imagePathArr count] > 0){
  89. if( ! _photoList){
  90. _photoList = [[NSMutableArray alloc]init];
  91. }
  92. for (int i = 0; i < [imagePathArr count]; i++) {
  93. NSDictionary *imgDic = imagePathArr[i];
  94. NSString *imgPath = [imgDic objectForKey:@"ImagePath"];
  95. DeliveryImg *img = [DeliveryImg new];
  96. img.imageName = imgPath;
  97. [_photoList addObject:img];
  98. }
  99. }
  100. if(arr1 != nil){
  101. self.tableView.frame=CGRectMake(10,10, self.view.bounds.size.width - 20, [self getArrayViewHeight:self.infoList] + _headerView.bounds.size.height) ;
  102. contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.tableView.bounds.size.height);
  103. scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight +rectNavHeight + 50);
  104. }
  105. [self.tableView reloadData];
  106. if(imagePathArr != nil&&[imagePathArr count] > 0){
  107. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  108. flowLayout.itemSize = CGSizeMake(85, 85);
  109. flowLayout.minimumInteritemSpacing = 5;
  110. flowLayout.minimumLineSpacing = 10;
  111. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  112. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  113. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(self.tableView.frame), self.view.bounds.size.width - 40, [Util getPhotoCollectionViewHeightWithPhotos:self.photoList]) collectionViewLayout:flowLayout];
  114. self.collectionView.backgroundColor = [UIColor clearColor];
  115. self.collectionView.dataSource = self;
  116. self.collectionView.delegate = self;
  117. self.collectionView.scrollEnabled = NO;
  118. [self.collectionView registerClass:[AlbumPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"PhotoCollectionViewCellIdentifier"];
  119. [contentView addSubview:self.collectionView];
  120. contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(self.collectionView.frame));
  121. scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight + rectNavHeight + 50);
  122. }
  123. if(positionArr != nil && [positionArr count] > 0){
  124. NSDictionary *d1 = positionArr[0];
  125. //位置信息--------------
  126. UIView *vLocation = [UIView new];
  127. if(imagePathArr != nil&&[imagePathArr count] > 0){
  128. vLocation.frame = CGRectMake(0, CGRectGetMaxY(self.collectionView.frame), Screen_Width, mHeight);
  129. }
  130. else{
  131. vLocation.frame = CGRectMake(0, CGRectGetMaxY(self.tableView.frame), Screen_Width, mHeight);
  132. }
  133. [contentView addSubview:vLocation];
  134. UIImageView *positionImg = [[UIImageView alloc]init];
  135. positionImg.frame = CGRectMake(20,16, 13, 15);
  136. [positionImg setImage:[UIImage imageNamed:@"icon_position"]];
  137. [vLocation addSubview:positionImg];
  138. _location = [UILabel new];
  139. _location.frame = CGRectMake(CGRectGetMaxX(positionImg.frame) + 3, 11, Screen_Width - 105, 25);
  140. _location.font = kTextFont;
  141. [vLocation addSubview:_location];
  142. _location.text = [d1 objectForKey:@"Position"];
  143. if(_location.text != nil){
  144. [vLocation setHidden:NO];
  145. }else{
  146. [vLocation setHidden:YES];
  147. }
  148. contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(vLocation.frame));
  149. scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight + rectNavHeight + 50);
  150. }
  151. }
  152. }
  153. else if(iStatus == ActionResultStatusAuthError
  154. ||iStatus == ActionResultStatusNoLogin
  155. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  156. [self showReLoginDialog:message];
  157. return;
  158. }
  159. else {
  160. [self.tableView reloadData];
  161. [self showAlertViewText:message];
  162. }
  163. }
  164. /**
  165. 数据加载失败方法
  166. @param sender <#sender description#>
  167. */
  168. - (void)onLoadFail:(ASIDownManager *)sender {
  169. [self cancel];
  170. [self.tableView reloadData];
  171. [self showAlertViewText:@"网络异常"];
  172. }
  173. /**
  174. tableview的分区数
  175. @param tableView <#tableView description#>
  176. @return <#return value description#>
  177. */
  178. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  179. {
  180. return [_infoList count];
  181. }
  182. /**
  183. tableview 分区的间隔高度
  184. @param tableView <#tableView description#>
  185. @param section <#section description#>
  186. @return <#return value description#>
  187. */
  188. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  189. {
  190. return 10;
  191. }
  192. /**
  193. tableview的分区视图
  194. @param tableView <#tableView description#>
  195. @param section <#section description#>
  196. @return <#return value description#>
  197. */
  198. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  199. {
  200. UIView* myView = [[UIView alloc]init];
  201. myView.backgroundColor = [UIColor clearColor];
  202. return myView;
  203. }
  204. /**
  205. tableview每个分区的行数
  206. @param tableView <#tableView description#>
  207. @param section <#section description#>
  208. @return <#return value description#>
  209. */
  210. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  211. {
  212. return 1;
  213. }
  214. /**
  215. 获取tableview cell
  216. @param tableView <#tableView description#>
  217. @param indexPath <#indexPath description#>
  218. @return <#return value description#>
  219. */
  220. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  221. {
  222. NSString *cellIdentifier = @"DeliveryListDetailCell";
  223. DeliveryListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  224. if(!cell)
  225. {
  226. NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:cellIdentifier owner:nil options:nil];
  227. cell = [nibs lastObject];
  228. self.tableView.rowHeight = UITableViewAutomaticDimension;
  229. cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height);
  230. }
  231. NSMutableArray *dataArray = _infoList;
  232. DeliveryListDetailModel *dataModel = [dataArray objectAtIndex:indexPath.section];
  233. cell.layer.cornerRadius = CornerRadius;
  234. cell.layer.backgroundColor = [UIColor whiteColor].CGColor;
  235. cell.layer.masksToBounds = YES;
  236. cell.sourceFromName.text = dataModel.sourceFromName;
  237. cell.outQuantity.text = dataModel.outQuantity;
  238. cell.receiptRemarks.numberOfLines = 0;
  239. cell.receiptRemarks.text = dataModel.receiptRemarks == nil ||[dataModel.receiptRemarks isEqualToString:@""]?@" ":dataModel.receiptRemarks;
  240. cell.receiptQuantity.text = dataModel.receiptQuantity;
  241. cell.deliveryQuantity.text = dataModel.deliveryQuantity;
  242. cell.code.text = dataModel.code;
  243. cell.onlyCode.text = dataModel.onlyCode;
  244. cell.expandAttribute.text = dataModel.expandAttribute;
  245. cell.kindName.text = dataModel.kindName;
  246. cell.brandName.text = dataModel.brandName;
  247. cell.gradeName.text = dataModel.gradeName;
  248. cell.varietyName.text = dataModel.varietyName;
  249. cell.unitName.text = dataModel.unitName;
  250. cell.package.text = dataModel.package;
  251. cell.weight.text = dataModel.weight;
  252. cell.acreage.text = dataModel.acreage;
  253. cell.specification.text = dataModel.specification;
  254. cell.colorNumber.text = dataModel.colorNumber;
  255. cell.warehouseName.text = dataModel.warehouseName;
  256. cell.positionNumber.text = dataModel.positionNumber;
  257. int type = [dataModel.salesDetailType intValue];
  258. if(type){
  259. cell.salesDetailType.text = @"是";
  260. }else{
  261. cell.salesDetailType.text = @"否";
  262. }
  263. int type2 = [dataModel.receiptType intValue];
  264. switch (type2) {
  265. case 1:
  266. cell.receiptType.text = @"完成";
  267. break;
  268. case 2:
  269. cell.receiptType.text = @"再送";
  270. break;
  271. case 3:
  272. cell.receiptType.text = @"换货";
  273. break;
  274. case 4:
  275. cell.receiptType.text = @"退货";
  276. break;
  277. default:
  278. break;
  279. }
  280. CGRectGetMaxY(cell.salesDetailType.frame);
  281. return cell;
  282. }
  283. /**
  284. cellection view的列表项
  285. @param collectionView <#collectionView description#>
  286. @param section <#section description#>
  287. @return <#return value description#>
  288. */
  289. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  290. return self.photoList.count;
  291. }
  292. /**
  293. collection view的cell
  294. @param collectionView <#collectionView description#>
  295. @param indexPath <#indexPath description#>
  296. @return <#return value description#>
  297. */
  298. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  299. static NSString *PhotoCollectionViewCellIdentifier = @"PhotoCollectionViewCellIdentifier";
  300. AlbumPhotoCollectionViewCell *cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath];
  301. NSArray *Infoarray = _photoList;
  302. cell1.indexPath = indexPath;
  303. DeliveryImg *image1 = [Infoarray objectAtIndex:indexPath.row];
  304. NSString *imagepath = [image1 imageName];
  305. if(imagepath != nil && [imagepath length] > 0){
  306. NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,imagepath];
  307. NSURL *url = [NSURL URLWithString:imageUrl];
  308. [cell1.photoImageView setImageWithURL:url placeholderImage:nil];
  309. }
  310. return cell1;
  311. };
  312. /**
  313. 定义collectionview cell的大小
  314. @param collectionView <#collectionView description#>
  315. @param collectionViewLayout <#collectionViewLayout description#>
  316. @param indexPath <#indexPath description#>
  317. @return <#return value description#>
  318. */
  319. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  320. {
  321. return CGSizeMake(85, 85);
  322. }
  323. /**
  324. 定义每个collectionview cell的间距
  325. @param collectionView <#collectionView description#>
  326. @param collectionViewLayout <#collectionViewLayout description#>
  327. @param section <#section description#>
  328. @return <#return value description#>
  329. */
  330. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  331. {
  332. return UIEdgeInsetsMake(5, 5, 5, 5);
  333. }
  334. /**
  335. 放大图片
  336. @param collectionView <#collectionView description#>
  337. @param indexPath <#indexPath description#>
  338. */
  339. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  340. [self showImageViewerAtIndexPath:indexPath];
  341. }
  342. /**
  343. 放大图片委托
  344. @param indexPath <#indexPath description#>
  345. */
  346. - (void)showImageViewerAtIndexPath:(NSIndexPath *)indexPath {
  347. AlbumPhotoCollectionViewCell *cell = (AlbumPhotoCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  348. NSMutableArray *imageViews = [NSMutableArray array];
  349. NSArray *visibleCell = [self.collectionView visibleCells];
  350. NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"indexPath" ascending:YES];
  351. visibleCell = [visibleCell sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
  352. [visibleCell enumerateObjectsUsingBlock:^(AlbumPhotoCollectionViewCell *cell, NSUInteger idx, BOOL *stop) {
  353. [imageViews addObject:[[cell.contentView subviews] lastObject]];
  354. }];
  355. XHImageViewer *imageViewer = [[XHImageViewer alloc] init];
  356. [imageViewer showWithImageViews:imageViews selectedView:[[cell.contentView subviews] lastObject]];
  357. }
  358. /**
  359. 返回collection view是否可以被选择
  360. @param collectionView <#collectionView description#>
  361. @param indexPath <#indexPath description#>
  362. @return <#return value description#>
  363. */
  364. - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
  365. {
  366. return YES;
  367. }
  368. #pragma mark - 私有函数
  369. /**
  370. 返回函数
  371. */
  372. - (void)goBack
  373. {
  374. [self.navigationController popViewControllerAnimated:YES];
  375. }
  376. /**
  377. 初始化ui
  378. */
  379. - (void)initUI{
  380. self.navigationItem.title = @"回执明细";
  381. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  382. [button setImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal];
  383. [button addTarget:self action:@selector(goBack)
  384. forControlEvents:UIControlEventTouchUpInside];
  385. button.frame = CGRectMake(0, 0,45,22);
  386. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  387. self.navigationItem.leftBarButtonItem = menuButton;
  388. contentView = [[UIView alloc]init];
  389. contentView.frame = CGRectZero;
  390. contentView.backgroundColor = [UIColor clearColor];
  391. self.tableView = [UITableView new];
  392. self.tableView.rowHeight = UITableViewAutomaticDimension;
  393. self.tableView.dataSource = self;
  394. self.tableView.delegate = self;
  395. self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  396. self.tableView.backgroundColor = [UIColor clearColor];
  397. self.tableView.scrollEnabled = NO;
  398. self.tableView.estimatedRowHeight = 44.0f;
  399. self.tableView.frame = CGRectZero;
  400. [contentView addSubview:self.tableView];
  401. scroll = [UIScrollView new];
  402. scroll.frame = self.view.bounds;
  403. scroll.tag = 1000;
  404. [self.view addSubview:scroll];
  405. if(Screen_Height2 <= 480){
  406. scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + 80);
  407. }
  408. _headerView = [[UIView alloc]init];
  409. _headerView.frame = CGRectZero;
  410. _headerView.layer.cornerRadius = CornerRadius;
  411. _headerView.backgroundColor = [UIColor whiteColor];
  412. [scroll addSubview:contentView];
  413. //回执单号--------------
  414. UIView *vReceiptNoName = [UIView new];
  415. vReceiptNoName.frame = CGRectMake(0, 1, Screen_Width, 51);
  416. [_headerView addSubview:vReceiptNoName];
  417. UILabel *lblTxtCast = [UILabel new];
  418. lblTxtCast.frame = CGRectMake(10, 16,70, 25);
  419. lblTxtCast.text = @"回执单号:";
  420. lblTxtCast.font = kTextFont;
  421. [vReceiptNoName addSubview:lblTxtCast];
  422. _receiptNo = [UILabel new];
  423. _receiptNo.frame = CGRectMake(CGRectGetMaxX(lblTxtCast.frame), 16, 200, 25);
  424. _receiptNo.font = kTextFont;
  425. [vReceiptNoName addSubview:_receiptNo];
  426. UIImageView *separatorImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,50,Screen_Width, 1)];
  427. [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]];
  428. [vReceiptNoName addSubview:separatorImg];
  429. //安排单号--------------
  430. UIView *vArrangementNo = [UIView new];
  431. vArrangementNo.frame = CGRectMake(0,CGRectGetMaxY(vReceiptNoName.frame), Screen_Width, mHeight);
  432. [_headerView addSubview:vArrangementNo];
  433. UILabel *lblTxtArrangementNo = [UILabel new];
  434. lblTxtArrangementNo.frame = CGRectMake(10, 3, 70, 25);
  435. lblTxtArrangementNo.text = @"安排单号:";
  436. lblTxtArrangementNo.font = kTextFont;
  437. [vArrangementNo addSubview:lblTxtArrangementNo];
  438. _arrangementNo = [UILabel new];
  439. _arrangementNo.frame = CGRectMake(CGRectGetMaxX(lblTxtArrangementNo.frame),3, 200, 25);
  440. _arrangementNo.font = kTextFont;
  441. [vArrangementNo addSubview:_arrangementNo];
  442. //送货单号--------------
  443. UIView *vDeliveryNo = [UIView new];
  444. vDeliveryNo.frame = CGRectMake(0,CGRectGetMaxY(vArrangementNo.frame), Screen_Width, mHeight);
  445. [_headerView addSubview:vDeliveryNo];
  446. UILabel *lblvDeliveryNo = [UILabel new];
  447. lblvDeliveryNo.frame = CGRectMake(10,3, 70, 25);
  448. lblvDeliveryNo.text = @"送货单号:";
  449. lblvDeliveryNo.font = kTextFont;
  450. [vDeliveryNo addSubview:lblvDeliveryNo];
  451. _deliveryNo = [UILabel new];
  452. _deliveryNo.frame = CGRectMake(CGRectGetMaxX(lblvDeliveryNo.frame),3, 200, 25);
  453. _deliveryNo.font = kTextFont;
  454. [vDeliveryNo addSubview:_deliveryNo];
  455. //回执类型--------------
  456. UIView *vRecReceiptType = [UIView new];
  457. vRecReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryNo.frame), Screen_Width, mHeight);
  458. [_headerView addSubview:vRecReceiptType];
  459. UILabel *lblRecReceiptType = [UILabel new];
  460. lblRecReceiptType.frame = CGRectMake(10,3, 70, 25);
  461. lblRecReceiptType.text = @"回执类型:";
  462. lblRecReceiptType.font = kTextFont;
  463. [vRecReceiptType addSubview:lblRecReceiptType];
  464. _recReceiptType = [UILabel new];
  465. _recReceiptType.frame = CGRectMake(CGRectGetMaxX(lblRecReceiptType.frame),3, 200, 25);
  466. _recReceiptType.font = kTextFont;
  467. [vRecReceiptType addSubview:_recReceiptType];
  468. //客户名称--------------
  469. UIView *vCustomerName = [UIView new];
  470. vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vRecReceiptType.frame), Screen_Width, mHeight);
  471. [_headerView addSubview:vCustomerName];
  472. UILabel *lblCustomerName = [UILabel new];
  473. lblCustomerName.frame = CGRectMake(10,3, 70, 25);
  474. lblCustomerName.text = @"客户名称:";
  475. lblCustomerName.font = kTextFont;
  476. [vCustomerName addSubview:lblCustomerName];
  477. _customerName = [UILabel new];
  478. _customerName.font = kTextFont;
  479. _customerName.frame = CGRectMake(CGRectGetMaxX(lblCustomerName.frame),3, 200, 25);
  480. [vCustomerName addSubview:_customerName];
  481. //联系人--------------
  482. UIView *vContacts = [UIView new];
  483. vContacts.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, mHeight);
  484. [_headerView addSubview:vContacts];
  485. UILabel *lblContacts = [UILabel new];
  486. lblContacts.frame = CGRectMake(10,3,70, 25);
  487. lblContacts.text = @"联 系 人:";
  488. lblContacts.font = kTextFont;
  489. [vContacts addSubview:lblContacts];
  490. _contacts = [UILabel new];
  491. _contacts.font = kTextFont;
  492. _contacts.frame = CGRectMake(CGRectGetMaxX(lblContacts.frame),3, 200, 25);
  493. [vContacts addSubview:_contacts];
  494. //电话--------------
  495. UIView *vTelephone = [UIView new];
  496. vTelephone.frame = CGRectMake(0,CGRectGetMaxY(vContacts.frame), Screen_Width, mHeight);
  497. [_headerView addSubview:vTelephone];
  498. UILabel *lblvTelephone = [UILabel new];
  499. lblvTelephone.frame = CGRectMake(10,3,70, 25);
  500. lblvTelephone.font = kTextFont;
  501. lblvTelephone.text = @"联系电话:";
  502. [vTelephone addSubview:lblvTelephone];
  503. _telephone = [UILabel new];
  504. _telephone.font = kTextFont;
  505. _telephone.frame=CGRectMake(CGRectGetMaxX(lblvTelephone.frame),3, 200, 25);
  506. [vTelephone addSubview:_telephone];
  507. //回执日期--------------
  508. UIView *vReceiptTime = [UIView new];
  509. vReceiptTime.frame = CGRectMake(0,CGRectGetMaxY(vTelephone.frame), Screen_Width, mHeight);
  510. [_headerView addSubview:vReceiptTime];
  511. UILabel *lblvReceiptTime = [UILabel new];
  512. lblvReceiptTime.frame = CGRectMake(10,3,70, 25);
  513. lblvReceiptTime.text = @"回执日期:";
  514. lblvReceiptTime.font = kTextFont;
  515. [vReceiptTime addSubview:lblvReceiptTime];
  516. _receiptTime = [UILabel new];
  517. _receiptTime.frame = CGRectMake(CGRectGetMaxX(lblvReceiptTime.frame),3, 200, 25);
  518. _receiptTime.font = kTextFont;
  519. [vReceiptTime addSubview:_receiptTime];
  520. //地址--------------
  521. UIView *vDeliveryAddress = [UIView new];
  522. vDeliveryAddress.frame = CGRectMake(0,CGRectGetMaxY(vReceiptTime.frame), Screen_Width, mHeight);
  523. [_headerView addSubview:vDeliveryAddress];
  524. UILabel *lblvDeliveryAddress = [UILabel new];
  525. lblvDeliveryAddress.frame = CGRectMake(10,3,70, 25);
  526. lblvDeliveryAddress.text = @"客户地址:";
  527. lblvDeliveryAddress.font = kTextFont;
  528. [vDeliveryAddress addSubview:lblvDeliveryAddress];
  529. _deliveryAddress = [UILabel new];
  530. _deliveryAddress.frame = CGRectMake(CGRectGetMaxX(lblvDeliveryAddress.frame),3, 200, 25);
  531. _deliveryAddress.font = kTextFont;
  532. [vDeliveryAddress addSubview:_deliveryAddress];
  533. //应收金额--------------
  534. UIView *vReceivables = [UIView new];
  535. vReceivables.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAddress.frame), Screen_Width, mHeight);
  536. [_headerView addSubview:vReceivables];
  537. UILabel *lblvReceivables = [UILabel new];
  538. lblvReceivables.frame = CGRectMake(10,3,70, 25);
  539. lblvReceivables.text = @"应收金额:";
  540. lblvReceivables.font = kTextFont;
  541. [vReceivables addSubview:lblvReceivables];
  542. _receivables = [UILabel new];
  543. _receivables.font = kTextFont;
  544. _receivables.frame = CGRectMake(CGRectGetMaxX(lblvReceivables.frame),3, 200, 25);
  545. [vReceivables addSubview:_receivables];
  546. //已回执金额--------------
  547. UIView *vCompleteReceivables = [UIView new];
  548. vCompleteReceivables.frame = CGRectMake(0,CGRectGetMaxY(vReceivables.frame), Screen_Width, mHeight);
  549. [_headerView addSubview:vCompleteReceivables];
  550. UILabel *lblCompleteReceivables = [UILabel new];
  551. lblCompleteReceivables.frame = CGRectMake(10,3,85, 25);
  552. lblCompleteReceivables.font = kTextFont;
  553. lblCompleteReceivables.text = @"已回执金额:";
  554. [vCompleteReceivables addSubview:lblCompleteReceivables];
  555. _completeReceivables = [UILabel new];
  556. _completeReceivables.font = kTextFont;
  557. _completeReceivables.frame = CGRectMake(CGRectGetMaxX(lblCompleteReceivables.frame),3, 200, 25);
  558. [vCompleteReceivables addSubview:_completeReceivables];
  559. //回执标识--------------
  560. UIView *vReceiptFlag = [UIView new];
  561. vReceiptFlag.frame = CGRectMake(0,CGRectGetMaxY(vCompleteReceivables.frame), Screen_Width, mHeight);
  562. [_headerView addSubview:vReceiptFlag];
  563. UILabel *lblvReceiptFlag = [UILabel new];
  564. lblvReceiptFlag.frame = CGRectMake(10,3,70, 25);
  565. lblvReceiptFlag.text = @"回执标识:";
  566. lblvReceiptFlag.font = kTextFont;
  567. [vReceiptFlag addSubview:lblvReceiptFlag];
  568. _receiptFlag = [UILabel new];
  569. _receiptFlag.font = kTextFont;
  570. _receiptFlag.frame = CGRectMake(CGRectGetMaxX(lblvReceiptFlag.frame),3, 200, 25);
  571. [vReceiptFlag addSubview:_receiptFlag];
  572. //送货单回执类型--------------
  573. UIView *vReceiptType = [UIView new];
  574. vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vReceiptFlag.frame), Screen_Width, mHeight);
  575. [_headerView addSubview:vReceiptType];
  576. UILabel *lblvReceiptType = [UILabel new];
  577. lblvReceiptType.frame = CGRectMake(10,3,110, 25);
  578. lblvReceiptType.text = @"送货单回执类型:";
  579. lblvReceiptType.font = kTextFont;
  580. [vReceiptType addSubview:lblvReceiptType];
  581. _receiptType = [UILabel new];
  582. _receiptType.font = kTextFont;
  583. _receiptType.frame = CGRectMake(CGRectGetMaxX(lblvReceiptType.frame),3, 200, 25);
  584. [vReceiptType addSubview:_receiptType];
  585. //推迟送货日期--------------
  586. UIView *vNextDeliveryDate = [UIView new];
  587. vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame), Screen_Width, mHeight);
  588. [_headerView addSubview:vNextDeliveryDate];
  589. UILabel *lblvNextDeliveryDate = [UILabel new];
  590. lblvNextDeliveryDate.frame = CGRectMake(10,3, 110, 25);
  591. lblvNextDeliveryDate.text = @"推迟送货日期:";
  592. lblvNextDeliveryDate.font = kTextFont;
  593. [vNextDeliveryDate addSubview:lblvNextDeliveryDate];
  594. _nextDeliveryDate = [UILabel new];
  595. _nextDeliveryDate.font = kTextFont;
  596. _nextDeliveryDate.frame = CGRectMake(CGRectGetMaxX(lblvNextDeliveryDate.frame),3, 200, 25);
  597. [vNextDeliveryDate addSubview:_nextDeliveryDate];
  598. //单据回收--------------
  599. UIView *vRecoverFlag = [UIView new];
  600. vRecoverFlag.frame = CGRectMake(0,CGRectGetMaxY(vNextDeliveryDate.frame), Screen_Width, mHeight);
  601. [_headerView addSubview:vRecoverFlag];
  602. UILabel *lblvRecoverFlag = [UILabel new];
  603. lblvRecoverFlag.frame = CGRectMake(10,3,70, 25);
  604. lblvRecoverFlag.text = @"单据回收:";
  605. lblvRecoverFlag.font = kTextFont;
  606. [vRecoverFlag addSubview:lblvRecoverFlag];
  607. _recoverFlag = [UILabel new];
  608. _recoverFlag.font = kTextFont;
  609. _recoverFlag.frame = CGRectMake(CGRectGetMaxX(lblvRecoverFlag.frame),3, 200, 25);
  610. [vRecoverFlag addSubview:_recoverFlag];
  611. UIView *vSignFlag = [UIView new];
  612. vSignFlag.frame = CGRectMake(0,CGRectGetMaxY(vRecoverFlag.frame), Screen_Width, mHeight);
  613. [_headerView addSubview:vSignFlag];
  614. UILabel *lblSignFlag = [UILabel new];
  615. lblSignFlag.frame = CGRectMake(10,3,70, 25);
  616. lblSignFlag.text = @"是否签收:";
  617. lblSignFlag.font = kTextFont;
  618. [vSignFlag addSubview:lblSignFlag];
  619. _lblSign= [UILabel new];
  620. _lblSign.font = kTextFont;
  621. _lblSign.frame = CGRectMake(CGRectGetMaxX(lblSignFlag.frame),3, 200, 25);
  622. [vSignFlag addSubview:_lblSign];
  623. UIView *vDeliveryAttribute = [UIView new];
  624. vDeliveryAttribute.frame = CGRectMake(0,CGRectGetMaxY(vSignFlag.frame), Screen_Width, mHeight);
  625. [_headerView addSubview:vDeliveryAttribute];
  626. UILabel *lblDeliveryAttributeTitle = [UILabel new];
  627. lblDeliveryAttributeTitle.frame = CGRectMake(10,3,70, 25);
  628. lblDeliveryAttributeTitle.text = @"送货属性:";
  629. lblDeliveryAttributeTitle.font = kTextFont;
  630. [vDeliveryAttribute addSubview:lblDeliveryAttributeTitle];
  631. _lblDeliveryAttribute= [UILabel new];
  632. _lblDeliveryAttribute.font = kTextFont;
  633. _lblDeliveryAttribute.frame = CGRectMake(CGRectGetMaxX(lblDeliveryAttributeTitle.frame),3, 200, 25);
  634. [vDeliveryAttribute addSubview:_lblDeliveryAttribute];
  635. UIView *vGoodsAttribute = [UIView new];
  636. vGoodsAttribute.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAttribute.frame), Screen_Width, mHeight);
  637. [_headerView addSubview:vGoodsAttribute];
  638. UILabel *lblGoodsAttributeTitle = [UILabel new];
  639. lblGoodsAttributeTitle.frame = CGRectMake(10,3,70, 25);
  640. lblGoodsAttributeTitle.text = @"货物属性:";
  641. lblGoodsAttributeTitle.font = kTextFont;
  642. [vGoodsAttribute addSubview:lblGoodsAttributeTitle];
  643. _lblGoodsAttribute= [UILabel new];
  644. _lblGoodsAttribute.font = kTextFont;
  645. _lblGoodsAttribute.frame = CGRectMake(CGRectGetMaxX(lblGoodsAttributeTitle.frame),3, 200, 25);
  646. [vGoodsAttribute addSubview:_lblGoodsAttribute];
  647. _headerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(vGoodsAttribute.frame)+10);
  648. _tableView.tableHeaderView = _headerView;
  649. contentView.frame = CGRectMake(0,0,self.tableView.bounds.size.width, self.tableView.bounds.size.height);
  650. if(!_infoList){
  651. _infoList = [[NSMutableArray alloc]init];
  652. }
  653. }
  654. /**
  655. 数据加载
  656. */
  657. - (void)initData{
  658. [self startLoading];
  659. NSString *urlStr = ServerURL;
  660. NSMutableDictionary *dict = [NSMutableDictionary new];
  661. [dict setObject:@"GetIntelligentReceiptDetailIphone" forKey:@"Action"];
  662. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  663. [dict setObject:kkUserCode forKey:@"UserCode"];
  664. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  665. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  666. [dict setObject:_deliveryId forKey:@"DeliveryID"];
  667. [dict setObject:_arrangementId forKey:@"ArrangementID"];
  668. [dict setObject:_recReceiptNo forKey:@"RecReceiptNo"];
  669. self.mDownManager = [[ASIDownManager alloc] init];
  670. _mDownManager.delegate = self;
  671. _mDownManager.onRequestSuccess = @selector(onLoadFinish:);
  672. _mDownManager.onRequestFail = @selector(onLoadFail:);
  673. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  674. }
  675. /**
  676. 取消进度条
  677. */
  678. - (void)cancel {
  679. [self stopLoading];
  680. }
  681. /**
  682. 获取tableview的高度
  683. @param Array <#Array description#>
  684. @return <#return value description#>
  685. */
  686. - (CGFloat)getArrayViewHeight:(NSArray *)Array {
  687. // 上下间隔已经在frame上做了
  688. NSInteger row = Array.count;
  689. CGFloat allheight = 0;
  690. for (int i = 0; i < Array.count; i++) {
  691. DeliveryListDetailModel *info = Array[i];
  692. if([info.receiptRemarks isEqualToString:@""]){
  693. //不加空格计算不出备注的高度
  694. info.receiptRemarks = @" ";
  695. }
  696. CGFloat height = [info.receiptRemarks sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height + 700;
  697. allheight += height;
  698. }
  699. return allheight;
  700. }
  701. @end