SignatureListViewController.m 14 KB

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