| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- //
- // InstallReceiptedVC.m
- // IBOSS
- //
- // Created by guan hong hou on 2017/7/10.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:安装已回执视图控制器
- #import "InstallReceiptedVC.h"
- #import "InstallReceiptListCell.h"
- #import "DateFormat.h"
- #import "InstallReceiptDetailVC.h"
- #import "DeliveryReceiptSearchModel.h"
- #define receiptTextFont [UIFont systemFontOfSize:14]
- @interface InstallReceiptedVC ()
- @end
- @implementation InstallReceiptedVC
- #pragma mark - 公共函数
- /**
- 视图加载函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- _dataList = [[NSMutableArray alloc]init];
- _pInfo = [[ParseInstallReceiptList alloc]init];
- UIView *searchView=[[UIView alloc]init];
- searchView.frame=CGRectMake(0, 0, Screen_Width,55);
- [searchView setBackgroundColor:[UIColor whiteColor]];
- _btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnSearch.frame=CGRectMake(15, 10, Screen_Width-30, 35);
- [_btnSearch setTitle:@"查询" forState:UIControlStateNormal];
- [_btnSearch setBackgroundColor:[UIColor colorWithRed:232.0/255.0 green:233.0/255.0 blue:235.0/255.0 alpha:1]];
- _btnSearch.layer.cornerRadius = 10;
- _btnSearch.layer.masksToBounds = YES;
- [_btnSearch setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
- _btnSearch.titleLabel.font=receiptTextFont;
- [_btnSearch addTarget:self action:@selector(searchInstallReceiptData)
- forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:searchView];
- [searchView addSubview:_btnSearch];
- _vCustomTableView = [[RefreshTableView alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(searchView.frame), self.view.frame.size.width - 20, self.view.frame.size.height - rectNavHeight - rectStatusHeight - 150)];
- _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vCustomTableView.backgroundColor = [UIColor clearColor];
- _vCustomTableView.delegate = self;
- _vCustomTableView.mTableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:_vCustomTableView];
- _infoModel = [[InstallReceiptListModel alloc]init];
- __weak typeof(self) weakself=self;
- self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
- for (SideSlipModel *model in dataList) {
- model.selectedItemList = nil;
- model.customDict = nil;
- }
- } commitBlock:^(NSArray *dataList) {
- SideSlipModel *serviceRegionModel = dataList[0];
- _pageNumber=1;
- DeliveryReceiptSearchModel *m = [serviceRegionModel.customDict objectForKey:SEARCH_RANGE_MODEL];
- _installationNo=m.deliveryNo;
- _receiptType=m.receiptType;
- _startDate=m.startDate;
- _endDate=m.endDate;
- _customerName=m.customerName;
- _customerAddress=m.customerAddress;
- _customerTelephone=m.customerTelephone;
- if(_startDate!=nil&&_endDate!=nil){
- NSUInteger result= [DateFormat compareDate:_startDate withDate:_endDate];
- if(result == -1){
- [self showAlertViewText:@"开始日期不能大于结束日期"];
- return;
- }
- }
- if(_dataList!=nil&&_dataList.count>0){
- [_dataList removeAllObjects];
- [_pInfo.infoArr removeAllObjects];
- [_vCustomTableView reloadData];
- }
- [weakself.filterController dismiss];
- [self reloadData];
- }];
- _filterController.animationDuration = .3f;
- _filterController.hasHeadView = YES;
- _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
- _filterController.dataList = [self packageDataList];
- _installationNo=@"";
- _receiptType=@"";
- _startDate=@"";
- _endDate=@"";
- _pageNumber = 1;
- [self reloadData];
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vCustomTableView.frame = CGRectMake(10,55,Screen_Width-20, self.view.superview.frame.size.height-55);
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark - 委托函数
- /**
- 数据加载成功函数
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- [self cancel];
- _vCustomTableView.mTableView.backgroundView = nil;
- int iNewCount = 0;
- int iStatus = resultModel.status;
- NSString *message = resultModel.message;
- if (iStatus == 0) {
- NSArray * infoArr = (NSArray*)resultModel.result;
- if(infoArr != nil && infoArr.count > 0)
- {
- [_dataList addObjectsFromArray:infoArr];
- [self.pInfo parseInstallReceiptInfoArr:_dataList];
- iNewCount = (int)self.pInfo.infoArr.count;
- _vCustomTableView.mbMoreHidden = (iNewCount == 0);
- [_vCustomTableView FinishLoading];
- [_vCustomTableView reloadData];
-
- }
- else{
- [_vCustomTableView FinishLoading];
- if(_pageNumber == 1){
- _vCustomTableView.mbMoreHidden=YES;
- UIView *noDataView = [self noDataViewByFrame:_vCustomTableView.mTableView.bounds];
- _vCustomTableView.mTableView.backgroundView =noDataView;
- // [self showAlertViewText:@"未找到匹配结果"];
- return;
- }
-
- }
- }
- else if(iStatus == ActionResultStatusAuthError
- || iStatus == ActionResultStatusNoLogin
- || iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }
-
- else{
- [_vCustomTableView FinishLoading];
- [self showAlertViewText:message];
- return;
-
- }
-
-
- }
- /**
- 数据加载失败函数
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self.vCustomTableView reloadData];
- [self showAlertViewText:@"网络异常"];
-
- }
- /**
- 数据加载成功函数
- @param sender <#sender description#>
- */
- - (void)onCancelLoadFinish:(ASIDownManager *)sender {
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- [self stopLoading];
-
- int iStatus = resultModel.status;
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- [self showAlertViewText:@"撤销成功"];
- _pageNumber = 1;
- [_dataList removeAllObjects];
- [_pInfo.infoArr removeAllObjects];
- [ _vCustomTableView reloadData];
- _vCustomTableView.mbMoreHidden = YES;
- [self reloadData];
-
-
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }
- else{
-
- [_vCustomTableView FinishLoading];
- [self showAlertViewText:message];
- }
- }
- /**
- 数据加载失败函数
- @param sender <#sender description#>
- */
- - (void)onCancelLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
-
- }
- -(void)cancelReceipt:(NSInteger)index{
- InstallReceiptedListFrame *frame = [_pInfo.infoArr objectAtIndex:index];
-
- InstallReceiptListModel *receiptListModel=[frame installationReceiptListModel];
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@""
- message:@"确定要撤销回执?" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action){
- [self goToCancelReceipt:receiptListModel];
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action){
-
- }];
- UIColor *cancelColor=[UIColor blackColor];
- UIColor *sureColor=[UIColor redColor];
- [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
- [okAction setValue:sureColor forKey:@"titleTextColor"];
- [alert addAction:okAction];
- [alert addAction:cancelAction];
- [self presentViewController:alert animated:YES completion:nil];
-
- }
- -(void)goToCancelReceipt:(InstallReceiptListModel*)receiptListModel{
-
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"CancelInstallationReceiptIphone" 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:@"" forKeyedSubscript:@"ReceiptID"];
- [dict setObject:receiptListModel.installationId forKeyedSubscript:@"InstallationID"];
- [dict setObject:receiptListModel.arrangementId forKeyedSubscript:@"ArrangementID"];
-
- self.mDownManager = [[ASIDownManager alloc] init];
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onCancelLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onCancelLoadFail:);
- [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- /**
- tableview的行数
- @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#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return[_pInfo.infoArr count];
- }
- /**
- 获取tableview的高度
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- NSUInteger row = [indexPath section];
- InstallReceiptedListFrame *frame = [_pInfo.infoArr objectAtIndex:row];
- NSInteger cellHeight = [frame cellHeight];
- return cellHeight+10;
- }
- /**
- 获取tableview的分区视图
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view ;
- }
- /**
- tableview分区的间隔高度
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- /**
- 获取tableview的cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *identifier = @"InstallReceiptListCell";
- InstallReceiptListCell* cell = (InstallReceiptListCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
- cell = [[InstallReceiptListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
- NSUInteger row = [indexPath section];
- cell.index=row;
- cell.cancelDelegate=self;
- InstallReceiptedListFrame *frame = [_pInfo.infoArr objectAtIndex:row];
- [cell parseInfoFrame:frame];
- return cell;
-
- }
- /**
- tableview列表项点击事件
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- InstallReceiptDetailVC *detailVc = [[InstallReceiptDetailVC alloc] init];
- NSUInteger row = [indexPath section];
- InstallReceiptedListFrame *frame = [self.pInfo.infoArr objectAtIndex:row];
- NSString *id = [frame.installationReceiptListModel installationId];
- detailVc.installationId = id;
- detailVc.arrangementId = [frame.installationReceiptListModel arrangementId];
- detailVc.receiptNo = [frame.installationReceiptListModel receiptNo];
- self.cNav.visibleViewController.hidesBottomBarWhenPushed = YES;
- [self.cNav pushViewController:detailVc animated:YES];
-
- }
- /**
- 控制tableview是否能刷新
- @param sender <#sender description#>
- @return <#return value description#>
- */
- - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
- return YES;
- }
- /**
- tableview加载更多函数
- @param sender <#sender description#>
- */
- - (void)LoadMoreList:(RefreshTableView *)sender {
- _pageNumber++;
- [self reloadData];
- }
- /**
- tableview下拉刷新函数
- @param sender <#sender description#>
- */
- - (void)ReloadList:(RefreshTableView *)sender{
- _pageNumber = 1;
- [_dataList removeAllObjects];
- [ _vCustomTableView reloadData];
- _vCustomTableView.mbMoreHidden = YES;
- [self reloadData];
- }
- #pragma mark - 私有函数
- /**
- 加载数据接口
- */
- - (void)reloadData
- {
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetInstallationReceiptIphone" 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:[NSString stringWithFormat:@"%ld",(long)_pageNumber] forKey:@"PageNum"];
- [dict setObject:[NSString stringWithFormat:@"%d",pageSize] forKey:@"PageSize"];
- [dict setObject:_installationNo forKeyedSubscript:@"InstallatationNo"];
- [dict setObject:_customerName forKeyedSubscript:@"CustomerName"];
- [dict setObject:_customerTelephone forKeyedSubscript:@"Telephone"];
- [dict setObject:_customerAddress forKeyedSubscript:@"Address"];
- [dict setObject:_startDate forKeyedSubscript:@"BeginTime"];
- [dict setObject:_endDate forKeyedSubscript:@"endTime"];
- [dict setObject:_receiptType forKeyedSubscript:@"ReceiptType"];
- self.mDownManager = [[ASIDownManager alloc] init];
- _mDownManager.delegate = self;
- _mDownManager.onRequestSuccess = @selector(onLoadFinish:);
- _mDownManager.onRequestFail = @selector(onLoadFail:);
- [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
-
- }
- -(void)searchInstallReceiptData{
- [_filterController showPagerView:self.cNav];
- }
- /**
- 抽屉加载布局
-
- @return
- */
- - (NSArray *)packageDataList {
- NSMutableArray *dataArray = [NSMutableArray array];
- SideSlipModel *model = [[SideSlipModel alloc] init];
- model.containerCellClass = @"InstallReceiptSearchCell";
- model.regionTitle = @"查询条件";
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- /**
- 取消加载进度条
- */
- - (void)cancel {
- [self stopLoading];
- }
- @end
|