Skip to content

Commit b90d169

Browse files
张达棣张达棣
authored andcommitted
完善项目外任务
1 parent d6d3bd7 commit b90d169

File tree

4 files changed

+70
-25
lines changed

4 files changed

+70
-25
lines changed

Coding_iOS/Controllers/RootControllers/MyTask_RootViewController.m

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ @interface MyTask_RootViewController ()
3131
@property (nonatomic, strong) NSString *keyword;
3232
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
3333
@property (nonatomic, strong) NSString *label; //任务标签
34-
34+
@property (nonatomic, strong) Tasks *tasks;
3535

3636
@end
3737

@@ -139,6 +139,7 @@ - (void)viewWillAppear:(BOOL)animated{
139139

140140

141141
- (void)resetCurView{
142+
_tasks = nil;
142143
if (!_myProjects.isLoading) {
143144
__weak typeof(self) weakSelf = self;
144145
[[Coding_NetAPIManager sharedManager] request_ProjectsHaveTasks_WithObj:_myProjects andBlock:^(id data, NSError *error) {
@@ -152,14 +153,22 @@ - (void)resetCurView{
152153
- (void)resetSearView {
153154
__weak typeof(self) weakSelf = self;
154155

155-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:nil keyword:_keyword status:_status label:_label andBlock:^(Projects *data, NSError *error) {
156-
// weakSelf.myProjectList = data.list;
157-
// [weakSelf.myCarousel reloadData];
156+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:nil keyword:_keyword status:_status label:_label andBlock:^(Tasks *data, NSError *error) {
157+
weakSelf.tasks = data;
158158
[weakSelf configSearchControlWithData:data];
159+
160+
161+
// [weakSelf.myProjectList removeAllObjects];
162+
// [weakSelf.myProjectList addObjectsFromArray:_tasks.list];
163+
// [_myCarousel reloadData];
164+
159165
}];
160166
}
161167

162168
- (void)configSegmentControlWithData:(Projects *)freshProjects {
169+
[_myProTksDict removeAllObjects];
170+
[self.myProjectList removeAllObjects];
171+
163172
BOOL dataHasChanged = NO;
164173
for (Project *freshPro in freshProjects.list) {
165174
BOOL hasFreshPro = NO;
@@ -199,31 +208,27 @@ - (void)configSegmentControlWithData:(Projects *)freshProjects {
199208

200209
}
201210

202-
- (void)configSearchControlWithData:(Projects *)freshProjects {
211+
- (void)configSearchControlWithData:(Tasks *)tasks{
212+
213+
[_myProTksDict removeAllObjects];
214+
[self.myProjectList removeAllObjects];
215+
203216
BOOL dataHasChanged = NO;
204-
for (Project *freshPro in freshProjects.list) {
205-
BOOL hasFreshPro = NO;
206-
for (Project *oldPro in self.myProjectList) {
207-
if (freshPro.id.integerValue == oldPro.id.integerValue) {
208-
hasFreshPro = YES;
209-
break;
210-
}
211-
}
212-
if (!hasFreshPro) {
213-
dataHasChanged = YES;
214-
break;
215-
}
216-
}
217217

218-
if (dataHasChanged) {
219-
// self.myProjectList = [[NSMutableArray alloc] initWithObjects:[Project project_All], nil];
220-
[self.myProjectList addObjectsFromArray:freshProjects.list];
218+
if (!dataHasChanged) {
219+
self.myProjectList = [[NSMutableArray alloc] initWithObjects:[Project project_All], nil];
220+
221+
NSMutableDictionary *proDict = @{}.mutableCopy;
222+
for (Task *task in tasks.list) {
223+
NSLog(@"-----%@--%@", task.project.id, task.project.name);
224+
[proDict setObject:task.project forKey:task.project.id.stringValue];
225+
}
226+
[self.myProjectList addObjectsFromArray:proDict.allValues];
221227

222228
//重置滑块
223229
if (_mySegmentControl) {
224230
[_mySegmentControl removeFromSuperview];
225231
}
226-
227232
__weak typeof(self) weakSelf = self;
228233
CGRect segmentFrame = CGRectMake(0, 0, kScreen_Width, kMySegmentControlIcon_Height);
229234
_mySegmentControl = [[XTSegmentControl alloc] initWithFrame:segmentFrame Items:_myProjectList selectedBlock:^(NSInteger index) {
@@ -251,7 +256,9 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
251256
curTasks = [Tasks tasksWithPro:curPro queryType:TaskQueryTypeAll];
252257
[_myProTksDict setObject:curTasks forKey:curPro.id];
253258
}
254-
259+
if (_tasks != nil) {
260+
curTasks = _tasks;
261+
}
255262
ProjectTaskListView *listView = (ProjectTaskListView *)view;
256263
if (listView) {
257264
[listView setTasks:curTasks];
@@ -267,6 +274,9 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
267274
} tabBarHeight:CGRectGetHeight(self.rdv_tabBarController.tabBar.frame)];
268275
}
269276
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
277+
listView.keyword = _keyword;
278+
listView.status = _status;
279+
listView.label = _label;
270280
return listView;
271281
}
272282

@@ -283,6 +293,12 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
283293
_mySegmentControl.currentIndex = carousel.currentItemIndex;
284294
}
285295
ProjectTaskListView *curView = (ProjectTaskListView *)carousel.currentItemView;
296+
NSInteger index = carousel.scrollOffset;
297+
if (index == 0) {
298+
curView.project_id = nil;
299+
} else {
300+
curView.project_id = ((Project *)_myProjectList[index - 1]).id.stringValue;
301+
}
286302
[curView refreshToQueryData];
287303
[carousel.visibleItemViews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
288304
[obj setSubScrollsToTop:(obj == carousel.currentItemView)];

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,9 +1502,16 @@ - (void)request_tasks_searchWithOwner:(NSString *)owner project_id:(NSString *)p
15021502
}
15031503
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/tasks/search" withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {
15041504

1505-
Projects *pros = [NSObject objectOfClass:@"Tasks" fromJSON:data[@"data"]];
1505+
// Projects *pros = [NSObject objectOfClass:@"Projects" fromJSON:data[@"data"]];
1506+
// pros.list = [NSObject arrayFromJSON:data[@"data"][@"list"] ofObjects:@"Project"];
1507+
Tasks *pros = [NSObject objectOfClass:@"Tasks" fromJSON:data[@"data"]];
15061508
pros.list = [NSObject arrayFromJSON:data[@"data"][@"list"] ofObjects:@"Task"];
1507-
// Tasks
1509+
if (status.integerValue == 1) {
1510+
pros.processingList = pros.list;
1511+
} else {
1512+
pros.doneList = pros.list;
1513+
}
1514+
15081515
if (data) {
15091516
block(pros, nil);
15101517
}else{

Coding_iOS/Views/TableListView/ProjectTaskListView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
typedef void(^ProjectTaskBlock)(ProjectTaskListView *taskListView, Task *task);
1414

1515
@interface ProjectTaskListView : UIView<UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate>
16+
@property (nonatomic, strong) NSString *keyword;
17+
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
18+
@property (nonatomic, strong) NSString *label; //任务标签
19+
@property (nonatomic, strong) NSString *project_id;
1620

1721
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
1822
- (void)setTasks:(Tasks *)tasks;

Coding_iOS/Views/TableListView/ProjectTaskListView.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ - (void)sendRequest{
124124
[self beginLoading];
125125
}
126126
__weak typeof(self) weakSelf = self;
127+
128+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:_project_id keyword:_keyword status:_status label:_label andBlock:^(Tasks *data, NSError *error) {
129+
[weakSelf endLoading];
130+
[weakSelf.myRefreshControl endRefreshing];
131+
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
132+
if (data) {
133+
[weakSelf.myTasks configWithTasks:data];
134+
[weakSelf.myTableView reloadData];
135+
weakSelf.myTableView.showsInfiniteScrolling = weakSelf.myTasks.canLoadMore;
136+
}
137+
[weakSelf configBlankPage:EaseBlankPageTypeTask hasData:(weakSelf.myTasks.list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
138+
[weakSelf refresh];
139+
}];
140+
141+
142+
143+
}];
144+
return;
127145
[[Coding_NetAPIManager sharedManager] request_ProjectTaskList_WithObj:_myTasks andBlock:^(Tasks *data, NSError *error) {
128146
[weakSelf endLoading];
129147
[weakSelf.myRefreshControl endRefreshing];

0 commit comments

Comments
 (0)