SignatureListViewController.m 13 KB

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