OtherInStorageGoodsListCell.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. //
  2. // OtherInStorageGoodsListCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/25.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "OtherInStorageGoodsListCell.h"
  9. @implementation OtherInStorageGoodsListCell
  10. #pragma mark 公共函数
  11. /**
  12. 加载 tableview cell
  13. @param style <#style description#>
  14. @param reuseIdentifier <#reuseIdentifier description#>
  15. @return <#return value description#>
  16. */
  17. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  18. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  19. return self;
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. }
  24. #pragma mark 委托函数
  25. /**
  26. textField失去焦点回调函数
  27. */
  28. - (void) textFieldDidEndEditing:(UITextField *) field
  29. {
  30. if(field.tag==1001){
  31. _inStorageGoodsListModel.enterPrice=field.text;
  32. if ([ _inStorageGoodsListModel.enterPrice doubleValue] >MAXIMUM_PRICE) {
  33. _inStorageGoodsListModel.enterPrice =[NSString stringWithFormat:@"%lf",MAXIMUM_PRICE];
  34. }
  35. }
  36. if(field.tag==1002){
  37. NSString *enterQuantity=field.text;
  38. if(enterQuantity!=nil){
  39. double enterQuantityValue=enterQuantity.doubleValue;
  40. NSInteger circulateType= _inStorageGoodsListModel.circulateType;
  41. NSString *quantity= [NSString stringWithFormat:@"%lf",enterQuantityValue];
  42. double acreage=[_inStorageGoodsListModel.acreage doubleValue];
  43. OrderQuantity *orderQuantity=[OrderQuantity new];
  44. int decimalPlaces= [_inStorageGoodsListModel.decimalPlaces intValue];
  45. NSString *calculateQuantity= [orderQuantity calculateOrderQuantity:circulateType decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:quantity acreage:acreage];
  46. _inStorageGoodsListModel.enterQuantity=calculateQuantity;
  47. field.text=calculateQuantity;
  48. }
  49. else{
  50. _inStorageGoodsListModel.enterQuantity=@"0";
  51. field.text=@"0";
  52. }
  53. }
  54. if(field.tag==1003){
  55. _inStorageGoodsListModel.colorNumber=field.text;
  56. }
  57. if([self.inStorageDelegate respondsToSelector:@selector(refreshTable)])
  58. {
  59. [self.inStorageDelegate refreshTable];
  60. }
  61. }
  62. - (void) textFieldDidChange:(UITextField *)textField
  63. {
  64. NSInteger kMaxLength =17;
  65. NSString *toBeString = textField.text;
  66. NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage; //ios7之前使用[UITextInputMode currentInputMode].primaryLanguage
  67. if ([lang isEqualToString:@"zh-Hans"]) { //中文输入
  68. UITextRange *selectedRange = [textField markedTextRange];
  69. //获取高亮部分
  70. UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
  71. if (!position) {// 没有高亮选择的字,则对已输入的文字进行字数统计和限制
  72. if (toBeString.length > kMaxLength) {
  73. textField.text = [toBeString substringToIndex:kMaxLength];
  74. }
  75. }
  76. else{//有高亮选择的字符串,则暂不对文字进行统计和限制
  77. }
  78. }else{//中文输入法以外的直接对其统计限制即可,不考虑其他语种情况
  79. if (toBeString.length > kMaxLength) {
  80. textField.text = [toBeString substringToIndex:kMaxLength];
  81. }
  82. }
  83. }
  84. /**
  85. 初始化其它入库 tableview cell
  86. @param goodsListModel <#goodsListModel description#>
  87. */
  88. -(void)setOtherInStorageGoodsModel:(OtherInStorageGoodsSearchListModel*) goodsListModel{
  89. _inStorageGoodsListModel=goodsListModel;
  90. if( _inStorageGoodsListModel==nil){
  91. return;
  92. }
  93. CGFloat heightLine = 1;
  94. CGFloat heightRow = 40;
  95. CGFloat lblx = 20;
  96. CGFloat lbly = 8;
  97. CGFloat lblwidth = 70;
  98. CGFloat lblheight = 25;
  99. CGFloat valuey = 8;
  100. CGFloat valueheight = 25;
  101. UIView *vGoodsName = [UIView new];
  102. vGoodsName.frame=CGRectMake(0,0, Screen_Width, heightRow);
  103. [self.contentView addSubview:vGoodsName];
  104. _lblGoodsName=[[UILabel alloc]init];
  105. _lblGoodsName.frame=CGRectMake(lblx, lbly,Screen_Width-85, valueheight);
  106. _lblGoodsName.text=_inStorageGoodsListModel.goodsName;
  107. _lblGoodsName.font=orderTextFont;
  108. [self.contentView addSubview:_lblGoodsName];
  109. _btnDelete=[UIButton buttonWithType:UIButtonTypeCustom];
  110. _btnDelete.frame=CGRectMake(Screen_Width-80,lbly,80, 25);
  111. [vGoodsName addSubview:_btnDelete];
  112. [_btnDelete addTarget:self action:@selector(deleteGoods) forControlEvents:UIControlEventTouchUpInside];
  113. UIImageView *deleteImg=[[UIImageView alloc]init];
  114. deleteImg.frame=CGRectMake(0,5,15,15);
  115. [deleteImg setImage:[UIImage imageNamed:@"icon_delete"]];
  116. deleteImg.userInteractionEnabled=NO;
  117. [_btnDelete addSubview:deleteImg];
  118. UILabel *deleteTitle=[[UILabel alloc]init];
  119. deleteTitle.frame=CGRectMake(CGRectGetMaxX(deleteImg.frame)+3,0,40, 25);
  120. deleteTitle.text=@"删除";
  121. deleteTitle.font=orderTextFont;
  122. [_btnDelete addSubview:deleteTitle];
  123. //分割线
  124. _topSeparator= [UIView new];
  125. _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(vGoodsName.frame), Screen_Width, heightLine);
  126. [self.contentView addSubview:_topSeparator];
  127. UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
  128. [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
  129. btnLine.frame = CGRectMake(0 ,0 , Screen_Width, heightLine);
  130. [_topSeparator addSubview:btnLine];
  131. //商品编码
  132. UIView *vGoodsCode = [UIView new];
  133. vGoodsCode.frame=CGRectMake(0, CGRectGetMaxY(_topSeparator.frame), Screen_Width/2, heightRow);
  134. [self.contentView addSubview:vGoodsCode];
  135. UILabel *lblGoodsCodeTitle=[UILabel new];
  136. lblGoodsCodeTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  137. lblGoodsCodeTitle.text=@"商品编码:";
  138. lblGoodsCodeTitle.textColor = [UIColor blackColor];
  139. lblGoodsCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  140. [vGoodsCode addSubview:lblGoodsCodeTitle];
  141. _lblGoodsCode = [UILabel new];
  142. _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblGoodsCodeTitle.frame), valueheight);
  143. _lblGoodsCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  144. [vGoodsCode addSubview:_lblGoodsCode];
  145. _lblGoodsCode.text = _inStorageGoodsListModel.code;
  146. //
  147. //唯一编码
  148. UIView *vOnlyCode = [UIView new];
  149. vOnlyCode.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(_topSeparator.frame), Screen_Width / 2, heightRow);
  150. [self.contentView addSubview: vOnlyCode];
  151. UILabel *lblOnlyCodeTitle=[UILabel new];
  152. lblOnlyCodeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  153. lblOnlyCodeTitle.text=@"唯一编码:";
  154. lblOnlyCodeTitle.textColor = [UIColor blackColor];
  155. lblOnlyCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  156. [vOnlyCode addSubview:lblOnlyCodeTitle];
  157. _lblOnlyCode= [UILabel new];
  158. _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  159. _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  160. [vOnlyCode addSubview:_lblOnlyCode];
  161. _lblOnlyCode.text = _inStorageGoodsListModel.onlyCode;
  162. UIView *vSpecification= [UIView new];
  163. vSpecification.frame=CGRectMake(lblx, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/2, heightRow);
  164. [self.contentView addSubview:vSpecification];
  165. UILabel *lblSpecificationTitle=[UILabel new];
  166. lblSpecificationTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  167. lblSpecificationTitle.text=@"规 格:";
  168. lblSpecificationTitle.textColor = [UIColor blackColor];
  169. lblSpecificationTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  170. [vSpecification addSubview:lblSpecificationTitle];
  171. _lblSpecification = [UILabel new];
  172. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame), valuey, vSpecification.frame.size.width -lblwidth, valueheight);
  173. _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  174. [vSpecification addSubview:_lblSpecification];
  175. _lblSpecification.text = _inStorageGoodsListModel.specification;
  176. UIView *vGrade= [UIView new];
  177. vGrade.frame=CGRectMake(Screen_Width/2, CGRectGetMaxY(vGoodsCode.frame),Screen_Width/2, heightRow);
  178. [self.contentView addSubview:vGrade];
  179. UILabel *lblGradeTitle=[UILabel new];
  180. lblGradeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  181. lblGradeTitle.text=@"等 级:";
  182. lblGradeTitle.textColor = [UIColor blackColor];
  183. lblGradeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  184. [vGrade addSubview:lblGradeTitle];
  185. _lblGrade = [UILabel new];
  186. _lblGrade.userInteractionEnabled=YES;
  187. _lblGrade.frame=CGRectMake(CGRectGetMaxX(lblGradeTitle.frame), lbly,vGrade.frame.size.width-lblwidth-5, valueheight);
  188. _lblGrade.text=@"请选择等级";
  189. UITapGestureRecognizer *tapRecognizerGrade=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goGrade:)];
  190. [_lblGrade addGestureRecognizer:tapRecognizerGrade];
  191. _lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  192. [vGrade addSubview:_lblGrade];
  193. if( _inStorageGoodsListModel.gradeName!=nil&&_inStorageGoodsListModel.gradeName.length>0){
  194. _lblGrade.text = _inStorageGoodsListModel.gradeName;
  195. }
  196. UIView *vColorNumber= [UIView new];
  197. vColorNumber.frame=CGRectMake(0, CGRectGetMaxY(vSpecification.frame), Screen_Width/2, heightRow);
  198. [self.contentView addSubview: vColorNumber];
  199. UILabel *lblColorNumberTitle=[UILabel new];
  200. lblColorNumberTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  201. lblColorNumberTitle.text=@"色 号:";
  202. lblColorNumberTitle.textColor = [UIColor blackColor];
  203. lblColorNumberTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  204. [vColorNumber addSubview:lblColorNumberTitle];
  205. _txtColorNumber= [UITextField new];
  206. _txtColorNumber.frame=CGRectMake(CGRectGetMaxX(lblColorNumberTitle.frame), valuey, vColorNumber.frame.size.width-lblwidth-5 , valueheight);
  207. _txtColorNumber.placeholder=@"请输入色号";
  208. _txtColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  209. _txtColorNumber.tag=1003;
  210. _txtColorNumber.delegate=self;
  211. [vColorNumber addSubview:_txtColorNumber];
  212. _txtColorNumber.text = _inStorageGoodsListModel.colorNumber;
  213. UIView *vBrand= [UIView new];
  214. vBrand.frame=CGRectMake(Screen_Width/2, CGRectGetMaxY(vSpecification.frame),Screen_Width/2, heightRow);
  215. [self.contentView addSubview:vBrand];
  216. UILabel *lblBrandTitle=[UILabel new];
  217. lblBrandTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  218. lblBrandTitle.text=@"品 牌:";
  219. lblBrandTitle.textColor = [UIColor blackColor];
  220. lblBrandTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  221. [vBrand addSubview:lblBrandTitle];
  222. _lblBrand = [UILabel new];
  223. _lblBrand.frame=CGRectMake(CGRectGetMaxX(lblBrandTitle.frame), lbly,vBrand.frame.size.width-lblwidth-5, valueheight);
  224. _lblBrand.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  225. [vBrand addSubview:_lblBrand];
  226. _lblBrand.text = _inStorageGoodsListModel.brandName;
  227. UIView *vWarehouse= [UIView new];
  228. vWarehouse.frame=CGRectMake(0, CGRectGetMaxY(vColorNumber.frame), Screen_Width, heightRow);
  229. [self.contentView addSubview: vWarehouse];
  230. UILabel *lblWarehouseTitle=[UILabel new];
  231. lblWarehouseTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  232. lblWarehouseTitle.text=@"库 区:";
  233. lblWarehouseTitle.textColor = [UIColor blackColor];
  234. lblWarehouseTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  235. [vWarehouse addSubview:lblWarehouseTitle];
  236. _lblWarehouse= [UILabel new];
  237. _lblWarehouse.frame=CGRectMake(CGRectGetMaxX(lblWarehouseTitle.frame), valuey, vWarehouse.frame.size.width-lblwidth-lblx-5 , valueheight);
  238. _lblWarehouse.userInteractionEnabled=YES;
  239. _lblWarehouse.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  240. [vWarehouse addSubview:_lblWarehouse];
  241. _lblWarehouse.text=@"请选择库区";
  242. UITapGestureRecognizer *tapRecognizerWarehouse=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goWarehouse:)];
  243. [_lblWarehouse addGestureRecognizer:tapRecognizerWarehouse];
  244. if(_inStorageGoodsListModel.warehouseName!=nil&&_inStorageGoodsListModel.warehouseName.length>0){
  245. _lblWarehouse.text = _inStorageGoodsListModel.warehouseName;
  246. }
  247. UIView *vPositionNumber= [UIView new];
  248. vPositionNumber.frame=CGRectMake(0, CGRectGetMaxY(vWarehouse.frame), Screen_Width, heightRow);
  249. [self.contentView addSubview: vPositionNumber];
  250. UILabel *lblPositionNumberTitle=[UILabel new];
  251. lblPositionNumberTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  252. lblPositionNumberTitle.text=@"仓 位 号:";
  253. lblPositionNumberTitle.textColor = [UIColor blackColor];
  254. lblPositionNumberTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  255. [vPositionNumber addSubview:lblPositionNumberTitle];
  256. _lblPostionNumber= [UILabel new];
  257. _lblPostionNumber.frame=CGRectMake(CGRectGetMaxX(lblPositionNumberTitle.frame), valuey, vPositionNumber.frame.size.width-lblwidth-lblx-5 , valueheight);
  258. _lblPostionNumber.userInteractionEnabled=YES;
  259. _lblPostionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  260. [vPositionNumber addSubview:_lblPostionNumber];
  261. _lblPostionNumber.text=@"请选择仓位号";
  262. UITapGestureRecognizer *tapRecognizerPositionNumber=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goPositionNumber:)];
  263. [_lblPostionNumber addGestureRecognizer:tapRecognizerPositionNumber];
  264. if(_inStorageGoodsListModel.positionNumberName!=nil&&_inStorageGoodsListModel.positionNumberName.length>0){
  265. _lblPostionNumber.text = _inStorageGoodsListModel.positionNumberName;
  266. }
  267. //分割线
  268. _middleSeparator= [UIView new];
  269. _middleSeparator.frame = CGRectMake(0, CGRectGetMaxY(vPositionNumber.frame), Screen_Width, heightLine);
  270. [_middleSeparator setBackgroundColor:LineBackgroundColor];
  271. [self.contentView addSubview:_middleSeparator];
  272. // NSDictionary *inStorageDict = @{NSFontAttributeName:orderTextFont};
  273. // UIView *vQuantity = [UIView new];
  274. // vQuantity.frame=CGRectMake(0, CGRectGetMaxY(_middleSeparator.frame), Screen_Width, heightRow);
  275. // [self.contentView addSubview:vQuantity];
  276. // _lblInventoryQuantity=[UILabel new];
  277. //
  278. // NSString *inventoryQuantity= _inStorageGoodsListModel.inventoryQuantity;
  279. // inventoryQuantity= [NSString stringWithFormat:@"%@%@",@"结存量:",inventoryQuantity];
  280. // CGRect inventoryQuantityFrame = [inventoryQuantity textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:inStorageDict];
  281. // inventoryQuantityFrame.origin.x =Screen_Width-inventoryQuantityFrame.size.width-10;
  282. // inventoryQuantityFrame.origin.y = valuey;
  283. //
  284. // _lblInventoryQuantity.frame=inventoryQuantityFrame;
  285. // _lblInventoryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  286. // _lblInventoryQuantity.textColor = [UIColor redColor];
  287. // _lblInventoryQuantity.text=inventoryQuantity;
  288. // [vQuantity addSubview:_lblInventoryQuantity];
  289. //
  290. // _lblCanSalesQuantity=[UILabel new];
  291. // NSString *canSalesQuantity=_inStorageGoodsListModel.canSalesQuantity;
  292. // canSalesQuantity=[NSString stringWithFormat:@"%@%@",@"可售量",canSalesQuantity];
  293. // CGRect canSalesQuantityFrame = [canSalesQuantity textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:inStorageDict];
  294. // canSalesQuantityFrame.origin.x =Screen_Width-inventoryQuantityFrame.size.width-canSalesQuantityFrame.size.width-10-5;
  295. // canSalesQuantityFrame.origin.y = valuey;
  296. //
  297. // _lblCanSalesQuantity.frame=canSalesQuantityFrame;
  298. // _lblCanSalesQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  299. // _lblCanSalesQuantity.textColor = [UIColor redColor];
  300. // _lblCanSalesQuantity.text=canSalesQuantity;
  301. // [vQuantity addSubview:_lblCanSalesQuantity];
  302. UIView *salesPriceView=[[UIView alloc]init];
  303. salesPriceView.layer.borderWidth=0.5f;
  304. salesPriceView.layer.borderColor=[UIColor blackColor].CGColor;
  305. salesPriceView.frame=CGRectMake(Screen_Width-280, CGRectGetMaxY(_middleSeparator.frame)+5, 115,25 );;
  306. [self.contentView addSubview: salesPriceView];
  307. UILabel *lblSymbol=[[UILabel alloc]init];
  308. lblSymbol.text=@"¥";
  309. lblSymbol.textColor=LabelGrayTextColor;
  310. lblSymbol.frame=CGRectMake(5,5,15,15);
  311. lblSymbol.font=orderTextFont;
  312. lblSymbol.textAlignment=NSTextAlignmentCenter;
  313. [salesPriceView addSubview:lblSymbol];
  314. _txtEnterPrice=[UITextField new];
  315. _txtEnterPrice.frame=CGRectMake(CGRectGetMaxX(lblSymbol.frame)+5, 0, 90, 25);
  316. _txtEnterPrice.userInteractionEnabled=YES;
  317. _txtEnterPrice.delegate=self;
  318. _txtEnterPrice.keyboardType=UIKeyboardTypeDecimalPad;
  319. _txtEnterPrice.tag=1001;
  320. _txtEnterPrice.text=_inStorageGoodsListModel.enterPrice;
  321. _txtEnterPrice.textAlignment=NSTextAlignmentCenter;
  322. _txtEnterPrice.font=orderTextFont;
  323. [_txtEnterPrice addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  324. [salesPriceView addSubview:_txtEnterPrice];
  325. UIButton *substractButton=[UIButton buttonWithType:UIButtonTypeCustom];
  326. [substractButton setTitle:@"-" forState:UIControlStateNormal];
  327. [substractButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  328. substractButton.frame=CGRectMake(CGRectGetMaxX(salesPriceView.frame)+10,CGRectGetMaxY(_middleSeparator.frame)+5,25,25);;
  329. substractButton.layer.borderColor=[UIColor blackColor].CGColor;
  330. substractButton.layer.borderWidth=0.5f;
  331. [substractButton addTarget:self action:@selector(substractQuantity) forControlEvents:UIControlEventTouchUpInside];
  332. [self.contentView addSubview:substractButton];
  333. _txtEnterQuantity=[UITextField new];
  334. _txtEnterQuantity.frame=CGRectMake(CGRectGetMaxX(substractButton.frame)-1,CGRectGetMaxY(_middleSeparator.frame)+5,100,25);;
  335. _txtEnterQuantity.delegate=self;
  336. _txtEnterQuantity.keyboardType=UIKeyboardTypeDecimalPad;
  337. _txtEnterQuantity.layer.borderWidth=0.5f;
  338. _txtEnterQuantity.tag=1002;
  339. [_txtEnterQuantity addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  340. _txtEnterQuantity.text=_inStorageGoodsListModel.enterQuantity;
  341. _txtEnterQuantity.textAlignment=NSTextAlignmentCenter;
  342. _txtEnterQuantity.layer.borderColor=[UIColor blackColor].CGColor;
  343. _txtEnterQuantity.font=orderTextFont;
  344. [self.contentView addSubview:_txtEnterQuantity];
  345. UIButton *addButton=[UIButton buttonWithType:UIButtonTypeCustom];
  346. [addButton setTitle:@"+" forState:UIControlStateNormal];
  347. [addButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  348. addButton.frame=CGRectMake(CGRectGetMaxX(_txtEnterQuantity.frame)-1,CGRectGetMaxY(_middleSeparator.frame)+5,25,25);
  349. addButton.layer.borderColor=[UIColor blackColor].CGColor;
  350. addButton.layer.borderWidth=0.5;
  351. [addButton addTarget:self action:@selector(addQuantity) forControlEvents:UIControlEventTouchUpInside];
  352. [self.contentView addSubview:addButton];
  353. //分割线
  354. _bottomSeparator= [UIView new];
  355. _bottomSeparator.frame = CGRectMake(0, CGRectGetMaxY(salesPriceView.frame)+5, Screen_Width, 10);
  356. [_bottomSeparator setBackgroundColor:LineBackgroundColor];
  357. [self.contentView addSubview:_bottomSeparator];
  358. }
  359. /**
  360. 跳转到等级页面
  361. @param gesture <#gesture description#>
  362. */
  363. -(void)goGrade:(UITapGestureRecognizer *)gesture{
  364. if([self.inStorageDelegate respondsToSelector:@selector(goGrade:) ]){
  365. [self.inStorageDelegate goGrade:_index];
  366. }
  367. }
  368. /**
  369. 跳转到库区页面
  370. @param gesture <#gesture description#>
  371. */
  372. -(void)goWarehouse:(UITapGestureRecognizer *)gesture{
  373. if([self.inStorageDelegate respondsToSelector:@selector(goWareHouse:) ]){
  374. [self.inStorageDelegate goWareHouse:_index];
  375. }
  376. }
  377. /**
  378. 跳转到仓位号页面
  379. @param gesture <#gesture description#>
  380. */
  381. -(void)goPositionNumber:(UITapGestureRecognizer *)gesture{
  382. if([self.inStorageDelegate respondsToSelector:@selector(goPositionNumber:) ]){
  383. [self.inStorageDelegate goPositionNumber:_index];
  384. }
  385. }
  386. /**
  387. 增加数量
  388. */
  389. -(void)addQuantity{
  390. NSString *enterQuantity=_txtEnterQuantity.text;
  391. if(enterQuantity!=nil){
  392. double quantityValue=enterQuantity.doubleValue;
  393. NSInteger circulateType= _inStorageGoodsListModel.circulateType;
  394. if(circulateType==2){
  395. #pragma clang diagnostic push
  396. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  397. UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"标题" message:@"请手动输入商品数量" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
  398. [ alert show];
  399. #pragma clang diagnostic pop
  400. return;
  401. }
  402. ++quantityValue;
  403. NSString *quantity= [NSString stringWithFormat:@"%lf",quantityValue];
  404. double acreage=[_inStorageGoodsListModel.acreage doubleValue];
  405. OrderQuantity *orderQuantity=[OrderQuantity new];
  406. int decimalPlaces= [_inStorageGoodsListModel.decimalPlaces intValue];
  407. NSString *calculateQuantity= [orderQuantity calculateOrderQuantity:circulateType decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:quantity acreage:acreage];
  408. _inStorageGoodsListModel.enterQuantity=calculateQuantity;
  409. _txtEnterQuantity.text=calculateQuantity;
  410. }
  411. else{
  412. _inStorageGoodsListModel.enterQuantity=@"0";
  413. _txtEnterQuantity.text=@"0";
  414. }
  415. if([self.inStorageDelegate respondsToSelector:@selector(refreshTable)])
  416. {
  417. [self.inStorageDelegate refreshTable];
  418. }
  419. }
  420. /**
  421. 减少数量
  422. */
  423. -(void)substractQuantity{
  424. NSString *enterQuantity=_txtEnterQuantity.text;
  425. if(enterQuantity!=nil){
  426. double quantityValue=enterQuantity.doubleValue;
  427. NSInteger circulateType= _inStorageGoodsListModel.circulateType;
  428. if(circulateType==2){
  429. UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"标题" message:@"请手动输入商品数量" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
  430. [ alert show];
  431. return;
  432. }
  433. --quantityValue;
  434. if(quantityValue<0){
  435. quantityValue=0;
  436. }
  437. NSString *quantity= [NSString stringWithFormat:@"%lld",(long long)quantityValue];
  438. double acreage=[_inStorageGoodsListModel.acreage doubleValue];
  439. OrderQuantity *orderQuantity=[OrderQuantity new];
  440. int decimalPlaces= [_inStorageGoodsListModel.decimalPlaces intValue];
  441. NSString *calculateQuantity= [orderQuantity calculateOrderQuantity:circulateType decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:quantity acreage:acreage];
  442. _txtEnterQuantity.text=calculateQuantity;
  443. _inStorageGoodsListModel.enterQuantity=calculateQuantity;
  444. }
  445. if([self.inStorageDelegate respondsToSelector:@selector(refreshTable)])
  446. {
  447. [self.inStorageDelegate refreshTable];
  448. }
  449. }
  450. /**
  451. 删除商品
  452. */
  453. -(void)deleteGoods{
  454. if([self.inStorageDelegate respondsToSelector:@selector(deleteGoods:)])
  455. {
  456. [self.inStorageDelegate deleteGoods:_index];
  457. }
  458. }
  459. @end