| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //
- // YRDocuVC.m
- // UU_Ent
- //
- // Created by liujl on 2019/7/4.
- // Copyright © 2019 UAS. All rights reserved.
- //
- #import "YRDocuVC.h"
- #import "YRDocuCell.h"
- @interface YRDocuVC()<UITableViewDelegate,UITableViewDataSource>
- @property(strong,nonatomic)YRTableView *tableView;
- @property(strong,nonatomic)NSMutableArray<NSMutableArray<YRDocuModel *> *> *dataArr;
- @end
- @implementation YRDocuVC
- -(void)viewDidLoad{
- [super viewDidLoad];
-
- }
- -(void)setUpUI{
-
- [self.view addSubview:self.tableView];
-
-
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.edges.equalTo(self.view);
-
- }];
-
- [self loadDataFromServerWith:self.caller];
-
- [self.tableView reloadData];
- @weakify(self)
- self.tableView.emptyDidClicked = ^{
- @strongify(self)
- [self.tableView reloadData];
-
- };
-
- }
- -(void)loadDataFromServerWith:(NSString *)caller{
-
- NSString *url = [NSString stringWithFormat:@"http://erp.yitoa.com:8888/ERP/mobile/common/getformandgriddetail.action?caller=FeePlease!CCSQ!new&condition=1=1&sessionId=4AA6E9E6F286E19211C32E1B8D5FC7A9&id=0"];
-
-
- url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- YRNetworkManager *manager = [YRNetworkManager shareManager];
-
- [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
-
-
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
-
-
-
- }];
-
- }
- #pragma mark - delegate && dataSource
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
-
- return self.dataArr.count;
-
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.dataArr[section].count;
-
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- YRDocuCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YRDocuCellReid"];
-
- if (!cell) {
-
- cell = [[YRDocuCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YRDocuCellReid"];
-
- }
-
- cell.indexPath = indexPath;
-
- @weakify(self)
- cell.didClicked = ^(YRDocuModel * _Nonnull model,NSIndexPath *indexPath) {
-
- model.value = [NSString stringWithFormat:@"%d",arc4random()];
-
- [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
-
- };
-
-
- cell.model = self.dataArr[indexPath.section][indexPath.row];
-
-
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return self.dataArr[indexPath.section][indexPath.row].height;
-
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- [self.dataArr removeAllObjects];
-
- [tableView reloadData];
-
- self.dataArr = nil;
-
- }
- -(void)viewWillDisappear:(BOOL)animated{
-
- [super viewWillDisappear:animated];
-
-
-
- }
- -(YRTableView *)tableView{
-
- if (!_tableView) {
-
- _tableView = [[YRTableView alloc]initWithFrame:self.view.frame];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.tableHeaderView = [UIView new];
- _tableView.tableFooterView = [UIView new];
-
- }
-
- return _tableView;
- }
- -(NSMutableArray *)dataArr{
-
- if (!_dataArr) {
-
- _dataArr = [[NSMutableArray alloc]init];
-
- NSMutableArray *arrOne = [[NSMutableArray alloc]init];
-
- for (int i=0; i<30; i++) {
-
- YRDocuModel *model = [YRDocuModel new];
- model.key = @"单据";
- model.value = @"";
- if (i%3==0) {
-
- model.value = @"这里是";
- model.type = @"FF";
-
- }
- [arrOne addObject:model];
- }
-
- [_dataArr addObject:arrOne];
- }
-
- return _dataArr;
- }
- @end
|