SignatureListViewController.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. //
  2. // SignatureListViewController.m
  3. // AntsContract
  4. //
  5. // Created by Ray on 12/19/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "SignatureListViewController.h"
  9. #import "SignatureTableViewCell.h"
  10. @interface SignatureListViewController ()
  11. @end
  12. @implementation SignatureListViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. }
  17. - (void)didReceiveMemoryWarning {
  18. [super didReceiveMemoryWarning];
  19. // Dispose of any resources that can be recreated.
  20. }
  21. - (IBAction)onAddClick:(id)sender {
  22. [self dismissViewControllerAnimated:false completion:^{
  23. if(self.blk_Add)
  24. self.blk_Add();
  25. }];
  26. }
  27. - (IBAction)onFillClick:(id)sender {
  28. UITableViewCell* cell = ((UIView*)sender).superview.superview;
  29. NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
  30. NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  31. // UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  32. if(self.blk_Fill)
  33. self.blk_Fill(item_json[@"file"]);
  34. }
  35. /*
  36. #pragma mark - Navigation
  37. // In a storyboard-based application, you will often want to do a little preparation before navigation
  38. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  39. // Get the new view controller using [segue destinationViewController].
  40. // Pass the selected object to the new view controller.
  41. }
  42. */
  43. #pragma mark - Table view data source
  44. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  45. {
  46. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  47. // if([item_json objectForKey:@"combine"] == nil)
  48. // {
  49. // return 120;
  50. // }
  51. // else
  52. // return 150;
  53. return 128;
  54. }
  55. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  56. //{
  57. // return 0;
  58. //}
  59. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  60. //{
  61. // return 0;
  62. //}
  63. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  64. //{
  65. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  66. // return myView;
  67. //
  68. //}
  69. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  70. //{
  71. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  72. //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  73. //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
  74. //// titleLabel.textColor=[UIColor whiteColor];
  75. //// titleLabel.backgroundColor = [UIColor clearColor];
  76. //// if(section==0)
  77. //// titleLabel.text=NSLocalizedString(@"display_items", nil);
  78. //// else
  79. //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
  80. //// [titleLabel sizeToFit];
  81. //// [myView addSubview:titleLabel];
  82. ////
  83. // return myView;
  84. //}
  85. //
  86. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  87. //{
  88. //
  89. //
  90. // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  91. //
  92. // if(value==nil)
  93. // value=@"";
  94. // unsigned long color = strtoul([value UTF8String],0,16);
  95. //
  96. //
  97. // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  98. // // myView.backgroundColor = UIColorFromRGB(0x996633);;
  99. //
  100. //
  101. // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  102. // // myView.layer.masksToBounds = false;
  103. // //添加四个边阴影
  104. //
  105. // myView.layer.shadowColor = [UIColor blackColor].CGColor;
  106. // myView.layer.shadowOffset = CGSizeMake(0, 0);
  107. // myView.layer.shadowOpacity = 0.5;
  108. // myView.layer.shadowRadius = 2.0;
  109. //
  110. //
  111. // NSString*labeltitle = nil;
  112. // switch (section) {
  113. // case 0:
  114. // labeltitle= @"Order Info";
  115. // break;
  116. // case 1:
  117. // {
  118. // labeltitle= @"More Info";
  119. //
  120. // NSString* btntitle=nil ;
  121. // if(self.showMore)
  122. // {
  123. // btntitle=@"Hide";
  124. // // [section setValue:@"false" forKey:@"hide"];
  125. // // [sender setTitle:@"Show" forState:UIControlStateNormal];
  126. // }
  127. // else{
  128. // btntitle=@"Show";
  129. // }
  130. //
  131. //
  132. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  133. // btn.tag=section;
  134. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  135. // [btn setTitle:btntitle forState:UIControlStateNormal];
  136. // [myView addSubview:btn];
  137. //
  138. // }
  139. // break;
  140. // case 2:{
  141. // labeltitle= @"Models";
  142. //
  143. // NSString* btntitle=nil ;
  144. // if(self.showModels)
  145. // {
  146. // btntitle=@"Hide";
  147. // }
  148. // else{
  149. // btntitle=@"Show";
  150. // }
  151. //
  152. //
  153. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  154. // btn.tag=section;
  155. //
  156. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  157. //
  158. // [btn setTitle:btntitle forState:UIControlStateNormal];
  159. // [myView addSubview:btn];
  160. //
  161. // }
  162. // break;
  163. // case 3:
  164. // labeltitle= @"Price Info";
  165. // default:
  166. // break;
  167. // }
  168. //
  169. //
  170. //
  171. // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  172. // titlelabel.textColor=UIColorFromRGB(color);;
  173. // titlelabel.backgroundColor = [UIColor clearColor];
  174. // titlelabel.text=NSLocalizedString(labeltitle, nil);
  175. // [titlelabel sizeToFit];
  176. // [myView addSubview:titlelabel];
  177. //
  178. // //
  179. // return myView;
  180. //}
  181. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  182. return [NSString stringWithFormat:@"Signature%ld",(long)section+1];
  183. }
  184. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  185. {
  186. return [self.signatureData[@"count"] intValue];
  187. }
  188. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  189. //{
  190. // return 33;
  191. //}
  192. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  193. {
  194. return 1;
  195. }
  196. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  197. {
  198. NSString *CellIdentifier = @"SignatureTableViewCell";
  199. SignatureTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  200. NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  201. UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  202. cell.signatureImageView.image = img;
  203. //
  204. //
  205. // cell.webview.tag = indexPath.section;
  206. //
  207. // cell.webview.delegate = self;
  208. // // cell.webView.scrollView.contentSize.height = 0;
  209. // cell.webview.scrollView.bounces=NO;
  210. // cell.webview.scrollView.directionalLockEnabled = true;
  211. // CGSize size= cell.webview.scrollView.contentSize;
  212. // size.height=10;
  213. // cell.webview.scrollView.contentSize=size;
  214. //
  215. // [cell.webview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
  216. //
  217. // cell.backgroundColor = [UIColor whiteColor];
  218. return cell;
  219. // if(tableView==self.itemListTable)
  220. // {
  221. // NSString *CellIdentifier = @"CartItemCell";
  222. // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  223. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  224. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  225. //
  226. // cell.bundle_item=combine_json;
  227. // NSString* img_url = [item_json valueForKey:@"img_url"];
  228. // NSString* description = [item_json valueForKey:@"description"];
  229. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  230. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  231. // NSString* currency = [item_json valueForKey:@"currency"];
  232. // int count =[[item_json valueForKey:@"count"] intValue];
  233. //
  234. // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
  235. //
  236. // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
  237. //
  238. // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
  239. // cell.unit_price = unitprice;
  240. // // cell.labelAttribute.text = attribute;
  241. // // cell.labelCurrency.text = currency;
  242. // cell.labelDescription.text = description;
  243. // // cell.labelIdentifier.text = identifier;
  244. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
  245. //
  246. // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
  247. //
  248. //
  249. //
  250. // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
  251. // cell.cart_id = cart_item_id;
  252. // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
  253. //
  254. //
  255. //
  256. // [cell set_Count:count];
  257. //
  258. // NSString* file_name=[img_url lastPathComponent];
  259. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  260. // if(img_data!=nil)
  261. // {
  262. //
  263. // UIImage * img =[UIImage imageWithData:img_data];
  264. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  265. // }
  266. // else
  267. // {
  268. //
  269. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  270. //
  271. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  272. //
  273. // dispatch_async(dispatch_get_main_queue(), ^{
  274. //
  275. //
  276. //
  277. // if(downloadimg_data!=nil)
  278. // {
  279. // [iSalesDB cache_img:downloadimg_data :file_name ];
  280. //
  281. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  282. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  283. // }
  284. //
  285. // });
  286. // });
  287. //
  288. //
  289. // }
  290. // return cell;
  291. // }
  292. // else
  293. // {
  294. // NSString *CellIdentifier = @"OrderInfoListItem";
  295. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  296. // return cell;
  297. // }
  298. }
  299. #pragma mark tableview delegate
  300. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  301. {
  302. if(self.blk_Select)
  303. {
  304. // SignatureTableViewCell * cell= [tableView cellForRowAtIndexPath:indexPath];
  305. NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  306. // UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  307. self.blk_Select(item_json[@"file"]);
  308. }
  309. [self dismissViewControllerAnimated:false completion:nil];
  310. // if (tableView.isEditing) { // 编辑模式下不响应
  311. // return;
  312. // }
  313. // //
  314. // if(indexPath.row==self.content_data.count)
  315. // return;
  316. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  317. //
  318. // if(appDelegate.user_type==USER_ROLE_CUSTOMER) { // Customer
  319. // if ([Singleton sharedInstance].global_lock) { // Order list 被锁
  320. // [RAUtils message_alert:@"App is locked,You can't view the order Detail" title:@"Warning" controller:self];
  321. // return;
  322. // }
  323. // }
  324. //
  325. // NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
  326. // OrderDetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"OrderDetailViewController" ];
  327. //
  328. // // int i =[[self.content_data[indexPath.row] valueForKey:@"order_code"];
  329. // dvc.selectOrder=^(NSMutableDictionary* order_detail){
  330. //
  331. // [self.navigationController popViewControllerAnimated:false];
  332. // if(self.selectOrder)
  333. // self.selectOrder(order_detail);
  334. //
  335. //
  336. //
  337. // };
  338. // NSString* order_code =[self.content_data[indexPath.row] valueForKey:@"order_code"];
  339. //
  340. // dvc.is_shoporder=(self.orderType == 0);
  341. // dvc.order_code = order_code;
  342. // dvc.order_status =[[self.content_data[indexPath.row] valueForKey:@"orderStatus"] intValue];
  343. // // bool temp_order = false ;
  344. // // NSString* order_status=[self.content_data[indexPath.row] valueForKey:@"order_status"];
  345. // // if([order_status isEqualToString:@"Saved"]||[order_status isEqualToString:@"Quoted"])
  346. // // temp_order=true;
  347. // //
  348. // // dvc.isTempOrder = temp_order;
  349. //
  350. // // dvc
  351. //
  352. // dvc.orderid=orderid;
  353. // // dvc.category_id=nil;
  354. // // dvc.ispush=true;
  355. // // [dvc reload];
  356. // [self.navigationController pushViewController:dvc animated:true];
  357. }
  358. @end