RepairReceiptDetailVC.m 28 KB

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