function addView() {
layer.open({
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['450px', '250px'], //宽高
maxmin: true, //允许全屏最小化
title: '添加网址',
content: '<form id="userForm" method="post" style="padding-top:10px;padding-left:20px;">' +
'<div class="kv-item clearfix"><div style="padding:30px;" class="kv-item-content">' +
'<p class="textp">网址名称:<input class="easyui-validatebox" type="text" style="ime-mode:disabled" id="addwebsitename"></p>' +
'<p class="textp">网址地址:<input class="easyui-validatebox" type="text" style="ime-mode:disabled" id="addwebsiteurl"></p>' +
'<p class="textp"><input style="margin-left:45%;margin-top:15px;" type="button" onclick="addData()" class="sapar-btn sapar-btn-recom query-btn" value="提交"></p>' +
'</div></div>' +
'</form>'
});
}
//添加数据
function addData() {
var index = layer.load(1, {shade: false});//遮罩layer
$.ajax({
type: "post",
url: '/website/add',
data: {
websitename: $("#addwebsitename").val(),
websiteurl: $("#addwebsiteurl").val()
},
async: false, //true异步运行false 同步
success: function (res) {
var obj = JSON.parse(res);
if (obj.errorCode === "0000") {
layer.close(index);
layer.msg("添加成功", {icon: 1});
setTimeout(function () {
layer.closeAll();
queryClick();
}, 1500);
} else {
layer.msg(obj.errorMsg, {icon: 2})
}
},
error: function (res) {
var obj = JSON.parse(res);
if (obj != null) {
if (obj.errorMsg != null) {
layer.msg(obj.errorMsg, {icon: 2})
} else {
layer.msg("系统异常", {icon: 2})
}
} else {
layer.msg("系统异常", {icon: 2})
}
}
})
}