DeliveryRequirementDetailController.m 30 KB

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