| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 | 
							- <?php
 
- /*
 
- |--------------------------------------------------------------------------
 
- | role.php 角色表
 
- |--------------------------------------------------------------------------
 
- */
 
- # 定义几个常用的选项
 
- $option = array
 
- (
 
- 	1 => '可用',
 
- 	2 => '不可用',
 
- );
 
-  
 
- # 获取权限list 建议这里使用匿名函数
 
- $auth = function()
 
- {
 
- 	return Maze::load('manage/auth.get');
 
- };
 
- # 获取头部菜单list 建议这里使用匿名函数
 
- $top = function()
 
- {
 
- 	$data = Maze::load('manage/top.all');
 
- 	$data['state'] = 1;
 
- 	return $data;
 
- };
 
- # 操作权限控制
 
- $oper = array
 
- (
 
- 	1 => '浏览',
 
- 	2 => '检索',
 
- 	3 => '更新',
 
- 	4 => '新增',
 
- 	5 => '删除',
 
- );
 
- //print_r($auth);die;
 
- return array
 
- (
 
- 	# 表名
 
- 	'name' => 'role',
 
- 	# 显示给用户看的名称
 
- 	'lang' => '管理角色设置',
 
- 	'order' => 8,
 
- 	# 数据结构
 
- 	'struct' => array
 
- 	(
 
- 		'id' 		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '角色ID',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '',
 
- 			'match' 	=> 'is_numeric',
 
- 			'search'	=> 'order',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'name'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-24',
 
- 			'name' 		=> '角色名',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入角色名',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'text',
 
- 			'search'	=> 'fulltext',
 
- 			'list_name'	=> '角色名',//定义列表页的名称
 
- 			'list'		=> true,
 
- 			'edit'		=> true,
 
- 		),
 
- 		
 
- 		/*
 
- 		//启用复制其他字段的值
 
- 		'testname'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-24',
 
- 			'name' 		=> '角色名',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入角色名',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'copy.name',//直接复制name的值
 
- 			'search'	=> 'order,fulltext',
 
- 			'list'		=> true,
 
- 		),
 
- 		*/
 
- 		
 
- 		#设置分割条
 
- 		/*
 
- 		'hr1'		=> array
 
- 		(
 
- 			'name' 		=> '基本信息',
 
- 			'class'		=> '',//本项必须填写
 
- 			'attr'		=> '',
 
- 		),
 
- 		*/
 
- 		
 
- 		'oper'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-24',
 
- 			'name' 		=> '操作权限',
 
- 			'default' 	=> array(1,2,3),
 
- 			'desc' 		=> '请选择操作权限',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'checkbox',
 
- 			'option'	=> $oper,
 
- 		),
 
- 		'auth'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '权限设置',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请选择权限',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'checkbox',
 
- 			//每个项对应的一个input以及父级更新的类型
 
- 			//'update_input' => '数量',
 
- 			//'update_parent' => 'radio',
 
- 			'option'	=> $auth,
 
- 		),
 
- 		'top'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '头部菜单',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请选择头部菜单',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'checkbox',
 
- 			'option'	=> $top,
 
- 		),
 
- 		'state'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '状态',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择状态',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $option,
 
- 			'update'	=> 'radio',
 
- 			'list'		=> true,
 
- 			'edit'		=> true,
 
- 			/*
 
- 			//启用位运算,仅支持与操作,数据保存时,将从0开始加起,一般用于站点之类的保存,慎用,测试需将radio改成checkbox
 
- 			'bit'		=> array
 
- 			(
 
- 				1 => 1,//1为对应的值,100为保存到数据库中的值
 
- 				2 => 10,
 
- 				//4 => 100,
 
- 			),
 
- 			*/
 
- 		),
 
- 		
 
- 		'cdate'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '录入时间',
 
- 			'match' 	=> array('is_numeric', time()),
 
- 			'desc' 		=> '',
 
- 			# 只有insert时才生效
 
- 			'insert'	=> true,
 
- 			# 加入搜索时间区间段
 
- 			'search'	=> 'date',
 
- 			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 
- 		),
 
- 	),
 
- 	# 更新表结构 请注意,新增字段已经无需在此增加add了,直接在struct中新增即可。如果是更新字段和删除字段,还需在此加相应配置,并且修改最新的版本号。
 
- 	/*
 
- 	'alter' => array
 
- 	(
 
- 		1 => array
 
- 		(
 
- 			array('add', 'top', 'top', 'text-255  头部菜单'),//新增字段
 
- 			array('update', 't1', 't2', 'text-255  头部菜单'),//更新字段
 
- 			array('delete', 't1'), //删除字段
 
- 		),
 
- 		'version' => 1,
 
- 	),
 
- 	*/
 
- 	
 
- 	# 默认值
 
- 	'default' => array
 
- 	(
 
- 		'col' => 'name,oper,auth,state,cdate',
 
- 		'value' => array
 
- 		(
 
- 			'"系统管理员","all","all",1,' . time(),
 
- 		),
 
- 	),
 
- 	
 
- 	# 索引
 
- 	'index' => array
 
- 	(
 
- 		# 索引名 => 索引id
 
- 		//'id' => 'id,state',
 
- 		
 
- 		# 版本号 更改版本号会更新当前表的索引,慎用
 
- 		//'version' => 1,
 
- 	),
 
- 	
 
- 	# 后台管理 此处的功能全部开放
 
- 	'manage' => array
 
- 	(
 
- 		# 启动自动保存功能
 
- 		'save' => true,
 
- 		# 启动预览功能
 
- 		'preview' => true,
 
- 		
 
- 		# 开启报表下载
 
- 		'excel' => true,
 
- 		# 开启批量管理
 
- 		'mul' => true,
 
- 		# 开启主动统计,需要人工选择选项来确定统计的项,有别于被动统计,实现中
 
- 		'stat' => 'top,auth,state,oper',//值为不显示的字段,无需输入id和cdate
 
- 		
 
- 		
 
- 		# 列表页每个元素管理下的button,其中3为编辑、6为删除,其他可以自定义。
 
- 		//'list_button' => array(1 => array('日志', '"api_log&option_site={id}"'), 6 => '删除'),
 
- 		//'list_button' => array(6 => '删除'),
 
- 		
 
- 		# 列表头部的button,多个直接添加字段即可
 
- 		'button' => array
 
- 		(
 
- 			//'更新接口' => 'manage/api.update',
 
- 		)
 
- 	),
 
- 	# request 请求接口定义
 
- 	'request' => array
 
- 	(
 
- 		# all 取所有数据
 
- 		'all' => array
 
- 		(
 
- 			# 匹配的正则或函数 选填项
 
- 			'option' => array
 
- 			(
 
- 				'name' => array('is_string', 'like'),
 
- 				'state' => 1,
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('id', 'desc'),
 
- 			'col' => '*,name as value,name as label|id',//这里为了做autocomplete进行测试,必须输出value和label
 
- 		),
 
- 		
 
- 		# 带有*号前缀的,可以直接接口访问
 
- 		'*get' => array
 
- 		(
 
- 			# 匹配的正则或函数 选填项
 
- 			'where' => array
 
- 			(
 
- 				'id' => array('is_string', 'in'),
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('id', 'desc'),
 
- 			'col' => '*',
 
- 		),
 
- 		
 
- 		# get 根据role的id取多条数据
 
- 		'get' => array
 
- 		(
 
- 			# 匹配的正则或函数 选填项
 
- 			'where' => array
 
- 			(
 
- 				'id' => array('is_string', 'in'),
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('id', 'desc'),
 
- 			'col' => '*|id',
 
- 		),
 
- 	),
 
- );
 
 
  |