Commit b9a36cf9 authored by freecui's avatar freecui

更改首页界面

parent c2a61d9c
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
//- (BOOL)functionTableCreate; //- (BOOL)functionTableCreate;
- (BOOL)displayFunctionTableCreate; - (BOOL)displayFunctionTableCreate;
- (BOOL)insertFunction: (GXFFunction *)function ; - (BOOL)insertFunction: (GXFFunction *)function ;
- (GXFFunction *)functionSelectWithId: (NSInteger)Id;
- (BOOL)updateFunctionHasPermissionWithId: (GXFFunction *)function; - (BOOL)updateFunctionHasPermissionWithId: (GXFFunction *)function;
- (BOOL)updateFunctionIsSelectedWithId: (GXFFunction *)function; - (BOOL)updateFunctionIsSelectedWithId: (GXFFunction *)function;
- (NSArray *)originFunctions;
//返回全部有权限的function //返回全部有权限的function
- (NSArray *)functionsHasPermission; - (NSArray *)functionsHasPermission;
//既有权限又被选择的 //既有权限又被选择的
...@@ -30,4 +32,10 @@ ...@@ -30,4 +32,10 @@
#pragma displayFunction #pragma displayFunction
- (BOOL)insertDisplayFunction: (GXFDisplayFunction *)displayFunction; - (BOOL)insertDisplayFunction: (GXFDisplayFunction *)displayFunction;
- (BOOL)updateDisplayFunctionIsSelectedWithId: (GXFDisplayFunction *)displayFunction;
-(NSArray *)displayFunctionsHasPermission;
//默认配置显示功能 初始配置为
- (NSArray *)defaultdisplayFunctions;
- (NSArray *)originDisplayFunctions;
- (NSArray *)isSelectedDisplayFunctions;
@end @end
...@@ -94,10 +94,27 @@ ...@@ -94,10 +94,27 @@
// [db close]; // [db close];
return work; return work;
} }
//查找一条数据
- (GXFFunction *)functionSelectWithId: (NSInteger)Id{
GXFFunction *function = [[GXFFunction alloc]init];
FMResultSet *rs = [_dataBase executeQuery:@"SELECT * FROM function WHERE Id = ? ",@(Id)];
while ([rs next]) {
function.Id = [rs intForColumnIndex:0];
function.name = [rs stringForColumnIndex:1];
function.caption = [rs stringForColumnIndex:2];
function.hasPermission = [rs intForColumnIndex:3];
function.isSelected = [rs intForColumnIndex:4];
break;
}
return function;
}
//更新权限 //更新权限
- (BOOL)updateFunctionHasPermissionWithId: (GXFFunction *)function{ - (BOOL)updateFunctionHasPermissionWithId: (GXFFunction *)function{
//GXFFunction *function = [self functionSelectWithId:Id];
BOOL work = [_dataBase executeUpdate:@"UPDATE function SET hasPermission = ? where Id = ?",function.hasPermission,function.Id]; BOOL work = [_dataBase executeUpdate:@"UPDATE function SET hasPermission = ? where Id = ?",@(function.hasPermission),@(function.Id)];
return work; return work;
} }
//更新是否选中 //更新是否选中
...@@ -105,6 +122,18 @@ ...@@ -105,6 +122,18 @@
BOOL work = [_dataBase executeUpdate:@"UPDATE function SET isSelected = ? where Id = ?",function.isSelected,function.Id]; BOOL work = [_dataBase executeUpdate:@"UPDATE function SET isSelected = ? where Id = ?",function.isSelected,function.Id];
return work; return work;
} }
//返回全部原始数据的function
- (NSArray *)originFunctions {
NSMutableArray *muArr = [NSMutableArray array];
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM function"];
while ([rs next]) {
GXFFunction *function = [[GXFFunction alloc]init];
function.Id = [rs intForColumn:@"Id"];
[muArr addObject:function];
}
return muArr;
}
//返回全部有权限的function //返回全部有权限的function
- (NSArray *)functionsHasPermission { - (NSArray *)functionsHasPermission {
NSMutableArray *muArr = [NSMutableArray array]; NSMutableArray *muArr = [NSMutableArray array];
...@@ -151,6 +180,19 @@ ...@@ -151,6 +180,19 @@
} }
#pragma displayFunction #pragma displayFunction
- (BOOL)insertDisplayFunction: (GXFDisplayFunction *)displayFunction { - (BOOL)insertDisplayFunction: (GXFDisplayFunction *)displayFunction {
...@@ -171,7 +213,11 @@ ...@@ -171,7 +213,11 @@
} }
return displayFunction; return displayFunction;
} }
//更新是否选中
- (BOOL)updateDisplayFunctionIsSelectedWithId: (GXFDisplayFunction *)displayFunction{
BOOL work = [_dataBase executeUpdate:@"UPDATE displayFunction SET isSelected = ? where functionId = ?",@(displayFunction.isSelected),@(displayFunction.functionId)];
return work;
}
#pragma 有权限的displayfunctions #pragma 有权限的displayfunctions
//待改正,最好的办法是两张表关联起来查找但是我还没做到 //待改正,最好的办法是两张表关联起来查找但是我还没做到
-(NSArray *)displayFunctionsHasPermission{ -(NSArray *)displayFunctionsHasPermission{
...@@ -180,19 +226,61 @@ ...@@ -180,19 +226,61 @@
NSArray *hasPermission = [self p_functionsIdPermission]; NSArray *hasPermission = [self p_functionsIdPermission];
for (int count = 0; count < hasPermission.count; count ++) { for (int count = 0; count < hasPermission.count; count ++) {
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction WHERE functionId = ?",[hasPermission[count] integerValue]]; FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction WHERE functionId = ?",hasPermission[count] ];
while ([rs next]) { while ([rs next]) {
GXFDisplayFunction *displayFunction = [[GXFDisplayFunction alloc]init]; GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
displayFunction.functionId = [rs intForColumn:@"functionId"];
displayFunction.functionName = [rs stringForColumn:@"functionName"];
displayFunction.functionImgName = [rs stringForColumn:@"functionImgName"];
displayFunction.functionSmallImgName = [rs stringForColumn:@"functionSmallImgName"];
[muArr addObject:displayFunction]; [muArr addObject:displayFunction];
} }
}
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];
}
}
return arr;
}
//返回全部原始数据的function
- (NSArray *)originDisplayFunctions {
NSMutableArray *muArr = [NSMutableArray array];
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction"];
while ([rs next]) {
GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
[muArr addObject:displayFunction];
} }
return muArr; return muArr;
} }
- (GXFDisplayFunction *)p_resultSetDisplayFunction: (FMResultSet *)rs {
GXFDisplayFunction *displayFunction = [[GXFDisplayFunction alloc]init];
displayFunction.functionId = [rs intForColumn:@"functionId"];
displayFunction.functionName = [rs stringForColumn:@"functionName"];
displayFunction.functionImgName = [rs stringForColumn:@"functionImgName"];
displayFunction.functionSmallImgName = [rs stringForColumn:@"functionSmallImgName"];
displayFunction.isSelected = [rs intForColumn:@"isSelected"];
return displayFunction;
}
//返回被选中的
- (NSArray *)isSelectedDisplayFunctions {
NSMutableArray *muArr = [NSMutableArray array];
FMResultSet *rs = [_dataBase executeQuery: @"SELECT * FROM displayFunction WHERE isSelected = ?",@(1)];
while ([rs next]) {
GXFDisplayFunction *displayFunction = [self p_resultSetDisplayFunction:rs];
[muArr addObject:displayFunction];
}
return muArr;
}
@end @end
...@@ -12,5 +12,8 @@ ...@@ -12,5 +12,8 @@
+ (instancetype)sharedInstance; + (instancetype)sharedInstance;
- (void)insertAllOriginFunctions; - (void)insertAllOriginFunctions;
- (BOOL)successInsertOriginFunctions;
- (void)insertAllOriginDisplayFunctions; - (void)insertAllOriginDisplayFunctions;
- (BOOL)sucessInsertOriginDisplayFunctions;
@end @end
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
//} //}
- (void)insertAllOriginFunctions{ - (void)insertAllOriginFunctions{
NSArray *functionsArr = [NSArray arrayWithArray:[self p_readJsonFile]]; NSArray *functionsArr = [NSArray arrayWithArray:[self p_readJsonFile]];
for (int count = 0; count < functionsArr.count; count ++) { for (int count = 0; count < functionsArr.count; count ++) {
GXFFunction *function = (GXFFunction *)functionsArr[count]; GXFFunction *function = (GXFFunction *)functionsArr[count];
[[GXFFunctionDB sharedInstance] insertFunction:function]; [[GXFFunctionDB sharedInstance] insertFunction:function];
...@@ -44,6 +46,14 @@ ...@@ -44,6 +46,14 @@
- (NSArray *)p_readJsonFile { - (NSArray *)p_readJsonFile {
NSMutableArray *muArr = [NSMutableArray array]; NSMutableArray *muArr = [NSMutableArray array];
//添加公告
GXFFunction *function = [[GXFFunction alloc]init];
function.Id = 000000;
function.name = @"announcement";
function.caption = @"公告";
function.hasPermission = YES;
function.isSelected = NO;
[muArr addObject:function];
NSString *path = [[NSBundle mainBundle] pathForResource:@"PermissionJson" ofType:nil]; NSString *path = [[NSBundle mainBundle] pathForResource:@"PermissionJson" ofType:nil];
NSData *jsonData = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:nil]; NSData *jsonData = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:nil];
...@@ -75,21 +85,24 @@ ...@@ -75,21 +85,24 @@
} }
- (NSArray *)p_createAllDisplayFunctions{ - (NSArray *)p_createAllDisplayFunctions{
NSArray *functionsId = @[@(500101),@(500102),@(500103), NSArray *functionsId = @[@(000000),
@(500101),@(500102),@(500103),
@(500201), @(500201),
@(500301),@(500302),@(500303),//"采购通知", @(500301),@(500302),@(500303),//"采购通知",
@(500401),@(500402),@(500403),@(500406),//"采购单" @(500401),@(500402),@(500403),@(500406),//"采购单"
@(500501),@(500502),@(500503),//"发运单" @(500501),@(500502),@(500503),//"发运单"
@(500601),@(500602),@(500603),//"转运单" @(500601),@(500602),@(500603),//"转运单"
@(500701),@(500702),@(500703),];//加工单 @(500701),@(500702),@(500703),];//加工单
NSArray *functionsName = @[@"新建行情调研",@"查看行情调研", @"查看行情调研", NSArray *functionsName = @[@"公告",
@"新建行情调研",@"查看行情调研", @"查看行情调研",
@"填写行情反馈", @"填写行情反馈",
@"新建采购通知",@"查看采购通知", @"查看采购通知", @"新建采购通知",@"查看采购通知", @"查看采购通知",
@"新建采购单",@"查看采购单", @"查看采购单", @"审核采购单【供应商】", @"新建采购单",@"查看采购单", @"查看采购单", @"审核采购单【供应商】",
@"新建发运单",@"查看发运单", @"查看发运单", @"新建发运单",@"查看发运单", @"查看发运单",
@"新增加工单",@"查看加工单", @"查看加工单", @"新增加工单",@"查看加工单", @"查看加工单",
@"新建转运单", @"查看转运单", @"查看转运单"]; @"新建转运单", @"查看转运单", @"查看转运单"];
NSArray *functionsImageName = @[@"create_surver",@"watch_surver", @"watch_surver", NSArray *functionsImageName = @[@"notice",
@"create_surver",@"watch_surver", @"watch_surver",
@"create_surver_result", @"create_surver_result",
@"create_needs",@"watch_needs", @"watch_needs", @"create_needs",@"watch_needs", @"watch_needs",
@"create_purchase",@"watch_purchase", @"watch_purchase", @"review_purchase", @"create_purchase",@"watch_purchase", @"watch_purchase", @"review_purchase",
...@@ -116,4 +129,11 @@ ...@@ -116,4 +129,11 @@
return muarr; return muarr;
} }
- (BOOL)successInsertOriginFunctions{
return [[GXFFunctionDB sharedInstance] originFunctions].count > 0 ? YES : NO;
}
- (BOOL)sucessInsertOriginDisplayFunctions {
return [[GXFFunctionDB sharedInstance] originDisplayFunctions].count > 0 ? YES : NO;
}
@end @end
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
[baseView addSubview:fControl]; [baseView addSubview:fControl];
} }
} }
baseView.height = MODULE_VIEW_HEIGHT * baseView.m_rows;
return baseView; return baseView;
} }
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
#ifndef XFFruit_ICRNotificationMacro_h #ifndef XFFruit_ICRNotificationMacro_h
#define XFFruit_ICRNotificationMacro_h #define XFFruit_ICRNotificationMacro_h
#define KNOTIFICATION_changeIsSelectedFunctions @"KNOTIFICATION_changeIsSelectedFunctions"
#endif #endif
...@@ -6,9 +6,12 @@ ...@@ -6,9 +6,12 @@
// Copyright (c) 2015年 Xummer. All rights reserved. // Copyright (c) 2015年 Xummer. All rights reserved.
// //
#import "GXFFunctionsViewController.h" #import "GXFFunctionsViewController.h"
#import "GXFDisplayFunction.h" #import "GXFDisplayFunction.h"
#import "GXFFunction.h" #import "GXFFunction.h"
#import "GXFFunctionDBHelper.h"
#import "GXFFunctionDB.h"
@interface GXFFunctionsViewController ()<UITableViewDataSource,UITableViewDelegate> @interface GXFFunctionsViewController ()<UITableViewDataSource,UITableViewDelegate>
//@property (nonatomic, strong) NSArray * //@property (nonatomic, strong) NSArray *
...@@ -28,14 +31,19 @@ static NSString *cellID = @"cell"; ...@@ -28,14 +31,19 @@ static NSString *cellID = @"cell";
[self setupSubViews]; [self setupSubViews];
} }
- (void)initData { - (void)initData {
NSUserDefaults *f_default = [NSUserDefaults standardUserDefaults];
BOOL noDefault = [[f_default objectForKey:@"noDefault"] integerValue] > 0 ? YES : NO;
if (!noDefault) {
self.secondSectionArr = [[GXFFunctionDB sharedInstance]defaultdisplayFunctions];
} else {
self.secondSectionArr = [[GXFFunctionDB sharedInstance]originDisplayFunctions];
}
NSDictionary *dictOne = @{@"Id":@(1),@"functionName":@"新建行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(0)}; NSDictionary *dictOne = @{@"Id":@(1),@"functionName":@"新建行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(0)};
NSDictionary *dictTwo = @{@"Id":@(2),@"functionName":@"查询行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(1)}; NSDictionary *dictTwo = @{@"Id":@(2),@"functionName":@"查询行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(1)};
GXFDisplayFunction *dFuntionOne = [[GXFDisplayFunction alloc]initWithDictionary:dictOne]; GXFDisplayFunction *dFuntionOne = [[GXFDisplayFunction alloc]initWithDictionary:dictOne];
GXFDisplayFunction *dFuntionTwo = [[GXFDisplayFunction alloc]initWithDictionary:dictTwo]; GXFDisplayFunction *dFuntionTwo =[[GXFDisplayFunction alloc]initWithDictionary:dictTwo];
self.firstSectionArr = @[dFuntionOne,dFuntionTwo]; self.firstSectionArr = @[dFuntionOne,dFuntionTwo];
self.secondSectionArr = @[dFuntionOne,dFuntionTwo]; //@[dFuntionOne,dFuntionTwo];
//self.firstSection =
} }
- (void)setupSubViews { - (void)setupSubViews {
[self setupRightBarBtn]; [self setupRightBarBtn];
...@@ -51,14 +59,25 @@ static NSString *cellID = @"cell"; ...@@ -51,14 +59,25 @@ static NSString *cellID = @"cell";
self.f_tableView.delegate = self; self.f_tableView.delegate = self;
//[self.f_tableView dequeueReusableCellWithIdentifier ] //[self.f_tableView dequeueReusableCellWithIdentifier ]
[self.view addSubview:_f_tableView]; [self.view addSubview:_f_tableView];
[_f_tableView reloadData];
} }
#pragma BarButton Action #pragma BarButton Action
- (void)selectedFunctions { - (void)selectedFunctions {
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_changeIsSelectedFunctions object:nil];
//配置功能 不是默认配置
NSUserDefaults *f_default = [NSUserDefaults standardUserDefaults];
BOOL noDefault = [[f_default objectForKey:@"noDefault"] integerValue] > 0 ? YES : NO;
if (!noDefault) {
[f_default setObject:@(1) forKey:@"noDefault"];
}
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} }
...@@ -76,25 +95,17 @@ static NSString *cellID = @"cell"; ...@@ -76,25 +95,17 @@ static NSString *cellID = @"cell";
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//TableViewCell重用机制避免重复显示问题 它的子视图全部删除
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) { if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
} } else {
switch (indexPath.section) { while ([cell.contentView.subviews lastObject] != nil) {
case 0: [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
{
[self p_contentToTableViewCell:cell andArray:_firstSectionArr];
}
break;
case 1:
{
[self p_contentToTableViewCell:cell andArray:_secondSectionArr];
} }
break;
default:
break;
} }
[self p_contentToTableViewCell:cell ForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
...@@ -119,16 +130,7 @@ static NSString *cellID = @"cell"; ...@@ -119,16 +130,7 @@ static NSString *cellID = @"cell";
} }
#pragma UITableViewDelegate #pragma UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [_f_tableView cellForRowAtIndexPath:indexPath]; switch (indexPath.section) {
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
// if (indexPath.section == 0) {
// _firstSectionArr
// }
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
switch (indexPath.section) {
case 0: case 0:
{ {
...@@ -136,6 +138,18 @@ static NSString *cellID = @"cell"; ...@@ -136,6 +138,18 @@ static NSString *cellID = @"cell";
break; break;
case 1: case 1:
{ {
GXFDisplayFunction *displayFunction = (GXFDisplayFunction *)_secondSectionArr[indexPath.row];
UITableViewCell *cell = [_f_tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
displayFunction.isSelected = YES;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
displayFunction.isSelected = NO;
}
[[GXFFunctionDB sharedInstance] updateDisplayFunctionIsSelectedWithId:displayFunction];
} }
break; break;
...@@ -144,12 +158,34 @@ static NSString *cellID = @"cell"; ...@@ -144,12 +158,34 @@ static NSString *cellID = @"cell";
} }
#pragma 给cell的内容赋值 #pragma 给cell的内容赋值
- (void)p_contentToTableViewCell: (UITableViewCell *)cell andArray: (NSArray *)array { - (void)p_contentToTableViewCell: (UITableViewCell *)cell ForRowAtIndexPath:(NSIndexPath *)indexPath {
for (int count = 0; count < array.count; count ++) { switch (indexPath.section) {
GXFDisplayFunction *dFunction = (GXFDisplayFunction *)array[count]; case 0:
cell.imageView.image = [UIImage imageNamed:dFunction.functionImgName]; {
cell.textLabel.text = dFunction.functionName; GXFDisplayFunction *dFunction = (GXFDisplayFunction *)_firstSectionArr[indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"RefreshBtn"];//dFunction.functionImgName];
cell.textLabel.text = dFunction.functionName;
}
break;
case 1:
{
GXFDisplayFunction *dFunction = (GXFDisplayFunction *)_secondSectionArr[indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"RefreshBtn"];//dFunction.functionImgName];
cell.textLabel.text = dFunction.functionName;
if (dFunction.isSelected) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
break;
default:
break;
} }
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#import "GXFFunctionCollectionViewCell.h" #import "GXFFunctionCollectionViewCell.h"
#import "GXFFunctionDB.h"
#define ICRFUNCTION_IMG_TOP_PADDING (25) #define ICRFUNCTION_IMG_TOP_PADDING (25)
#define ICRFUNCTION_IMG_WIDTH (65) #define ICRFUNCTION_IMG_WIDTH (65)
#define ICRFUNCTION_LABEL_HEIGHT (15) #define ICRFUNCTION_LABEL_HEIGHT (15)
...@@ -46,7 +48,7 @@ ...@@ -46,7 +48,7 @@
@property (nonatomic, strong) UITableView *f_tableView; @property (nonatomic, strong) UITableView *f_tableView;
@property (nonatomic, strong) NSArray *firstSectionArr; @property (nonatomic, strong) NSArray *firstSectionArr;
@property (nonatomic, strong) NSArray *secondSectionArr; @property (nonatomic, strong) NSMutableArray *secondSectionArr;
@property (nonatomic, strong) ICRFunctionBaseView *f_functionBaseView; @property (nonatomic, strong) ICRFunctionBaseView *f_functionBaseView;
@property (nonatomic, strong) UICollectionView *f_collectionView; @property (nonatomic, strong) UICollectionView *f_collectionView;
...@@ -66,27 +68,32 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -66,27 +68,32 @@ static NSString *collectionCellID = @"collectionCell";
[self initData]; [self initData];
[self setupSubviews]; [self setupSubviews];
} }
- (void)viewWillAppear:(BOOL)animated {
}
- (void)setupSubviews { - (void)setupSubviews {
[self setupRightBarBtn]; [self setupRightBarBtn];
[self setupTableView]; [self setupTableView];
[self setupColletionView]; // [self setupColletionView];
[self setupFunctionBaseView]; [self setupFunctionBaseView];
} }
- (void)initData { - (void)initData {
NSDictionary *dictOne = @{@"Id":@(1),@"functionName":@"新建行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(0)}; NSDictionary *dictOne = @{@"Id":@(1),@"functionName":@"新建行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(0)};
NSDictionary *dictTwo = @{@"Id":@(2),@"functionName":@"查询行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(1)}; NSDictionary *dictTwo = @{@"Id":@(2),@"functionName":@"查询行情反馈",@"imgName":@"RefreshBtn",@"isSelected":@(1)};
GXFDisplayFunction *dFuntionOne = [[GXFDisplayFunction alloc]initWithDictionary:dictOne]; GXFDisplayFunction *dFuntionOne = [[GXFDisplayFunction alloc]initWithDictionary:dictOne];
GXFDisplayFunction *dFuntionTwo = [[GXFDisplayFunction alloc]initWithDictionary:dictTwo]; GXFDisplayFunction *dFuntionTwo = [[GXFDisplayFunction alloc]initWithDictionary:dictTwo];
self.firstSectionArr = @[dFuntionOne,dFuntionTwo]; self.firstSectionArr = @[dFuntionOne,dFuntionTwo];
self.secondSectionArr = @[dFuntionOne,dFuntionTwo]; self.secondSectionArr = [NSMutableArray array];
//self.firstSection = [self.secondSectionArr addObjectsFromArray:[[GXFFunctionDB sharedInstance]isSelectedDisplayFunctions]];
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeSecondSectionArr) name:KNOTIFICATION_changeIsSelectedFunctions object:nil];
}
- (void) setupRightBarBtn { - (void) setupRightBarBtn {
UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc]initWithTitle:@"自定义功能" style:UIBarButtonItemStylePlain target:self action:@selector(defineFunctions)]; UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc]initWithTitle:@"自定义功能" style:UIBarButtonItemStylePlain target:self action:@selector(defineFunctions)];
...@@ -94,10 +101,15 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -94,10 +101,15 @@ static NSString *collectionCellID = @"collectionCell";
} }
- (void)setupTableView { - (void)setupTableView {
self.f_tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped]; self.f_tableView = [[UITableView alloc]initWithFrame:(CGRect){
.origin.x = 0,
.origin.y =0,
.size.width = self.view.width,
.size.height = self.view.height - 80}
style:UITableViewStyleGrouped];
self.f_tableView.dataSource = self; self.f_tableView.dataSource = self;
self.f_tableView.delegate = self; self.f_tableView.delegate = self;
//[self.f_tableView dequeueReusableCellWithIdentifier ]
[self.view addSubview:_f_tableView]; [self.view addSubview:_f_tableView];
} }
...@@ -116,54 +128,11 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -116,54 +128,11 @@ static NSString *collectionCellID = @"collectionCell";
- (void)setupFunctionBaseView { - (void)setupFunctionBaseView {
NSMutableArray *funtionEntitlesArr = [NSMutableArray array]; NSMutableArray *funtionEntitlesArr = [NSMutableArray array];
for (GXFDisplayFunction *displayFunction in _secondSectionArr) {
NSArray *functionImageNames = @[ @"AnnouncementIcon",@"create_surver",@"watch_surver",@"create_surver_result",@"create_needs",@"watch_needs",@"create_purchase",@"watch_purchase",@"review_purchase",@"create_transport",@"watch_transort",@"create_process"];
NSArray *functionNames = @[ [IBTCommon localizableString:@"Announcement"],
[IBTCommon localizableString:@"AddSurvey"],
[IBTCommon localizableString:@"Survey"],
[IBTCommon localizableString:@"Survey1"],
[IBTCommon localizableString:@"Survey2"],
[IBTCommon localizableString:@"Survey3"],
[IBTCommon localizableString:@"Survey4"],
[IBTCommon localizableString:@"Survey5"],
[IBTCommon localizableString:@"Survey6"],
[IBTCommon localizableString:@"Survey7"],
[IBTCommon localizableString:@"Survey8"],[IBTCommon localizableString:@"Survey9"],
];
NSArray *functionTags = @[ @(kFunctionNotice),
//公告
@(kFunctionNewSurvey),
//新建行情调研
@(kFunctionSeeSurvey),
//查看行情调研
@(kFunctionFeeBackSurvey),
//填写行情反馈
@(kFunctionNewPurchaseNotice),
//新建采购通知
@(kFunctionSeePurchaseNotice),
//查看采购通知
@(kFunctionNewPurchase),
//新建采购单
@(kFunctionSeePurchase),
//查看采购单
@(kFunctionExaminePurchas),
//审核采购单
@(kFunctionNewShipment),
//新建发运单
@(kFunctionSeeShipment),
//查看发运单
@(kFunctionNewProcessing)];
//新建加工单
int i = 0;
for (NSString *functionName in functionNames) {
ICRFunctionEntity *functionEntity = [[ICRFunctionEntity alloc]init]; ICRFunctionEntity *functionEntity = [[ICRFunctionEntity alloc]init];
functionEntity.functionName = functionName; functionEntity.functionName = displayFunction.functionName;
functionEntity.iconName = functionImageNames[i]; functionEntity.iconName = displayFunction.functionImgName;
// functionEntity.functionItemTag = []
[funtionEntitlesArr addObject:functionEntity]; [funtionEntitlesArr addObject:functionEntity];
i++;
} }
self.f_functionBaseView = [ICRFunctionBaseView initWithFunctionData:funtionEntitlesArr]; self.f_functionBaseView = [ICRFunctionBaseView initWithFunctionData:funtionEntitlesArr];
...@@ -171,17 +140,29 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -171,17 +140,29 @@ static NSString *collectionCellID = @"collectionCell";
.origin.x = 0, .origin.x = 0,
.origin.y =0, .origin.y =0,
.size.width = CGRectGetWidth(self.view.frame), .size.width = CGRectGetWidth(self.view.frame),
.size.height = CGRectGetHeight(self.view.frame),}; .size.height = _f_functionBaseView.height};//CGRectGetHeight(self.view.frame),};
_f_functionBaseView.backgroundColor = [UIColor clearColor]; _f_functionBaseView.backgroundColor = [UIColor clearColor];
_f_functionBaseView.m_delegate = self; _f_functionBaseView.m_delegate = self;
} }
#pragma BarButton Action
#pragma Notification
- (void)changeSecondSectionArr {
if (_secondSectionArr.count ) {
[_secondSectionArr removeAllObjects];
[self.secondSectionArr addObjectsFromArray:[[GXFFunctionDB sharedInstance]isSelectedDisplayFunctions]];
}
if (_f_functionBaseView) {
[_f_functionBaseView removeFromSuperview];
_f_functionBaseView = nil;
[self setupFunctionBaseView];
}
[_f_tableView reloadData];
}
#pragma rightBarButton Action
- (void)defineFunctions { - (void)defineFunctions {
GXFFunctionsViewController *functionsVc = [[GXFFunctionsViewController alloc]init]; GXFFunctionsViewController *functionsVc = [[GXFFunctionsViewController alloc]init];
[self PushViewController:functionsVc animated:YES]; [self PushViewController:functionsVc animated:YES];
} }
#pragma UITablewViewDataSource #pragma UITablewViewDataSource
...@@ -198,7 +179,7 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -198,7 +179,7 @@ static NSString *collectionCellID = @"collectionCell";
} }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1) { if (indexPath.section == 1) {
return 900; return _f_functionBaseView.height ;
} else { } else {
return 44; return 44;
} }
...@@ -213,16 +194,11 @@ static NSString *collectionCellID = @"collectionCell"; ...@@ -213,16 +194,11 @@ static NSString *collectionCellID = @"collectionCell";
cell.textLabel.text = @"查看行情反馈-进行中"; cell.textLabel.text = @"查看行情反馈-进行中";
} else { } else {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"secondCell"]; cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"secondCell"];
//self.f_collectionView.size =
// [cell.contentView addSubview:_f_collectionView];
[cell.contentView addSubview:_f_functionBaseView]; [cell.contentView addSubview:_f_functionBaseView];
NSLog(@"%@",NSStringFromCGRect(cell.frame)); NSLog(@"%@",NSStringFromCGRect(cell.frame));
} }
} }
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
......
...@@ -145,8 +145,24 @@ ...@@ -145,8 +145,24 @@
[[GXFFunctionDB sharedInstance]createTables]; [[GXFFunctionDB sharedInstance]createTables];
//完成对初始化数据书库的操作 //完成对初始化数据书库的操作
[[GXFFunctionDBHelper sharedInstance] insertAllOriginFunctions]; if (![[GXFFunctionDBHelper sharedInstance] successInsertOriginFunctions]) {
[[GXFFunctionDBHelper sharedInstance] insertAllOriginDisplayFunctions]; [[GXFFunctionDBHelper sharedInstance] insertAllOriginFunctions];
}
if (![[GXFFunctionDBHelper sharedInstance] sucessInsertOriginDisplayFunctions]) {
[[GXFFunctionDBHelper sharedInstance] insertAllOriginDisplayFunctions];
}
//更改功能权限
for (int count = 0; count < userUtil.permissions.count; count ++) {
GXFFunction *function = [[GXFFunctionDB sharedInstance]functionSelectWithId:[userUtil.permissions[count] integerValue]];
if (function.Id) {
function.hasPermission = 1;
[[GXFFunctionDB sharedInstance] updateFunctionHasPermissionWithId:function];
}
}
}; };
......
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
#import "IBTConstants.h" #import "IBTConstants.h"
#import "ICRAppMacro.h" #import "ICRAppMacro.h"
#import "ICRNotificationMacro.h"
#endif #endif
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