InstallReceiptDetailVC.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. //
  2. // InstallReceiptDetailVC.m
  3. // IBOSS
  4. //
  5. // Created by apple on 16/1/8.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:安装回执明细视图控制器
  9. #import "InstallReceiptDetailVC.h"
  10. #import "InstallReceiptDetailCell.h"
  11. #import "DKCamera.h"
  12. #import "DKUICollectionViewCell.h"
  13. #import "DateFormat.h"
  14. #import "InstallReceiptDetailModel.h"
  15. #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  16. @interface InstallReceiptDetailVC ()
  17. {
  18. UIView *contentView;
  19. UIScrollView *scroll;
  20. UIView *vPosition;
  21. NSInteger imagesHeight;
  22. NSInteger posHeight;
  23. DateFormat* dateformat;
  24. NSArray *imageArr;
  25. }
  26. @end
  27. @implementation InstallReceiptDetailVC
  28. @synthesize vCustomTableView;
  29. #pragma mark - 公共函数
  30. /**
  31. 视图加载函数
  32. */
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.navigationItem.title = @"安装回执明细";
  36. _dataList = [[NSMutableArray alloc]init];
  37. _dataHead = [[NSMutableArray alloc]init];
  38. dateformat = [[DateFormat alloc]init];
  39. _assets = [[NSMutableArray alloc]init];
  40. [self initNavUI];
  41. [self initData];
  42. }
  43. /**
  44. 安全区视图发生变化
  45. */
  46. -(void)viewSafeAreaInsetsDidChange{
  47. scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  48. [super viewSafeAreaInsetsDidChange];
  49. }
  50. /**
  51. 初始化collection view
  52. */
  53. - (void)setupCollectionView{
  54. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  55. flowLayout.itemSize = CGSizeMake(85, 85);
  56. flowLayout.minimumInteritemSpacing = 5;
  57. flowLayout.minimumLineSpacing = 10;
  58. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  59. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  60. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  61. self.collectionView.backgroundColor = [UIColor clearColor];
  62. self.collectionView.dataSource = self;
  63. self.collectionView.delegate = self;
  64. [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
  65. [contentView addSubview:self.collectionView];
  66. }
  67. #pragma mark - 委托函数
  68. /**
  69. 分区数
  70. @param tableView <#tableView description#>
  71. @return <#return value description#>
  72. */
  73. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  74. return [_dataList count];
  75. }
  76. /**
  77. table view行数
  78. @param tableView <#tableView description#>
  79. @param section <#section description#>
  80. @return <#return value description#>
  81. */
  82. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  83. {
  84. return 1;
  85. }
  86. /**
  87. 获取tableview cell
  88. @param tableView <#tableView description#>
  89. @param indexPath <#indexPath description#>
  90. @return <#return value description#>
  91. */
  92. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  93. {
  94. static NSString *identifier = @"InstallReceiptDetailCell";
  95. InstallReceiptDetailCell* cell=(InstallReceiptDetailCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
  96. if(cell == nil){
  97. NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InstallReceiptDetailCell" owner:self options:nil];
  98. cell = [nib objectAtIndex:0];
  99. vCustomTableView.rowHeight = UITableViewAutomaticDimension;
  100. cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height);
  101. }
  102. NSUInteger row = [indexPath section];
  103. cell.layer.cornerRadius = CornerRadius;
  104. cell.layer.backgroundColor = [UIColor whiteColor].CGColor;
  105. cell.layer.masksToBounds = YES;
  106. [cell setInstallReceiptDetailInfo:_dataList[row]];
  107. return cell;
  108. }
  109. /**
  110. tableview 分区的间隔高度
  111. @param tableView <#tableView description#>
  112. @param section <#section description#>
  113. @return <#return value description#>
  114. */
  115. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  116. {
  117. return 10;
  118. }
  119. /**
  120. tableview的分区视图
  121. @param tableView <#tableView description#>
  122. @param section <#section description#>
  123. @return <#return value description#>
  124. */
  125. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  126. {
  127. UIView* myView = [[UIView alloc]init];
  128. myView.backgroundColor = [UIColor clearColor];
  129. return myView;
  130. }
  131. /**
  132. collection view的分区数
  133. @param pickerBrowser <#pickerBrowser description#>
  134. @return <#return value description#>
  135. */
  136. - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{
  137. return 1;
  138. }
  139. /**
  140. collection view的项数
  141. @param photoBrowser <#photoBrowser description#>
  142. @param section <#section description#>
  143. @return <#return value description#>
  144. */
  145. - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{
  146. return [self.assets count];
  147. }
  148. /**
  149. collection view的照片放大函数
  150. @param pickerBrowser <#pickerBrowser description#>
  151. @param indexPath <#indexPath description#>
  152. @return <#return value description#>
  153. */
  154. - (DKPhotoPickerBrowserPhoto *)photoBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{
  155. id imageObj = [self.assets objectAtIndex:indexPath.item];
  156. DKPhotoPickerBrowserPhoto *photo = [DKPhotoPickerBrowserPhoto photoAnyImageObjWith:imageObj];
  157. // 包装下imageObj 成 DKPhotoPickerBrowserPhoto 传给数据源
  158. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  159. // 缩略图
  160. photo.thumbImage = cell.imageView.image;
  161. return photo;
  162. }
  163. /**
  164. collection view的分区数
  165. @param collectionView <#collectionView description#>
  166. @return <#return value description#>
  167. */
  168. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  169. return 1;
  170. }
  171. /**
  172. collection view的项数
  173. @param collectionView <#collectionView description#>
  174. @param section <#section description#>
  175. @return <#return value description#>
  176. */
  177. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  178. return [self.assets count];
  179. }
  180. /**
  181. collection view cell
  182. @param collectionView <#collectionView description#>
  183. @param indexPath <#indexPath description#>
  184. @return <#return value description#>
  185. */
  186. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  187. DKUICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DKUICollectionViewCell" forIndexPath:indexPath];
  188. // 判断类型来获取Image
  189. DKPhotoAssets *asset = self.assets[indexPath.item];
  190. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  191. cell.imageView.image = asset.thumbImage;
  192. }
  193. else if ([asset isKindOfClass:[NSString class]]){
  194. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:(NSString *)asset] placeholderImage:[UIImage imageNamed:@"wallpaper_placeholder"]];
  195. }
  196. else if([asset isKindOfClass:[UIImage class]]){
  197. cell.imageView.image = (UIImage *)asset;
  198. }
  199. else if ([asset isKindOfClass:[DKCamera class]]){
  200. cell.imageView.image = [asset thumbImage];
  201. }
  202. return cell;
  203. }
  204. /**
  205. collection view的点击事件
  206. @param collectionView <#collectionView description#>
  207. @param indexPath <#indexPath description#>
  208. */
  209. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  210. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  211. // 图片游览器
  212. DKPhotoPickerBrowserViewController *pickerBrowser = [[DKPhotoPickerBrowserViewController alloc] init];
  213. // 传入点击图片View的话,会有微信朋友圈照片的风格
  214. pickerBrowser.toView = cell.imageView;
  215. // 数据源/delegate
  216. pickerBrowser.delegate = self;
  217. pickerBrowser.dataSource = self;
  218. // 是否可以删除照片
  219. pickerBrowser.editing = NO;
  220. // 当前选中的值
  221. pickerBrowser.currentIndexPath = [NSIndexPath indexPathForItem:indexPath.row inSection:0];
  222. // 展示控制器
  223. [pickerBrowser show];
  224. }
  225. #pragma mark - 私有函数
  226. /**
  227. 返回函数
  228. */
  229. - (void)goBack
  230. {
  231. [self.navigationController popViewControllerAnimated:YES];
  232. }
  233. /**
  234. 初始化返回按钮UI
  235. */
  236. - (void)initNavUI{
  237. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  238. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  239. [button addTarget:self action:@selector(goBack)
  240. forControlEvents:UIControlEventTouchUpInside];
  241. button.frame = CGRectMake(0, 0,45,22);
  242. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  243. self.navigationItem.leftBarButtonItem = menuButton;
  244. }
  245. /**
  246. 初始化地图位置ui
  247. @param posvalue <#posvalue description#>
  248. */
  249. - (void)initPositionUI:(NSString* )posvalue{
  250. if(posvalue == nil|| [posvalue isEqualToString:@""]){
  251. posHeight = 0;
  252. return;
  253. }
  254. posHeight = 31;
  255. vPosition = [UIView new];
  256. if(imageArr != nil && imageArr.count > 0){
  257. vPosition.frame = CGRectMake(0, CGRectGetMaxY(self.collectionView.frame), Screen_Width, posHeight);
  258. }
  259. else{
  260. vPosition.frame = CGRectMake(0, CGRectGetMaxY(self.vCustomTableView.frame), Screen_Width, posHeight);
  261. }
  262. [contentView addSubview:vPosition];
  263. UIImageView *positionView = [UIImageView new];
  264. positionView.frame = CGRectMake(20, 12,13, 15);
  265. positionView.image = [UIImage imageNamed:@"icon_position"];
  266. [vPosition addSubview:positionView];
  267. UILabel *lblPositionValue = [UILabel new];
  268. lblPositionValue.frame = CGRectMake(CGRectGetMaxX(positionView.frame) + 3,8, ((Screen_Width - 45)), 25);
  269. lblPositionValue.font = kTextFont;
  270. lblPositionValue.text = posvalue;
  271. [vPosition addSubview:lblPositionValue];
  272. }
  273. /**
  274. 初始化UI
  275. @param arr <#arr description#>
  276. */
  277. - (void)initUI:(NSArray* )arr{
  278. if(arr == nil){
  279. return;
  280. }
  281. NSDictionary * dic = arr[0];
  282. scroll = [UIScrollView new];
  283. scroll.frame = self.view.bounds;
  284. scroll.tag = 1000;
  285. [self.view addSubview:scroll];
  286. if(Screen_Height2 <= 480){
  287. scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + 80);
  288. }
  289. vCustomTableView = [UITableView new];
  290. vCustomTableView.frame = CGRectZero;
  291. self.vCustomTableView.estimatedRowHeight = 44.0f;
  292. self.vCustomTableView.rowHeight = UITableViewAutomaticDimension;
  293. vCustomTableView.backgroundColor = [UIColor clearColor];
  294. vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  295. vCustomTableView.delegate = self;
  296. vCustomTableView.scrollEnabled = NO;
  297. vCustomTableView.dataSource = self;
  298. contentView = [[UIView alloc]init];
  299. contentView.frame=CGRectZero;
  300. contentView.backgroundColor = [UIColor clearColor];
  301. [contentView addSubview:vCustomTableView];
  302. _headerView = [[UIView alloc]init];
  303. _headerView.frame = CGRectZero;
  304. _headerView.layer.cornerRadius =CornerRadius;
  305. _headerView.backgroundColor = [UIColor whiteColor];
  306. [scroll addSubview:contentView];
  307. double wh=((Screen_Width - 120 - 12));
  308. //回执单号 —————————
  309. UIView *vCode = [UIView new];
  310. vCode.frame = CGRectMake(0, 1, Screen_Width, 51);
  311. [_headerView addSubview:vCode];
  312. UILabel *lblcode = [UILabel new];
  313. lblcode.frame = CGRectMake(10, 16,80, 25);
  314. lblcode.text = @"回执单号:";
  315. lblcode.font = kTextFont;
  316. [vCode addSubview:lblcode];
  317. UILabel *lblCodeValue = [UILabel new];
  318. lblCodeValue.frame = CGRectMake(80, 16, wh, 25);
  319. lblCodeValue.text = [dic objectForKey:@"ReceiptNo"];
  320. lblCodeValue.font = kTextFont;
  321. [vCode addSubview:lblCodeValue];
  322. UIImageView *separatorImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(vCode.frame) - 1,Screen_Width, 1)];
  323. [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]];
  324. [vCode addSubview:separatorImg];
  325. [_headerView addSubview:vCode];
  326. //安排单号 —————————
  327. UIView *vArrangeCode = [UIView new];
  328. vArrangeCode.frame = CGRectMake(0, CGRectGetMaxY(vCode.frame), Screen_Width, 31);
  329. [_headerView addSubview:vArrangeCode];
  330. UILabel *lblArrangeCode = [UILabel new];
  331. lblArrangeCode.frame = CGRectMake(10, 3,80, 25);
  332. lblArrangeCode.text = @"安排单号:";
  333. lblArrangeCode.font = kTextFont;
  334. [vArrangeCode addSubview:lblArrangeCode];
  335. UILabel *lblArrangeCodeValue = [UILabel new];
  336. lblArrangeCodeValue.frame=CGRectMake(80, 3, wh, 25);
  337. lblArrangeCodeValue.text = [dic objectForKey:@"ArrangementNo"];
  338. lblArrangeCodeValue.font = kTextFont;
  339. [vArrangeCode addSubview:lblArrangeCodeValue];
  340. [_headerView addSubview:vArrangeCode];
  341. [_headerView addSubview:vArrangeCode];
  342. //单号 —————————
  343. UIView *vInstallCode = [UIView new];
  344. vInstallCode.frame = CGRectMake(0,CGRectGetMaxY(vArrangeCode.frame), Screen_Width, 31);
  345. [_headerView addSubview:vInstallCode];
  346. UILabel *lblInstallCode = [UILabel new];
  347. lblInstallCode.frame = CGRectMake(10, 3,80, 25);
  348. lblInstallCode.text = @"安装单号:";
  349. lblInstallCode.font = kTextFont;
  350. [vInstallCode addSubview:lblInstallCode];
  351. UILabel *lblInstallCodeValue = [UILabel new];
  352. lblInstallCodeValue.frame = CGRectMake(80, 3, wh, 25);
  353. lblInstallCodeValue.text = [dic objectForKey:@"InstallationNo"];
  354. lblInstallCodeValue.font = kTextFont;
  355. [vInstallCode addSubview:lblInstallCodeValue];
  356. [_headerView addSubview:vInstallCode];
  357. //回执类型 —————————
  358. UIView *vReceiptType = [UIView new];
  359. vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vInstallCode.frame), Screen_Width, 31);
  360. [_headerView addSubview:vReceiptType];
  361. UILabel *lblReceiptType = [UILabel new];
  362. lblReceiptType.frame = CGRectMake(10, 3,80, 25);
  363. lblReceiptType.text = @"回执类型:";
  364. lblReceiptType.font = kTextFont;
  365. [vReceiptType addSubview:lblReceiptType];
  366. UILabel *lblReceiptTypeValue = [UILabel new];
  367. lblReceiptTypeValue.frame = CGRectMake(80, 3, wh, 25);
  368. lblReceiptTypeValue.font = kTextFont;
  369. NSString* value = [[dic objectForKey:@"recReceiptType"] stringValue];
  370. if ([value isEqualToString:@"false"] || [value isEqualToString:@"0"]) {
  371. lblReceiptTypeValue.text = @"回执";
  372. }
  373. if ([value isEqualToString:@"true"] || [value isEqualToString:@"1"]) {
  374. lblReceiptTypeValue.text = @"撤销回执";
  375. }
  376. [vReceiptType addSubview:lblReceiptTypeValue];
  377. [_headerView addSubview:vReceiptType];
  378. //客户名称 —————————
  379. UIView *vCustomerName = [UIView new];
  380. vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame), Screen_Width, 31);
  381. [_headerView addSubview:vCustomerName];
  382. UILabel *lblCustomerName = [UILabel new];
  383. lblCustomerName.font = kTextFont;
  384. lblCustomerName.frame = CGRectMake(10, 3,80, 25);
  385. lblCustomerName.text = @"客户名称:";
  386. [vCustomerName addSubview:lblCustomerName];
  387. UILabel *lblCustomerNameValue = [UILabel new];
  388. lblCustomerNameValue.font = kTextFont;
  389. lblCustomerNameValue.frame = CGRectMake(80, 3, wh, 25);
  390. lblCustomerNameValue.text = [dic objectForKey:@"CustomerName"];
  391. [vCustomerName addSubview:lblCustomerNameValue];
  392. [_headerView addSubview:vCustomerName];
  393. //回执日期 —————————
  394. UIView *vReceiptDate = [UIView new];
  395. vReceiptDate.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, 31);
  396. [_headerView addSubview:vReceiptDate];
  397. UILabel *lblReceiptDate = [UILabel new];
  398. lblReceiptDate.font = kTextFont;
  399. lblReceiptDate.frame = CGRectMake(10, 3,80, 25);
  400. lblReceiptDate.text = @"回执日期:";
  401. [vReceiptDate addSubview:lblReceiptDate];
  402. UILabel *lblReceiptDateValue = [UILabel new];
  403. lblReceiptDateValue.font = kTextFont;
  404. lblReceiptDateValue.frame = CGRectMake(80, 3, wh, 25);
  405. if ([dic objectForKey:@"ReceiptTime"] != nil) {
  406. lblReceiptDateValue.text = [DateFormat dateFormatSplit:[dic objectForKey:@"ReceiptTime"]] ;
  407. }else{
  408. lblReceiptDateValue.text = @"";
  409. }
  410. [vReceiptDate addSubview:lblReceiptDateValue];
  411. //安装地址 —————————
  412. UIView *vInstallAddress = [UIView new];
  413. vInstallAddress.frame = CGRectMake(0,CGRectGetMaxY(vReceiptDate.frame), Screen_Width, 31);
  414. [_headerView addSubview:vInstallAddress];
  415. UILabel *lblInstallAddress = [UILabel new];
  416. lblInstallAddress.frame = CGRectMake(10, 3,80, 25);
  417. lblInstallAddress.text = @"安装地址:";
  418. lblInstallAddress.font = kTextFont;
  419. [vInstallAddress addSubview:lblInstallAddress];
  420. UILabel *lblInstallAddressValue = [UILabel new];
  421. lblInstallAddressValue.frame = CGRectMake(80, 3, wh, 25);
  422. lblInstallAddressValue.font = kTextFont;
  423. lblInstallAddressValue.text = [dic objectForKey:@"Address"];
  424. [vInstallAddress addSubview:lblInstallAddressValue];
  425. //应收金额 —————————
  426. UIView *vReceivables = [UIView new];
  427. vReceivables.frame = CGRectMake(0,CGRectGetMaxY(vInstallAddress.frame), Screen_Width, 31);
  428. [_headerView addSubview:vReceivables];
  429. UILabel *lblReceivables = [UILabel new];
  430. lblReceivables.font = kTextFont;
  431. lblReceivables.frame = CGRectMake(10, 3,80, 25);
  432. lblReceivables.text = @"应收金额:";
  433. [vReceivables addSubview:lblReceivables];
  434. UILabel *lblReceivablesValue = [UILabel new];
  435. lblReceivablesValue.font = kTextFont;
  436. lblReceivablesValue.frame = CGRectMake(80, 3, wh, 25);
  437. lblReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Receivables"] doubleValue]];
  438. [vReceivables addSubview:lblReceivablesValue];
  439. //已回金额 —————————
  440. UIView *vCompleteReceivables = [UIView new];
  441. vCompleteReceivables.frame = CGRectMake(0,CGRectGetMaxY(vReceivables.frame), Screen_Width, 31);
  442. [_headerView addSubview:vCompleteReceivables];
  443. UILabel *lblCompleteReceivables = [UILabel new];
  444. lblCompleteReceivables.frame = CGRectMake(10, 3,80, 25);
  445. lblCompleteReceivables.text = @"已回执金额:";
  446. lblCompleteReceivables.font = kTextFont;
  447. [vCompleteReceivables addSubview:lblCompleteReceivables];
  448. UILabel *lblCompleteReceivablesValue = [UILabel new];
  449. lblCompleteReceivablesValue.frame = CGRectMake(92, 3, wh, 25);
  450. lblCompleteReceivablesValue.font = kTextFont;
  451. lblCompleteReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"CompleteReceivables"] doubleValue]];
  452. [vCompleteReceivables addSubview:lblCompleteReceivablesValue];
  453. //回执标识 —————————
  454. UIView *vReceiptFlag = [UIView new];
  455. vReceiptFlag.frame = CGRectMake(0,CGRectGetMaxY(vCompleteReceivables.frame), Screen_Width, 31);
  456. [_headerView addSubview:vReceiptFlag];
  457. UILabel *lblReceiptFlag = [UILabel new];
  458. lblReceiptFlag.frame = CGRectMake(10, 3,80, 25);
  459. lblReceiptFlag.text = @"回执标识:";
  460. lblReceiptFlag.font = kTextFont;
  461. [vReceiptFlag addSubview:lblReceiptFlag];
  462. UILabel *lblReceiptFlagValue = [UILabel new];
  463. lblReceiptFlagValue.font = kTextFont;
  464. lblReceiptFlagValue.frame = CGRectMake(80, 3, wh, 25);
  465. BOOL flag = [[dic objectForKey:@"ReceiptFlag"] boolValue];
  466. if (flag) {
  467. lblReceiptFlagValue.text = @"是";
  468. }else{
  469. lblReceiptFlagValue.text = @"否";
  470. }
  471. [vReceiptFlag addSubview:lblReceiptFlagValue];
  472. //单据回执类型 —————————
  473. UIView *vDocReceiptType = [UIView new];
  474. vDocReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vReceiptFlag.frame), Screen_Width, 31);
  475. [_headerView addSubview:vDocReceiptType];
  476. UILabel *lblDocReceiptType = [UILabel new];
  477. lblDocReceiptType.font = kTextFont;
  478. lblDocReceiptType.frame = CGRectMake(10, 3, 80, 25);
  479. lblDocReceiptType.text = @"回执状态:";
  480. [vDocReceiptType addSubview:lblDocReceiptType];
  481. UILabel *lblDocReceiptTypeValue = [UILabel new];
  482. lblDocReceiptTypeValue.font = kTextFont;
  483. lblDocReceiptTypeValue.frame = CGRectMake(80, 3, wh-20, 25);
  484. value = [[dic objectForKey:@"ReceiptType"] stringValue];
  485. if ([value isEqualToString:@"1"]) {
  486. lblDocReceiptTypeValue.text = @"完成";
  487. }
  488. if ([value isEqualToString:@"3"]) {
  489. lblDocReceiptTypeValue.text = @"推迟安装";
  490. }
  491. [vDocReceiptType addSubview:lblDocReceiptTypeValue];
  492. //推迟日期
  493. UIView *vNextDate = [UIView new];
  494. vNextDate.frame=CGRectMake(0,CGRectGetMaxY(vDocReceiptType.frame), Screen_Width, 31);
  495. [_headerView addSubview:vNextDate];
  496. UILabel *lblNextDate = [UILabel new];
  497. lblNextDate.frame = CGRectMake(10, 3,80, 25);
  498. lblNextDate.text = @"推迟日期:";
  499. lblNextDate.font = kTextFont;
  500. [vNextDate addSubview:lblNextDate];
  501. UILabel *lblNextDateValue = [UILabel new];
  502. lblNextDateValue.frame = CGRectMake(80, 3, wh, 25);
  503. if ([value isEqualToString:@"3"]) {
  504. NSString *nextInstallationDate= [dic objectForKey:@"NextInstallDate"];
  505. if(nextInstallationDate!=nil){
  506. lblNextDateValue.text = [DateFormat dateFormatSplit:nextInstallationDate];
  507. }
  508. }
  509. lblNextDateValue.font = kTextFont;
  510. [vNextDate addSubview:lblNextDateValue];
  511. _headerView.frame = CGRectMake(0,0,vCustomTableView.bounds.size.width,CGRectGetMaxY(vNextDate.frame));
  512. vCustomTableView.tableHeaderView = _headerView;
  513. [self setupCollectionView];
  514. }
  515. /**
  516. 获取tableview的高度
  517. @param Array <#Array description#>
  518. @return <#return value description#>
  519. */
  520. - (CGFloat)getArrayViewHeight:(NSArray *)Array {
  521. // 上下间隔已经在frame上做了
  522. NSInteger row = Array.count;
  523. CGFloat allheight = 0;
  524. for (int i = 0; i < Array.count; i++) {
  525. InstallReceiptDetailModel *info = Array[i];
  526. if(info.receiptRemark == nil){
  527. //不加空格计算不出备注的高度
  528. info.receiptRemark = @" ";
  529. }
  530. CGFloat height = [info.receiptRemark sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height + 660;
  531. allheight += height;
  532. }
  533. return allheight;
  534. }
  535. /**
  536. 数据加载接口
  537. */
  538. - (void)initData{
  539. [self startLoading];
  540. NSString *urlStr = ServerURL;
  541. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  542. [dict setObject:@"GetInstallationReceiptDetailIphone" forKey:@"Action"];
  543. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  544. [dict setObject:kkUserCode forKey:@"UserCode"];
  545. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  546. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  547. [dict setObject:_installationId forKey:@"InstallationID"];
  548. [dict setObject:_arrangementId forKey:@"ArrangementID"];
  549. [dict setObject:_receiptNo forKey:@"RecReceiptNo"];
  550. self.mDownManager = [[ASIDownManager alloc] init];
  551. NSString *JsonArr = [self.mDownManager syncPostHttpRequestUrl:urlStr dic:dict path:nil filename:nil fileType:nil];
  552. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:JsonArr];
  553. int iStatus = resultModel.status;
  554. NSString *message = resultModel.message;
  555. if (iStatus == 0) {
  556. NSArray *infoArr;
  557. NSArray *infoHead;
  558. NSArray *posArr;
  559. [_dataList removeAllObjects];
  560. [_dataHead removeAllObjects];
  561. NSDictionary *dicResult =(NSDictionary*) resultModel.result;
  562. if(dicResult != nil){
  563. infoArr = [dicResult objectForKey:@"Table1"];
  564. infoHead = [dicResult objectForKey:@"Table"];
  565. imageArr = [dicResult objectForKey:@"ImagePath"];
  566. posArr = [dicResult objectForKey:@"Position"];
  567. }
  568. [self cancel];
  569. //更新ui
  570. if(infoHead!= nil && infoHead.count > 0){
  571. [self initUI:infoHead];
  572. }
  573. if(infoArr != nil&&infoArr.count > 0){
  574. for(int i=0;i<infoArr.count;i++){
  575. InstallReceiptDetailModel *model = [InstallReceiptDetailModel dk_modelWithDictionary:infoArr[i]];
  576. [_dataList addObject:model];
  577. }
  578. [_dataHead addObjectsFromArray:infoHead];
  579. if(_dataList.count == 0)
  580. {
  581. [self showAlertViewText:@"未找到匹配结果"];
  582. return;
  583. }
  584. vCustomTableView.frame = CGRectMake(10,10, self.view.bounds.size.width - 20, [self getArrayViewHeight:_dataList] + _headerView.bounds.size.height) ;
  585. contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(vCustomTableView.frame));
  586. scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 90);
  587. }
  588. [vCustomTableView reloadData];
  589. if(imageArr != nil && imageArr.count > 0)
  590. {
  591. [self.assets removeAllObjects];
  592. //共条数据
  593. for (int i = 0; i < imageArr.count; i++) {
  594. NSDictionary *dicImages=imageArr[i];
  595. NSString * imgPath = [dicImages objectForKey:@"ImagePath"];
  596. if(imgPath != nil && [imgPath length] > 0){
  597. NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,imgPath];
  598. DKCamera *c = [[DKCamera alloc] init];
  599. NSString *imagePath = (NSString *)[self.mDownManager downloadImageWithURL:imageUrl];
  600. if (imagePath == nil || [imagePath isEqualToString:@""]) {
  601. continue;
  602. }
  603. c.imagePath = imagePath;
  604. c.thumbImage = [UIImage imageWithContentsOfFile:imagePath ];
  605. [self.assets addObject:c];
  606. }
  607. }
  608. _collectionView.frame = CGRectMake(0,CGRectGetMaxY(vCustomTableView.frame), Screen_Width, [Util getPhotoCollectionViewHeightWithPhotos:self.assets]);
  609. contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(self.collectionView.frame));
  610. scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 90);
  611. [self.collectionView reloadData];
  612. }
  613. if(posArr != nil && posArr.count > 0)
  614. {
  615. //共一条数据
  616. NSDictionary * dicPositon = posArr[0];
  617. NSString *pos = [dicPositon objectForKey:@"Position"];
  618. [self initPositionUI:pos];
  619. contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(vPosition.frame));
  620. scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 90);
  621. }
  622. }
  623. else if(iStatus == ActionResultStatusAuthError
  624. || iStatus == ActionResultStatusNoLogin
  625. || iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  626. [self showReLoginDialog:message];
  627. return;
  628. }
  629. else{
  630. [self showAlertViewText:message];
  631. return;
  632. }
  633. }
  634. /**
  635. 进度条取消函数
  636. */
  637. - (void)cancel {
  638. [self stopLoading];
  639. }
  640. @end