1、权限接口类
package com.sundablog.service.backend.system.upms.permissions;
import com.sundablog.pojo.AdminPermission;
import com.sundablog.result.LayUiResult;
/**
* 权限接口类
* @ClassName: PermissionsService
* @Description:权限接口类
* @author: 哒哒
* @date: 2018年3月14日 下午6:54:53
*
* @Copyright: 2018 www.sundablog.com Inc. All rights reserved.
*/
public interface PermissionsService {
/**
* 添加一条权限
* @Title: addPermissions
* @Description: 添加一条权限
* @param: @param adminPermission
* @param: @return
* @return:
* @throws
*/
int addPermissions(AdminPermission adminPermission);
/**
* 修改一条权限数据
* @Title: updataPermissions
* @Description: 修改一条权限数据
* @param: @param adminPermission
* @param: @return
* @return: int
* @throws
*/
int updataPermissions(AdminPermission adminPermission);
/**
* 禁用一条权限(注意:如果当前状态是禁用,如调用此方法会变成启用)
* @Title: updataDisablePermissionId
* @Description: 禁用一条权限(注意:如果当前状态是禁用,如调用此方法会变成启用)
* @param: @param permissionId
* @param: @return
* @return: int
* @throws
*/
int updataDisablePermissionId(int permissionId);
/**
* 根据permissionId查询一条数据
* @Title: updataPermissionsByPermissionId
* @Description: 根据permissionId查询一条数据
* @param: @param permissionId
* @param: @return
* @return: int
* @throws
*/
AdminPermission selectPermissionsByPermissionId(int permissionId);
/**
* 删除一条权限
* @Title: deletePermission
* @Description: 删除一条权限
* @param: @param permissionId
* @param: @return
* @return: int
* @throws
*/
int deletePermission(int permissionId);
/**
* 获取全部权限
* @Title: findPagingQuery
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @return
* @return: LayUiResult
* @throws
*/
LayUiResult findPagingQuery();
}
2、权限接口实现类
package com.sundablog.service.impl.backend.system.upms.permissions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sundablog.mapper.AdminPermissionMapper;
import com.sundablog.pojo.AdminPermission;
import com.sundablog.pojo.AdminPermissionExample;
import com.sundablog.pojo.AdminPermissionExample.Criteria;
import com.sundablog.result.LayUiResult;
import com.sundablog.service.backend.system.upms.permissions.PermissionsService;
/**
* 权限接口实现类
*
* @ClassName: PermissionsServiceImpl
* @Description:权限接口实现类
* @author: 哒哒
* @date: 2018年3月14日 下午7:01:46
*
* @Copyright: 2018 www.sundablog.com Inc. All rights reserved.
*/
@Service
public class PermissionsServiceImpl implements PermissionsService {
@Autowired
private AdminPermissionMapper adminPermissionMapper;
/**
* 添加一条权限
* Title: addPermissions
* Description:添加一条权限
* @param adminPermission
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#addPermissions(com.sundablog.pojo.AdminPermission)
*/
@Override
public int addPermissions(AdminPermission adminPermission) {
//添加根目录默认pid为0
if (null == adminPermission.getPid()) {
adminPermission.setPid(0);
}
//状态默认正常
adminPermission.setStatus((byte) 1);
//设置时间为现在时间
adminPermission.setCtime(new Date());
int i = adminPermissionMapper.insertSelective(adminPermission);
return i;
}
/**
* 修改一条权限
* Title: updataPermissions
* Description:修改一条权限
* @param adminPermission
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#updataPermissions(com.sundablog.pojo.AdminPermission)
*/
@Override
public int updataPermissions(AdminPermission adminPermission) {
int i = adminPermissionMapper.updateByPrimaryKeySelective(adminPermission);
return i;
}
/**
* 禁用一条权限
* Title: updataDisablePermissionId
* Description:禁用一条权限
* @param permissionId
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#updataDisablePermissionId(int)
*/
@Override
public int updataDisablePermissionId(int permissionId) {
AdminPermission adminPermission = adminPermissionMapper.selectByPrimaryKey(permissionId);
if (0 == adminPermission.getStatus().intValue()) {
adminPermission.setStatus((byte) 1);
} else {
adminPermission.setStatus((byte) 0);
}
int i = adminPermissionMapper.updateByPrimaryKeySelective(adminPermission);
return i;
}
/**
* 根据permissionId查询一条数据
* Title: updataPermissionsByPermissionId
* Description:
* @param permissionId
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#updataPermissionsByPermissionId(int)
*/
@Override
public AdminPermission selectPermissionsByPermissionId(int permissionId) {
AdminPermission permission = adminPermissionMapper.selectByPrimaryKey(permissionId);
return permission;
}
/**
* 获取全部权限
* Title: findPagingQuery
* Description:
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#findPagingQuery()
*/
@Override
public LayUiResult findPagingQuery() {
AdminPermissionExample example = new AdminPermissionExample();
List<AdminPermission> list = adminPermissionMapper.selectByExample(example);
LayUiResult layUiResult = new LayUiResult();
layUiResult.setCode(0);
layUiResult.setMsg("");
layUiResult.setCount(0);
layUiResult.setData(list);
return layUiResult;
}
/**
* 删除一条权限
* Title: deletePermission
* Description:
* @param permissionId
* @return
* @see com.sundablog.service.backend.system.upms.permissions.PermissionsService#deletePermission(int)
*/
@Override
public int deletePermission(int permissionId) {
AdminPermissionExample example = new AdminPermissionExample();
Criteria criteria = example.createCriteria();
criteria.andPidEqualTo(permissionId);
List<AdminPermission> list = adminPermissionMapper.selectByExample(example);
if (list.size() > 0) {
AdminPermissionExample permissionExample = new AdminPermissionExample();
Criteria createCriteria = permissionExample.createCriteria();
createCriteria.andPidEqualTo(permissionId);
int i = adminPermissionMapper.deleteByExample(permissionExample);
return i;
} else {
int i = adminPermissionMapper.deleteByPrimaryKey(permissionId);
return i;
}
}
}
3、权限控制器类
package com.sundablog.controller.backend.system.upms.permissions;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sundablog.pojo.AdminPermission;
import com.sundablog.pojo.AdminRoleExample;
import com.sundablog.result.BaseResult;
import com.sundablog.result.LayUiResult;
import com.sundablog.service.backend.system.upms.permissions.PermissionsService;
/**
* 权限管理控制器
* @ClassName: PermissionsController
* @Description:权限管理控制器
* @author: 哒哒
* @date: 2018年3月14日 下午7:10:13
*
* @Copyright: 2018 www.sundablog.com Inc. All rights reserved.
*/
@Controller
@RequestMapping("/backend/system/upms/permissions")
public class PermissionsController {
@Autowired
private PermissionsService permissionsService;
/**
* 界面显示
* @Title: index
* @Description: 界面显示
* @param: @return
* @return: String
* @throws
*/
@RequestMapping("/index")
public String index() {
return "backend/system/upms/permissions/index";
}
/**
* 添加根界面显示
* @Title: add
* @Description: 添加界面显示
* @param: @return
* @return: String
* @throws
*/
@RequestMapping("/add")
public String add() {
return "backend/system/upms/permissions/add";
}
/**
* 添加子菜单界面显示
* @Title: addPermissions
* @Description: 添加子菜单界面显示
* @param: @return
* @return: String
* @throws
*/
@RequestMapping("/addPermissionsIndex")
public String addPermissionsIndex() {
return "backend/system/upms/permissions/addPermissions";
}
/**
* 图标显示
* @Title: larryfont
* @Description: 图标显示
* @param: @return
* @return: String
* @throws
*/
@RequestMapping("/larryfont")
public String larryfont() {
return "backend/system/upms/permissions/larryfont";
}
/**
* 编辑界面显示
* @Title: edit
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @return
* @return: String
* @throws
*/
@RequestMapping("/edit")
public String edit() {
return "backend/system/upms/permissions/edit";
}
/**
* 查询权限
* @Title: findPagingQuery
* @Description: 查询权限
* @param: @return
* @return: LayUiResult
* @throws
*/
@RequestMapping("/findPagingQuery")
@ResponseBody
public LayUiResult findPagingQuery() {
LayUiResult result = permissionsService.findPagingQuery();
return result;
}
/**
* 添加权限
* @Title: addPermissions
* @Description: 添加权限
* @param: @param adminPermission
* @param: @return
* @return: BaseResult
* @throws
*/
@RequestMapping("/addPermissions")
@ResponseBody
public BaseResult addPermissions(AdminPermission adminPermission) {
int i = permissionsService.addPermissions(adminPermission);
if (i > 0) {
return BaseResult.build(200, BaseResult.addSuccess);
} else {
return BaseResult.build(209, BaseResult.addFail);
}
}
/**
* 删除一条权限
* @Title: deletePermission
* @Description: 删除一条权限
* @param: @param permissionId
* @param: @return
* @return: BaseResult
* @throws
*/
@RequestMapping("/deletePermission")
@ResponseBody
public BaseResult deletePermission(int permissionId) {
int i = permissionsService.deletePermission(permissionId);
if (i > 0) {
return BaseResult.build(200, BaseResult.delectSuccess);
} else {
return BaseResult.build(209, BaseResult.delectFail);
}
}
/**
* 禁用一条权限(注意:如果当前状态是禁用,如调用此方法会变成启用)
* @Title: updataDisablePermissionId
* @Description: 禁用一条权限(注意:如果当前状态是禁用,如调用此方法会变成启用)
* @param: @param permissionId
* @param: @return
* @return: BaseResult
* @throws
*/
@RequestMapping("/updataDisablePermissionId")
@ResponseBody
public BaseResult updataDisablePermissionId(int permissionId) {
int i = permissionsService.updataDisablePermissionId(permissionId);
if (i > 0) {
return BaseResult.build(200, BaseResult.updataSuccess);
} else {
return BaseResult.build(209, BaseResult.updataFail);
}
}
/**
* 根据id查询一条权限数据
* @Title: selectPermissionsByPermissionId
* @Description: 根据id查询一条权限数据
* @param: @param permissionId
* @param: @return
* @return: BaseResult
* @throws
*/
@RequestMapping("/selectPermissionsByPermissionId")
@ResponseBody
public BaseResult selectPermissionsByPermissionId(int permissionId) {
AdminPermission adminPermission = permissionsService.selectPermissionsByPermissionId(permissionId);
return BaseResult.build(200, "", adminPermission);
}
/**
* 修改权限
* @Title: updataPermissions
* @Description: 修改权限
* @param: @param permissionId
* @param: @return
* @return: BaseResult
* @throws
*/
@RequestMapping("/updataPermissions")
@ResponseBody
public BaseResult updataPermissions(AdminPermission adminPermission) {
int i = permissionsService.updataPermissions(adminPermission);
if (i > 0) {
return BaseResult.build(200, BaseResult.updataSuccess);
} else {
return BaseResult.build(200, BaseResult.updataFail);
}
}
}
4、权限界面
添加根节点
html
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../../../../public/common.jsp"%>
<body>
<form class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">菜单名称</label>
<div class="layui-input-block">
<input type="text" name="name" lay-verify="title"
autocomplete="off" placeholder="请输入菜单名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">类型</label>
<div class="layui-input-block">
<select name="type" lay-filter="aihao">
<option value="" selected="">请选择类型</option>
<option value="1">目录</option>
<option value="2">菜单</option>
<option value="3">按钮</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">权限值</label>
<div class="layui-input-block">
<input type="text" name="permissionValue" lay-verify="title"
autocomplete="off" placeholder="请输入权限值" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">路径</label>
<div class="layui-input-block">
<input type="text" name="uri" lay-verify="title"
autocomplete="off" placeholder="路径" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-inline">
<input type="text" name="icon" lay-verify="title"
autocomplete="off" placeholder="请输入图片" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="button" id="icon" class="layui-btn">查找图标</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="text" name="orders" lay-verify="title"
autocomplete="off" placeholder="排序" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit="" lay-filter="permissionsAdd">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</body>
<!-- 加载js文件-->
<script type="text/javascript" src="/LarryMS/common/layui/layui.js"></script>
<script type="text/javascript">
layui.cache.page = 'system/upms/permissions/add';
layui.config({
version : "1.0.0",
base : '/LarryMS/common/'
}).extend({
larry : 'js/base'
}).use('larry');
</script>
</html>
js
/**
* @name 权限
*/
layui.define(['larry', 'form', 'table'], function(exports) {
"use strict";
var $ = layui.$,
larry = layui.larry,
form = layui.form,
table = layui.table;
//图标选择
$('#icon').on('click', function() {
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/larryfont' //iframe的url
});
});
//监听提交
form.on('submit(permissionsAdd)', function(data) {
$.post("/backend/system/upms/permissions/addPermissions",data.field,function(result){
if(result.status != 200){
layer.msg(result.msg);
} else {
parent.layer.closeAll();
}
});
return false;
});
exports('mypanel', {});
});
添加子节点
HTML
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../../../../public/common.jsp"%>
<body>
<form class="layui-form">
<input type="hidden" name="pid" id="pid">
<div class="layui-form-item">
<label class="layui-form-label">父菜单名称</label>
<div class="layui-input-block">
<input type="text" id="pidName" name="pidName" lay-verify="title"
autocomplete="off" readonly="readonly" placeholder="请输入父菜单名称" class="layui-input layui-unselect layui-disabled">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">菜单名称</label>
<div class="layui-input-block">
<input type="text" name="name" lay-verify="title"
autocomplete="off" placeholder="请输入菜单名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">类型</label>
<div class="layui-input-block">
<select name="type" lay-filter="aihao">
<option value="" selected="">请选择类型</option>
<option value="1">目录</option>
<option value="2">菜单</option>
<option value="3">按钮</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">权限值</label>
<div class="layui-input-block">
<input type="text" name="permissionValue" lay-verify="title"
autocomplete="off" placeholder="请输入权限值" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">路径</label>
<div class="layui-input-block">
<input type="text" name="uri" lay-verify="title"
autocomplete="off" placeholder="路径" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-inline">
<input type="text" name="icon" lay-verify="title"
autocomplete="off" placeholder="请输入图片" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="button" id="icon" class="layui-btn">查找图标</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="text" name="orders" lay-verify="title"
autocomplete="off" placeholder="排序" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit="" lay-filter="permissionsAdd">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</body>
<!-- 加载js文件-->
<script type="text/javascript" src="/LarryMS/common/layui/layui.js"></script>
<script type="text/javascript">
layui.cache.page = 'system/upms/permissions/addPermissions';
layui.config({
version : "1.0.0",
base : '/LarryMS/common/'
}).extend({
larry : 'js/base'
}).use('larry');
</script>
</html>
js
/**
* @name 权限
*/
layui.define(['larry', 'form', 'table'], function(exports) {
"use strict";
var $ = layui.$,
larry = layui.larry,
form = layui.form,
table = layui.table;
var pid = GetQueryString("permissionId")
var pidName = GetQueryString("pidName")
$("#pid").val(pid);
$("#pidName").val(pidName);
//图标选择
$('#icon').on('click', function() {
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/larryfont' //iframe的url
});
});
//监听提交
form.on('submit(permissionsAdd)', function(data) {
$.post("/backend/system/upms/permissions/addPermissions",data.field,function(result){
if(result.status != 200){
layer.msg(result.msg);
} else {
parent.layer.closeAll();
}
});
return false;
});
exports('mypanel', {});
});
编辑节点
HTML
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../../../../public/common.jsp"%>
<body>
<form class="layui-form">
<input type="hidden" name="permissionId" id="permissionId">
<div class="layui-form-item">
<label class="layui-form-label">菜单名称</label>
<div class="layui-input-block">
<input type="text" id="name" name="name" lay-verify="title"
autocomplete="off" placeholder="请输入菜单名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">类型</label>
<div class="layui-input-block">
<select id="type" name="type" lay-filter="aihao">
<option value="" selected="">请选择类型</option>
<option value="1">目录</option>
<option value="2">菜单</option>
<option value="3">按钮</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">权限值</label>
<div class="layui-input-block">
<input type="text" id="permissionValue" name="permissionValue" lay-verify="title"
autocomplete="off" placeholder="请输入权限值" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">路径</label>
<div class="layui-input-block">
<input type="text" id="uri" name="uri" lay-verify="title"
autocomplete="off" placeholder="路径" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-inline">
<input type="text" id="icon" name="icon" lay-verify="title"
autocomplete="off" placeholder="请输入图片" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="button" id="icon" class="layui-btn">查找图标</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="text" id="orders" name="orders" lay-verify="title"
autocomplete="off" placeholder="排序" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit="" lay-filter="editAdd">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</body>
<!-- 加载js文件-->
<script type="text/javascript" src="/LarryMS/common/layui/layui.js"></script>
<script type="text/javascript">
layui.cache.page = 'system/upms/permissions/edit';
layui.config({
version : "1.0.0",
base : '/LarryMS/common/'
}).extend({
larry : 'js/base'
}).use('larry');
</script>
</html>
js
/**
* @name 权限
*/
layui.define(['larry', 'form', 'table'], function(exports) {
"use strict";
var $ = layui.$,
larry = layui.larry,
form = layui.form,
table = layui.table;
$.post("/backend/system/upms/permissions/selectPermissionsByPermissionId",{"permissionId":GetQueryString("permissionId")},function(result){
$("#name").val(result.data["name"]);
$("#type").val(result.data["type"]);
$("#permissionValue").val(result.data["permissionValue"]);
$("#uri").val(result.data["uri"]);
$("#icon").val(result.data["icon"]);
$("#orders").val(result.data["orders"]);
$("#permissionId").val(result.data["permissionId"]);
form.render('select');
});
//图标选择
$('#icon').on('click', function() {
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/larryfont' //iframe的url
});
});
//监听提交
form.on('submit(editAdd)', function(data) {
$.post("/backend/system/upms/permissions/updataPermissions",data.field,function(result){
if(result.status != 200){
layer.msg(result.msg);
} else {
parent.layer.closeAll();
}
});
return false;
});
exports('mypanel', {});
});
所有权限 和删除
HTML
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../../../../public/common.jsp"%>
<body>
<div style="margin-top: 10px; margin-left: 10px">
<button id="addPermissions" class="layui-btn ">添加根菜单</button>
</div>
<table class="layui-hidden" id="permissionsList" lay-filter="permissionsList"></table>
<script type="text/html" id="permissionsBar">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">添加子菜单</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑菜单</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="statusTpl">
<input type="checkbox" name="lock" value="{{d.permissionId}}" title="锁定" lay-filter="status" {{ d.status == 0 ? 'checked' : '' }}>
</script>
<script type="text/html" id="iconTpl">
<i class="larry-icon {{d.icon}}"></i>
</script>
</body>
<!-- 加载js文件-->
<script type="text/javascript" src="/LarryMS/common/layui/layui.js"></script>
<script type="text/javascript">
layui.cache.page = 'system/upms/permissions/index';
layui.config({
version : "1.0.0",
base : '/LarryMS/common/'
}).extend({
larry : 'js/base'
}).use('larry');
</script>
</html>
js
/**
* @name 权限
*/
layui.define(['larry', 'form', 'table', 'treeGrid'], function(exports) {
"use strict";
var $ = layui.$,
larry = layui.larry,
form = layui.form,
table = layui.table,
treeGrid = layui.treeGrid;
var tableIns = treeGrid.render({
elem: '#permissionsList', //指定原始表格元素选择器(推荐id选择器)
cols: [
[{
field: 'name',
title: '名称',
}, {
field: 'permissionValue',
align: 'center',
title: '权限值',
align: 'center',
}, {
field: 'uri',
align: 'center',
title: '路径',
}, {
field: 'icon',
align: 'center',
title: '图标',
templet: '#iconTpl',
}, {
field: 'status',
align: 'center',
title: '状态',
templet: '#statusTpl',
}, {
align: 'center',
title: '操作',
toolbar: '#permissionsBar'
}]
], //设置表头
url: '/backend/system/upms/permissions/findPagingQuery',
treeId: 'permissionId', //树形id字段名称
treeUpId: 'pid', //树形父id字段名称
treeShowName: 'name', //以树形式显示的字段
page: false
});
//监听锁定操作
form.on('checkbox(status)', function(obj) {
$.post("/backend/system/upms/permissions/updataDisablePermissionId", {
"permissionId": this.value
}, function(result) {
if (result.status != 200) {
layer.tips(result.mgs);
tableIns.reload();
}
});
});
//图标选择
$('#addPermissions').on('click', function() {
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/add', //iframe的url
end: function() {
tableIns.reload();
}
});
});
//监听工具条
treeGrid.on('tool(permissionsList)', function(obj) {
var data = obj.data;
if (obj.event === 'detail') {
//添加子菜单
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/addPermissionsIndex?permissionId=' + data.permissionId + '&pidName=' + data.name,
end: function() {
tableIns.reload();
}
});
} else if (obj.event === 'del') {
//删除
layer.confirm('真的删除行么', function(index) {
$.post("/backend/system/upms/permissions/deletePermission", {
"permissionId": data.permissionId
}, function(result) {
if (result.status == 200) {
tableIns.reload();
} else {
layer.msg(result.msg);
tableIns.reload();
}
layer.close(index);
});
});
} else if (obj.event === 'edit') {
//编辑
layer.open({
type: 2,
title: '图标选择',
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: '/backend/system/upms/permissions/edit?permissionId=' + data.permissionId,
end: function() {
tableIns.reload();
}
});
}
});
exports('mypanel', {});
});