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
9ac5fda2
Commit
9ac5fda2
authored
Dec 09, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理字典添加条目
parent
ddd35cac
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
90 deletions
+61
-90
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
+1
-1
src/main/java/cn/stylefeng/guns/modular/system/entity/Dict.java
+0
-0
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
+13
-0
src/main/webapp/WEB-INF/system/dict/dict_add_item.html
+5
-5
src/main/webapp/assets/modular/system/dict/dict_add_item.js
+42
-84
No files found.
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
View file @
9ac5fda2
...
...
@@ -110,7 +110,7 @@ public class DictController extends BaseController {
if
(
ToolUtil
.
isEmpty
(
dictDto
.
getDictTypeId
()))
{
this
.
dictService
.
addDictType
(
dictDto
);
}
else
{
//TODO
this
.
dictService
.
addDictItem
(
dictDto
);
}
return
SUCCESS_TIP
;
...
...
src/main/java/cn/stylefeng/guns/modular/system/entity/Dict.java
View file @
9ac5fda2
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
View file @
9ac5fda2
...
...
@@ -46,6 +46,19 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
}
/**
* 添加字典子类型
*/
public
void
addDictItem
(
DictDto
dictDto
)
{
Dict
dict
=
new
Dict
();
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
//字典的父级id为字典tyeId
dict
.
setPid
(
dictDto
.
getDictTypeId
());
this
.
insert
(
dict
);
}
/**
* 添加字典
*/
@Transactional
...
...
src/main/webapp/WEB-INF/system/dict/dict_add_item.html
View file @
9ac5fda2
...
...
@@ -2,7 +2,7 @@
<div
class=
"container-fluid"
>
<form
id=
"dictForm"
\@
submit=
"submitForm"
>
<input
value=
"${dictTypeId}"
type=
"hidden"
class=
"form-control"
>
<input
id=
"dictTypeId"
value=
"${dictTypeId}"
type=
"hidden"
class=
"form-control"
>
<div
class=
"row"
>
<div
class=
"col-6"
>
...
...
@@ -13,15 +13,15 @@
</div>
</div>
<div
class=
"form-group"
>
<h5>
字典
名称
<span
class=
"text-danger"
>
*
</span></h5>
<h5>
字典
编码
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"
nam
e"
type=
"text"
class=
"form-control"
>
<input
v-model=
"
cod
e"
type=
"text"
class=
"form-control"
>
</div>
</div>
<div
class=
"form-group"
>
<h5>
字典编码
<span
class=
"text-danger"
>
*
</span></h5>
<h5>
字典编码
对应的值
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"
cod
e"
type=
"text"
class=
"form-control"
>
<input
v-model=
"
nam
e"
type=
"text"
class=
"form-control"
>
</div>
</div>
</div>
...
...
src/main/webapp/assets/modular/system/dict/dict_add_item.js
View file @
9ac5fda2
/**
*
初始化字典详情对话框
*
角色详情对话框(可用于添加和修改对话框)
*/
var
DictInfoDlg
=
{
count
:
$
(
"#itemSize"
).
val
(),
dictName
:
''
,
//字典的名称
dictCode
:
''
,
//字典类型编码
dictTips
:
''
,
//字典备注
mutiString
:
''
,
//拼接字符串内容(拼接字典条目)
itemTemplate
:
$
(
"#itemTemplate"
).
html
()
};
/**
* item获取新的id
*/
DictInfoDlg
.
newId
=
function
()
{
if
(
this
.
count
==
undefined
){
this
.
count
=
0
;
data
:
{
dictTypeId
:
$
(
"#dictTypeId"
).
val
(),
name
:
""
,
code
:
""
,
description
:
""
,
sort
:
""
}
this
.
count
=
this
.
count
+
1
;
return
"dictItem"
+
this
.
count
;
};
/**
...
...
@@ -29,90 +19,58 @@ DictInfoDlg.close = function () {
};
/**
*
添加条目
*
验证表单
*/
DictInfoDlg
.
addItem
=
function
()
{
$
(
"#itemsArea"
).
append
(
this
.
itemTemplate
);
$
(
"#dictItem"
).
attr
(
"id"
,
this
.
newId
());
};
DictInfoDlg
.
validateForm
=
function
()
{
/**
* 删除item
*/
DictInfoDlg
.
deleteItem
=
function
(
event
)
{
var
obj
=
Feng
.
eventParseObject
(
event
);
obj
=
obj
.
is
(
'button'
)
?
obj
:
obj
.
parent
();
obj
.
parent
().
parent
().
remove
();
};
var
data
=
DictInfoDlg
.
data
;
/**
* 清除为空的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
();
if
(
!
data
.
name
)
{
return
"请输入字典名称"
;
}
if
(
!
(
data
.
code
))
{
return
"请输入字典编码"
;
}
});
};
/**
* 收集添加字典的数据
*/
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
;
return
true
;
};
/**
* 提交添加
字典
* 提交添加
角色
*/
DictInfoDlg
.
addSubmit
=
function
()
{
this
.
collectData
();
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/add"
,
function
(
data
)
{
Feng
.
success
(
"添加成功!"
);
parent
.
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
parent
.
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
.
set
(
this
.
data
);
ajax
.
start
();
};
/**
* 提交修改
*/
DictInfoDlg
.
editSubmit
=
function
()
{
this
.
collectData
();
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/update"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
$
(
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
();
},
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
();
};
});
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