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
355f5909
Commit
355f5909
authored
Apr 28, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改字典业务和修改字典页面的完善
parent
f50766c0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
47 deletions
+72
-47
src/main/java/com/stylefeng/guns/modular/system/controller/DictController.java
+7
-5
src/main/java/com/stylefeng/guns/modular/system/service/IDictService.java
+2
-2
src/main/java/com/stylefeng/guns/modular/system/service/impl/DictServiceImpl.java
+6
-11
src/main/webapp/WEB-INF/view/system/dict/dict_edit.html
+47
-24
src/main/webapp/static/modular/system/dict/dict.js
+1
-1
src/main/webapp/static/modular/system/dict/dict_info.js
+8
-3
src/test/java/com/stylefeng/guns/system/DictTest.java
+1
-1
No files found.
src/main/java/com/stylefeng/guns/modular/system/controller/DictController.java
View file @
355f5909
...
...
@@ -5,6 +5,7 @@ import com.stylefeng.guns.common.annotion.log.BussinessLog;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
com.stylefeng.guns.core.log.LogObjectHolder
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.modular.system.dao.DictDao
;
import
com.stylefeng.guns.modular.system.service.IDictService
;
...
...
@@ -64,9 +65,10 @@ public class DictController extends BaseController {
@RequestMapping
(
"/dict_edit/{dictId}"
)
public
String
deptUpdate
(
@PathVariable
Integer
dictId
,
Model
model
)
{
Dict
dict
=
dictMapper
.
selectById
(
dictId
);
model
.
addAttribute
(
dict
);
model
.
addAttribute
(
"dict"
,
dict
);
List
<
Dict
>
subDicts
=
dictMapper
.
selectList
(
new
EntityWrapper
<
Dict
>().
eq
(
"pid"
,
dictId
));
model
.
addAttribute
(
subDicts
);
model
.
addAttribute
(
"subDicts"
,
subDicts
);
LogObjectHolder
.
me
().
set
(
dict
);
return
PREFIX
+
"dict_edit.html"
;
}
...
...
@@ -111,11 +113,11 @@ public class DictController extends BaseController {
@BussinessLog
(
"修改字典"
)
@RequestMapping
(
value
=
"/update"
)
@ResponseBody
public
Object
update
(
String
mutiString
)
{
if
(
ToolUtil
.
is
Empty
(
mutiString
))
{
public
Object
update
(
Integer
dictId
,
String
dictName
,
String
dictValues
)
{
if
(
ToolUtil
.
is
OneEmpty
(
dictId
,
dictName
,
dictValues
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
dictService
.
editDict
(
mutiString
);
dictService
.
editDict
(
dictId
,
dictName
,
dictValues
);
return
super
.
SUCCESS_TIP
;
}
...
...
src/main/java/com/stylefeng/guns/modular/system/service/IDictService.java
View file @
355f5909
...
...
@@ -14,7 +14,7 @@ public interface IDictService {
* @author fengshuonan
* @Date 2017/4/27 17:01
*/
void
addDict
(
String
dictName
,
String
dictValues
);
void
addDict
(
String
dictName
,
String
dictValues
);
/**
* 编辑字典
...
...
@@ -22,7 +22,7 @@ public interface IDictService {
* @author fengshuonan
* @Date 2017/4/28 11:01
*/
void
editDict
(
String
dicts
);
void
editDict
(
Integer
dictId
,
String
dictName
,
String
dicts
);
/**
* 删除字典
...
...
src/main/java/com/stylefeng/guns/modular/system/service/impl/DictServiceImpl.java
View file @
355f5909
...
...
@@ -29,7 +29,6 @@ public class DictServiceImpl implements IDictService {
@Override
public
void
addDict
(
String
dictName
,
String
dictValues
)
{
//判断有没有该字典
List
<
Dict
>
dicts
=
dictMapper
.
selectList
(
new
EntityWrapper
<
Dict
>().
eq
(
"name"
,
dictName
).
and
().
eq
(
"pid"
,
0
));
if
(
dicts
!=
null
&&
dicts
.
size
()
>
0
){
...
...
@@ -59,20 +58,16 @@ public class DictServiceImpl implements IDictService {
}
@Override
public
void
editDict
(
String
dicts
)
{
List
<
Map
<
String
,
String
>>
items
=
parseIdKeyValue
(
dicts
);
for
(
Map
<
String
,
String
>
item
:
items
)
{
String
dictId
=
item
.
get
(
MUTI_STR_ID
);
Dict
dict
=
dictMapper
.
selectById
(
dictId
);
dict
.
setNum
(
Integer
.
valueOf
(
item
.
get
(
MUTI_STR_KEY
)));
dict
.
setName
(
item
.
get
(
MUTI_STR_VALUE
));
dict
.
updateById
();
}
public
void
editDict
(
Integer
dictId
,
String
dictName
,
String
dicts
)
{
//删除之前的字典
this
.
delteDict
(
dictId
);
//重新添加新的字典
this
.
addDict
(
dictName
,
dicts
);
}
@Override
public
void
delteDict
(
Integer
dictId
)
{
//删除这个字典的子词典
Wrapper
<
Dict
>
dictEntityWrapper
=
new
EntityWrapper
<>();
dictEntityWrapper
=
dictEntityWrapper
.
eq
(
"pid"
,
dictId
);
...
...
src/main/webapp/WEB-INF/view/system/dict/dict_edit.html
View file @
355f5909
...
...
@@ -3,41 +3,63 @@
<div
class=
"ibox-content"
>
<div
class=
"form-horizontal"
>
<input
type=
"hidden"
id=
"id"
value=
"
${dept.id}
"
>
<input
type=
"hidden"
id=
"id"
value=
""
>
<div
class=
"row"
>
<div
class=
"col-sm-6 b-r"
>
<
#
input
id=
"simplename"
name=
"部门名称"
underline=
"true"
value=
"${dept.simplename}"
/>
<
#
input
id=
"fullname"
name=
"部门全称"
underline=
"true"
value=
"${dept.fullname}"
/>
<
#
input
id=
"tips"
name=
"备注"
underline=
"true"
value=
"${dept.tips}"
/>
<div
class=
"col-sm-12"
id=
"itemsArea"
>
<input
type=
"hidden"
id=
"itemSize"
value=
"${subDicts.~size!0}"
/>
<div
class=
"form-group"
>
<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-6"
>
<
#
input
id=
"num"
name=
"排序"
underline=
"true"
value=
"${dept.num}"
/>
<
#
input
id=
"pName"
name=
"上级部门"
readonly=
"readonly"
hidden=
"pid"
hiddenValue=
"${dept.pid}"
value=
"${pName}"
clickFun=
"DeptInfoDlg.showDeptSelectTree(); return false;"
style=
"background-color: #ffffff !important;"
/>
<div
class=
"col-sm-2"
>
<
#
button
btnCss=
"info"
name=
"增加"
icon=
"fa-plus"
clickFun=
"DictInfoDlg.addItem()"
/>
</div>
</div>
<!-- 父级部门的选择框 -->
<div
id=
"parentDeptMenu"
class=
"menuContent"
style=
"display: none; position: absolute; z-index: 200;"
>
<ul
id=
"parentDeptMenuTree"
class=
"ztree tree-box"
style=
"width: 245px !important;"
></ul>
<div
class=
"hr-line-dashed"
></div>
@for(item in subDicts){
<div
class=
"form-group"
name=
"dictItem"
id=
"dictItem${itemLP.index}"
>
<label
class=
"col-sm-2 control-label"
>
值
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
type=
"text"
name=
"itemNum"
value=
"${item.num}"
>
</div>
<label
class=
"col-sm-2 control-label"
style=
"width: 8%;"
>
名称
</label>
<div
class=
"col-sm-2"
>
<input
class=
"form-control"
type=
"text"
name=
"itemName"
value=
"${item.name}"
>
</div>
<div
class=
"col-sm-4"
>
<
#
button
btnCss=
"danger"
name=
"删除"
id=
"cancel"
icon=
"fa-remove"
clickFun=
"DictInfoDlg.deleteItem(event)"
/>
</div>
</div>
@}
</input>
</div>
<div
class=
"row btn-group-m-t"
>
<div
class=
"col-sm-10"
>
<
#
button
btnCss=
"info"
name=
"提交"
id=
"ensure"
icon=
"fa-check"
clickFun=
"DeptInfoDlg.editSubmit()"
/>
<
#
button
btnCss=
"danger"
name=
"取消"
id=
"cancel"
icon=
"fa-eraser"
clickFun=
"DeptInfoDlg.close()"
/>
<
#
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>
</div>
<script
type=
"text/template"
id=
"itemTemplate"
>
<
div
class
=
"form-group"
name
=
"dictItem"
id
=
"dictItem"
>
<
label
class
=
"col-sm-2 control-label"
>
值
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemNum"
>
<
/div
>
<
label
class
=
"col-sm-2 control-label"
style
=
"width: 8%;"
>
名称
<
/label
>
<
div
class
=
"col-sm-2"
>
<
input
class
=
"form-control"
type
=
"text"
name
=
"itemName"
>
<
/div
>
</div>
<script
src=
"${ctxPath}/static/modular/system/dict/dict_info.js"
></script>
<
div
class
=
"col-sm-4"
>
<
#
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/static/modular/system/dict/dict.js
View file @
355f5909
...
...
@@ -14,7 +14,7 @@ var Dict = {
Dict
.
initColumn
=
function
()
{
return
[
{
field
:
'selectItem'
,
radio
:
true
},
{
title
:
'id'
,
field
:
'id'
,
visible
:
tru
e
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'id'
,
field
:
'id'
,
visible
:
fals
e
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'名称'
,
field
:
'name'
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'详情'
,
field
:
'detail'
,
align
:
'center'
,
valign
:
'middle'
},
{
title
:
'备注'
,
field
:
'tips'
,
align
:
'center'
,
valign
:
'middle'
}];
...
...
src/main/webapp/static/modular/system/dict/dict_info.js
View file @
355f5909
...
...
@@ -2,7 +2,7 @@
* 初始化字典详情对话框
*/
var
DictInfoDlg
=
{
count
:
0
,
count
:
$
(
"#itemSize"
).
val
()
,
dictName
:
''
,
//字典的名称
mutiString
:
''
,
//拼接字符串内容(拼接字典条目)
itemTemplate
:
$
(
"#itemTemplate"
).
html
()
...
...
@@ -12,6 +12,9 @@ var DictInfoDlg = {
* item获取新的id
*/
DictInfoDlg
.
newId
=
function
()
{
if
(
this
.
count
==
undefined
){
this
.
count
=
0
;
}
this
.
count
=
this
.
count
+
1
;
return
"dictItem"
+
this
.
count
;
};
...
...
@@ -93,12 +96,14 @@ DictInfoDlg.editSubmit = function () {
this
.
collectData
();
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/update"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
D
ep
t
.
table
.
refresh
();
window
.
parent
.
D
ic
t
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
this
.
dictInfoData
);
ajax
.
set
(
'dictId'
,
$
(
"#dictId"
).
val
());
ajax
.
set
(
'dictName'
,
this
.
dictName
);
ajax
.
set
(
'dictValues'
,
this
.
mutiString
);
ajax
.
start
();
};
...
...
src/test/java/com/stylefeng/guns/system/DictTest.java
View file @
355f5909
...
...
@@ -24,6 +24,6 @@ public class DictTest extends BaseTest{
@Test
public
void
editTest
()
{
dictService
.
editDict
(
"45:0:测试1;46:1:冻结1;47:4:sd1;48:3:接触1;
"
);
dictService
.
editDict
(
1
,
"测试"
,
"
"
);
}
}
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