一、初始化权限数据
1.系统运行所以须的基础数据
2.运行sql
INSERT INTO `auth_function` VALUES (‘11‘, ‘基础档案‘, ‘jichudangan‘, null, null, ‘1‘, ‘0‘, null);
INSERT INTO `auth_function` VALUES (‘112‘, ‘收派标准‘, ‘standard‘, null, ‘page_base_standard.action‘, ‘1‘, ‘1‘, ‘11‘);
INSERT INTO `auth_function` VALUES (‘113‘, ‘取派员设置‘, ‘staff‘, null, ‘page_base_staff.action‘, ‘1‘, ‘2‘, ‘11‘);
INSERT INTO `auth_function` VALUES (‘114‘, ‘区域设置‘, ‘region‘, null, ‘page_base_region.action‘, ‘1‘, ‘3‘, ‘11‘);
INSERT INTO `auth_function` VALUES (‘115‘, ‘管理分区‘, ‘subarea‘, null, ‘page_base_subarea.action‘, ‘1‘, ‘4‘, ‘11‘);
INSERT INTO `auth_function` VALUES (‘116‘, ‘管理定区/调度排班‘, ‘decidedzone‘, null, ‘page_base_decidedzone.action‘, ‘1‘, ‘5‘, ‘11‘);
INSERT INTO `auth_function` VALUES (‘12‘, ‘受理‘, ‘shouli‘, null, null, ‘1‘, ‘1‘, null);
INSERT INTO `auth_function` VALUES (‘121‘, ‘业务受理‘, ‘noticebill‘, null, ‘page_qupai_noticebill_add.action‘, ‘1‘, ‘0‘, ‘12‘);
INSERT INTO `auth_function` VALUES (‘122‘, ‘工作单快速录入‘, ‘quickworkordermanage‘, null, ‘page_qupai_quickworkorder.action‘, ‘1‘, ‘1‘, ‘12‘);
INSERT INTO `auth_function` VALUES (‘124‘, ‘工作单导入‘, ‘workordermanageimport‘, null, ‘page_qupai_workorderimport.action‘, ‘1‘, ‘3‘, ‘12‘);
INSERT INTO `auth_function` VALUES (‘13‘, ‘调度‘, ‘diaodu‘, null, null, ‘1‘, ‘2‘, null);
INSERT INTO `auth_function` VALUES (‘131‘, ‘查台转单‘, ‘changestaff‘, null, null, ‘1‘, ‘0‘, ‘13‘);
INSERT INTO `auth_function` VALUES (‘132‘, ‘人工调度‘, ‘personalassign‘, null, ‘page_qupai_diaodu.action‘, ‘1‘, ‘1‘, ‘13‘);
INSERT INTO `auth_function` VALUES (‘14‘, ‘物流配送流程管理‘, ‘zhongzhuan‘, null, null, ‘1‘, ‘3‘, null);
INSERT INTO `auth_function` VALUES (‘141‘, ‘启动配送流程‘, ‘start‘, null, ‘workOrderManageAction_list.action‘, ‘1‘, ‘0‘, ‘14‘);
INSERT INTO `auth_function` VALUES (‘142‘, ‘查看个人任务‘, ‘personaltask‘, null, ‘taskAction_findPersonalTask.action‘, ‘1‘, ‘1‘, ‘14‘);
INSERT INTO `auth_function` VALUES (‘143‘, ‘查看我的组任务‘, ‘grouptask‘, null, ‘taskAction_findGroupTask.action‘, ‘1‘, ‘2‘, ‘14‘);
INSERT INTO `auth_function` VALUES (‘8a7e843355a4392d0155a43aa7150000‘, ‘删除取派员‘, ‘staff.delete‘, ‘xxx‘, ‘staffAction_delete.action‘, ‘0‘, ‘1‘, ‘113‘);
INSERT INTO `auth_function` VALUES (‘8a7e843355a442460155a442bcfc0000‘, ‘传智播客‘, ‘itcast‘, ‘‘, ‘http://www.itcast.cn‘, ‘1‘, ‘1‘, null);
二、添加权限数据
1.将function.hbm.xml中的主键生成策略设置为uuid
2.将admin/function_add.jsp页面的输入id的更改为关键字
<tr>
<td width="200">关键字</td>
<td>
<input type="text" name="code" class="easyui-validatebox" data-options="required:true" />
</td>
</tr>
3.修改父功能点这一栏的的textField和url属性,设置从Action获取数据
<tr>
<td>父功能点</td>
<td>
<input name="parentFunction.id" class="easyui-combobox" data-options="valueField:‘id‘,textField:‘name‘,url:‘functionAction_listajax.action‘"/>
</td>
</tr>
3.实现FunctionAction.listajax
/**
* 查询所有权限数据,返回json
*/
public String listajax(){
List<Function> list = functionService.list();
list2JsonAndWriteResponse(list, "parentFunction", "roles", "children");
return NONE;
}
4.实现FuctionService.list方法
@Override
public List<Function> list() {
return functionDao.list();
}
5.为保存按钮绑定单机事件,进行校验,通过则提交表单
$(function(){
// 点击保存
$(‘#save‘).click(function(){
//表单校验
var f = $("#functionForm").form("validate");
if(f){
//校验通过则提交表单
$("#functionForm").submit();
}
});
});
6.实现FunctionAction.add方法
@Override
public void save(Function model) {
Function parentFunction = model.getParentFunction();
if(parentFunction != null && parentFunction.getId().equals("")){
model.setParentFunction(null);
}
functionDao.save(model);
}
三、权限分页查询
1.修改页面数据表格的url为functionAction_pageQuery.action
2.实现FunctionAction.pageQuery方法,注意处理page属性被Function实体读取的问题
/**
* 权限数据分页查询
* @return
*/
public String pageQuery(){
//处理分页参数page和Function属性page冲突的情况
int currentPage = Integer.parseInt(model.getPage());
pageBean.setCurrentPage(currentPage);
//调用service进行分页查询
functionService.pageQuery(pageBean);
object2JsonAndWriteToResponse(pageBean, "parentFunction", "roles", "children");
return NONE;
}