@@ -32,6 +32,7 @@ @interface MyTask_RootViewController ()
3232@property (nonatomic , strong ) NSString *label; // 任务标签
3333@property (nonatomic , strong ) NSString *project_id;
3434@property (nonatomic , strong ) NSString *owner, *watcher, *creator;
35+ @property (nonatomic , assign ) TaskRoleType role;
3536@end
3637
3738@implementation MyTask_RootViewController
@@ -89,10 +90,12 @@ - (void)viewDidLoad
8990 _owner = [Login curLoginUser ].id .stringValue ;
9091
9192 // 初始化过滤目录
92- _myFliterMenu = [[TaskSelectionView alloc ] initWithFrame: CGRectMake (0 , 64 , kScreen_Width , kScreen_Height - 64 ) items: @[@" 我的任务" , @" 我关注的" , @" 我创建的" ]];
93+ _myFliterMenu = [[TaskSelectionView alloc ] initWithFrame: CGRectMake (0 , 64 , kScreen_Width , kScreen_Height - 64 ) items: @[@" 我的任务(0) " , @" 我关注的(0) " , @" 我创建的(0) " ]];
9394 __weak typeof (self) weakSelf = self;
9495 _myFliterMenu.clickBlock = ^(NSInteger pageIndex){
95- [weakSelf.titleBtn setTitle: weakSelf.myFliterMenu.items[pageIndex] forState: UIControlStateNormal];
96+ _role = pageIndex;
97+ NSString *title = weakSelf.myFliterMenu .items [pageIndex];
98+ [weakSelf.titleBtn setTitle: [title substringToIndex: 4 ] forState: UIControlStateNormal];
9699 weakSelf.owner = weakSelf.watcher = weakSelf.creator = nil ;
97100 if (pageIndex == 0 ) {
98101 weakSelf.owner = [Login curLoginUser ].id .stringValue ;
@@ -106,13 +109,18 @@ - (void)viewDidLoad
106109 ProjectTaskListView *listView = (ProjectTaskListView *)weakSelf.myCarousel .currentItemView ;
107110 [weakSelf assignmentWithlistView: listView];
108111 [listView refresh ];
112+ [weakSelf resetTaskCount ];
113+ [weakSelf loadTasksLabels ];
109114
110115 };
111116 _myFliterMenu.closeBlock =^(){
112117 [weakSelf.myFliterMenu dismissMenu ];
113118 };
114119
115120 _screenView = [ScreenView creat ];
121+ weakSelf.screenView .tastArray = @[[NSString stringWithFormat: @" 进行中的(0)" ],
122+ [NSString stringWithFormat: @" 已完成的(0)" ]
123+ ];
116124 _screenView.selectBlock = ^(NSString *keyword, NSString *status, NSString *label) {
117125 [((UIButton *)screenBar.customView) setImage: [UIImage imageNamed: @" a1-hasScreen" ] forState: UIControlStateNormal];
118126 weakSelf.keyword = keyword;
@@ -127,10 +135,10 @@ - (void)viewDidLoad
127135 [listView refresh ];
128136
129137 };
130-
131-
132138}
133139
140+
141+
134142- (void )addItemClicked : (id )sender {
135143 EditTaskViewController *vc = [EditTaskViewController new ];
136144
@@ -143,6 +151,7 @@ - (void)addItemClicked:(id)sender{
143151}
144152
145153- (void )screenItemClicked : (UIBarButtonItem *)sender {
154+ [_myFliterMenu dismissMenu ];
146155 [_screenView showOrHide ];
147156}
148157
@@ -155,6 +164,9 @@ - (void)didReceiveMemoryWarning
155164- (void )viewWillAppear : (BOOL )animated {
156165 [super viewWillAppear: animated];
157166 [self resetCurView ];
167+ [self resetTaskCount ];
168+ [self loadTasksLabels ];
169+
158170}
159171
160172
@@ -169,6 +181,49 @@ - (void)resetCurView{
169181 }
170182}
171183
184+ - (void )resetTaskCount {
185+ __weak typeof (self) weakSelf = self;
186+ [[Coding_NetAPIManager sharedManager ] request_tasks_countAndBlock: ^(id data, NSError *error) {
187+ NSInteger processing = [data[@" data" ][@" processing" ] integerValue ];
188+ NSInteger done = [data[@" data" ][@" done" ] integerValue ];
189+
190+ NSInteger watchAll = [data[@" data" ][@" watchAll" ] integerValue ];
191+ NSInteger watchAllProcessing = [data[@" data" ][@" watchAllProcessing" ] integerValue ];
192+
193+ NSInteger create = [data[@" data" ][@" create" ] integerValue ];
194+ NSInteger createProcessing = [data[@" data" ][@" createProcessing" ] integerValue ];
195+
196+
197+ weakSelf.myFliterMenu .items = @[[NSString stringWithFormat: @" 我的任务(%ld )" , processing + done],
198+ [NSString stringWithFormat: @" 我关注的(%ld )" , watchAll],
199+ [NSString stringWithFormat: @" 我创建的(%ld )" , create]
200+ ];
201+ if (weakSelf.role == TaskRoleTypeWatcher) {
202+ processing = watchAllProcessing;
203+ done = watchAll - processing;
204+ }
205+
206+ if (weakSelf.role == TaskRoleTypeCreator) {
207+ processing = createProcessing;
208+ done = create - processing;
209+ }
210+
211+ weakSelf.screenView .tastArray = @[[NSString stringWithFormat: @" 进行中的(%ld )" , processing],
212+ [NSString stringWithFormat: @" 已完成的(%ld )" , done]
213+ ];
214+ }];
215+
216+ }
217+
218+ - (void )loadTasksLabels {
219+ __weak typeof (self) weakSelf = self;
220+ [[Coding_NetAPIManager sharedManager ] request_projects_tasks_labelsWithRole: _role andBlock: ^(id data, NSError *error) {
221+ if (data != nil ) {
222+ weakSelf.screenView .labels = data[@" data" ];
223+ }
224+ }];
225+ }
226+
172227- (void )configSegmentControlWithData : (Projects *)freshProjects {
173228
174229 BOOL dataHasChanged = NO ;
@@ -236,10 +291,6 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
236291 };
237292 [weakSelf.navigationController pushViewController: vc animated: YES ];
238293 } tabBarHeight: CGRectGetHeight (self .rdv_tabBarController.tabBar.frame)];
239- listView.taskcountBlock = ^(NSInteger processingCount, NSInteger doneListCount) {
240- weakSelf.screenView .processingCount = processingCount;
241- weakSelf.screenView .doneListCount = doneListCount;
242- };
243294 }
244295 [listView setSubScrollsToTop: (index == carousel.currentItemIndex)];
245296 return listView;
0 commit comments