layer.open 实现弹出框新增后关闭 刷新父页面

1、效果图

2、父页面 :

3、子页面点击保存按钮:

js方法:

$('.publish').on('click', function(){
        layer.msg('确定要保存么?', {
        time: 0 //不自动关闭
        ,btn: ['确定', '取消']
        ,yes:function(){
            
            $.ajax({
                type:"post",
                url:"${basePath}/material?action=addMaterialEntity",
                data:"dicId="+ $("#dicId").val() +"&dicNumber=" + $("#dicNumber").val()
                + "&dicName=" + $("#dicName").val()+ "&dicCode=" + $("#dicCode").val()
                + "&dicUnit=" + $("#dicUnit").val()+ "&dicType=" + $("#dicType").val()
                + "&dicIsMixture=" + $("#dicIsMixture").val()
                + "&dicIsOds=" + $("#dicIsOds").val()
                + "&dicOdpUp=" + $("#dicOdpUp").val()
                + "&dicOdpDown=" + $("#dicOdpDown").val()
                + "&dicOdpCurrent=" + $("#dicOdpCurrent").val()
                + "&dicStatus=" + $("#dicStatus").val(),//表单数据
                success:function(d){
                    
                    if(d=='1'){
                        alert("保存成功!");
                    }
                    if(d!='1'){
                        alert("保存异常!");
                    }
                    window.parent.layer.closeAll();//关闭弹窗
                }
            });
        }
        });

        });

4、子页面走后台代码:

你可能感兴趣的:(layui)