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
ddd35cac
Commit
ddd35cac
authored
Dec 08, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理字典的添加
parent
3496f212
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
492 additions
and
403 deletions
+492
-403
src/main/java/cn/stylefeng/guns/core/beetl/BeetlConfiguration.java
+0
-5
src/main/java/cn/stylefeng/guns/core/tag/DictSelectorTag.java
+0
-217
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
+25
-11
src/main/java/cn/stylefeng/guns/modular/system/model/DictDto.java
+38
-0
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
+15
-0
src/main/webapp/WEB-INF/system/dict/dict.html
+57
-20
src/main/webapp/WEB-INF/system/dict/dict_add.html
+0
-65
src/main/webapp/WEB-INF/system/dict/dict_add_item.html
+53
-0
src/main/webapp/WEB-INF/system/dict/dict_add_type.html
+50
-0
src/main/webapp/WEB-INF/system/dict/dict_edit.html
+28
-70
src/main/webapp/assets/modular/system/dict/dict.js
+33
-15
src/main/webapp/assets/modular/system/dict/dict_add_item.js
+118
-0
src/main/webapp/assets/modular/system/dict/dict_add_type.js
+75
-0
src/main/webapp/assets/modular/system/dict/dict_edit.js
+0
-0
No files found.
src/main/java/cn/stylefeng/guns/core/beetl/BeetlConfiguration.java
View file @
ddd35cac
...
...
@@ -15,7 +15,6 @@
*/
package
cn
.
stylefeng
.
guns
.
core
.
beetl
;
import
cn.stylefeng.guns.core.tag.DictSelectorTag
;
import
cn.stylefeng.guns.core.util.DefaultImages
;
import
cn.stylefeng.guns.core.util.KaptchaUtil
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
...
...
@@ -39,9 +38,6 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
@Autowired
private
Environment
env
;
@Autowired
private
DictSelectorTag
dictSelectorTag
;
@Override
public
void
initOther
()
{
...
...
@@ -49,7 +45,6 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
groupTemplate
.
registerFunctionPackage
(
"shiro"
,
new
ShiroExt
());
groupTemplate
.
registerFunctionPackage
(
"tool"
,
new
ToolUtil
());
groupTemplate
.
registerFunctionPackage
(
"kaptcha"
,
new
KaptchaUtil
());
groupTemplate
.
registerTagFactory
(
"dictSelector"
,
()
->
dictSelectorTag
);
groupTemplate
.
registerFunction
(
"env"
,
new
Function
()
{
@Override
...
...
src/main/java/cn/stylefeng/guns/core/tag/DictSelectorTag.java
deleted
100644 → 0
View file @
3496f212
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
core
.
tag
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.service.DictService
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
org.beetl.core.Tag
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
/**
* 字典标签渲染
*
* @author zhangjiajia
* @Date 2018年6月4日17:33:32
*/
@Component
@Scope
(
"prototype"
)
public
class
DictSelectorTag
extends
Tag
{
@Autowired
DictService
dictService
;
@Override
public
void
render
()
{
//String tagName = (String) this.args[0];
Map
attrs
=
(
Map
)
args
[
1
];
if
(
ToolUtil
.
isEmpty
(
attrs
.
get
(
"code"
)))
{
throw
new
ServiceException
(
BizExceptionEnum
.
ERROR_CODE_EMPTY
);
}
//字典类型编码
String
code
=
attrs
.
get
(
"code"
).
toString
();
//控件显示类型select 选择框,radio 单选按钮,checkbox 多选按钮
String
type
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"type"
))
?
attrs
.
get
(
"type"
).
toString
()
:
"select"
;
//开启多选
String
multiple
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"multiple"
))
?
attrs
.
get
(
"multiple"
).
toString
()
:
""
;
//字典名称
String
label
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"label"
))
?
attrs
.
get
(
"label"
).
toString
()
:
""
;
//提示
String
placeholder
=
(
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"placeholder"
))
?
attrs
.
get
(
"placeholder"
).
toString
()
:
""
);
//宽度
String
width
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"width"
))
?
attrs
.
get
(
"width"
).
toString
()
:
"248"
;
//默认值
String
value
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"value"
))
?
attrs
.
get
(
"value"
).
toString
()
:
""
;
//id
String
id
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"id"
))
?
attrs
.
get
(
"id"
).
toString
()
:
""
;
//name
String
name
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"name"
))
?
attrs
.
get
(
"name"
).
toString
()
:
""
;
//分割线
String
underline
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"underline"
))
?
attrs
.
get
(
"underline"
).
toString
()
:
""
;
//onchange事件
String
onchange
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"onchange"
))
?
attrs
.
get
(
"onchange"
).
toString
()
:
""
;
//readonly属性
String
readonly
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"readonly"
))
?
attrs
.
get
(
"readonly"
).
toString
()
:
""
;
//disabled属性
String
disabled
=
ToolUtil
.
isNotEmpty
(
attrs
.
get
(
"disabled"
))
?
attrs
.
get
(
"disabled"
).
toString
()
:
""
;
//searchnum 下拉选项数量达到多少启用搜索,默认10
int
searchnum
=
ToolUtil
.
isNum
(
attrs
.
get
(
"searchnum"
))
?
Integer
.
parseInt
(
attrs
.
get
(
"searchnum"
).
toString
())
:
10
;
//根据code查询字典数据
List
<
Dict
>
list
=
dictService
.
selectByParentCode
(
code
);
StringBuffer
html
=
new
StringBuffer
();
html
.
append
(
"<div class=\"form-group\">\r\n"
);
html
.
append
(
"<label class=\"col-sm-3 control-label\">"
+
label
+
"</label>\r\n"
);
html
.
append
(
"<div class=\"col-sm-9\">\r\n"
);
//单选按钮
if
(
"radio"
.
equals
(
type
))
{
list
.
forEach
(
obj
->
{
html
.
append
(
"<label class=\"radio-inline i-checks\">\r\n<input type=\"radio\" "
);
//判断控件是否禁用
if
(
"true"
.
equals
(
disabled
)
||
"disabled"
.
equals
(
disabled
))
{
html
.
append
(
"disabled "
);
}
else
{
if
(
ToolUtil
.
isNotEmpty
(
name
))
{
html
.
append
(
"name=\""
+
name
+
"\" "
);
}
}
if
(
"true"
.
equals
(
readonly
)
||
"disabled"
.
equals
(
readonly
))
{
html
.
append
(
"disabled "
);
}
if
(
ToolUtil
.
isNotEmpty
(
value
)
&&
value
.
equals
(
obj
.
getCode
()))
{
html
.
append
(
"checked "
);
}
html
.
append
(
"value=\""
+
obj
.
getCode
()
+
"\" >"
+
obj
.
getName
()
+
"</label>\r\n"
);
});
//多选按钮
}
else
if
(
"checkbox"
.
equals
(
type
))
{
list
.
forEach
(
obj
->
{
html
.
append
(
"<label class=\"checkbox-inline i-checks\">\r\n<input type=\"checkbox\" "
);
//判断控件是否禁用
if
(
"true"
.
equals
(
disabled
)
||
"disabled"
.
equals
(
disabled
))
{
html
.
append
(
"disabled "
);
}
else
{
if
(
ToolUtil
.
isNotEmpty
(
name
))
{
html
.
append
(
"name=\""
+
name
+
"\" "
);
}
}
if
(
"true"
.
equals
(
readonly
)
||
"disabled"
.
equals
(
readonly
))
{
html
.
append
(
"disabled "
);
}
if
(
ToolUtil
.
isNotEmpty
(
value
)
&&
value
.
equals
(
obj
.
getCode
()))
{
html
.
append
(
"checked "
);
}
html
.
append
(
"value=\""
+
obj
.
getCode
()
+
"\" >"
+
obj
.
getName
()
+
"</label>\r\n"
);
});
//默认select
}
else
{
//开启多选
if
(
"true"
.
equals
(
multiple
))
{
if
(
list
.
size
()
>=
searchnum
)
{
html
.
append
(
"<select multiple "
);
}
else
{
html
.
append
(
"<select multiple=\"multiple\" size=\"10\" "
);
}
}
else
{
html
.
append
(
"<select "
);
}
//判断控件是否启用提示
if
(
ToolUtil
.
isNotEmpty
(
placeholder
))
{
html
.
append
(
" data-placeholder=\""
+
placeholder
+
"\" "
);
}
//判断控件是否禁用
if
(
"true"
.
equals
(
disabled
)
||
"disabled"
.
equals
(
disabled
))
{
html
.
append
(
"disabled=\"disabled\" "
);
}
else
{
//启用
if
(
ToolUtil
.
isNotEmpty
(
id
))
{
html
.
append
(
"id=\""
+
id
+
"\" "
);
}
if
(
ToolUtil
.
isNotEmpty
(
name
))
{
html
.
append
(
"name=\""
+
name
+
"\" "
);
}
}
//判断是否启用搜索框
//判断下拉数据,如果查询出来的条数达到启用搜索的数量就启用
if
(
list
.
size
()
>=
searchnum
)
{
html
.
append
(
"class=\"form-control chosen-select\" style=\"width:"
+
width
+
"px\" tabindex=\"1\" \r\n"
);
}
else
{
html
.
append
(
"class=\"form-control\" style=\"width:"
+
width
+
"px\" \r\n"
);
}
//判断控件是否只读
if
(
"true"
.
equals
(
readonly
)
||
"readonly"
.
equals
(
readonly
))
{
if
(
list
.
size
()
>=
searchnum
)
{
html
.
append
(
"disabled=\"disabled\" "
);
}
else
{
html
.
append
(
"onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\" "
);
}
}
//判断是否绑定onchange事件
if
(
ToolUtil
.
isNotEmpty
(
onchange
))
{
html
.
append
(
"onchange=\""
+
onchange
+
"($(this).children('option:selected').val())\" "
);
}
html
.
append
(
">"
);
if
(
ToolUtil
.
isNotEmpty
(
placeholder
))
{
html
.
append
(
"<option value=\"\">"
+
placeholder
+
"</option>\r\n"
);
}
//将查询出来的数据添加到select中
list
.
forEach
(
obj
->
{
if
(
ToolUtil
.
isNotEmpty
(
value
)
&&
value
.
equals
(
obj
.
getCode
()))
{
html
.
append
(
"<option selected value=\""
+
obj
.
getCode
()
+
"\">"
+
obj
.
getName
()
+
"</option>\r\n"
);
}
else
{
html
.
append
(
"<option value=\""
+
obj
.
getCode
()
+
"\">"
+
obj
.
getName
()
+
"</option>\r\n"
);
}
});
html
.
append
(
"</select>\r\n"
);
}
html
.
append
(
"</div>\r\n</div>\r\n"
);
//判断是否添加分割线
if
(
ToolUtil
.
isNotEmpty
(
underline
)
&&
"true"
.
equals
(
underline
))
{
html
.
append
(
"<div class=\"hr-line-dashed\" ></div >\r\n"
);
}
try
{
this
.
ctx
.
byteWriter
.
writeString
(
html
.
toString
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"输出字典标签错误"
);
}
}
}
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
View file @
ddd35cac
...
...
@@ -23,6 +23,7 @@ import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.log.LogObjectHolder
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.guns.modular.system.service.DictService
;
import
cn.stylefeng.guns.modular.system.warpper.DictWarpper
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
...
...
@@ -64,11 +65,21 @@ public class DictController extends BaseController {
}
/**
* 跳转到添加字典
* 跳转到添加字典
类型
*/
@RequestMapping
(
"/dict_add"
)
public
String
deptAdd
()
{
return
PREFIX
+
"dict_add.html"
;
@RequestMapping
(
"/dict_add_type"
)
public
String
deptAddType
()
{
return
PREFIX
+
"dict_add_type.html"
;
}
/**
* 跳转到添加字典条目
*/
@RequestMapping
(
"/dict_add_item"
)
public
String
deptAddItem
(
@RequestParam
(
"dictId"
)
Long
dictId
,
Model
model
)
{
model
.
addAttribute
(
"dictTypeId"
,
dictId
);
model
.
addAttribute
(
"dictTypeName"
,
ConstantFactory
.
me
().
getDictName
(
dictId
));
return
PREFIX
+
"dict_add_item.html"
;
}
/**
...
...
@@ -76,7 +87,7 @@ public class DictController extends BaseController {
*/
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/dict_edit/{dictId}"
)
public
String
deptUpdate
(
@PathVariable
Integer
dictId
,
Model
model
)
{
public
String
deptUpdate
(
@PathVariable
Long
dictId
,
Model
model
)
{
Dict
dict
=
dictService
.
selectById
(
dictId
);
model
.
addAttribute
(
"dict"
,
dict
);
List
<
Dict
>
subDicts
=
dictService
.
selectList
(
new
EntityWrapper
<
Dict
>().
eq
(
"PID"
,
dictId
));
...
...
@@ -87,18 +98,21 @@ public class DictController extends BaseController {
/**
* 新增字典
*
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结"
*/
@BussinessLog
(
value
=
"添加字典记录"
,
key
=
"dictName,dictValues"
,
dict
=
DictMap
.
class
)
@RequestMapping
(
value
=
"/add"
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
public
Object
add
(
String
dictCode
,
String
dictTips
,
String
dictName
,
String
dictValues
)
{
if
(
ToolUtil
.
isOneEmpty
(
dict
Code
,
dictName
,
dictValues
))
{
public
Object
add
(
DictDto
dictDto
)
{
if
(
ToolUtil
.
isOneEmpty
(
dict
Dto
,
dictDto
.
getCode
(),
dictDto
.
getName
()
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
this
.
dictService
.
addDict
(
dictCode
,
dictName
,
dictTips
,
dictValues
);
if
(
ToolUtil
.
isEmpty
(
dictDto
.
getDictTypeId
()))
{
this
.
dictService
.
addDictType
(
dictDto
);
}
else
{
//TODO
}
return
SUCCESS_TIP
;
}
...
...
src/main/java/cn/stylefeng/guns/modular/system/model/DictDto.java
0 → 100644
View file @
ddd35cac
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
model
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 字典信息
*
* @author fengshuonan
* @Date 2018/12/8 18:16
*/
@Data
public
class
DictDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 类型id
*/
private
Long
dictTypeId
;
/**
* 名称
*/
private
String
name
;
/**
* 编码
*/
private
String
code
;
/**
* 备注
*/
private
String
description
;
/**
* 序号
*/
private
Integer
sort
;
}
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
View file @
ddd35cac
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.mapper.DictMapper
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
...
...
@@ -31,6 +33,19 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
private
DictMapper
dictMapper
;
/**
* 添加字典类型
*/
public
void
addDictType
(
DictDto
dictDto
)
{
Dict
dict
=
new
Dict
();
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
//类型的父级id都为0
dict
.
setPid
(
0L
);
this
.
insert
(
dict
);
}
/**
* 添加字典
*/
@Transactional
...
...
src/main/webapp/WEB-INF/system/dict/dict.html
View file @
ddd35cac
@layout("/common/_container.html"){
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
字典管理
</h5>
</div>
<div
class=
"ibox-content"
>
<div
class=
"row row-lg"
>
<div
class=
"col-sm-12"
>
@layout("/common/_container.html",{plugins:["table","layer","sweet-alert"],js:["/assets/modular/system/dict/dict.js"]}){
<div
class=
"row"
id=
"dictPage"
>
<div
class=
"col-lg-12"
>
<div
class=
"card card-outline-theme m-b-10"
>
<div
class=
"card-body"
>
<div
class=
"form-horizontal"
>
<div
class=
"form-body"
>
<div
class=
"row"
>
<div
class=
"col-sm-3"
>
<
#
NameCon
id=
"condition"
name=
"名称"
/>
<div
class=
"col-md-3"
>
<div
class=
"input-group"
>
<div
class=
"input-group-prepend"
>
<div
class=
"input-group-text"
>
字典名称
</div>
</div>
<input
v-model=
"condition"
type=
"text"
class=
"form-control"
placeholder=
"字典名称"
autocomplete=
"off"
>
</div>
</div>
<div
class=
"col-md-3"
>
<div
class=
"input-group condition-button"
>
<div
class=
"input-group-btn condition-button"
>
<button
type=
"button"
id=
"check-minutes"
class=
"btn btn-info waves-effect waves-light condition-button-width"
onclick=
"Dict.search()"
>
查询
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-sm-3"
>
<
#
button
name=
"搜索"
icon=
"fa-search"
clickFun=
"Dict.search()"
/>
</div>
</div>
<div
class=
"hidden-xs"
id=
"DictTableToolbar"
role=
"group"
>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"card card-outline-theme m-b-0"
>
<div
class=
"card-body p-t-0 p-b-0"
>
<div
class=
"form-horizontal"
>
<div
class=
"form-actions"
>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"card m-b-0 p-b-0"
>
<div
class=
"hidden-xs"
id=
"dictTableToolbar"
role=
"group"
>
@if(shiro.hasPermission("/dict/add")){
<
#
button
name=
"添加"
icon=
"fa-plus"
clickFun=
"Dict.openAddDict()"
/>
<button
type=
"button"
class=
"btn btn-primary waves-effect"
onclick=
"Dict.openAddType()"
>
<i
class=
"fa fa-plus"
></i>
添加类型
</button>
@}
@if(shiro.hasPermission("/dict/add")){
<button
type=
"button"
class=
"btn btn-primary waves-effect m-l-5"
onclick=
"Dict.openAddItem()"
>
<i
class=
"fa fa-plus"
></i>
添加子条目
</button>
@}
@if(shiro.hasPermission("/dict/update")){
<
#
button
name=
"修改"
icon=
"fa-plus"
clickFun=
"Dict.openDictDetail()"
space=
"true"
/>
<button
type=
"button"
class=
"btn btn-primary waves-effect m-l-5"
onclick=
"Dict.openDictDetail()"
>
<i
class=
"fa fa-edit"
></i>
修改
</button>
@}
@if(shiro.hasPermission("/dict/delete")){
<
#
button
name=
"删除"
icon=
"fa-plus"
clickFun=
"Dict.delete()"
space=
"true"
/>
<button
type=
"button"
class=
"btn btn-primary waves-effect m-l-5"
onclick=
"Dict.delete()"
>
<i
class=
"fa fa-remove"
></i>
删除
</button>
@}
</div>
<
#
table
id=
"DictTable"
/>
<
#
table
id=
"dictTable"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script
src=
"${ctxPath}/static/modular/system/dict/dict.js"
></script>
@}
src/main/webapp/WEB-INF/system/dict/dict_add.html
deleted
100644 → 0
View file @
3496f212
@layout("/common/_container.html"){
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-content"
>
<div
class=
"form-horizontal"
>
<input
type=
"hidden"
id=
"id"
value=
""
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
id=
"itemsArea"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
类型编码
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
id=
"dictCode"
type=
"text"
>
</div>
<label
class=
"col-sm-2 control-label"
>
类型名称
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
id=
"dictName"
type=
"text"
>
</div>
<div
class=
"col-sm-2"
>
<
#
button
btnCss=
"info"
name=
"增加"
icon=
"fa-plus"
clickFun=
"DictInfoDlg.addItem()"
/>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
备注
</label>
<div
class=
"col-sm-8"
>
<input
class=
"form-control"
id=
"dictTips"
type=
"text"
>
</div>
</div>
<div
class=
"hr-line-dashed"
></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=
"DictInfoDlg.addSubmit()"
/>
<
#
button
btnCss=
"danger"
name=
"取消"
id=
"cancel"
icon=
"fa-eraser"
clickFun=
"DictInfoDlg.close()"
/>
</div>
</div>
</div>
</div>
<script
type=
"text/template"
id=
"itemTemplate"
>
<
div
class
=
"form-group"
name
=
"dictItem"
id
=
"dictItem"
>
<
label
class
=
"col-sm-1 control-label"
>
值
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemCode"
>
<
/div
>
<
label
class
=
"col-sm-1 control-label"
>
名称
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemName"
>
<
/div
>
<
label
class
=
"col-sm-1 control-label"
>
序号
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemNum"
>
<
/div
>
<
div
class
=
"col-sm-2"
>
<
#
button
btnCss
=
"danger"
name
=
"删除"
id
=
"cancel"
icon
=
"fa-remove"
clickFun
=
"DictInfoDlg.deleteItem(event)"
/>
<
/div
>
<
/div
>
</script>
<script
src=
"${ctxPath}/static/modular/system/dict/dict_info.js"
></script>
@}
\ No newline at end of file
src/main/webapp/WEB-INF/system/dict/dict_add_item.html
0 → 100644
View file @
ddd35cac
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/dict/dict_add_item.js"]}){
<div
class=
"container-fluid"
>
<form
id=
"dictForm"
\@
submit=
"submitForm"
>
<input
value=
"${dictTypeId}"
type=
"hidden"
class=
"form-control"
>
<div
class=
"row"
>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
父级字典
</h5>
<div
class=
"controls"
>
<input
value=
"${dictTypeName}"
disabled=
"disabled"
type=
"text"
class=
"form-control"
>
</div>
</div>
<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>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
描述
</h5>
<div
class=
"controls"
>
<input
v-model=
"description"
type=
"text"
class=
"form-control"
>
</div>
</div>
<div
class=
"form-group"
>
<h5>
排序
</h5>
<div
class=
"controls"
>
<input
v-model=
"sort"
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>
@}
src/main/webapp/WEB-INF/system/dict/dict_add_type.html
0 → 100644
View file @
ddd35cac
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/dict/dict_add_type.js"]}){
<div
class=
"container-fluid"
>
<form
id=
"dictForm"
\@
submit=
"submitForm"
>
<div
class=
"row"
>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
父级字典
</h5>
<div
class=
"controls"
>
<input
value=
"顶级"
disabled=
"disabled"
type=
"text"
class=
"form-control"
>
</div>
</div>
<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>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
描述
</h5>
<div
class=
"controls"
>
<input
v-model=
"description"
type=
"text"
class=
"form-control"
>
</div>
</div>
<div
class=
"form-group"
>
<h5>
排序
</h5>
<div
class=
"controls"
>
<input
v-model=
"sort"
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>
@}
src/main/webapp/WEB-INF/system/dict/dict_edit.html
View file @
ddd35cac
@layout("/common/_container.html"){
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-content"
>
<div
class=
"form-horizontal"
>
<input
type=
"hidden"
id=
"id"
value=
""
>
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/role/role_edit.js"]}){
<div
class=
"container-fluid"
>
<form
id=
"roleForm"
\@
submit=
"submitForm"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
id=
"itemsArea"
>
<input
type=
"hidden"
id=
"itemSize"
value=
"${subDicts.~size!0}"
/>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
类型编码
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
id=
"dictCode"
type=
"text"
value=
"${dict.code}"
>
</div>
<label
class=
"col-sm-2 control-label"
>
类型名称
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
id=
"dictName"
type=
"text"
value=
"${dict.name}"
>
<input
type=
"hidden"
id=
"dictId"
value=
"${dict.id}"
>
</div>
<div
class=
"col-sm-2"
>
<
#
button
btnCss=
"info"
name=
"增加"
icon=
"fa-plus"
clickFun=
"DictInfoDlg.addItem()"
/>
<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"
>
<label
class=
"col-sm-2 control-label"
>
备注
</label>
<div
class=
"col-sm-8"
>
<input
class=
"form-control"
id=
"dictTips"
type=
"text"
value=
"${dict.description}"
>
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
@for(item in subDicts){
<div
class=
"form-group"
name=
"dictItem"
id=
"dictItem${itemLP.index}"
>
<label
class=
"col-sm-1 control-label"
>
值
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
type=
"text"
name=
"itemCode"
value=
"${item.code}"
>
</div>
<label
class=
"col-sm-1 control-label"
>
名称
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
type=
"text"
name=
"itemName"
value=
"${item.name}"
>
<h5>
上级名称
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"pName"
id=
"pName"
\@
click=
"showParentSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"pid"
type=
"hidden"
class=
"form-control"
>
</div>
<label
class=
"col-sm-1 control-label"
>
序号
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
type=
"text"
name=
"itemNum"
value=
"${item.num}"
>
</div>
<div
class=
"col-sm-2"
>
<
#
button
btnCss=
"danger"
name=
"删除"
id=
"cancel"
icon=
"fa-remove"
clickFun=
"DictInfoDlg.deleteItem(event)"
/>
</div>
</div>
@}
</input>
<div
class=
"form-group"
>
<h5>
别名
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"description"
type=
"text"
class=
"form-control"
>
</div>
<div
class=
"row btn-group-m-t"
>
<div
class=
"col-sm-10"
>
<
#
button
btnCss=
"info"
name=
"提交"
id=
"ensure"
icon=
"fa-check"
clickFun=
"DictInfoDlg.editSubmit()"
/>
<
#
button
btnCss=
"danger"
name=
"取消"
id=
"cancel"
icon=
"fa-eraser"
clickFun=
"DictInfoDlg.close()"
/>
</div>
</div>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
排序
</h5>
<div
class=
"controls"
>
<input
v-model=
"sort"
type=
"text"
class=
"form-control"
>
</div>
</div>
<script
type=
"text/template"
id=
"itemTemplate"
>
<
div
class
=
"form-group"
name
=
"dictItem"
id
=
"dictItem"
>
<
label
class
=
"col-sm-1 control-label"
>
值
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemCode"
>
</div>
<
label
class
=
"col-sm-1 control-label"
>
名称
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemName"
>
</div>
<
label
class
=
"col-sm-1 control-label"
>
序号
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemNum"
>
<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
class
=
"col-sm-2"
>
<
#
button
btnCss
=
"danger"
name
=
"删除"
id
=
"cancel"
icon
=
"fa-remove"
clickFun
=
"DictInfoDlg.deleteItem(event)"
/>
</div>
</div>
</script>
<script
src=
"${ctxPath}/static/modular/system/dict/dict_info.js"
></script>
@}
\ No newline at end of file
</form>
</div>
@}
src/main/webapp/assets/modular/system/dict/dict.js
View file @
ddd35cac
...
...
@@ -2,10 +2,13 @@
* 字典管理初始化
*/
var
Dict
=
{
id
:
"
D
ictTable"
,
//表格id
id
:
"
d
ictTable"
,
//表格id
seItem
:
null
,
//选中的条目
table
:
null
,
layerIndex
:
-
1
layerIndex
:
-
1
,
condition
:
{
condition
:
""
}
};
/**
...
...
@@ -14,8 +17,9 @@ var Dict = {
Dict
.
initColumn
=
function
()
{
return
[
{
field
:
'selectItem'
,
radio
:
true
},
{
title
:
'id'
,
field
:
'
i
d'
,
visible
:
false
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'id'
,
field
:
'
dictI
d'
,
visible
:
false
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'名称'
,
field
:
'name'
,
align
:
'center'
,
valign
:
'middle'
,
sortable
:
true
},
{
title
:
'字典编码'
,
field
:
'code'
,
align
:
'center'
,
valign
:
'middle'
,
sortable
:
true
},
{
title
:
'详情'
,
field
:
'detail'
,
align
:
'center'
,
valign
:
'middle'
,
sortable
:
true
},
{
title
:
'备注'
,
field
:
'description'
,
align
:
'center'
,
valign
:
'middle'
,
sortable
:
true
}];
};
...
...
@@ -25,7 +29,7 @@ Dict.initColumn = function () {
*/
Dict
.
check
=
function
()
{
var
selected
=
$
(
'#'
+
this
.
id
).
bootstrapTable
(
'getSelections'
);
if
(
selected
.
length
==
0
)
{
if
(
selected
.
length
==
=
0
)
{
Feng
.
info
(
"请先选中表格中的某一记录!"
);
return
false
;
}
else
{
...
...
@@ -35,18 +39,33 @@ Dict.check = function () {
};
/**
* 点击添加字典
* 点击添加字典类型
*/
Dict
.
openAddType
=
function
()
{
this
.
layerIndex
=
layer
.
open
({
type
:
2
,
title
:
'添加字典类型'
,
area
:
[
'800px'
,
'420px'
],
//宽高
fix
:
false
,
//不固定
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/dict/dict_add_type'
});
};
/**
* 点击添加字典子条目
*/
Dict
.
openAddDict
=
function
()
{
var
index
=
layer
.
open
({
Dict
.
openAddItem
=
function
()
{
if
(
this
.
check
())
{
this
.
layerIndex
=
layer
.
open
({
type
:
2
,
title
:
'添加字典
'
,
title
:
'添加字典条目
'
,
area
:
[
'800px'
,
'420px'
],
//宽高
fix
:
false
,
//不固定
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/dict/dict_add'
content
:
Feng
.
ctxPath
+
'/dict/dict_add_item?dictId='
+
Dict
.
seItem
.
dictId
});
this
.
layerIndex
=
index
;
}
};
/**
...
...
@@ -54,15 +73,14 @@ Dict.openAddDict = function () {
*/
Dict
.
openDictDetail
=
function
()
{
if
(
this
.
check
())
{
var
i
ndex
=
layer
.
open
({
this
.
layerI
ndex
=
layer
.
open
({
type
:
2
,
title
:
'字典详情'
,
area
:
[
'800px'
,
'420px'
],
//宽高
fix
:
false
,
//不固定
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/dict/dict_edit/'
+
Dict
.
seItem
.
i
d
content
:
Feng
.
ctxPath
+
'/dict/dict_edit/'
+
Dict
.
seItem
.
dictI
d
});
this
.
layerIndex
=
index
;
}
};
...
...
@@ -72,14 +90,14 @@ Dict.openDictDetail = function () {
Dict
.
delete
=
function
()
{
if
(
this
.
check
())
{
var
operation
=
function
()
{
var
operation
=
function
()
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/delete"
,
function
(
data
)
{
Feng
.
success
(
"删除成功!"
);
Dict
.
table
.
refresh
();
},
function
(
data
)
{
Feng
.
error
(
"删除失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
"dictId"
,
Dict
.
seItem
.
i
d
);
ajax
.
set
(
"dictId"
,
Dict
.
seItem
.
dictI
d
);
ajax
.
start
();
};
...
...
src/main/webapp/assets/modular/system/dict/dict_add_item.js
0 → 100644
View file @
ddd35cac
/**
* 初始化字典详情对话框
*/
var
DictInfoDlg
=
{
count
:
$
(
"#itemSize"
).
val
(),
dictName
:
''
,
//字典的名称
dictCode
:
''
,
//字典类型编码
dictTips
:
''
,
//字典备注
mutiString
:
''
,
//拼接字符串内容(拼接字典条目)
itemTemplate
:
$
(
"#itemTemplate"
).
html
()
};
/**
* item获取新的id
*/
DictInfoDlg
.
newId
=
function
()
{
if
(
this
.
count
==
undefined
){
this
.
count
=
0
;
}
this
.
count
=
this
.
count
+
1
;
return
"dictItem"
+
this
.
count
;
};
/**
* 关闭此对话框
*/
DictInfoDlg
.
close
=
function
()
{
parent
.
layer
.
close
(
window
.
parent
.
Dict
.
layerIndex
);
};
/**
* 添加条目
*/
DictInfoDlg
.
addItem
=
function
()
{
$
(
"#itemsArea"
).
append
(
this
.
itemTemplate
);
$
(
"#dictItem"
).
attr
(
"id"
,
this
.
newId
());
};
/**
* 删除item
*/
DictInfoDlg
.
deleteItem
=
function
(
event
)
{
var
obj
=
Feng
.
eventParseObject
(
event
);
obj
=
obj
.
is
(
'button'
)
?
obj
:
obj
.
parent
();
obj
.
parent
().
parent
().
remove
();
};
/**
* 清除为空的item Dom
*/
DictInfoDlg
.
clearNullDom
=
function
(){
$
(
"[name='dictItem']"
).
each
(
function
(){
var
num
=
$
(
this
).
find
(
"[name='itemNum']"
).
val
();
var
name
=
$
(
this
).
find
(
"[name='itemName']"
).
val
();
if
(
num
==
''
||
name
==
''
){
$
(
this
).
remove
();
}
});
};
/**
* 收集添加字典的数据
*/
DictInfoDlg
.
collectData
=
function
()
{
this
.
clearNullDom
();
var
mutiString
=
""
;
$
(
"[name='dictItem']"
).
each
(
function
(){
var
code
=
$
(
this
).
find
(
"[name='itemCode']"
).
val
();
var
name
=
$
(
this
).
find
(
"[name='itemName']"
).
val
();
var
num
=
$
(
this
).
find
(
"[name='itemNum']"
).
val
();
mutiString
=
mutiString
+
(
code
+
":"
+
name
+
":"
+
num
+
";"
);
});
this
.
dictName
=
$
(
"#dictName"
).
val
();
this
.
dictCode
=
$
(
"#dictCode"
).
val
();
this
.
dictTips
=
$
(
"#dictTips"
).
val
();
this
.
mutiString
=
mutiString
;
};
/**
* 提交添加字典
*/
DictInfoDlg
.
addSubmit
=
function
()
{
this
.
collectData
();
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/add"
,
function
(
data
)
{
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
'dictName'
,
this
.
dictName
);
ajax
.
set
(
'dictCode'
,
this
.
dictCode
);
ajax
.
set
(
'dictTips'
,
this
.
dictTips
);
ajax
.
set
(
'dictValues'
,
this
.
mutiString
);
ajax
.
start
();
};
/**
* 提交修改
*/
DictInfoDlg
.
editSubmit
=
function
()
{
this
.
collectData
();
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/update"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
'dictId'
,
$
(
"#dictId"
).
val
());
ajax
.
set
(
'dictName'
,
this
.
dictName
);
ajax
.
set
(
'dictCode'
,
this
.
dictCode
);
ajax
.
set
(
'dictTips'
,
this
.
dictTips
);
ajax
.
set
(
'dictValues'
,
this
.
mutiString
);
ajax
.
start
();
};
src/main/webapp/assets/modular/system/dict/dict_add_type.js
0 → 100644
View file @
ddd35cac
/**
* 角色详情对话框(可用于添加和修改对话框)
*/
var
DictInfoDlg
=
{
data
:
{
name
:
""
,
code
:
""
,
description
:
""
,
sort
:
""
}
};
/**
* 关闭此对话框
*/
DictInfoDlg
.
close
=
function
()
{
parent
.
layer
.
close
(
window
.
parent
.
Dict
.
layerIndex
);
};
/**
* 验证表单
*/
DictInfoDlg
.
validateForm
=
function
()
{
var
data
=
DictInfoDlg
.
data
;
if
(
!
data
.
name
)
{
return
"请输入字典名称"
;
}
if
(
!
(
data
.
code
))
{
return
"请输入字典编码"
;
}
return
true
;
};
/**
* 提交添加角色
*/
DictInfoDlg
.
addSubmit
=
function
()
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/add"
,
function
(
data
)
{
parent
.
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
parent
.
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
this
.
data
);
ajax
.
start
();
};
$
(
function
()
{
DictInfoDlg
.
app
=
new
Vue
({
el
:
'#dictForm'
,
data
:
DictInfoDlg
.
data
,
methods
:
{
submitForm
:
function
(
e
)
{
e
.
preventDefault
();
},
ensure
:
function
()
{
var
result
=
DictInfoDlg
.
validateForm
();
if
(
result
===
true
)
{
DictInfoDlg
.
addSubmit
();
}
else
{
Feng
.
alert
(
result
);
}
},
close
:
function
()
{
DictInfoDlg
.
close
();
}
}
});
});
src/main/webapp/assets/modular/system/dict/dict_
info
.js
→
src/main/webapp/assets/modular/system/dict/dict_
edit
.js
View file @
ddd35cac
File moved
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