打开模态窗体,并获取返回值、刷新

JS:
<script src="/Scripts/lhgdialog/lhgdialog.min.js?self=true&skin=idialog" type="text/javascript"></script>

//父页面
var api, W;
            try {
                if (frameElement != undefined) {
                    api = frameElement.api;
                    W = api.opener;
                }
            }
            catch (e) { }


//新增

            function add() {
                if (currentTreeNode != null) {
                    var dialog = WindowDialog("Add.aspx?parId=" + currentTreeNode.id + "&type=" + currentTreeNode.type + "&HandlerType=add&rand=" + newCommon.atrand(10000000), "新增通讯录"500300);
                    var dialogreload = dialog.reload;
                    dialog.reload = function () {
                        dialog.close();
                        window.location.reload();
                        return false;
                    }
                } else
                    parent.alertErrorMsg("请先选择节点!");
            }



//子页面
var api = frameElement.api;
        $(function () {

        });

// 提交
        function SubmitForm() {
            var valid = $("#SubmitForm").form("validate");
            if (valid) {
                $("<div id=\"datagridmask\" class=\"datagrid-mask\"></div>").css({ display: "block", width: "100%", height: $(window).height() }).appendTo("body");
                $("<div id=\"datagridmaskmsg\" class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候...").appendTo("body").css({ display: "block", left: ($(document.body).outerWidth(true) - 150) / 2, top: ($(window).height() - 45) / 2 });
                $.post('ExOperate.ashx?HandlerType=add', $("#SubmitForm").serialize(), function (data) {
                    $("#datagridmask").remove();
                    $("#datagridmaskmsg").remove();
                    if (data.State == "1") {
                        api.returnValue = eval("({ id: '" + $("#hidRecordID").val() + "', pId: '" + '<%= Request.QueryString["parId"] %>' + "', name: '" + $("#FolderName").val() + "',iconSkin:'folder'})");
                        api.reload();
                    } else
                        $.messager.alert("系统提示", data.Message, "error");
                }, "json");
            }
        }
        $(function () {
            $('#FolderUrl').val('<%=Request.UserHostName %>');
        });


//子页面2:

var api = null;
        var W = null;
        try {
            if (frameElement.api != null) {
                api = frameElement.api;
                W = api.opener;
            }
        } catch (e) { }


//确定
        function ok() {
            var ids = "";
            var nodes = $.fn.zTree.getZTreeObj("treeAdd").getNodes();
            if (nodes != null && nodes.length > 0) {
                for (var i = 0; i < nodes.length; i++) {
                    if (nodes[i].iconSkin == "person") {
                        if (ids != "")
                            ids += ",";
                        ids += "{UserCode:'" + nodes[i].id + "',UserName:'" + nodes[i].name + "',SJH:'" + nodes[i].sjh + "',RYLX:'" + nodes[i].rylx + "', XBM:'" + nodes[i].xbm + "'}";
                    }
                }
                if (ids == "")
                    $.messager.alert("系统提示""请选择人员!""error");
                else {
                    ids = "[" + ids + "]";
                    if (api != null && api.data != null) {
                        api.data.fGetOrgUser(eval(ids));
                        api.close();
                    }
                    else if (W != undefined) {
                        W.fGetOrgUser(eval(ids));
                        api.close();
                    }
                    else {
                        window.returnValue = eval(ids);
                        window.close();
                    }
                }
            }
            else
                $.messager.alert("系统提示""请选择人员!""error");
        }
posted @ 2015-04-16 15:55  Tz__C  阅读(877)  评论(0编辑  收藏  举报