ProcurementApplySearchCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. //
  2. // ProcurementApplySearchCell.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2018/7/23.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "ProcurementApplySearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. @implementation ProcurementApplySearchCell
  12. #pragma mark -公共函数
  13. /**
  14. 唤醒xib
  15. */
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. }
  19. /**
  20. 汇总类型
  21. @return <#return value description#>
  22. */
  23. - (NSMutableArray *)summaryTypeArr{
  24. if (_summaryTypeArr == nil) {
  25. _summaryTypeArr = [[NSMutableArray alloc]init];
  26. BaseIDAndNameModel *m = [BaseIDAndNameModel new];
  27. m.id = @"1";
  28. m.name = @"请购单号";
  29. [_summaryTypeArr addObject:m];
  30. m = [BaseIDAndNameModel new];
  31. m.id = @"2";
  32. m.name = @"销售订单单号";
  33. [_summaryTypeArr addObject:m];
  34. m = [BaseIDAndNameModel new];
  35. m.id = @"3";
  36. m.name = @"商品品牌";
  37. [_summaryTypeArr addObject:m];
  38. m = [BaseIDAndNameModel new];
  39. m.id = @"4";
  40. m.name = @"商品规格";
  41. [_summaryTypeArr addObject:m];
  42. m = [BaseIDAndNameModel new];
  43. m.id = @"5";
  44. m.name = @"商品编码";
  45. [_summaryTypeArr addObject:m];
  46. m = [BaseIDAndNameModel new];
  47. m.id = @"6";
  48. m.name = @"商品种类";
  49. [_summaryTypeArr addObject:m];
  50. m = [BaseIDAndNameModel new];
  51. m.id = @"7";
  52. m.name = @"商品系列";
  53. [_summaryTypeArr addObject:m];
  54. m = [BaseIDAndNameModel new];
  55. m.id = @"8";
  56. m.name = @"请购人";
  57. [_summaryTypeArr addObject:m];
  58. }
  59. return _summaryTypeArr;
  60. }
  61. #pragma mark -委托函数
  62. /**
  63. 高度
  64. @return <#return value description#>
  65. */
  66. - (CGFloat)cellHeight {
  67. return 768.5;
  68. }
  69. /**
  70. 创建cell
  71. @param indexPath <#indexPath description#>
  72. @return <#return value description#>
  73. */
  74. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  75. ProcurementApplySearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ProcurementApplySearchCell" owner:nil options:nil][0];
  76. cell.txtApplyNo.delegate=cell;
  77. cell.txtApplyTitle.delegate=cell;
  78. cell.txtCustomerCode.delegate=cell;
  79. cell.txtCustomerName.delegate=cell;
  80. [cell configureKeyboard];
  81. return cell;
  82. }
  83. /**
  84. 更新model
  85. 关宏厚2017-7-6
  86. @param model <#model description#>
  87. @param indexPath <#indexPath description#>
  88. */
  89. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  90. self.regionModel = *model;
  91. NSString *startDateStr = [DateFormat getDateBefore:31];
  92. NSString *endDateStr = [DateFormat getCurrentDate];
  93. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  94. _sStartDate= _btnStartDate.titleLabel.text;
  95. [_btnEndDate setTitle:endDateStr forState:UIControlStateNormal];
  96. _sEndDate =_btnEndDate.titleLabel.text;
  97. [self updateModel];
  98. }
  99. /**
  100. Identifier
  101. @return <#return value description#>
  102. */
  103. + (NSString *)cellReuseIdentifier {
  104. return @"ProcurementApplySearchCell";
  105. }
  106. /**
  107. 重置按钮 事件
  108. */
  109. - (void)resetData {
  110. [_txtApplyNo setText:@""];
  111. [_txtApplyTitle setText:@""];
  112. [_txtCustomerCode setText:@""];
  113. [_txtCustomerName setText:@""];
  114. [_btnStartDate setTitle:@"请选择开始日期" forState:UIControlStateNormal];
  115. _sStartDate = @"";
  116. [_btnEndDate setTitle:@"请选择结束日期" forState:UIControlStateNormal];
  117. _sEndDate = @"";
  118. [_btnApplyDepartment setTitle:@"请选择申请部门" forState:UIControlStateNormal];
  119. _organizationCode = @"";
  120. [_btnApplier setTitle:@"请选择申请者" forState:UIControlStateNormal];
  121. _applierId = @"";
  122. [_btnSummaryType setTitle:@"请选择汇总类型" forState:UIControlStateNormal];
  123. _summaryTypeId=@"";
  124. }
  125. /**
  126. 长度
  127. @param textField <#textField description#>
  128. @param range <#range description#>
  129. @param string <#string description#>
  130. @return <#return value description#>
  131. */
  132. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  133. return YES;
  134. }
  135. /**
  136. 文本编辑结束事件
  137. @param textField <#textField description#>
  138. */
  139. - (void)textFieldDidEndEditing:(UITextField *)textField {
  140. [self updateModel];
  141. }
  142. /**
  143. 触摸事件
  144. @param touches <#touches description#>
  145. @param event <#event description#>
  146. */
  147. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  148. [self hideKey];
  149. [_txtApplyNo resignFirstResponder];
  150. [_txtCustomerCode resignFirstResponder];
  151. [_txtCustomerName resignFirstResponder];
  152. [_txtApplyTitle resignFirstResponder];
  153. }
  154. /**
  155. 业务员 业务部门
  156. @param Amodel <#Amodel description#>
  157. @param cr <#cr description#>
  158. */
  159. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  160. //返回值
  161. if(cr == ReportAchiementDepartmt){
  162. _organizationCode = Amodel.organizationCode;
  163. [_btnApplyDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
  164. }
  165. // 业务员
  166. if(cr == ReportAchiementmn){
  167. _applierId = Amodel.staffId;
  168. [_btnApplier setTitle:Amodel.staffName forState:UIControlStateNormal];
  169. }
  170. [self updateModel];
  171. }
  172. /**
  173. 汇总类型
  174. @param model <#model description#>
  175. @param value <#value description#>
  176. */
  177. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)model
  178. BaseIDAndName:(baseIdAndName)value{
  179. _summaryTypeId = model.id;
  180. [self.btnSummaryType setTitle:model.name forState:UIControlStateNormal];
  181. [self updateModel];
  182. }
  183. #pragma mark -私有函数
  184. /**
  185. 键盘配置
  186. */
  187. - (void)configureKeyboard {
  188. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  189. _txtApplyNo.inputAccessoryView = keyBoardAccessoryView;
  190. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  191. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  192. _txtApplyTitle.inputAccessoryView=keyBoardAccessoryView;
  193. }
  194. /**
  195. 文本编辑时候 弹出取消完成按钮
  196. @return <#return value description#>
  197. */
  198. - (UIView *)createKeyBoardAccessoryView {
  199. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  200. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  201. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  202. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  203. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  204. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  205. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  206. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  207. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  208. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  209. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  210. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  211. [keyBoardAccessoryView addSubview:backButton];
  212. [keyBoardAccessoryView addSubview:doneButton];
  213. return keyBoardAccessoryView;
  214. }
  215. /**
  216. * 隐藏键盘
  217. */
  218. - (void)hideKey
  219. {
  220. [self.contentView endEditing:YES];
  221. }
  222. /**
  223. 取消文本
  224. */
  225. - (void)accessoryButtonBack {
  226. [self hideKey];}
  227. /**
  228. 确定文本
  229. */
  230. - (void)accessoryButtonDone {
  231. [_txtApplyTitle resignFirstResponder];
  232. [_txtCustomerCode resignFirstResponder];
  233. [_txtCustomerName resignFirstResponder];
  234. [_txtApplyNo resignFirstResponder];
  235. [self hideKey];
  236. }
  237. /**
  238. 点击请购部门事件
  239. @param sender <#sender description#>
  240. */
  241. - (IBAction)clickApplyDepartmentAction:(id)sender {
  242. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  243. tc.cDelegate = self;
  244. tc.isPresentViewFlag = YES;
  245. tc.flag = YES;
  246. tc.showDialogViewTag=ReportAchiementDepartmt;
  247. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  248. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  249. }
  250. }
  251. /**
  252. 点击申请者事件
  253. @param sender <#sender description#>
  254. */
  255. - (IBAction)clickApplierAction:(id)sender {
  256. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  257. tc.cDelegate = self;
  258. tc.isPresentViewFlag = YES;
  259. tc.showDialogViewTag=ReportAchiementmn;
  260. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  261. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  262. }
  263. }
  264. /**
  265. 点击开始日期
  266. @param sender <#sender description#>
  267. */
  268. - (IBAction)clickStartDateAction:(id)sender {
  269. __weak typeof(self) weakself=self;
  270. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  271. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  272. _tempStartDate=date;
  273. }
  274. andCompletionBlock:^(void){
  275. weakself.sStartDate = _tempStartDate;
  276. [weakself.btnStartDate setTitle:weakself.sStartDate forState:UIControlStateNormal];
  277. [self updateModel];
  278. }
  279. andCancelBlock:^(void){
  280. }];
  281. [_dealDatePicker show];
  282. }
  283. /**
  284. 点击结束日期
  285. @param sender <#sender description#>
  286. */
  287. - (IBAction)clickEndDateAction:(id)sender {
  288. __weak typeof(self) weakself=self;
  289. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  290. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  291. _tempEndDate=date;
  292. } andCompletionBlock:^(void){
  293. weakself.sEndDate = _tempEndDate;
  294. [weakself.btnEndDate setTitle:weakself.sEndDate forState:UIControlStateNormal];
  295. [self updateModel];
  296. } andCancelBlock:^(void){
  297. }];
  298. [_dealDatePicker show];
  299. }
  300. /**
  301. 点击汇总类型
  302. @param sender <#sender description#>
  303. */
  304. - (IBAction)clickSummaryTypeAction:(id)sender {
  305. BaseIDAndNameViewController *tc = [[BaseIDAndNameViewController alloc ]init];
  306. tc.bDelegate = self;
  307. tc.isPresentViewFlg = YES;
  308. tc.arrFilter = self.summaryTypeArr;
  309. tc.arrSearch = self.summaryTypeArr;
  310. tc.showDialogViewTag = baseIdAndNameValueFlag;
  311. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  312. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  313. }
  314. }
  315. /**
  316. 更新model
  317. */
  318. -(void)updateModel
  319. {
  320. ProcurementApplySearchModel *searchModel=[[ProcurementApplySearchModel alloc]init];
  321. searchModel.applyNo=[_txtApplyNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  322. searchModel.applyTitle=[_txtApplyTitle.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  323. searchModel.customerCode=[_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  324. searchModel.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  325. searchModel.organizationCode=_organizationCode;
  326. searchModel.applierId=_applierId;
  327. searchModel.startDate=_sStartDate;
  328. searchModel.endDate=_sEndDate;
  329. searchModel.summaryTypeId=_summaryTypeId;
  330. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  331. [mutDict setValue:searchModel forKey:PROCUREMENT_APPLY_SEARCH_RANGE_MODEL];
  332. _regionModel.customDict = [mutDict copy];
  333. }
  334. @end