InventoryCostSearchCell.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. //
  2. // InventoryCostSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/11/16.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryCostSearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. @implementation InventoryCostSearchCell
  11. - (void)awakeFromNib {
  12. [super awakeFromNib];
  13. }
  14. /**
  15. 高度
  16. @return return value description
  17. */
  18. - (CGFloat)cellHeight {
  19. return 529.0f;
  20. }
  21. /**
  22. cell
  23. @param indexPath <#indexPath description#>
  24. @return <#return value description#>
  25. */
  26. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  27. InventoryCostSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"InventoryCostSearchCell" owner:nil options:nil][0];
  28. cell.txtCode.delegate = cell;
  29. cell.txtOnlyCode.delegate = cell;
  30. cell.txtSpecification.delegate=cell;
  31. [cell configureKeyboard];
  32. return cell;
  33. }
  34. /**
  35. 键盘配置
  36. */
  37. - (void)configureKeyboard {
  38. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  39. _txtCode.inputAccessoryView = keyBoardAccessoryView;
  40. _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
  41. _txtSpecification.inputAccessoryView = keyBoardAccessoryView;
  42. }
  43. /**
  44. 文本编辑时候 弹出取消完成按钮
  45. @return <#return value description#>
  46. */
  47. - (UIView *)createKeyBoardAccessoryView {
  48. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  49. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  50. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  51. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  52. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  53. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  54. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  55. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  56. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  57. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  58. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  59. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  60. [keyBoardAccessoryView addSubview:backButton];
  61. [keyBoardAccessoryView addSubview:doneButton];
  62. return keyBoardAccessoryView;
  63. }
  64. /**
  65. Identifier
  66. @return <#return value description#>
  67. */
  68. + (NSString *)cellReuseIdentifier {
  69. return @"InventoryCostSearchCell";
  70. }
  71. /**
  72. 更新model
  73. @param model <#model description#>
  74. @param indexPath <#indexPath description#>
  75. */
  76. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  77. self.regionModel = *model;
  78. // 1. 创建一个点击事件,点击时触发labelClick方法
  79. UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
  80. // 2. 将点击事件添加到label上
  81. [self.lblFilterZeroInventory addGestureRecognizer:labelTapGestureRecognizer];
  82. self.lblFilterZeroInventory.userInteractionEnabled = YES; // 可以理解为设置label可被点击
  83. self.lblFilterZeroInventory.layer.borderWidth = 1;
  84. self.lblFilterZeroInventory.layer.borderColor = [UIColor redColor].CGColor;
  85. self.isfilterQuantityEqZero = YES;
  86. self.lblFilterZeroInventory.text = @"已过滤";
  87. self.lblFilterZeroInventory.textColor = [UIColor redColor];
  88. // [self updateModel];
  89. }
  90. /**
  91. 零库存过滤
  92. */
  93. - (void)labelClick{
  94. if (self.isfilterQuantityEqZero) {
  95. self.lblFilterZeroInventory.layer.borderColor = [UIColor lightGrayColor].CGColor;
  96. self.isfilterQuantityEqZero = NO;
  97. self.lblFilterZeroInventory.text = @"未过滤";
  98. self.lblFilterZeroInventory.textColor = [UIColor lightGrayColor];
  99. }else{
  100. self.lblFilterZeroInventory.layer.borderColor = [UIColor redColor].CGColor;
  101. self.isfilterQuantityEqZero = YES;
  102. self.lblFilterZeroInventory.text = @"已过滤";
  103. self.lblFilterZeroInventory.textColor = [UIColor redColor];
  104. }
  105. [self updateModel];
  106. }
  107. /**
  108. 重置按钮 事件
  109. */
  110. - (void)resetData {
  111. [_txtOnlyCode setText:@""];
  112. [_txtCode setText:@""];
  113. [_txtSpecification setText:@""];
  114. [_btnWarehouseArea setTitle:@"请选择库区" forState:UIControlStateNormal];
  115. _warehouseId = @"";
  116. _wareid = @"";
  117. [_btnBrand setTitle:@"请选择品牌" forState:UIControlStateNormal];
  118. _brandId = @"";
  119. _lblFilterZeroInventory.text = @"已过滤";
  120. _isfilterQuantityEqZero= YES;
  121. _lblFilterZeroInventory.textColor = [UIColor redColor];
  122. }
  123. /**
  124. 长度
  125. @param textField <#textField description#>
  126. @param range <#range description#>
  127. @param string <#string description#>
  128. @return <#return value description#>
  129. */
  130. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  131. return YES;
  132. }
  133. /**
  134. 文本编辑结束事件
  135. @param textField <#textField description#>
  136. */
  137. - (void)textFieldDidEndEditing:(UITextField *)textField {
  138. [self updateModel];
  139. }
  140. /**
  141. 触摸事件
  142. @param touches <#touches description#>
  143. @param event <#event description#>
  144. */
  145. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  146. [self hideKey];
  147. [_txtCode resignFirstResponder];
  148. [_txtOnlyCode resignFirstResponder];
  149. [_txtSpecification resignFirstResponder];
  150. }
  151. /**
  152. 取消文本
  153. */
  154. - (void)accessoryButtonBack {
  155. [self hideKey];
  156. }
  157. /**
  158. 确定文本
  159. */
  160. - (void)accessoryButtonDone {
  161. [_txtCode resignFirstResponder];
  162. [_txtOnlyCode resignFirstResponder];
  163. [_txtSpecification resignFirstResponder];
  164. [self hideKey];
  165. }
  166. /**
  167. 库区,品牌回调函数
  168. @param model <#model description#>
  169. @param value <#value description#>
  170. */
  171. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)m BaseIDAndName:(baseIdAndName)value{
  172. if (value == baseIdAndNameWare) {
  173. _warehouseId = m.id;
  174. _wareid = m.warehouseId;//211110 add
  175. [self.btnWarehouseArea setTitle:m.name forState:UIControlStateNormal];
  176. }
  177. if (value == baseIdAndNameBrand) {
  178. _brandId = m.id;
  179. [self.btnBrand setTitle:m.name forState:UIControlStateNormal];
  180. }
  181. [self updateModel];
  182. }
  183. /**
  184. 更新model
  185. */
  186. - (void)updateModel{
  187. InventorySearchModel *model = [[InventorySearchModel alloc] init];
  188. model.onlyCode = [_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  189. model.goodsCode = [_txtCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  190. model.goodsSpecification = [_txtSpecification.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  191. model.warehouseId = _wareid;
  192. //model.whId = _wareid; //2111110
  193. model.brandId = _brandId;
  194. model.isfilterQuantityEqZero = _isfilterQuantityEqZero;
  195. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  196. [mutDict setValue:model forKey:INVENTORY_SEARCH_RANGE_MODEL];
  197. _regionModel.customDict = [mutDict copy];
  198. }
  199. /**
  200. * 隐藏键盘
  201. */
  202. - (void)hideKey
  203. {
  204. [self.contentView endEditing:YES];
  205. }
  206. - (IBAction)clickWarehouseAreaAction:(id)sender {
  207. WareSearchViewController *tc = [[WareSearchViewController alloc ]init];
  208. tc.bDelegate = self;
  209. tc.isPresentViewFlg = YES;
  210. tc.showDialogViewTag = baseIdAndNameWare;
  211. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  212. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  213. }
  214. }
  215. - (IBAction)clickBrandAction:(id)sender {
  216. BrandSearchViewController *tc = [[BrandSearchViewController alloc ]init];
  217. tc.bDelegate = self;
  218. tc.isPresentViewFlag = YES;
  219. tc.showDialogViewTag = baseIdAndNameBrand;
  220. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  221. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  222. }
  223. }
  224. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  225. [super setSelected:selected animated:animated];
  226. }
  227. @end