封装:
function openwin(title, page, w, h, full = false, reload = null, closeRefresh = false) {
//layui 弹出层
//https://www.layui.com/doc/modules/layer.html
//点击关闭按钮会依次执行cancel和end回调,加上isClose进行控制,只执行cancel回调
var isClose = false;
var index = layer.open({
type: 2,
title: title,
shadeClose: false,
shade: [0],
maxmin: false, //开启最大化最小化按钮
area: [w, h],
anim: 2,
content: page,
cancel: function (index) {
if (!closeRefresh) {
isClose = true;
}
layer.close(index);
},
end: function () {
//判断fucntion
if (typeof (reload) == "function" && !isClose) {
//刷新父级列表
reload();
}
}
});
if (full) {
layer.full(index);
}
}
调用:
openwin('继承规划', 'InheritPlan?PlanningId=' + data.id, '40%', '70%', false,reload);
注意:
reload 是你页面自定义的刷新方法。