PromotionOrderSearchCell.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. //
  2. // PromotionOrderSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/9/7.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "PromotionOrderSearchCell.h"
  9. @implementation PromotionOrderSearchCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. }
  13. /**
  14. 高度
  15. @return return value description
  16. */
  17. - (CGFloat)cellHeight {
  18. return 1119.0f;
  19. }
  20. /**
  21. cell
  22. @param indexPath <#indexPath description#>
  23. @return <#return value description#>
  24. */
  25. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  26. PromotionOrderSearchCell *cell = [[NSBundle mainBundle]
  27. loadNibNamed:@"PromotionOrderSearchCell"
  28. owner:nil
  29. options:nil][0];
  30. cell.txtGoodsCode.delegate = cell;
  31. cell.txtOnlyCode.delegate=cell;
  32. cell.txtStrategyName.delegate=cell;
  33. cell.txtPromotionName.delegate=cell;
  34. cell.txtSpecification.delegate=cell;
  35. cell.txtColorNumber.delegate=cell;
  36. [cell configureKeyboard];
  37. return cell;
  38. }
  39. - (void)loadGradeData
  40. {
  41. _downManager = [[ASIDownManager alloc] init];
  42. _downManager.delegate = self;
  43. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  44. _downManager.onRequestFail = @selector(onLoadFail:);
  45. NSString *urlStr = ServerURL;
  46. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  47. [dict setObject:@"GetGradeDataSource" forKey:@"Action"];
  48. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  49. [dict setObject:kkUserCode forKey:@"UserCode"];
  50. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  51. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  52. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  53. }
  54. /**
  55. 数据加载成功回调
  56. @param sender <#sender description#>
  57. */
  58. - (void)onLoadFinish:(ASIDownManager *)sender
  59. {
  60. // 服务器返回数据
  61. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  62. // 服务器返回数据状态值
  63. int iStatus = resultModel.status;
  64. // 服务器返回数据消息
  65. NSString *message = resultModel.message;
  66. // 服务器返回数据状态值正确
  67. if (iStatus == 0)
  68. {
  69. NSArray *approvArr = (NSArray *)resultModel.result;
  70. if(approvArr!=nil&&approvArr.count>0)
  71. {
  72. _gradeList=[[NSMutableArray alloc]init];
  73. for(int i=0;i<approvArr.count;i++)
  74. {
  75. NSDictionary *approveDic=[approvArr objectAtIndex:i];
  76. NSString *gradeId= [approveDic objectForKey:@"GradeID"];
  77. NSString *gradeName=[approveDic objectForKey:@"GradeName"];
  78. GradeModel *model=[GradeModel new];
  79. [model parseDic:approveDic];
  80. GradeFrame *gradeFrame=[GradeFrame new];
  81. [gradeFrame setGradeFrame:model];
  82. [_gradeList addObject:gradeFrame];
  83. }
  84. }
  85. }
  86. }
  87. - (void)onLoadFail:(ASIDownManager *)sender
  88. {
  89. }
  90. /**
  91. 键盘配置
  92. */
  93. - (void)configureKeyboard {
  94. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  95. _txtGoodsCode.inputAccessoryView = keyBoardAccessoryView;
  96. _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
  97. _txtStrategyName.inputAccessoryView = keyBoardAccessoryView;
  98. _txtPromotionName.inputAccessoryView = keyBoardAccessoryView;
  99. _txtSpecification.inputAccessoryView = keyBoardAccessoryView;
  100. _txtColorNumber.inputAccessoryView = keyBoardAccessoryView;
  101. }
  102. /**
  103. 文本编辑时候 弹出取消完成按钮
  104. @return <#return value description#>
  105. */
  106. - (UIView *)createKeyBoardAccessoryView {
  107. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  108. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  109. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  110. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  111. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  112. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  113. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  114. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  115. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  116. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  117. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  118. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  119. [keyBoardAccessoryView addSubview:backButton];
  120. [keyBoardAccessoryView addSubview:doneButton];
  121. return keyBoardAccessoryView;
  122. }
  123. /**
  124. * 隐藏键盘
  125. */
  126. -(void)hideKey
  127. {
  128. [self.contentView endEditing:YES];
  129. }
  130. /**
  131. 取消文本
  132. */
  133. - (void)accessoryButtonBack {
  134. [self hideKey];}
  135. /**
  136. 确定文本
  137. */
  138. - (void)accessoryButtonDone {
  139. [_txtGoodsCode resignFirstResponder];
  140. [_txtOnlyCode resignFirstResponder];
  141. [_txtStrategyName resignFirstResponder];
  142. [_txtPromotionName resignFirstResponder];
  143. [_txtSpecification resignFirstResponder];
  144. [_txtColorNumber resignFirstResponder];
  145. [self hideKey];
  146. }
  147. -(void)showGradeInfo:(NSMutableArray*)gradeList
  148. {
  149. _gradeSelectedList=gradeList;
  150. NSString *gradeStr=@"";
  151. NSString *gradeIdStr=@"";
  152. for(GradeFrame *frame in _gradeSelectedList){
  153. GradeModel *model=frame.gModel;
  154. gradeStr= [NSString stringWithFormat:@"%@%@%@",gradeStr,model.gradeName,@","];
  155. gradeIdStr=[NSString stringWithFormat:@"%@%ld%@",gradeIdStr,model.gradeId,@"^"];
  156. }
  157. gradeStr=[gradeStr substringToIndex:gradeStr.length-1];
  158. _gradeIds=[gradeIdStr substringToIndex:gradeIdStr.length-1];
  159. [_btnGrade setTitle:gradeStr forState:UIControlStateNormal];
  160. [self updateModel];
  161. }
  162. /**
  163. Identifier
  164. @return <#return value description#>
  165. */
  166. + (NSString *)cellReuseIdentifier {
  167. return @"PromotionOrderSearchCell";
  168. }
  169. /**
  170. 长度
  171. @param textField <#textField description#>
  172. @param range <#range description#>
  173. @param string <#string description#>
  174. @return <#return value description#>
  175. */
  176. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  177. return YES;
  178. }
  179. /**
  180. 更新model
  181. @param model <#model description#>
  182. @param indexPath <#indexPath description#>
  183. */
  184. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  185. indexPath:(NSIndexPath *)indexPath{
  186. [self loadGradeData];
  187. self.regionModel = *model;
  188. }
  189. /**
  190. 文本编辑结束事件
  191. @param textField <#textField description#>
  192. */
  193. - (void)textFieldDidEndEditing:(UITextField *)textField {
  194. [self updateModel];
  195. }
  196. /**
  197. 库区,品牌回调函数
  198. @param model <#model description#>
  199. @param value <#value description#>
  200. */
  201. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)m BaseIDAndName:(baseIdAndName)value{
  202. if (value == baseIdAndNameWare) {
  203. _warehouseId = m.id;
  204. [self.btnWarehouseArea setTitle:m.name forState:UIControlStateNormal];
  205. }
  206. if(value==baseIdAndNameBrand)
  207. {
  208. _brandId=m.id;
  209. [self.btnBrand setTitle:m.name forState:UIControlStateNormal];
  210. }
  211. if(value==baseIdAndNameSeries)
  212. {
  213. _seriesId=m.id;
  214. [self.btnSeries setTitle:m.name forState:UIControlStateNormal];
  215. }
  216. if(value==baseIdAndNameKind)
  217. {
  218. _kindCode=m.code;
  219. [self.btnKInd setTitle:m.name forState:UIControlStateNormal];
  220. }
  221. if(value==baseIdAndNameVariety)
  222. {
  223. _varietyId=m.id;
  224. [self.btnVariety setTitle:m.name forState:UIControlStateNormal];
  225. }
  226. if(value==BaseIDAndNamePromotionType)
  227. {
  228. _promotionTypeId=m.id;
  229. [self.btnPromotionType setTitle:m.name forState:UIControlStateNormal];
  230. }
  231. [self updateModel];
  232. }
  233. -(void)updateModel
  234. {
  235. SalesOrderListSearchModel *searchModel=[SalesOrderListSearchModel new];
  236. NSString *goodsCode=[_txtGoodsCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  237. searchModel.goodsCode=goodsCode;
  238. NSString *onlyCode=[_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  239. searchModel.onlyCode=onlyCode;
  240. NSString *strategyName=[_txtStrategyName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  241. searchModel.strategyName=strategyName;
  242. NSString *promotionName=[_txtPromotionName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  243. searchModel.promotionName=promotionName;
  244. NSString *specification=[_txtSpecification.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  245. searchModel.specification=specification;
  246. NSString *colorNumber=[_txtColorNumber.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  247. searchModel.colorNumber=colorNumber;
  248. searchModel.warehouseAreaId=_warehouseId;
  249. searchModel.brandId=_brandId;
  250. searchModel.seriesId=_seriesId;
  251. searchModel.kindCode=_kindCode;
  252. searchModel.varietyId=_varietyId;
  253. searchModel.gradeIds=_gradeIds;
  254. searchModel.promotionTypeId=_promotionTypeId;
  255. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  256. [mutDict setValue:searchModel forKey:SALES_ORDER_LIST_SEARCH_RANGE_MODEL];
  257. _regionModel.customDict = [mutDict copy];
  258. }
  259. - (IBAction)clickVarietyAction:(id)sender {
  260. SalesOrderVarietyVC *tc = [[SalesOrderVarietyVC alloc ]init];
  261. tc.bDelegate = self;
  262. tc.isPresentViewFlag = YES;
  263. tc.showDialogViewTag = baseIdAndNameVariety;
  264. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  265. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  266. }
  267. }
  268. - (IBAction)clickPromotionTypeAction:(id)sender {
  269. PromotionTypeVC *tc = [[PromotionTypeVC alloc ]init];
  270. tc.bDelegate = self;
  271. tc.isPresentViewFlag = YES;
  272. tc.showDialogViewTag = BaseIDAndNamePromotionType;
  273. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  274. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  275. }
  276. }
  277. - (IBAction)clickGradeAction:(id)sender {
  278. if(_gradeList!=nil&&_gradeList.count>0)
  279. {
  280. SalesOrderGradeVC *tc = [[SalesOrderGradeVC alloc ]init];
  281. tc.gradeList=_gradeList;
  282. _gradeTempList= [[NSMutableArray alloc] initWithArray:_gradeList copyItems:YES];
  283. tc.isPresentViewFlag=YES;
  284. tc.gradeDelegate = self;
  285. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  286. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  287. }
  288. }
  289. }
  290. - (IBAction)clickWarehouseAreaAction:(id)sender {
  291. WarehouseAreaSearchVC *tc = [[WarehouseAreaSearchVC alloc ]init];
  292. tc.bDelegate = self;
  293. tc.isPresentViewFlg = YES;
  294. tc.showDialogViewTag = baseIdAndNameWare;
  295. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  296. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  297. }
  298. }
  299. - (IBAction)clickBrandAction:(id)sender {
  300. SalesOrderBrandSearchVC *tc = [[SalesOrderBrandSearchVC alloc ]init];
  301. tc.bDelegate = self;
  302. tc.isPresentViewFlag = YES;
  303. tc.showDialogViewTag = baseIdAndNameBrand;
  304. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  305. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  306. }
  307. }
  308. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  309. [super setSelected:selected animated:animated];
  310. }
  311. - (IBAction)clickSeriesAction:(id)sender {
  312. SalesOrderSeriesVC *tc = [[SalesOrderSeriesVC alloc ]init];
  313. tc.bDelegate = self;
  314. tc.isPresentViewFlag = YES;
  315. tc.showDialogViewTag = baseIdAndNameSeries;
  316. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  317. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  318. }
  319. }
  320. - (IBAction)clickKindAction:(id)sender {
  321. SalesOrderKindVC *tc = [[SalesOrderKindVC alloc ]init];
  322. tc.bDelegate = self;
  323. tc.isPresentViewFlag = YES;
  324. tc.showDialogViewTag = baseIdAndNameKind;
  325. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  326. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  327. }
  328. }
  329. -(void)recoveryData{
  330. if(_gradeTempList!=nil&&_gradeTempList.count>0){
  331. _gradeList= [[NSMutableArray alloc] initWithArray:_gradeTempList copyItems:YES];;
  332. }
  333. }
  334. @end