Commit a64cbdf8 authored by freecui's avatar freecui

modify 首页bug

parent 404500c5
......@@ -66,7 +66,7 @@
if (![_dataBase open]) {
[self openDb];
}
NSString *createTableSql = @"CREATE TABLE IF NOT EXISTS displayFunction (Id INTEGER PRIMARY KEY AUTOINCREMENT,functionId INTEGER,functionName VARCHAR ,functionImgName VARCHAR,functionSmallImgName VARCHAR, isSelected INTEGER,functionItemTag INTEGER )";
NSString *createTableSql = @"CREATE TABLE IF NOT EXISTS displayFunction (Id INTEGER PRIMARY KEY AUTOINCREMENT,functionId INTEGER,functionName VARCHAR ,functionImgName VARCHAR,functionSmallImgName VARCHAR, isSelected INTEGER,hasPermission INTEGER,functionItemTag INTEGER )";
BOOL work = [_dataBase executeUpdate:createTableSql];
return work;
......@@ -196,24 +196,31 @@
#pragma displayFunction
- (BOOL)insertDisplayFunction: (GXFDisplayFunction *)displayFunction {
NSString *inserSql = @"INSERT INTO displayFunction(functionId,functionName,functionImgName,functionSmallImgName,functionItemTag) VALUES(?,?,?,?,?)";
BOOL work = [_dataBase executeUpdate:inserSql,@(displayFunction.functionId),displayFunction.functionName,displayFunction.functionImgName,displayFunction.functionSmallImgName,@(displayFunction.functionItemTag)];
NSString *inserSql = @"INSERT INTO displayFunction(functionId,functionName,functionImgName,functionSmallImgName,hasPermission,functionItemTag) VALUES(?,?,?,?,?,?)";
BOOL work = [_dataBase executeUpdate:inserSql,@(displayFunction.functionId),displayFunction.functionName,displayFunction.functionImgName,displayFunction.functionSmallImgName,@(0),@(displayFunction.functionItemTag)];
return work;
}
- (GXFDisplayFunction *)selectDisplayFunctionByFunctionId: (NSInteger)functionId{
GXFDisplayFunction *displayFunction = [[GXFDisplayFunction alloc]init];
FMResultSet *rs = [_dataBase executeQuery:@"SELET * FROM displayFunction WHERE functionId = ? ",@(functionId)];
while ([rs next]) {
displayFunction.functionId = [rs intForColumn:@"functionId"];
displayFunction.functionName = [rs stringForColumn:@"functionName"];
displayFunction.functionImgName = [rs stringForColumn:@"functionImgName"];
displayFunction.functionSmallImgName = [rs stringForColumn:@"functionSmallImgName"];
displayFunction.functionItemTag = [rs intForColumn:@"functionItemTag"];
break;
}
return displayFunction;
//- (GXFDisplayFunction *)upDatePermissionDisplayFunctionByFunctionId: (NSInteger)functionId {
// GXFDisplayFunction *displayFunction = [[GXFDisplayFunction alloc]init];
// FMResultSet *rs = [_dataBase executeQuery:@"SELET * FROM displayFunction WHERE functionId = ? ",@(functionId)];
// while ([rs next]) {
// displayFunction.functionId = [rs intForColumn:@"functionId"];
// displayFunction.functionName = [rs stringForColumn:@"functionName"];
// displayFunction.functionImgName = [rs stringForColumn:@"functionImgName"];
// displayFunction.functionSmallImgName = [rs stringForColumn:@"functionSmallImgName"];
// displayFunction.functionItemTag = [rs intForColumn:@"functionItemTag"];
// break;
// }
// return displayFunction;
//}
//更新权限
- (BOOL)updateDisplayFunctionPermissionWithId: (GXFDisplayFunction *)displayFunction{
BOOL work = [_dataBase executeUpdate:@"UPDATE displayFunction SET hasPermission = ? where functionId = ?",@(displayFunction.hasPermission),@(displayFunction.functionId)];
return work;
}
//更新是否选中
- (BOOL)updateDisplayFunctionIsSelectedWithId: (GXFDisplayFunction *)displayFunction{
BOOL work = [_dataBase executeUpdate:@"UPDATE displayFunction SET isSelected = ? where functionId = ?",@(displayFunction.isSelected),@(displayFunction.functionId)];
......@@ -221,31 +228,151 @@
}
#pragma 有权限的displayfunctions
//待改正,最好的办法是两张表关联起来查找但是我还没做到
//返回有权限的,并更新了权限
-(NSArray *)displayFunctionsHasPermission{
NSMutableArray *muArr = [NSMutableArray array];
NSArray *hasPermission = [self p_functionsIdPermission];
BOOL hasSeeOption1 = NO;
BOOL hasSeeOption3 = NO;
BOOL hasSeeOption4 = NO;
BOOL hasSeeOption5 = NO;
BOOL hasSeeOption6 = NO;
BOOL hasSeeOption7 = NO;
for (int count = 0; count < hasPermission.count; count ++) {
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction WHERE functionId = ?",hasPermission[count] ];
while ([rs next]) {
GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
displayFunction.hasPermission = YES;
[self updateDisplayFunctionPermissionWithId:displayFunction];
[muArr addObject:displayFunction];
if (displayFunction.functionId == 500102 && hasSeeOption1 == NO) {
hasSeeOption1 = YES;
}
if (displayFunction.functionId == 500103 && hasSeeOption1 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption1 = NO;
}
continue;
}
}
return muArr;
}
//把显示重复功能的去掉
- (NSArray *)siftDuplicationDisplayFunctionsButton {
NSMutableArray *allDisplayFunctionsArr = [NSMutableArray arrayWithArray:[self displayFunctionsHasPermission]];
NSMutableArray *muArr = [NSMutableArray array];
NSArray *hasPermission = [self p_functionsIdPermission];
BOOL hasSeeOption1 = NO;
BOOL hasSeeOption3 = NO;
BOOL hasSeeOption4 = NO;
BOOL hasSeeOption5 = NO;
BOOL hasSeeOption6 = NO;
BOOL hasSeeOption7 = NO;
for (int count = 0; count < hasPermission.count; count ++) {
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction WHERE functionId = ?",hasPermission[count] ];
while ([rs next]) {
GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
[muArr addObject:displayFunction];
//"行情反馈",
if (displayFunction.functionId == 500102 && hasSeeOption1 == NO) {
hasSeeOption1 = YES;
}
if (displayFunction.functionId == 500103 && hasSeeOption1 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption1 = NO;
}
//"采购通知"
if (displayFunction.functionId == 500302 && hasSeeOption3 == NO) {
hasSeeOption3 = YES;
}
if (displayFunction.functionId == 500303 && hasSeeOption3 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption3 = NO;
}
//采购单???? 有三个:"全部查看权"、"本人查看权"、 "供应商查看权"
if (displayFunction.functionId == 500402 && hasSeeOption4 == NO) {
hasSeeOption4 = YES;
}
if (displayFunction.functionId == 500403 && hasSeeOption4 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption4 = YES;
}
// if (displayFunction.functionId == 500403 && hasSeeOption4 == NO) {
// //[muArr removeObject:displayFunction];
// hasSeeOption4 = YES;
// }
// if (displayFunction.functionId == 500403 && hasSeeOption4 == YES) {
// [muArr removeObject:displayFunction];
// hasSeeOption4 = YES;
// }
// if (displayFunction.functionId == 500404 && hasSeeOption4 == YES) {
// [muArr removeObject:displayFunction];
// hasSeeOption4 = YES;
// }
//"发运单"
if (displayFunction.functionId == 500502 && hasSeeOption5 == NO) {
hasSeeOption5 = YES;
}
if (displayFunction.functionId == 500503 && hasSeeOption5 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption5 = NO;
}
//"转运单"
if (displayFunction.functionId == 500602 && hasSeeOption6 == NO) {
hasSeeOption6 = YES;
}
if (displayFunction.functionId == 500603 && hasSeeOption6 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption6 = NO;
}
//"加工单"
if (displayFunction.functionId == 500702 && hasSeeOption7 == NO) {
hasSeeOption7 = YES;
}
if (displayFunction.functionId == 500703 && hasSeeOption7 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption7 = NO;
}
}
}
return muArr;
}
//默认配置显示功能 初始配置为
- (NSArray *)defaultdisplayFunctions {
NSMutableArray *arr = [NSMutableArray arrayWithArray:[self displayFunctionsHasPermission]];
for (int count = 0; count < arr.count; count ++) {
if ((count % 2) || (count == 0)) {
GXFDisplayFunction *displayFunction = (GXFDisplayFunction *)arr[count];
displayFunction.isSelected = YES;
[self updateDisplayFunctionIsSelectedWithId:displayFunction];
[arr replaceObjectAtIndex:count withObject:displayFunction];
}
}
......@@ -256,9 +383,72 @@
- (NSArray *)originDisplayFunctions {
NSMutableArray *muArr = [NSMutableArray array];
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction"];
BOOL hasSeeOption1 = NO;
BOOL hasSeeOption3 = NO;
BOOL hasSeeOption4 = NO;
BOOL hasSeeOption5 = NO;
BOOL hasSeeOption6 = NO;
BOOL hasSeeOption7 = NO;
while ([rs next]) {
GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
[muArr addObject:displayFunction];
//"行情反馈",
if (displayFunction.functionId == 500102 && hasSeeOption1 == NO) {
hasSeeOption1 = YES;
}
if (displayFunction.functionId == 500103 && hasSeeOption1 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption1 = NO;
}
//"采购通知"
if (displayFunction.functionId == 500302 && hasSeeOption3 == NO) {
hasSeeOption3 = YES;
}
if (displayFunction.functionId == 500303 && hasSeeOption3 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption3 = NO;
}
//采购单???? 有三个:"全部查看权"、"本人查看权"、 "供应商查看权"
if (displayFunction.functionId == 500402 && hasSeeOption4 == NO) {
hasSeeOption4 = YES;
}
if (displayFunction.functionId == 500403 && hasSeeOption4 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption4 = YES;
}
//"发运单"
if (displayFunction.functionId == 500502 && hasSeeOption5 == NO) {
hasSeeOption5 = YES;
}
if (displayFunction.functionId == 500503 && hasSeeOption5 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption5 = NO;
}
//"转运单"
if (displayFunction.functionId == 500602 && hasSeeOption6 == NO) {
hasSeeOption6 = YES;
}
if (displayFunction.functionId == 500603 && hasSeeOption6 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption6 = NO;
}
//"加工单"
if (displayFunction.functionId == 500702 && hasSeeOption7 == NO) {
hasSeeOption7 = YES;
}
if (displayFunction.functionId == 500703 && hasSeeOption7 == YES) {
[muArr removeObject:displayFunction];
hasSeeOption7 = NO;
}
}
return muArr;
......@@ -271,6 +461,7 @@
displayFunction.functionImgName = [rs stringForColumn:@"functionImgName"];
displayFunction.functionSmallImgName = [rs stringForColumn:@"functionSmallImgName"];
displayFunction.isSelected = [rs intForColumn:@"isSelected"];
displayFunction.hasPermission = [rs intForColumn:@"hasPermission"];
displayFunction.functionItemTag = [rs intForColumn:@"functionItemTag"];
return displayFunction;
}
......
......@@ -89,7 +89,7 @@
@(500101),@(500102),@(500103),
@(500201),
@(500301),@(500302),@(500303),//"采购通知",
@(500401),@(500402),@(500403),@(500406),//"采购单"
@(500401),@(500402),@(500403),@(500404),//"采购单"
@(500501),@(500502),@(500503),//"发运单"
@(500601),@(500602),@(500603),//"转运单"
@(500701),@(500702),@(500703),];//加工单
......@@ -97,7 +97,7 @@
@"新建行情调研",@"查看行情调研", @"查看行情调研",
@"填写行情反馈",
@"新建采购通知",@"查看采购通知", @"查看采购通知",
@"新建采购单",@"查看采购单", @"查看采购单", @"审核采购单【供应商】",
@"新建采购单",@"查看采购单", @"查看采购单", @"审核采购单",//【供应商】",
@"新建发运单",@"查看发运单", @"查看发运单",
@"新增加工单",@"查看加工单", @"查看加工单",
@"新建转运单", @"查看转运单", @"查看转运单"];
......
......@@ -54,7 +54,7 @@ static NSString *cellID = @"cell";
self.navigationItem.rightBarButtonItem = rightBarBtn;
}
- (void)setupTableView {
self.f_tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
self.f_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height - 64) style:UITableViewStyleGrouped];
self.f_tableView.dataSource = self;
self.f_tableView.delegate = self;
//[self.f_tableView dequeueReusableCellWithIdentifier ]
......
......@@ -58,7 +58,7 @@
@end
@implementation ICRHomeViewController
static NSString *cellID = @"cell";
static NSString *firestCellID = @"firestCell";
static NSString *secondCellID = @"secondCell";
static NSString *collectionCellID = @"collectionCell";
//static CGFloat colletionCellHeight [UIScreen mainScreen].bounds.size.width / 3.0
......@@ -187,24 +187,30 @@ static NSString *collectionCellID = @"collectionCell";
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
UITableViewCell *cell; //= [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
if (indexPath.section == 0) {
cell = [[GXFNoticeFunctionTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = @"查看行情反馈-进行中";
cell = [tableView dequeueReusableCellWithIdentifier:firestCellID];
if (!cell) {
cell = [[GXFNoticeFunctionTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:firestCellID];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = @"查看行情反馈-进行中";
}
} else {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"secondCell"];
cell = [tableView dequeueReusableCellWithIdentifier:secondCellID];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:secondCellID];
} else {
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView *)[cell.contentView.subviews lastObject]removeFromSuperview];
}
}
[cell.contentView addSubview:_f_functionBaseView];
NSLog(@"%@",NSStringFromCGRect(cell.frame));
}
} else {
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
}
}
return cell;
}
......
......@@ -15,6 +15,7 @@
@property (nonatomic, copy) NSString *functionImgName; //
@property (nonatomic, copy) NSString *functionSmallImgName;
@property (nonatomic, assign) BOOL isSelected; //选中
@property (nonatomic, assign) BOOL hasPermission;
@property (nonatomic, assign) NSInteger functionItemTag;
+ (instancetype)initClassWithDictionary: (NSDictionary *)dict;
......
......@@ -163,12 +163,14 @@
}
}
if (![[GXFFunctionDB sharedInstance]defaultdisplayFunctions]) {
//配置功能 不是默认配置
NSUserDefaults *f_default = [NSUserDefaults standardUserDefaults];
BOOL noDefault = [[f_default objectForKey:@"noDefault"] integerValue] > 0 ? YES : NO;
if (!noDefault) {
[[GXFFunctionDB sharedInstance]defaultdisplayFunctions];
}
};
void(^fail)(id) = ^(id data) {
......
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