InventorySearchCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. //
  2. // InventorySearchCell.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/23.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:库存明细表查询条件单元格
  9. //
  10. #import "InventorySearchCell.h"
  11. #import "UIColor+hexColor.h"
  12. #import "InventorySearchModel.h"
  13. #import "SideSlipConfig.h"
  14. #import "WareSearchViewController.h"
  15. #import "BrandSearchViewController.h"
  16. #import "PositionNumberViewController.h"
  17. #import "StatusInfoTextVC.h"
  18. #import "StatusInfo.h"
  19. @interface InventorySearchCell() <UITextFieldDelegate,BaseIDAndNameProtocol,StatusInfoTextDelegate>
  20. /**
  21. 抽屉对象model
  22. */
  23. @property (strong,nonatomic) SideSlipModel *regionModel;
  24. @end
  25. @implementation InventorySearchCell
  26. /**
  27. 高度
  28. @return return value description
  29. */
  30. - (CGFloat)cellHeight {
  31. return 1042.5f;
  32. }
  33. /**
  34. cell
  35. @param indexPath <#indexPath description#>
  36. @return <#return value description#>
  37. */
  38. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  39. InventorySearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"InventorySearchCell" owner:nil options:nil][0];
  40. cell.txtCode.delegate = cell;
  41. cell.txtOnlyCode.delegate = cell;
  42. cell.txtGoodName.delegate = cell;
  43. cell.txtGoodsSpecification.delegate=cell;
  44. cell.txtMinimumCanSalesQuantity.delegate=cell;
  45. cell.txtMinimumCanSalesQuantity.keyboardType= UIKeyboardTypeDecimalPad;
  46. cell.txtMaximumCanSalesQuantity.delegate=cell;
  47. cell.txtMaximumCanSalesQuantity.keyboardType= UIKeyboardTypeDecimalPad;
  48. [cell configureKeyboard];
  49. return cell;
  50. }
  51. - (IBAction)clickCeaseAction:(id)sender {
  52. [self initCeaseFlagData];
  53. StatusInfoTextVC *statusVc=[[StatusInfoTextVC alloc ]init];
  54. statusVc.sdelegate=self;
  55. statusVc.isPresentViewFlag = YES;
  56. statusVc.arrFilter=_ceaseFlagList;
  57. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  58. [self.delegate sideSlipTableViewCellNeedsDismissViewController:statusVc animated:YES];
  59. }
  60. }
  61. -(void)initCeaseFlagData
  62. {
  63. _ceaseFlagList=[[NSMutableArray alloc]init];
  64. StatusInfo *statusInfo=[StatusInfo new];
  65. [statusInfo setStatusId:@"2"];
  66. [statusInfo setName:@"全部"];
  67. [_ceaseFlagList addObject:statusInfo];
  68. statusInfo=[StatusInfo new];
  69. [statusInfo setStatusId:@"0"];
  70. [statusInfo setName:@"未停产"];
  71. [_ceaseFlagList addObject:statusInfo];
  72. statusInfo=[StatusInfo new];
  73. [statusInfo setStatusId:@"1"];
  74. [statusInfo setName:@"已停产"];
  75. [_ceaseFlagList addObject:statusInfo];
  76. }
  77. - (void)showStatusValue:(StatusInfo*)s
  78. {
  79. [_btnCeaseFlag setTitle:s.name forState:UIControlStateNormal];
  80. [_btnCeaseFlag setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  81. _ceaseFlagId=s.statusId;
  82. [self updateModel];
  83. }
  84. /**
  85. awakeFromNib
  86. */
  87. - (void)awakeFromNib {
  88. [super awakeFromNib];
  89. }
  90. - (IBAction)clickPositionNumberAction:(id)sender {
  91. PositionNumberViewController *tc = [[PositionNumberViewController alloc ]init];
  92. tc.bDelegate = self;
  93. tc.isPresentViewFlg = YES;
  94. tc.showDialogViewTag = baseIdAndNameValuePositionNumber;
  95. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  96. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  97. }
  98. }
  99. /**
  100. Identifier
  101. @return <#return value description#>
  102. */
  103. + (NSString *)cellReuseIdentifier {
  104. return @"InventorySearchCell";
  105. }
  106. /**
  107. 键盘配置
  108. */
  109. - (void)configureKeyboard {
  110. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  111. _txtCode.inputAccessoryView = keyBoardAccessoryView;
  112. _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
  113. _txtGoodName.inputAccessoryView = keyBoardAccessoryView;
  114. _txtGoodsSpecification.inputAccessoryView=keyBoardAccessoryView;
  115. _txtMinimumCanSalesQuantity.inputAccessoryView=keyBoardAccessoryView;
  116. _txtMaximumCanSalesQuantity.inputAccessoryView=keyBoardAccessoryView;
  117. }
  118. /**
  119. 更新model
  120. @param model <#model description#>
  121. @param indexPath <#indexPath description#>
  122. */
  123. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  124. self.regionModel = *model;
  125. // 1. 创建一个点击事件,点击时触发labelClick方法
  126. UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
  127. // 2. 将点击事件添加到label上
  128. [self.lblFilterQuantityEqZero addGestureRecognizer:labelTapGestureRecognizer];
  129. self.lblFilterQuantityEqZero.userInteractionEnabled = YES; // 可以理解为设置label可被点击
  130. self.lblFilterQuantityEqZero.layer.borderWidth = 1;
  131. self.lblFilterQuantityEqZero.layer.borderColor = [UIColor redColor].CGColor;
  132. self.isfilterQuantityEqZero = YES;
  133. self.lblFilterQuantityEqZero.text = @"已过滤";
  134. self.lblFilterQuantityEqZero.textColor = [UIColor redColor];
  135. [_btnCeaseFlag setTitle:@"全部" forState:UIControlStateNormal];
  136. _ceaseFlagId=@"2";
  137. [self updateModel];
  138. }
  139. /**
  140. 零库存过滤
  141. */
  142. - (void)labelClick{
  143. if (self.isfilterQuantityEqZero) {
  144. self.lblFilterQuantityEqZero.layer.borderColor = [UIColor lightGrayColor].CGColor;
  145. self.isfilterQuantityEqZero = NO;
  146. self.lblFilterQuantityEqZero.text = @"未过滤";
  147. self.lblFilterQuantityEqZero.textColor = [UIColor lightGrayColor];
  148. }else{
  149. self.lblFilterQuantityEqZero.layer.borderColor = [UIColor redColor].CGColor;
  150. self.isfilterQuantityEqZero = YES;
  151. self.lblFilterQuantityEqZero.text = @"已过滤";
  152. self.lblFilterQuantityEqZero.textColor = [UIColor redColor];
  153. }
  154. [self updateModel];
  155. }
  156. /**
  157. 重置按钮 事件
  158. */
  159. - (void)resetData {
  160. [_txtOnlyCode setText:@""];
  161. [_txtCode setText:@""];
  162. [_txtGoodName setText:@""];
  163. [_txtGoodsSpecification setText:@""];
  164. [_txtMinimumCanSalesQuantity setText:@""];
  165. [_txtMaximumCanSalesQuantity setText:@""];
  166. [_btnWare setTitle:@"请选择库区" forState:UIControlStateNormal];
  167. _ware = @"";
  168. [_btnBrand setTitle:@"请选择品牌" forState:UIControlStateNormal];
  169. [_btnPositionNumber setTitle:@"请选择仓位号" forState:UIControlStateNormal];
  170. _brand = @"";
  171. _positionNumberValue=@"";
  172. _lblFilterQuantityEqZero.text = @"已过滤";
  173. _isfilterQuantityEqZero= YES;
  174. _lblFilterQuantityEqZero.textColor = [UIColor redColor];
  175. [_btnCeaseFlag setTitle:@"全部" forState:UIControlStateNormal];
  176. _ceaseFlagId=@"2";
  177. }
  178. /**
  179. 文本编辑时候 弹出取消完成按钮
  180. @return <#return value description#>
  181. */
  182. - (UIView *)createKeyBoardAccessoryView {
  183. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  184. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  185. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  186. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  187. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  188. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  189. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  190. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  191. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  192. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  193. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  194. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  195. [keyBoardAccessoryView addSubview:backButton];
  196. [keyBoardAccessoryView addSubview:doneButton];
  197. return keyBoardAccessoryView;
  198. }
  199. /**
  200. 长度
  201. @param textField <#textField description#>
  202. @param range <#range description#>
  203. @param string <#string description#>
  204. @return <#return value description#>
  205. */
  206. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  207. return YES;
  208. }
  209. /**
  210. 文本编辑结束事件
  211. @param textField <#textField description#>
  212. */
  213. - (void)textFieldDidEndEditing:(UITextField *)textField {
  214. [self updateModel];
  215. }
  216. /**
  217. 触摸事件
  218. @param touches <#touches description#>
  219. @param event <#event description#>
  220. */
  221. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  222. [self hideKey];
  223. [_txtCode resignFirstResponder];
  224. [_txtOnlyCode resignFirstResponder];
  225. [_txtGoodName resignFirstResponder];
  226. [_txtGoodsSpecification resignFirstResponder];
  227. [_txtMinimumCanSalesQuantity resignFirstResponder];
  228. [_txtMaximumCanSalesQuantity resignFirstResponder];
  229. }
  230. /**
  231. 取消文本
  232. */
  233. - (void)accessoryButtonBack {
  234. [self hideKey];}
  235. /**
  236. 确定文本
  237. */
  238. - (void)accessoryButtonDone {
  239. [_txtCode resignFirstResponder];
  240. [_txtOnlyCode resignFirstResponder];
  241. [_txtGoodName resignFirstResponder];
  242. [_txtGoodsSpecification resignFirstResponder];
  243. [_txtMinimumCanSalesQuantity resignFirstResponder];
  244. [_txtMaximumCanSalesQuantity resignFirstResponder];
  245. [self hideKey];
  246. }
  247. /**
  248. 库区,品牌回调函数
  249. @param model <#model description#>
  250. @param value <#value description#>
  251. */
  252. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)m BaseIDAndName:(baseIdAndName)value{
  253. if (value == baseIdAndNameWare) {
  254. _ware = m.id;
  255. [self.btnWare setTitle:m.name forState:UIControlStateNormal];
  256. }
  257. if (value == baseIdAndNameBrand) {
  258. _brand = m.id;
  259. [self.btnBrand setTitle:m.name forState:UIControlStateNormal];
  260. }
  261. if(value==baseIdAndNameValuePositionNumber)
  262. {
  263. _positionNumberValue=m.name;
  264. [self.btnPositionNumber setTitle:m.name forState:UIControlStateNormal];
  265. }
  266. [self updateModel];
  267. }
  268. /**
  269. * 隐藏键盘
  270. */
  271. - (void)hideKey
  272. {
  273. [self.contentView endEditing:YES];
  274. }
  275. /**
  276. 品牌
  277. @param sender <#sender description#>
  278. */
  279. - (IBAction)showBrand:(id)sender {
  280. BrandSearchViewController *tc = [[BrandSearchViewController alloc ]init];
  281. tc.bDelegate = self;
  282. tc.isPresentViewFlag = YES;
  283. tc.showDialogViewTag = baseIdAndNameBrand;
  284. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  285. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  286. }
  287. }
  288. /**
  289. 库区
  290. @param sender <#sender description#>
  291. */
  292. - (IBAction)showWare:(id)sender {
  293. WareSearchViewController *tc = [[WareSearchViewController alloc ]init];
  294. tc.bDelegate = self;
  295. tc.isPresentViewFlg = YES;
  296. tc.showDialogViewTag = baseIdAndNameWare;
  297. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  298. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  299. }
  300. }
  301. /**
  302. 更新model
  303. */
  304. - (void)updateModel{
  305. InventorySearchModel *model = [[InventorySearchModel alloc] init];
  306. model.onlyCode = [_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  307. model.goodsCode = [_txtCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  308. model.goodsName = [_txtGoodName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  309. model.goodsSpecification = [_txtGoodsSpecification.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  310. model.minimumCanSalesQuantity=[_txtMinimumCanSalesQuantity.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  311. model.maximumCanSalesQuantity=[_txtMaximumCanSalesQuantity.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  312. model.warehouseId = _ware;
  313. model.brandId = _brand;
  314. model.isfilterQuantityEqZero = _isfilterQuantityEqZero;
  315. model.positionNumberName=_positionNumberValue;
  316. model.ceaseFlag =_ceaseFlagId;
  317. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  318. [mutDict setValue:model forKey:INVENTORY_SEARCH_RANGE_MODEL];
  319. _regionModel.customDict = [mutDict copy];
  320. }
  321. @end