@@ -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)];
0 commit comments