layui.use(['form', 'layer'], function () {
    var form = layui.form
    layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

    form.on("submit(save)", function (data) {
        //弹出loading
        const index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        //实际使用时的提交信息
        $.ajax( {
            url : "/upms/sysuser/save",
            type : "POST",
            dataType:"json",
            contentType:'application/json;charset=UTF-8',
            data:JSON.stringify({loginName:$("#loginName").val(),
                userName:$("#userName").val(),
                userAddress: $("#userAddress").val(),
                userMobilePhone: $("#userMobilePhone").val(),
                userDesc: $("#userDesc").val(),
                userEmail: $("#userEmail").val(),
                userType: $("#userType").val(),
                userGender: $('input[name="userGender"]:checked').val(),
                userStatus: $("#userStatus").val(),
                orgTreeId: $("#orgTreeId").val(),
                remark: $("#remark").val(),
            }),
            success : function(res) {
                console.log(res);
                layer.close(index);
                layer.msg(res.msg);
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
            },
            error:function(e){
                layer.close(index);
                layer.msg("信息提交异常！");
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
            }
        })
        return false;
    })
})