B2BMyHandleWorkVC.m 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. //
  2. // B2BMyHandleWorkVC.m
  3. // shiku_im
  4. //
  5. // Created by 周西 on 17/3/29.
  6. // Copyright © 2017年 UAS. All rights reserved.
  7. //
  8. #import "B2BMyHandleWorkVC.h"
  9. #import "ApprovalCell.h"
  10. #import "AFNetworking.h"
  11. #import "ApprovalWebView.h"
  12. #import "WYWebController.h"
  13. #import "iflyMSC/IFlyMSC.h"
  14. #import "IATConfig.h"
  15. #import "ISRDataHelper.h"
  16. #import "B2BApprovalDetailVC.h"
  17. #import "B2BNewTaskVC.h"
  18. #import "B2BHandleTaskModle.h"
  19. #import "B2BHandleTaskCell.h"
  20. #import "MJExtension.h"
  21. #import "B2BReplyTaskVC.h"
  22. static NSString *cellID = @"cellID";
  23. @interface B2BMyHandleWorkVC ()<UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,IFlySpeechRecognizerDelegate>
  24. @property (nonatomic,strong)UITableView *tableView;
  25. @property (nonatomic,strong) UISearchBar *searchBar;
  26. @property (nonatomic,strong) UIView * uv;
  27. @property(nonatomic,strong) IFlySpeechRecognizer * iFlySpeechRecognizer;//带视图的语音识别器
  28. @property(nonatomic,strong)UIImageView * imageV;
  29. @property(nonatomic,strong)UIView * MyView;
  30. @end
  31. @implementation B2BMyHandleWorkVC
  32. {
  33. UIButton *_weiShenpi; //未审批按钮
  34. UIButton *_yiShenpi; //已审批按钮
  35. UIButton *_woFaqide; //我发起的按钮
  36. UIImageView *_selectBtn1; //选择了按钮1的背景
  37. UIImageView *_selectBtn2; //选择了按钮2的背景
  38. UIImageView *_selectBtn3; //选择了按钮3的背景
  39. UILabel *_title1; //未审批
  40. UILabel *_title2; //已审批
  41. UILabel *_title3; //我发起的
  42. int _select; //选中哪个
  43. int _increaseNum; //刷新加多少条
  44. NSMutableArray *_searchArr;
  45. NSMutableArray *_testArr; //转换的数组
  46. UIImageView *_noData; //无数据的图片
  47. MBProgressHUD * HUD;
  48. /*********************************/
  49. NSMutableArray * _AllDataHandleArr;//主数组
  50. NSMutableArray * _AllDataHandleBrr;//备份数组
  51. }
  52. - (void)viewDidLoad {
  53. [super viewDidLoad];
  54. self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
  55. self.view.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
  56. _searchArr = [[NSMutableArray alloc]init];
  57. _testArr = [[NSMutableArray alloc]init];
  58. _AllDataHandleArr = [[NSMutableArray alloc]init];
  59. _AllDataHandleBrr = [[NSMutableArray alloc]init];
  60. _select = 1;
  61. //获取网络数据(默认选中未处理)
  62. [self getTaskDataFromServerWithCondition:@""];
  63. //设置导航栏三个按钮
  64. [self setNavigationTitle];
  65. //设置tableView
  66. [self setTableView];
  67. //下拉刷新
  68. [self setupHeader];
  69. }
  70. -(void)getTaskDataFromServerWithCondition1:(NSString *)conditionStr
  71. {
  72. SLog(@"获取的人员是:%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]);
  73. _searchBar.text = @"";
  74. self.uv.hidden = NO;
  75. [_searchBar resignFirstResponder];
  76. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  77. NSString *ip = [UASUserInfo shareManager].urlIp;
  78. NSString *url = [NSString stringWithFormat:@"%@mobile/mobiletask/myTasks?emuu=%@&enuu=%@&pageNumber=%@&pageSize=%d&status=%@&sessionId=%@",ip,g_emcode,g_B2B_enuu,@"1",1000,conditionStr,sessionId];
  79. DLog(@"我的任务列表:%@",url);
  80. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  81. UASNetworkManager *manager = [UASNetworkManager shareManager];
  82. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  83. //拼接sessionID
  84. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  85. //设置cookie
  86. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  87. [manager request:url method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  88. [MBProgressHUD hideHUD];
  89. _weiShenpi.enabled = YES;
  90. _yiShenpi.enabled = YES;
  91. _woFaqide.enabled = YES;
  92. [_AllDataHandleArr removeAllObjects];
  93. [_AllDataHandleBrr removeAllObjects];
  94. [_searchArr removeAllObjects];
  95. NSMutableArray * allDataArr = [[NSMutableArray alloc]init];
  96. // SLog(@"我的任务列表数据1:%@",responseObject);
  97. for (id obj in responseObject[@"listdata"]) {
  98. [allDataArr addObject:obj];
  99. }
  100. allDataArr = [NSDictionary changeType:allDataArr];
  101. for (int i= 0; i<allDataArr.count; i++) {
  102. B2BHandleTaskModle * modle = [B2BHandleTaskModle mj_objectWithKeyValues:allDataArr[i]];
  103. modle = [NSDictionary changeType:modle];
  104. [_AllDataHandleArr addObject:modle];
  105. }
  106. //过滤重复数据
  107. NSSet * set1 = [NSSet setWithArray:_AllDataHandleArr];
  108. [_AllDataHandleArr removeAllObjects];
  109. _AllDataHandleArr = [[set1 allObjects] mutableCopy];
  110. //数组里面的时间元素按降序排列
  111. [self OrderByTimeDesc:_AllDataHandleArr];
  112. _AllDataHandleBrr = [[NSMutableArray alloc]initWithArray:_AllDataHandleArr];
  113. B2BHandleTaskModle * model;
  114. for (int i = 0; i<_AllDataHandleArr.count; i++) {
  115. model = _AllDataHandleArr[i];
  116. [_searchArr addObject:[NSString stringWithFormat:@"%@%@",model.recorder,model.taskname]];
  117. }
  118. [_tableView reloadData];
  119. if ([_AllDataHandleArr count] == 0) {
  120. _noData.hidden = NO;
  121. }else
  122. {
  123. _noData.hidden = YES;
  124. }
  125. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  126. [MBProgressHUD hideHUD];
  127. _weiShenpi.enabled = YES;
  128. _yiShenpi.enabled = YES;
  129. _woFaqide.enabled = YES;
  130. DLog(@"请求失败:%@",error);
  131. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  132. if (returnData) {
  133. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  134. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  135. DLog(@"错误的原因:%@",errorStr);
  136. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  137. }
  138. else{
  139. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  140. }
  141. }];
  142. }
  143. #pragma mark --- 网络请求
  144. -(void)getTaskDataFromServerWithCondition:(NSString *)conditionStr
  145. {
  146. SLog(@"获取的人员是:%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]);
  147. _searchBar.text = @"";
  148. self.uv.hidden = NO;
  149. [_searchBar resignFirstResponder];
  150. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  151. NSString *ip = [UASUserInfo shareManager].urlIp;
  152. NSString *url = [NSString stringWithFormat:@"%@mobile/mobiletask/getAllTasks?emuu=%@&enuu=%@&pageNumber=%@&pageSize=%d&status=%@&sessionId=%@",ip,g_emcode,g_B2B_enuu,@"1",1000,conditionStr,sessionId];
  153. DLog(@"我的任务列表:%@",url);
  154. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  155. UASNetworkManager *manager = [UASNetworkManager shareManager];
  156. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  157. //拼接sessionID
  158. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  159. //设置cookie
  160. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  161. [manager request:url method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  162. [MBProgressHUD hideHUD];
  163. _weiShenpi.enabled = YES;
  164. _yiShenpi.enabled = YES;
  165. _woFaqide.enabled = YES;
  166. [_AllDataHandleArr removeAllObjects];
  167. [_AllDataHandleBrr removeAllObjects];
  168. [_searchArr removeAllObjects];
  169. NSMutableArray * allDataArr = [[NSMutableArray alloc]init];
  170. // SLog(@"我的任务列表数据:%@",responseObject);
  171. for (id obj in responseObject[@"listdata"]) {
  172. [allDataArr addObject:obj];
  173. }
  174. allDataArr = [NSDictionary changeType:allDataArr];
  175. NSMutableArray * arry1 =[[NSMutableArray alloc]init];
  176. NSMutableArray * arry2 =[[NSMutableArray alloc]init];
  177. // NSMutableArray * arry3 =[[NSMutableArray alloc]init];
  178. for (int i= 0; i<allDataArr.count; i++) {
  179. B2BHandleTaskModle * modle = [B2BHandleTaskModle mj_objectWithKeyValues:allDataArr[i]];
  180. modle = [NSDictionary changeType:modle];
  181. if ([modle.status isEqualToString:@"进行中"]) {
  182. [arry1 addObject:modle];
  183. }
  184. if ([modle.recordercode isEqualToString:g_emcode]&&[modle.status isEqualToString:@"待确认"]) {
  185. [arry1 addObject:modle];
  186. }
  187. if ([modle.status isEqualToString:@"已完成"]) {
  188. [arry2 addObject:modle];
  189. }
  190. if (![modle.recordercode isEqualToString:g_emcode]&&[modle.status isEqualToString:@"待确认"]) {
  191. [arry2 addObject:modle];
  192. }
  193. // if ([modle.recorder isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]]&&[modle.status isEqualToString:@"进行中"]) {
  194. // [arry3 addObject:modle];
  195. // }
  196. // if ([modle.recorder isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"personName"]]&&[modle.status isEqualToString:@"已完成"]) {
  197. // [arry3 addObject:modle];
  198. // }
  199. }
  200. if (_select == 1) {
  201. _AllDataHandleArr = [arry1 mutableCopy];
  202. }
  203. else if(_select == 2){
  204. _AllDataHandleArr = [arry2 mutableCopy];
  205. }
  206. // else{
  207. // _AllDataHandleArr = [arry3 mutableCopy];
  208. // }
  209. //过滤重复数据
  210. NSSet * set1 = [NSSet setWithArray:_AllDataHandleArr];
  211. [_AllDataHandleArr removeAllObjects];
  212. _AllDataHandleArr = [[set1 allObjects] mutableCopy];
  213. //数组里面的时间元素按降序排列
  214. [self OrderByTimeDesc:_AllDataHandleArr];
  215. _AllDataHandleBrr = [[NSMutableArray alloc]initWithArray:_AllDataHandleArr];
  216. B2BHandleTaskModle * model;
  217. for (int i = 0; i<_AllDataHandleArr.count; i++) {
  218. model = _AllDataHandleArr[i];
  219. [_searchArr addObject:[NSString stringWithFormat:@"%@%@",model.recorder,model.taskname]];
  220. }
  221. [_tableView reloadData];
  222. if ([_AllDataHandleArr count] == 0) {
  223. _noData.hidden = NO;
  224. }else
  225. {
  226. _noData.hidden = YES;
  227. }
  228. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  229. [MBProgressHUD hideHUD];
  230. _weiShenpi.enabled = YES;
  231. _yiShenpi.enabled = YES;
  232. _woFaqide.enabled = YES;
  233. DLog(@"请求失败:%@",error);
  234. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  235. if (returnData) {
  236. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  237. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  238. DLog(@"错误的原因:%@",errorStr);
  239. [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
  240. }
  241. else{
  242. [JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
  243. }
  244. }];
  245. }
  246. -(void)initRecognizer1
  247. {
  248. DLog(@"%s",__func__);
  249. //单例模式,无UI的实例
  250. if (_iFlySpeechRecognizer == nil) {
  251. _iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
  252. [_iFlySpeechRecognizer setParameter:@"" forKey:[IFlySpeechConstant PARAMS]];
  253. //设置听写模式
  254. [_iFlySpeechRecognizer setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]];
  255. }
  256. _iFlySpeechRecognizer.delegate = self;
  257. if (_iFlySpeechRecognizer != nil) {
  258. IATConfig *instance = [IATConfig sharedInstance];
  259. //设置最长录音时间
  260. [_iFlySpeechRecognizer setParameter:instance.speechTimeout forKey:[IFlySpeechConstant SPEECH_TIMEOUT]];
  261. //设置后端点
  262. [_iFlySpeechRecognizer setParameter:instance.vadEos forKey:[IFlySpeechConstant VAD_EOS]];
  263. //设置前端点
  264. [_iFlySpeechRecognizer setParameter:instance.vadBos forKey:[IFlySpeechConstant VAD_BOS]];
  265. //网络等待时间
  266. [_iFlySpeechRecognizer setParameter:@"20000" forKey:[IFlySpeechConstant NET_TIMEOUT]];
  267. //设置采样率,推荐使用16K
  268. [_iFlySpeechRecognizer setParameter:instance.sampleRate forKey:[IFlySpeechConstant SAMPLE_RATE]];
  269. if ([instance.language isEqualToString:[IATConfig chinese]]) {
  270. //设置语言
  271. [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
  272. //设置方言
  273. [_iFlySpeechRecognizer setParameter:instance.accent forKey:[IFlySpeechConstant ACCENT]];
  274. }else if ([instance.language isEqualToString:[IATConfig english]]) {
  275. [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
  276. }
  277. //设置是否返回标点符号
  278. [_iFlySpeechRecognizer setParameter:instance.dot forKey:[IFlySpeechConstant ASR_PTT]];
  279. }
  280. }
  281. -(void)setTableView
  282. {
  283. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  284. _tableView.delegate = self;
  285. _tableView.dataSource = self;
  286. _tableView.rowHeight = 50;
  287. [self.view addSubview: _tableView];
  288. _tableView.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
  289. [_tableView registerClass:[ApprovalCell class] forCellReuseIdentifier:cellID];
  290. UIView *v = [[UIView alloc] initWithFrame:CGRectZero];
  291. v.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
  292. _tableView.tableFooterView = v;
  293. _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
  294. _searchBar.placeholder = Localized(@"UU_custom_search");
  295. _searchBar.barTintColor = Color(235, 233, 233, 1);
  296. _searchBar.delegate = self;
  297. UIView * uv = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-48, 7.5, 40, 30)];
  298. uv.userInteractionEnabled = YES;
  299. self.uv = uv;
  300. // uv.backgroundColor = [UIColor redColor];
  301. UITapGestureRecognizer * tapges =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickVoiceSearch)];
  302. UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(17,7 , 16,16 )];
  303. // [btn setBackgroundImage:[UIImage imageNamed:@"icon-searcher-custom"] forState:UIControlStateNormal];
  304. [btn setImage:[UIImage imageNamed:@"icon-searcher-custom"] forState:UIControlStateNormal];
  305. // [btn setBackgroundColor:[UIColor greenColor]];
  306. [btn addTarget:self action:@selector(clickVoiceSearch) forControlEvents:UIControlEventTouchUpInside];
  307. [uv addSubview:btn];
  308. [uv addGestureRecognizer:tapges];
  309. [_searchBar addSubview:uv];
  310. //添加 searchBar 到 headerView
  311. UIView *tableHeaderView = [[UIView alloc] init];
  312. [tableHeaderView addSubview:_searchBar];
  313. tableHeaderView.height = 44;
  314. [_tableView setTableHeaderView:tableHeaderView];
  315. HUD = [[MBProgressHUD alloc]initWithView:self.view];
  316. HUD.dimBackground = YES;
  317. HUD.mode = MBProgressHUDModeIndeterminate;
  318. // [HUD show:YES];
  319. [self.view addSubview:HUD];
  320. _noData = [[UIImageView alloc]init];
  321. _noData.image = [UIImage imageNamed:@"crm_all_noData"];
  322. _noData.hidden = YES;
  323. [self.view addSubview:_noData];
  324. [_noData mas_makeConstraints:^(MASConstraintMaker *make) {
  325. make.width.mas_equalTo(100);
  326. make.height.mas_equalTo(126);
  327. make.center.equalTo(self.view);
  328. }];
  329. }
  330. -(void)setNavigationTitle
  331. {
  332. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 180, 22)];
  333. UIImageView *titleBG = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 180, 22)];
  334. titleBG.image = [UIImage imageNamed:@"uu_shenpiTitleBG"];
  335. [view addSubview:titleBG];
  336. titleBG.userInteractionEnabled = YES;
  337. _selectBtn1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  338. _selectBtn1.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
  339. _selectBtn2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  340. _selectBtn2.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
  341. _selectBtn3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  342. _selectBtn3.image = [UIImage imageNamed:@"uu_shenpiTitle_select"];
  343. _weiShenpi = [UIButton buttonWithType:UIButtonTypeCustom];
  344. _weiShenpi.frame = CGRectMake(0, 0, 60, 22);
  345. [_weiShenpi addSubview:_selectBtn1];
  346. [_weiShenpi addTarget:self action:@selector(noApprovalprocessChangeData) forControlEvents:UIControlEventTouchUpInside];
  347. _yiShenpi = [UIButton buttonWithType:UIButtonTypeCustom];
  348. _yiShenpi.frame = CGRectMake(60, 0, 60, 22);
  349. [_yiShenpi addSubview:_selectBtn2];
  350. _selectBtn2.hidden = YES;
  351. [_yiShenpi addTarget:self action:@selector(haveApprovalprocessChangeData) forControlEvents:UIControlEventTouchUpInside];
  352. _woFaqide = [UIButton buttonWithType:UIButtonTypeCustom];
  353. _woFaqide.frame = CGRectMake(120, 0, 60, 22);
  354. [_woFaqide addSubview:_selectBtn3];
  355. _selectBtn3.hidden = YES;
  356. [_woFaqide addTarget:self action:@selector(myLoadChangeData) forControlEvents:UIControlEventTouchUpInside];
  357. [titleBG addSubview:_weiShenpi];
  358. [titleBG addSubview:_yiShenpi];
  359. [titleBG addSubview:_woFaqide];
  360. _title1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  361. _title1.font = FONT_SIZE(13);
  362. _title1.textColor = Color(87, 87, 87, 1);
  363. _title1.text = @"待处理";
  364. _title1.textAlignment = NSTextAlignmentCenter;
  365. [_weiShenpi addSubview:_title1];
  366. _title2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  367. _title2.font = FONT_SIZE(13);
  368. _title2.textColor = Color(255, 255, 255, 1);
  369. _title2.text = @"已处理";
  370. _title2.textAlignment = NSTextAlignmentCenter;
  371. [_yiShenpi addSubview:_title2];
  372. _title3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 22)];
  373. _title3.font = FONT_SIZE(13);
  374. _title3.textColor = Color(255, 255, 255, 1);
  375. _title3.text = @"我发起的";
  376. _title3.textAlignment = NSTextAlignmentCenter;
  377. [_woFaqide addSubview:_title3];
  378. self.navigationItem.titleView = view;
  379. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  380. btn2.frame = CGRectMake(0, 5, 22, 22);
  381. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  382. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  383. [btn2 addSubview:image];
  384. [btn2 addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  385. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  386. self.navigationItem.leftBarButtonItems = @[bbi2];
  387. UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeSystem];
  388. btn3.frame = CGRectMake(0, 5, 20, 20);
  389. UIImageView *image1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5, 20, 20)];
  390. image1.image = [UIImage imageNamed:@"crm_main_add"];
  391. [btn3 addSubview:image1];
  392. [btn3 addTarget:self action:@selector(clickRightButton) forControlEvents:UIControlEventTouchUpInside];
  393. UIBarButtonItem *bbi3 = [[UIBarButtonItem alloc]initWithCustomView:btn3];
  394. self.navigationItem.rightBarButtonItem = bbi3;
  395. }
  396. -(void)clickRightButton{
  397. B2BNewTaskVC * bvc = [[B2BNewTaskVC alloc]init];
  398. bvc.block1 = ^(){
  399. DLog(@"有走这个方法么");
  400. _select==3?[self getTaskDataFromServerWithCondition1:@""]:[self getTaskDataFromServerWithCondition:@""];
  401. };
  402. [self.navigationController pushViewController:bvc animated:YES];
  403. }
  404. -(void)clickVoiceSearch{
  405. DLog(@"什么被点击了呢");
  406. [_searchBar resignFirstResponder];
  407. UIView * MyView =[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
  408. MyView.backgroundColor =[UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
  409. self.MyView = MyView;
  410. [self.view addSubview:MyView];
  411. UIImageView * imageV =[[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-60)/2, 200, 60, 60)];
  412. imageV.image = [UIImage imageNamed:@"uu_voice_search1"];
  413. imageV.userInteractionEnabled = YES;
  414. imageV.tag = 100;
  415. self.imageV = imageV;
  416. [MyView addSubview:imageV];
  417. [_iFlySpeechRecognizer startListening];
  418. }
  419. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  420. [super touchesBegan:touches withEvent:event];
  421. [self.MyView removeFromSuperview];
  422. [_iFlySpeechRecognizer cancel];
  423. }
  424. #pragma mark -- UITableView Delegate / DataSoure
  425. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  426. {
  427. return _AllDataHandleArr.count;
  428. }
  429. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  430. {
  431. B2BHandleTaskCell *cell = [B2BHandleTaskCell cellWithTableView:tableView];
  432. cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:249/255.0 blue:249/255.0 alpha:1.0];
  433. // cell.selectionStyle = UITableViewCellAccessoryNone;
  434. B2BHandleTaskModle * modle = _AllDataHandleArr[indexPath.row];
  435. cell.modle = modle;
  436. //我发起的过滤我的人名
  437. if (_select == 3) {
  438. cell.nameLbl.text =[NSString stringWithFormat:@"%@",modle.taskname];
  439. }
  440. return cell;
  441. }
  442. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  443. {
  444. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  445. NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
  446. [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
  447. B2BHandleTaskModle * modle = _AllDataHandleArr[indexPath.row];
  448. B2BReplyTaskVC *replyVC = [[B2BReplyTaskVC alloc]init];
  449. replyVC.launchPerson = modle.recorder;
  450. replyVC.acceptPerson = modle.doman;
  451. replyVC.taskName = modle.taskname;
  452. replyVC.status =modle.status;
  453. replyVC.startDate = [NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[NSString stringWithFormat:@"%@",modle.startdate] longLongValue]/1000]]]];
  454. replyVC.endDate = [NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[NSString stringWithFormat:@"%@",modle.enddate] longLongValue]/1000]]]];
  455. replyVC.describ = modle.detail;
  456. // replyVC.taskcode = modle.;
  457. replyVC.ra_id = modle.id;
  458. replyVC.taskid = modle.id;
  459. replyVC.recorderCode = modle.recordercode;
  460. replyVC.domanCode = modle.domancode;
  461. NSString *state = modle.statuscode;
  462. if ([state isEqualToString:@"start"]) {
  463. replyVC.type = HandleTaskTypeForStart;
  464. }else if([state isEqualToString:@"uncomfirmed"])
  465. {
  466. replyVC.type = HandleTaskTypeForWaitVerify;
  467. }else
  468. {
  469. replyVC.type = HandleTaskTypeForFinish;
  470. }
  471. [self.navigationController pushViewController:replyVC animated:YES];
  472. }
  473. #pragma mark -- 未处理
  474. -(void)noApprovalprocessChangeData
  475. {
  476. _select = 1;
  477. _selectBtn1.hidden = NO;
  478. _selectBtn2.hidden = YES;
  479. _selectBtn3.hidden = YES;
  480. _title1.textColor = Color(87, 87, 87, 1);
  481. _title2.textColor = Color(255, 255, 255, 1);
  482. _title3.textColor = Color(255, 255, 255, 1);
  483. [_iFlySpeechRecognizer cancel];
  484. [self getTaskDataFromServerWithCondition:@""];
  485. // [_tableView reloadData];
  486. }
  487. #pragma mark -- 已处理
  488. -(void)haveApprovalprocessChangeData
  489. {
  490. _select = 2;
  491. _selectBtn1.hidden = YES;
  492. _selectBtn2.hidden = NO;
  493. _selectBtn3.hidden = YES;
  494. _title1.textColor = Color(255, 255, 255, 1);
  495. _title2.textColor = Color(87, 87, 87, 1);
  496. _title3.textColor = Color(255, 255, 255, 1);
  497. [_iFlySpeechRecognizer cancel];
  498. [self getTaskDataFromServerWithCondition:@""];
  499. // [_tableView reloadData];
  500. }
  501. #pragma mark -- 我发起的
  502. -(void)myLoadChangeData
  503. {
  504. _select = 3;
  505. _selectBtn1.hidden = YES;
  506. _selectBtn2.hidden = YES;
  507. _selectBtn3.hidden = NO;
  508. _title1.textColor = Color(255, 255, 255, 1);
  509. _title2.textColor = Color(255, 255, 255, 1);
  510. _title3.textColor = Color(87, 87, 87, 1);
  511. [_iFlySpeechRecognizer cancel];
  512. [self getTaskDataFromServerWithCondition1:@""];
  513. // [_tableView reloadData];
  514. }
  515. #pragma mark -- 上下拉刷新
  516. //下拉刷新相关函数
  517. - (void)setupHeader
  518. {
  519. __weak typeof(B2BMyHandleWorkVC) *weakSelf = self;
  520. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  521. __strong typeof(B2BMyHandleWorkVC) *strongSelf = weakSelf;
  522. strongSelf->_weiShenpi.enabled = NO;
  523. strongSelf->_yiShenpi.enabled = NO;
  524. strongSelf->_woFaqide.enabled = NO;
  525. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  526. strongSelf->_select==3?[weakSelf getTaskDataFromServerWithCondition1:@""]:[weakSelf getTaskDataFromServerWithCondition:@""];
  527. [_tableView.mj_header endRefreshing];
  528. });
  529. }];
  530. // 进入页面自动加载一次数据
  531. //[refreshHeader beginRefreshing];
  532. }
  533. //上啦刷新
  534. - (void)setupFooter
  535. {
  536. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  537. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  538. [_tableView.mj_footer endRefreshing];
  539. });
  540. }];
  541. }
  542. #pragma mark 下面是语音识别的回调函数
  543. - (void) onError:(IFlySpeechError *) error
  544. {
  545. if (error.errorCode == 20001) {
  546. [KPromptBox showKPromptBoxWithMassage:@"请检查网络连接"];
  547. }else if(error.errorCode == 20006){
  548. [KPromptBox showKPromptBoxWithMassage:@"请检查麦克风权限是否开启"];
  549. }
  550. [self.MyView removeFromSuperview];
  551. }
  552. - (void) onVolumeChanged: (int)volume{
  553. int ff = volume;
  554. if (ff>=0&&ff<3) {
  555. [self.imageV setImage:GetImage(@"uu_voice_search1")];
  556. } else if (ff>=3 && ff<6) {
  557. [self.imageV setImage:GetImage(@"uu_voice_search2")];
  558. } else if (ff >=6 &&ff<9) {
  559. [self.imageV setImage:GetImage(@"uu_voice_search3")];
  560. } else if (ff >=9 &&ff<12) {
  561. [self.imageV setImage:GetImage(@"uu_voice_search4")];
  562. } else if (ff >=12 &&ff<15) {
  563. [self.imageV setImage:GetImage(@"uu_voice_search5")];
  564. } else if (ff >= 15 && ff < 18) {
  565. [self.imageV setImage:GetImage(@"uu_voice_search6")];
  566. } else if (ff >= 18 && ff < 21) {
  567. [self.imageV setImage:GetImage(@"uu_voice_search7")];
  568. } else if(ff>=21){
  569. [self.imageV setImage:GetImage(@"uu_voice_search8")];
  570. }
  571. }
  572. //听写结果回调
  573. // resultArray:听写结果
  574. // isLast:表示最后一次
  575. - (void) onResults:(NSArray *) results isLast:(BOOL)isLast{
  576. NSMutableString *result = [[NSMutableString alloc] init];
  577. NSDictionary *dic = [results objectAtIndex:0];
  578. for (NSString *key in dic) {
  579. [result appendFormat:@"%@",key];
  580. }
  581. NSString * resultFromJson = [ISRDataHelper stringFromJson:result];
  582. NSString * searchText = [NSString stringWithFormat:@"%@",resultFromJson];
  583. _searchBar.text = searchText;
  584. if (![_searchBar.text isEqualToString:@""]) {
  585. _uv.hidden = YES;
  586. }
  587. [self getTheResultFrom:searchText];
  588. [_iFlySpeechRecognizer cancel];
  589. }
  590. -(void)getTheResultFrom:(NSString *)searchText{
  591. [_testArr removeAllObjects];
  592. for (int i=0;i<_AllDataHandleBrr.count;i++)
  593. {
  594. searchText = [searchText stringByReplacingOccurrencesOfString:@" " withString:@""];
  595. /**
  596. options:匹配类型(比如是否区分大小写)
  597. */
  598. NSRange range = [_searchArr[i] rangeOfString:searchText options:NSCaseInsensitiveSearch];
  599. if (range.location != NSNotFound)
  600. {
  601. [_testArr addObject:_AllDataHandleBrr[i]];
  602. }
  603. }
  604. DLog(@"aaaaaa:%@",_testArr);
  605. if ([searchText isEqualToString:@""]) {
  606. self.uv.hidden = NO;
  607. _noData.hidden = YES;
  608. _AllDataHandleArr = _AllDataHandleBrr;
  609. }else
  610. {
  611. _AllDataHandleArr = _testArr;
  612. if (_testArr.count==0) {
  613. _noData.hidden = NO;
  614. }
  615. else{
  616. _noData.hidden = YES;
  617. }
  618. }
  619. [_tableView reloadData];
  620. }
  621. #pragma mark -- UISearchBarDelegate
  622. -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  623. {
  624. [self getTheResultFrom:searchText];
  625. }
  626. -(BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
  627. self.uv.hidden = YES;
  628. return YES;
  629. }
  630. -(void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
  631. {
  632. DLog(@"didEndEditing");
  633. }
  634. -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  635. {
  636. DLog(@"searchButtonClicked");
  637. [_searchBar resignFirstResponder];
  638. }
  639. -(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
  640. {
  641. [_searchBar resignFirstResponder];
  642. }
  643. -(void)scrollViewDidScroll:(UIScrollView *)scrollView
  644. {
  645. [self.view endEditing:YES];
  646. [_searchBar resignFirstResponder];
  647. }
  648. -(void)backAction
  649. {
  650. [self.navigationController popViewControllerAnimated:YES];
  651. }
  652. -(void)viewWillAppear:(BOOL)animated
  653. {
  654. [self initRecognizer1];
  655. _select == 3?[self getTaskDataFromServerWithCondition1:@""]:[self getTaskDataFromServerWithCondition:@""];
  656. [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenTabBar"object:nil];
  657. }
  658. /*
  659. 显示完整分割线
  660. */
  661. -(void)viewDidLayoutSubviews {
  662. if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
  663. [_tableView setSeparatorInset:UIEdgeInsetsZero];
  664. }
  665. if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
  666. [_tableView setLayoutMargins:UIEdgeInsetsZero];
  667. }
  668. }
  669. - (void)didReceiveMemoryWarning {
  670. [super didReceiveMemoryWarning];
  671. // Dispose of any resources that can be recreated.
  672. }
  673. //将数组中的每一个模型按时间字段降序排列
  674. -(void)OrderByTimeDesc:(NSMutableArray * )MutArr{
  675. NSMutableArray *pi = [[NSMutableArray alloc]init];
  676. pi = MutArr;
  677. for(int i=0;i<[pi count];i++){
  678. for (int j = 0; j < [pi count] - i - 1; j++) {
  679. B2BHandleTaskModle * modle = pi[j];
  680. B2BHandleTaskModle * modle1 = pi[j+1];
  681. NSString *str1 = modle.recorddate;
  682. NSString *str2 = modle1.recorddate;
  683. if([str2 integerValue]>[str1 integerValue]){ //同上potions NSNumericSearch = 64,
  684. [pi exchangeObjectAtIndex:j+1 withObjectAtIndex:j]; //这里可以用exchangeObjectAtIndex:方法来交换两个位置的数组元素。
  685. }
  686. }
  687. }
  688. _AllDataHandleArr = pi;
  689. }
  690. -(void)viewWillDisappear:(BOOL)animated{
  691. [_iFlySpeechRecognizer cancel];
  692. [self.MyView removeFromSuperview];
  693. }
  694. -(void)dealloc{
  695. }
  696. @end