封装open

v1.0
bobi 2019-05-12 19:22:05 +08:00
parent 387950d60f
commit 0517d4c85c
2 changed files with 20 additions and 28 deletions

View File

@ -1,6 +1,7 @@
layui.define(["layer"], function (exports) { layui.define(["layer"], function (exports) {
var $ = layui.jquery; var $ = layui.jquery;
var okLayer = { var okLayer = {
// TODO 统一全站风格
tableNotCheckMsg: function () { tableNotCheckMsg: function () {
layer.msg("未选择有效数据", {offset: "t", anim: 6}); layer.msg("未选择有效数据", {offset: "t", anim: 6});
}, },
@ -25,6 +26,23 @@ layui.define(["layer"], function (exports) {
layer.msg(content, {icon: 1, time: 1000}, function () { layer.msg(content, {icon: 1, time: 1000}, function () {
$(".layui-laypage-btn")[0].click(); $(".layui-laypage-btn")[0].click();
}); });
},
open: function (title, content, width, height) {
layer.open({
title: title,
type: 2,
shade: false,
maxmin: true,
shade: 0.5,
anim: 4,
area: [width, height],
content: content,
zIndex: layer.zIndex,
skin: "layui-layer-molv",
end: function () {
$(".layui-laypage-btn")[0].click();
}
});
} }
} }

View File

@ -106,19 +106,7 @@
var data = obj.data; var data = obj.data;
var layEvent = obj.event; var layEvent = obj.event;
if (layEvent === "edit") { if (layEvent === "edit") {
layer.open({ okLayer.open("编辑用户", "user-edit.html", "90%", "90%")
title: "编辑用户",
type: 2,
shade: false,
maxmin: true,
shade: 0.5,
area: ["90%", "90%"],
content: "user-edit.html",
zIndex: layer.zIndex,
end: function () {
$(".layui-laypage-btn")[0].click();
}
});
} else if (layEvent === "del") { } else if (layEvent === "del") {
okLayer.confirm("确定要删除吗?", function () { okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/user/batchDel", "post", {idsStr: data.id}).done(function (response) { okUtils.ajax("/user/batchDel", "post", {idsStr: data.id}).done(function (response) {
@ -179,21 +167,7 @@
}) })
$("#addUser").click(function () { $("#addUser").click(function () {
layer.open({ okLayer.open("添加用户", "user-add.html", "90%", "90%")
title: "添加用户",
type: 2,
shade: false,
maxmin: true,
shade: 0.5,
anim: 4,
area: ["90%", "90%"],
content: "user-add.html",
zIndex: layer.zIndex,
// skin: "layui-layer-molv",
end: function () {
$(".layui-laypage-btn")[0].click();
}
});
}) })
}) })
</script> </script>