| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855 |
- //
- // B2BMyHandleWorkVC.m
- // shiku_im
- //
- // Created by 周西 on 17/3/29.
- // Copyright © 2017年 UAS. All rights reserved.
- //
- #import "B2BMyHandleWorkVC.h"
- #import "ApprovalCell.h"
- #import "AFNetworking.h"
- #import "ApprovalWebView.h"
- #import "WYWebController.h"
- #import "iflyMSC/IFlyMSC.h"
- #import "IATConfig.h"
- #import "ISRDataHelper.h"
- #import "B2BApprovalDetailVC.h"
- #import "B2BNewTaskVC.h"
- #import "B2BHandleTaskModle.h"
- #import "B2BHandleTaskCell.h"
- #import "MJExtension.h"
- #import "B2BReplyTaskVC.h"
- static NSString *cellID = @"cellID";
- @interface B2BMyHandleWorkVC ()<UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,IFlySpeechRecognizerDelegate>
- @property (nonatomic,strong)UITableView *tableView;
- @property (nonatomic,strong) UISearchBar *searchBar;
- @property (nonatomic,strong) UIView * uv;
- @property(nonatomic,strong) IFlySpeechRecognizer * iFlySpeechRecognizer;//带视图的语音识别器
- @property(nonatomic,strong)UIImageView * imageV;
- @property(nonatomic,strong)UIView * MyView;
- @end
- @implementation B2BMyHandleWorkVC
- {
- UIButton *_weiShenpi; //未审批按钮
- UIButton *_yiShenpi; //已审批按钮
- UIButton *_woFaqide; //我发起的按钮
- UIImageView *_selectBtn1; //选择了按钮1的背景
- UIImageView *_selectBtn2; //选择了按钮2的背景
- UIImageView *_selectBtn3; //选择了按钮3的背景
- UILabel *_title1; //未审批
- UILabel *_title2; //已审批
- UILabel *_title3; //我发起的
-
- int _select; //选中哪个
- int _increaseNum; //刷新加多少条
- NSMutableArray *_searchArr;
- NSMutableArray *_testArr; //转换的数组
-
- UIImageView *_noData; //无数据的图片
-
- MBProgressHUD * HUD;
-
- /*********************************/
- NSMutableArray * _AllDataHandleArr;//主数组
- NSMutableArray * _AllDataHandleBrr;//备份数组
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
- self.view.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
-
- _searchArr = [[NSMutableArray alloc]init];
- _testArr = [[NSMutableArray alloc]init];
-
- _AllDataHandleArr = [[NSMutableArray alloc]init];
- _AllDataHandleBrr = [[NSMutableArray alloc]init];
-
- _select = 1;
- //获取网络数据(默认选中未处理)
- [self getTaskDataFromServerWithCondition:@""];
- //设置导航栏三个按钮
- [self setNavigationTitle];
-
- //设置tableView
- [self setTableView];
- //下拉刷新
- [self setupHeader];
- }
- -(void)getTaskDataFromServerWithCondition1:(NSString *)conditionStr
- {
- SLog(@"获取的人员是:%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]);
- _searchBar.text = @"";
- self.uv.hidden = NO;
- [_searchBar resignFirstResponder];
- NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
- NSString *ip = [UASUserInfo shareManager].urlIp;
-
- NSString *url = [NSString stringWithFormat:@"%@mobile/mobiletask/myTasks?emuu=%@&enuu=%@&pageNumber=%@&pageSize=%d&status=%@&sessionId=%@",ip,g_emcode,g_B2B_enuu,@"1",1000,conditionStr,sessionId];
- DLog(@"我的任务列表:%@",url);
- url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- UASNetworkManager *manager = [UASNetworkManager shareManager];
- manager.responseSerializer = [AFJSONResponseSerializer serializer];
-
- //拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //设置cookie
- [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- [manager request:url method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- [MBProgressHUD hideHUD];
- _weiShenpi.enabled = YES;
- _yiShenpi.enabled = YES;
- _woFaqide.enabled = YES;
-
- [_AllDataHandleArr removeAllObjects];
- [_AllDataHandleBrr removeAllObjects];
- [_searchArr removeAllObjects];
- NSMutableArray * allDataArr = [[NSMutableArray alloc]init];
- // SLog(@"我的任务列表数据1:%@",responseObject);
-
- for (id obj in responseObject[@"listdata"]) {
- [allDataArr addObject:obj];
- }
- allDataArr = [NSDictionary changeType:allDataArr];
-
- for (int i= 0; i<allDataArr.count; i++) {
- B2BHandleTaskModle * modle = [B2BHandleTaskModle mj_objectWithKeyValues:allDataArr[i]];
- modle = [NSDictionary changeType:modle];
-
- [_AllDataHandleArr addObject:modle];
- }
- //过滤重复数据
- NSSet * set1 = [NSSet setWithArray:_AllDataHandleArr];
-
- [_AllDataHandleArr removeAllObjects];
-
- _AllDataHandleArr = [[set1 allObjects] mutableCopy];
-
- //数组里面的时间元素按降序排列
- [self OrderByTimeDesc:_AllDataHandleArr];
- _AllDataHandleBrr = [[NSMutableArray alloc]initWithArray:_AllDataHandleArr];
- B2BHandleTaskModle * model;
- for (int i = 0; i<_AllDataHandleArr.count; i++) {
- model = _AllDataHandleArr[i];
- [_searchArr addObject:[NSString stringWithFormat:@"%@%@",model.recorder,model.taskname]];
-
- }
-
- [_tableView reloadData];
- if ([_AllDataHandleArr count] == 0) {
- _noData.hidden = NO;
- }else
- {
- _noData.hidden = YES;
- }
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- [MBProgressHUD hideHUD];
- _weiShenpi.enabled = YES;
- _yiShenpi.enabled = YES;
- _woFaqide.enabled = YES;
- DLog(@"请求失败:%@",error);
- NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
- if (returnData) {
- NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
-
- NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
-
- DLog(@"错误的原因:%@",errorStr);
- [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
- }
- else{
- [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
- }
- }];
-
- }
- #pragma mark --- 网络请求
- -(void)getTaskDataFromServerWithCondition:(NSString *)conditionStr
- {
- SLog(@"获取的人员是:%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]);
- _searchBar.text = @"";
- self.uv.hidden = NO;
- [_searchBar resignFirstResponder];
- NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
- NSString *ip = [UASUserInfo shareManager].urlIp;
-
- NSString *url = [NSString stringWithFormat:@"%@mobile/mobiletask/getAllTasks?emuu=%@&enuu=%@&pageNumber=%@&pageSize=%d&status=%@&sessionId=%@",ip,g_emcode,g_B2B_enuu,@"1",1000,conditionStr,sessionId];
- DLog(@"我的任务列表:%@",url);
- url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- UASNetworkManager *manager = [UASNetworkManager shareManager];
- manager.responseSerializer = [AFJSONResponseSerializer serializer];
-
- //拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //设置cookie
- [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- [manager request:url method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- [MBProgressHUD hideHUD];
- _weiShenpi.enabled = YES;
- _yiShenpi.enabled = YES;
- _woFaqide.enabled = YES;
-
- [_AllDataHandleArr removeAllObjects];
- [_AllDataHandleBrr removeAllObjects];
- [_searchArr removeAllObjects];
- NSMutableArray * allDataArr = [[NSMutableArray alloc]init];
- // SLog(@"我的任务列表数据:%@",responseObject);
-
- for (id obj in responseObject[@"listdata"]) {
- [allDataArr addObject:obj];
- }
- allDataArr = [NSDictionary changeType:allDataArr];
- NSMutableArray * arry1 =[[NSMutableArray alloc]init];
- NSMutableArray * arry2 =[[NSMutableArray alloc]init];
- // NSMutableArray * arry3 =[[NSMutableArray alloc]init];
- for (int i= 0; i<allDataArr.count; i++) {
- B2BHandleTaskModle * modle = [B2BHandleTaskModle mj_objectWithKeyValues:allDataArr[i]];
- modle = [NSDictionary changeType:modle];
- if ([modle.status isEqualToString:@"进行中"]) {
- [arry1 addObject:modle];
- }
- if ([modle.recordercode isEqualToString:g_emcode]&&[modle.status isEqualToString:@"待确认"]) {
- [arry1 addObject:modle];
- }
- if ([modle.status isEqualToString:@"已完成"]) {
- [arry2 addObject:modle];
- }
- if (![modle.recordercode isEqualToString:g_emcode]&&[modle.status isEqualToString:@"待确认"]) {
- [arry2 addObject:modle];
- }
- // if ([modle.recorder isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]]&&[modle.status isEqualToString:@"进行中"]) {
- // [arry3 addObject:modle];
- // }
- // if ([modle.recorder isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]]&&[modle.status isEqualToString:@"已完成"]) {
- // [arry3 addObject:modle];
- // }
- }
- if (_select == 1) {
- _AllDataHandleArr = [arry1 mutableCopy];
-
- }
- else if(_select == 2){
- _AllDataHandleArr = [arry2 mutableCopy];
- }
- // else{
- // _AllDataHandleArr = [arry3 mutableCopy];
- // }
- //过滤重复数据
- NSSet * set1 = [NSSet setWithArray:_AllDataHandleArr];
-
- [_AllDataHandleArr removeAllObjects];
-
- _AllDataHandleArr = [[set1 allObjects] mutableCopy];
-
- //数组里面的时间元素按降序排列
- [self OrderByTimeDesc:_AllDataHandleArr];
- _AllDataHandleBrr = [[NSMutableArray alloc]initWithArray:_AllDataHandleArr];
- B2BHandleTaskModle * model;
- for (int i = 0; i<_AllDataHandleArr.count; i++) {
- model = _AllDataHandleArr[i];
- [_searchArr addObject:[NSString stringWithFormat:@"%@%@",model.recorder,model.taskname]];
-
- }
-
- [_tableView reloadData];
- if ([_AllDataHandleArr count] == 0) {
- _noData.hidden = NO;
- }else
- {
- _noData.hidden = YES;
- }
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- [MBProgressHUD hideHUD];
- _weiShenpi.enabled = YES;
- _yiShenpi.enabled = YES;
- _woFaqide.enabled = YES;
- DLog(@"请求失败:%@",error);
- NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
- if (returnData) {
- NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
-
- NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
-
- DLog(@"错误的原因:%@",errorStr);
- [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
- }
- else{
- [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
- }
- }];
- }
- -(void)initRecognizer1
- {
- DLog(@"%s",__func__);
-
- //单例模式,无UI的实例
- if (_iFlySpeechRecognizer == nil) {
- _iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
-
- [_iFlySpeechRecognizer setParameter:@"" forKey:[IFlySpeechConstant PARAMS]];
-
- //设置听写模式
- [_iFlySpeechRecognizer setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]];
- }
- _iFlySpeechRecognizer.delegate = self;
-
- if (_iFlySpeechRecognizer != nil) {
- IATConfig *instance = [IATConfig sharedInstance];
-
- //设置最长录音时间
- [_iFlySpeechRecognizer setParameter:instance.speechTimeout forKey:[IFlySpeechConstant SPEECH_TIMEOUT]];
- //设置后端点
- [_iFlySpeechRecognizer setParameter:instance.vadEos forKey:[IFlySpeechConstant VAD_EOS]];
- //设置前端点
- [_iFlySpeechRecognizer setParameter:instance.vadBos forKey:[IFlySpeechConstant VAD_BOS]];
- //网络等待时间
- [_iFlySpeechRecognizer setParameter:@"20000" forKey:[IFlySpeechConstant NET_TIMEOUT]];
-
- //设置采样率,推荐使用16K
- [_iFlySpeechRecognizer setParameter:instance.sampleRate forKey:[IFlySpeechConstant SAMPLE_RATE]];
-
- if ([instance.language isEqualToString:[IATConfig chinese]]) {
- //设置语言
- [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
- //设置方言
- [_iFlySpeechRecognizer setParameter:instance.accent forKey:[IFlySpeechConstant ACCENT]];
- }else if ([instance.language isEqualToString:[IATConfig english]]) {
- [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
- }
- //设置是否返回标点符号
- [_iFlySpeechRecognizer setParameter:instance.dot forKey:[IFlySpeechConstant ASR_PTT]];
-
- }
-
- }
- -(void)setTableView
- {
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.rowHeight = 50;
- [self.view addSubview: _tableView];
- _tableView.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
- [_tableView registerClass:[ApprovalCell class] forCellReuseIdentifier:cellID];
-
- UIView *v = [[UIView alloc] initWithFrame:CGRectZero];
- v.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
- _tableView.tableFooterView = v;
-
- _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
- _searchBar.placeholder = Localized(@"UU_custom_search");
- _searchBar.barTintColor = Color(235, 233, 233, 1);
- _searchBar.delegate = self;
- UIView * uv = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-48, 7.5, 40, 30)];
- uv.userInteractionEnabled = YES;
- self.uv = uv;
- // uv.backgroundColor = [UIColor redColor];
- UITapGestureRecognizer * tapges =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickVoiceSearch)];
- UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(17,7 , 16,16 )];
- // [btn setBackgroundImage:[UIImage imageNamed:@"icon-searcher-custom"] forState:UIControlStateNormal];
- [btn setImage:[UIImage imageNamed:@"icon-searcher-custom"] forState:UIControlStateNormal];
- // [btn setBackgroundColor:[UIColor greenColor]];
- [btn addTarget:self action:@selector(clickVoiceSearch) forControlEvents:UIControlEventTouchUpInside];
- [uv addSubview:btn];
- [uv addGestureRecognizer:tapges];
- [_searchBar addSubview:uv];
- //添加 searchBar 到 headerView
- UIView *tableHeaderView = [[UIView alloc] init];
- [tableHeaderView addSubview:_searchBar];
- tableHeaderView.height = 44;
- [_tableView setTableHeaderView:tableHeaderView];
-
- HUD = [[MBProgressHUD alloc]initWithView:self.view];
- HUD.dimBackground = YES;
- HUD.mode = MBProgressHUDModeIndeterminate;
- // [HUD show:YES];
- [self.view addSubview:HUD];
-
- _noData = [[UIImageView alloc]init];
- _noData.image = [UIImage imageNamed:@"crm_all_noData"];
- _noData.hidden = YES;
- [self.view addSubview:_noData];
- [_noData mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(100);
- make.height.mas_equalTo(126);
- make.center.equalTo(self.view);
- }];
- }
- -(void)setNavigationTitle
- {
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 180, 22)];
-
- UIImageView *titleBG = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 180, 22)];
- titleBG.image = [UIImage imageNamed:@"uu_shenpiTitleBG"];
- [view addSubview:titleBG];
- titleBG.userInteractionEnabled = YES;
-
- _selectBtn1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _selectBtn1.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
-
- _selectBtn2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _selectBtn2.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
-
- _selectBtn3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _selectBtn3.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
-
- _weiShenpi = [UIButton buttonWithType:UIButtonTypeCustom];
- _weiShenpi.frame = CGRectMake(0, 0, 60, 22);
- [_weiShenpi addSubview:_selectBtn1];
- [_weiShenpi addTarget:self action:@selector(noApprovalprocessChangeData) forControlEvents:UIControlEventTouchUpInside];
-
- _yiShenpi = [UIButton buttonWithType:UIButtonTypeCustom];
- _yiShenpi.frame = CGRectMake(60, 0, 60, 22);
- [_yiShenpi addSubview:_selectBtn2];
- _selectBtn2.hidden = YES;
- [_yiShenpi addTarget:self action:@selector(haveApprovalprocessChangeData) forControlEvents:UIControlEventTouchUpInside];
-
- _woFaqide = [UIButton buttonWithType:UIButtonTypeCustom];
- _woFaqide.frame = CGRectMake(120, 0, 60, 22);
- [_woFaqide addSubview:_selectBtn3];
- _selectBtn3.hidden = YES;
- [_woFaqide addTarget:self action:@selector(myLoadChangeData) forControlEvents:UIControlEventTouchUpInside];
-
- [titleBG addSubview:_weiShenpi];
- [titleBG addSubview:_yiShenpi];
- [titleBG addSubview:_woFaqide];
-
- _title1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _title1.font = FONT_SIZE(13);
- _title1.textColor = Color(87, 87, 87, 1);
- _title1.text = @"待处理";
- _title1.textAlignment = NSTextAlignmentCenter;
- [_weiShenpi addSubview:_title1];
-
- _title2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _title2.font = FONT_SIZE(13);
- _title2.textColor = Color(255, 255, 255, 1);
- _title2.text = @"已处理";
- _title2.textAlignment = NSTextAlignmentCenter;
- [_yiShenpi addSubview:_title2];
-
- _title3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
- _title3.font = FONT_SIZE(13);
- _title3.textColor = Color(255, 255, 255, 1);
- _title3.text = @"我发起的";
- _title3.textAlignment = NSTextAlignmentCenter;
- [_woFaqide addSubview:_title3];
-
- self.navigationItem.titleView = view;
-
- UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
- btn2.frame = CGRectMake(0, 5, 22, 22);
- UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
- image.image = [UIImage imageNamed:@"icon_back_nor3"];
- [btn2 addSubview:image];
- [btn2 addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
- self.navigationItem.leftBarButtonItems = @[bbi2];
-
- UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeSystem];
- btn3.frame = CGRectMake(0, 5, 20, 20);
- UIImageView *image1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5, 20, 20)];
- image1.image = [UIImage imageNamed:@"crm_main_add"];
- [btn3 addSubview:image1];
- [btn3 addTarget:self action:@selector(clickRightButton) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *bbi3 = [[UIBarButtonItem alloc]initWithCustomView:btn3];
- self.navigationItem.rightBarButtonItem = bbi3;
- }
- -(void)clickRightButton{
- B2BNewTaskVC * bvc = [[B2BNewTaskVC alloc]init];
- bvc.block1 = ^(){
- DLog(@"有走这个方法么");
- _select==3?[self getTaskDataFromServerWithCondition1:@""]:[self getTaskDataFromServerWithCondition:@""];
- };
- [self.navigationController pushViewController:bvc animated:YES];
-
-
- }
- -(void)clickVoiceSearch{
- DLog(@"什么被点击了呢");
- [_searchBar resignFirstResponder];
- UIView * MyView =[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
- MyView.backgroundColor =[UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
- self.MyView = MyView;
- [self.view addSubview:MyView];
- UIImageView * imageV =[[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-60)/2, 200, 60, 60)];
- imageV.image = [UIImage imageNamed:@"uu_voice_search1"];
- imageV.userInteractionEnabled = YES;
- imageV.tag = 100;
- self.imageV = imageV;
-
- [MyView addSubview:imageV];
- [_iFlySpeechRecognizer startListening];
-
-
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- [super touchesBegan:touches withEvent:event];
- [self.MyView removeFromSuperview];
- [_iFlySpeechRecognizer cancel];
- }
- #pragma mark -- UITableView Delegate / DataSoure
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return _AllDataHandleArr.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- B2BHandleTaskCell *cell = [B2BHandleTaskCell cellWithTableView:tableView];
- cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
- // cell.selectionStyle = UITableViewCellAccessoryNone;
- B2BHandleTaskModle * modle = _AllDataHandleArr[indexPath.row];
- cell.modle = modle;
- //我发起的过滤我的人名
- if (_select == 3) {
- cell.nameLbl.text =[NSString stringWithFormat:@"%@",modle.taskname];
- }
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:NO];
- NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
- B2BHandleTaskModle * modle = _AllDataHandleArr[indexPath.row];
- B2BReplyTaskVC *replyVC = [[B2BReplyTaskVC alloc]init];
- replyVC.launchPerson = modle.recorder;
- replyVC.acceptPerson = modle.doman;
- replyVC.taskName = modle.taskname;
- replyVC.status =modle.status;
- replyVC.startDate = [NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[NSString stringWithFormat:@"%@",modle.startdate] longLongValue]/1000]]]];
- replyVC.endDate = [NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[NSString stringWithFormat:@"%@",modle.enddate] longLongValue]/1000]]]];
- replyVC.describ = modle.detail;
- // replyVC.taskcode = modle.;
- replyVC.ra_id = modle.id;
- replyVC.taskid = modle.id;
-
- replyVC.recorderCode = modle.recordercode;
- replyVC.domanCode = modle.domancode;
- NSString *state = modle.statuscode;
-
- if ([state isEqualToString:@"start"]) {
- replyVC.type = HandleTaskTypeForStart;
- }else if([state isEqualToString:@"uncomfirmed"])
- {
- replyVC.type = HandleTaskTypeForWaitVerify;
- }else
- {
- replyVC.type = HandleTaskTypeForFinish;
- }
- [self.navigationController pushViewController:replyVC animated:YES];
- }
- #pragma mark -- 未处理
- -(void)noApprovalprocessChangeData
- {
-
- _select = 1;
- _selectBtn1.hidden = NO;
- _selectBtn2.hidden = YES;
- _selectBtn3.hidden = YES;
- _title1.textColor = Color(87, 87, 87, 1);
- _title2.textColor = Color(255, 255, 255, 1);
- _title3.textColor = Color(255, 255, 255, 1);
- [_iFlySpeechRecognizer cancel];
- [self getTaskDataFromServerWithCondition:@""];
- // [_tableView reloadData];
-
- }
- #pragma mark -- 已处理
- -(void)haveApprovalprocessChangeData
- {
-
- _select = 2;
- _selectBtn1.hidden = YES;
- _selectBtn2.hidden = NO;
- _selectBtn3.hidden = YES;
- _title1.textColor = Color(255, 255, 255, 1);
- _title2.textColor = Color(87, 87, 87, 1);
- _title3.textColor = Color(255, 255, 255, 1);
- [_iFlySpeechRecognizer cancel];
- [self getTaskDataFromServerWithCondition:@""];
- // [_tableView reloadData];
-
- }
- #pragma mark -- 我发起的
- -(void)myLoadChangeData
- {
-
- _select = 3;
- _selectBtn1.hidden = YES;
- _selectBtn2.hidden = YES;
- _selectBtn3.hidden = NO;
- _title1.textColor = Color(255, 255, 255, 1);
- _title2.textColor = Color(255, 255, 255, 1);
- _title3.textColor = Color(87, 87, 87, 1);
- [_iFlySpeechRecognizer cancel];
- [self getTaskDataFromServerWithCondition1:@""];
- // [_tableView reloadData];
-
- }
- #pragma mark -- 上下拉刷新
- //下拉刷新相关函数
- - (void)setupHeader
- {
- __weak typeof(B2BMyHandleWorkVC) *weakSelf = self;
- _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- __strong typeof(B2BMyHandleWorkVC) *strongSelf = weakSelf;
- strongSelf->_weiShenpi.enabled = NO;
- strongSelf->_yiShenpi.enabled = NO;
- strongSelf->_woFaqide.enabled = NO;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- strongSelf->_select==3?[weakSelf getTaskDataFromServerWithCondition1:@""]:[weakSelf getTaskDataFromServerWithCondition:@""];
- [_tableView.mj_header endRefreshing];
- });
- }];
-
-
-
-
- // 进入页面自动加载一次数据
- //[refreshHeader beginRefreshing];
- }
- //上啦刷新
- - (void)setupFooter
- {
-
- _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [_tableView.mj_footer endRefreshing];
-
- });
-
-
-
- }];
-
- }
- #pragma mark 下面是语音识别的回调函数
- - (void) onError:(IFlySpeechError *) error
- {
- if (error.errorCode == 20001) {
- [KPromptBox showKPromptBoxWithMassage:@"请检查网络连接"];
- }else if(error.errorCode == 20006){
- [KPromptBox showKPromptBoxWithMassage:@"请检查麦克风权限是否开启"];
- }
- [self.MyView removeFromSuperview];
-
- }
- - (void) onVolumeChanged: (int)volume{
-
- int ff = volume;
- if (ff>=0&&ff<3) {
- [self.imageV setImage:GetImage(@"uu_voice_search1")];
- } else if (ff>=3 && ff<6) {
- [self.imageV setImage:GetImage(@"uu_voice_search2")];
- } else if (ff >=6 &&ff<9) {
- [self.imageV setImage:GetImage(@"uu_voice_search3")];
- } else if (ff >=9 &&ff<12) {
- [self.imageV setImage:GetImage(@"uu_voice_search4")];
- } else if (ff >=12 &&ff<15) {
- [self.imageV setImage:GetImage(@"uu_voice_search5")];
- } else if (ff >= 15 && ff < 18) {
- [self.imageV setImage:GetImage(@"uu_voice_search6")];
- } else if (ff >= 18 && ff < 21) {
- [self.imageV setImage:GetImage(@"uu_voice_search7")];
- } else if(ff>=21){
- [self.imageV setImage:GetImage(@"uu_voice_search8")];
- }
- }
- //听写结果回调
- // resultArray:听写结果
- // isLast:表示最后一次
- - (void) onResults:(NSArray *) results isLast:(BOOL)isLast{
-
-
- NSMutableString *result = [[NSMutableString alloc] init];
- NSDictionary *dic = [results objectAtIndex:0];
-
- for (NSString *key in dic) {
- [result appendFormat:@"%@",key];
- }
-
- NSString * resultFromJson = [ISRDataHelper stringFromJson:result];
-
- NSString * searchText = [NSString stringWithFormat:@"%@",resultFromJson];
- _searchBar.text = searchText;
- if (![_searchBar.text isEqualToString:@""]) {
- _uv.hidden = YES;
- }
- [self getTheResultFrom:searchText];
- [_iFlySpeechRecognizer cancel];
- }
- -(void)getTheResultFrom:(NSString *)searchText{
- [_testArr removeAllObjects];
- for (int i=0;i<_AllDataHandleBrr.count;i++)
- {
- searchText = [searchText stringByReplacingOccurrencesOfString:@" " withString:@""];
- /**
- options:匹配类型(比如是否区分大小写)
- */
- NSRange range = [_searchArr[i] rangeOfString:searchText options:NSCaseInsensitiveSearch];
-
- if (range.location != NSNotFound)
- {
- [_testArr addObject:_AllDataHandleBrr[i]];
- }
- }
- DLog(@"aaaaaa:%@",_testArr);
- if ([searchText isEqualToString:@""]) {
- self.uv.hidden = NO;
- _noData.hidden = YES;
- _AllDataHandleArr = _AllDataHandleBrr;
-
- }else
- {
- _AllDataHandleArr = _testArr;
- if (_testArr.count==0) {
- _noData.hidden = NO;
- }
- else{
- _noData.hidden = YES;
- }
-
- }
- [_tableView reloadData];
-
- }
- #pragma mark -- UISearchBarDelegate
- -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
- {
- [self getTheResultFrom:searchText];
-
- }
- -(BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
-
- self.uv.hidden = YES;
- return YES;
- }
- -(void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
- {
- DLog(@"didEndEditing");
- }
- -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
- {
- DLog(@"searchButtonClicked");
- [_searchBar resignFirstResponder];
- }
- -(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
- {
- [_searchBar resignFirstResponder];
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- [_searchBar resignFirstResponder];
- }
- -(void)backAction
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
-
- [self initRecognizer1];
- _select == 3?[self getTaskDataFromServerWithCondition1:@""]:[self getTaskDataFromServerWithCondition:@""];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenTabBar"object:nil];
- }
- /*
- 显示完整分割线
- */
- -(void)viewDidLayoutSubviews {
-
- if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
- [_tableView setSeparatorInset:UIEdgeInsetsZero];
- }
- if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
- [_tableView setLayoutMargins:UIEdgeInsetsZero];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- //将数组中的每一个模型按时间字段降序排列
- -(void)OrderByTimeDesc:(NSMutableArray * )MutArr{
- NSMutableArray *pi = [[NSMutableArray alloc]init];
- pi = MutArr;
- for(int i=0;i<[pi count];i++){
- for (int j = 0; j < [pi count] - i - 1; j++) {
- B2BHandleTaskModle * modle = pi[j];
- B2BHandleTaskModle * modle1 = pi[j+1];
- NSString *str1 = modle.recorddate;
- NSString *str2 = modle1.recorddate;
- if([str2 integerValue]>[str1 integerValue]){ //同上potions NSNumericSearch = 64,
- [pi exchangeObjectAtIndex:j+1 withObjectAtIndex:j]; //这里可以用exchangeObjectAtIndex:方法来交换两个位置的数组元素。
- }
-
- }
- }
- _AllDataHandleArr = pi;
-
- }
- -(void)viewWillDisappear:(BOOL)animated{
- [_iFlySpeechRecognizer cancel];
- [self.MyView removeFromSuperview];
- }
- -(void)dealloc{
-
-
- }
- @end
|