Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MCMS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
MCMS
Commits
0de40ccc
Commit
0de40ccc
authored
Mar 02, 2016
by
mingsoft
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复后台菜单bug
parent
96e139cf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
422 deletions
+0
-422
src/main/java/com/mingsoft/basic/action/ModelAction.java
src/main/java/com/mingsoft/basic/action/ModelAction.java
+0
-233
src/main/webapp/manager/model/model_list.ftl
src/main/webapp/manager/model/model_list.ftl
+0
-189
No files found.
src/main/java/com/mingsoft/basic/action/ModelAction.java
deleted
100644 → 0
View file @
96e139cf
/**
The MIT License (MIT) * Copyright (c) 2015 铭飞科技
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package
com
.
mingsoft
.
basic
.
action
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mingsoft.base.entity.BaseEntity
;
import
com.mingsoft.basic.biz.IManagerBiz
;
import
com.mingsoft.basic.biz.IModelBiz
;
import
com.mingsoft.base.constant.ModelCode
;
import
com.mingsoft.basic.entity.ManagerEntity
;
import
com.mingsoft.basic.entity.ModelEntity
;
import
com.mingsoft.util.StringUtil
;
/**
* 模块控制层
* @author 史爱华
* @version
* 版本号:100-000-000<br/>
* 创建日期:2014-6-29<br/>
* 历史修订:<br/>
*/
@Controller
@RequestMapping
(
"/manager/model"
)
public
class
ModelAction
extends
BaseAction
{
/**
* 注入模块业务层
*/
@Autowired
private
IModelBiz
modelBiz
;
@Autowired
private
IManagerBiz
managerBiz
;
/**
* 增加模块
* @param model 模块实体
* @param request 请求对象
* @param response 响应对象
*/
@RequestMapping
(
"/save"
)
@ResponseBody
public
void
save
(
@ModelAttribute
ModelEntity
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//获取管理员id并赋值给模块的id
model
.
setModelId
(
getManagerId
(
request
));
// 获取模块保存时间
model
.
setModelDatetime
(
new
Timestamp
(
System
.
currentTimeMillis
()));
if
(!
StringUtil
.
checkLength
(
model
.
getModelTitle
(),
1
,
20
)
)
{
this
.
outJson
(
response
,
getResString
(
"err.length"
,
this
.
getResString
(
"modelTitle"
),
"2"
,
"20"
));
return
;
}
if
(!
StringUtil
.
checkLength
(
model
.
getModelCode
(),
1
,
20
)){
this
.
outJson
(
response
,
getResString
(
"err.length"
,
this
.
getResString
(
"modelCode"
),
"2"
,
"20"
));
return
;
}
//判断图标是否为空,不为空去掉,图标地址中含有的“|”
//空值判断
if
(!
StringUtil
.
isBlank
(
model
.
getModelIcon
()))
{
model
.
setModelIcon
(
model
.
getModelIcon
().
replace
(
"|"
,
""
));
}
modelBiz
.
saveEntity
(
model
);
//返回模块id到页面
this
.
outJson
(
response
,
ModelCode
.
ROLE
,
true
,
String
.
valueOf
(
model
.
getModelId
()));
}
/**
* 查询所有模块,以json格式输出
* @param response 响应对象
*/
@RequestMapping
(
"/queryAll"
)
public
void
queryAll
(
HttpServletResponse
response
)
{
List
<
BaseEntity
>
modelList
=
modelBiz
.
queryAll
();
this
.
outJson
(
response
,
JSONObject
.
toJSONString
(
modelList
));
}
/**
* 根据模块id编辑模块
* @param modelId 模块id
* @return 模块实体Map集合
*/
@RequestMapping
(
"/edit/{modelId}"
)
@ResponseBody
public
Map
edit
(
@PathVariable
int
modelId
)
{
Map
mode
=
new
HashMap
();
List
<
BaseEntity
>
allModel
=
modelBiz
.
queryAll
();
mode
.
clear
();
//根据id获取模块
ModelEntity
model
=
(
ModelEntity
)
modelBiz
.
getEntity
(
modelId
);
//根据父模块id查寻模块
ModelEntity
parentModel
=
(
ModelEntity
)
modelBiz
.
getEntity
(
model
.
getModelModelId
());
mode
.
put
(
"allModel"
,
allModel
);
mode
.
put
(
"parentModel"
,
parentModel
);
mode
.
put
(
"model"
,
model
);
return
mode
;
}
/**
* 修改模块
* @param model 模块实体
* @param request 请求对象
* @param response 响应对象
*/
@RequestMapping
(
"/update"
)
@ResponseBody
public
void
update
(
@ModelAttribute
ModelEntity
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(!
StringUtil
.
checkLength
(
model
.
getModelTitle
(),
2
,
20
)
||
!
StringUtil
.
checkLength
(
model
.
getModelCode
(),
2
,
20
))
{
return
;
}
//判断图标是否为空,不为空去掉,图标地址中含有的“|”
//空值判断
if
(!
StringUtil
.
isBlank
(
model
.
getModelIcon
()))
{
model
.
setModelIcon
(
model
.
getModelIcon
().
replace
(
"|"
,
""
));
}
modelBiz
.
updateEntity
(
model
);
this
.
outJson
(
response
,
ModelCode
.
ROLE
,
true
,
String
.
valueOf
(
model
.
getModelId
()));
}
/**
* 加载模块列表页
* @param mode ModelMap实体对象
* @param request 请求对象
* @return 模块列表页面地址
*/
@RequestMapping
(
"/list"
)
public
String
list
(
ModelMap
mode
,
HttpServletRequest
request
)
{
List
<
BaseEntity
>
parentModelList
=
modelBiz
.
queryAll
();
mode
.
addAttribute
(
"parentModelList"
,
JSONArray
.
toJSONString
(
parentModelList
));
return
"/manager/model/model_list"
;
}
/**
* 根据模块id查询所有子模块列表
* @param modelId 模块id
* @param response 响应对象
* @return 子模块的map集合
*/
@RequestMapping
(
"/{modelId}/childlist"
)
@ResponseBody
public
Map
childList
(
@PathVariable
int
modelId
,
HttpServletResponse
response
)
{
Map
model
=
new
HashMap
();
List
<
BaseEntity
>
childModelList
=
modelBiz
.
queryChildList
(
modelId
);
model
.
put
(
"chileModelList"
,
childModelList
);
return
model
;
}
/**
* 根据id查询是否有子模块
* @param modelId 模块id
* @param response 响应对象
*/
@RequestMapping
(
"/{modelId}/isChildModel"
)
@ResponseBody
public
void
isChildModel
(
@PathVariable
int
modelId
,
HttpServletResponse
response
)
{
int
childCount
=
modelBiz
.
queryChildList
(
modelId
).
size
();
if
(
childCount
>
0
)
{
this
.
outJson
(
response
,
true
);
}
else
{
this
.
outJson
(
response
,
modelId
);
}
}
/**
* 根据Id删除模块
* @param modelId 模块id
* @param response 响应对象
*/
@RequestMapping
(
"/{modelId}/delete"
)
@ResponseBody
public
void
delete
(
@PathVariable
int
modelId
,
HttpServletResponse
response
)
{
ModelEntity
model
=
(
ModelEntity
)
modelBiz
.
getEntity
(
modelId
);
modelBiz
.
deleteEntity
(
modelId
);
this
.
outJson
(
response
,
ModelCode
.
ROLE
,
true
,
String
.
valueOf
(
model
.
getModelModelId
()));
}
/**
* 根据管理员ID查询模块集合
* @param managerId 管理员id
* @param request 请求对象
* @param response 响应对象
*/
@RequestMapping
(
"/{managerId}/queryModelByRoleId"
)
public
void
queryModelByRoleId
(
@PathVariable
int
managerId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ManagerEntity
manager
=(
ManagerEntity
)
managerBiz
.
getEntity
(
managerId
);
if
(
manager
==
null
){
return
;
}
List
<
BaseEntity
>
modelList
=
new
ArrayList
<
BaseEntity
>();
modelList
=
modelBiz
.
queryModelByRoleId
(
manager
.
getManagerRoleID
());
this
.
outJson
(
response
,
null
,
true
,
JSONObject
.
toJSONString
(
modelList
));
}
}
\ No newline at end of file
src/main/webapp/manager/model/model_list.ftl
deleted
100644 → 0
View file @
96e139cf
<!DOCTYPE html>
<html
lang=
"zh"
>
<head>
<
#include
"/
manager
/
include
/
macro
.
ftl
"
/>
<
#include
"/
manager
/
include
/
meta
.
ftl
"
/>
<style>
#addEditModelDialog
.modal-body
{
overflow
:
inherit
;
}
</style>
</head>
<body>
<script
id=
"beforedmodelTree"
type=
"text/x-jquery-tmpl"
>
<
td
class
=
"
text-center
"
style
=
"
width:10%;
"
>
<
i
class
=
"
icon iconfont icon-logo
"
>
{{
if
modelIcon
}}{{
=
modelIcon
}}{{
else
}}{{
/if}
}
<
/i>
<
/td>
</script>
<script
id=
"aftermodelTree"
type=
"text/x-jquery-tmpl"
>
<
td
style
=
"
width:30%;
"
>
{{
=
modelCode
}}
<
/td
>
<
td
class
=
"
text-left
"
style
=
"
width: 20%;
"
>
{{
=
modelUrl
}}
<
/td
>
<
td
class
=
"
text-center
"
>
{{
if
modelIsMenu
>
0
}}
是
{{
else
}}
否
{{
/
if
}}
<
/td
>
<
td
class
=
"
text-center
"
>
<
a
class
=
"
btn btn-xs red tooltips editModal
"
onclick
=
"
editModal(this)
"
data
-
toggle
=
"
tooltip
"
data
-
id
=
"
{{= modelId}}
"
data
-
original
-
title
=
"
编辑
"
>
<
i
class
=
"
glyphicon glyphicon-pencil
"
><
/i
>
<
/a
>
<
a
class
=
"
btn btn-xs red tooltips deleteModal
"
onclick
=
"
deleteModal(this)
"
data
-
toggle
=
"
tooltip
"
data
-
id
=
"
{{= modelId}}
"
data
-
original
-
title
=
"
删除
"
>
<
i
class
=
"
glyphicon glyphicon-trash
"
><
/i
>
<
/a
>
<
/td
>
</script>
<
@
ms
.
content
>
<
@
ms
.
contentBody
>
<
@
ms
.
contentNav
title=
"模块管理列表"
></
@
ms
.contentNav
>
<
@
ms
.
contentPanel
>
<
@
ms
.
panelNav
>
<
@
ms
.
panelNavBtnGroup
>
<
@
ms
.
panelNavBtnAdd
/>
</
@
ms
.panelNavBtnGroup
>
</
@
ms
.panelNav
>
<
@
ms
.
nodata
style=
"text-align:left;"
content=
"模块编码:8位整型组成,00-00-00-00-00,表示:项目-模块-子功能-CURDO(查:0添:1删:2改:3等其他)
<br/>
特别说明: 通用模块编号:分类(99) 文章(98) 订单(97) 订单状态(96) 支付方式(95) 配送方式(94) 前端模块(93) "
/>
<
@
ms
.
table
head=
["<th
style=
'width:7%'
>
模块编号
</th>
","
<th
class=
'text-center'
>
模块图标
</th>
",'模块标题','模块编码(项目-模块-子功能-CURDO)','模块链接地址',"
<th
class=
'text-center'
>
是否是菜单
</th>
","
<th
style=
'text-align:center;'
>
操作
</th>
"] id="tableConterent">
<
#if
parentModelList
?
has_content
>
<
@
ms
.
treeTable
style=
"width:20%"
treeId=
"modelTree"
tmplBefored=
"true"
tbodyId=
"tableConterent"
jsonName=
"modelTitle"
jsonId=
"modelId"
jsonPid=
"modelModelId"
json=
"${parentModelList?default('')}"
/>
<
#else
>
<tr>
<td
colspan=
"7"
class=
"text-center"
>
<
@
ms
.
nodata
content=
"暂无模块"
/>
</td>
</tr>
</
#
if>
</
@
ms
.table
>
<!--添加模块-->
<
@
ms
.
modal
modalName=
"addEditModel"
title=
"添加模块"
>
<
@
ms
.
modalBody
height=
"350"
>
<
@
ms
.
form
isvalidation=
true
name=
"addEditForm"
action=
""
method=
"post"
>
<
@
ms
.
text
name=
"modelTitle"
label=
"标题"
title=
"模块标题"
placeholder=
"请输入模块标题"
value=
""
validation=
{"required":"true",
"
data-bv-notempty-message
"
:
"请输入模块标题!"}
/>
<
@
ms
.
text
name=
"modelCode"
label=
"编码"
title=
"模块编码"
placeholder=
"请输入模块编码"
value=
""
validation=
{"required":"true",
"
data-bv-notempty-message
"
:
"请输入模块编码!"}
/>
<
@
ms
.
text
name=
"modelIcon"
label=
"图标"
title=
"模块图标"
placeholder=
"请输入模块图标"
value=
""
/>
<
@
ms
.
text
name=
"modelUrl"
label=
"链接地址"
title=
"模块链接地址"
placeholder=
"请输入模块链接地址"
value=
""
/>
<
#assign
isMenu=
[{"id":"0","name":"否"},{"id":"1","name":"是"}]
>
<
@
ms
.
select
name=
"modelIsMenu"
style=
"width: 25%;"
id=
"modelMenuSelect"
list=
isMenu
listKey=
"id"
listValue=
"name"
label=
"是否是菜单"
value=
"0"
title=
"是否是菜单"
/>
<
@
ms
.
formRow
label=
"父亲菜单"
>
<
@
ms
.
treeInput
treeId=
"modelInputTree"
json=
"${parentModelList?default('')}"
jsonId=
"modelId"
jsonPid=
"modelModelId"
jsonName=
"modelTitle"
addNodesName=
"顶级模块"
buttonText=
"顶级模块"
inputName=
"modelModelId"
inputValue=
"0"
expandAll=
"true"
showIcon=
"true"
/>
</
@
ms
.formRow
>
<
@
ms
.
hidden
name=
"modelId"
value=
""
id=
"hideModelId"
/>
</
@
ms
.form
>
</
@
ms
.modalBody
>
<
@
ms
.
modalButton
>
<
@
ms
.
button
value=
""
id=
"addEditBtn"
/>
</
@
ms
.modalButton
>
</
@
ms
.modal
>
<
@
ms
.
modal
modalName=
"deleteModel"
title=
"删除提示!"
>
<
@
ms
.
modalBody
>
确认删除??
</
@
ms
.modalBody
>
<
@
ms
.
modalButton
>
<
@
ms
.
button
value=
"确认"
id=
"rightDelete"
url=
"${base}/manager/loginOut.do"
/>
</
@
ms
.modalButton
>
</
@
ms
.modal
>
</
@
ms
.contentPanel
>
</
@
ms
.contentBody
>
</
@
ms
.content
>
<script>
var
modelId
;
var
postMessage
;
$
(
function
(){
//新增模块
$
(
"
#addButton
"
).
click
(
function
(){
postMessage
=
"
保存成功!
"
;
$
(
"
#addEditBtn
"
).
text
(
"
保存
"
);
$
(
"
#addEditForm
"
).
attr
(
"
action
"
,
"
${base}/manager/model/save.do
"
);
$
(
"
#addEditForm
"
)[
0
].
reset
();
$
(
"
.addEditModel
"
).
modal
();
$
(
"
#hideModelId
"
).
attr
(
"
disabled
"
,
true
);
});
$
(
"
#addEditBtn
"
).
on
(
"
click
"
,
function
(){
var
vobj
=
$
(
"
#addEditForm
"
).
data
(
'
bootstrapValidator
'
).
validate
();
if
(
vobj
.
isValid
()){
$
(
this
).
postForm
(
"
#addEditForm
"
,{
func
:
function
(
msg
)
{
if
(
msg
.
result
){
alert
(
postMessage
);
location
.
reload
();
}
}});
}
});
//删除模块
$
(
"
#rightDelete
"
).
on
(
"
click
"
,
function
(){
var
rightUrl
=
base
+
"
/manager/model/
"
+
modelId
+
"
/isChildModel.do
"
;
$
(
this
).
request
({
url
:
rightUrl
,
method
:
"
post
"
,
func
:
function
(
data
){
if
(
data
==
true
){
alert
(
"
请先删除子模块!!
"
);
$
(
"
.deleteModel
"
).
modal
(
"
hide
"
);
}
else
{
var
actionUrl
=
base
+
"
/manager/model/
"
+
data
+
"
/delete.do
"
;
$
(
this
).
request
({
url
:
actionUrl
,
type
:
"
json
"
,
method
:
"
post
"
,
func
:
function
(
msg
)
{
alert
(
"
删除成功
"
);
location
.
reload
();
}});
}
}});
});
});
//编辑模块
function
editModal
(
obj
){
modelId
=
$
(
obj
).
attr
(
"
data-id
"
);
var
editUrl
=
base
+
"
/manager/model/edit/
"
+
modelId
+
"
.do
"
;
$
(
this
).
request
({
url
:
editUrl
,
type
:
"
json
"
,
method
:
"
post
"
,
func
:
function
(
data
){
var
model
=
data
.
model
;
// 给表单赋值
if
(
model
!=
null
){
$
(
"
input[name='modelId']
"
).
val
(
model
.
modelId
);
if
(
model
.
modelIcon
!=
undefined
){
$
(
"
input[name='modelIcon']
"
).
val
(
model
.
modelIcon
);
}
$
(
"
input[name='modelTitle']
"
).
val
(
model
.
modelTitle
);
$
(
"
input[name='modelCode']
"
).
val
(
model
.
modelCode
);
$
(
"
input[name='modelUrl']
"
).
val
(
model
.
modelUrl
);
$
(
"
#modelMenuSelect option[value=
"
+
model
.
modelMenu
+
"
]
"
).
attr
(
"
selected
"
,
true
);
$
(
"
input[name='modelModelId']
"
).
val
(
model
.
modelModelId
);
if
(
model
.
modelModelId
==
0
){
$
(
"
#treeLabelmodelInputTree
"
).
text
(
"
顶级模块
"
);
}
else
{
$
(
"
#treeLabelmodelInputTree
"
).
text
(
data
.
parentModel
.
modelTitle
);
}
$
(
"
.addEditModel
"
).
modal
();
postMessage
=
"
更新成功!
"
;
$
(
"
#addEditBtn
"
).
text
(
"
更新
"
);
$
(
"
#hideModelId
"
).
attr
(
"
disabled
"
,
false
);
$
(
"
#hideModelId
"
).
val
(
model
.
modelId
);
$
(
"
#addEditForm
"
).
attr
(
"
action
"
,
"
${base}/manager/model/update.do
"
);
}
}});
}
//删除模块
function
deleteModal
(
obj
){
modelId
=
$
(
obj
).
attr
(
"
data-id
"
);
$
(
"
.deleteModel
"
).
modal
();
}
</script>
</body>
</html>
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