NewDispatchRequirementCell.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. //
  2. // NewDeliveryRequirementCell.m
  3. // IBOSSHSH
  4. //
  5. // Created by ssl on 2018/1/15.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "NewDispatchRequirementCell.h"
  9. #import "OrderQuantity.h"
  10. #import "UIColor+hexColor.h"
  11. #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  12. #define kTitleFont [UIFont systemFontOfSize:15]
  13. @implementation NewDispatchRequirementCell
  14. #pragma mark - 公共函数
  15. /**
  16. 初始化单元格
  17. @param style <#style description#>
  18. @param reuseIdentifier <#reuseIdentifier description#>
  19. @return <#return value description#>
  20. */
  21. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  22. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  23. if (self) {
  24. }
  25. return self;
  26. }
  27. /**
  28. 单元格选中事件
  29. @param selected <#selected description#>
  30. @param animated <#animated description#>
  31. */
  32. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  33. }
  34. #pragma mark - 委托函数
  35. /**
  36. 限制用户输入小数点后位数的方法
  37. @param textField <#textField description#>
  38. @param range <#range description#>
  39. @param string <#string description#>
  40. @return <#return value description#>
  41. */
  42. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  43. if([textField isEqual:self.remark]){
  44. return YES;
  45. }
  46. if ([textField.text rangeOfString:@"."].location == NSNotFound) {
  47. _isHaveDian = NO;
  48. }
  49. if ([string length] > 0) {
  50. unichar single = [string characterAtIndex:0];//当前输入的字符
  51. if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
  52. //首字母不能为0和小数点
  53. if([textField.text length] == 0){
  54. if(single == '.') {
  55. [self showAlertViewText:@"第一个数字不能为小数点"];
  56. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  57. return NO;
  58. }
  59. }
  60. if([textField.text length] == 1 && [[textField.text substringToIndex:1] isEqualToString: @"0"]){
  61. if(!(single == '.')) {
  62. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  63. return NO;
  64. }
  65. }
  66. //输入的字符是否是小数点
  67. if (single == '.') {
  68. if(!_isHaveDian)//text中还没有小数点
  69. {
  70. _isHaveDian = YES;
  71. return YES;
  72. }else{
  73. [self showAlertViewText:@"您已经输入过小数点了"];
  74. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  75. return NO;
  76. }
  77. }else{
  78. if (_isHaveDian) {//存在小数点
  79. //判断小数点的位数
  80. NSRange ran = [textField.text rangeOfString:@"."];
  81. if (range.location - ran.location <= 6) {
  82. return YES;
  83. }
  84. else{
  85. return NO;
  86. }
  87. }else{
  88. return YES;
  89. }
  90. }
  91. }else{//输入的数据格式不正确
  92. [self showAlertViewText:@"您输入的格式不正确"];
  93. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  94. return NO;
  95. }
  96. }
  97. else
  98. {
  99. return YES;
  100. }
  101. }
  102. /**
  103. 文本字段开始编辑回调
  104. @param textField <#textField description#>
  105. */
  106. - (void)textFieldDidBeginEditing:(UITextField *)textField{
  107. NSLog(@"textFieldDidBeginEditing");
  108. if([textField isEqual:self.remark]||[textField isEqual:self.receiptQuantity]||[textField isEqual:self.installReceiptQuantity]){
  109. if([self.nddelegate respondsToSelector:@selector(keyboardWillShow:)])
  110. {
  111. [self.nddelegate keyboardWillShow:self];
  112. }
  113. }
  114. }
  115. /**
  116. 文本字段结束编辑回调
  117. @param textField <#textField description#>
  118. */
  119. - (void)textFieldDidEndEditing:(UITextField *)textField{
  120. if([textField isEqual:self.remark]){
  121. if([self.nddelegate respondsToSelector:@selector(keyboardWillHide:)])
  122. {
  123. [self.nddelegate keyboardWillHide:self];
  124. }
  125. }else if([textField isEqual:self.receiptQuantity]){
  126. OrderQuantity *quantity = [OrderQuantity new];
  127. NSInteger decimalPlaces= self.ml.decimalPlaces;
  128. NSString *receiptQuantity = [quantity calculateReceiptQuantity:[self.ml.circulateType integerValue] decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:self.receiptQuantity.text acreage:[self.ml.acreage doubleValue]];
  129. self.receiptQuantity.text = receiptQuantity;
  130. self.ml.receiptQuantity = self.receiptQuantity.text;
  131. [self.nddelegate keyboardWillHide:self];
  132. }
  133. else if([textField isEqual:self.installReceiptQuantity]){
  134. OrderQuantity *quantity = [OrderQuantity new];
  135. NSInteger decimalPlaces= self.ml.decimalPlaces;
  136. NSString *receiptQuantity = [quantity calculateReceiptQuantity:[self.ml.circulateType integerValue] decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:self.installReceiptQuantity.text acreage:[self.ml.acreage doubleValue]];
  137. self.installReceiptQuantity.text = receiptQuantity;
  138. self.ml.installReceiptQuantity = self.installReceiptQuantity.text;
  139. [self.nddelegate keyboardWillHide:self];
  140. }
  141. if([self.nddelegate respondsToSelector:@selector(endEdit:)])
  142. {
  143. [self.nddelegate endEdit:self];
  144. }
  145. return ;
  146. }
  147. #pragma mark - 私有函数
  148. /**
  149. 设置配送回执单元格UI和数据
  150. @param model <#model description#>
  151. @param receiptType <#receiptType description#>
  152. */
  153. - (void)parseInfoModel:(NewDispatchRequirementModel *)model receiptType:(NSString*)receiptType receiptFlag:(NSString*)receiptFlag{
  154. if(model != nil){
  155. _sReceiptType=receiptType;
  156. _ml=model;
  157. UILabel *lblOnlyCode = [UILabel new];
  158. lblOnlyCode.frame=CGRectMake(20, 8, 80,21);
  159. lblOnlyCode.text = @"唯一编码:";
  160. lblOnlyCode.font=kTitleFont;
  161. [self.contentView addSubview:lblOnlyCode];
  162. self.lblOnlyCode = [UILabel new];
  163. self.lblOnlyCode.font=kTitleFont;
  164. self.lblOnlyCode.frame=CGRectMake(95, 8,SCREENWIDTH-CGRectGetMaxX(lblOnlyCode.frame),21);
  165. [self.contentView addSubview:self.lblOnlyCode];
  166. self.lblOnlyCode.text=model.onlyCode;
  167. UILabel *lblCode = [UILabel new];
  168. lblCode.frame=CGRectMake(20, CGRectGetMaxY(lblOnlyCode.frame)+10, 80,21);
  169. lblCode.text = @"商品编码:";
  170. lblCode.font=kTitleFont;
  171. [self.contentView addSubview:lblCode];
  172. self.code = [UILabel new];
  173. self.code.font=kTitleFont;
  174. self.code.frame=CGRectMake(95, CGRectGetMaxY(lblOnlyCode.frame)+10,SCREENWIDTH-CGRectGetMaxX(lblCode.frame),21);
  175. [self.contentView addSubview:self.code];
  176. UILabel *lblGoodsName = [UILabel new];
  177. lblGoodsName.frame=CGRectMake(20,CGRectGetMaxY(lblCode.frame)+10, 80,21);
  178. lblGoodsName.text = @"商品名称:";
  179. lblGoodsName.font=kTitleFont;
  180. [self.contentView addSubview:lblGoodsName];
  181. self.goodsName = [UILabel new];
  182. self.goodsName.font=kTitleFont;
  183. self.goodsName.frame=CGRectMake(95, CGRectGetMaxY(lblCode.frame)+10,SCREENWIDTH-CGRectGetMaxX(lblGoodsName.frame),21);
  184. [self.contentView addSubview:self.goodsName];
  185. UILabel *lblDeliveryQuantity = [UILabel new];
  186. lblDeliveryQuantity.frame=CGRectMake(20, CGRectGetMaxY(lblGoodsName.frame)+10,80, 21);
  187. lblDeliveryQuantity.font=kTextFont;
  188. lblDeliveryQuantity.text = @"送货数量:";
  189. [self.contentView addSubview:lblDeliveryQuantity];
  190. self.deliveryQuantity = [UILabel new];
  191. self.deliveryQuantity.font=kTextFont;
  192. self.deliveryQuantity.frame=CGRectMake(95, CGRectGetMaxY(lblGoodsName.frame)+10, 200, 21);
  193. [self.contentView addSubview:self.deliveryQuantity];
  194. UILabel *lbTitleInstallQuantity = [UILabel new];
  195. lbTitleInstallQuantity.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblGoodsName.frame)+10,75,21);
  196. lbTitleInstallQuantity.text = [NSString stringWithFormat:@"安装数量:"];
  197. lbTitleInstallQuantity.font=kTextFont;
  198. [self.contentView addSubview:lbTitleInstallQuantity];
  199. UILabel *lbInstallQuantity = [UILabel new];
  200. lbInstallQuantity.frame=CGRectMake(CGRectGetMaxX(lbTitleInstallQuantity.frame),CGRectGetMaxY(lblGoodsName.frame)+10,75,21);
  201. lbInstallQuantity.font=kTextFont;
  202. [self.contentView addSubview:lbInstallQuantity];
  203. lbInstallQuantity.text=model.installQuantity;
  204. UILabel *lblTitleDeliveryFinishQuantity = [UILabel new];
  205. lblTitleDeliveryFinishQuantity.frame=CGRectMake(20, CGRectGetMaxY(lblDeliveryQuantity.frame)+10,100, 21);
  206. lblTitleDeliveryFinishQuantity.font=kTextFont;
  207. lblTitleDeliveryFinishQuantity.text = @"已送货数量:";
  208. [self.contentView addSubview:lblTitleDeliveryFinishQuantity];
  209. self.lblFinalDeliveryReceiptQuantity = [UILabel new];
  210. self.lblFinalDeliveryReceiptQuantity.font=kTextFont;
  211. self.lblFinalDeliveryReceiptQuantity.frame=CGRectMake(120, CGRectGetMaxY(lblDeliveryQuantity.frame)+10, 200, 21);
  212. [self.contentView addSubview:self.lblFinalDeliveryReceiptQuantity];
  213. self.lblFinalDeliveryReceiptQuantity.text=model.finalDeliveryReceiptQuantity;
  214. UILabel *lbTitleFinalInstallQuantity = [UILabel new];
  215. lbTitleFinalInstallQuantity.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblDeliveryQuantity.frame)+10,100,21);
  216. lbTitleFinalInstallQuantity.text = [NSString stringWithFormat:@"已安装数量:"];
  217. lbTitleFinalInstallQuantity.font=kTextFont;
  218. [self.contentView addSubview:lbTitleFinalInstallQuantity];
  219. _lblFinalInstallReceiptQuantity = [UILabel new];
  220. _lblFinalInstallReceiptQuantity.frame=CGRectMake(CGRectGetMaxX(lbTitleFinalInstallQuantity.frame),CGRectGetMaxY(lblDeliveryQuantity.frame)+10,200,21);
  221. _lblFinalInstallReceiptQuantity.font=kTextFont;
  222. [self.contentView addSubview:_lblFinalInstallReceiptQuantity];
  223. _lblFinalInstallReceiptQuantity.text=model.finalInstallReceiptQuantity;
  224. UILabel *lblTitleOutQuantity = [UILabel new];
  225. lblTitleOutQuantity.frame=CGRectMake(20, CGRectGetMaxY(lblTitleDeliveryFinishQuantity.frame)+10,100, 21);
  226. lblTitleOutQuantity.font=kTextFont;
  227. lblTitleOutQuantity.text = @"出库数量:";
  228. [self.contentView addSubview:lblTitleOutQuantity];
  229. self.lblOutQuantity = [UILabel new];
  230. self.lblOutQuantity.font=kTextFont;
  231. self.lblOutQuantity.frame=CGRectMake(120, CGRectGetMaxY(lblTitleDeliveryFinishQuantity.frame)+10,SCREENWIDTH-120, 21);
  232. [self.contentView addSubview:self.lblOutQuantity];
  233. self.lblOutQuantity.text=model.outQuantity;
  234. UILabel *lblReceiptType = [UILabel new];
  235. lblReceiptType.frame=CGRectMake(20,CGRectGetMaxY(lblTitleOutQuantity.frame)+10, 100,21);
  236. lblReceiptType.text = @"配送回执类型:";
  237. lblReceiptType.font=kTextFont;
  238. [self.contentView addSubview:lblReceiptType];
  239. self.btstate = [UIButton buttonWithType:UIButtonTypeCustom];
  240. self.btstate.frame=CGRectMake(CGRectGetMaxX(lblReceiptType.frame),CGRectGetMaxY(lblTitleOutQuantity.frame)+10,80, 21);
  241. self.btstate.titleLabel.font=kTextFont;
  242. self.btstate.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  243. [self.btstate setTitle:model.receiptTypeName forState:UIControlStateNormal];
  244. [self.btstate setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  245. [self.contentView addSubview:self.btstate];
  246. UILabel *lblInstallReceiptType = [UILabel new];
  247. lblInstallReceiptType.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblTitleOutQuantity.frame)+10, 100,21);
  248. lblInstallReceiptType.text = @"安装回执类型:";
  249. lblInstallReceiptType.font=kTextFont;
  250. [self.contentView addSubview:lblInstallReceiptType];
  251. self.btnInstallState = [UIButton buttonWithType:UIButtonTypeCustom];
  252. self.btnInstallState.frame=CGRectMake(CGRectGetMaxX(lblInstallReceiptType.frame),CGRectGetMaxY(lblTitleOutQuantity.frame)+10,80, 21);
  253. self.btnInstallState.titleLabel.font=kTextFont;
  254. self.btnInstallState.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  255. [self.btnInstallState setTitle:model.installReceiptTypeName forState:UIControlStateNormal];
  256. [self.btnInstallState setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
  257. [self.contentView addSubview:self.btnInstallState];
  258. UILabel *lblReceiptQuantity = [UILabel new];
  259. lblReceiptQuantity.frame=CGRectMake(20,CGRectGetMaxY(lblReceiptType.frame)+10,100,21);
  260. lblReceiptQuantity.text = @"配送回执数量:";
  261. lblReceiptQuantity.font=kTextFont;
  262. [lblReceiptQuantity setTextColor:[UIColor blackColor]];
  263. [self.contentView addSubview:lblReceiptQuantity];
  264. self.receiptQuantity = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lblReceiptQuantity.frame),CGRectGetMaxY(lblReceiptType.frame)+10,Screen_Width/2-CGRectGetMaxX(lblReceiptQuantity.frame),21)];
  265. self.receiptQuantity.font=kTextFont;
  266. [self.contentView addSubview:self.receiptQuantity];
  267. UILabel *lblInstallQuantity = [UILabel new];
  268. lblInstallQuantity.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblReceiptType.frame)+10,100,21);
  269. lblInstallQuantity.text = @"安装回执数量:";
  270. lblInstallQuantity.font=kTextFont;
  271. [lblInstallQuantity setTextColor:[UIColor hexColor:@"c32000"]];
  272. [self.contentView addSubview:lblInstallQuantity];
  273. self.installReceiptQuantity = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lblInstallQuantity.frame),CGRectGetMaxY(lblReceiptType.frame)+10,200,21)];
  274. self.installReceiptQuantity.font=kTextFont;
  275. self.installReceiptQuantity.placeholder = @"请输入安装回执数量";
  276. [self.contentView addSubview:self.installReceiptQuantity];
  277. UILabel *lblRemarks = [UILabel new];
  278. lblRemarks.frame=CGRectMake(20,CGRectGetMaxY(lblReceiptQuantity.frame)+10,80,21);
  279. lblRemarks.text = @"回执备注:";
  280. lblRemarks.font=kTextFont;
  281. [self.contentView addSubview:lblRemarks];
  282. self.remark = [[UITextField alloc]initWithFrame:CGRectMake(95,CGRectGetMaxY(lblReceiptQuantity.frame)+10,200,21)];
  283. self.remark.font=kTextFont;
  284. [self.contentView addSubview:self.remark];
  285. UIView *separatorView = [UIView new];
  286. separatorView.frame=CGRectMake(0,CGRectGetMaxY(lblRemarks.frame)+10, Screen_Width, 1);
  287. separatorView.backgroundColor=LineBackgroundColor;
  288. [self.contentView addSubview:separatorView];
  289. if([receiptType intValue] == 1){
  290. if([receiptFlag intValue]==1)
  291. {
  292. [self.btstate setEnabled:YES];
  293. [self.btnInstallState setEnabled:NO];
  294. self.installReceiptQuantity.enabled=NO;
  295. [lblReceiptType setTextColor:[UIColor hexColor:@"c32000"]];
  296. [lblReceiptQuantity setTextColor:[UIColor hexColor:@"c32000"]];
  297. [ lblInstallReceiptType setTextColor:[UIColor blackColor]];
  298. [lblInstallQuantity setTextColor:[UIColor blackColor]];
  299. }
  300. if([receiptFlag intValue]==2)
  301. {
  302. [self.btstate setEnabled:NO];
  303. [self.btnInstallState setEnabled:YES];
  304. self.receiptQuantity.enabled=NO;
  305. [ lblInstallReceiptType setTextColor:[UIColor hexColor:@"c32000"]];
  306. [lblInstallQuantity setTextColor:[UIColor hexColor:@"c32000"]];
  307. [lblReceiptType setTextColor:[UIColor blackColor]];
  308. [lblReceiptQuantity setTextColor:[UIColor blackColor]];
  309. }
  310. if([receiptFlag intValue]==3)
  311. {
  312. [self.btstate setEnabled:YES];
  313. [self.btnInstallState setEnabled:YES];
  314. [ lblInstallReceiptType setTextColor:[UIColor hexColor:@"c32000"]];
  315. [lblInstallQuantity setTextColor:[UIColor hexColor:@"c32000"]];
  316. [lblReceiptType setTextColor:[UIColor hexColor:@"c32000"]];
  317. [lblReceiptQuantity setTextColor:[UIColor hexColor:@"c32000"]];
  318. }
  319. if ([model.receiptType isEqualToString:@"0"]) {
  320. self.receiptQuantity.enabled= NO;
  321. }
  322. if ([model.receiptType isEqualToString:@"1"]) {
  323. self.receiptQuantity.enabled= NO;
  324. }
  325. if ([model.receiptType isEqualToString:@"2"]) {
  326. self.receiptQuantity.enabled= YES;
  327. }
  328. if ([model.installReceiptType isEqualToString:@"0"]) {
  329. self.installReceiptQuantity.enabled= NO;
  330. }
  331. if ([model.installReceiptType isEqualToString:@"5"]) {
  332. self.installReceiptQuantity.enabled= YES;
  333. }
  334. if([model.installReceiptType isEqualToString:@"1"]){
  335. [self.btnInstallState setTitle:@"完成" forState:UIControlStateNormal];
  336. self.installReceiptQuantity.enabled= NO;
  337. }
  338. }
  339. else if([receiptType intValue] == 2){
  340. [self.btstate setEnabled:NO];
  341. [self.btnInstallState setEnabled:NO];
  342. self.receiptQuantity.enabled=NO;
  343. self.installReceiptQuantity.enabled=NO;
  344. [lblInstallReceiptType setTextColor:[UIColor blackColor]];
  345. [lblInstallQuantity setTextColor:[UIColor blackColor]];
  346. [lblReceiptType setTextColor:[UIColor blackColor]];
  347. [lblReceiptQuantity setTextColor:[UIColor blackColor]];
  348. }
  349. self.sCode=model.code;
  350. self.sDeliveryQuantity=model.deliveryQuantity;
  351. self.sReceiptType=model.receiptType;
  352. self.sReceiptRemarks=model.receiptRemarks;
  353. self.sOutQuantity=model.outQuantity;
  354. self.sDetailID=model.detailId;
  355. self.sInvoiceID=model.invoiceId;
  356. self.sInvoiceDetailID=model.invoiceDetailId;
  357. self.code.text=_sCode;
  358. self.deliveryQuantity.text=_sDeliveryQuantity;
  359. self.goodsName.text=model.goodsName;
  360. self.outQuantity.text=_sOutQuantity;
  361. self.remark.text=_sReceiptRemarks;
  362. self.remark.placeholder = @"请输入回执备注";
  363. self.remark.delegate=self;
  364. self.remark.tag=1001;
  365. self.receiptQuantity.delegate=self;
  366. self.receiptQuantity.placeholder = @"请输入回执数量";
  367. self.receiptQuantity.keyboardType=UIKeyboardTypeDecimalPad;
  368. self.receiptQuantity.tag=1000;
  369. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFocusPeopleEditingChanged:) name:@"UITextFieldTextDidChangeNotification" object: self.receiptQuantity];
  370. // [self.receiptQuantity addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  371. // [self.remark addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  372. [self.btstate addTarget:self action:@selector(btnCilck) forControlEvents:UIControlEventTouchUpInside];
  373. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFocusPeopleEditingChanged:) name:@"UITextFieldTextDidChangeNotification" object: self.installReceiptQuantity];
  374. self.installReceiptQuantity.delegate=self;
  375. self.installReceiptQuantity.tag = 2000;
  376. self.installReceiptQuantity.keyboardType=UIKeyboardTypeDecimalPad;
  377. // [self.installReceiptQuantity addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  378. [self.btstate setTitle:model.receiptTypeName forState:UIControlStateNormal];
  379. [self.btnInstallState setTitle:model.installReceiptTypeName forState:UIControlStateNormal];
  380. self.installReceiptQuantity.text = model.installReceiptQuantity;
  381. self.receiptQuantity.text=model.receiptQuantity;
  382. [self.btnInstallState addTarget:self action:@selector(btnInstallStateCilck) forControlEvents:UIControlEventTouchUpInside];
  383. }
  384. }
  385. /**
  386. 安装状态
  387. */
  388. -(void) btnInstallStateCilck{
  389. if ([self.dispatchDelegate respondsToSelector:@selector(setInstallReceiptType:)]) {
  390. [self.dispatchDelegate setInstallReceiptType:_myIndexPath];
  391. }
  392. }
  393. - (void)setback:(int)mytage:(NSString *)mystateid{
  394. [self.btstate setTitle:@"退货" forState:UIControlStateNormal];
  395. self.outQuantity.text = @"5";
  396. _ml.outQuantity = @"5";
  397. }
  398. /**
  399. 文本框长度限制
  400. @param sender <#sender description#>
  401. */
  402. - (void)onFocusPeopleEditingChanged:(NSNotification *)sender
  403. {
  404. UITextField *textField = (UITextField *)sender.object;
  405. NSString *toBeString = textField.text;
  406. NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage;
  407. int kMaxLength=0;
  408. if([textField isEqual:self.receiptQuantity]||[textField isEqual:self.installReceiptQuantity]){
  409. kMaxLength=17;
  410. if (toBeString != nil && toBeString.length>0 && [toBeString floatValue]-MAXIMUM_QUANTITY>0.0000000001f) {
  411. textField.text = MAX_COUNT ;
  412. toBeString = MAX_COUNT;
  413. }
  414. }
  415. if ([lang isEqualToString:@"zh-Hans"]) {
  416. UITextRange *selectedRange = [textField markedTextRange];
  417. UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
  418. if (!position) {
  419. if (toBeString.length > kMaxLength) {
  420. textField.text = [toBeString substringToIndex:kMaxLength];
  421. }
  422. }
  423. }
  424. else{
  425. if (toBeString.length > kMaxLength) {
  426. textField.text = [toBeString substringToIndex:kMaxLength];
  427. }
  428. }
  429. }
  430. /**
  431. 出示警告对话框
  432. @param text <#text description#>
  433. */
  434. - (void)showAlertViewText:(NSString *)text
  435. {
  436. UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示"
  437. message:text
  438. delegate:nil
  439. cancelButtonTitle:@"确定"
  440. otherButtonTitles:nil];
  441. [alert show];
  442. }
  443. /**
  444. 回执类型点击事件
  445. */
  446. - (void)btnCilck{
  447. if ([self.dispatchDelegate respondsToSelector:@selector(setDeliveryReceiptType:)]) {
  448. [self.dispatchDelegate setDeliveryReceiptType:_myIndexPath];
  449. }
  450. }
  451. /**
  452. 文本字段变化事件
  453. @param sender <#sender description#>
  454. */
  455. - (void)textFieldDidChange:(UITextField*) sender{
  456. UITextField* txt=sender;
  457. if([self.nddelegate respondsToSelector:@selector(textValueChange:txtField:qualityField:remarkField:)])
  458. {
  459. [self.nddelegate textValueChange:self txtField:txt qualityField:nil remarkField:nil];
  460. }
  461. }
  462. @end