----------
后台添加代码模块:
@At
@Ok("json")
@SLog(tag="新建网关",msg = "网关名称:${args[0].gatewayName}")
@RequiresPermissions("instrument.monitor.gateway.add")
public Object addDo(@Param("..")Ins_Gateway ins_Gateway,HttpServletRequest request) {
try {
gatewayService.insert(ins_Gateway);
return Result.success("system.success");
} catch (Exception e) {
return Result.error("system.error");
}
}
前台代码模块:(html:)
<div class="modal-footer" >
<button type="button" id="goback" style="width:120px"class="btn btn-default pull-left" data-dismiss="modal"><a id="goback" href="${base}/instrument/monitor/gateway">关闭</a></button>
<button class="btn btn-primary" data-loading-text="正在提交..." style="width:120px">确定</button>
</div>
(js模块:)
$(document).ready(function () {
myForm.init();
$("#add-gateway-time").datepicker({
language: "zh-CN",
todayHighlight: true,
weekStart: 1,
autoclose: true,//选中之后自动隐藏日期选择框
clearBtn: true,//清除按钮
todayBtn: "linked",//今日按钮
format: "yyyy/mm/dd"//日期格式,详见 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
});
$('#addForm').ajaxForm({
dataType: 'json',
beforeSubmit: function (arr, form, options) {
if($("#url").val()==""){
Toast.error("原始URL不能为空");
return false;
}
if($("#toUrl").val()==""){
Toast.error("转发URL不能为空");
return false;
}
if($("#type").val()=="hide"&&$("#toUrl").val().indexOf("http")>-1){
Toast.error("隐性URL不可为外链");
return false;
}
form.find("button:submit").button("loading");
},
success: function (data, statusText, xhr, form) {
alert(data.code);
if (data.code == 0) {
Toast.success(data.msg);
//刷新父级菜单
//form.resetForm();
setTimeout(function () {
$("#goback").trigger("click");
}, 1000);
} else {
Toast.error(data.msg);
}
form.find("button:submit").button("reset");
}
error:function (data, statusText, xhr, form){
alert(data.code);
}
});
});
跳转的页面:{
code:0,
msg:"操作成功"
}