AveragePriceMonitorSearchCellTableViewCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. //
  2. // AveragePriceMonitorSearchCellTableViewCell.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/9/7.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. // 功能描述:均价监控搜索cell
  9. #import "AveragePriceMonitorSearchCellTableViewCell.h"
  10. #import "BusinessDepartmentTreeViewController.h"
  11. #import "GoodsKindViewController.h"
  12. #import "DateFormat.h"
  13. #import "StatusInfo.h"
  14. #import "StatusInfoTextVC.h"
  15. @implementation AveragePriceMonitorSearchCellTableViewCell
  16. static AveragePriceMonitorSearchCellTableViewCell *searchCell;
  17. #pragma 公有函数
  18. /**
  19. 加载xib
  20. */
  21. - (void)awakeFromNib {
  22. [super awakeFromNib];
  23. }
  24. /**
  25. 单据类型数据源
  26. */
  27. - (void)initStatus{
  28. _arrayStatus = [[NSMutableArray alloc]init];
  29. StatusInfo* s = [[StatusInfo alloc]init];
  30. s = [[StatusInfo alloc]init];
  31. s.statusId = @"1";
  32. s.name = @"订单";
  33. [_arrayStatus addObject:s];
  34. s = [[StatusInfo alloc]init];
  35. s.statusId = @"2";
  36. s.name = @"销售单";
  37. [_arrayStatus addObject:s];
  38. }
  39. #pragma 委托函数
  40. /**
  41. 单元格高度
  42. @return <#return value description#>
  43. */
  44. - (CGFloat)cellHeight {
  45. return 280.0f;
  46. }
  47. /**
  48. 加载tableviewcell
  49. @param indexPath <#indexPath description#>
  50. @return <#return value description#>
  51. */
  52. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  53. AveragePriceMonitorSearchCellTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"AveragePriceMonitorSearchCellTableViewCell" owner:nil options:nil][0];
  54. searchCell = cell;
  55. return cell;
  56. }
  57. /**
  58. 初始化cell数据
  59. @param model <#model description#>
  60. @param indexPath <#indexPath description#>
  61. */
  62. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  63. indexPath:(NSIndexPath *)indexPath {
  64. _slideModel = *model;
  65. _searchModel=[[AveragePriceMonitorSearchModel alloc]init];
  66. NSString *startDateStr= [DateFormat getDateBefore:31];
  67. NSString *endDataStr = [DateFormat getCurrentDate];
  68. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  69. _startDate= _btnStartDate.titleLabel.text;
  70. [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal];
  71. _endDate= _btnEndDate.titleLabel.text;
  72. _searchModel.startDate=_startDate;
  73. _searchModel.endDate=_endDate;
  74. UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
  75. UITapGestureRecognizer *toSalesTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toSalesClick)];
  76. [self.lblIncludeGift addGestureRecognizer:labelTapGestureRecognizer];
  77. self.isIncludeGift =@"0";
  78. self.lblIncludeGift.text = @"不包含";
  79. self.lblIncludeGift.userInteractionEnabled = YES;
  80. self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor;
  81. self.lblIncludeGift.layer.borderWidth =1;
  82. _searchModel.invoiceType=@"1";
  83. [self.lblOrderToSales addGestureRecognizer:toSalesTapGestureRecognizer];
  84. self.isIncludeOrderToSales =@"0";
  85. self.lblOrderToSales.text = @"不包含";
  86. self.lblOrderToSales.userInteractionEnabled = YES;
  87. self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor;
  88. self.lblOrderToSales.layer.borderWidth =1;
  89. _searchModel.isIncludeOrderToSales=@"0";
  90. [self.btnInvoiceType setTitle:@"订单" forState:UIControlStateNormal];
  91. _searchModel.giftFlag=_isIncludeGift;
  92. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  93. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  94. _slideModel.customDict = _mutDict;
  95. }
  96. /**
  97. 重置按钮 事件
  98. */
  99. - (void)resetData {
  100. [_btnBusinessDepartment setTitle:@"请选择业务部门" forState:UIControlStateNormal];
  101. _searchModel.businessDepartmentCode=@"";
  102. [_btnGoodsType setTitle:@"请选择商品种类" forState:UIControlStateNormal];
  103. _searchModel.goodsType=@"";
  104. NSString *startDateStr= [DateFormat getDateBefore:31];
  105. NSString *endDataStr = [DateFormat getCurrentDate];
  106. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  107. _startDate= _btnStartDate.titleLabel.text;
  108. [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal];
  109. self.isIncludeGift =@"0";
  110. self.lblIncludeGift.text = @"不包含";
  111. self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor;
  112. self.lblIncludeGift.layer.borderWidth =1;
  113. _searchModel.giftFlag=_isIncludeGift;
  114. _searchModel.invoiceType=@"1";
  115. [self.btnInvoiceType setTitle:@"订单" forState:UIControlStateNormal];
  116. self.isIncludeOrderToSales =@"0";
  117. self.lblOrderToSales.text = @"不包含";
  118. self.lblOrderToSales.userInteractionEnabled =YES;
  119. self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor;
  120. self.lblOrderToSales.layer.borderWidth =1;
  121. _searchModel.isIncludeOrderToSales=@"0";
  122. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  123. _slideModel.customDict = _mutDict;
  124. }
  125. /**
  126. 返回tableviewcell标识
  127. @return <#return value description#>
  128. */
  129. + (NSString *)cellReuseIdentifier {
  130. return @"SearchTableViewCell";
  131. }
  132. /**
  133. 业务部门回调函数
  134. @param code <#code description#>
  135. @param name <#name description#>
  136. */
  137. -(void)achievementDataTreeResult:(NSString *)code name:(NSString*)name{
  138. [self.btnBusinessDepartment setTitle:name forState:UIControlStateNormal];
  139. _searchModel.businessDepartmentCode=code;
  140. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  141. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  142. _slideModel.customDict = _mutDict;
  143. }
  144. /**
  145. 产品种类回调函数
  146. @param id <#id description#>
  147. @param name <#name description#>
  148. */
  149. -(void)kindDataTreeResult:(NSString *)id name:(NSString*)name{
  150. [self.btnGoodsType setTitle:name forState:UIControlStateNormal];
  151. _searchModel.goodsType=id;
  152. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  153. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  154. _slideModel.customDict = _mutDict;
  155. }
  156. /**
  157. 单据类型回调
  158. @param s <#s description#>
  159. */
  160. - (void)showStatusValue:(StatusInfo *)s{
  161. NSString *statusId=s.statusId;
  162. [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal];
  163. [_searchModel setInvoiceType:statusId];
  164. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  165. _slideModel.customDict =_mutDict;
  166. }
  167. #pragma 私有函数
  168. /**
  169. 是否包含赠品点击事件
  170. */
  171. -(void)labelClick{
  172. if ( [self.isIncludeGift isEqualToString:@"1"]) {
  173. self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor;
  174. self.isIncludeGift =@"0";
  175. self.lblIncludeGift.text = @"不包含";
  176. self.lblIncludeGift.textColor = [UIColor lightGrayColor];
  177. }else{
  178. self.lblIncludeGift.layer.borderColor = [UIColor redColor].CGColor;
  179. self.isIncludeGift = @"1";
  180. self.lblIncludeGift.text = @"包含";
  181. self.lblIncludeGift.textColor = [UIColor redColor];
  182. }
  183. _searchModel.giftFlag=_isIncludeGift;
  184. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  185. _slideModel.customDict = _mutDict;
  186. }
  187. /**
  188. 是否包含转单的销售单点击事件
  189. */
  190. -(void)toSalesClick{
  191. if([_searchModel.invoiceType isEqualToString:@"2"]){
  192. if ( [self.isIncludeOrderToSales isEqualToString:@"1"]) {
  193. self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor;
  194. self.isIncludeOrderToSales =@"0";
  195. self.lblOrderToSales.text = @"不包含";
  196. self.lblOrderToSales.textColor = [UIColor lightGrayColor];
  197. }else{
  198. self.lblOrderToSales.layer.borderColor = [UIColor redColor].CGColor;
  199. self.isIncludeOrderToSales = @"1";
  200. self.lblOrderToSales.text = @"包含";
  201. self.lblOrderToSales.textColor = [UIColor redColor];
  202. }
  203. _searchModel.isIncludeOrderToSales=_isIncludeOrderToSales;
  204. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  205. _slideModel.customDict = _mutDict;
  206. }
  207. }
  208. /**
  209. 业务部门点击事件
  210. @param sender <#sender description#>
  211. */
  212. - (IBAction)businessDepartmentAction:(id)sender {
  213. BusinessDepartmentTreeViewController*tc = [[ BusinessDepartmentTreeViewController alloc] init];
  214. tc.isPresentViewFlag=YES;
  215. tc.cDelegate=self;
  216. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  217. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  218. }
  219. }
  220. /**
  221. 产品种类点击事件
  222. @param sender <#sender description#>
  223. */
  224. - (IBAction)goodsTypeAction:(id)sender {
  225. GoodsKindViewController *gc= [[ GoodsKindViewController alloc] init];
  226. gc.isPresentViewFlag=YES;
  227. gc.cDelegate=self;
  228. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  229. [self.delegate sideSlipTableViewCellNeedsDismissViewController:gc animated:YES];
  230. }
  231. }
  232. /**
  233. 开始日期点击事件
  234. @param sender <#sender description#>
  235. */
  236. - (IBAction)startDateAction:(id)sender {
  237. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  238. [ _brDatePicker configureSelectionBlock:^(NSString *date){
  239. _startDate=date;
  240. } andCompletionBlock:^(void){
  241. [_searchModel setStartDate:_startDate];
  242. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  243. _slideModel.customDict =_mutDict;
  244. [_btnStartDate setTitle:_startDate forState:UIControlStateNormal];
  245. } andCancelBlock:^(void){
  246. _startDate=_btnStartDate.titleLabel.text;
  247. }];
  248. [_brDatePicker show];
  249. }
  250. /**
  251. 结束日期点击事件
  252. @param sender <#sender description#>
  253. */
  254. - (IBAction)endDateAction:(id)sender {
  255. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  256. [_brDatePicker configureSelectionBlock:^(NSString *date){
  257. _endDate=date;
  258. } andCompletionBlock:^(void){
  259. [_searchModel setEndDate:_endDate];
  260. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  261. _slideModel.customDict = _mutDict;
  262. [_btnEndDate setTitle:_endDate forState:UIControlStateNormal];
  263. } andCancelBlock:^(void){
  264. _endDate=_btnEndDate.titleLabel.text;
  265. }];
  266. [_brDatePicker show];
  267. }
  268. /**
  269. 单据类型点击事件
  270. @param sender <#sender description#>
  271. */
  272. - (IBAction)invoiceTypeAction:(id)sender {
  273. [self initStatus];
  274. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  275. tc.sdelegate=self;
  276. tc.isPresentViewFlag=YES;
  277. [tc.arrFilter addObjectsFromArray: _arrayStatus];
  278. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  279. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  280. }
  281. }
  282. @end