Commit eb529a77 by fsn

菜单管理增加菜单级别搜索条件

parent b6da4907
...@@ -96,8 +96,8 @@ public class MenuController extends BaseController { ...@@ -96,8 +96,8 @@ public class MenuController extends BaseController {
*/ */
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
@ResponseBody @ResponseBody
public Object list(@RequestParam(required = false) String menuName) { public Object list(@RequestParam(required = false) String menuName,@RequestParam(required = false) String level) {
List<Map<String, Object>> menus = this.menuDao.selectMenus(menuName); List<Map<String, Object>> menus = this.menuDao.selectMenus(menuName,level);
return super.warpObject(new MenuWarpper(menus)); return super.warpObject(new MenuWarpper(menus));
} }
......
...@@ -21,7 +21,7 @@ public interface MenuDao { ...@@ -21,7 +21,7 @@ public interface MenuDao {
* @return * @return
* @date 2017年2月12日 下午9:14:34 * @date 2017年2月12日 下午9:14:34
*/ */
public List<Map<String, Object>> selectMenus(@Param("condition") String condition); public List<Map<String, Object>> selectMenus(@Param("condition") String condition,@Param("level") String level);
/** /**
* 根据条件查询菜单 * 根据条件查询菜单
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<if test="condition != null and condition != ''"> <if test="condition != null and condition != ''">
and (name like CONCAT('%',#{condition},'%') or code like CONCAT('%',#{condition},'%')) and (name like CONCAT('%',#{condition},'%') or code like CONCAT('%',#{condition},'%'))
</if> </if>
<if test="level != null and level != ''">
and levels = #{level}
</if>
</select> </select>
<select id="getMenuIdsByRoleId" resultType="int"> <select id="getMenuIdsByRoleId" resultType="int">
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
<#NameCon id="menuName" name="菜单名称" /> <#NameCon id="menuName" name="菜单名称" />
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<#NameCon id="level" name="层级" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="Menu.search()"/> <#button name="搜索" icon="fa-search" clickFun="Menu.search()"/>
</div> </div>
</div> </div>
......
...@@ -2,113 +2,114 @@ ...@@ -2,113 +2,114 @@
* 角色管理的单例 * 角色管理的单例
*/ */
var Menu = { var Menu = {
id : "menuTable", //表格id id: "menuTable", //表格id
seItem : null, //选中的条目 seItem: null, //选中的条目
table : null, table: null,
layerIndex : -1 layerIndex: -1
}; };
/** /**
* 初始化表格的列 * 初始化表格的列
*/ */
Menu.initColumn = function(){ Menu.initColumn = function () {
var columns = [ var columns = [
{field: 'selectItem',radio:true}, {field: 'selectItem', radio: true},
{title: 'id',field: 'id', visible: false, align: 'center',valign: 'middle'}, {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
{title: '菜单编号',field: 'code',align: 'center',valign: 'middle'}, {title: '菜单编号', field: 'code', align: 'center', valign: 'middle'},
{title: '菜单父编号',field: 'pcode',align: 'center',valign: 'middle'}, {title: '菜单父编号', field: 'pcode', align: 'center', valign: 'middle'},
{title: '菜单名称',field: 'name',align: 'center',valign: 'middle'}, {title: '菜单名称', field: 'name', align: 'center', valign: 'middle'},
{title: '请求地址',field: 'url',align: 'center',valign: 'middle'}, {title: '请求地址', field: 'url', align: 'center', valign: 'middle'},
{title: '排序',field: 'num',align: 'center',valign: 'middle'}, {title: '排序', field: 'num', align: 'center', valign: 'middle'},
{title: '层级',field: 'levels',align: 'center',valign: 'middle'}, {title: '层级', field: 'levels', align: 'center', valign: 'middle'},
{title: '状态',field: 'statusName',align: 'center',valign: 'middle'}] {title: '状态', field: 'statusName', align: 'center', valign: 'middle'}]
return columns; return columns;
}; };
/** /**
* 绑定表格的事件 * 绑定表格的事件
*/ */
Menu.bindEvent = function(){ Menu.bindEvent = function () {
$('#' + this.id).on('click-row.bs.table', function(e, row, $element) { $('#' + this.id).on('click-row.bs.table', function (e, row, $element) {
Menu.seItem = row; Menu.seItem = row;
}); });
}; };
/** /**
* 检查是否选中 * 检查是否选中
*/ */
Menu.check = function(){ Menu.check = function () {
if(this.seItem == null){ if (this.seItem == null) {
Feng.info("请先选中表格中的某一记录!"); Feng.info("请先选中表格中的某一记录!");
return false; return false;
}else{ } else {
return true; return true;
} }
}; };
/** /**
* 点击添加菜单 * 点击添加菜单
*/ */
Menu.openAddMenu = function(){ Menu.openAddMenu = function () {
var index = layer.open({ var index = layer.open({
type: 2, type: 2,
title: '添加菜单', title: '添加菜单',
area: ['800px', '450px'], //宽高 area: ['800px', '450px'], //宽高
fix: false, //不固定 fix: false, //不固定
maxmin: true, maxmin: true,
content :Feng.ctxPath + '/menu/menu_add' content: Feng.ctxPath + '/menu/menu_add'
}); });
this.layerIndex = index; this.layerIndex = index;
}; };
/** /**
* 点击修改 * 点击修改
*/ */
Menu.openChangeMenu = function(){ Menu.openChangeMenu = function () {
if(this.check()){ if (this.check()) {
var index = layer.open({ var index = layer.open({
type: 2, type: 2,
title: '修改菜单', title: '修改菜单',
area: ['800px', '450px'], //宽高 area: ['800px', '450px'], //宽高
fix: false, //不固定 fix: false, //不固定
maxmin: true, maxmin: true,
content :Feng.ctxPath + '/menu/menu_edit/' + this.seItem.id content: Feng.ctxPath + '/menu/menu_edit/' + this.seItem.id
}); });
this.layerIndex = index; this.layerIndex = index;
} }
}; };
/** /**
* 删除 * 删除
*/ */
Menu.delMenu = function(){ Menu.delMenu = function () {
if(this.check()){ if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/menu/remove/" + this.seItem.id, function(data){ var ajax = new $ax(Feng.ctxPath + "/menu/remove/" + this.seItem.id, function (data) {
Feng.success("删除成功!"); Feng.success("删除成功!");
Menu.table.refresh(); Menu.table.refresh();
},function(data){ }, function (data) {
Feng.error("删除失败!"); Feng.error("删除失败!");
}); });
ajax.start(); ajax.start();
} }
}; };
/** /**
* 搜索 * 搜索
*/ */
Menu.search = function(){ Menu.search = function () {
var queryData = {}; var queryData = {};
queryData['menuName'] = $("#menuName").val(); queryData['menuName'] = $("#menuName").val();
queryData['level'] = $("#level").val();
Menu.table.refresh({query: queryData}); Menu.table.refresh({query: queryData});
} }
$(function(){ $(function () {
var defaultColunms = Menu.initColumn(); var defaultColunms = Menu.initColumn();
var table = new BSTable(Menu.id,"/menu/list",defaultColunms); var table = new BSTable(Menu.id, "/menu/list", defaultColunms);
table.setPaginationType("client"); table.setPaginationType("client");
table.init(); table.init();
Menu.bindEvent(); Menu.bindEvent();
Menu.table = table; Menu.table = table;
}); });
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