SalesInStorageGoodsSearchCell.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. //
  2. // SalesInStorageGoodsSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/24.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesInStorageGoodsSearchCell.h"
  9. @implementation SalesInStorageGoodsSearchCell
  10. #pragma mark 公共函数
  11. /**
  12. 加载xib函数
  13. */
  14. - (void)awakeFromNib {
  15. [super awakeFromNib];
  16. }
  17. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  18. [super setSelected:selected animated:animated];
  19. }
  20. #pragma mark 委托函数
  21. /**
  22. 重置按钮 事件
  23. */
  24. - (void)resetData {
  25. [_txtGoodsCode setText:@""];
  26. [_txtOnlyCode setText:@""];
  27. [_txtGoodsName setText:@""];
  28. _kindId=@"";
  29. _varietyId=@"";
  30. _brandId=@"";
  31. [self.btnKind setTitle:@"请选择种类" forState:UIControlStateNormal];
  32. [self.btnBrand setTitle:@"请选择品牌" forState:UIControlStateNormal];
  33. [self.btnVariety setTitle:@"请选择品种" forState:UIControlStateNormal];
  34. }
  35. /**
  36. 更新model
  37. @param model <#model description#>
  38. @param indexPath <#indexPath description#>
  39. */
  40. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  41. indexPath:(NSIndexPath *)indexPath{
  42. self.regionModel = *model;
  43. }
  44. /**
  45. cell
  46. @param indexPath <#indexPath description#>
  47. @return <#return value description#>
  48. */
  49. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  50. SalesInStorageGoodsSearchCell
  51. *cell = [[NSBundle mainBundle]
  52. loadNibNamed:@"SalesInStorageGoodsSearchCell"
  53. owner:nil
  54. options:nil][0];
  55. cell.txtGoodsCode.delegate=cell;
  56. cell.txtOnlyCode.delegate=cell;
  57. cell.txtGoodsName.delegate=cell;
  58. [cell configureKeyboard];
  59. return cell;
  60. }
  61. /**
  62. 高度
  63. @return return value description
  64. */
  65. - (CGFloat)cellHeight {
  66. return 472.5f;
  67. }
  68. /**
  69. 触摸事件
  70. @param touches <#touches description#>
  71. @param event <#event description#>
  72. */
  73. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  74. [self hideKey];
  75. [_txtGoodsCode resignFirstResponder];
  76. [_txtOnlyCode resignFirstResponder];
  77. [_txtGoodsName resignFirstResponder];
  78. }
  79. /**
  80. 长度
  81. @param textField <#textField description#>
  82. @param range <#range description#>
  83. @param string <#string description#>
  84. @return <#return value description#>
  85. */
  86. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  87. return YES;
  88. }
  89. /**
  90. 文本编辑结束事件
  91. @param textField <#textField description#>
  92. */
  93. - (void)textFieldDidEndEditing:(UITextField *)textField {
  94. [self updateModel];
  95. }
  96. /**
  97. Identifier
  98. @return <#return value description#>
  99. */
  100. + (NSString *)cellReuseIdentifier {
  101. return @"SalesInStorageGoodsSearchCell";
  102. }
  103. /**
  104. 库区,品牌回调函数
  105. @param model <#model description#>
  106. @param value <#value description#>
  107. */
  108. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)m BaseIDAndName:(baseIdAndName)value{
  109. if (value == baseIdAndNameBrand) {
  110. _brandId = m.id;
  111. [self.btnBrand setTitle:m.name forState:UIControlStateNormal];
  112. }
  113. [self updateModel];
  114. }
  115. /**
  116. 种类,品种返回回调
  117. @param model <#model description#>
  118. @param cr <#cr description#>
  119. */
  120. - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr
  121. {
  122. if (model==nil) {
  123. return;
  124. }
  125. //渠道返回值
  126. if(cr==ReportKind){
  127. _kindId=model.idCode;
  128. _kindCode=model.code;
  129. [self.btnKind setTitle:model.name forState:UIControlStateNormal];
  130. }
  131. if(cr==ReportVariety){
  132. _varietyId=model.idCode;
  133. [self.btnVariety setTitle:model.name forState:UIControlStateNormal];
  134. }
  135. [self updateModel];
  136. }
  137. #pragma mark 私有函数
  138. /**
  139. 键盘配置
  140. */
  141. - (void)configureKeyboard {
  142. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  143. _txtGoodsCode.inputAccessoryView = keyBoardAccessoryView;
  144. _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
  145. _txtGoodsName.inputAccessoryView = keyBoardAccessoryView;
  146. }
  147. /**
  148. 取消文本
  149. */
  150. - (void)accessoryButtonBack {
  151. [self hideKey];}
  152. /**
  153. 确定文本
  154. */
  155. - (void)accessoryButtonDone {
  156. [_txtGoodsCode resignFirstResponder];
  157. [_txtOnlyCode resignFirstResponder];
  158. [_txtGoodsName resignFirstResponder];
  159. [self hideKey];
  160. }
  161. /**
  162. * 隐藏键盘
  163. */
  164. -(void)hideKey
  165. {
  166. [self.contentView endEditing:YES];
  167. }
  168. /**
  169. 文本编辑时候 弹出取消完成按钮
  170. @return <#return value description#>
  171. */
  172. - (UIView *)createKeyBoardAccessoryView {
  173. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  174. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  175. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  176. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  177. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  178. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  179. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  180. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  181. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  182. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  183. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  184. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  185. [keyBoardAccessoryView addSubview:backButton];
  186. [keyBoardAccessoryView addSubview:doneButton];
  187. return keyBoardAccessoryView;
  188. }
  189. /**
  190. 更新model
  191. */
  192. - (void)updateModel{
  193. OtherInStorageGoodsSearchModel *model = [[OtherInStorageGoodsSearchModel alloc] init];
  194. _goodsCode = [_txtGoodsCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  195. _goodsName=[_txtGoodsName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  196. _onlyCode=[_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  197. model.goodsCode=_goodsCode;
  198. model.goodsName=_goodsName;
  199. model.onlyCode=_onlyCode;
  200. model.brandId=_brandId;
  201. model.kindId=_kindId;
  202. model.kindCode=_kindCode;
  203. model.varietyId=_varietyId;
  204. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  205. [mutDict setValue:model forKey:In_STORAGE_SEARCH_RANGE_MODEL];
  206. _regionModel.customDict = [mutDict copy];
  207. }
  208. /**
  209. 点击种类事件
  210. @param sender <#sender description#>
  211. */
  212. - (IBAction)clickKindAction:(id)sender {
  213. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  214. tc.delegate=self;
  215. tc.dataSourceCode=@"T_MST_Goods_Kind";
  216. tc.isPresentViewFlag = YES;
  217. tc.showDialogViewTag=ReportKind;
  218. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  219. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  220. }
  221. }
  222. /**
  223. 点击品牌事件
  224. @param sender <#sender description#>
  225. */
  226. - (IBAction)clickBrandAction:(id)sender {
  227. BrandSearchViewController *tc=[[BrandSearchViewController alloc ]init];
  228. tc.bDelegate = self;
  229. tc.isPresentViewFlag = YES;
  230. tc.showDialogViewTag = baseIdAndNameBrand;
  231. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  232. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  233. }
  234. }
  235. /**
  236. 点击品种事件
  237. @param sender <#sender description#>
  238. */
  239. - (IBAction)clickVarietyAction:(id)sender {
  240. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  241. tc.delegate=self;
  242. tc.dataSourceCode=@"T_MST_Goods_Variety";
  243. tc.isPresentViewFlag = YES;
  244. tc.showDialogViewTag=ReportVariety;
  245. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  246. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  247. }
  248. }
  249. @end