var commonGridObj_orderlist;
var comboCUSTOMERNAME; //委托单位 
var sortName = "";
var sortIndex = "";
var newHeaderArgs;
var newWidthArgs;
var newColAlignArgs;
var newColSortArgs;
var newColTypeArgs;

function $(id) {
    return document.getElementById(id);
}

function createGrid(type) {
    //获取自定义列表样式
    //if(document.getElementById("origvwwmsdetail") == null){
    var url = "../UserSettings/UserGridSource/OrigVwWmsDetailListGrid.js?uid=" + newGuid();
    var loader = dhtmlxAjax.getSync(url);
    var jsVal = loader.xmlDoc.responseText;


    var oHead = document.getElementsByTagName('head').item(0);
    var oScript = document.createElement("script");

    oScript.language = "javascript";
    oScript.type = "text/javascript";
    oScript.id = "origvwwmsdetail";
    oScript.defer = true;
    oScript.text = jsVal;

    oHead.appendChild(oScript);
    //}
    //
    var searchJson = "";
    if (type == 2) {
        if (document.getElementById("origvwwmsdetail") == null) {
            var url = "../UserSettings/UserGridSource/OrigVwWmsDetailListGrid.js?uid=" + newGuid();
            var loader = dhtmlxAjax.getSync(url);
            var jsVal = loader.xmlDoc.responseText;


            var oHead = document.getElementsByTagName('head').item(0);
            var oScript = document.createElement("script");

            oScript.language = "javascript";
            oScript.type = "text/javascript";
            oScript.id = "origvwwmsdetail";
            oScript.defer = true;
            oScript.text = jsVal;

            oHead.appendChild(oScript);
        }
        var _begintime = $("txt_beginetd").value.trim();

        if (_begintime.trim() != "") {
            if (!validateDateTime(_begintime)) {
                alert("起始时间格式错误");
                return;
            }
        }
        var _endtime = $("txt_endetd").value.trim();
        if (_endtime.trim() != "") {
            if (!validateDateTime(_endtime)) {
                alert("结束时间格式错误");
                return;
            }
        }

        var _begintime2 = $("txt_beginetd2").value.trim();

        if (_begintime2.trim() != "") {
            if (!validateDateTime(_begintime2)) {
                alert("起始时间格式错误");
                return;
            }
        }
        var _endtime2 = $("txt_endetd2").value.trim();
        if (_endtime2.trim() != "") {
            if (!validateDateTime(_endtime2)) {
                alert("结束时间格式错误");
                return;
            }
        }

        var _customer = $("h_customer").value.trim();
        var _checkno = $("txt_no").value.trim();

        var searchJson = "";
        //begin
        searchJson += "{";
        searchJson += "[";

        //如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
        if (_begintime != "" && _endtime != "") {
            if (_begintime.length > 9 && _endtime.length > 9) {
                var status = DateTimeEqual(_begintime, _endtime);
                if (status == 0) {
                    searchJson += "\"btime\":\"" + _begintime + "\","
                    searchJson += "\"etime\":\"" + _endtime + "\","
                } else if (status == -1) {
                    alert("时间设置错误,起始时间不能大于结束时间,请修改!");
                    return;
                }
            }
            else {
                alert("时间格式有问题,长度应大于9个字符,请修改!");
                return;
            }
        } else {
            searchJson += "\"btime\":\"" + _begintime + "\","
            searchJson += "\"etime\":\"" + _endtime + "\","
        }

        //如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
        if (_begintime2 != "" && _endtime2 != "") {
            if (_begintime2.length > 9 && _endtime2.length > 9) {
                var status2 = DateTimeEqual(_begintime2, _endtime2);
                if (status2 == 0) {
                    searchJson += "\"btime2\":\"" + _begintime2 + "\","
                    searchJson += "\"etime2\":\"" + _endtime2 + "\","
                } else if (status == -1) {
                    alert("时间设置错误,起始时间不能大于结束时间,请修改!");
                    return;
                }
            }
            else {
                alert("时间格式有问题,长度应大于9个字符,请修改!");
                return;
            }
        } else {
            searchJson += "\"btime2\":\"" + _begintime + "\","
            searchJson += "\"etime2\":\"" + _endtime + "\","
        }

        searchJson += "\"cus\":\"" + _customer + "\",";
        searchJson += "\"no\":\"" + _checkno + "\"";
        searchJson += "]";
        searchJson += "}";
    }

    commonGridObj_orderlist = new TGridCommon("mygrid_container_seae", "form1", headerArgs_orderlist, widthArgs_orderlist, colAlignArgs_orderlist, colSortArgs_orderlist, colTypeArgs_orderlist);
    commonGridObj_orderlist.setResponseUrl("VwWmsDetailListGridSource2.aspx");
    commonGridObj_orderlist.setSortValue("", ""); //"dodate_out", "desc"

    var searchcacheName = $("h_searchcache").value;
    if (commonGridObj_orderlist.sortValue.length > 1 && commonGridObj_orderlist.sortType.length > 1) {
        if (searchcacheName != "") {
            commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid() + "&sort=" + commonGridObj_orderlist.sortValue + "&sortindex=" + commonGridObj_orderlist.sortType + "&searchcachename=" + searchcacheName);
        } else {
            if (searchJson.trim() != "") {
                commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&search=" + escape(searchJson) + "&uid=" + commonGridObj_orderlist.newGuid() + "&sort=" + commonGridObj_orderlist.sortValue + "&sortindex=" + commonGridObj_orderlist.sortType);
            } else {
                commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid() + "&sort=" + commonGridObj_orderlist.sortValue + "&sortindex=" + commonGridObj_orderlist.sortType);
            }
        }

    } else {
        if (searchcacheName != "") {
            commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid() + "&searchcachename=" + searchcacheName); //&sort=dodate_out&sortindex=desc
        } else {
            if (searchJson.trim() != "") {
                commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&search=" + escape(searchJson) + "&uid=" + commonGridObj_orderlist.newGuid()); //&sort=dodate_out&sortindex=desc
            } else {
                commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid()); //&sort=dodate_out&sortindex=desc
            }
        }

    }

    if (searchcacheName != "") {
        commonGridObj_orderlist.setMultiple("&searchcachename=" + searchcacheName);
    }
    commonGridObj_orderlist.setSourceType("json");
    commonGridObj_orderlist.setSkin("xp");
    commonGridObj_orderlist.setImageUrl("../images/");
    commonGridObj_orderlist.loadafter = true;
    commonGridObj_orderlist.after = function () {
        var url = "../UserSettings/UserGridSource/OrigVwWmsDetailListGrid.js?uid=" + newGuid();
        var loader = dhtmlxAjax.getSync(url);
        var jsVal = loader.xmlDoc.responseText;
        var oHead = document.getElementsByTagName('head').item(0);
        var oScript = document.createElement("script");
        oScript.language = "javascript";
        oScript.type = "text/javascript";
        oScript.id = "origvwwmsdetail";
        oScript.defer = true;
        oScript.text = jsVal;
        oHead.appendChild(oScript);
        //
        var arg = new Array();
        if (newColSortArgs.length == colSortArgs_orderlist.length) {
            for (var i = 0; i < colSortArgs_orderlist.length; i++) {
                var oIndex = i;
                var nIndex = 0;
                var iCount = 0;
                if (colSortArgs_orderlist[i] != newColSortArgs[i]) {
                    for (var k = 0; k < colSortArgs_orderlist.length; k++) {
                        if (colSortArgs_orderlist[k] == newColSortArgs[i]) {
                            nIndex = k;
                            commonGridObj_orderlist.getGridObj().moveColumn(nIndex, oIndex);

                            var title = headerArgs_orderlist[nIndex];
                            var width = widthArgs_orderlist[nIndex];
                            var sort = colSortArgs_orderlist[nIndex];
                            var colType = colTypeArgs_orderlist[nIndex];
                            var align = colAlignArgs_orderlist[nIndex];

                            headerArgs_orderlist[nIndex] = headerArgs_orderlist[oIndex];
                            widthArgs_orderlist[nIndex] = widthArgs_orderlist[oIndex];
                            colSortArgs_orderlist[nIndex] = colSortArgs_orderlist[oIndex];
                            colTypeArgs_orderlist[nIndex] = colTypeArgs_orderlist[oIndex];
                            colAlignArgs_orderlist[nIndex] = colAlignArgs_orderlist[oIndex];

                            headerArgs_orderlist[oIndex] = title;
                            widthArgs_orderlist[oIndex] = width;
                            colSortArgs_orderlist[oIndex] = sort;
                            colTypeArgs_orderlist[oIndex] = colType;
                            colAlignArgs_orderlist[oIndex] = align;

                            commonGridObj_orderlist.getGridObj().moveColumn(oIndex + 1, nIndex + 1);
                            var tempWidth = widthArgs_orderlist[nIndex];
                            commonGridObj_orderlist.getGridObj().setColWidth(nIndex, tempWidth);

                            iCount++;
                            break;
                        }
                    }
                } else {
                    var tempWidth = newWidthArgs[i];
                    commonGridObj_orderlist.getGridObj().setColWidth(i, tempWidth);
                }
            }
        }

        finishLoading();
    };
    commonGridObj_orderlist.initGrid();
    setTimeout(function () {
        initLoading();
        commonGridObj_orderlist.bind();
    }, 500);

    commonGridObj_orderlist.isSort = true;
    commonGridObj_orderlist.setSearch(searchJson);
    commonGridObj_orderlist.initPageByHandle("list");
    commonGridObj_orderlist.isDBClickEvent = true;

    commonGridObj_orderlist.sortEventFun = function () {
        commonGridObj_orderlist.getGridObj().attachEvent("onBeforeSorting", function (ind, type, direction) {
            if (type == "na" || type == "checkboxs") {
                return false;
            } else {
                commonGridObj_orderlist.setSortValue(type, direction);
                commonGridObj_orderlist.getGridObj().clearAll();
                commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid() + "&sort=" + type + "&sortindex=" + direction);
                if (commonGridObj_orderlist.loadafter) {
                    commonGridObj_orderlist.loadafter = false;
                    commonGridObj_orderlist.after = function () {
                    }
                }
                commonGridObj_orderlist.bind();


                return true;
            }
        });
    }
    commonGridObj_orderlist.getGridObj().attachEvent("onBeforeSorting", function (ind, type, direction) {
        if (type == "na" || type == "checkboxs") {
            return false;
        } else {
            commonGridObj_orderlist.setSortValue(type, direction);
            commonGridObj_orderlist.getGridObj().clearAll();

            commonGridObj_orderlist.setRequest("VwWmsDetailListGridSource2.aspx?handle=list&show_page=15&cur_page=1&uid=" + commonGridObj_orderlist.newGuid() + "&sort=" + type + "&sortindex=" + direction);

            if (commonGridObj_orderlist.loadafter) {
                commonGridObj_orderlist.loadafter = false;
                commonGridObj_orderlist.after = function () {
                }
            }
            commonGridObj_orderlist.bind();
            return true;
        }
    });
}

function initCombo() {
    CustomerCombo();
}
function createComboBsType() {//业务类型
    comboBsType = dhtmlXComboFromSelect("sel_bstype");
}

function CustomerCombo() {
    comboCustomer = new TCombo("sel_customer", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER", true, true, false, true, "h_customer");
    comboCustomer.initComboEvent();
    comboCustomer.bind();
}

function initSearch() {
    $("h_customer").value = "";
    comboCustomer.setText($("h_customer").value);
    $("txt_no").value = "";

    $("txt_beginetd").value = "";
    $("txt_endetd").value = "";
    $("txt_beginetd2").value = "";
    $("txt_endetd2").value = "";

    if ($("h_searchcache").value != "") {
        $("h_searchcache").value = "";
    }
    createGrid(1);
}

function ShowDetailSelect() {
    createGrid();
}

function GetRange(strgid) {
    var loader;
    var dates;
    var strR = "";
    if ($("hdRangeV").value != $("hdRangeO").value) {
        if ($("hdRangeO").value == "1") {//分公司
            loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=1&strGID=" + strgid + "&RangeName=modOrderManagement&val=" + newGuid()); //委托管理列表
            dates = loader.xmlDoc.responseText;
            if (dates == "") {
                //alert("您没有操作此数据的权限!");
                return "您没有操作业务的权限!"; //0;
            }
        }
        else if ($("hdRangeO").value == "2") {//分公司
            loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=2&strGID=" + strgid + "&RangeName=modOrderManagement&val=" + newGuid()); //委托管理列表
            dates = loader.xmlDoc.responseText;
            if (dates == "") {
                //alert("您没有操作此数据的权限!");
                return "您没有操作数据的权限!"; //0;
            }
        } else if ($("hdRangeO").value == "3") {//个人
            loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=3&strGID=" + strgid + "&RangeName=modOrderManagement&val=" + newGuid()); //委托管理列表
            dates = loader.xmlDoc.responseText;
            if (dates == "") {
                //alert("您没有操作此数据的权限!");
                return "您没有操作数据的权限!"; //0;
            }
        }
    }
    return "";
}
function newGuid() {
    var guid = "";
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
            guid += "-";
    }
    return guid.toUpperCase();
}

function refreshOrder() {
    window.location.href = window.location.href;
}

//校验时间格式
function validateDateTime(dateTimeObj) {
    var isValid = false;

    var parseToObj = new Date(dateTimeObj.replace(/-/g, "/"));
    if (!isNaN(parseToObj)) {
        isValid = true;
    }

    return isValid;
}
function DateTimeEqual(beginObj, endObj) {
    var isEqual = 0;
    var begin = new Date(beginObj.replace(/-/g, "/"));
    var end = new Date(endObj.replace(/-/g, "/"));

    if (Date.parse(begin) - Date.parse(end) > 0) {
        isEqual = -1; //起始时间大于结束时间
    }
    return isEqual;
}
//根据条件查询付费申请信息
function search() {
    createGrid(2);
}

String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }


function searchMultiple() {
    printMessageBox(event);
}

function checkAll(id) {
    if ($(id).checked) {
        for (var i = 0; i < commonGridObj_orderlist.getGridObj().getRowsNum(); i++) {
            commonGridObj_orderlist.getGridObj().cellByIndex(i, 0).setValue(1);
        }
    } else {
        for (var i = 0; i < commonGridObj_orderlist.getGridObj().getRowsNum(); i++) {
            commonGridObj_orderlist.getGridObj().cellByIndex(i, 0).setValue(0);
        }
    }
}

var isIe = (document.all) ? true : false;
//设置select的可见状态
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 showMessageBox(wTitle, content, pos, wWidth) {
    closeWindow();
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight);
    if (isIe) {
        setSelectState('hidden');
    }
    var back = document.createElement("div");
    back.id = "back";
    var styleStr = "top:0px;left:0px;position:absolute;background:#666;width:" + bWidth + "px;height:" + bHeight + "px;";
    styleStr += (isIe) ? "filter:alpha(opacity=0);" : "opacity:0;";
    back.style.cssText = styleStr;
    document.body.appendChild(back);
    showBackground(back, 50);
    var mesW = document.createElement("div");
    mesW.id = "mesWindow";
    mesW.className = "mesWindow";
    mesW.innerHTML = "<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>" + wTitle + "</td><td style='width:1px;'>"
                       + "<input type='button' onclick='closeWindow();' title='关闭窗口' class='close' value='关闭' style='width:60px;'/></td></tr></table></div>"
                       + "<div class='mesWindowContent' id='mesWindowContent'>" + content + "</div><div class='mesWindowBottom'></div>";
    var v_top = (document.body.clientHeight - mesW.clientHeight) / 2;
    v_top += document.documentElement.scrollTop;
    styleStr = "top:" + (v_top - 180) + "px;left:" + (document.body.clientWidth / 2 - mesW.clientWidth / 2) + "px;position:absolute;width:700px;margin-left:-300px;left:50%;z-index:9999;";
    mesW.style.cssText = styleStr;
    document.body.appendChild(mesW);
}
//让背景渐渐变暗
function showBackground(obj, endInt) {
    if (isIe) {
        obj.filters.alpha.opacity += 5;
        if (obj.filters.alpha.opacity < endInt) {
            setTimeout(function () { showBackground(obj, endInt) }, 5);
        }
    } else {
        var al = parseFloat(obj.style.opacity); al += 0.05;
        obj.style.opacity = al;
        if (al < (endInt / 100)) {
            setTimeout(function () { showBackground(obj, endInt) }, 5);
        }
    }
}
//关闭窗口
function closeWindow() {
    if (document.getElementById('back') != null) {
        document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
    }
    if (document.getElementById('mesWindow') != null) {
        document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }
    if (isIe) {
        setSelectState('');
    }
}
//测试弹出
function printMessageBox(ev) {

    var messContent = "";
    var objPos = mousePosition(ev);
    messContent += "<div style=\"padding:20px 0 20px 0;text-align:center\">"
                + "<iframe frameborder=\"0\" src=\"../search/multiplesearch.aspx?handle=vwwmsdetail&opentype=frame\" width=\"100%\" height=\"230px;\" scrolling=\"no\">";
+"</div> ";

    showMessageBox('综合查询', messContent, objPos, 350);
}

function reInitJs() {
    if (document.getElementById("origvwwmsdetail") == null) {
        var url = "../UserSettings/UserGridSource/OrigVwWmsDetailListGrid.js?uid=" + newGuid();
        var loader = dhtmlxAjax.getSync(url);
        var jsVal = loader.xmlDoc.responseText;


        var oHead = document.getElementsByTagName('head').item(0);
        var oScript = document.createElement("script");

        oScript.language = "javascript";
        oScript.type = "text/javascript";
        oScript.id = "origvwwmsdetail";
        oScript.defer = true;
        oScript.text = jsVal;

        oHead.appendChild(oScript);
    }

    if (document.getElementById("defaultsource") == null) {
        var url = "../js/DefaultSource.js?uid=" + newGuid();
        var loader = dhtmlxAjax.getSync(url);
        var jsVal = loader.xmlDoc.responseText;

        var oHead = document.getElementsByTagName('head').item(0);
        var oScript = document.createElement("script");

        oScript.language = "javascript";
        oScript.type = "text/javascript";
        oScript.id = "defaultsource";
        oScript.defer = true;
        oScript.text = jsVal;

        oHead.appendChild(oScript);
    }

    if (document.getElementById("vwwmsdetail") == null) {
        var url = "../UserSettings/UserGridSource/" + $("h_uid").value + "gridvwwmsdetail.js?uid=" + newGuid();

        var loader = dhtmlxAjax.getSync(url);
        var jsVal = loader.xmlDoc.responseText;


        if (jsVal.indexOf("newHeaderArgs") >= 0) {
            var oHead = document.getElementsByTagName('head').item(0);
            var oScript = document.createElement("script");

            oScript.language = "javascript";
            oScript.type = "text/javascript";
            oScript.id = "vwwmsdetail";
            oScript.defer = true;
            oScript.text = jsVal;

            oHead.appendChild(oScript);
        }
    }

    initCombo(); createGrid(1);
}

function initLoading() {
    $("progressBar").style.display = "";
}

function finishLoading() {
    $("progressBar").style.display = "none";
}

function editGridSetting() {
    var openSet = "height=500, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 500) / 2 + ",Left= " + (screen.width - 800) / 2
    var openType = "_blank";

    var openUrl = "../UserSettings/UserGridEdit.aspx?handle=usergrid&templatetype=vwwmsdetail";
    window.open(openUrl, openType, openSet);
}

function printDetail() {
    var strBSNO = "";
    strBSNO = commonGridObj_orderlist.getGridObj().getCheckedRows(0); //所有选中的grid的id编号 
    var printUrl = "";
    var companyID = "";
    var typeName = "printwmsdetail";
    var dbSourceID = "";
    var userID = "";
    //查询条件
    var _begintime = $("txt_beginetd").value.trim();

    if (_begintime.trim() != "") {
        if (!validateDateTime(_begintime)) {
            alert("起始时间格式错误");
            return;
        }
    }
    var _endtime = $("txt_endetd").value.trim();
    if (_endtime.trim() != "") {
        if (!validateDateTime(_endtime)) {
            alert("结束时间格式错误");
            return;
        }
    }

    var _begintime2 = $("txt_beginetd2").value.trim();

    if (_begintime2.trim() != "") {
        if (!validateDateTime(_begintime2)) {
            alert("起始时间格式错误");
            return;
        }
    }
    var _endtime2 = $("txt_endetd2").value.trim();
    if (_endtime2.trim() != "") {
        if (!validateDateTime(_endtime2)) {
            alert("结束时间格式错误");
            return;
        }
    }

    var _customer = $("h_customer").value.trim();
    var _checkno = $("txt_no").value.trim();

    var searchJson = "";
    //begin
    searchJson += "{";
    searchJson += "[";

    //如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
    if (_begintime != "" && _endtime != "") {
        if (_begintime.length > 9 && _endtime.length > 9) {
            var status = DateTimeEqual(_begintime, _endtime);
            if (status == 0) {
                searchJson += "\"btime\":\"" + _begintime + "\","
                searchJson += "\"etime\":\"" + _endtime + "\","
            } else if (status == -1) {
                alert("时间设置错误,起始时间不能大于结束时间,请修改!");
                return;
            }
        }
        else {
            alert("时间格式有问题,长度应大于9个字符,请修改!");
            return;
        }
    } else {
        searchJson += "\"btime\":\"" + _begintime + "\","
        searchJson += "\"etime\":\"" + _endtime + "\","
    }

    //如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
    if (_begintime2 != "" && _endtime2 != "") {
        if (_begintime2.length > 9 && _endtime2.length > 9) {
            var status2 = DateTimeEqual(_begintime2, _endtime2);
            if (status2 == 0) {
                searchJson += "\"btime2\":\"" + _begintime2 + "\","
                searchJson += "\"etime2\":\"" + _endtime2 + "\","
            } else if (status == -1) {
                alert("时间设置错误,起始时间不能大于结束时间,请修改!");
                return;
            }
        }
        else {
            alert("时间格式有问题,长度应大于9个字符,请修改!");
            return;
        }
    } else {
        searchJson += "\"btime2\":\"" + _begintime + "\","
        searchJson += "\"etime2\":\"" + _endtime + "\","
    }

    searchJson += "\"cus\":\"" + _customer + "\",";
    searchJson += "\"no\":\"" + _checkno + "\"";
    searchJson += "]";
    searchJson += "}";
    //
    var url = "../Reports/ReportService.aspx?handle=printwmsdetail&bsno=" + strBSNO + "&search=" + escape(searchJson) + "&val=" + commonGridObj_orderlist.newGuid();
    var loader = dhtmlxAjax.getSync(url);
    var reportVal = loader.xmlDoc.responseText;
    var reportObj = null;

    if (reportVal != "") {
        reportObj = eval('(' + reportVal + ')');
        if (reportObj.reports.length > 0) {
            if (reportObj.reports[0].compid != "") {
                companyID = reportObj.reports[0].compid;
            }
            if (reportObj.reports[0].sourceid != "") {
                dbSourceID = reportObj.reports[0].sourceid;
            }
            if (reportObj.reports[0].compid != "") {
                userID = reportObj.reports[0].userid;
            }
            printUrl = "print://?comp=" + companyID + "&type=" + typeName + "&dbid=" + dbSourceID + "&uid=" + userID; //alert(printUrl);

            window.location.href = window.location.href;
            location.href = printUrl;
        }

    } else {
        alert("没有要打印的报表");
        return;
    }
}