Commit 0889884c by fengshuonan

菜单编辑完善

parent 91bd3531
...@@ -81,8 +81,8 @@ public class MenuController extends BaseController { ...@@ -81,8 +81,8 @@ public class MenuController extends BaseController {
* 跳转到菜单详情列表页面 * 跳转到菜单详情列表页面
*/ */
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/menu_edit/{menuId}") @RequestMapping(value = "/menu_edit")
public String menuEdit(@PathVariable Long menuId, Model model) { public String menuEdit(@RequestParam Long menuId, Model model) {
if (ToolUtil.isEmpty(menuId)) { if (ToolUtil.isEmpty(menuId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL); throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
} }
...@@ -196,6 +196,18 @@ public class MenuController extends BaseController { ...@@ -196,6 +196,18 @@ public class MenuController extends BaseController {
} }
/** /**
* 获取菜单信息
*/
@RequestMapping(value = "/getMenuInfo")
@ResponseBody
public Object getMenuInfo(@RequestParam Long menuId) {
if (ToolUtil.isEmpty(menuId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
return this.menuService.selectById(menuId);
}
/**
* 获取菜单列表(首页用) * 获取菜单列表(首页用)
*/ */
@RequestMapping(value = "/menuTreeList") @RequestMapping(value = "/menuTreeList")
......
@layout("/common/_container.html"){ @layout("/common/_dialog.html",{plugins:["laydate","sweet-alert","layer"],js:["/assets/modular/system/menu/menu_edit.js"]}){
<div class="ibox float-e-margins"> <div class="container-fluid">
<div class="ibox-content"> <form id="menuForm" \@submit="submitForm">
<div class="form-horizontal" id="menuInfoForm">
<input type="hidden" id="id" value="${menu.id}">
<input type="hidden" id="ismenuValue" value="${menu.ismenu}">
<div class="row"> <div class="row">
<div class="col-sm-6 b-r"> <div class="col-6">
<#input id="name" name="名称" value="${menu.name}" underline="true" /> <div class="form-group">
<#input id="code" name="菜单编号" value="${menu.code}" underline="true" /> <h5>名称 <span class="text-danger">*</span></h5>
<#input id="pcodeName" name="父级编号" value="${menu.pcodeName}" underline="true" <div class="controls">
hidden="pcode" readonly="readonly" hiddenValue="${menu.pcode}" <input v-model="name" type="text" class="form-control">
clickFun="MenuInfoDlg.showMenuSelectTree(); return false;"
style="background-color: #ffffff !important;"
selectFlag="true" selectId="pcodeTreeDiv" selectTreeId="pcodeTree" selectStyle="width:244px !important;"/>
<#select id="ismenu" name="是否是菜单">
<option value="1"></option>
<option value="0">不是</option>
</#select>
</div> </div>
<div class="col-sm-6">
<#input id="url" name="请求地址" value="${menu.url}" underline="true" />
<#input id="num" name="排序" value="${menu.num}" underline="true" />
<#input id="icon" name="图标" underline="false" value="${menu.icon}"/>
</div> </div>
<div class="form-group">
<h5>菜单编号 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="code" type="text" class="form-control">
</div> </div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="MenuInfoDlg.editSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="MenuInfoDlg.close()"/>
</div> </div>
<div class="form-group">
<h5>父级编号 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="pcodeName" id="detpName" \@click="showMenuSelectTree" type="text" class="form-control" autocomplete="off">
<input v-model="pcode" type="hidden" class="form-control">
</div> </div>
</div> </div>
<div class="form-group">
<h5>是否是菜单 <span class="text-danger">*</span></h5>
<div class="controls">
<select v-model="ismenu" class="form-control">
<option value="">请选择</option>
<option value="Y"></option>
<option value="N">不是</option>
</select>
</div> </div>
</div>
</div>
<div class="col-6">
<div class="form-group">
<h5>请求地址 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="url" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<h5>排序</h5>
<div class="controls">
<input v-model="num" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<h5>图标</h5>
<div class="controls">
<input v-model="icon" type="text" class="form-control">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="text-xs-right">
<button class="btn btn-info normal-button-width" \@click="ensure">提交</button>
<button class="btn btn-inverse normal-button-width m-l-10" \@click="close">取消</button>
</div>
</div>
</div>
</form>
</div> </div>
<script src="${ctxPath}/static/modular/system/menu/menu_info.js"></script>
@} @}
...@@ -69,7 +69,7 @@ Menu.openChangeMenu = function () { ...@@ -69,7 +69,7 @@ Menu.openChangeMenu = function () {
area: ['800px', '500px'], //宽高 area: ['800px', '500px'], //宽高
fix: false, //不固定 fix: false, //不固定
maxmin: true, maxmin: true,
content: Feng.ctxPath + '/menu/menu_edit/' + this.seItem.id content: Feng.ctxPath + '/menu/menu_edit?menuId=' + this.seItem.menuId
}); });
} }
}; };
......
...@@ -2,135 +2,57 @@ ...@@ -2,135 +2,57 @@
* 菜单详情对话框 * 菜单详情对话框
*/ */
var MenuInfoDlg = { var MenuInfoDlg = {
menuInfoData: {}, data: {
ztreeInstance: null, menuId: "",
validateFields: { name: "",
name: { code: "",
validators: { pcode: "",
notEmpty: { pcodeName: "",
message: '菜单名称不能为空' url: "",
} num: "",
} levels: "",
}, icon: "",
code: { ismenu: ""
validators: {
notEmpty: {
message: '菜单编号不能为空'
}
}
},
pcodeName: {
validators: {
notEmpty: {
message: '父菜单不能为空'
}
}
},
url: {
validators: {
notEmpty: {
message: '请求地址不能为空'
}
}
},
num: {
validators: {
notEmpty: {
message: '序号不能为空'
}
}
}
} }
}; };
/** /**
* 清除数据
*/
MenuInfoDlg.clearData = function () {
this.menuInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
MenuInfoDlg.set = function (key, value) {
this.menuInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
MenuInfoDlg.get = function (key) {
return $("#" + key).val();
}
/**
* 关闭此对话框 * 关闭此对话框
*/ */
MenuInfoDlg.close = function () { MenuInfoDlg.close = function () {
parent.layer.close(window.parent.Menu.layerIndex); parent.layer.close(window.parent.Menu.layerIndex);
} };
/**
* 收集数据
*/
MenuInfoDlg.collectData = function () {
this.set('id').set('name').set('code').set('pcode').set('url').set('num').set('levels').set('icon').set("ismenu");
}
/** /**
* 验证数据是否为空 * 验证数据是否为空
*/ */
MenuInfoDlg.validate = function () { MenuInfoDlg.validateForm = function () {
$('#menuInfoForm').data("bootstrapValidator").resetForm();
$('#menuInfoForm').bootstrapValidator('validate');
return $("#menuInfoForm").data('bootstrapValidator').isValid();
}
/**
* 提交添加用户
*/
MenuInfoDlg.addSubmit = function () {
this.clearData(); var data = MenuInfoDlg.data;
this.collectData();
if (!this.validate()) { if (!data.name) {
return; return "请输入菜单名称";
}
if (!data.code) {
return "请输入菜单编号";
}
if (!data.pcode) {
return "请输入菜单上级";
}
if (!data.ismenu) {
return "请输入是否是菜单";
}
if (!data.url) {
return "请输入url地址";
} }
//提交信息 return true;
var ajax = new $ax(Feng.ctxPath + "/menu/add", function (data) { };
Feng.success("添加成功!");
window.parent.Menu.table.refresh();
MenuInfoDlg.close();
}, function (data) {
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.menuInfoData);
ajax.start();
}
/** /**
* 提交修改 * 提交添加菜单
*/ */
MenuInfoDlg.editSubmit = function () { MenuInfoDlg.addSubmit = function () {
this.clearData();
this.collectData();
if (!this.validate()) {
return;
}
//提交信息
var ajax = new $ax(Feng.ctxPath + "/menu/edit", function (data) { var ajax = new $ax(Feng.ctxPath + "/menu/edit", function (data) {
Feng.success("修改成功!"); Feng.success("修改成功!");
window.parent.Menu.table.refresh(); window.parent.Menu.table.refresh();
...@@ -138,38 +60,47 @@ MenuInfoDlg.editSubmit = function () { ...@@ -138,38 +60,47 @@ MenuInfoDlg.editSubmit = function () {
}, function (data) { }, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!"); Feng.error("修改失败!" + data.responseJSON.message + "!");
}); });
ajax.set(this.menuInfoData); ajax.set(this.data);
ajax.start(); ajax.start();
}
/**
* 点击父级编号input框时
*/
MenuInfoDlg.onClickDept = function (e, treeId, treeNode) {
$("#pcodeName").attr("value", MenuInfoDlg.ztreeInstance.getSelectedVal());
$("#pcode").attr("value", treeNode.id);
};
/**
* 显示父级菜单选择的树
*/
MenuInfoDlg.showMenuSelectTree = function () {
Feng.showInputTree("pcodeName", "pcodeTreeDiv", 15, 34);
}; };
$(function () { $(function () {
Feng.initValidator("menuInfoForm", MenuInfoDlg.validateFields);
var ztree = new $ZTree("pcodeTree", "/menu/selectMenuTreeList");
ztree.bindOnClick(MenuInfoDlg.onClickDept);
ztree.init();
MenuInfoDlg.ztreeInstance = ztree;
//初始化是否是菜单 //获取菜单信息
if($("#ismenuValue").val() == undefined){ var ajax = new $ax(Feng.ctxPath + "/menu/getMenuInfo?menuId=" + Feng.getUrlParam("menuId"));
$("#ismenu").val(0); var result = ajax.start();
}else{ MenuInfoDlg.data = result.data;
$("#ismenu").val($("#ismenuValue").val());
MenuInfoDlg.app = new Vue({
el: '#menuForm',
data: MenuInfoDlg.data,
methods: {
submitForm: function (e) {
e.preventDefault();
},
showMenuSelectTree: function () {
var formName = encodeURIComponent("parent.MenuInfoDlg.app.pcodeName");
var formId = encodeURIComponent("parent.MenuInfoDlg.app.pcode");
var treeUrl = encodeURIComponent(Feng.ctxPath + "/menu/selectMenuTreeList");
layer.open({
type: 2,
title: '部门选择',
area: ['300px', '400px'],
content: Feng.ctxPath + '/system/commonTree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl
});
},
ensure: function () {
var result = MenuInfoDlg.validateForm();
if (result === true) {
MenuInfoDlg.addSubmit();
} else {
Feng.alert(result);
}
},
close: function () {
MenuInfoDlg.close();
} }
}
});
}); });
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