///<reference path="/Scripts/ExtPB_Net.js" />
///<reference path="/Scripts/MyExtPB.js" />
///<reference path="/Scripts/ExtPB_Dll_Pb_Http.js" />
///<reference path="/Scripts/MyExtPb_Input.js" />
///<reference  path="/CaiGou/CaiGouTongJiFenxi/W_CG_HZ_Base.win.js" /> 

//注意,需要在对象定义后面，手工增加以下代码实现对象继承
// W_CW_KHDZD_Main.prototype = new W_CG_HZ_Base( ); 

function W_CW_KHDZD_Main() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var sle_zh = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var rb_mx = new RadioButton(requestor);
    var rb_hz = new RadioButton(requestor);
    var ddlb_1 = new DropDownListBox(requestor);
   
    var sle_bm = new SingleLineEdit(requestor);
    var sle_gys = new SingleLineEdit(requestor);
    var dw_temp = new DataWindow(requestor);
    var dw_format = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var dw_parameter = new DataWindow(requestor);
    var dw_xt_div_tree_no_parm = new DataWindow(requestor);
    var dw_3 = new DataWindow(requestor);
    var dw_proxy = new DataWindow(requestor);
    var dw_da_qx_mokuai = new DataWindow(requestor);
    var dw_sort = new DataWindow(requestor);
    var dw_print = new DataWindow(requestor);
    var dw_2 = new DataWindow(requestor);
    var dw_init = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);
    var sle_sk = new SingleLineEdit(requestor);
    var sle_ck = new SingleLineEdit(requestor);
    var cb_Save = new CommandButton(requestor);
    var cb_Select = new CommandButton(requestor);
    var sle_formatname = new SingleLineEdit(requestor);

    if (typeof (this.bind) == "function") var baseBind = this.bind;
    this.bind = function (win) {
        self.Instance = win;
        if (typeof (baseBind) == "function") baseBind(win);

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (sle_zh == null) sle_zh = new SingleLineEdit(requestor);
        sle_zh.Attach(win.Control("sle_zh"));

        if (ddlb_1 == null) ddlb_1 = new DropDownListBox(requestor);
        ddlb_1.Attach(win.Control("ddlb_1")); 

        if (rb_mx == null) rb_mx = new RadioButton(requestor);
        rb_mx.Attach(win.Control("rb_mx"));
        if (rb_hz == null) rb_hz = new RadioButton(requestor);
        rb_hz.Attach(win.Control("rb_hz")); 
        if (sle_sk == null) sle_sk = new SingleLineEdit(requestor);
        sle_sk.Attach(win.Control("sle_sk"));
        if (sle_ck == null) sle_ck = new SingleLineEdit(requestor);
        sle_ck.Attach(win.Control("sle_ck"));
        if (dp_2 == null) dp_2 = new DatePicker(requestor);
        dp_2.Attach(win.Control("dp_2"));
        if (dp_1 == null) dp_1 = new DatePicker(requestor);
        dp_1.Attach(win.Control("dp_1"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (sle_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        if (dw_temp == null) dw_temp = new DataWindow(requestor);
        dw_temp.Attach(win.Control("dw_temp"));
        if (dw_format == null) dw_format = new DataWindow(requestor);
        dw_format.Attach(win.Control("dw_format"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (dw_parameter == null) dw_parameter = new DataWindow(requestor);
        dw_parameter.Attach(win.Control("dw_parameter"));
        if (dw_xt_div_tree_no_parm == null) dw_xt_div_tree_no_parm = new DataWindow(requestor);
        dw_xt_div_tree_no_parm.Attach(win.Control("dw_xt_div_tree_no_parm"));
        if (dw_3 == null) dw_3 = new DataWindow(requestor);
        dw_3.Attach(win.Control("dw_3"));
        if (dw_proxy == null) dw_proxy = new DataWindow(requestor);
        dw_proxy.Attach(win.Control("dw_proxy"));
        if (dw_da_qx_mokuai == null) dw_da_qx_mokuai = new DataWindow(requestor);
        dw_da_qx_mokuai.Attach(win.Control("dw_da_qx_mokuai"));
        if (dw_sort == null) dw_sort = new DataWindow(requestor);
        dw_sort.Attach(win.Control("dw_sort"));
        if (dw_print == null) dw_print = new DataWindow(requestor);
        dw_print.Attach(win.Control("dw_print"));
        if (dw_2 == null) dw_2 = new DataWindow(requestor);
        dw_2.Attach(win.Control("dw_2"));
        if (dw_init == null) dw_init = new DataWindow(requestor);
        dw_init.Attach(win.Control("dw_init"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));
        if (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));

        if (typeof (self.PostOpen) == "function")
            win.AttachEvent("window", "PostOpen", self.PostOpen);

        if (typeof (self.Changegys) == "function")
            win.AttachEvent("cb_7", "Clicked", self.Changegys);

        if (typeof (self.Changebmbh) == "function")
            win.AttachEvent("cb_1", "Clicked", self.Changebmbh);

        if (typeof (self.DoubleClicked) == "function")
            win.AttachEvent("dw_list", "DoubleClicked", self.DoubleClicked);


        if (typeof (self.Print) == "function")
            win.AttachEvent("btn_Print", "Clicked", self.Print);

        if (typeof (self.TongJi) == "function")
            win.AttachEvent("btn_Query", "Clicked", self.TongJi);

        if (typeof (self.ReportOp) == "function")
            win.AttachEvent("列格式保存ToolStripMenuItem", "Clicked", self.ReportOp);

        if (typeof (self.ReportClare) == "function")
            win.AttachEvent("清空当前窗口所有格式ToolStripMenuItem", "Clicked", self.ReportClare);

        if (typeof (self.picpreview) == "function")
            win.AttachEvent("浏览图片ToolStripMenuItem", "Clicked", self.picpreview);

        if (typeof (self.SelectGS) == "function")
            win.AttachEvent("cb_Select", "Clicked", self.SelectGS);

        if (typeof (self.SaveGS) == "function")
            win.AttachEvent("cb_Save", "Clicked", self.SaveGS);

        if (typeof (self.DoubleClicked) == "function")
            win.AttachEvent("dw_List", "DoubleClicked", self.DoubleClicked);


        if (typeof (self.RightKey) == "function")
            win.AttachEvent("xxxxxxaToolStripMenuItem", "Clicked", self.RightKey);

        if (typeof (self.Exit) == "function")
            win.AttachEvent("btn_Exit", "Clicked", self.Exit);

    }

    if (typeof (this.unbind) == "function") var baseUnBind = this.unbind;
    this.unbind = function () {
        self.Instance = null;
        if (typeof (this.Release) == "function") this.Release();
        if (typeof (baseUnBind) == "function") baseUnBind();
        sle_zh.Detach(); sle_zh = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        rb_mx.Detach(); rb_mx = null;
        rb_hz.Detach(); rb_hz = null; 
        sle_sk.Detach(); sle_sk = null;
        sle_ck.Detach(); sle_ck = null;
        sle_bm.Detach(); sle_bm = null;
        sle_gys.Detach(); sle_gys = null;
        dw_temp.Detach(); dw_temp = null;
        dw_format.Detach(); dw_format = null;
        ddlb_1.Detach(); ddlb_1 = null; 
        dw_list.Detach(); dw_list = null;
        dw_parameter.Detach(); dw_parameter = null;
        dw_xt_div_tree_no_parm.Detach(); dw_xt_div_tree_no_parm = null;
        dw_3.Detach(); dw_3 = null;
        dw_proxy.Detach(); dw_proxy = null;
        dw_da_qx_mokuai.Detach(); dw_da_qx_mokuai = null;
        dw_sort.Detach(); dw_sort = null;
        dw_print.Detach(); dw_print = null;
        dw_2.Detach(); dw_2 = null;
        dw_init.Detach(); dw_init = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;
        sle_formatname.Detach(); sle_formatname = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改

    var curW_OPEN_BMDA = new OpenWindowQueryBase();
    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();

    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    
    
    var curW_YW_LIST = new W_YW_LIST();
    var curYhbh = "";
    var curCdbh = "";
    var C_CheckValue = "";
    var curKhyeJqdBm = "0";
    var curKhdzdNew = "0";
    var curBbmc = "rb_sp";
    var curFromKHYE = "";

    //报表名称
    var curBBMCNew = "";
    var curBBPZH = "";
    var curOptype = "0" //0 ：保存  1：修改 
    var cur_Open_Window = null;
    var ChildDWCheckValue = "";
    var curDw_format_hz = null; //格式汇总窗口
    var curDw_format_mx = null; //格式明细窗口
    var Exel_FH_Flag = "1";
    var curW_Base_Report_Open_Mx_Ex = new W_Base_Report_Open_Mx_Ex();
    var curUserId = "";
    var curcbx_gs = 0;
    var xsmrgs = 0;
    var curPzh = "";
    var syntax = "";
    var evealStr = "";
    var lastSortName = "";
    var isFirstSave = "";
    var curSfQyQDID = "0";  // 如果启用渠道ID,默认不启用
    var curJqm = "";
    var curUserGroupId = "";
    var curSfQYQXZ = "0";
    var dw_da_qx_mokuai_print = null;
    var jqd = 0;           // 精确度
    var jqw = 0;           // 几舍几入
    
    //#region PostOpen
    this.PostOpen = function () {
        jqd = parseFloat(requestor.GetParm("curJqd").toString());
        jqw = parseInt(requestor.GetParm("curJqw").toString());
        sle_bm.SetEnabled(false);
        if (dw_da_qx_mokuai_print == null) {
            dw_da_qx_mokuai_print = new DataWindow(requestor);
            if (dw_da_qx_mokuai_print == null) dw_da_qx_mokuai_print = new DataWindow(requestor);
            dw_da_qx_mokuai_print.Attach(requestor.Control("dw_da_qx_mokuai_print"));
        }

        curDw_format_hz = window.external.Control("dw_format_hz");
        curDw_format_mx = window.external.Control("dw_format");
        curSfQyQDID = GetGlobalParm("XTCS", "SFQYQDID", "qybz");
        curSfQYQXZ = GetGlobalParm("XTCS", "SFQYQXZ-NEW", "qybz"); // 是否启用新版权限组。
        curJqm = requestor.GetParm("curJqm"); //管理系统机器码
        Exel_FH_Flag = GetGlobalParm("Excel_FH_Flag", "Excel_FH_Flag", "qybz");
        curUserGroupId = requestor.GetParm("curUserGroupId");


        if (Exel_FH_Flag.length < 1) {
            Exel_FH_Flag = "1";
        }
        if (typeof (self.ckfschanges) == "function")
            requestor.AttachEvent("cb_ck", "Clicked", self.ckfschanges);
        if (typeof (self.skfschanges) == "function")
            requestor.AttachEvent("cb_sk", "Clicked", self.skfschanges);
        if (typeof (self.zhhanges) == "function")
            requestor.AttachEvent("cb_zh", "Clicked", self.zhhanges);

        if (typeof (self.Myprints) == "function")
            requestor.AttachEvent("btn_Print", "Clicked", self.Myprints);

        var myDate = new Date();
        var nian = myDate.getFullYear().toString();
        var yue = myDate.getMonth();
        var ri = "01";
        var objDate = new Date(nian, yue, ri);

        dp_1.SetValue(objDate.getVarDate())
        dp_2.SetValue(UtcDateFormatToString(new Date().getVarDate()))
        dw_list.SetRowSelection("1");
        curKhyeJqdBm = GetGlobalParm("cw_jqdbm", "jqdbm", "qybz");
        curKhdzdNew = GetGlobalParm("XTCS", "CW_NEW", "qybz");
        curCdbh = requestor.GetParm("curCdbh");
        curYhbh = requestor.GetParm("curYhbh");
        var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();
         
        //旧版财务
        if (curKhdzdNew == "0") {
            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("dw_cw_khbmdzd_list");
            }
            else {
                dw_temp.SetDataObject("dw_cw_khdzd_list");
            }
        } else {
            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("da_cw_new_khbmdzd_list");
            }
            else {
                dw_temp.SetDataObject("da_cw_new_khdzd_list");
            }
        }
        dw_format.RetrieveEx("cdbh='" + curCdbh + "' and yhbh='" + curYhbh + "' and bbmc='" + curBbmc + "'");

        curFromKHYE = requestor.GetParm("curFromKHYE");
        if (curFromKHYE.length > 0) {
            dp_1.SetValue(curFromKHYE.split("@@@")[0]);
            dp_2.SetValue(curFromKHYE.split("@@@")[1]);
            sle_gys.SetText("'" + curFromKHYE.split("@@@")[2] + "'");
            if (curFromKHYE.split("@@@")[3].length > 0) {
                sle_bm.SetText("'" + curFromKHYE.split("@@@")[3] + "'");
            }

            self.Query();
        }
        curPzh = requestor.GetParm("pzh");
        curBbmc = requestor.GetParm("bbmc");
        curBbfl = requestor.GetParm("bbfl");
        var context = curPzh + "#" + curBbmc + "#" + curBbfl;
        self.SetBBMC(context, "1");
        if (curOptype == "1" && curBBMCNew.length > 0) {
            sle_formatname.SetText(curBBMCNew);
            self.ClearAndTJ(true);
        } else {
            sle_formatname.SetText("");
            curBBPZH = "";
        }

    }
    //#endregion

    //#region Function 呼出数据窗口的函数群 

    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName == "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CW_KHDZD_Main, "bmbh", "bmmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=cwcx"), curW_OPEN_BMDA_NEW, null);
    }


    this.Changegys = function (x, y, row, dwoName) {
        dwoName == "khbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CW_KHDZD_Main, "khbh", "khmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_khda_fl_tree&listDw=dw_pub_khda_list_all&treeRootLabel=客户分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);
    }
    this.ckfschanges = function (x, y, row, dwoName) {
        dwoName == "csbh";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CW_KHDZD_Main, "csbh", "csmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_da_qj_csb_cgfs_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }

    this.skfschanges = function (x, y, row, dwoName) {
        dwoName == "skfs";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CW_KHDZD_Main, "skfs", "skmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_list_qj_csb_skfs&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    this.zhhanges = function (x, y, row, dwoName) {

        dwoName == "zhbh";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CW_KHDZD_Main, "zhbh", "zhmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_yinhangzhanghao_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    //#endregion

    //#region 选中后赋值

    this.SetSleValue = function (difBh, val) {

        if ("''" == val)
            val = "";
        if ("bmbh" == difBh)
            sle_bm.SetText(val);
        else if ("khbh" == difBh)
            sle_gys.SetText(val);
        else if ("skfs" == difBh)
            sle_sk.SetText(val);
        else if ("csbh" == difBh)
            sle_ck.SetText(val);
        else if ("zhbh" == difBh) {
            sle_zh.SetText(val);
        }
    }

    //#endregion

    //#region 执行查询
    this.Query = function () {
        if (rb_mx.GetChecked()) {
            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("da_cw_new_khbmdzd_list_mx");
            }
            else {
                dw_temp.SetDataObject("da_cw_new_khdzd_list_mx");
            }

        } else {
            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("da_cw_new_khbmdzd_list");
            }
            else {
                dw_temp.SetDataObject("da_cw_new_khdzd_list");
            }
        }
        dw_temp.RetrieveEx("1=1 " + self.GetSqlWhere(true))
        var curRowCount = dw_temp.RowCount();

        dw_list.SetFullState(dw_temp.GetFullState());
        //DWSort(dw_format, dw_list);

        self.SetValue(C_CheckValue, curBbmc, curCdbh, curYhbh);



    }
    //#endregion

    //#region 获取where 条件
    this.GetSqlWhere = function (flag) {

        var realSql = "";
        var beginDate = UtcDateFormatToString(dp_1.GetValue());
        var endDate = UtcDateFormatToString(dp_2.GetValue());
        var curYhbh = requestor.GetParm("curYhbh")
        var curBm = sle_bm.GetText();
        var curGys = sle_gys.GetText();
        var curck = sle_ck.GetText();
        var cursk = sle_sk.GetText();
        var curzh = sle_zh.GetText();
        //旧版财务
        if (curKhdzdNew == "0") {

            realSql += " and (CONVERT(date,jzsj) between '" + beginDate + "' and '" + endDate + "')";

            if (curBm.length > 0) {
                curBm = self.DealWords(curBm);
                if (flag == true) {
                    realSql += " and bmbh  in(" + curBm + ")";
                } else {
                    realSql += " and  bmbh  in('" + curBm + "')";
                }
            } else {
                realSql += " and bmbh in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and cwcx = '1')";
            }
            if (curGys.length > 0) {

                curGys = self.DealWords(curGys);
                if (flag == true) {
                    if (curKhdzdNew == "1") {
                        realSql += " and khbh  in(" + curGys + ")";
                    } else {
                        realSql += " and a.khbh in(" + curGys + ")";
                    }
                } else {
                    if (curKhdzdNew == "1") {
                        realSql += " and khbh in('" + curGys + "')";
                    } else {
                        realSql += " and a.khbh in('" + curGys + "')";
                    }
                }
            } else {
                if (curKhdzdNew == "1") {
                    realSql += " and khbh in(select khbh  from da_qx_khda where yhbh = '" + curYhbh + "'and bz3 = '1')";
                } else {
                    realSql += " and a.khbh in(select khbh  from da_qx_khda where yhbh = '" + curYhbh + "'and bz3 = '1')";
                }
            }

        }
        else {
            realSql += " and (CONVERT(date,rq) between '" + beginDate + "' and '" + endDate + "')";

            if (curBm.length > 0) {
                curBm = self.DealWords(curBm);
                if (flag == true) {
                    realSql += " and bmbh  in(" + curBm + ")";
                } else {
                    realSql += " and  bmbh  in('" + curBm + "')";
                }
            } else {
                realSql += " and bmbh in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and cwcx = '1')";
            }
            if (curGys.length > 0) {

                curGys = self.DealWords(curGys);
                if (flag == true) {
                    if (curKhdzdNew == "1") {
                        realSql += " and khbh  in(" + curGys + ")";
                    } else {
                        realSql += " and a.khbh in(" + curGys + ")";
                    }
                } else {
                    if (curKhdzdNew == "1") {
                        realSql += " and khbh in('" + curGys + "')";
                    } else {
                        realSql += " and a.khbh in('" + curGys + "')";
                    }
                }
            } else {
                if (curKhdzdNew == "1") {
                    realSql += " and khbh in(select khbh  from da_qx_khda where yhbh = '" + curYhbh + "'and bz3 = '1')";
                } else {
                    realSql += " and a.khbh in(select khbh  from da_qx_khda where yhbh = '" + curYhbh + "'and bz3 = '1')";
                }
            }


            if (curck.length > 0) {

                curck = self.DealWords(curck);
                if (curKhdzdNew == "1") {
                    realSql += " and ckfs in(select  csmc from da_qj_csb  where csfl='CG_CGFS' and csbh in (" + curck + "))";
                } else {
                    realSql += " and ckfs in(select  csmc from da_qj_csb  where csfl='CG_CGFS' and csbh in(" + curck + "))";
                }
            }

            if (cursk.length > 0) {
                cursk = self.DealWords(cursk);
                if (rb_mx.GetChecked()) {
                    realSql += " AND (  skfs IN(SELECT csmc FROM dbo.da_qj_csb WHERE csbh IN(" + cursk + ") AND csfl IN('skfs')) OR(skfs='组合收款' AND ISNULL(TTT.zhmc,'')='' AND flag<>1 AND pzh IN(SELECT pzh FROM cw_new_xhskd_mx WHERE skx IN(SELECT csbh FROM dbo.da_qj_csb WHERE csfl='ZDYSKX' AND csmc IN(SELECT csmc FROM dbo.da_qj_csb WHERE csbh IN(" + cursk + ") AND csfl IN('skfs','ZDYSKX')))  AND ISNULL(bcsk,0)<>0 ))  OR c.csmc='现金'  AND zhsk_mx<>0)";
                } else {

                    if (curKhdzdNew == "1") {
                        realSql += " and skfs in(select  csmc from da_qj_csb  where csfl='skfs' and csbh in(" + cursk + "))";
                    } else {
                        realSql += " and skfs in(select  csmc from da_qj_csb  where csfl='skfs' and csbh in(" + cursk + "))";
                    }
                }

            }

            if (curzh.length > 0) {
                curzh = self.DealWords(curzh);
                if (curKhdzdNew == "1") {
                    realSql += " and ttt.fyzh in(" + curzh + ") ";
                } else {
                    realSql += " and ttt.fyzh in(" + curzh + ")";
                }

            }
        }
        return realSql;


    }
    //#endregion


    //#region Function DealWords
    this.DealWords = function (words) {

        if (!(words.charAt(0) == "'"))
            words = "'" + words + "'";

        return words;

    }
    //#endregion

    this.DoubleClicked = function (x, y, row, dwcName) {
       
        if (dwcName.indexOf("_t") > -1) {
           
            var curColName = dwcName.split("_")[0];
            if (curColName == lastSortName) {
                dw_list.SetSort(curColName + " A");
                lastSortName = "";
                dw_list.Sort();
            } else {
                dw_list.SetSort(curColName + " D");
                lastSortName = dwcName.split("_")[0];
                dw_list.Sort();
            }
            return 1;

        }
       
        var curPzh = "";
        var curLydh = "";
        var itemData = "";
        var itemLabel = "";

        var curRow = dw_list.GetRow();

        if (curRow > 0) {
            curPzh = dw_list.GetItemString(curRow, "pzh");
            curLydh = dw_list.GetItemString(curRow, "lydh");
            // && (curLydh.substring(0, 2) == "PF" || curLydh.substring(0, 2) == "PT")
            if (curLydh.length > 0 && curLydh.substring(0, 7).toUpperCase() != "POSSPKH") {
                curPzh = curLydh;
            }
            if (curKhdzdNew == "1") {
                var ts_1 = window.external.Control("ts_1");
                if (curPzh.substring(0, 2) == "PF") {
                    itemData = "SJ141";
                    itemLabel = "批发出库单";
                } else if (curPzh.substring(0, 2) == "PT") {
                    itemData = "SJ144";
                    itemLabel = "批发退货单";
                } else if (curPzh.substring(0, 2) == "LC") {
                    itemData = "SJ123";
                    itemLabel = "连锁配送出库单";
                } else if (curPzh.substring(0, 2) == "LT") {
                    itemData = "SJ126";
                    itemLabel = "连锁退货入库单";
                } else if (curPzh.substring(0, 2) == "QC") {
                    itemData = "SJ204";
                    itemLabel = "渠道配货出库单";
                } else if (curPzh.substring(0, 2) == "QT") {
                    itemData = "SJ207";
                    itemLabel = "渠道退货入库单";
                } else if (curPzh.substring(0, 2) == "XS") {
                    itemData = "SJ555";
                    itemLabel = "销货收款单";

                } else if (curPzh.substring(0, 2) == "XF") {
                    itemData = "SJ556";
                    itemLabel = "销货费用单";
                }
                else if (curLydh.substring(0, 2) == "TJ") {
                    itemData = "SJ648";
                    itemLabel = "客户调价单";
                }
                else if (curLydh.substring(0, 2) == "DC") {
                    itemData = "SJ010";
                    itemLabel = "仓库调拨出库单";
                }
                else if (curLydh.substring(0, 2) == "DR") {
                    itemData = "SJ173";
                    itemLabel = "仓库调拨入库单";
                }
                ts_1.CloseItem(itemData);
                ts_1.Open(itemData, itemLabel, '', "/Service/OpenSheet.aspx?FunID=" + itemData + "&curDate=" + new Date().toLocaleTimeString() + "&Reload=Y&curDzdPzh=" + curPzh, true);
            } else {
                //window.parent.OpenSheet("SJ811", "订单管理", ddbh);
                requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.CaiWu.CaiWuTongJiFenXi.W_YW_LIST&curpzh=" + curPzh + "&curJqdbm=" + curKhyeJqdBm), curW_YW_LIST, null);
            }
        }
    }

    //#region 打印
    this.Myprints = function () {

        var curKhbh = sle_gys.GetText();
        if (curKhbh.length < 1) {
            alert("请检查客户编号");
            return;
        }
        if (curKhbh.indexOf(",") > -1) {
            alert("只能选择一个客户对账");
            return;
        }
        var curBeginDate = UtcDateFormatToString(dp_1.GetValue());
        var curEndDate = UtcDateFormatToString(dp_2.GetValue());

        self.Query();


        dw_print.SetDataObject("dw_null");
        dw_proxy.SetDataObject("dw_null");
        var curVisibleNoModifyStr = "";
        var curZdyNoVisibleCol = "";
        var curVisibleStr = "";
        var curVisibleArrStr = "";
        var curAllColumnArr = new Array();
        var modifyArr = new Array();
        var curAllColumn = "";
        var curSlje = 0; //数量金额
        var curRmb = 0; //人民币
        var curDygs = "1";
        //dw_mx.Retrieve(dw_mx_top.GetItemString(dw_mx_top.GetRow(), "pzh"));
        var curSjbh = requestor.GetParm("curCdbh");
        var curUserId = requestor.GetParm("curYhbh");

        if (curSfQYQXZ == "1") {
            dw_xt_div_tree_no_parm.Retrieve(curUserGroupId);
        } else {
            dw_xt_div_tree_no_parm.Retrieve(curUserId);
        }

        dw_proxy.SetFullState(dw_temp.GetFullState());



        //#region 1--begin 先取排过序，调整过宽度的数据窗口


        var findRow = dw_xt_div_tree_no_parm.Find(" cdbh ='" + curSjbh + "'", 0, dw_xt_div_tree_no_parm.RowCount());

        if (findRow > 0) {
            var curSjckmc = dw_xt_div_tree_no_parm.GetItemString(findRow, "sjckmc");
            var curMkCName = dw_xt_div_tree_no_parm.GetItemString(findRow, "cdmc");

            //            if (curSfQyQDID == "1") {
            //             //   dw_da_qx_mokuai.SetDataObject("dw_da_qx_mokuai_save_print");
            //                dw_da_qx_mokuai.RetrieveEx(" jqm ='" + curJqm + "' and cdbh ='" + curSjbh + "'"); // 权限模块表，查出[当前]用户的[当前]模块
            //            }
            //            else {
            //              //  dw_da_qx_mokuai.SetDataObject("dw_da_qx_mokuai_save");
            //                dw_da_qx_mokuai.RetrieveEx(" yhbh ='" + curUserId + "' and cdbh ='" + curSjbh + "'"); // 权限模块表，查出[当前]用户的[当前]模块
            //            }

            if (curSfQYQXZ == "1") {
                dw_da_qx_mokuai.RetrieveEx(" yhbh ='" + curUserGroupId + "' and cdbh ='" + curSjbh + "'"); // 权限模块表，查出[当前]用户的[当前]模块
            } else {
                dw_da_qx_mokuai.RetrieveEx(" yhbh ='" + curUserId + "' and cdbh ='" + curSjbh + "'"); // 权限模块表，查出[当前]用户的[当前]模块
            }
   
            dw_da_qx_mokuai_print.RetrieveEx(" jqm ='" + curJqm + "' and cdbh ='" + curSjbh + "'"); // 机器码模块表，查出[当前]用户的[当前]模块  精确到机器码的数据窗口
    

            //取不显示列的 modify 字符串【来自权限】
            if (dw_da_qx_mokuai_print.RowCount() > 0) {

                var curSortStr = dw_da_qx_mokuai_print.GetItemString(1, "zdypxdy" + curDygs); // 自定义排序
                //------------------------------------权限不显示列-------------begin------------------

                var curLzfc = ""; // 不显示的列字符串  
                if (curSfQyQDID != "1") {
                    curLzfc = dw_da_qx_mokuai_print.GetItemString(1, "lzfc");
                }
                curVisibleNoModifyStr = curLzfc;
                //------------------------------------自定义不显示列-------------begin----------------

                var curZdyycl = dw_da_qx_mokuai_print.GetItemString(1, "zdyycldy" + curDygs); // 自定义不显示列     
                curZdyNoVisibleCol = curZdyycl;
                if (curLzfc.length > 0) {

                    curLzfc += "," + curZdyycl;
                } else {
                    curLzfc += curZdyycl;

                }
                //------------------------------------自定义不显示列-------------end------------------
                if (curLzfc.length > 0) {
                    var curVisibleArr = curLzfc.split(",");
                    for (var k = 0; k < curVisibleArr.length; k++) {
                        curVisibleStr += curVisibleArr[k] + ".Visible='0' "; // 不显示的列字符串设置为【不显示】
                        curVisibleStr += curVisibleArr[k] + ".Width='0' "; // 不显示的列字符串设置为【不显示】
                        if (curVisibleArrStr.length > 0) {
                            curVisibleArrStr += "," + curVisibleArr[k];
                        } else {
                            curVisibleArrStr += curVisibleArr[k];
                        }
                    }
                }
                //------------------------------------权限不显示列-------------end------------------
            }

            var colNewNameArr = new Array();
            // 初始化列对应的名称（取权限表里边自定义的列名称）

            var curGglm = dw_da_qx_mokuai.GetItemString(1, "gglm");

            if (curSjckmc != null && curSjckmc.length > 0) {
                //    dw_print.SetDataObject(curSjckmc); // 隐藏数据窗口  

                if (curKhyeJqdBm == "1") {
                    dw_print.SetDataObject("da_cw_new_khbmdzd_list");
                }
                else {
                    dw_print.SetDataObject("da_cw_new_khdzd_list");
                }

                var colCount = dw_print.Describe("DataWindow.Column.Count");
                var modifyArr = new Array();
                for (var i = 1; i <= colCount; i++) {
                    if (dw_print.Describe("#" + i + ".Visible") == "1") {
                        var detailName = dw_print.Describe("#" + i + ".Name"); // PB对应字段名                           
                        var curNewName = self.isMyHave(curGglm, detailName) // 没有就返回-1，有就返回当前新的名称
                        if (curNewName != "-1") {
                            curAllColumnArr.push(detailName + "#" + curNewName);
                            modifyArr.push(detailName + "_t.Text='" + curNewName + "'");
                        } else {
                            curAllColumnArr.push(detailName + "#" + (dw_print.Describe(detailName + "_t.Text") == "!" ? detailName : dw_print.Describe(detailName + "_t.Text")) + "#" + dw_print.Describe(detailName + ".x"));
                            modifyArr.push(detailName + "_t.Text='" + (dw_print.Describe(detailName + "_t.Text") == "!" ? detailName : dw_print.Describe(detailName + "_t.Text")) + "'");
                        }
                    }
                }
                //#region  计算列
                var ls_objects = dw_print.Describe("DataWindow.Objects");
                var ls_objectsArr = ls_objects.split("\t");
                for (var w = 0; w < ls_objectsArr.length; w++) {
                    var ls_name = ls_objectsArr[w].substring(0, ls_objectsArr[w].length - 2);
                    var ls_type = dw_print.Describe(ls_name + ".type");
                    var ls_band = dw_print.Describe(ls_name + ".band");
                    if (ls_type == "compute" && ls_band == "detail") {

                        //#region 这里是计算列
                        if (dw_print.Describe(ls_name + ".visible") == "1") {
                            var detailName = dw_print.Describe(ls_name + ".Name"); // PB对应字段名      
                            var curNewName = self.isMyHave(curGglm, detailName) // 没有就返回-1，有就返回当前新的名称
                            if (curNewName != "-1") {
                                curAllColumnArr.push(detailName + "#" + curNewName + "#" + dw_print.Describe(detailName + ".x"));
                                modifyArr.push(detailName + "_t.Text='" + curNewName + "'");
                            } else {
                                curAllColumnArr.push(detailName + "#" + dw_print.Describe(detailName + "_t.Text") + "#" + dw_print.Describe(detailName + ".x"));
                                modifyArr.push(detailName + "_t.Text='" + dw_print.Describe(detailName + "_t.Text") + "'");
                            }

                        }
                        //#endregion
                    }
                }

                //#endregion 
                dw_print.Modify(modifyArr.join(" ").toString());     // 权限中修改列的名称  
            } else {
                alert("请为当前模块设置数据窗口名称");
                return;
            }
        }

        if (curVisibleStr.length > 0) {

            dw_print.Modify(curVisibleStr.toString());  // 不显示列【来自权限】。                      // 1.不显示的列
        }
        // 当前显示的所有列

        curAllColumn = self.getMyNewStr(curAllColumnArr, curVisibleNoModifyStr.toString());      //  2.当前所有列

        self.DoSort(curSortStr, false);
        //#endregion 1--end 


        var curAllModifyStr = "";
        var curAllModifyStrFreeDw = "";
        var curHeaderHeight = 600;
        var curDetailHeight = 88;
        var curSummaryHeight = 300;
        var curHengXiangOrShuXiang = 1//默认是横向。
        var curZhiZhang = 1//默认是纸张。
        var curZhiZhangDaXiao = 4//默认是纸张大小。

        dw_proxy.ShareData(dw_print);
        dw_print.SetRedraw(false);

        //#region 获取 dw_parameter，值 
        if (curSjbh != null && curSjbh != "") {
            dw_parameter.Retrieve(curSjbh, curJqm, curDygs);
            if (dw_parameter.RowCount() > 0) {
                if (dw_parameter.GetItemNumber(1, "header_val_" + curDygs) > 0) {
                    curHeaderHeight = dw_parameter.GetItemNumber(1, "header_val_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "detail_val_" + curDygs) > 0) {
                    curDetailHeight = dw_parameter.GetItemNumber(1, "detail_val_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "summary_val_" + curDygs) > 0) {
                    curSummaryHeight = dw_parameter.GetItemNumber(1, "summary_val_" + curDygs);
                }

                if (dw_parameter.GetItemNumber(1, "orien" + curDygs) > 0) {
                    curHengXiangOrShuXiang = dw_parameter.GetItemNumber(1, "orien" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "paper" + curDygs) > 0) {
                    curZhiZhang = dw_parameter.GetItemNumber(1, "paper" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "papersize" + curDygs) > 0) {
                    curZhiZhangDaXiao = dw_parameter.GetItemNumber(1, "papersize" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "cb_slje_" + curDygs) > 0) {
                    curSlje = dw_parameter.GetItemNumber(1, "cb_slje_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "cb_rmb_" + curDygs) > 0) {
                    curRmb = dw_parameter.GetItemNumber(1, "cb_rmb_" + curDygs);
                }

            }
        }
        //#endregion 

        //#region 初始化当前窗口 curAllColumn, curVisibleArrStr,
        if (curAllColumn.length > 0) {
            var curColumns = curAllColumn.split("@");
            dw_sort.Reset();
            for (var i = 0; i < curColumns.length; i++) {

                if (self.isHave(curVisibleArrStr, curColumns[i].split("#")[0])) {
                    // 打×的不显示出来

                    dw_print.Modify(curColumns[i].split("#")[0] + ".visible='0'");
                    dw_print.Modify(curColumns[i].split("#")[0] + ".width='0'");

                } else {

                    var rows = dw_sort.RowCount() + 1;
                    dw_sort.InsertRow(rows);
                    dw_sort.SetItem(rows, "flag1", curColumns[i].split("#")[0]);
                    dw_sort.SetItem(rows, "flag2", curColumns[i].split("#")[1]);
                    dw_sort.SetItem(rows, "pxbh", parseInt(dw_print.Describe(curColumns[i].split("#")[0] + ".x")))
                    // dw_sort.SetItem(rows, "pxbh", parseInt(curColumns[i].split("#")[2]));
                    dw_sort.SetItem(rows, "flag3", "√");

                    // 如果不是二维模式的时候把header中_t抬高
                    if (curDygs != "1") {
                        dw_print.Modify(curColumns[i].split("#")[0] + "_t.y='0'");
                    }
                    //把尺码1-35的Text清空
                    if (curColumns[i].split("#")[0].length > 2 && curColumns[i].split("#")[0].substring(0, 2).toUpperCase() == "CM" && !isNaN(curColumns[i].split("#")[0].substring(2, 5))) {
                        // 如果不是二维模式的时候把header第一行设置为空.

                        if (curDygs != "1") {
                            //本来这里应该要设置为空是最好的，但是我要在header.1区域取尺码标题，所有先把第一行的尺码标题字体设置为透明的。
                            //  dw_print.Modify(curColumns[i].split("#")[0] + "_t.Text=''");
                            dw_print.Modify(curColumns[i].split("#")[0] + "_t.color='553648127'");
                        }
                    }
                }
            }
        }
        dw_sort.SetSort("pxbh");
        dw_sort.Sort();
        //#endregion  


        //#region 画线 
        if (curDygs == "1") { // 二唯

        } else {              // 非二唯
            // 改变header高度
            dw_print.Modify("DataWindow.Header.Height='70'");

        }

        //第一条横线从这里开始。
        var curHxStart = parseInt(curHeaderHeight) - parseInt(dw_print.Describe("DataWindow.Header.Height"));
        //竖线-最左边
        var curXhLStart = dw_sort.GetItemNumber(1, "pxbh");
        //竖线-最右边
        var curXhREnd = parseInt(parseInt(dw_sort.GetItemNumber(dw_sort.RowCount(), "pxbh")) + parseInt(dw_print.Describe(dw_sort.GetItemString(dw_sort.RowCount(), "flag1") + ".width")));

        // Head宽度放大。背景颜色设为“透明”
        curAllModifyStr += "DataWindow.Header.Height='" + curHeaderHeight + "'\tDataWindow.Header.Color='553648127'\tDataWindow.detail.Height='" + curDetailHeight + "'\t DataWindow.summary.Height='" + curSummaryHeight + "'\t";

        // 这里把所有的header区域压下来。。。
        var ls_objects = dw_print.Describe("DataWindow.Objects");
        var ls_objectsArr = ls_objects.split("\t");
        for (var w = 0; w < ls_objectsArr.length; w++) {
            var ls_name = ls_objectsArr[w];
            var ls_name_hz = ls_name.substring(ls_name.length - 2, ls_name.length);
            if (ls_name.length > 2 && ls_name_hz == "_t") {
                var curT_y = dw_print.Describe(ls_name + ".y");
                dw_print.Modify(ls_name + ".y='" + parseInt(parseInt(curHxStart) + parseInt(curT_y)) + "'");
                if (curDygs == "1") { // 二维    
                    dw_print.Modify("cm" + parseInt(w + 1) + "_t.border='4'");
                } else {
                    dw_print.Modify(ls_name + ".border='0'");
                }
            }
        }


        //字段列 
        for (var i = 1; i <= dw_sort.RowCount(); i++) {
            var colName = dw_sort.GetItemString(i, "flag1");

            curAllModifyStr += colName + ".moveable='1'\t";
            curAllModifyStr += colName + "_t.moveable='1'\t";
            var curX = dw_sort.GetItemNumber(i, "pxbh") - 10;
            if (i == 1) {
                curX = curX + 9;
            }
            // ------------------------------画列的竖线--------------------begin--
            // Header
            curAllModifyStrFreeDw += " create line(band=header x1='" + curX + "' y1='" + curHxStart + "' x2='" + curX + "' y2='" + curHeaderHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
            // Detail
            curAllModifyStrFreeDw += " create line(band=detail x1='" + curX + "' y1='0'  x2='" + curX + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
            // summary
            curAllModifyStrFreeDw += " create line(band=summary x1='" + curX + "' y1='0'  x2='" + curX + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";

            // ------------------------------画列的竖线--------------------end---
            //            // 最后一列有画最右边的线
            if (i == dw_sort.RowCount()) {
                // Header
                curAllModifyStrFreeDw += " create line(band=header x1='" + curXhREnd + "' y1='" + curHxStart + "' x2='" + curXhREnd + "' y2='" + curHeaderHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
                // Detail
                curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhREnd + "' y1='0'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
                // summary
                curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhREnd + "' y1='0'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";

            }

        }
        //画横线。。。
        //最上边的线
        curAllModifyStrFreeDw += " create line(band=header x1='" + curXhLStart + "' y1='" + curHxStart + "' x2='" + curXhREnd + "' y2='" + curHxStart + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //数据区域的start线
        curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhLStart + "' y1='0' x2='" + curXhREnd + "' y2='0' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //数据区域的end线
        curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhLStart + "' y1='" + curDetailHeight + "' x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //summaryStart线
        curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='0'  x2='" + curXhREnd + "' y2='0' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //summaryend线
        curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='" + curDetailHeight + "'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //结束线
        //    curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='" + curSummaryHeight + "'  x2='" + curXhREnd + "' y2='" + curSummaryHeight + "' pen.style='0' pen.width='10' pen.color='255'  background.mode='2' background.color='16777215' )\t";



        // 处理显示数据列名称
        curAllModifyStrFreeDw += " DataWindow.ShowDefinition='Yes'\t";

        // 设置标题
        var tit = requestor.GetParm("dw_yw_cg_top_title_value");
        var titX = 1400; // 设置标题
        var titYmX = 2800; //【页码】
        var titRqX = 2300; //【加入日期】 
        var titJjyrjX = 1500; //【" + GetErpProductTypeName() + "软件】
        var titBzX = 2800; //加入打印备注
        var titSlAndJeX = "2500"// 数量金额
        var titRmb = "2500"// 人民币大写
        curAllModifyStrFreeDw += " create text(band=header     alignment='2' text='" + tit + "' border='0'  name=my_title moveable=1 resizeable=1   color='0'  x='" + titX + "'  y='25' height='85' moveable=1 width='500'  font.face='黑体' font.height='-14' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【页码】 
        //curAllModifyStrFreeDw += " create text(band=header     alignment='0' text='页码' border='0' moveable=1 resizeable=1  name=my_ym  color='0' x='" + titYmX + "'  y='120' height='56' moveable=1 width='200'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【数量金额】
        curAllModifyStrFreeDw += " create text(band=header  alignment='0' text='数量金额' border='0' moveable=1 resizeable=1  name=my_slje  color='0' x='" + titSlAndJeX + "' visible='" + curSlje + "' y='120' height='56' moveable=1 width='700'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【人民币大写】
        curAllModifyStrFreeDw += " create text(band=summary  alignment='0' text='人民币大写' border='0' moveable=1 resizeable=1  name=my_rmb  color='0' x='" + titRmb + "'  y='60' visible='" + curRmb + "' height='56' moveable=1 width='700'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【" + GetErpProductTypeName() + "软件】
        curAllModifyStrFreeDw += " create text(band=summary    alignment='1' text='【" + GetErpProductTypeName() + "软件】' name=my_jjyrj  border='0'moveable=1 resizeable=1  color='0' x='" + titJjyrjX + "' y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400'  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' font.underline='0' background.mode='2' background.color='16777215')\t";
        //【加入日期】
        curAllModifyStrFreeDw += " create compute(band=summary alignment='1' expression='today()' border='0' color='0'   moveable=1 resizeable=1        x='" + titRqX + "'  y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400' format='yyyy年mm月dd日'  name=my_rq  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' background.mode='2' background.color='16777215')\t";
        //加入打印备注
        //curAllModifyStrFreeDw += " create text(band=summary    alignment='0' text='打印'  name=my_dy    border='0' color='0' moveable=1 resizeable=1       x='" + titBzX + "' y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400'  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' font.underline='0' background.mode='2' background.color='16777215' )\t";
        //        //-------------------------------表头区域------------------end-------   
        dw_print.Modify(curAllModifyStr);

        //#region 如果visible的列就不显示。
        var colCount = dw_print.Describe("DataWindow.Column.Count");
        for (var k = 1; k <= colCount; k++) {
            var detailName = dw_print.Describe("#" + k + ".Name"); // PB对应字段名    
            if (dw_print.Describe(detailName + ".visible") == '0') {
                dw_print.Modify(detailName + ".Visible='0' " + detailName + ".Width='0'");
            } else {
                dw_print.Modify(detailName + "_t.background.mode='0'");
                dw_print.Modify(detailName + "_t.background.color='553648127'");
                dw_print.Modify(detailName + "_t.background.gradient.color ='553648127'");

                if (detailName.length > 2 && detailName.substring(0, 2).toUpperCase() == "CM" && !isNaN(detailName.substring(2, 5))) {
                    for (var i = 1; i < 10; i++) {
                        var ls_names = detailName + (i > 9 ? i : "0" + i);
                        dw_print.Modify(ls_names + "_t.background.mode='0' " + ls_names + "_t.background.color='553648127' " + ls_names + "_t.background.gradient.color ='553648127'");
                        if (curDygs == "1") {
                            dw_print.Modify(ls_names + "_t.border='4' ");
                        } else {
                            dw_print.Modify(ls_names + "_t.border='1' ");
                        }
                    }
                }
            }
        }
        //#region  计算列
        var ls_objects = dw_print.Describe("DataWindow.Objects");
        var ls_objectsArr = ls_objects.split("\t");
        for (var w = 0; w < ls_objectsArr.length; w++) {
            var ls_name = ls_objectsArr[w].substring(0, ls_objectsArr[w].length - 2);
            var ls_type = dw_print.Describe(ls_name + ".type");
            var ls_band = dw_print.Describe(ls_name + ".band");
            if (ls_type == "compute" && ls_band == "detail") {
                dw_print.Modify(ls_name + "_t.background.mode='0'");
                dw_print.Modify(ls_name + "_t.background.color='553648127'");
                dw_print.Modify(ls_name + "_t.background.gradient.color ='553648127'");
                if (dw_print.Describe(ls_name + ".visible") == '0') {
                    dw_print.Modify(ls_name + ".Visible='0' " + ls_name + ".Width='0'");
                } else {
                    dw_print.Modify(ls_name + "_t.background.mode='0'  " + ls_name + "_t.background.color='553648127'");
                }
            }
        }

        //#endregion
        ls_syntax = dw_print.Describe("DataWindow.Syntax");


        ls_syntax = ls_syntax.replace("processing=1", "processing=0");

        dw_print.Create(ls_syntax);

        dw_print.Modify(curAllModifyStrFreeDw);


        dw_proxy.ShareData(dw_print);
        dw_print.SetRedraw(true);
        //#endregion 画线

        //#region 表头表尾取值

        dw_init.Retrieve(curJqm, curSjbh, curDygs); // 打印初始化      

        for (var i = 1; i <= dw_init.RowCount(); i++) {
            var curModifyTopButtonStr = "";
            var obj = dw_init.GetItemString(i, 'obj');
            var obj_typ = dw_init.GetItemString(i, 'obj_typ');
            if (obj_typ == "") {
                obj_typ = "text";
            }
            if (obj_typ && obj_typ.length < 3) {
                obj_typ = "text";
            }
            var band = dw_init.GetItemString(i, 'band_n');
            var xin = dw_init.GetItemString(i, 'xin');
            var pos_x = dw_init.GetItemString(i, 'pos_x');
            var pos_y = dw_init.GetItemString(i, 'pos_y');
            var pos_x2 = dw_init.GetItemString(i, 'pos_x2');
            var pos_y2 = dw_init.GetItemString(i, 'pos_y2');
            var pos_width = dw_init.GetItemString(i, 'pos_width');
            var pos_height = dw_init.GetItemString(i, 'pos_height');
            var font_face = dw_init.GetItemString(i, 'font_face');
            var font_height = dw_init.GetItemString(i, 'font_height');
            var font_weight = dw_init.GetItemString(i, 'font_weight');
            var font_italic = dw_init.GetItemString(i, 'font_italic');
            var font_underline = dw_init.GetItemString(i, 'font_underline');
            var dw_border = dw_init.GetItemString(i, 'dw_border');
            var pos_width = dw_init.GetItemString(i, 'pos_width');
            var pos_height = dw_init.GetItemString(i, 'pos_height');
            var dw_visible = dw_init.GetItemString(i, 'dw_visible');
            var pen_style = dw_init.GetItemString(i, 'pen_style');
            var pen_width = dw_init.GetItemString(i, 'pen_width');
            var pen_color = '0';
            var color1 = '0';
            var format1 = dw_init.GetItemString(i, 'format');
            var alignment1 = dw_init.GetItemString(i, 'alignment');
            var style1 = dw_init.GetItemString(i, 'style');
            var text1 = dw_init.GetItemString(i, 'text_n');

            if (xin == '0') {
                if (obj_typ == "line") {
                    if (pos_x.length > 0 && pos_x != "?") { curModifyTopButtonStr += obj + ".x1='" + pos_x + "'\t"; }
                    if (pos_y.length > 0 && pos_y != "?") { curModifyTopButtonStr += obj + ".y1='" + pos_y + "'\t"; }
                    if (pos_width.length > 0 && pos_width != "?") { curModifyTopButtonStr += obj + ".x2='" + pos_width + "'\t"; }
                    if (pos_height.length > 0 && pos_height != "?") { curModifyTopButtonStr += obj + ".y2='" + pos_height + "'\t"; }
                    if (pen_style > 0 && pen_style != "?") { curModifyTopButtonStr += obj + ".pen.style='" + pen_style + "'\t"; }
                    if (pen_width.length > 0 && pen_width != "?") { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    if (pen_color.length > 0 && pen_color != "?") { curModifyTopButtonStr += obj + ".pen.color='" + pen_color + "'\t"; }
                } else if (obj_typ == "rectangle" || obj_typ == "roundrectangle" || obj_typ == "ellipse") {
                    if (pos_x.length > 0 && pos_x != "?") { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0 && pos_y != "?") { curModifyTopButtonStr += obj + ".pen.y='" + pos_y + "'\t"; }
                    if (pen_width.length > 0 && pen_width != "?") { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    if (pos_height.length > 0 && pos_height != "?") { curModifyTopButtonStr += obj + ".pos.height='" + pos_height + "'\t"; }
                    if (color1.length > 0 && color1 != "?") { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "groupbox" || obj_typ == "button") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                    if (text1.length > 0) { curModifyTopButtonStr += obj + ".text='" + text1 + "'\t"; }
                } else if (obj_typ == "bitmap") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                } else if (obj_typ == "column" || obj_typ == "text" || obj_typ == "compute") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                    if (text1.length > 0) {
                        curModifyTopButtonStr += obj + ".text='" + text1 + "'\t";
                        dw_print.Modify(obj + ".text='" + text1 + "'");
                    }
                }
            } else if (xin == '1') {
                if (obj_typ == "line") {
                    curModifyTopButtonStr += ' create line(band=' + band + ' resizeable=1  moveable=1 x1="' + pos_x + '"   y1="' + pos_y + '"' + ' x2="' + pos_x2 + '"' + ' y2="' + pos_y2 + '"' + '  name=' + obj + ' visible="1"  resizeable=1  moveable=1 pen.style="0" pen.width="5" pen.color="0"  background.mode="2" background.color="1073741824" )\t';
                    //                    if (pen_style.length > 0) { curModifyTopButtonStr += obj + ".pen.style='" + pen_style + "'\t"; }
                    //                    if (pen_width.length > 0) { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    //                    if (pen_color.length > 0) { curModifyTopButtonStr += obj + ".pen.color='" + pen_color + "'\t"; }
                } else if (obj_typ == "rectangle") {
                    curModifyTopButtonStr += 'create rectangle(band=background resizeable=1  moveable=1   x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "roundrectangle") {
                    curModifyTopButtonStr += 'create roundrectangle(band=background resizeable=1  moveable=1  ellipseheight="36" ellipsewidth="41" x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "ellipse") {
                    curModifyTopButtonStr += 'create ellipse(band=background resizeable=1  moveable=1   x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color1='" + color1 + "'\t"; }
                } else if (obj_typ == "groupbox") {
                    curModifyTopButtonStr += 'create   groupbox(band=background border="2"  resizeable=1  moveable=1  text="' + text1 + '"     x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                } else if (obj_typ == "button") {
                    curModifyTopButtonStr += 'create button(band=' + band + ' text="' + left(text1, pos(text1, '|') - 1) + '" filename= "' + right(text1, len(text1) - pos(text1, '|') - 1) + '" action="0" border="1" color="33554432" x="' + pos_x + '" y="' + pos_y + '" height="' + pos_height + '" width="' + pos_width + '" vtextalign="0" htextalign="0"  name=' + obj + ' visible="1"  font.face="楷体_GB2312" font.height="-24" font.weight="700"  font.family="1" font.pitch="1" font.charset="134" background.mode="2" background.color="67108864" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                } else if (obj_typ == "bitmap") {
                    curModifyTopButtonStr += ' create bitmap(band=' + band + ' resizeable=1  moveable=1 filename="' + text1 + '" x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"   border="0"  name=' + obj + ' visible="1" )\t';
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                } else if (obj_typ == "text") {
                    curModifyTopButtonStr += ' create   text(band=' + band + '  alignment="0"   text="' + text1 + '"    moveable=1 resizeable=1   x="' + pos_x + '"   y="' + pos_y + '"' + ' height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }

                } else if (obj_typ == "compute") {

                    curModifyTopButtonStr += ' create compute(band=' + band + ' alignment="0" expression="' + text1 + '"   moveable=1 resizeable=1    x="' + pos_x + '"   y="' + pos_y + '"' + ' height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }

                }
            }
            dw_print.Modify(curModifyTopButtonStr.toString());
        } // for end


        //#endregion 表头表尾取值      

        //#endregion 2-end

        //#region 方向
        dw_print.Modify("DataWindow.Print.Orientation='" + curHengXiangOrShuXiang + "'");
        //#endregion

        //#region 纸张
        var pap = -1;
        if (curZhiZhang == 1) {
            pap = 12;
        } else if (curZhiZhang == 2) {
            pap = 13;
        } else if (curZhiZhang == 3) {
            pap = 9;
        } else if (curZhiZhang == 4) {
            pap = 11;
        } else if (curZhiZhang == 5) {
            pap = 8;
        } else if (curZhiZhang == 6) {
            pap = 3;
        } else if (curZhiZhang == 7) {
            pap = 0;
        }

        dw_print.Modify("DataWindow.Print.Paper.Size='" + pap + "'");
        //#endregion

        //#region 纸张大小
        var pSize = "100%";
        if (curZhiZhangDaXiao == 1) {
            pSize = "25%";
        } else if (curZhiZhangDaXiao == 2) {
            pSize = "50%";
        } else if (curZhiZhangDaXiao == 3) {
            pSize = "75%";
        } else if (curZhiZhangDaXiao == 4) {
            pSize = "100%";
        } else if (curZhiZhangDaXiao == 5) {
            pSize = "125%";
        } else if (curZhiZhangDaXiao == 6) {
            pSize = "150%";
        } else if (curZhiZhangDaXiao == 7) {
            pSize = "200%";
        }
        dw_print.Modify("DataWindow.Zoom='" + pSize.split("%")[0] + "'");
        //#endregion


        //旧版财务

        if (curKhyeJqdBm == "1") {

            if (dw_print.RowCount() > 0) {

                dw_print.SetItem(dw_print.RowCount(), "zsdjy", dw_print.GetItemNumber(1, "bmsdjy"));
                dw_print.SetItem(dw_print.RowCount(), "zbdjy", dw_print.GetItemNumber(dw_print.RowCount(), "bmljye"))
            }
        }
        else {

            if (dw_print.RowCount() > 0) {
                dw_print.SetItem(dw_print.RowCount(), "zsdjy", dw_print.GetItemNumber(1, "sdjy"));
                dw_print.SetItem(dw_print.RowCount(), "zbdjy", dw_print.GetItemNumber(dw_print.RowCount(), "ljye"))
            }
        }

        dw_print.PrintPreview();

    }

    this.isMyHave = function (str1, str2) {
        var re = "-1";
        if (str1.length > 0 && str2.length > 0) {
            var str1s = str1.split("@");
            for (var i = 0; i < str1s.length; i++) {
                if (str1s[i].split("#")[0] == str2) {
                    return str1s[i].split("#")[1];
                    break;
                }
            }
        }
        return re;
    }
    // 排序和宽度。。
    this.DoSort = function (curSortStrs, isReturnStrBool) {
        var curSortStringArr = curSortStrs.split(",");
        var curModifyStr = "";
        for (var i = 0; i < curSortStringArr.length; i++) {
            curModifyStr += curSortStringArr[i].split("#")[0] + ".x='" + curSortStringArr[i].split("#")[1] + "' ";
            curModifyStr += curSortStringArr[i].split("#")[0] + ".width='" + curSortStringArr[i].split("#")[2] + "' ";
        }
        if (isReturnStrBool) {
            return curModifyStr.toString();
        } else {
            dw_print.Modify(curModifyStr.toString());
        }

    }
    this.isHave = function (str1, str2) {
        var re = false;
        if (str1.length > 0 && str2.length > 0) {
            var str1s = str1.split(",");
            for (var i = 0; i < str1s.length; i++) {
                if (str1s[i] == str2) {
                    return true;
                    break;
                }
            }
        }
        return re;
    }
    this.getMyNewStr = function (allColArr, noVisibleColStr) {   //  所有列，不显示的列，返回：要显示的所有列

        var curShowcolArrs = "";
        for (var i = 0; i < allColArr.length; i++) {
            if (!self.isHave(noVisibleColStr, allColArr[i].split("#")[0])) {  // 要显示           
                if (curShowcolArrs.length > 0) {
                    curShowcolArrs += "@" + allColArr[i];
                } else {
                    curShowcolArrs += allColArr[i];
                }
            }
        }
        return curShowcolArrs;
    }


    //#endregion 

    //#region 设置报表名称和凭证号

    this.SetBBMC = function (context, optype) {
        isFirstSave = "";
        if (context.length > 0) {
            curBBPZH = context.split("#")[0];
            curBBMCNew = context.split("#")[1];
            isFirstSave = context.split("#")[2];
            if (optype == "1") {
                curBbmc = context.split("#")[2];
                self.SetBbfl(curBbmc);
            }
        }
        curOptype = optype;
    }
    //#endregion

    //#region 报表格式选择
    this.SelectGS = function () {
        self.SelectBBFL();
        cur_Open_Window = new W_Base_BB_List();
        cur_Open_Window.SetParentWindow(self);
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.KuCun.TongJiFenXi.Base.W_Base_BB_List" + "&opFlag=KC" + "&FunID=" + curCdbh + "&bbfl=" + curBbmc + "&dataObject=dw_pub_all_report_format_hz"), cur_Open_Window, null);

        if (curOptype == "1" && curBBMCNew.length > 0) {
            sle_formatname.SetText(curBBMCNew);
            self.ClearAndTJ(true);
        } else {
            sle_formatname.SetText("");
            curBBPZH = "";
        }
        //刷新
    }
    //#endregion 

    //#region 格式保存#报表格式清空
    this.ReportClare = function () {
        var tempPzh = "";
        if (curDw_format_hz.RowCount() > 0) {
            tempPzh = curDw_format_hz.GetItemString("1", "pzh");
        }
        //        if (tempPzh.length <= 0 || sle_formatname.GetText().length <= 0) {
        //            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
        //            return;
        //        }
        curDw_format_mx.Reset();
        curDw_format_hz.Reset();
        sle_formatname.SetText("");
        self.TongJi();
    }
    this.ClearAndTJ = function (isTj) {
        curDw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.SetFilter("mrgxtj='1'");
        curDw_format_mx.Filter();
        xsmrgs = curDw_format_mx.RowCount();
        //界面控制
        evealStr = "";
        for (var i = 1; i <= curDw_format_mx.RowCount(); i++) {
            evealStr += curDw_format_mx.GetItemString(i, "col") + ".SetChecked(true);";
        }
        eval(evealStr);

        curDw_format_mx.SetFilter("");
        curDw_format_mx.Filter();
        curDw_format_mx.SetFilter("mrgxtj='0'");
        curDw_format_mx.Filter();
        if (isTj == true) {
            //self.TongJi();
            if (curDw_format_mx.RowCount() <= 0) {
                sle_formatname.SetText("");
            }
        }
    }
    //#endregion

    //#region 横向/纵向

    this.SetBbfl = function (bbfl) {
        if (bbfl == "rb_sp") {
        }

    }
    //#endregion

    //#region 保存
    this.SaveGS = function () {
        self.SelectBBFL();

        //curBBMCNew = "";
        if (curBbmc.length > 0) {
            cur_Open_Window = new W_Base_SaveOP();
            cur_Open_Window.SetParentWindow(self, curCdbh);
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.KuCun.TongJiFenXi.Base.W_Base_SaveOP" + "&opFlag=CG" + "&Bbfl=" + curBbmc + "&dataObject=dw_kctjfx_top"), cur_Open_Window, null);
        }
        if (curBBMCNew.length <= 0 || curOptype != 0) {
            return;
        }
        sle_formatname.SetText(curBBMCNew);
        self.ReportSave();
    }
    //#endregion

    //#region 获取报表分类
    this.SelectBBFL = function () {

            curBbmc = "rb_sp";


    }
    //#endregion 

    //#region 提交
    this.ReportSave = function () {
        //self.PropertCheckStatus();
        var msg = ReportSaveEx(dw_list, curDw_format_hz, curDw_format_mx, curUserId, curCdbh, curBbmc, curBBPZH, curYhbh, curBBMCNew, "", "", isFirstSave);
        if (msg == "OK") {
            requestor.MessageBox("提示", "保存成功", ICON.Information);
            curDw_format_mx.ResetUpdate();
            curDw_format_mx.SetFilter("mrgxtj='1'");
            curCol = requestor.GetParm("curCol");
            curDw_format_mx.Filter();
            xsmrgs = curDw_format_mx.RowCount();
            curDw_format_mx.SetFilter("");
            curDw_format_mx.Filter();
            curDw_format_mx.SetFilter("mrgxtj='0'");
            curDw_format_mx.Filter();
            self.TongJi();
            return;
        }
        else {
            requestor.MessageBox("提示", msg, ICON.StopSign);
        }
    }
    //#endregion


    //#region 定义title高度
    this.A8erp_Report_Header_Row_Height = function (curDw_List, curSingleFlag) {
        if (curSingleFlag) {
            curDw_List.Modify("datawindow.header.height='76'");
        }
    }
    //#endregion

    //#region 定义detail高度
    this.A8erp_Report_Detail_Row_Height = function (curDw_List) {
        curDw_List.Modify("datawindow.detail.height='76'");
    }
    //#endregion

    //#region 定义单据样式

    this.A8erp_Report_Style = function (curDw_List) {//67108864    15780518
        curDw_List.Modify("datawindow.detail.color='67108864' datawindow.detail.gradient.color='16777215' datawindow.detail.brushmode='1' ")
    }
    //#endregion

    //#region FormatSave
    this.FormatSave = function () {
        curDw_format_mx.SetRedraw(false);
        curDw_format_mx.SetSort("col_x A");
        curDw_format_mx.Sort();
        for (var i = 1; i <= curDw_format_mx.RowCount(); i++) {
            var curCol = curDw_format_mx.GetItemString(i, "col");
            var curVisible = curDw_format_mx.GetItemString(i, "visible");
            dw_list.Modify(curCol + ".visible='0'");
            dw_list.Modify(curCol + ".visible='" + curVisible + "'");
            var curWidth = curDw_format_mx.GetItemNumber(i, "width");
            dw_list.Modify(curCol + ".width='" + curWidth + "'");
            var curColHz = curDw_format_mx.GetItemString(i, "col_hz");
            dw_list.Modify(curCol + "_t.Text='" + curColHz + "'");
            var curfont_face = curDw_format_mx.GetItemString(i, "font_face");
            dw_list.Modify(curCol + ".Font.Face='" + curfont_face + "'");

            var curfont_height = curDw_format_mx.GetItemString(i, "font_height");
            dw_list.Modify(curCol + ".Font.Height='" + curfont_height + "'");

            var curfont_weight = curDw_format_mx.GetItemString(i, "font_weight");
            dw_list.Modify(curCol + ".Font.Weight='" + curfont_weight + "'");

            var curfont_italic = curDw_format_mx.GetItemString(i, "font_italic");
            dw_list.Modify(curCol + ".Font.Italic='" + curfont_italic + "'");

            var curfont_underline = curDw_format_mx.GetItemString(i, "font_underline");
            dw_list.Modify(curCol + ".Font.Underline='" + curfont_underline + "'");

            var curCol_border = curDw_format_mx.GetItemString(i, "col_border");
            dw_list.Modify(curCol + ".Border='" + curCol_border + "'");

            var ls_color = curDw_format_mx.GetItemString(i, "color");
            dw_list.Modify(curCol + ".Color='" + curCol_border + "'");

            var ls_format = curDw_format_mx.GetItemString(i, "format");
            dw_list.Modify(curCol + ".Format='" + ls_format + "'");

            var ls_alignment = curDw_format_mx.GetItemString(i, "alignment");
            dw_list.Modify(curCol + ".Alignment='" + ls_alignment + "'");

            var ls_alignment = curDw_format_mx.GetItemString(i, "tabsequence");
            dw_list.Modify(curCol + ".TabSequence='" + ls_alignment + "'");

            var li_bg_mode = curDw_format_mx.GetItemString(i, "bg_mode");
            dw_list.Modify(curCol + ".Background.Mode='" + li_bg_mode + "'");

            var ls_bg_color = curDw_format_mx.GetItemString(i, "bg_color");
            dw_list.Modify(curCol + ".Background.Color='" + ls_bg_color + "'");
        }
        curDw_format_mx.SetRedraw(true);
        //#endregion
    }

    //#endregion

    //#region 格式保存#报表列格式操作
    this.ReportOp = function () {
        if (curBBPZH.length <= 0 || sle_formatname.GetText().length <= 0) {
            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
            return;
        }
        curW_Base_Report_Open_Mx_Ex.SetDataWindow(self, curUserId, curCdbh, curBbmc, curBBPZH, "curParent.ClearAndTJ(true);");
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.Base.W_Base_Report_Open_Mx_Ex"), curW_Base_Report_Open_Mx_Ex, null);
        curDw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
    }
    //#endregion

    //#region  执行查询
    this.TongJi = function () {
        dw_list.SetRedraw(false);
        self.Query(); //横向
        dw_list.Modify("cm1.Format='###' cm2.Format='###' cm3.Format='###' cm4.Format='###' cm5.Format='###' cm6.Format='###' cm7.Format='###' cm8.Format='###' cm9.Format='###' cm10.Format='###' cm11.Format='###' cm12.Format='###' cm13.Format='###' cm14.Format='###' cm15.Format='###' cm16.Format='###' cm17.Format='###' cm18.Format='###' cm19.Format='###' cm20.Format='###' cm21.Format='###' cm22.Format='###' cm23.Format='###' cm24.Format='###' cm25.Format='###' cm26.Format='###' cm27.Format='###' cm28.Format='###' cm29.Format='###' cm30.Format='###' cm31.Format='###' cm32.Format='###' cm33.Format='###' cm34.Format='###' cm35.Format='###'");
        if (Exel_FH_Flag == "1") {
            dw_list.Modify("DataWindow.Sparse='spkh\tksmc\tjldw\tysbh\tysmc\tbxbh\tbxmc'");
        }
        self.FormatSave();
        dw_list.SetSort("spkh,ksmc,v.ysbh,v.ysmc,v.bxbh,v.bxmc");
        dw_list.Sort();

        //self.A8erp_Report_Header_Row_Height(dw_list, true);
        //A8erp_Report.ReportDataWindowHeaderColor(dw_list);
        self.A8erp_Report_Style(dw_list);
        self.A8erp_Report_Detail_Row_Height(dw_list);
        //requestor.ClipBoard(dw_list.Describe("datawindow.syntax"))
        if (rb_mx.GetChecked()) {
            dw_list.Modify("DataWindow.Sparse='pzh\tdjmc\tjzsj\trq\tkhbh\tkhmc\tbmbh\tbmmc\tskfs\tsklx\tckfs\tlydh'");
            
        }
        dw_list.SetRedraw(true);
    }
    //#endregion

    //#region  SetValue
    this.SetValue = function (str1, str2, str3, str4) {

        ChildDWCheckValue = str1;
        curBbmc = str2;
        curCdbh = str3;
        curUserId = str4;
    }
    //#endregion



    //#region 图片预览
    this.picpreview = function () {
        var cloumCount = 0;
        var cloumName = "";
        cloumCount = parseInt(dw_list.Describe("datawindow.column.count"));
        for (var i = 1; i <= cloumCount; i++) {
            cloumName += dw_list.Describe("#" + String(i) + ".name")
        }
        if (cloumName.indexOf("spkh") > -1) {
            var curRow = dw_list.GetRow();
            //图片的跳转
            if (curRow > 0) {
                var curspkh = dw_list.GetItemString(curRow, "spkh")
                var picuploadflag = 0;
                curW_KC_PIC.SetDataWindow(dw_list, curspkh, self, picuploadflag, "");
                requestor.Open("/Service/LoadWindow.ashx?WinName= A8ERP.KuCun.TongJiFenXi.W_KC_PIC&curSpkh=" + curspkh, curW_KC_PIC);
            }
        } else {
            requestor.MessageBox("提示", "此页面不支持预览图片!", ICON.Information);
        }


    }
    //#endregion

    //#region 右键保存
    this.RightKey = function () {
        if (sle_formatname.GetText().toString().length > 0) {
            self.ReportSave();
        }
        else {
            requestor.MessageBox("提示", "请选择格式后再保存!", ICON.Information);
        }
    }
    //#endregion


    this.Exit = function () {
        setTimeout("window.close()", 100);
    }



    //#region this.setJGJqd
    this.setJGJqd = function (row, lsj) {
        var jg = 0;
        if (lsj < 0) {
            jg = GetAccSub(lsj, jqd);
        } else {
            jg = GetAccAdd(lsj, jqd);
        }

        var len = (jg.toString()).split(".")[0].length + 1 + jqw;
        var zhjg = parseFloat((jg.toString()).substring(0, len));
        // dw_list.SetItem(row, "sjje", zhjg);
        return zhjg;
    }
    //#endregion
}

//W_CW_KHDZD_Main.prototype = new W_CG_HZ_Base();