Commit 11b26e92 authored by admin's avatar admin

完善在线抽查权限

parent e0627ecd
......@@ -321,12 +321,18 @@
cell.photoButton2.tag = 22011;
[cell.photoButton2 addTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// UILongPressGestureRecognizer *longGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longClick:)];
// [cell.photoButton1 addGestureRecognizer:longGR];
// cell.contentView.backgroundColor = [UIColor orangeColor];
return cell;
} else {
InspectAddCell *cell=[tableView dequeueReusableCellWithIdentifier:kOnLineInspectAddCell];
if (!cell) {
cell = [[InspectAddCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kOnLineInspectAddCell];
}
cell.photoButton.tag = 22001;
[cell.photoButton addTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
......@@ -347,6 +353,8 @@
cell.photoButton1.tag = 1118 + (indexPath.row ) * 2;
[cell.photoButton1 setImage:image00 forState:UIControlStateNormal];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSString *imageName1 = _imageNameArray[(indexPath.row) * 2 + 1];
NSString *fullPath1 = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName1];
......@@ -355,6 +363,13 @@
[cell.photoButton2 addTarget:self action:@selector(showLookOnLinePic:) forControlEvents:UIControlEventTouchUpInside];
cell.photoButton2.tag = 1118 + (indexPath.row ) * 2 + 1;
[cell.photoButton2 setImage:image11 forState:UIControlStateNormal];
// UILongPressGestureRecognizer *longGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longClick:)];
//
// [cell.photoButton1 addGestureRecognizer:longGR];
// [cell.photoButton2 addGestureRecognizer:longGR];
return cell;
}
......@@ -362,6 +377,39 @@
}
- (void)longClick:(UIGestureRecognizer *)longGR
{
if (longGR.state == UIGestureRecognizerStateBegan) {
// 获取到点击的显示图片的按钮
UIButton *showButton = (UIButton *)longGR.view;
// 创建长按删除的按钮
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
deleteButton.tag = 5521 + (showButton.tag - 1118);
deleteButton.backgroundColor = [UIColor redColor];
deleteButton.bounds = CGRectMake(0, 0, 20, 20);
[deleteButton addTarget:self action:@selector(deletePicture:) forControlEvents:UIControlEventTouchUpInside];
deleteButton.frame = CGRectMake(showButton.frame.size.width - deleteButton.frame.size.width, 0, deleteButton.frame.size.width, deleteButton.frame.size.height);
[showButton addSubview:deleteButton];
}
}
// 删除图片
- (void)deletePicture:(UIButton *)button
{
// 从存放所有Image的数组里移除当前点击的Image
[self.imageNameArray removeObjectAtIndex:(button.tag - 5521)];
if ((_imageNameArray.count + 1) % 2 == 0) {
_rowNumber--;
[self.tableView reloadData];
} else {
[self.tableView reloadData];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return CGFLOAT_MIN;
......
......@@ -109,7 +109,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
self.navigationItem.titleView = customLab;
self.titleArray = [NSMutableArray array];
self.sectionArray = [NSMutableArray arrayWithObjects:@"口碑报告",@"商场风采",@"优秀案例",@"巡店报告", @"问题知识",@"口碑巡检",@"在线抽查", @"查看抽查",nil];
self.sectionArray = [NSMutableArray arrayWithObjects:@"口碑报告",@"商场风采",@"优秀案例",@"巡店报告", @"问题知识",@"口碑巡检",@"在线抽查",nil];
// self.sectionArray = [NSMutableArray arrayWithObjects:@"口碑报告",@"商场风采",@"优秀案例",@"巡店报告", @"问题知识",@"口碑巡检",nil];
self.allRankListArray = [NSMutableArray array];
......@@ -147,10 +147,14 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
if ([permissions containsObject:@"500301"] || [permissions containsObject:@"500302"]) {
[self.titleArray addObject:@"图说口碑"];
} else {
[_sectionArray removeObject:@"图说口碑"];
}
if ([permissions containsObject:@"500401"] || [permissions containsObject:@"500402"]) {
[self.titleArray addObject:@"口碑标准"];
} else {
[_sectionArray removeObject:@"口碑标准"];
}
if ([permissions containsObject:@"500501"] || [permissions containsObject:@"500502"]) {
......@@ -167,15 +171,26 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[_sectionArray removeObject:@"口碑巡检"];
}
if ([permissions containsObject:@"500701"]) {
if ([permissions containsObject:@"500701"] || [permissions containsObject:@"500702"]) {
[self.titleArray addObject:@"在线抽查"];
[self requestSpotCheckList];
if ([permissions containsObject:@"500701"]) {
[self requestLookOnLineList];
} else if ([permissions containsObject:@"500702"]){
[self requestSpotCheckList];
}
} else {
[_sectionArray removeObject:@"在线抽查"];
}
if ([permissions containsObject:@"500702"]) {
[self.titleArray addObject:@"查看抽查"];
[self requestLookOnLineList];
}
// if ([permissions containsObject:@"500702"]) {
// [self.titleArray addObject:@"在线抽查"];
//
// } else {
// [_sectionArray removeObjectAtIndex:7];
// }
[self setupTableView];
......@@ -617,6 +632,10 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
if (_allSpotCheckList.count == 0) {
[_sectionArray removeObject:@"在线抽查"];
} else {
if (![_sectionArray containsObject:@"在线抽查"]) {
[_sectionArray addObject:@"在线抽查"];
}
}
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
......@@ -648,7 +667,12 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
_allLookOnLineList = [NSMutableArray arrayWithArray:tempArray];
if (_allLookOnLineList.count == 0) {
[_sectionArray removeObject:@"查看抽查"];
[_sectionArray removeObject:@"在线抽查"];
} else {
if (![_sectionArray containsObject:@"在线抽查"]) {
[_sectionArray addObject:@"在线抽查"];
}
}
[self.tableView reloadData];
......@@ -707,11 +731,19 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
// 更多按钮点击事件
- (void)moreButtonClick:(UIButton *)sender
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
NSInteger section = sender.tag - 332892;
UINavigationController *nav;
if ([_sectionArray[section] isEqualToString:@"在线抽查"]) {
SpotCheckOnLineViewController *spotOnline = [[SpotCheckOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:spotOnline];
if ([permissions containsObject:@"500701"]) {
SpotCheckOnLineViewController *spotOnline = [[SpotCheckOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:spotOnline];
} else if ([permissions containsObject:@"500702"]){
LookOnLineViewController *lookOnLine = [[LookOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:lookOnLine];
}
} else if ([_sectionArray[section] isEqualToString:@"口碑巡检"]) {
InspectListViewController *inspectListVC = [[InspectListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:inspectListVC];
......@@ -727,9 +759,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} else if ([_sectionArray[section] isEqualToString:@"口碑报告"]){
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
} else if ([_sectionArray[section] isEqualToString:@"查看抽查"]){
LookOnLineViewController *lookOnLine = [[LookOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:lookOnLine];
} else if ([_sectionArray[section] isEqualToString:@"商场风采"]) {
PictureViewController *pic = [[PictureViewController alloc] init];
pic.come = @"首页";
......@@ -758,11 +787,21 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
- (void)itemClick:(HomeCellItem *)sender
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
HomeCellItem *item = (HomeCellItem *)sender;
UINavigationController *nav;
if ([item.titleLabel.text isEqualToString:@"在线抽查"]) {
SpotCheckOnLineViewController *spotOnline = [[SpotCheckOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:spotOnline];
if ([permissions containsObject:@"500701"]) {
SpotCheckOnLineViewController *spotOnline = [[SpotCheckOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:spotOnline];
} else if ([permissions containsObject:@"500702"]){
LookOnLineViewController *lookOnLine = [[LookOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:lookOnLine];
}
} else if ([item.titleLabel.text isEqualToString:@"口碑巡检"]) {
InspectListViewController *inspectListVC = [[InspectListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:inspectListVC];
......@@ -778,9 +817,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} else if ([item.titleLabel.text isEqualToString:@"口碑报告"]){
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
} else if ([item.titleLabel.text isEqualToString:@"查看抽查"]){
LookOnLineViewController *lookOnLine = [[LookOnLineViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:lookOnLine];
} else if ([item.titleLabel.text isEqualToString:@"商场风采"]) {
PictureViewController *pic = [[PictureViewController alloc] init];
pic.come = @"首页";
......@@ -806,6 +842,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
NSUInteger s2 = [_sectionArray indexOfObject:@"口碑报告"];
NSUInteger s4 = [_sectionArray indexOfObject:@"商场风采"];
NSUInteger s3 = [_sectionArray indexOfObject:@"问题知识"];
......@@ -813,7 +852,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
NSUInteger s5 = [_sectionArray indexOfObject:@"优秀案例"];
NSUInteger s6 = [_sectionArray indexOfObject:@"巡店报告"];
NSUInteger s7 = [_sectionArray indexOfObject:@"在线抽查"];
NSUInteger s8 = [_sectionArray indexOfObject:@"查看抽查"];
//NSUInteger s8 = [_sectionArray indexOfObject:@"在线抽查"];
if ([_sectionArray[section] isEqualToString:@"口碑巡检"] && section == s1) {
return _taskListDataArray.count;
......@@ -828,9 +867,13 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} else if ([_sectionArray[section] isEqualToString:@"巡店报告"] && section == s6) {
return _allPatrolReportArray.count;
} else if ([_sectionArray[section] isEqualToString:@"在线抽查"] && section == s7) {
return _allSpotCheckList.count;
} else if ([_sectionArray[section] isEqualToString:@"查看抽查"] && section == s8) {
return _allLookOnLineList.count;
if ([permissions containsObject:@"500701"]) {
return _allSpotCheckList.count;
} else if ([permissions containsObject:@"500702"]){
return _allLookOnLineList.count;
} else {
return 0;
}
} else {
return 0;
}
......@@ -840,6 +883,10 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
NSUInteger s2 = [_sectionArray indexOfObject:@"口碑报告"];
NSUInteger s4 = [_sectionArray indexOfObject:@"商场风采"];
NSUInteger s3 = [_sectionArray indexOfObject:@"问题知识"];
......@@ -847,7 +894,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
NSUInteger s5 = [_sectionArray indexOfObject:@"优秀案例"];
NSUInteger s6 = [_sectionArray indexOfObject:@"巡店报告"];
NSUInteger s7 = [_sectionArray indexOfObject:@"在线抽查"];
NSUInteger s8 = [_sectionArray indexOfObject:@"查看抽查"];
//NSUInteger s8 = [_sectionArray indexOfObject:@"在线抽查"];
if ([_sectionArray[indexPath.section] isEqualToString:@"口碑巡检"] && indexPath.section == s1) {
InspectListCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeInspectListCell];
......@@ -922,35 +969,36 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
cell.pictureList = _allPatrolReportArray[indexPath.row];
return cell;
} else if ([_sectionArray[indexPath.section] isEqualToString:@"在线抽查"] && indexPath.section == s7) {
SpotCheckTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeSpotCehcekCell];
if (!cell) {
cell = [[SpotCheckTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeSpotCehcekCell];
}
cell.spotCheck = _allSpotCheckList[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else if ([_sectionArray[indexPath.section] isEqualToString:@"查看抽查"] && indexPath.section == s8) {
LookOnLineTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeLookOnLineCell];
if (!cell) {
cell = [[LookOnLineTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeLookOnLineCell];
if ([permissions containsObject:@"500701"]) {
SpotCheckTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeSpotCehcekCell];
if (!cell) {
cell = [[SpotCheckTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeSpotCehcekCell];
}
cell.spotCheck = _allSpotCheckList[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else if ([permissions containsObject:@"500702"]){
LookOnLineTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeLookOnLineCell];
if (!cell) {
cell = [[LookOnLineTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeLookOnLineCell];
}
cell.lookOnLine = _allLookOnLineList[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
return nil;
}
cell.lookOnLine = _allLookOnLineList[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
return nil;
}
}
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
NSUInteger s2 = [_sectionArray indexOfObject:@"口碑报告"];
NSUInteger s4 = [_sectionArray indexOfObject:@"商场风采"];
NSUInteger s3 = [_sectionArray indexOfObject:@"问题知识"];
......@@ -958,7 +1006,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
NSUInteger s5 = [_sectionArray indexOfObject:@"优秀案例"];
NSUInteger s6 = [_sectionArray indexOfObject:@"巡店报告"];
NSUInteger s7 = [_sectionArray indexOfObject:@"在线抽查"];
NSUInteger s8 = [_sectionArray indexOfObject:@"查看抽查"];
//NSUInteger s8 = [_sectionArray indexOfObject:@"在线抽查"];
if ([_sectionArray[indexPath.section] isEqualToString:@"口碑巡检"] && indexPath.section == s1) {
InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init];
TaskListModel *taskList = self.taskListDataArray[indexPath.row];
......@@ -1009,18 +1057,26 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:storyVC animated:YES];
} else if ([_sectionArray[indexPath.section] isEqualToString:@"在线抽查"] && indexPath.section == s7) {
SpotCheckModel *spot = _allSpotCheckList[indexPath.row];
OnLineCompleteViewController *completeVC = [[OnLineCompleteViewController alloc] init];
completeVC.uuid = spot.uuid;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:completeVC animated:YES];
} else if ([_sectionArray[indexPath.section] isEqualToString:@"查看抽查"] && indexPath.section == s8) {
LookOnLineModel *lookOnLine = _allLookOnLineList[indexPath.row];
LookOnLineDetailViewController *lookDetailVC = [[LookOnLineDetailViewController alloc] init];
lookDetailVC.lookOnLine = lookOnLine;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:lookDetailVC animated:YES];
} else {
if ([permissions containsObject:@"500701"]) {
SpotCheckModel *spot = _allSpotCheckList[indexPath.row];
OnLineCompleteViewController *completeVC = [[OnLineCompleteViewController alloc] init];
completeVC.uuid = spot.uuid;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:completeVC animated:YES];
} else if ([permissions containsObject:@"500702"]){
LookOnLineModel *lookOnLine = _allLookOnLineList[indexPath.row];
LookOnLineDetailViewController *lookDetailVC = [[LookOnLineDetailViewController alloc] init];
lookDetailVC.lookOnLine = lookOnLine;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:lookDetailVC animated:YES];
} else {
return;
}
} else {
return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment