Skip to content

Commit 6d93fe3

Browse files
张达棣张达棣
authored andcommitted
修改接口
1 parent 0b05aba commit 6d93fe3

9 files changed

Lines changed: 41 additions & 118 deletions

File tree

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,19 @@ - (void)viewDidLoad
117117
[tasksView refresh];
118118
}
119119

120+
_role = TaskRoleTypeAll;
120121
//初始化过滤目录
121122
_myFliterMenu = [[TaskSelectionView alloc] initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Height - 64) items:@[@"所有任务(0)", @"我关注的(0)", @"我创建的(0)"]];
122123
__weak typeof(self) weakSelf = self;
123124
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
124125
_role = pageIndex;
126+
if (pageIndex == 0) {
127+
_role = TaskRoleTypeAll;
128+
}
125129

126130
NSString *title = weakSelf.myFliterMenu.items[pageIndex];
127131
[weakSelf.titleBtn setTitle:[title substringToIndex:4] forState:UIControlStateNormal];
128132

129-
weakSelf.owner = weakSelf.watcher = weakSelf.creator = nil;
130-
if (pageIndex == 0) {
131-
weakSelf.owner = [Login curLoginUser].id.stringValue;
132-
}
133-
if (pageIndex == 1) {
134-
weakSelf.watcher = [Login curLoginUser].id.stringValue;
135-
}
136-
if (pageIndex == 2) {
137-
weakSelf.creator = [Login curLoginUser].id.stringValue;
138-
}
139133
UIView *curView = [weakSelf getCurContentView];
140134
if (![curView isKindOfClass:[ProjectTasksView class]]) {
141135
return;
@@ -332,7 +326,7 @@ - (void)refreshWithNewIndex:(NSInteger)newIndex{
332326
} defaultIndex:0];
333327
});
334328
((ProjectTasksView *)curView).selctUserBlock = ^(NSString *owner) {
335-
weakSelf.owner = owner;
329+
weakSelf.userId = owner;
336330
};
337331
}
338332
break;
@@ -726,7 +720,7 @@ - (void)setupTitleBtn{
726720
[_titleBtn.titleLabel setFont:[UIFont systemFontOfSize:kNavTitleFontSize]];
727721
[_titleBtn addTarget:self action:@selector(fliterClicked:) forControlEvents:UIControlEventTouchUpInside];
728722
self.navigationItem.titleView = _titleBtn;
729-
[self setTitleBtnStr:@"我的任务"];
723+
[self setTitleBtnStr:@"所有任务"];
730724
}
731725
}
732726

@@ -756,9 +750,8 @@ - (void)assignmentWithlistView:(ProjectTasksView *)listView {
756750
listView.keyword = self.keyword;
757751
listView.status = self.status;
758752
listView.label = self.label;
759-
listView.owner = self.owner;
760-
listView.watcher = self.watcher;
761-
listView.creator = self.creator;
753+
listView.userId = self.userId;
754+
listView.role = self.role;
762755
listView.project_id = self.myProject.id.stringValue;
763756
}
764757

Coding_iOS/Controllers/RootControllers/MyTask_RootViewController.m

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ @interface MyTask_RootViewController ()
3131
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
3232
@property (nonatomic, strong) NSString *label; //任务标签
3333
@property (nonatomic, strong) NSString *project_id;
34-
@property (nonatomic, strong) NSString *owner, *watcher, *creator;
3534
@property (nonatomic, assign) TaskRoleType role;
3635
@end
3736

@@ -87,25 +86,13 @@ - (void)viewDidLoad
8786
self.navigationItem.rightBarButtonItems = @[addBar, screenBar];
8887

8988

90-
_owner = [Login curLoginUser].id.stringValue;
91-
9289
//初始化过滤目录
9390
_myFliterMenu = [[TaskSelectionView alloc] initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Height - 64) items:@[@"我的任务(0)", @"我关注的(0)", @"我创建的(0)"]];
9491
__weak typeof(self) weakSelf = self;
9592
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
9693
_role = pageIndex;
9794
NSString *title = weakSelf.myFliterMenu.items[pageIndex];
9895
[weakSelf.titleBtn setTitle:[title substringToIndex:4] forState:UIControlStateNormal];
99-
weakSelf.owner = weakSelf.watcher = weakSelf.creator = nil;
100-
if (pageIndex == 0) {
101-
weakSelf.owner = [Login curLoginUser].id.stringValue;
102-
}
103-
if (pageIndex == 1) {
104-
weakSelf.watcher = [Login curLoginUser].id.stringValue;
105-
}
106-
if (pageIndex == 2) {
107-
weakSelf.creator = [Login curLoginUser].id.stringValue;
108-
}
10996
ProjectTaskListView *listView = (ProjectTaskListView *)weakSelf.myCarousel.currentItemView;
11097
[weakSelf assignmentWithlistView:listView];
11198
[listView refresh];
@@ -283,7 +270,7 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
283270
[listView setTasks:curTasks];
284271
}else{
285272
__weak typeof(self) weakSelf = self;
286-
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks project_id:_project_id keyword:_keyword status:_status label:_label owner:_owner watcher:_watcher creator:_creator block:^(ProjectTaskListView *taskListView, Task *task) {
273+
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks project_id:_project_id keyword:_keyword status:_status label:_label userId:nil role:_role block:^(ProjectTaskListView *taskListView, Task *task) {
287274
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
288275
vc.myTask = task;
289276
vc.taskChangedBlock = ^(){
@@ -388,9 +375,7 @@ - (void)assignmentWithlistView:(ProjectTaskListView *)listView {
388375
listView.status = self.status;
389376
listView.label = self.label;
390377
listView.project_id = self.project_id;
391-
listView.owner = self.owner;
392-
listView.watcher = self.watcher;
393-
listView.creator = self.creator;
378+
listView.role = self.role;
394379
}
395380

396381

Coding_iOS/Models/Tasks.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ typedef NS_ENUM(NSInteger, TaskEntranceType){
2222

2323
typedef NS_ENUM(NSInteger, TaskRoleType)
2424
{
25-
TaskRoleTypeOwner = 0, //执行者
25+
TaskRoleTypeOwner = 0, //执行者 /所有任务
2626
TaskRoleTypeWatcher, //关注者
2727
TaskRoleTypeCreator, //创建者
28-
TaskRoleTypeAll, //全部
28+
TaskRoleTypeAll, //所有任务
2929
};
3030

3131
@interface Tasks : NSObject

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ typedef NS_ENUM(NSInteger, PurposeType) {
165165
- (void)request_DeleteComment:(TaskComment *)comment ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
166166
- (void)request_ChangeWatcher:(User *)watcher ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
167167
- (void)request_projects_tasks_labelsWithRole:(TaskRoleType)role projectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block; //任务标签
168-
- (void)request_tasks_searchWithOwner:(NSString *)owner watcher:(NSString *)watcher creator:(NSString *)creator project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
168+
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
169169
- (void)request_tasks_countAndBlock:(void (^)(id data, NSError *error))block;
170170
- (void)request_project_tasks_countWithProjectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block;
171171

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,16 +1494,10 @@ - (void)request_projects_tasks_labelsWithRole:(TaskRoleType)role projectId:(NSSt
14941494

14951495
}
14961496

1497-
- (void)request_tasks_searchWithOwner:(NSString *)owner watcher:(NSString *)watcher creator:(NSString *)creator project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block {
1497+
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block {
14981498
NSMutableDictionary *param = @{@"page": @(page)}.mutableCopy;
1499-
if (owner != nil) {
1500-
[param setValue:owner forKey:@"owner"];
1501-
}
1502-
if (watcher != nil) {
1503-
[param setValue:watcher forKey:@"watcher"];
1504-
}
1505-
if (creator != nil) {
1506-
[param setValue:creator forKey:@"creator"];
1499+
if (userId != nil) {
1500+
[param setValue:userId forKey:@"owner"];
15071501
}
15081502
if (project_id != nil) {
15091503
[param setValue:project_id forKey:@"project_id"];
@@ -1517,6 +1511,13 @@ - (void)request_tasks_searchWithOwner:(NSString *)owner watcher:(NSString *)watc
15171511
if (label != nil) {
15181512
[param setValue:label forKey:@"label"];
15191513
}
1514+
1515+
NSArray *roleArray = @[@"owner", @"watcher", @"creator"];
1516+
if (role < roleArray.count) {
1517+
[param setValue:[Login curLoginUser].id.stringValue forKey:roleArray[role]];
1518+
1519+
}
1520+
15201521
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/tasks/search" withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {
15211522

15221523
Tasks *pros = [NSObject objectOfClass:@"Tasks" fromJSON:data[@"data"]];

Coding_iOS/Views/TableListView/ProjectTaskListView.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ typedef void(^ProjectTaskBlock)(ProjectTaskListView *taskListView, Task *task);
1717
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
1818
@property (nonatomic, strong) NSString *label; //任务标签
1919
@property (nonatomic, strong) NSString *project_id;
20-
@property (nonatomic, strong) NSString *owner, *watcher, *creator;
20+
@property (nonatomic, strong) NSString *userId;
21+
@property (nonatomic, assign) TaskRoleType role;
2122

2223

23-
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
24-
25-
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label owner:(NSString *)owner watcher:(NSString *)watcher creator:(NSString *)creator block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
24+
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label userId:(NSString *)userId role:(TaskRoleType )role block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
2625
- (void)setTasks:(Tasks *)tasks;
2726
- (void)refreshToQueryData;
2827
- (void)tabBarItemClicked;

Coding_iOS/Views/TableListView/ProjectTaskListView.m

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -39,50 +39,7 @@ - (void)reloadData{
3939
}
4040
}
4141

42-
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight{
43-
self = [super initWithFrame:frame];
44-
if (self) {
45-
// Initialization code
46-
_myTasks = tasks;
47-
_block = block;
48-
_page = 1;
49-
50-
_myTableView = ({
51-
UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
52-
tableView.backgroundColor = [UIColor clearColor];
53-
tableView.delegate = self;
54-
tableView.dataSource = self;
55-
[tableView registerClass:[ProjectTaskListViewCell class] forCellReuseIdentifier:kCellIdentifier_ProjectTaskList];
56-
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
57-
[self addSubview:tableView];
58-
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
59-
make.edges.equalTo(self);
60-
}];
61-
if (tabBarHeight != 0) {
62-
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, tabBarHeight, 0);
63-
tableView.contentInset = insets;
64-
tableView.scrollIndicatorInsets = insets;
65-
}
66-
tableView;
67-
});
68-
69-
_myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
70-
[_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
71-
__weak typeof(self) weakSelf = self;
72-
[_myTableView addInfiniteScrollingWithActionHandler:^{
73-
[weakSelf refreshMore];
74-
}];
75-
if (_myTasks.list.count > 0) {
76-
[_myTableView reloadData];
77-
}else{
78-
[self sendRequest];
79-
}
80-
}
81-
return self;
82-
}
83-
84-
85-
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label owner:(NSString *)owner watcher:(NSString *)watcher creator:(NSString *)creator block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight{
42+
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label userId:(NSString *)userId role:(TaskRoleType )role block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight{
8643
self = [super initWithFrame:frame];
8744
if (self) {
8845
// Initialization code
@@ -94,9 +51,8 @@ - (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)pr
9451
self.keyword = keyword;
9552
self.status = status;
9653
self.label = label;
97-
self.owner = owner;
98-
self.watcher = watcher;
99-
self.creator = creator;
54+
self.userId = userId;
55+
self.role = role;
10056

10157

10258
_myTableView = ({
@@ -180,7 +136,7 @@ - (void)sendRequest{
180136
}
181137
__weak typeof(self) weakSelf = self;
182138

183-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:_owner watcher:_watcher creator:_creator project_id:_project_id keyword:_keyword status:_status label:_label page:_page andBlock:^(Tasks *data, NSError *error) {
139+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:_role project_id:_project_id keyword:_keyword status:_status label:_label page:_page andBlock:^(Tasks *data, NSError *error) {
184140
[weakSelf endLoading];
185141
[weakSelf.myRefreshControl endRefreshing];
186142
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
@@ -194,21 +150,6 @@ - (void)sendRequest{
194150
}];
195151

196152
}];
197-
/*
198-
[[Coding_NetAPIManager sharedManager] request_ProjectTaskList_WithObj:_myTasks andBlock:^(Tasks *data, NSError *error) {
199-
[weakSelf endLoading];
200-
[weakSelf.myRefreshControl endRefreshing];
201-
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
202-
if (data) {
203-
[weakSelf.myTasks configWithTasks:data];
204-
[weakSelf.myTableView reloadData];
205-
weakSelf.myTableView.showsInfiniteScrolling = weakSelf.myTasks.canLoadMore;
206-
}
207-
[weakSelf configBlankPage:EaseBlankPageTypeTask hasData:(weakSelf.myTasks.list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
208-
[weakSelf refresh];
209-
}];
210-
}];
211-
*/
212153
}
213154

214155

Coding_iOS/Views/TableListView/ProjectTasksView.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
@property (nonatomic, strong) NSString *keyword;
1919
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
2020
@property (nonatomic, strong) NSString *label; //任务标签
21-
@property (nonatomic, strong) NSString *owner, *watcher, *creator;
21+
@property (nonatomic, strong) NSString *userId;
22+
@property (nonatomic, assign) TaskRoleType role;
2223
@property (nonatomic, strong) NSString *project_id;
2324
@property (nonatomic, copy) void(^selctUserBlock)(NSString *owner);
2425

Coding_iOS/Views/TableListView/ProjectTasksView.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ - (id)initWithFrame:(CGRect)frame project:(Project *)project block:(ProjectTaskB
3030
if (self) {
3131
// Initialization code
3232
_myProject = project;
33+
_role = TaskRoleTypeAll;
3334
self.project_id = project.id.stringValue;
3435
_block = block;
3536
_myProTksDict = [[NSMutableDictionary alloc] initWithCapacity:1];
@@ -102,7 +103,10 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
102103
[self assignmentWithlistView:listView];
103104
[listView setTasks:curTasks];
104105
}else{
105-
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks project_id:_project_id keyword:_keyword status:_status label:_label owner:_owner watcher:_watcher creator:_creator block:_block tabBarHeight:0];
106+
if (_role == TaskRoleTypeOwner) {
107+
_role = TaskRoleTypeAll;
108+
}
109+
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks project_id:_project_id keyword:_keyword status:_status label:_label userId:_userId role:_role block:_block tabBarHeight:0];
106110
}
107111
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
108112
return listView;
@@ -125,9 +129,9 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
125129
if (index != 0) {
126130
userId = ((ProjectMember *)_myMemberList[index]).user_id.stringValue;
127131
}
128-
_owner = userId;
132+
_userId = userId;
129133
if (_selctUserBlock) {
130-
_selctUserBlock(_owner);
134+
_selctUserBlock(_userId);
131135
}
132136
[self refresh];
133137

@@ -140,9 +144,8 @@ - (void)assignmentWithlistView:(ProjectTaskListView *)listView {
140144
listView.keyword = self.keyword;
141145
listView.status = self.status;
142146
listView.label = self.label;
143-
listView.owner = self.owner;
144-
listView.watcher = self.watcher;
145-
listView.creator = self.creator;
147+
listView.userId = self.userId;
148+
listView.role = self.role;
146149
listView.project_id = _project_id;
147150
}
148151

0 commit comments

Comments
 (0)