2222#import " WebViewController.h"
2323#import " ProjectToChooseListViewController.h"
2424#import " EditLabelViewController.h"
25+ #import " TaskResourceReferenceViewController.h"
2526
2627@interface EditTaskViewController ()<TTTAttributedLabelDelegate>
2728@property (strong , nonatomic ) UITableView *myTableView;
@@ -164,7 +165,7 @@ - (void)queryToRefreshActivityList{
164165 [[Coding_NetAPIManager sharedManager ] request_ActivityListOfTask: _myCopyTask andBlock: ^(id data, NSError *error) {
165166 if (data) {
166167 weakSelf.myCopyTask .activityList = data;
167- [weakSelf.myTableView reloadSections: [ NSIndexSet indexSetWithIndex: 2 ] withRowAnimation: UITableViewRowAnimationAutomatic ];
168+ [weakSelf.myTableView reloadData ];
168169 };
169170 }];
170171}
@@ -182,13 +183,23 @@ - (void)queryToRefreshTaskDetail{
182183 [weakSelf configTitle ];
183184
184185 [weakSelf.myTableView reloadData ];
186+ [weakSelf queryToRefreshResourceReference ];
185187 [weakSelf queryToRefreshActivityList ];
186188 }else if ([[[error.userInfo objectForKey: @" msg" ] allKeys ] containsObject: @" task_not_exist" ]){
187189 [self .navigationItem setRightBarButtonItem: nil animated: YES ];
188190 }
189191 }];
190192}
191193
194+ - (void )queryToRefreshResourceReference {
195+ __weak typeof (self) weakSelf = self;
196+ [[Coding_NetAPIManager sharedManager ] request_TaskResourceReference: _myTask andBlock: ^(id data, NSError *error) {
197+ if (data) {
198+ _myTask.resourceReference = data;
199+ [weakSelf.myTableView reloadData ];
200+ }
201+ }];
202+ }
192203#pragma mark Mine M
193204- (void )doneBtnClicked {
194205 if (_myCopyTask.isRequesting ) {
@@ -281,7 +292,7 @@ - (void)deleteComment:(TaskComment *)comment{
281292}
282293#pragma mark Table M
283294- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
284- return (self.myCopyTask .handleType > TaskHandleTypeEdit)? 2 : 3 ;
295+ return (self.myCopyTask .handleType > TaskHandleTypeEdit)? 2 : self. myTask . resourceReference . itemList . count > 0 ? 4 : 3 ;
285296}
286297- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
287298 NSInteger row = 0 ;
@@ -290,6 +301,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
290301 }else if (section == 1 ){
291302 TaskHandleType handleType = self.myCopyTask .handleType ;
292303 row = handleType == TaskHandleTypeEdit? 5 : handleType == TaskHandleTypeAddWithProject? 4 : 5 ;
304+ }else if (section == 2 && _myTask.resourceReference .itemList .count > 0 ){
305+ row = 1 ;
293306 }else {
294307 row = self.myCopyTask .activityList .count ;
295308 }
@@ -361,6 +374,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
361374 cell.backgroundColor = kColorTableBG ;
362375 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
363376 return cell;
377+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
378+ LeftImage_LRTextCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_LeftImage_LRText forIndexPath: indexPath];
379+ [cell setObj: _myTask type: LeftImage_LRTextCellTypeTaskResourceReference];
380+ cell.backgroundColor = kColorTableBG ;
381+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
382+ return cell;
364383 }else {
365384 ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
366385 if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -376,7 +395,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
376395 cell.contentLabel .delegate = self;
377396 [cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _myCopyTask.activityList.count - 1 )];
378397 cell.backgroundColor = kColorTableBG ;
379- // [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
380398 return cell;
381399 }else {
382400 TaskActivityCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TaskActivityCell forIndexPath: indexPath];
@@ -398,6 +416,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
398416 }
399417 }else if (indexPath.section == 1 ){
400418 cellHeight = [LeftImage_LRTextCell cellHeight ];
419+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
420+ cellHeight = [LeftImage_LRTextCell cellHeight ];
401421 }else if (self.myCopyTask .activityList .count > indexPath.row ){
402422 ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
403423 if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -413,8 +433,6 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
413433- (CGFloat)tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
414434 if (section == 0 ) {
415435 return 0.5 ;
416- }else if (section == 3 ){
417- return 0.5 ;
418436 }else {
419437 return 20.0 ;
420438 }
@@ -427,28 +445,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
427445- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
428446 UIView *headerView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 1 )];
429447 headerView.backgroundColor = kColorTableSectionBg ;
430- if (section == 0 ) {
431- [headerView setHeight: 30.0 ];
432- }else if (section == 3 ){
433- headerView.backgroundColor = [UIColor whiteColor ];
434- [headerView setHeight: 1.0 ];
435- }else {
436- [headerView setHeight: 20 ];
437- }
438448 return headerView;
439449}
440450
441451- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
442452 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
443453 ESWeakSelf;
444454 if (indexPath.section == 0 ) {
445- // if (indexPath.row != 0) {
446- // if (self.myCopyTask.has_description.boolValue && !self.myCopyTask.task_description) {
447- // //描述内容 还没有加载成功
448- // return ;
449- // }
450- // [self goToDescriptionVC];
451- // }
452455 }else if (indexPath.section == 1 ){
453456 LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1 ;
454457 if (cellType == LeftImage_LRTextCellTypeTaskProject) {
@@ -522,6 +525,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
522525 vc.curTask = _myCopyTask;
523526 [self .navigationController pushViewController: vc animated: YES ];
524527 }
528+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
529+ TaskResourceReferenceViewController *vc = [TaskResourceReferenceViewController new ];
530+ vc.curTask = _myTask;
531+ [self .navigationController pushViewController: vc animated: YES ];
525532 }else {
526533 ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
527534 if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -549,6 +556,7 @@ - (void)goToDescriptionVC{
549556 _self.taskChangedBlock ();
550557 }
551558 [_self.myTableView reloadData ];
559+ [_self queryToRefreshResourceReference ];
552560 };
553561 [self .navigationController pushViewController: vc animated: YES ];
554562}
0 commit comments