NewSalesGoodsDetailCell.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. //
  2. // NewSalesGoodsDetailCell.m
  3. // IBOSSmini
  4. //
  5. // Created by ssl on 2018/2/27.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "NewSalesGoodsDetailCell.h"
  9. @implementation NewSalesGoodsDetailCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. return self;
  13. }
  14. -(void) goUsePosition{
  15. }
  16. - (void)setInventoryCell:(InventoryModel *)inventoryDetailModel editStatus:(int)flag editFlag:(int)editFlag{
  17. CGFloat heightLine = 1;
  18. CGFloat lblx = 20;
  19. CGFloat valuey = 10;
  20. CGFloat valueheight = 25;
  21. _inventoryModel=inventoryDetailModel;
  22. _editStatus=flag;
  23. _lblGoodsName = [UILabel new];
  24. _lblGoodsName.frame=CGRectMake(lblx, valuey, Screen_Width- lblx - 55, valueheight);
  25. _lblGoodsName.font =orderTextFont;
  26. [self addSubview:_lblGoodsName];
  27. _lblGoodsName.text = _inventoryModel.goodsName;
  28. _vDelete=[UIView new];
  29. _vDelete.frame=CGRectMake(Screen_Width-65, valuey,70 , valueheight);
  30. UIButton *btnDelete=[UIButton buttonWithType:UIButtonTypeCustom];
  31. btnDelete.frame=CGRectMake(0, 4,15, 15);
  32. UIImageView *deleteImg=[[UIImageView alloc]init];
  33. deleteImg.frame=CGRectMake(0,0,15,15);
  34. [deleteImg setImage:[UIImage imageNamed:@"icon_delete"]];
  35. deleteImg.userInteractionEnabled=NO;
  36. [btnDelete addSubview:deleteImg];
  37. [_vDelete addSubview:btnDelete];
  38. _vDelete.userInteractionEnabled=YES;
  39. UILabel *lblDelete=[UILabel new];
  40. lblDelete.text=@"删除";
  41. lblDelete.frame=CGRectMake(CGRectGetMaxX(btnDelete.frame)+3, 0,30, 25);
  42. lblDelete.font=orderTextFont;
  43. [_vDelete addSubview:lblDelete];
  44. [self addSubview:_vDelete];
  45. UITapGestureRecognizer *tapRecognizerDelete=[[UITapGestureRecognizer alloc] initWithTarget:self
  46. action:@selector(deleteOrder)];
  47. _vDelete.userInteractionEnabled=YES;
  48. [_vDelete addGestureRecognizer:tapRecognizerDelete];
  49. _topSeparator=[UIView new];
  50. _topSeparator.frame=CGRectMake(0, CGRectGetMaxY(_vDelete.frame)+valuey, Screen_Width, heightLine);
  51. [self addSubview:_topSeparator];
  52. UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
  53. [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
  54. btnLine.frame = CGRectMake(0 ,0 , Screen_Width, heightLine);
  55. [_topSeparator addSubview:btnLine];
  56. UILabel *lblGoodsCodeTitle=[UILabel new];
  57. lblGoodsCodeTitle.frame=CGRectMake(lblx,CGRectGetMaxY(_topSeparator.frame)+valuey,70, valueheight);
  58. lblGoodsCodeTitle.text=@"商品编码:";
  59. lblGoodsCodeTitle.font=orderTextFont;
  60. lblGoodsCodeTitle.textColor=LabelGrayTextColor;
  61. [self addSubview:lblGoodsCodeTitle];
  62. _lblGoodsCode=[UILabel new];
  63. NSString *goodsCode=_inventoryModel.code;
  64. if(goodsCode!=nil){
  65. _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame), CGRectGetMaxY(_topSeparator.frame)+valuey,Screen_Width/2-CGRectGetMaxX(lblGoodsCodeTitle.frame)-3, valueheight);
  66. _lblGoodsCode.text=goodsCode;
  67. _lblGoodsCode.font=orderTextFont;
  68. [self addSubview:_lblGoodsCode];
  69. }
  70. UILabel *lblOnlyCodeTitle=[UILabel new];
  71. lblOnlyCodeTitle.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(_topSeparator.frame)+valuey,70, valueheight);
  72. lblOnlyCodeTitle.text=@"唯一编码:";
  73. lblOnlyCodeTitle.font=orderTextFont;
  74. lblOnlyCodeTitle.textColor=LabelGrayTextColor;
  75. [self addSubview:lblOnlyCodeTitle];
  76. NSString *onlyCode=_inventoryModel.onlyCode;
  77. if(onlyCode!=nil){
  78. _lblOnlyCode=[UILabel new];
  79. _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame),CGRectGetMaxY(_topSeparator.frame)+valuey , Screen_Width/2-lblOnlyCodeTitle.frame.size.width-3, valueheight);
  80. _lblOnlyCode.text=onlyCode;
  81. _lblOnlyCode.font=orderTextFont;
  82. [self addSubview:_lblOnlyCode];
  83. }
  84. UILabel *lblColorNumberTitle=[UILabel new];
  85. lblColorNumberTitle.frame=CGRectMake(lblx, CGRectGetMaxY(lblGoodsCodeTitle.frame)+valuey,70, valueheight);
  86. lblColorNumberTitle.text=@"色 号:";
  87. lblColorNumberTitle.font=orderTextFont;
  88. lblColorNumberTitle.textColor=LabelGrayTextColor;
  89. [self addSubview:lblColorNumberTitle];
  90. NSString *colorNumber=[_inventoryModel colorNumber];
  91. if(colorNumber!=nil){
  92. _lblColorNumber=[UILabel new];
  93. _lblColorNumber.frame=CGRectMake(CGRectGetMaxX(lblColorNumberTitle.frame), CGRectGetMaxY(lblGoodsCodeTitle.frame)+valuey,Screen_Width/2-CGRectGetMaxX(lblColorNumberTitle.frame), valueheight);
  94. _lblColorNumber.font=orderTextFont;
  95. _lblColorNumber.text=colorNumber;
  96. [self addSubview:_lblColorNumber];
  97. }
  98. UILabel *lblSpecificationTitle=[UILabel new];
  99. lblSpecificationTitle.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblGoodsCodeTitle.frame)+valuey,70, valueheight);
  100. lblSpecificationTitle.text=@"规 格:";
  101. lblSpecificationTitle.font=orderTextFont;
  102. lblSpecificationTitle.textColor=LabelGrayTextColor;
  103. [self addSubview:lblSpecificationTitle];
  104. NSString *specification=_inventoryModel.specification;
  105. if(specification!=nil){
  106. _lblSpecification=[UILabel new];
  107. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame), CGRectGetMaxY(lblGoodsCodeTitle.frame)+valuey, Screen_Width/2-lblSpecificationTitle.frame.size.width-3, valueheight);
  108. _lblSpecification.text=specification;
  109. _lblSpecification.font=orderTextFont;
  110. [self addSubview:_lblSpecification];
  111. }
  112. UILabel *lblWarehouseAreaTitle=[UILabel new];
  113. lblWarehouseAreaTitle.frame=CGRectMake(lblx, CGRectGetMaxY(lblColorNumberTitle.frame)+valuey,70, valueheight);
  114. lblWarehouseAreaTitle.text=@"库 区:";
  115. lblWarehouseAreaTitle.font=orderTextFont;
  116. lblWarehouseAreaTitle.textColor=LabelGrayTextColor;
  117. [self addSubview:lblWarehouseAreaTitle];
  118. NSString *warehouseArea=_inventoryModel.wareHouseName;
  119. if(warehouseArea!=nil){
  120. _lblWarehouseArea=[UILabel new];
  121. _lblWarehouseArea.frame=CGRectMake(CGRectGetMaxX(lblWarehouseAreaTitle.frame),CGRectGetMaxY(lblColorNumberTitle.frame)+valuey, Screen_Width-CGRectGetMaxX(lblWarehouseAreaTitle.frame)-3, valueheight);
  122. _lblWarehouseArea.text=warehouseArea;
  123. _lblWarehouseArea.font=orderTextFont;
  124. [self addSubview:_lblWarehouseArea];
  125. }
  126. UILabel *lblRemarksTitle=[UILabel new];
  127. lblRemarksTitle.frame=CGRectMake(lblx, CGRectGetMaxY(lblWarehouseAreaTitle.frame)+valuey,70, valueheight);
  128. lblRemarksTitle.text=@"备 注:";
  129. lblRemarksTitle.font=orderTextFont;
  130. lblRemarksTitle.textColor=LabelGrayTextColor;
  131. [self addSubview:lblRemarksTitle];
  132. NSString *remarks=_inventoryModel.remarks;
  133. _txtRemarks=[UITextField new];
  134. _txtRemarks.placeholder=@"请输入备注";
  135. _txtRemarks.tag=1003;
  136. _txtRemarks.delegate=self;
  137. _txtRemarks.enabled=YES;
  138. _txtRemarks.text=remarks;
  139. _txtRemarks.font=orderTextFont;
  140. _txtRemarks.frame=CGRectMake(CGRectGetMaxX(lblRemarksTitle.frame), CGRectGetMaxY(lblWarehouseAreaTitle.frame)+valuey, Screen_Width-CGRectGetMaxX(lblRemarksTitle.frame)-3, valueheight);
  141. [self addSubview:_txtRemarks];
  142. UILabel *lblUsePositionTitle=[UILabel new];
  143. lblUsePositionTitle.frame=CGRectMake(lblx, CGRectGetMaxY(lblRemarksTitle.frame)+valuey,70, valueheight);
  144. lblUsePositionTitle.text=@"使用位置:";
  145. lblUsePositionTitle.font=orderTextFont;
  146. lblUsePositionTitle.textColor=LabelGrayTextColor;
  147. [self addSubview:lblUsePositionTitle];
  148. _btnUsePosition=[UIButton buttonWithType:UIButtonTypeCustom];
  149. _btnUsePosition.frame=CGRectMake(CGRectGetMaxX(lblUsePositionTitle.frame), CGRectGetMaxY(lblRemarksTitle.frame)+valuey, Screen_Width/2-CGRectGetMaxX(lblUsePositionTitle.frame)-3, valueheight);
  150. [_btnUsePosition setTitleColor:LabelGrayTextColor forState:UIControlStateNormal];
  151. [_btnUsePosition setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  152. [_btnUsePosition addTarget:self action:@selector(clickUsePosition) forControlEvents:UIControlEventTouchUpInside];
  153. _btnUsePosition.userInteractionEnabled=YES;
  154. NSString *usePosition=_inventoryModel.usePositionName;
  155. if(usePosition!=nil&&usePosition.length>0){
  156. [_btnUsePosition setTitle:usePosition forState:UIControlStateNormal];
  157. }else{
  158. [_btnUsePosition setTitle:@"请选择使用位置" forState:UIControlStateNormal];
  159. }
  160. _btnUsePosition.titleLabel.font=orderTextFont;
  161. [self addSubview:_btnUsePosition];
  162. UILabel *lblGradeTitle=[UILabel new];
  163. lblGradeTitle.frame=CGRectMake(Screen_Width/2, CGRectGetMaxY(lblRemarksTitle.frame)+valuey,70, valueheight);
  164. lblGradeTitle.text=@"等 级:";
  165. lblGradeTitle.font=orderTextFont;
  166. lblGradeTitle.textColor=LabelGrayTextColor;
  167. [self addSubview:lblGradeTitle];
  168. NSString *grade=_inventoryModel.gradeName;
  169. if(grade!=nil){
  170. _lblGrade=[UILabel new];
  171. _lblGrade.frame=CGRectMake(CGRectGetMaxX(lblGradeTitle.frame), CGRectGetMaxY(lblRemarksTitle.frame)+valuey,Screen_Width/2-lblGradeTitle.frame.size.width-3, valueheight);
  172. _lblGrade.text=grade;
  173. _lblGrade.font=orderTextFont;
  174. [self addSubview:_lblGrade];
  175. }
  176. _middleSeparator=[UIView new];
  177. _middleSeparator.frame=CGRectMake(0, CGRectGetMaxY(lblUsePositionTitle.frame)+valuey, Screen_Width, 1);
  178. _middleSeparator.backgroundColor=LineBackgroundColor;
  179. [self addSubview:_middleSeparator];
  180. _lblDiscount= [[UILabel alloc] init];
  181. [self updateFrame];
  182. [self addSubview:_lblDiscount];
  183. UIView *salesPriceView=[[UIView alloc]init];
  184. salesPriceView.layer.borderWidth=1.0f;
  185. salesPriceView.layer.borderColor=[LabelGrayTextColor CGColor];
  186. salesPriceView.frame=CGRectMake(Screen_Width-300, CGRectGetMaxY(_lblDiscount.frame)+10, 130,25 );
  187. [self addSubview: salesPriceView];
  188. UILabel *lblSymbol=[[UILabel alloc]init];
  189. lblSymbol.text=@"¥";
  190. lblSymbol.textColor=LabelGrayTextColor;
  191. lblSymbol.frame=CGRectMake(0,5,15,15);
  192. lblSymbol.font=orderTextFont;
  193. lblSymbol.textAlignment=NSTextAlignmentCenter;
  194. [salesPriceView addSubview:lblSymbol];
  195. NSString *salesPrice=_inventoryModel.salesPrice;
  196. _txtSalesPrice=[UITextField new];
  197. _txtSalesPrice.frame=CGRectMake(CGRectGetMaxX(lblSymbol.frame), 0, 100, 25);
  198. _txtSalesPrice.text=salesPrice;
  199. _txtSalesPrice.enabled=YES;
  200. _txtSalesPrice.delegate=self;
  201. _txtSalesPrice.keyboardType=UIKeyboardTypeDecimalPad;
  202. _txtSalesPrice.tag=1001;
  203. _txtSalesPrice.textAlignment=NSTextAlignmentCenter;
  204. _txtSalesPrice.font=orderTextFont;
  205. [salesPriceView addSubview:_txtSalesPrice];
  206. UIImageView *penImg= [[UIImageView alloc]init];
  207. [penImg setImage:[UIImage imageNamed:@"icon_pen"]];
  208. penImg.frame=CGRectMake(salesPriceView.frame.size.width-17,5,12,12);
  209. [salesPriceView addSubview:penImg];
  210. UIButton *substractButton=[UIButton buttonWithType:UIButtonTypeCustom];
  211. [substractButton setTitle:@"-" forState:UIControlStateNormal];
  212. [substractButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  213. substractButton.frame=CGRectMake(CGRectGetMaxX(salesPriceView.frame)+10,CGRectGetMaxY(_lblDiscount.frame)+10,25,25);
  214. substractButton.layer.borderColor=[LabelGrayTextColor CGColor];
  215. substractButton.layer.borderWidth=1.0;
  216. substractButton.userInteractionEnabled=YES;
  217. [substractButton addTarget:self action:@selector(substractQuantity) forControlEvents:UIControlEventTouchUpInside];
  218. [self addSubview:substractButton];
  219. _txtSalesQuantity=[UITextField new];
  220. _txtSalesQuantity.frame=CGRectMake(CGRectGetMaxX(substractButton.frame)-1,CGRectGetMaxY(_lblDiscount.frame)+10,100,25);;
  221. _txtSalesQuantity.text=_inventoryModel.salesQuantity;
  222. _txtSalesQuantity.delegate=self;
  223. _txtSalesQuantity.enabled=YES;
  224. _txtSalesQuantity.keyboardType=UIKeyboardTypeDecimalPad;
  225. _txtSalesQuantity.layer.borderWidth=1.0f;
  226. _txtSalesQuantity.tag=1002;
  227. _txtSalesQuantity.textAlignment=NSTextAlignmentCenter;
  228. _txtSalesQuantity.layer.borderColor=[LabelGrayTextColor CGColor];
  229. _txtSalesQuantity.font=orderTextFont;
  230. [self addSubview:_txtSalesQuantity];
  231. UIButton *addButton=[UIButton buttonWithType:UIButtonTypeCustom];
  232. [addButton setTitle:@"+" forState:UIControlStateNormal];
  233. [addButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  234. addButton.frame=CGRectMake(CGRectGetMaxX(_txtSalesQuantity.frame)-1,CGRectGetMaxY(_lblDiscount.frame)+10,25,25);;
  235. addButton.layer.borderColor=[LabelGrayTextColor CGColor];
  236. addButton.layer.borderWidth=1.0;
  237. addButton.userInteractionEnabled=YES;
  238. [addButton addTarget:self action:@selector(addQuantity) forControlEvents:UIControlEventTouchUpInside];
  239. [self addSubview:addButton];
  240. UIView *bottomSeparator=[[UIView alloc]init];
  241. bottomSeparator.frame=CGRectMake(0,CGRectGetMaxY(salesPriceView.frame)+10,Screen_Width, 10);
  242. bottomSeparator.backgroundColor=LineBackgroundColor;
  243. [self addSubview:bottomSeparator];
  244. // 未完成状态,编辑状态商品,转销售或转采购数量>0,不能修改价格和删除;
  245. if(_editStatus==5){
  246. NSString *flag=_inventoryModel.flag;
  247. if([flag isEqualToString:@"modify"]){
  248. _vDelete.userInteractionEnabled = NO;
  249. _txtSalesPrice.enabled=NO;
  250. _txtSalesQuantity.enabled=NO;
  251. substractButton.userInteractionEnabled=NO;
  252. addButton.userInteractionEnabled=NO;
  253. }
  254. }
  255. else if(_editStatus==7){
  256. _txtSalesQuantity.enabled=NO;
  257. substractButton.userInteractionEnabled=NO;
  258. addButton.userInteractionEnabled=NO;
  259. _btnUsePosition.userInteractionEnabled=NO;
  260. _txtSalesPrice.enabled=NO;
  261. _vDelete.userInteractionEnabled = NO;
  262. }
  263. else if(_editStatus==10){
  264. _txtSalesQuantity.enabled=NO;
  265. substractButton.userInteractionEnabled=NO;
  266. addButton.userInteractionEnabled=NO;
  267. _btnUsePosition.userInteractionEnabled=NO;
  268. _txtSalesPrice.enabled=NO;
  269. _txtRemarks.enabled=NO;
  270. _vDelete.userInteractionEnabled = NO;
  271. }
  272. else if(_editStatus==4){
  273. _vDelete.userInteractionEnabled = NO;
  274. _txtSalesPrice.enabled=NO;
  275. _txtSalesQuantity.enabled=NO;
  276. substractButton.userInteractionEnabled=NO;
  277. addButton.userInteractionEnabled=NO;
  278. }
  279. if(editFlag == 3){
  280. _vDelete.userInteractionEnabled = NO;
  281. _txtSalesPrice.enabled=NO;
  282. }
  283. }
  284. -(void)deleteOrder{
  285. if([self.orderDelegate respondsToSelector:@selector(deleteOrderDetail:)])
  286. {
  287. [self.orderDelegate deleteOrderDetail:_cellIndex];
  288. }
  289. }
  290. #pragma mark - 委托函数
  291. /**
  292. textField回调函数
  293. */
  294. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  295. {
  296. NSCharacterSet *cs;
  297. if(textField == _txtSalesQuantity)
  298. {
  299. cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
  300. NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  301. BOOL basicTest = [string isEqualToString:filtered];
  302. if(!basicTest)
  303. {
  304. return NO;
  305. }
  306. }
  307. if(textField == _txtSalesPrice)
  308. {
  309. cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
  310. NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  311. BOOL basicTest = [string isEqualToString:filtered];
  312. if(!basicTest)
  313. {
  314. return NO;
  315. }
  316. }
  317. return YES;
  318. }
  319. /**
  320. textField失去焦点回调函数
  321. */
  322. - (void) textFieldDidEndEditing:(UITextField *) field
  323. {
  324. if(field.tag==1001){
  325. NSString *salesPrice=field.text;
  326. if(salesPrice==nil||[salesPrice isEqualToString:@""]||[salesPrice isEqualToString:@"."]){
  327. field.text = _inventoryModel.salesPrice;
  328. return;
  329. }
  330. _inventoryModel.salesPrice=salesPrice;
  331. double markedPrice= [ _inventoryModel.markedPrice doubleValue];
  332. if(markedPrice>0){
  333. double discount= [_inventoryModel.salesPrice doubleValue]/markedPrice*100;
  334. NSString *discountStr= [NSString stringWithFormat:@"%.2f",discount];
  335. _inventoryModel.discount=discountStr;
  336. }
  337. else{
  338. _inventoryModel.discount=@"100";
  339. }
  340. if([self.orderDelegate respondsToSelector:@selector(updateNewSalesGoodsDetail:textField:)])
  341. {
  342. [self.orderDelegate updateNewSalesGoodsDetail:self textField:_txtSalesPrice];
  343. }
  344. [self updateFrame];
  345. }
  346. else if(field.tag==1002){
  347. NSString *salesQuantity=field.text;
  348. if(salesQuantity==nil||[salesQuantity isEqualToString:@""]||[salesQuantity isEqualToString:@"."]){
  349. field.text = _inventoryModel.salesQuantity;
  350. return;
  351. }
  352. double salesQuantityValue=[salesQuantity doubleValue];
  353. NSInteger circulateType=_inventoryModel.circulateType;
  354. NSString *decimalPlaces=_inventoryModel.decimalPlaces;
  355. double acreage=_inventoryModel.acreage;
  356. OrderQuantity *quantity=[OrderQuantity new];
  357. salesQuantity= [quantity calculateNewOrderDetailQuantity:circulateType decimalPlaces:decimalPlaces quantity:salesQuantity acreage:acreage];
  358. _inventoryModel.salesQuantity=salesQuantity;
  359. field.text = _inventoryModel.salesQuantity;
  360. if([self.orderDelegate respondsToSelector:@selector(updateNewSalesGoodsDetail:textField:)])
  361. {
  362. [self.orderDelegate updateNewSalesGoodsDetail:self textField:_txtSalesQuantity];
  363. }
  364. }
  365. else if(field.tag==1003){
  366. NSString *remarks=field.text;
  367. if(remarks==nil){
  368. remarks=@"";
  369. }
  370. _inventoryModel.remarks=remarks;
  371. if([self.orderDelegate respondsToSelector:@selector(updateNewSalesGoodsDetail:textField:)])
  372. {
  373. [self.orderDelegate updateNewSalesGoodsDetail:self textField:_txtRemarks];
  374. }
  375. }
  376. }
  377. -(void)addQuantity{
  378. NSString *salesQuantity= _txtSalesQuantity.text;
  379. if(salesQuantity!=nil){
  380. if([salesQuantity isEqualToString:@"."]){
  381. return;
  382. }
  383. double quan=[salesQuantity doubleValue];
  384. NSInteger circulateType= _inventoryModel.circulateType;
  385. NSString *decimalPlaces=_inventoryModel.decimalPlaces;
  386. double acreage=_inventoryModel.acreage;
  387. if(circulateType==2){
  388. if([self.orderDelegate respondsToSelector:@selector(showNewOrderDetailError:)])
  389. {
  390. [self.orderDelegate showNewOrderDetailError:@"请手动输入商品数量"];
  391. return;
  392. }
  393. }
  394. ++quan;
  395. salesQuantity=[NSString stringWithFormat:@"%lf",quan];
  396. OrderQuantity *quantity=[OrderQuantity new];
  397. salesQuantity= [quantity calculateNewOrderDetailQuantity:circulateType decimalPlaces:decimalPlaces quantity:salesQuantity acreage:acreage];
  398. _inventoryModel.salesQuantity=salesQuantity;
  399. _txtSalesQuantity.text = _inventoryModel.salesQuantity;
  400. if([self.orderDelegate respondsToSelector:@selector(updateNewSalesGoodsDetail:textField:)])
  401. {
  402. [self.orderDelegate updateNewSalesGoodsDetail:self textField:_txtSalesQuantity];
  403. }
  404. }
  405. }
  406. -(void)substractQuantity{
  407. NSString *salesQuantity= _txtSalesQuantity.text;
  408. if(salesQuantity!=nil){
  409. if([salesQuantity isEqualToString:@"."]){
  410. return;
  411. }
  412. double quan=[salesQuantity doubleValue];
  413. NSInteger circulateType= _inventoryModel.circulateType;
  414. NSString *decimalPlaces=_inventoryModel.decimalPlaces;
  415. double acreage=_inventoryModel.acreage;
  416. if(circulateType==2){
  417. if([self.orderDelegate respondsToSelector:@selector(showNewOrderDetailError:)])
  418. {
  419. [self.orderDelegate showNewOrderDetailError:@"请手动输入商品数量"];
  420. return;
  421. }
  422. }
  423. --quan;
  424. if(quan<0){
  425. quan=0;
  426. }
  427. salesQuantity=[NSString stringWithFormat:@"%lf",quan];
  428. OrderQuantity *quantity=[OrderQuantity new];
  429. salesQuantity= [quantity calculateNewOrderDetailQuantity:circulateType decimalPlaces:decimalPlaces quantity:salesQuantity acreage:acreage];
  430. _inventoryModel.salesQuantity=salesQuantity;
  431. _txtSalesQuantity.text = _inventoryModel.salesQuantity;
  432. if([self.orderDelegate respondsToSelector:@selector(updateNewSalesGoodsDetail:textField:)])
  433. {
  434. [self.orderDelegate updateNewSalesGoodsDetail:self textField:_txtSalesQuantity];
  435. }
  436. }
  437. }
  438. -(void)clickUsePosition{
  439. if([self.orderDelegate respondsToSelector:@selector(goUsePosition:)])
  440. {
  441. [self.orderDelegate goUsePosition:_cellIndex];
  442. }
  443. }
  444. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  445. [super setSelected:selected animated:animated];
  446. }
  447. /**
  448. 更新标价和折扣
  449. */
  450. - (void) updateFrame{
  451. NSString *discount=_inventoryModel.discount;
  452. if(discount==nil){
  453. discount=@"0.0%";
  454. }
  455. else{
  456. discount=[NSString stringWithFormat:@"%@%@",discount,@"%"];
  457. }
  458. NSString *markedPrice=_inventoryModel.markedPrice;
  459. _lblDiscount.text = [NSString stringWithFormat:@"标价:%@ 折扣:%@",markedPrice,discount];
  460. _lblDiscount.font = [UIFont systemFontOfSize:13];
  461. _lblDiscount.textColor = [UIColor redColor];
  462. [_lblDiscount sizeToFit];
  463. _lblDiscount.frame = CGRectMake(Screen_Width-CGRectGetWidth(_lblDiscount.frame)-10, CGRectGetMaxY(_middleSeparator.frame)+10, CGRectGetWidth(_lblDiscount.frame), CGRectGetHeight(_lblDiscount.frame));
  464. }
  465. @end