| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754 |
- //
- // RepairReceiptDetailVC.m
- // IBOSS
- //
- // Created by apple on 16/1/8.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:维修回执明细控制器
- #import "RepairReceiptDetailVC.h"
- #import "RepairReceiptDetailCell.h"
- #import "DKCamera.h"
- #import "DKUICollectionViewCell.h"
- #import "DateFormat.h"
- #import "RepairReceiptDetailModel.h"
- #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
- @interface RepairReceiptDetailVC ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate,DKPhotoPickerBrowserViewControllerDataSource,DKPhotoPickerBrowserViewControllerDelegate>
- {
- UIView *_contentView;
- UIScrollView *_scroll;
- UIView *_vPosition;
- NSInteger _imagesHeight;
- NSInteger _posHeight;
- }
- @property (strong,nonatomic) ASIDownManager* mDownManager ;
- @end
- @implementation RepairReceiptDetailVC
- @synthesize vCustomTableView;
- #pragma 公有函数
- /**
- 初始化下载管理器
- @return <#return value description#>
- */
- - (ASIDownManager *)mDownManager{
- if (!_mDownManager) {
- _mDownManager = [[ASIDownManager alloc] init];
- _mDownManager.delegate = self;
- }
- return _mDownManager;
- }
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"维修回执明细";
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- _dataList = [[NSMutableArray alloc]init];
- _dataHead = [[NSMutableArray alloc]init];
- _assets = [[NSMutableArray alloc]init];
- [self initData];
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 视图消失函数
- @param animated <#animated description#>
- */
- - (void)viewWillDisappear:(BOOL)animated
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super viewWillDisappear:animated];
- }
- #pragma 委托函数
- /**
- table view的分区数
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return [_dataList count];;
- }
- /**
- table view的行数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- /**
- tableview 分区的间隔高度
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- /**
- tableview的分区视图
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView* myView = [[UIView alloc]init];
- myView.backgroundColor = [UIColor clearColor];
- return myView;
- }
- /**
- 获取table view的cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *identifier = @"RepairReceiptDetailCell";
- RepairReceiptDetailCell* cell=(RepairReceiptDetailCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
- if(cell == nil){
- NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"RepairReceiptDetailCell" owner:self options:nil];
- cell = [nib objectAtIndex:0];
- }
-
- NSUInteger row = [indexPath section];
- cell.layer.cornerRadius=CornerRadius;
- cell.layer.backgroundColor = [UIColor whiteColor].CGColor;
- cell.layer.masksToBounds=YES;
- [cell setRepairReceiptDetailInfo:_dataList[row]];
- return cell;
- }
- /**
- 获取collection view的分区数
- @param pickerBrowser <#pickerBrowser description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{
- return 1;
- }
- /**
- 获取collection view的项数
- @param photoBrowser <#photoBrowser description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{
- return [self.assets count];
- }
- /**
- collection view的图片放大回调
- @param pickerBrowser <#pickerBrowser description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (DKPhotoPickerBrowserPhoto *)photoBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{
- id imageObj = [self.assets objectAtIndex:indexPath.item];
- DKPhotoPickerBrowserPhoto *photo = [DKPhotoPickerBrowserPhoto photoAnyImageObjWith:imageObj];
- // 包装下imageObj 成 DKPhotoPickerBrowserPhoto 传给数据源
- DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
- // 缩略图
- photo.thumbImage = cell.imageView.image;
- return photo;
- }
- /**
- 获取collection view的分区数
- @param collectionView <#collectionView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- /**
- 获取collection view的项数
- @param collectionView <#collectionView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
-
- self.collectionView.frame=CGRectMake(0,CGRectGetMaxY(vCustomTableView.frame), Screen_Width, [Util getPhotoCollectionViewHeightWithPhotos:self.assets]);
- _vPosition.frame=CGRectMake(0,CGRectGetMaxY(self.collectionView.frame), Screen_Width, 51);
- _contentView.frame=CGRectMake(0, 0, Screen_Width,CGRectGetMaxY(_vPosition.frame));
- _scroll.contentSize=CGSizeMake(Screen_Width, _contentView.frame.size.height+90);
- return [self.assets count];
- }
- /**
- 获取collection view的cell
- @param collectionView <#collectionView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
-
- DKUICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DKUICollectionViewCell" forIndexPath:indexPath];
-
- // 判断类型来获取Image
- DKPhotoAssets *asset = self.assets[indexPath.item];
- if ([asset isKindOfClass:[DKPhotoAssets class]]) {
- cell.imageView.image = asset.thumbImage;
- }else if ([asset isKindOfClass:[NSString class]]){
- [cell.imageView sd_setImageWithURL:[NSURL URLWithString:(NSString *)asset] placeholderImage:[UIImage imageNamed:@"wallpaper_placeholder"]];
- }else if([asset isKindOfClass:[UIImage class]]){
- cell.imageView.image = (UIImage *)asset;
- }else if ([asset isKindOfClass:[DKCamera class]]){
- cell.imageView.image = [asset thumbImage];
- }
-
- return cell;
-
- }
- /**
- collection view的点击事件
- @param collectionView <#collectionView description#>
- @param indexPath <#indexPath description#>
- */
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
-
- DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
- // 图片游览器
- DKPhotoPickerBrowserViewController *pickerBrowser = [[DKPhotoPickerBrowserViewController alloc] init];
- // 传入点击图片View的话,会有微信朋友圈照片的风格
- pickerBrowser.toView = cell.imageView;
- // 数据源/delegate
- pickerBrowser.delegate = self;
- pickerBrowser.dataSource = self;
- // 是否可以删除照片
- pickerBrowser.editing = NO;
- // 当前选中的值
- pickerBrowser.currentIndexPath = [NSIndexPath indexPathForItem:indexPath.row inSection:0];
- // 展示控制器
- [pickerBrowser show];
- }
- #pragma 私有函数
- /**
- 返回函数
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 初始化位置UI
- @param posvalue <#posvalue description#>
- */
- - (void)initPositionUI:(NSString* )posvalue{
- if(posvalue == nil|| [posvalue isEqualToString:@""]){
- return;
- }
-
- _vPosition.frame=CGRectMake(0,CGRectGetMaxY(self.collectionView.frame), Screen_Width, 51);
- UIImageView *positionView = [[UIImageView alloc]init];
- positionView.frame=CGRectMake(20,16,13, 15);
- positionView.image = [UIImage imageNamed:@"icon_position"];
- [_vPosition addSubview:positionView];
-
- UILabel *lblPositionValue = [UILabel new];
- lblPositionValue.frame=CGRectMake(CGRectGetMaxX(positionView.frame)+3,11, ((Screen_Width-40)), 25);
- lblPositionValue.text=posvalue;
- lblPositionValue.font=kTextFont;
- [_vPosition addSubview:lblPositionValue];
- }
- /**
- 初始化UI
- @param arr <#arr description#>
- */
- - (void)initUI:(NSArray* )arr{
- if(arr == nil){
- return;
- }
- NSDictionary * dic=arr[0];
- _scroll = [UIScrollView new];
- _scroll.frame=self.view.bounds;
- _scroll.tag=1000;
- [self.view addSubview:_scroll];
-
- if(Screen_Height2<=480){
- _scroll.contentSize=CGSizeMake(self.view.frame.size.width, self.view.frame.size.height+80);
- }
- _contentView = [[UIView alloc]init];
- _contentView.frame=CGRectZero;
- _contentView.backgroundColor = [UIColor clearColor];
- [_scroll addSubview:_contentView];
-
- _headerView = [[UIView alloc]init];
- _headerView.frame=CGRectZero;
- _headerView.layer.cornerRadius=CornerRadius;
- _headerView.backgroundColor = [UIColor whiteColor];
- vCustomTableView = [[UITableView alloc]init];
- vCustomTableView.frame = CGRectZero;
- vCustomTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
- vCustomTableView.backgroundColor = [UIColor clearColor];
- vCustomTableView.scrollEnabled=NO;
- vCustomTableView.delegate = self;
- vCustomTableView.estimatedRowHeight = 44.0f;
- vCustomTableView.rowHeight = UITableViewAutomaticDimension;
- vCustomTableView.dataSource = self;
- [_contentView addSubview:vCustomTableView];
- double wh=((Screen_Width-110-12));
- //回执单号
- UIView *vCode = [UIView new];
- vCode.frame=CGRectMake(0, 0, Screen_Width, 51);
- [_headerView addSubview:vCode];
- UILabel *lblCode = [UILabel new];
- lblCode.frame=CGRectMake(10, 16, 90, 25);
- lblCode.text = @"回执单号:";
- lblCode.font=kTextFont;
- [vCode addSubview:lblCode];
-
- UILabel *lblCodeValue = [UILabel new];
- lblCodeValue.frame=CGRectMake(80,16, wh, 25);
- lblCodeValue.text = [dic objectForKey:@"ReceiptNo"];
- lblCodeValue.font=kTextFont;
- [vCode addSubview:lblCodeValue];
-
- UIImageView *separatorImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,50,Screen_Width, 1)];
- [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]];
- [vCode addSubview:separatorImg];
-
- //单号 —————————
- UIView *vRepairCode = [UIView new];
- vRepairCode.frame=CGRectMake(0,CGRectGetMaxY(vCode.frame), Screen_Width, 31);
- [_headerView addSubview:vRepairCode];
- UILabel *lblRepairCode = [UILabel new];
- lblRepairCode.frame=CGRectMake(10, 3,90, 25);
- lblRepairCode.text = @"维修单号:";
- lblRepairCode.font=kTextFont;
- [vRepairCode addSubview:lblRepairCode];
-
- UILabel *lblRepairCodeValue = [UILabel new];
- lblRepairCodeValue.frame=CGRectMake(80, 3, wh, 25);
- lblRepairCodeValue.text = [dic objectForKey:@"RepairNo"];
- lblRepairCodeValue.font=kTextFont;
- [vRepairCode addSubview:lblRepairCodeValue];
- //安排单号 —————————
- UIView *vArrangeCode = [UIView new];
- vArrangeCode.frame=CGRectMake(0,CGRectGetMaxY(vRepairCode.frame), Screen_Width, 31);
- [_headerView addSubview:vArrangeCode];
- UILabel *lblArrangeCode = [UILabel new];
- lblArrangeCode.frame=CGRectMake(10, 3,90, 25);
- lblArrangeCode.text = @"安排单号:";
- lblArrangeCode.font=kTextFont;
- [vArrangeCode addSubview:lblArrangeCode];
-
- UILabel *lblArrangeCodeValue = [UILabel new];
- lblArrangeCodeValue.frame=CGRectMake(80, 3, wh, 25);
- lblArrangeCodeValue.text = [dic objectForKey:@"ArrangementNo"];
- lblArrangeCodeValue.font=kTextFont;
- [vArrangeCode addSubview:lblArrangeCodeValue];
-
-
- //地址 —————————
- UIView *vRepairAddr = [UIView new];
- vRepairAddr.frame=CGRectMake(0,CGRectGetMaxY(vArrangeCode.frame), Screen_Width, 31);
- [_headerView addSubview:vRepairAddr];
- UILabel *lblRepairAddr = [UILabel new];
- lblRepairAddr.frame=CGRectMake(10, 3,90, 25);
- lblRepairAddr.text = @"地 址:";
- lblRepairAddr.font=kTextFont;
- [vRepairAddr addSubview:lblRepairAddr];
-
- UILabel *lblRepairAddrValue = [UILabel new];
- lblRepairAddrValue.frame=CGRectMake(80, 3, wh, 25);
- lblRepairAddrValue.text = [dic objectForKey:@"Address"];
- lblRepairAddrValue.font=kTextFont;
- [vRepairAddr addSubview:lblRepairAddrValue];
-
- //客户名称 —————————
- UIView *vCustomerName = [UIView new];
- vCustomerName.frame=CGRectMake(0,CGRectGetMaxY(vRepairAddr.frame), Screen_Width, 31);
- [_headerView addSubview:vCustomerName];
- UILabel *lblCustomerName = [UILabel new];
- lblCustomerName.frame=CGRectMake(10, 3,90, 25);
- lblCustomerName.text = @"客户姓名:";
- lblCustomerName.font=kTextFont;
- [vCustomerName addSubview:lblCustomerName];
-
- UILabel *lblCustomerNameValue = [UILabel new];
- lblCustomerNameValue.frame=CGRectMake(80, 3, wh, 25);
- lblCustomerNameValue.text = [dic objectForKey:@"CustomerName"];
- lblCustomerNameValue.font=kTextFont;
- [vCustomerName addSubview:lblCustomerNameValue];
-
- //客服人员 —————————
- UIView *vServiceName = [UIView new];
- vServiceName.frame=CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, 31);
- [_headerView addSubview:vServiceName];
- UILabel *lblServiceName = [UILabel new];
- lblServiceName.frame=CGRectMake(10, 3,90, 25);
- lblServiceName.text = @"客服人员:";
- lblServiceName.font=kTextFont;
- [vServiceName addSubview:lblServiceName];
-
- UILabel *lblServiceNameValue = [UILabel new];
- lblServiceNameValue.frame=CGRectMake(80, 3, wh, 25);
- lblServiceNameValue.text = [dic objectForKey:@"ServiceStaffName"];
- lblServiceNameValue.font=kTextFont;
- [vServiceName addSubview:lblServiceNameValue];
-
- //回执日期 —————————
- UIView *vReceiptDate = [UIView new];
- vReceiptDate.frame=CGRectMake(0,CGRectGetMaxY(vServiceName.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptDate];
- UILabel *lblReceiptDate = [UILabel new];
- lblReceiptDate.frame=CGRectMake(10, 3,90, 25);
- lblReceiptDate.text = @"回执日期:";
- lblReceiptDate.font=kTextFont;
- [vReceiptDate addSubview:lblReceiptDate];
-
- UILabel *lblReceiptDateValue = [UILabel new];
- lblReceiptDateValue.frame=CGRectMake(80, 3, wh, 25);
- lblReceiptDateValue.font=kTextFont;
- if ([dic objectForKey:@"ReceiptTime"] != nil) {
- lblReceiptDateValue.text = [DateFormat dateFormatSplit:[dic objectForKey:@"ReceiptTime"]] ;
- }else{
- lblReceiptDateValue.text = @"";
- }
-
- [vReceiptDate addSubview:lblReceiptDateValue];
-
- //应收金额 —————————
- UIView *vReceivables = [UIView new];
- vReceivables.frame=CGRectMake(0,CGRectGetMaxY(vReceiptDate.frame), Screen_Width, 31);
- [_headerView addSubview:vReceivables];
- UILabel *lblReceivables = [UILabel new];
- lblReceivables.frame=CGRectMake(10, 3,90, 25);
- lblReceivables.text = @"应收金额:";
- lblReceivables.font=kTextFont;
- [vReceivables addSubview:lblReceivables];
-
- UILabel *lblReceivablesValue = [UILabel new];
- lblReceivablesValue.frame=CGRectMake(80, 3, wh, 25);
- lblReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Receivables"] doubleValue]];
- lblReceivablesValue.font=kTextFont;
- [vReceivables addSubview:lblReceivablesValue];
-
- //已回金额 —————————
- UIView *vCompleteReceivables = [UIView new];
- vCompleteReceivables.frame=CGRectMake(0,CGRectGetMaxY(vReceivables.frame), Screen_Width, 31);
- [_headerView addSubview:vCompleteReceivables];
- UILabel *lblCompleteReceivables = [UILabel new];
- lblCompleteReceivables.frame=CGRectMake(10, 3,90, 25);
- lblCompleteReceivables.text = @"已回执金额:";
- lblCompleteReceivables.font=kTextFont;
- [vCompleteReceivables addSubview:lblCompleteReceivables];
-
- UILabel *lblCompleteReceivablesValue = [UILabel new];
- lblCompleteReceivablesValue.frame=CGRectMake(95, 3, wh, 25);
- lblCompleteReceivablesValue.font=kTextFont;
- lblCompleteReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"CompleteReceivables"] doubleValue]];
- [vCompleteReceivables addSubview:lblCompleteReceivablesValue];
-
- //回执状态 —————————
- UIView *vReceiptStatus = [UIView new];
- vReceiptStatus.frame=CGRectMake(0,CGRectGetMaxY(vCompleteReceivables.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptStatus];
- UILabel *lblReceiptStatus = [UILabel new];
- lblReceiptStatus.frame=CGRectMake(10, 3,110, 25);
- lblReceiptStatus.text = @"维修单回执状态:";
- lblReceiptStatus.font=kTextFont;
- [vReceiptStatus addSubview:lblReceiptStatus];
-
- UILabel *lblReceiptStatusValue = [UILabel new];
- lblReceiptStatusValue.frame=CGRectMake(120, 3, wh, 25);
- lblReceiptStatusValue.font=kTextFont;
- NSString* status = [[dic objectForKey:@"ReceiptStatus"] stringValue];
- if ([status isEqualToString:@"0"]) {
- lblReceiptStatusValue.text = @"再安排";
- }else if ([status isEqualToString:@"1"]) {
- lblReceiptStatusValue.text = @"完成";
- }else if ([status isEqualToString:@"2"]) {
- lblReceiptStatusValue.text = @"部分完成";
- }
- [vReceiptStatus addSubview:lblReceiptStatusValue];
-
- //回执标识 —————————
- UIView *vReceiptFlag = [UIView new];
- vReceiptFlag.frame=CGRectMake(0,CGRectGetMaxY(vReceiptStatus.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptFlag];
- UILabel *lblReceiptFlag = [UILabel new];
- lblReceiptFlag.frame=CGRectMake(10, 3,110, 25);
- lblReceiptFlag.font=kTextFont;
- lblReceiptFlag.text = @"维修单回执标示:";
- [vReceiptFlag addSubview:lblReceiptFlag];
-
- UILabel *lblReceiptFlagValue = [UILabel new];
- lblReceiptFlagValue.frame=CGRectMake(120, 3, wh, 25);
- lblReceiptFlagValue.font=kTextFont;
- BOOL flag = [[dic objectForKey:@"ReceiptFlag"] boolValue];
- if (flag) {
- lblReceiptFlagValue.text = @"是";
- }else{
- lblReceiptFlagValue.text = @"否";
- }
- [vReceiptFlag addSubview:lblReceiptFlagValue];
-
- //回执类型 —————————
- UIView *vReceiptType = [UIView new];
- vReceiptType.frame=CGRectMake(0,CGRectGetMaxY(vReceiptFlag.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptType];
- UILabel *lblReceiptType = [UILabel new];
- lblReceiptType.frame=CGRectMake(10, 3,90, 25);
- lblReceiptType.text = @"回执类型:";
- lblReceiptType.font=kTextFont;
- [vReceiptType addSubview:lblReceiptType];
-
- UILabel *lblReceiptTypeValue = [UILabel new];
- lblReceiptTypeValue.frame=CGRectMake(80, 3, wh, 25);
- lblReceiptTypeValue.font=kTextFont;
- NSString* value = [[dic objectForKey:@"recReceiptType"] stringValue];
- if ([value isEqualToString:@"false"] || [value isEqualToString:@"0"]) {
- lblReceiptTypeValue.text = @"回执";
- }
- if ([value isEqualToString:@"true"] || [value isEqualToString:@"1"]) {
- lblReceiptTypeValue.text = @"撤销回执";
- }
- [vReceiptType addSubview:lblReceiptTypeValue];
-
- _headerView.frame=CGRectMake(0,0,vCustomTableView.bounds.size.width,CGRectGetMaxY(vReceiptType.frame));
- vCustomTableView.tableHeaderView=_headerView;
- _contentView.frame=CGRectMake(0,0,vCustomTableView.bounds.size.width, vCustomTableView.bounds.size.height);
- [_contentView addSubview:vCustomTableView];
- [self setupCollectionView];
-
- }
- /**
- 初始化CollectionView
- */
- - (void)setupCollectionView{
- UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
- flowLayout.itemSize = CGSizeMake(85, 85);
- flowLayout.minimumInteritemSpacing = 5;
- flowLayout.minimumLineSpacing = 10;
-
- flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
- flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
- self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, (85+15)*3) collectionViewLayout:flowLayout];
-
- self.collectionView.backgroundColor = [UIColor clearColor];
- self.collectionView.dataSource = self;
- self.collectionView.scrollEnabled=NO;
- self.collectionView.delegate = self;
- [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
- [_contentView addSubview:self.collectionView];
-
- }
- /**
- 初始化数据
- */
- - (void)initData{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetRepairReceiptDetailIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_repairId forKey:@"RepairID"];
- [dict setObject:_arrangementId forKey:@"ArrangementID"];
- [dict setObject:_receiptNo forKey:@"ReceiptNo"];
- NSString* JsonArr= [self.mDownManager syncPostHttpRequestUrl:urlStr dic:dict path:nil filename:nil fileType:nil];
-
- if([JsonArr length] != 0){
- NSDictionary *dic = [JsonArr JSONValue];
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- NSString *message = [dic objectForKey:@"Message"];
- if (iStatus == 0) {
- NSArray * infoArr;
- NSArray * infoHead;
- NSArray * imageArr;
- NSArray * posArr;
- [_dataList removeAllObjects];
- [_dataHead removeAllObjects];
- NSDictionary *dicResult = [dic objectForKey:@"Result"];
-
- if(dicResult != nil){
- infoArr = [dicResult objectForKey:@"Table1"];
- infoHead = [dicResult objectForKey:@"Table"];
- imageArr = [dicResult objectForKey:@"ImagePath"];
- posArr = [dicResult objectForKey:@"Position"];
- }
- self.mDownManager = nil;
- [self cancel];
-
- //更新ui
- [self initUI:infoHead];
-
- if(infoArr != nil&&infoArr.count>0){
-
- for(int i=0;i<infoArr.count;i++){
- RepairReceiptDetailModel *model = [RepairReceiptDetailModel dk_modelWithDictionary:infoArr[i]];
- [_dataList addObject:model];
- }
- [_dataHead addObjectsFromArray:infoHead];
-
- if(_dataList.count == 0)
- {
- [self showAlertViewText:@"未找到匹配结果"];
- return;
- }
-
- vCustomTableView.frame=CGRectMake(10,10, self.view.bounds.size.width-20, [self getArrayViewHeight:_dataList]+_headerView.bounds.size.height) ;
-
- _contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,vCustomTableView.bounds.size.height);
- _scroll.contentSize=CGSizeMake(self.view.frame.size.width, _contentView.frame.size.height+90);
-
- [vCustomTableView reloadData];
- }
-
- if(imageArr != nil&&imageArr.count>0)
- {
- [self.assets removeAllObjects];
-
- //共条数据
- for (int i=0; i<imageArr.count; i++) {
- NSDictionary * dicImages=imageArr[i];
- NSString * imgPath = [dicImages objectForKey:@"ImagePath"];
- if(imgPath != nil&&[imgPath length]>0){
- NSString *imageUrl= [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,imgPath];
- DKCamera * c = [[DKCamera alloc] init];
- NSString* imagePath=(NSString *)[self.mDownManager downloadImageWithURL:imageUrl];
- if (imagePath == nil || [imagePath isEqualToString:@""]) {
- continue;
- }
- c.imagePath=imagePath;
- c.thumbImage = [UIImage imageWithContentsOfFile:imagePath ];
- [self.assets addObject:c];
-
- }
-
- }
-
- }
- [self.collectionView reloadData];
- _vPosition = [UIView new];
- _vPosition.frame=CGRectMake(0,CGRectGetMaxY(self.collectionView.frame), Screen_Width,0);
- [_contentView addSubview:_vPosition];
- if(posArr != nil && posArr.count>0)
- {
- NSDictionary * dicPositon=posArr[0];
- NSString * pos = [dicPositon objectForKey:@"Position"];
- [self initPositionUI:pos];
- _contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(_vPosition.frame));
- _scroll.contentSize=CGSizeMake(self.view.frame.size.width, _contentView.frame.size.height+90);
- }
-
-
- }
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }
-
- else{
- [self showAlertViewText:message];
- return;
- }
-
- }
- }
- }
- /**
- 取消进度条加载
- */
- - (void)cancel {
- [self stopLoading];
- }
- /**
- 获取tableview的高度
- @param Array <#Array description#>
- @return <#return value description#>
- */
- - (CGFloat)getArrayViewHeight:(NSArray *)Array {
- // 上下间隔已经在frame上做了
- NSInteger row = Array.count;
- CGFloat allheight = 0;
- for (int i = 0; i < Array.count; i++) {
- RepairReceiptDetailModel *info = Array[i];
- if(info.remarks == nil){
- //不加空格计算不出备注的高度
- info.remarks = @" ";
- }
- CGFloat remarksHeight = [info.remarks sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height;
- if(info.receiptRemark == nil){
- //不加空格计算不出备注的高度
- info.receiptRemark = @" ";
- }
- CGFloat receiptRemarkHeight = [info.receiptRemark sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height;
- CGFloat height = receiptRemarkHeight + remarksHeight + 700;
- allheight += height;
- }
- return allheight;
- }
- @end
|