Form.api.bindevent($(“form[role=form]”), (data, ret) => { 重写绑定事件,返回false即可
注意:只有返回code=1才能拦截,其他值不进行拦截
add: function () {
//获取当前search里面的type值
var type = location.search.split('type=')[1];
Form.api.bindevent($("form[role=form]"), (data, ret) => {
console.log(data, ret);
if (ret.data) {
let index = Layer.confirm(ret.msg, {
btn: ['继续', '取消'], icon: 1, yes: () => {
Layer.close(index)
$.post(`appdevice/add?type=${type}&force=1`, $("form[role=form]").serialize(), (data) => {
if (data.code != 1) {
return false;
}
parent.Layer.closeAll(); // 关闭所有对话框类型弹窗
parent.Layer.msg(data.msg || __('Operation Success'), {icon: 1});
parent.location.reload();
})
}, btn2: () => {
}
});
} else {
Layer.msg(ret.msg || __('Operation Failed'));
}
return false;
});
}
关闭父窗口的弹出框
parent.Layer.closeAll(); // 关闭所有对话框类型弹窗
parent.Layer.msg(data.msg || __('Operation Success'), {icon: 1});
parent.location.reload();