fastadmin后端添加页面,自主控制弹出框关闭,关闭父页面弹框

Form.api.bindevent($("form[role=form]"), (data, ret) => { 重写绑定事件,返回false即可

注意:只有返回code=1才能拦截,其他值不进行拦截

javascript 复制代码
        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;
            });

        }

关闭父窗口的弹出框

javascript 复制代码
                                parent.Layer.closeAll(); // 关闭所有对话框类型弹窗
                                parent.Layer.msg(data.msg || __('Operation Success'), {icon: 1});
                                parent.location.reload();
相关推荐
开箱测评小汪17 天前
FastAdmin按钮类功能全解析 class 属性定义不同的交互行为
fastadmin
汤米粥3 个月前
FastAdmin和thinkPHP学习文档
学习·thinkphp·fastadmin
ETO_冬5 个月前
FastAdmin后端列表导入表格数据
javascript·thinkphp·fastadmin
ETO_冬5 个月前
Fastadmin根据链接参数显示不同列表格
javascript·php·thinkphp·fastadmin
appleคิดถึง6 个月前
fastadmin 表格数据导入
html·php·fastadmin
toooooop87 个月前
fastadmin批量压缩下载远程视频文件
fastadmin
appleคิดถึง9 个月前
fastadmin 列表页表格实现动态列
android·fastadmin·tp5
appleคิดถึง9 个月前
fastadmin 多商户模式下侧边栏跳转路径BUG
fastadmin·多商户
向宇it9 个月前
fastadmin搜索刷新列表,怎么限制用户频繁点击?
开发语言·前端·javascript·fastadmin