InventorySearchCell.m 9.7 KB

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