弹窗 自定义 页面

var prox;
var proy;
var proxc;
var proyc;
var isIe = (document.all) ? true : false;
var od = document.getElementById("fd");
function setSelectState(state) {
    var objl = document.getElementsByTagName('select');
    for (var i = 0; i < objl.length; i++) {
        objl[i].style.visibility = state;
    }
}
function mousePosition(ev) {
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    return {
        x: ev.clientX + document.body.scrollLeft - document.body.clientLeft, y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}
//关闭窗口
function closeWindow() {
    if (document.getElementById('back' + (backCount - 1)) != null) {
        document.getElementById('back' + (backCount - 1)).parentNode.removeChild(document.getElementById('back' + (backCount - 1)));
    }
    if (document.getElementById('mesWindow') != null) {
        document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }

    if (isIe) {
        setSelectState('');
    }
}
var SetValueFunction; //用于赋值函数
var CloseFunction;
var backCount = 0;
var zindex = 10000;
//show("fd", event, "ChooseIntegralType.aspx", "760", "550", "选择积分类型", showUser,CloseMethod);
function show(id, ev, url, Win_Width, Win_Height, title,method,CloseMethod) {/*--打开--*/
    
    var bWidth = document.body.clientWidth; //parseInt(document.documentElement.scrollWidth);
    var bHeight = document.body.clientHeight; ;
    if (isIe) {
        setSelectState('hidden');
    }
    var back = document.createElement("div");
    back.id = "back" + backCount;
    var styleStr = "top:0px;left:0px;position:absolute;width:" + bWidth + "px;height:" + bHeight + "px;z-index:" + zindex;
    //styleStr += (isIe) ? "filter:alpha(opacity=20);" : "opacity:0.20;";
    back.style.cssText = styleStr;
    document.body.appendChild(back);
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = CreateWindow(title, Win_Width, Win_Height, url)
    o.style.display = "block";
    o.style.height = Win_Height + "px";
    o.style.width = Win_Width + "px";
    o.style.left = (bWidth - Win_Width) / 2-2;
    o.style.top = (bHeight - Win_Height) / 2 - 2;
    SetValueFunction = method;
    CloseFunction = CloseMethod;
    backCount++;
    zindex++;
}
var vbtnTG=null;
var vbtnJQ=null;
var vbtnSC=null;
var vbtnFZ=null;
var vbtnCH=null;

function showApp(id, ev, url, Win_Width, Win_Height, title,method,CloseMethod,btnTG,btnJQ,btnSC,btnFZ,btnCH) 
{
    vbtnTG=btnTG;vbtnJQ=btnJQ;vbtnSC=btnSC;vbtnFZ=btnFZ;vbtnCH=btnCH;
    var bWidth = document.body.clientWidth; //parseInt(document.documentElement.scrollWidth);
    var bHeight = document.body.clientHeight; ;
    if (isIe) {
        setSelectState('hidden');
    }
    var back = document.createElement("div");
    back.id = "back" + backCount;
    var styleStr = "top:0px;left:0px;position:absolute;width:" + bWidth + "px;height:" + bHeight + "px;z-index:" + zindex;
    //styleStr += (isIe) ? "filter:alpha(opacity=20);" : "opacity:0.20;";
    back.style.cssText = styleStr;
    document.body.appendChild(back);
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = CreateWindow(title, Win_Width, Win_Height, url)
    o.style.display = "block";
    o.style.height = Win_Height + "px";
    o.style.width = Win_Width + "px";
    o.style.left = (bWidth - Win_Width) / 2-2;
    o.style.top = (bHeight - Win_Height) / 2 - 2;
    SetValueFunction = method;
    CloseFunction = CloseMethod;
    backCount++;
    zindex++;
}
function openx(o, x) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx < x) {
        o.style.width = (cx + Math.ceil((x - cx) / 5)) + "px";
    }
    else {
        clearInterval(prox);
        proy = setInterval(function () { openy(o, 300) }, 10);
    }
}
function openy(o, y) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy < y) {
        o.style.height = (cy + Math.ceil((y - cy) / 5)) + "px";
    }
    else {
        clearInterval(proy);
    }
}
//弹出div窗体
function ShowWindow(vc, vcnumber, url, ta, valueForVC, valueForNumber) {
    var strType = valueForVC;
    if (strType == null)
        strType = 1;

    if (document.all.divLoad != null)
        document.all.divLoad.style.display = '';
    var va;
    var myDate = new Date();
    var m = myDate.getMilliseconds();   //获取当前毫秒数(0-999)

    //单据类型
    var varBillType
    try {
        varBillType = $("#txtBillType").val().split('|');
    }
    catch (e) {
        varBillType = ''
    }
    //条件
    var val = $("#" + vc + "").val();
    Control = vc;
    CurrentType = ta;
    ControlNumber = vcnumber;
    var url = "" + url + "?tempid=" + m + "&ta=" + ta + "&BillType=" + varBillType + "&vartj=" + escape(val) + "&strType=" + strType + "&varModel=" + valueForNumber + " ";

    show('fd', event, url, 760, 500);
    document.all.divLoad.style.display = 'none';
}
//设置选中的值
function SetValue(va) {
    var varc;
    var ta = CurrentType;
    var vcnumber = ControlNumber;
    var vc = Control;

    if (va == null) {
        $("#" + vc + "").val('');
        document.all.divLoad.style.display = 'none';
        return;
    }
    else
        varc = va.split(",");

    //    if (valueForVC != undefined) 
    //    {
    //        document.getElementById(vc).value = varc[valueForVC];
    //        document.getElementById(vcnumber).value = varc[valueForNumber];
    //    } 
    //    else 
    //    {
    if (ta == "Base_Worker") {
        if (document.getElementById(vcnumber).value != varc[1]) {
            document.getElementById(vc).value = varc[0];
            document.getElementById(vcnumber).value = varc[1];

            if (vc != 'txtGuestName') {
                try {
                    if (vc != 'txtUser') {//不是录单员
                        document.getElementById("txtBranchName").value = varc[2];
                        $("#txtBranchNum").val(varc[3]);
                    }
                }
                catch (e) {
                }
                try {
                    document.getElementById("btnGetCode").click(); //重新生成单据
                }
                catch (e) {
                }
            }
        }
    }
    else if (ta == "Base_Guest") {
        try {
            document.getElementById(vc).value = varc[0];
            document.getElementById(vcnumber).value = varc[1];
            if (varc[2] == "") {
                varc[2] = '0';
            }
            if (vc == "txtSellCompany") {
                if (varc[3] == "")
                    document.getElementById("txtSellTel").value = varc[3];
            }
            else {
                var vardate = new Date();
                vardate.setDate(vardate.getDate() + parseInt(varc[2]));
                document.getElementById("txtPayDate").value = vardate.getYear() + '-' + (vardate.getMonth() + 1) + '-' + vardate.getDate();
            }
        }
        catch (e) {
        }
    }
    else if (ta == "Base_Storage") {
        if (document.getElementById(vcnumber).value != varc[1]) {
            document.getElementById(vc).value = varc[0];
            document.getElementById(vcnumber).value = varc[1];

            //商品调拨时,出入仓库不能相同
            try {
                funInOutStro(vc, vcnumber)
            }
            catch (e) {
            }
            try {
                document.getElementById("btnUpdateGoods").click(); //更新所选商品库存数量
            }
            catch (e) {
            }
        }
    }
    else if (varTable == 'Base_Branch')//固定资产还回
    {
        if ($("#" + varnumber + "").val() != varc[1]) {
            document.getElementById(vc).value = varc[0];
            document.getElementById(vcnumber).value = varc[1];
            try {
                document.getElementById("btnDapFixed").click();
            }
            catch (e) {
            }
        }
    }
    else {
        document.getElementById(vc).value = varc[0];
        document.getElementById(vcnumber).value = varc[1];
    }
    document.all.divLoad.style.display = 'none';
    closeed('fd');
}
var t;
function closeed() {/*--关闭--*/
    t = setTimeout("close_window()", 10);
    
}
function close_window() 
{
    closeWindow();
    var div_window = divList[divList.length - 1];   
    try
    {
        var iframeObj = div_window.getElementsByTagName("iframe")[0];
        iframeObj.setAttribute("onreadystatechange", function () { });
        iframeObj.src = "";
    }
    catch(e)
    {}
    div_window.parentNode.removeChild(div_window);
    od = divList[divList.length - 2]; //重新div窗体
    divList.length = divList.length - 1;
    backCount--;
    zindex--;
    try{
    div_window.parentNode.focus();
    }catch(e){}
    if(CloseFunction)
      CloseFunction();
    clearTimeout(t);
}
function closey(o) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy > 0) {
        o.style.height = (cy - Math.ceil(cy / 5)) + "px";
    }
    else {
        clearInterval(proyc);
        proxc = setInterval(function () { closex(o) }, 10);
    }
}
function closex(o) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx > 0) {
        o.style.width = (cx - Math.ceil(cx / 5)) + "px";
    }
    else {
        clearInterval(proxc);
        o.style.display = "none";
    }
}


/*-------------------------鼠标拖动---------------------*/
var od;//= document.getElementById("fd");
var dx, dy, mx, my, mouseD;
var odrag;
var isIE = document.all ? true : false;
//div鼠标放开事件
MouseUp = function () {
    mouseD = false;
    odrag = "";
    if (isIE) {
        od.releaseCapture();
       // od.filters.alpha.opacity = 100;
    }
    else {
        window.releaseEvents(od.MOUSEMOVE);
       // od.style.opacity = 1;
    }
}

//div鼠标按下事件
MouseDown = function (e) {
    odrag = this;
    var e = e ? e : event;
    if (e.button == (document.all ? 1 : 0)) 
    {
        mx = e.clientX;
        my = e.clientY;
       
        if (isIE) {
            od.setCapture();
        }
        else {
            window.captureEvents(Event.MOUSEMOVE);
        }

        mouseD = true;
    }
}
//div移动事件
MouseMove = function (e) {
    var e = e ? e : event;

    //alert(mrx);
    //alert(e.button);        
    if (mouseD == true && odrag) {
        var mrx = e.clientX - mx;
        var mry = e.clientY - my;
        od.style.left = parseInt(od.style.left) + mrx + "px";
        od.style.top = parseInt(od.style.top) + mry + "px";
        mx = e.clientX;
        my = e.clientY;
    }
}

function showBackground(obj, endInt) {
    obj.filters.alpha.opacity += 1;
    if (obj.filters.alpha.opacity < endInt) {
        setTimeout(function () { showBackground(obj, endInt) }, 8);
    }
}
//设置iframe加载函数
Iframe_readystatechange = function (obj,li_Statue) {
    var li_Statue = document.getElementById(li_Statue);
    if (obj.readyState == "complete") 
    {
        var vht='';
        if(vbtnTG)
            vht=vht+"<input id=\"btnTG\" type=\"button\" value=\"通过\" class=\"btn\" onclick=\"funA(1)\" />&nbsp;&nbsp;";
        
        if(vbtnJQ)
            vht=vht+"<input id=\"btnJQ\" type=\"button\" value=\"拒签\" class=\"btn\" onclick=\"funA(2)\" />&nbsp;&nbsp;";
            
        if(vbtnFZ)
            vht=vht+"<input id=\"btnFZ\" type=\"button\" value=\"复制草稿\" class=\"btn\" onclick=\"funA(3)\" />&nbsp;&nbsp;";
            
        if(vbtnSC)
            vht=vht+"<input id=\"btnSC\" type=\"button\" value=\"删除\" class=\"btn\" onclick=\"funA(4)\" />&nbsp;&nbsp;";
            
        if(vbtnCH)
            vht=vht+"<input id=\"btnCH\" type=\"button\" value=\"冲红\" class=\"btn\" onclick=\"funA(5)\" />&nbsp;&nbsp;";

        if(vht=='')
            document.getElementById("divApp").style.display='none';
        else
        {
            document.getElementById("divApp").style.display='';
            document.getElementById("divApp").innerHTML = vht;
        }
            
         li_Statue.innerText = "加载完成。";


    }
    else {
        li_Statue.innerText = "页面加载中……";
    }
}


var divList = new Array();
//创建div弹出窗口
function CreateWindow(title,width,height,url) {
    var div = document.createElement("div");
    od = div;
    div.id = "fd" + backCount;
    div.className = "fd";
    od.style.left = 0;
    od.style.top = 0;
    if (isIE) 
    {
        div.setAttribute("onmousedown", MouseDown);
        div.setAttribute("onmouseup", MouseUp);
        div.setAttribute("onmousemove", MouseMove);
    }
    else
    {
        div.addEventListener("mousedown", MouseDown,false);
        div.addEventListener("mouseup", MouseUp,false);
        div.addEventListener("mousemove", MouseMove,false);
    }
    divList[divList.length] = div;
    div.style.width = width + "px";
    div.style.height = height + "px";
    var iframe_Height = height - 60;
    var iframe_Width = width - 8;
    div.style.zIndex = zindex+1;
    var innerHtml = "<div class=\"contentup\"><a href=\"#\" class=\"divclose\" onclick=\"closeed(this);return false;\" id='a_windowClose" + divList.length + "'> </a>";
    innerHtml += " <div class=\"tittleup\">" + title + "</div>";
    innerHtml += " <ul class=\"upcontent\" ><iframe height=\"" + iframe_Height + "\" onreadystatechange=\"Iframe_readystatechange(this,'li_Statue" + divList.length + "')\" width=\"" + iframe_Width + "\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" src=\"" + url + "\" vspace=\"0\" frameborder=\"0\" scrolling=\"No\" id=\"iframe_Content" + divList.length + "\"></iframe>";
     innerHtml += "<div id=\"divApp\" style=\"position:absolute;height:25px;line-height:25px;bottom:18px;left:5px;\"></div>";
    innerHtml += "<li id='li_Statue"+divList.length+"' class=\"li_Statue\">页面加载中……</li></ul></div>";

    div.innerHTML = innerHtml;
    document.body.appendChild(div);
    window.frames["iframe_Content" + divList.length].focus();
    return div;
}



function showdiv(id, ev, divid, Win_Width, Win_Height, title,method,CloseMethod) {/*--打开--*/
    
    var bWidth = document.body.clientWidth; //parseInt(document.documentElement.scrollWidth);
    var bHeight = document.body.clientHeight; ;
    if (isIe) {
        setSelectState('hidden');
    }
//    var back = document.createElement("div");
//    back.id = "back" + backCount;
//    var styleStr = "top:0px;left:0px;position:absolute;width:" + bWidth + "px;height:" + bHeight + "px;z-index:" + zindex;
//    //styleStr += (isIe) ? "filter:alpha(opacity=20);" : "opacity:0.20;";
//    back.style.cssText = styleStr;
//    document.body.appendChild(back);
//    clearInterval(prox);
//    clearInterval(proy);
//    clearInterval(proxc);
//    clearInterval(proyc);
//   
    var o = CreateDiv(title, Win_Width, Win_Height, divid)
    o.style.display = "block";
    o.style.height = Win_Height + "px";
    o.style.width = Win_Width + "px";
    o.style.left = (bWidth - Win_Width) / 2-2;
    o.style.top = (bHeight - Win_Height) / 2 - 2;
    SetValueFunction = method;
    CloseFunction = CloseMethod;
    backCount++;
    zindex++;
    
}

//显示div弹出窗口
function CreateDiv(title,width,height,divid) {
    var div = document.createElement("div");
    od = div;
    div.id = "fd" + backCount;
    div.className = "fd";
    od.style.left = 0;
    od.style.top = 0;
//    div.setAttribute("onmousedown", MouseDown);
//    div.setAttribute("onmouseup", MouseUp);
//    div.setAttribute("onmousemove", MouseMove);
    divList[divList.length] = div;
    div.style.width = width + "px";
    div.style.height = height + "px";
    var iframe_Height = height - 60;
    var iframe_Width = width - 8;
    div.style.zIndex = zindex+1;
//    var innerHtml = "<div class=\"contentup\"><a href=\"#\" class=\"od\" onclick=\"closeed(this);return false;\" id='a_windowClose" + divList.length + "'>关 闭 </a>";
//    innerHtml += " <div class=\"tittleup\">" + title + "</div>";
//    innerHtml += " <ul class=\"upcontent\" >"
//    innerHtml += "<li id='li_Statue"+divList.length+"' class=\"li_Statue\">页面加载中……</li></ul></div>";

//    div.innerHTML = innerHtml;
    document.body.appendChild(div);
    var divAL = document.createElement("div");
    divAL.className = "contentup";
    divAL.innerHTML ="<a href=\"#\" class=\"divclose\" onclick=\"closeed(this);return false;\" id='a_windowClose" + divList.length + "'> </a>";
    
    
    var divTi = document.createElement("div");
    divTi.className = "upcontent";
    divTi.innerHTML =title;
//    divTi.setAttribute("onmousedown", MouseDown);
//    divTi.setAttribute("onmouseup", MouseUp);
//    divTi.setAttribute("onmousemove", MouseMove);
    
    
    var divUi = document.createElement("div");
    divUi.className = "upcontent";
    
    document.getElementById(divid).style.height = height-60 + "px";
     document.getElementById(divid).style.width = width + "px";
    divUi.appendChild(document.getElementById(divid));
     divAL.appendChild(divTi);
     divAL.appendChild(divUi);
   
    div.appendChild(divAL);
    return div;
}
View Code

 

posted on 2017-03-10 17:59  邹敏向日葵  阅读(95)  评论(0编辑  收藏  举报

导航