| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- //
- // InstallReceiptDetailVC.m
- // IBOSS
- //
- // Created by apple on 16/1/8.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:安装回执明细视图控制器
- #import "InstallReceiptDetailVC.h"
- #import "InstallReceiptDetailCell.h"
- #import "DKCamera.h"
- #import "DKUICollectionViewCell.h"
- #import "DateFormat.h"
- #import "InstallReceiptDetailModel.h"
- #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
- @interface InstallReceiptDetailVC ()
- {
- UIView *contentView;
- UIScrollView *scroll;
- UIView *vPosition;
- NSInteger imagesHeight;
- NSInteger posHeight;
- DateFormat* dateformat;
- NSArray *imageArr;
- }
- @end
- @implementation InstallReceiptDetailVC
- @synthesize vCustomTableView;
- #pragma mark - 公共函数
- /**
- 视图加载函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"安装回执明细";
- _dataList = [[NSMutableArray alloc]init];
- _dataHead = [[NSMutableArray alloc]init];
- dateformat = [[DateFormat alloc]init];
- _assets = [[NSMutableArray alloc]init];
- [self initNavUI];
- [self initData];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 初始化collection view
- */
- - (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:CGRectZero collectionViewLayout:flowLayout];
- self.collectionView.backgroundColor = [UIColor clearColor];
- self.collectionView.dataSource = self;
- self.collectionView.delegate = self;
- [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
- [contentView addSubview:self.collectionView];
-
- }
- #pragma mark - 委托函数
- /**
- 分区数
- @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 cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *identifier = @"InstallReceiptDetailCell";
- InstallReceiptDetailCell* cell=(InstallReceiptDetailCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
- if(cell == nil){
- NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InstallReceiptDetailCell" owner:self options:nil];
- cell = [nib objectAtIndex:0];
- vCustomTableView.rowHeight = UITableViewAutomaticDimension;
- cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height);
-
- }
-
- NSUInteger row = [indexPath section];
- cell.layer.cornerRadius = CornerRadius;
- cell.layer.backgroundColor = [UIColor whiteColor].CGColor;
- cell.layer.masksToBounds = YES;
- [cell setInstallReceiptDetailInfo:_dataList[row]];
-
- return cell;
-
- }
- /**
- 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;
- }
- /**
- 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{
-
- 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 mark - 私有函数
- /**
- 返回函数
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 初始化返回按钮UI
- */
- - (void)initNavUI{
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] 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;
-
- }
- /**
- 初始化地图位置ui
- @param posvalue <#posvalue description#>
- */
- - (void)initPositionUI:(NSString* )posvalue{
- if(posvalue == nil|| [posvalue isEqualToString:@""]){
- posHeight = 0;
- return;
- }
-
- posHeight = 31;
- vPosition = [UIView new];
- if(imageArr != nil && imageArr.count > 0){
- vPosition.frame = CGRectMake(0, CGRectGetMaxY(self.collectionView.frame), Screen_Width, posHeight);
- }
- else{
- vPosition.frame = CGRectMake(0, CGRectGetMaxY(self.vCustomTableView.frame), Screen_Width, posHeight);
- }
- [contentView addSubview:vPosition];
- UIImageView *positionView = [UIImageView new];
- positionView.frame = CGRectMake(20, 12,13, 15);
- positionView.image = [UIImage imageNamed:@"icon_position"];
- [vPosition addSubview:positionView];
- UILabel *lblPositionValue = [UILabel new];
- lblPositionValue.frame = CGRectMake(CGRectGetMaxX(positionView.frame) + 3,8, ((Screen_Width - 45)), 25);
- lblPositionValue.font = kTextFont;
- lblPositionValue.text = posvalue;
- [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);
- }
-
- vCustomTableView = [UITableView new];
- vCustomTableView.frame = CGRectZero;
- self.vCustomTableView.estimatedRowHeight = 44.0f;
- self.vCustomTableView.rowHeight = UITableViewAutomaticDimension;
- vCustomTableView.backgroundColor = [UIColor clearColor];
- vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- vCustomTableView.delegate = self;
- vCustomTableView.scrollEnabled = NO;
- vCustomTableView.dataSource = self;
- contentView = [[UIView alloc]init];
- contentView.frame=CGRectZero;
- contentView.backgroundColor = [UIColor clearColor];
- [contentView addSubview:vCustomTableView];
- _headerView = [[UIView alloc]init];
- _headerView.frame = CGRectZero;
- _headerView.layer.cornerRadius =CornerRadius;
- _headerView.backgroundColor = [UIColor whiteColor];
- [scroll addSubview:contentView];
- double wh=((Screen_Width - 120 - 12));
- //回执单号 —————————
- UIView *vCode = [UIView new];
- vCode.frame = CGRectMake(0, 1, Screen_Width, 51);
- [_headerView addSubview:vCode];
- UILabel *lblcode = [UILabel new];
- lblcode.frame = CGRectMake(10, 16,80, 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,CGRectGetMaxY(vCode.frame) - 1,Screen_Width, 1)];
- [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]];
- [vCode addSubview:separatorImg];
- [_headerView addSubview:vCode];
- //安排单号 —————————
- UIView *vArrangeCode = [UIView new];
- vArrangeCode.frame = CGRectMake(0, CGRectGetMaxY(vCode.frame), Screen_Width, 31);
- [_headerView addSubview:vArrangeCode];
- UILabel *lblArrangeCode = [UILabel new];
- lblArrangeCode.frame = CGRectMake(10, 3,80, 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];
- [_headerView addSubview:vArrangeCode];
- [_headerView addSubview:vArrangeCode];
- //单号 —————————
- UIView *vInstallCode = [UIView new];
- vInstallCode.frame = CGRectMake(0,CGRectGetMaxY(vArrangeCode.frame), Screen_Width, 31);
- [_headerView addSubview:vInstallCode];
- UILabel *lblInstallCode = [UILabel new];
- lblInstallCode.frame = CGRectMake(10, 3,80, 25);
- lblInstallCode.text = @"安装单号:";
- lblInstallCode.font = kTextFont;
- [vInstallCode addSubview:lblInstallCode];
- UILabel *lblInstallCodeValue = [UILabel new];
- lblInstallCodeValue.frame = CGRectMake(80, 3, wh, 25);
- lblInstallCodeValue.text = [dic objectForKey:@"InstallationNo"];
- lblInstallCodeValue.font = kTextFont;
- [vInstallCode addSubview:lblInstallCodeValue];
- [_headerView addSubview:vInstallCode];
- //回执类型 —————————
- UIView *vReceiptType = [UIView new];
- vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vInstallCode.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptType];
- UILabel *lblReceiptType = [UILabel new];
- lblReceiptType.frame = CGRectMake(10, 3,80, 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 addSubview:vReceiptType];
- //客户名称 —————————
- UIView *vCustomerName = [UIView new];
- vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame), Screen_Width, 31);
- [_headerView addSubview:vCustomerName];
- UILabel *lblCustomerName = [UILabel new];
- lblCustomerName.font = kTextFont;
- lblCustomerName.frame = CGRectMake(10, 3,80, 25);
- lblCustomerName.text = @"客户名称:";
- [vCustomerName addSubview:lblCustomerName];
-
- UILabel *lblCustomerNameValue = [UILabel new];
- lblCustomerNameValue.font = kTextFont;
- lblCustomerNameValue.frame = CGRectMake(80, 3, wh, 25);
- lblCustomerNameValue.text = [dic objectForKey:@"CustomerName"];
- [vCustomerName addSubview:lblCustomerNameValue];
- [_headerView addSubview:vCustomerName];
- //回执日期 —————————
- UIView *vReceiptDate = [UIView new];
- vReceiptDate.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptDate];
- UILabel *lblReceiptDate = [UILabel new];
- lblReceiptDate.font = kTextFont;
- lblReceiptDate.frame = CGRectMake(10, 3,80, 25);
- lblReceiptDate.text = @"回执日期:";
- [vReceiptDate addSubview:lblReceiptDate];
-
- UILabel *lblReceiptDateValue = [UILabel new];
- lblReceiptDateValue.font = kTextFont;
- lblReceiptDateValue.frame = CGRectMake(80, 3, wh, 25);
- if ([dic objectForKey:@"ReceiptTime"] != nil) {
- lblReceiptDateValue.text = [DateFormat dateFormatSplit:[dic objectForKey:@"ReceiptTime"]] ;
- }else{
- lblReceiptDateValue.text = @"";
- }
-
- [vReceiptDate addSubview:lblReceiptDateValue];
-
- //安装地址 —————————
- UIView *vInstallAddress = [UIView new];
- vInstallAddress.frame = CGRectMake(0,CGRectGetMaxY(vReceiptDate.frame), Screen_Width, 31);
- [_headerView addSubview:vInstallAddress];
- UILabel *lblInstallAddress = [UILabel new];
- lblInstallAddress.frame = CGRectMake(10, 3,80, 25);
- lblInstallAddress.text = @"安装地址:";
- lblInstallAddress.font = kTextFont;
- [vInstallAddress addSubview:lblInstallAddress];
-
- UILabel *lblInstallAddressValue = [UILabel new];
- lblInstallAddressValue.frame = CGRectMake(80, 3, wh, 25);
- lblInstallAddressValue.font = kTextFont;
- lblInstallAddressValue.text = [dic objectForKey:@"Address"];
- [vInstallAddress addSubview:lblInstallAddressValue];
-
- //应收金额 —————————
- UIView *vReceivables = [UIView new];
- vReceivables.frame = CGRectMake(0,CGRectGetMaxY(vInstallAddress.frame), Screen_Width, 31);
- [_headerView addSubview:vReceivables];
- UILabel *lblReceivables = [UILabel new];
- lblReceivables.font = kTextFont;
- lblReceivables.frame = CGRectMake(10, 3,80, 25);
- lblReceivables.text = @"应收金额:";
- [vReceivables addSubview:lblReceivables];
-
- UILabel *lblReceivablesValue = [UILabel new];
- lblReceivablesValue.font = kTextFont;
- lblReceivablesValue.frame = CGRectMake(80, 3, wh, 25);
- lblReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Receivables"] doubleValue]];
- [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,80, 25);
- lblCompleteReceivables.text = @"已回执金额:";
- lblCompleteReceivables.font = kTextFont;
- [vCompleteReceivables addSubview:lblCompleteReceivables];
-
- UILabel *lblCompleteReceivablesValue = [UILabel new];
- lblCompleteReceivablesValue.frame = CGRectMake(92, 3, wh, 25);
- lblCompleteReceivablesValue.font = kTextFont;
- lblCompleteReceivablesValue.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"CompleteReceivables"] doubleValue]];
-
- [vCompleteReceivables addSubview:lblCompleteReceivablesValue];
-
- //回执标识 —————————
- UIView *vReceiptFlag = [UIView new];
- vReceiptFlag.frame = CGRectMake(0,CGRectGetMaxY(vCompleteReceivables.frame), Screen_Width, 31);
- [_headerView addSubview:vReceiptFlag];
- UILabel *lblReceiptFlag = [UILabel new];
- lblReceiptFlag.frame = CGRectMake(10, 3,80, 25);
- lblReceiptFlag.text = @"回执标识:";
- lblReceiptFlag.font = kTextFont;
- [vReceiptFlag addSubview:lblReceiptFlag];
-
- UILabel *lblReceiptFlagValue = [UILabel new];
- lblReceiptFlagValue.font = kTextFont;
- lblReceiptFlagValue.frame = CGRectMake(80, 3, wh, 25);
- BOOL flag = [[dic objectForKey:@"ReceiptFlag"] boolValue];
- if (flag) {
- lblReceiptFlagValue.text = @"是";
- }else{
- lblReceiptFlagValue.text = @"否";
- }
- [vReceiptFlag addSubview:lblReceiptFlagValue];
-
- //单据回执类型 —————————
- UIView *vDocReceiptType = [UIView new];
- vDocReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vReceiptFlag.frame), Screen_Width, 31);
- [_headerView addSubview:vDocReceiptType];
- UILabel *lblDocReceiptType = [UILabel new];
- lblDocReceiptType.font = kTextFont;
- lblDocReceiptType.frame = CGRectMake(10, 3, 80, 25);
- lblDocReceiptType.text = @"回执状态:";
- [vDocReceiptType addSubview:lblDocReceiptType];
-
- UILabel *lblDocReceiptTypeValue = [UILabel new];
- lblDocReceiptTypeValue.font = kTextFont;
- lblDocReceiptTypeValue.frame = CGRectMake(80, 3, wh-20, 25);
- value = [[dic objectForKey:@"ReceiptType"] stringValue];
- if ([value isEqualToString:@"1"]) {
- lblDocReceiptTypeValue.text = @"完成";
- }
- if ([value isEqualToString:@"3"]) {
- lblDocReceiptTypeValue.text = @"推迟安装";
- }
-
- [vDocReceiptType addSubview:lblDocReceiptTypeValue];
-
- //推迟日期
- UIView *vNextDate = [UIView new];
- vNextDate.frame=CGRectMake(0,CGRectGetMaxY(vDocReceiptType.frame), Screen_Width, 31);
- [_headerView addSubview:vNextDate];
- UILabel *lblNextDate = [UILabel new];
- lblNextDate.frame = CGRectMake(10, 3,80, 25);
- lblNextDate.text = @"推迟日期:";
- lblNextDate.font = kTextFont;
- [vNextDate addSubview:lblNextDate];
-
- UILabel *lblNextDateValue = [UILabel new];
- lblNextDateValue.frame = CGRectMake(80, 3, wh, 25);
- if ([value isEqualToString:@"3"]) {
- NSString *nextInstallationDate= [dic objectForKey:@"NextInstallDate"];
- if(nextInstallationDate!=nil){
- lblNextDateValue.text = [DateFormat dateFormatSplit:nextInstallationDate];
- }
- }
- lblNextDateValue.font = kTextFont;
- [vNextDate addSubview:lblNextDateValue];
- _headerView.frame = CGRectMake(0,0,vCustomTableView.bounds.size.width,CGRectGetMaxY(vNextDate.frame));
- vCustomTableView.tableHeaderView = _headerView;
- [self setupCollectionView];
-
- }
- /**
- 获取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++) {
- InstallReceiptDetailModel *info = Array[i];
- if(info.receiptRemark == nil){
- //不加空格计算不出备注的高度
- info.receiptRemark = @" ";
- }
- CGFloat height = [info.receiptRemark sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height + 660;
- allheight += height;
- }
- return allheight;
- }
- /**
- 数据加载接口
- */
- - (void)initData{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetInstallationReceiptDetailIphone" 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:_installationId forKey:@"InstallationID"];
- [dict setObject:_arrangementId forKey:@"ArrangementID"];
- [dict setObject:_receiptNo forKey:@"RecReceiptNo"];
- self.mDownManager = [[ASIDownManager alloc] init];
- NSString *JsonArr = [self.mDownManager syncPostHttpRequestUrl:urlStr dic:dict path:nil filename:nil fileType:nil];
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:JsonArr];
- int iStatus = resultModel.status;
- NSString *message = resultModel.message;
- if (iStatus == 0) {
- NSArray *infoArr;
- NSArray *infoHead;
- NSArray *posArr;
- [_dataList removeAllObjects];
- [_dataHead removeAllObjects];
- NSDictionary *dicResult =(NSDictionary*) resultModel.result;
- if(dicResult != nil){
- infoArr = [dicResult objectForKey:@"Table1"];
- infoHead = [dicResult objectForKey:@"Table"];
- imageArr = [dicResult objectForKey:@"ImagePath"];
- posArr = [dicResult objectForKey:@"Position"];
- }
-
- [self cancel];
-
- //更新ui
- if(infoHead!= nil && infoHead.count > 0){
- [self initUI:infoHead];
- }
-
- if(infoArr != nil&&infoArr.count > 0){
-
-
- for(int i=0;i<infoArr.count;i++){
- InstallReceiptDetailModel *model = [InstallReceiptDetailModel 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,CGRectGetMaxY(vCustomTableView.frame));
- 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];
-
- }
-
- }
-
- _collectionView.frame = CGRectMake(0,CGRectGetMaxY(vCustomTableView.frame), Screen_Width, [Util getPhotoCollectionViewHeightWithPhotos:self.assets]);
-
- contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(self.collectionView.frame));
- scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 90);
- [self.collectionView reloadData];
- }
-
-
- 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];
- }
- @end
|