Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
0889884c
Commit
0889884c
authored
Dec 18, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜单编辑完善
parent
91bd3531
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
177 deletions
+145
-177
src/main/java/cn/stylefeng/guns/modular/system/controller/MenuController.java
+14
-2
src/main/webapp/WEB-INF/system/menu/menu_edit.html
+60
-35
src/main/webapp/assets/modular/system/menu/menu.js
+1
-1
src/main/webapp/assets/modular/system/menu/menu_edit.js
+70
-139
No files found.
src/main/java/cn/stylefeng/guns/modular/system/controller/MenuController.java
View file @
0889884c
...
...
@@ -81,8 +81,8 @@ public class MenuController extends BaseController {
* 跳转到菜单详情列表页面
*/
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/menu_edit
/{menuId}
"
)
public
String
menuEdit
(
@
PathVariable
Long
menuId
,
Model
model
)
{
@RequestMapping
(
value
=
"/menu_edit"
)
public
String
menuEdit
(
@
RequestParam
Long
menuId
,
Model
model
)
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
...
...
@@ -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"
)
...
...
src/main/webapp/WEB-INF/system/menu/menu_edit.html
View file @
0889884c
@layout("/common/_container.html"){
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-content"
>
<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=
"col-sm-6 b-r"
>
<
#
input
id=
"name"
name=
"名称"
value=
"${menu.name}"
underline=
"true"
/>
<
#
input
id=
"code"
name=
"菜单编号"
value=
"${menu.code}"
underline=
"true"
/>
<
#
input
id=
"pcodeName"
name=
"父级编号"
value=
"${menu.pcodeName}"
underline=
"true"
hidden=
"pcode"
readonly=
"readonly"
hiddenValue=
"${menu.pcode}"
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
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}"
/>
@layout("/common/_dialog.html",{plugins:["laydate","sweet-alert","layer"],js:["/assets/modular/system/menu/menu_edit.js"]}){
<div
class=
"container-fluid"
>
<form
id=
"menuForm"
\@
submit=
"submitForm"
>
<div
class=
"row"
>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
名称
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"name"
type=
"text"
class=
"form-control"
>
</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=
"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
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
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
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
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>
</div>
</form>
</div>
<script
src=
"${ctxPath}/static/modular/system/menu/menu_info.js"
></script>
@}
src/main/webapp/assets/modular/system/menu/menu.js
View file @
0889884c
...
...
@@ -69,7 +69,7 @@ Menu.openChangeMenu = function () {
area
:
[
'800px'
,
'500px'
],
//宽高
fix
:
false
,
//不固定
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/menu/menu_edit
/'
+
this
.
seItem
.
i
d
content
:
Feng
.
ctxPath
+
'/menu/menu_edit
?menuId='
+
this
.
seItem
.
menuI
d
});
}
};
...
...
src/main/webapp/assets/modular/system/menu/menu_edit.js
View file @
0889884c
...
...
@@ -2,135 +2,57 @@
* 菜单详情对话框
*/
var
MenuInfoDlg
=
{
menuInfoData
:
{},
ztreeInstance
:
null
,
validateFields
:
{
name
:
{
validators
:
{
notEmpty
:
{
message
:
'菜单名称不能为空'
}
}
},
code
:
{
validators
:
{
notEmpty
:
{
message
:
'菜单编号不能为空'
}
}
},
pcodeName
:
{
validators
:
{
notEmpty
:
{
message
:
'父菜单不能为空'
}
}
},
url
:
{
validators
:
{
notEmpty
:
{
message
:
'请求地址不能为空'
}
}
},
num
:
{
validators
:
{
notEmpty
:
{
message
:
'序号不能为空'
}
}
}
data
:
{
menuId
:
""
,
name
:
""
,
code
:
""
,
pcode
:
""
,
pcodeName
:
""
,
url
:
""
,
num
:
""
,
levels
:
""
,
icon
:
""
,
ismenu
:
""
}
};
/**
* 清除数据
*/
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
()
{
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
()
{
$
(
'#menuInfoForm'
).
data
(
"bootstrapValidator"
).
resetForm
();
$
(
'#menuInfoForm'
).
bootstrapValidator
(
'validate'
);
return
$
(
"#menuInfoForm"
).
data
(
'bootstrapValidator'
).
isValid
();
}
MenuInfoDlg
.
validateForm
=
function
()
{
/**
* 提交添加用户
*/
MenuInfoDlg
.
addSubmit
=
function
()
{
this
.
clearData
();
this
.
collectData
();
var
data
=
MenuInfoDlg
.
data
;
if
(
!
this
.
validate
())
{
return
;
if
(
!
data
.
name
)
{
return
"请输入菜单名称"
;
}
if
(
!
data
.
code
)
{
return
"请输入菜单编号"
;
}
if
(
!
data
.
pcode
)
{
return
"请输入菜单上级"
;
}
if
(
!
data
.
ismenu
)
{
return
"请输入是否是菜单"
;
}
if
(
!
data
.
url
)
{
return
"请输入url地址"
;
}
//提交信息
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
();
}
return
true
;
};
/**
* 提交
修改
* 提交
添加菜单
*/
MenuInfoDlg
.
editSubmit
=
function
()
{
this
.
clearData
();
this
.
collectData
();
if
(
!
this
.
validate
())
{
return
;
}
//提交信息
MenuInfoDlg
.
addSubmit
=
function
()
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/menu/edit"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
Menu
.
table
.
refresh
();
...
...
@@ -138,38 +60,47 @@ MenuInfoDlg.editSubmit = function () {
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
this
.
menuInfoD
ata
);
ajax
.
set
(
this
.
d
ata
);
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
()
{
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
){
$
(
"#ismenu"
).
val
(
0
);
}
else
{
$
(
"#ismenu"
).
val
(
$
(
"#ismenuValue"
).
val
());
}
//获取菜单信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/menu/getMenuInfo?menuId="
+
Feng
.
getUrlParam
(
"menuId"
));
var
result
=
ajax
.
start
();
MenuInfoDlg
.
data
=
result
.
data
;
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
();
}
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment