PendingDocumentsViewController.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. //
  2. // PendingDocumentsViewController.m
  3. // Granite Expo eSign
  4. //
  5. // Created by Ray on 11/04/2017.
  6. // Copyright © 2017 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "PendingDocumentsViewController.h"
  9. #import "RANetwork.h"
  10. #import "PendingDocumentsTableViewCell.h"
  11. #import "RAUtils.h"
  12. #import "GEContractFilterViewController.h"
  13. #import "RAPDFViewController.h"
  14. #import "AppDelegate.h"
  15. #import "ExtDocumentsViewController.h"
  16. #import "DocnotesViewController.h"
  17. #import "DocumentPageViewController.h"
  18. #import "AddExtDocumentViewController.h"
  19. @interface PendingDocumentsViewController ()
  20. @end
  21. @implementation PendingDocumentsViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.offset = 0;
  25. self.limit = 20;
  26. self.table_data = [[NSMutableArray alloc] init];
  27. self.filterparams = [[NSMutableDictionary alloc]init];
  28. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  29. ref.tag = 201 ;
  30. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  31. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  32. // ref.hidden = true;
  33. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  34. [self.tableView addSubview:ref];
  35. // NSMutableArray * arr = [[NSMutableArray alloc] init];
  36. // for(int i=0;i<100;i++)
  37. // {
  38. // [arr addObject:[NSNumber numberWithInt:i]];
  39. // }
  40. // NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
  41. // dict[@"arr"] = arr;
  42. // DebugLog([RAUtils dict2string:dict]);
  43. [self loadpage];
  44. // Do any additional setup after loading the view.
  45. }
  46. - (void)didReceiveMemoryWarning {
  47. [super didReceiveMemoryWarning];
  48. // Dispose of any resources that can be recreated.
  49. }
  50. - (IBAction)onAddClick:(id)sender {
  51. __weak typeof(self) weakself = self;
  52. {
  53. AddExtDocumentViewController * addVC;
  54. addVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AddExtDocumentViewController"];
  55. addVC.is_present = true;
  56. addVC.doc_number = nil;
  57. addVC.uploadSuccess = ^(NSMutableArray* arr_upload){
  58. if(arr_upload.count>0)
  59. [weakself loadpage];
  60. };
  61. //addVC.arr_documents = [NSMutableArray arrayWithObjects:appDelegate.shareFile, nil];
  62. //appDelegate.shareFile=nil;
  63. // notesVC.docNotes = notes;
  64. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:addVC] ;
  65. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  66. [self presentViewController:navi animated:YES completion:^{
  67. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  68. DebugLog(@"filter present.........");
  69. // self.btop = false;
  70. // <#code#>
  71. }];
  72. }
  73. }
  74. - (IBAction)onFilterClick:(id)sender {
  75. GEContractFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"GEContractFilterViewController"];
  76. filterVC.filterparams = self.filterparams;
  77. filterVC.OnSearch = ^(NSMutableDictionary* params)
  78. {
  79. // [self reload_container_getdata:true];
  80. self.reset_result=true;
  81. // self.norefresh=true;
  82. [self loadpage];
  83. };
  84. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:filterVC] ;
  85. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  86. [self presentViewController:navi animated:YES completion:^{
  87. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  88. DebugLog(@"filter present.........");
  89. // self.btop = false;
  90. // <#code#>
  91. }];
  92. }
  93. -(void) previewPDF:(NSString*)url title:(NSString*)title subject:(NSString*)subject
  94. {
  95. NSString* name=@"";//[self.content_data[indexPath.row] valueForKey:@"tear_name"];
  96. // NSString* url= file;//[self.content_data[indexPath.row] valueForKey:@"pdf_path"];
  97. bool isLocalFile= false;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
  98. RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  99. ViewController.url = url;
  100. ViewController.canSave = false;
  101. ViewController.isLocalfile=isLocalFile;
  102. ViewController.defaultStyle = true;
  103. ViewController.save_name = title;
  104. // NSString* subject;
  105. // if (company.length==0) {
  106. // NSString* cur_time =[RAUtils current_date];
  107. // subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
  108. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  109. // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  110. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  111. // if(customer_email.length>0)
  112. // {
  113. // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  114. // // customer_email compo
  115. // // [send_to addObject:customer_email];
  116. // }
  117. ViewController.mail_to = send_to;
  118. // }
  119. // else
  120. // {
  121. // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
  122. // }
  123. // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
  124. ViewController.mail_subject = subject;
  125. ViewController.hidenavi = false;
  126. [self.navigationController pushViewController:ViewController animated:YES];
  127. }
  128. #pragma mark - OperationQueue request page data
  129. -(void) loadpage
  130. {
  131. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  132. self.table_data = [[defaults arrayForKey:@"pending_doc"] mutableCopy];
  133. }
  134. - (void)loadmore
  135. {
  136. // self.btnrefresh.enabled = NO;
  137. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"loading",nil);
  138. // [self.btnrefresh setTitle:@"Loading..." forState:UIControlStateNormal];
  139. [self loadpage];
  140. }
  141. -(void)manually_refresh
  142. {
  143. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  144. // if(self.isrefreshing)
  145. // {
  146. // [reF endRefreshing];
  147. // return;
  148. // }
  149. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  150. if ([self respondsToSelector:@selector(ReloadData)])
  151. [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
  152. }
  153. -(void)ReloadData
  154. {
  155. // [self.content_data removeAllObjects];
  156. // [self.table_order reloadData];
  157. // self.table_order.hidden = true;
  158. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  159. [reF endRefreshing];
  160. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  161. // self.keywords=self.searchbar.text;
  162. // // self.offset = 0;
  163. self.reset_result=true;
  164. // [self.content_data removeAllObjects];
  165. // [self.table_order reloadData];
  166. [self loadpage];
  167. // [self loadpage];
  168. }
  169. -(void)refresh_btn_click:(UILongPressGestureRecognizer*)gestureRecognizer
  170. {
  171. // [self reload_container_getdata:true];
  172. self.reset_result=true;
  173. // self.norefresh=true;
  174. [self loadpage];
  175. }
  176. /*
  177. #pragma mark - Navigation
  178. // In a storyboard-based application, you will often want to do a little preparation before navigation
  179. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  180. // Get the new view controller using [segue destinationViewController].
  181. // Pass the selected object to the new view controller.
  182. }
  183. */
  184. #pragma mark - Table view data source
  185. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  186. {
  187. return 44;
  188. }
  189. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  190. //{
  191. // return 0;
  192. //}
  193. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  194. //{
  195. // return 0;
  196. //}
  197. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  198. //{
  199. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  200. // return myView;
  201. //
  202. //}
  203. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  204. {
  205. NSString* value =nil;//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  206. if(value==nil)
  207. value=@"";
  208. unsigned long color = strtoul([value UTF8String],0,16);
  209. UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  210. myView.backgroundColor = UIColorFromRGB(0xf7f7f7);
  211. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  212. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  213. myView.layer.shadowOffset = CGSizeMake(0, 0);
  214. myView.layer.shadowOpacity = 0.5;
  215. myView.layer.shadowRadius = 2.0;
  216. UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 2, 130, 22)];
  217. statuslabel.textColor=UIColorFromRGB(color);
  218. statuslabel.backgroundColor = [UIColor clearColor];
  219. statuslabel.text=NSLocalizedString(@"Document #", nil);
  220. [statuslabel sizeToFit];
  221. [myView addSubview:statuslabel];
  222. UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(143, 2, 135, 22)];
  223. userlabel.textColor=UIColorFromRGB(color);
  224. userlabel.backgroundColor = [UIColor clearColor];
  225. userlabel.text=NSLocalizedString(@"Customer", nil);
  226. [userlabel sizeToFit];
  227. [myView addSubview:userlabel];
  228. // UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 21, 135, 22)];
  229. // creatorlabel.textColor=UIColorFromRGB(color);
  230. // creatorlabel.backgroundColor = [UIColor clearColor];
  231. // creatorlabel.text=NSLocalizedString(@"Create by", nil);
  232. // [creatorlabel sizeToFit];
  233. // [myView addSubview:creatorlabel];
  234. UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(345, 2, 150, 22)];
  235. contactlabel.textColor=UIColorFromRGB(color);
  236. contactlabel.backgroundColor = [UIColor clearColor];
  237. contactlabel.text=NSLocalizedString(@"Job Date", nil);
  238. [contactlabel sizeToFit];
  239. [myView addSubview:contactlabel];
  240. //
  241. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
  242. // modellabel.textColor=[UIColor whiteColor];
  243. // modellabel.backgroundColor = [UIColor clearColor];
  244. // modellabel.text=NSLocalizedString(@"Model", nil);
  245. // [modellabel sizeToFit];
  246. // [myView addSubview:modellabel];
  247. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
  248. // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  249. // modellabel.textColor=[UIColor whiteColor];
  250. // modellabel.backgroundColor = [UIColor clearColor];
  251. // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
  252. // [modellabel sizeToFit];
  253. // [myView addSubview:modellabel];
  254. UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.tableView.frame.size.width-313, 2, 100, 22)];
  255. pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  256. pricelabel.textColor=UIColorFromRGB(color);
  257. pricelabel.backgroundColor = [UIColor clearColor];
  258. pricelabel.text=NSLocalizedString(@"Agent Name", nil);
  259. [pricelabel sizeToFit];
  260. [myView addSubview:pricelabel];
  261. UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.frame.size.width-131/*605*/,2, 148, 22)];
  262. timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  263. timelabel.textColor=UIColorFromRGB(color);
  264. timelabel.backgroundColor = [UIColor clearColor];
  265. // if(self.time_zone==nil)
  266. timelabel.text=@"Create by";
  267. // else
  268. // timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
  269. [timelabel sizeToFit];
  270. [myView addSubview:timelabel];
  271. myView.autoresizesSubviews=true;
  272. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  273. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  274. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  275. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  276. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  277. //
  278. return myView;
  279. }
  280. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  281. //{
  282. //
  283. //
  284. // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  285. //
  286. // if(value==nil)
  287. // value=@"";
  288. // unsigned long color = strtoul([value UTF8String],0,16);
  289. //
  290. //
  291. // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  292. // // myView.backgroundColor = UIColorFromRGB(0x996633);;
  293. //
  294. //
  295. // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  296. // // myView.layer.masksToBounds = false;
  297. // //添加四个边阴影
  298. //
  299. // myView.layer.shadowColor = [UIColor blackColor].CGColor;
  300. // myView.layer.shadowOffset = CGSizeMake(0, 0);
  301. // myView.layer.shadowOpacity = 0.5;
  302. // myView.layer.shadowRadius = 2.0;
  303. //
  304. //
  305. // NSString*labeltitle = nil;
  306. // switch (section) {
  307. // case 0:
  308. // labeltitle= @"Order Info";
  309. // break;
  310. // case 1:
  311. // {
  312. // labeltitle= @"More Info";
  313. //
  314. // NSString* btntitle=nil ;
  315. // if(self.showMore)
  316. // {
  317. // btntitle=@"Hide";
  318. // // [section setValue:@"false" forKey:@"hide"];
  319. // // [sender setTitle:@"Show" forState:UIControlStateNormal];
  320. // }
  321. // else{
  322. // btntitle=@"Show";
  323. // }
  324. //
  325. //
  326. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  327. // btn.tag=section;
  328. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  329. // [btn setTitle:btntitle forState:UIControlStateNormal];
  330. // [myView addSubview:btn];
  331. //
  332. // }
  333. // break;
  334. // case 2:{
  335. // labeltitle= @"Models";
  336. //
  337. // NSString* btntitle=nil ;
  338. // if(self.showModels)
  339. // {
  340. // btntitle=@"Hide";
  341. // }
  342. // else{
  343. // btntitle=@"Show";
  344. // }
  345. //
  346. //
  347. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  348. // btn.tag=section;
  349. //
  350. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  351. //
  352. // [btn setTitle:btntitle forState:UIControlStateNormal];
  353. // [myView addSubview:btn];
  354. //
  355. // }
  356. // break;
  357. // case 3:
  358. // labeltitle= @"Price Info";
  359. // default:
  360. // break;
  361. // }
  362. //
  363. //
  364. //
  365. // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  366. // titlelabel.textColor=UIColorFromRGB(color);;
  367. // titlelabel.backgroundColor = [UIColor clearColor];
  368. // titlelabel.text=NSLocalizedString(labeltitle, nil);
  369. // [titlelabel sizeToFit];
  370. // [myView addSubview:titlelabel];
  371. //
  372. // //
  373. // return myView;
  374. //}
  375. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  376. //
  377. // return [NSString stringWithFormat:@"Signature%ld",(long)section+1];
  378. //
  379. //}
  380. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  381. {
  382. return 1;
  383. }
  384. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  385. {
  386. return 22;
  387. }
  388. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  389. {
  390. return self.table_data.count;
  391. }
  392. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  393. {
  394. NSString *CellIdentifier = @"PendingDocumentsTableViewCell";
  395. PendingDocumentsTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  396. NSDictionary * item_json = self.table_data[indexPath.row];
  397. cell.labelAgent.text = item_json[@"agent_name"];
  398. // if(sss.length==0)
  399. // sss=@"";
  400. cell.labelDocID.text = item_json[@"doc_number"];//
  401. cell.labelJobDate.text =item_json[@"job_date"];
  402. cell.labelCustomer.text =item_json[@"customer_name"];
  403. cell.labelSignDate.text =item_json[@"signed_date"];
  404. cell.labelCreateby.text =item_json[@"create_by"];
  405. return cell;
  406. }
  407. #pragma mark tableview delegate
  408. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  409. {
  410. NSDictionary * item_json = self.table_data[indexPath.row];
  411. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  412. // dvc.templateName = @"debug.json";
  413. dvc.templatePath = [RANetwork getjsonPath:item_json[@"serial"]];
  414. dvc.pdfPath = [RANetwork getPDFPath:item_json[@"pdf"]] ;
  415. dvc.hide_control =true;
  416. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  417. dvc.no_save = appDelegate.accessMode==AppAccessModeOffline;
  418. dvc.docment_id = item_json[@"doc_number"];
  419. dvc.OnSave=^(NSString* file, NSString* subject)
  420. {
  421. [self.table_data removeObjectAtIndex:indexPath.row];
  422. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  423. [defaults setObject:self.table_data forKey:@"pending_doc"];
  424. [defaults synchronize];
  425. [self.tableView reloadData];
  426. };
  427. [self.navigationController pushViewController:dvc animated:true];
  428. }
  429. - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  430. {
  431. // __weak typeof (self) weekself=self;
  432. // __weak NSIndexPath* weekindex = indexPath;
  433. // NSDictionary * item_json = self.table_data[indexPath.row];
  434. //
  435. // NSString* notes = item_json[@"notes"];
  436. // NSString* doc_number = item_json[@"doc_number"];
  437. //
  438. // NSMutableArray* arr_doc = [item_json[@"documents"] mutableCopy];
  439. //
  440. // UITableViewRowAction *docAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Documents"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  441. //
  442. // DebugLog(@"Documents click");
  443. //
  444. // [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  445. //
  446. //
  447. // ExtDocumentsViewController * docVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"ExtDocumentsViewController"];
  448. //
  449. // docVC.docNumber = doc_number;
  450. // docVC.arr_documents =arr_doc;
  451. //
  452. // docVC.closeExtDoc=^(bool refresh){
  453. //
  454. // if(refresh)
  455. // {
  456. //
  457. // self.reset_result=true;
  458. // // self.norefresh=true;
  459. // [self loadpage];
  460. // }
  461. // // [weekself.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:weekindex, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
  462. //
  463. // };
  464. // // notesVC.docNotes = notes;
  465. //
  466. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:docVC] ;
  467. //
  468. //
  469. //
  470. //
  471. //
  472. //
  473. // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  474. // [self presentViewController:navi animated:YES completion:^{
  475. //
  476. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  477. //
  478. // DebugLog(@"filter present.........");
  479. //
  480. // // self.btop = false;
  481. // // <#code#>
  482. // }];
  483. //
  484. // }];
  485. //
  486. //
  487. // docAction.backgroundColor = UIColorFromRGB(0xff9933);
  488. //
  489. //
  490. // UITableViewRowAction *modifyAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Modify " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  491. //
  492. // DebugLog(@"modify click");
  493. //
  494. //
  495. // // [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  496. // // DocnotesViewController * notesVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"DocnotesViewController"];
  497. // //
  498. // // notesVC.docNumber = doc_number;
  499. // // notesVC.docNotes = notes;
  500. // //
  501. // // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:notesVC] ;
  502. // //
  503. // //
  504. // //
  505. // //
  506. // //
  507. // //
  508. // // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  509. // // [self presentViewController:navi animated:YES completion:^{
  510. // //
  511. // // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  512. // //
  513. // // DebugLog(@"filter present.........");
  514. // //
  515. // // // self.btop = false;
  516. // // // <#code#>
  517. // // }];
  518. //
  519. // }];
  520. //
  521. // modifyAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
  522. //
  523. UITableViewRowAction *delAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  524. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Delete pending document" message:@"Are you sure?" preferredStyle:UIAlertControllerStyleAlert];
  525. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  526. [self.table_data removeObjectAtIndex:indexPath.row];
  527. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  528. [defaults setObject:self.table_data forKey:@"pending_doc"];
  529. [defaults synchronize];
  530. [self.tableView reloadData];
  531. }];
  532. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  533. }];
  534. [alertControl addAction:actionOne];
  535. [alertControl addAction:alertthree];
  536. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  537. [self presentViewController:alertControl animated:YES completion:nil];
  538. }];
  539. delAction.backgroundColor = UIColorFromRGB(0x336699);
  540. return @[delAction];
  541. }
  542. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  543. return YES;
  544. }
  545. - (void)tableView:(UITableView *)tableView
  546. commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  547. }
  548. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  549. return UITableViewCellEditingStyleDelete;
  550. }
  551. /*
  552. #pragma mark - Navigation
  553. // In a storyboard-based application, you will often want to do a little preparation before navigation
  554. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  555. // Get the new view controller using [segue destinationViewController].
  556. // Pass the selected object to the new view controller.
  557. }
  558. */
  559. @end