Controller层
//添加
@RequestMapping("adds")
@ResponseBody
public void addType(String tName,String tCrtate,String tJiao){
AuditType a=new AuditType();
a.settName(tName);
a.settCrtate(tCrtate);
a.settJiao(tJiao);
auditTypeService.addty(a);
}
//添加
@Transactional
public void addty(AuditType auditType){
auditTypeRep.save(auditType);
}
页面HTML
<script>
function add() {
$("#adddlg").dialog("open");
}
//添加
function adds(){
var d=$("#dg1").datagrid('getSelected');
var tName=$("#tName");
var tCrtate=$("#tCrtate");
var tJiao=$("#tJiao");
$.ajax({
url:"adds?tName="+tName+"&&tCrtate="+tCrtate+"&&tJiao="+tJiao,
dataType:"json",
type:"post",
success:function(data){
if(data>0) {
$.messager.alert("系统提示",'新增成功');
/*$("#dg1").datagrid("reload");
$("#adddlg").dialog("close");*/
}else{
$.messager.alert("系统提示",'新增失败');
}
},
/* error:function (data) {
$.messager.alert("系统提示",'错误');
}*/
})
}
</script>
<div id="tool">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="add()" style="width: 100px;">增加</a>
</div>
<table class="easyui-datagrid" id="dg1" toolbar="#tool" data-options=" url:'selectAllAuditType',fitColumns:true,pagination:true" style="width: 100%;">
<thead>
<tr>
<th data-options="field:'tName',width:402">名称</th>
<th data-options="field:'tCrtate',width:401">类型</th>
<th data-options="field:'tJiao',width:401">角色</th>
</tr>
</thead>
</table>
<div id="adddlg" class="easyui-dialog" data-options="iconCls:'icon-save',closed:true,buttons:'#fm'"
style="width:400px;height:200px;">
<form id="add_form" method="post">
<table>
<tr>
<td>名称:</td>
<td><input type="text" name="tName" id="tName"/></td>
</tr>
<tr>
<td>类型:</td>
<td><input type="text" name="tCrtate" id="tCrtate"/></td>
</tr>
<tr>
<td>角色:</td>
<td><input type="text" name="tJiao" id="tJiao"/></td>
</tr>
</table>
</form>
</div>
<div id="fm">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="adds()">保存</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">关闭</a>
</div>