Ext.namespace('Shipping'); Shipping.RptCwGLIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.RptCwGLIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.RptCwGLIndex, Ext.Panel, { PageSize: 1000, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', strCwSTARTGID: '', initUIComponents: function () { this.formname = "formRptCwGLIndex"; //科目总账 //#region formSearch 下拉框信息加载 //科目加载 this.storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems.load({ params: { condition: "ISENABLE=1" }, callback: function (options, success, response) { var data = { "GID": "", "ACCID": "", "ACCNAME": "", "ACCIDNAME": "", "DETAILED": "", "DC": "", "ISFCY": "", "ISDEPTACC": "", //核算部门,按规则设置生成 "ISEMPLACC": "", //核算人员,按规则设置生成 "ISCORPACC": "", //核算客户,按规则设置生成 "ISITEMACC": "", //核算项目,按规则设置生成 "REMARKS": "", "YEAR": "", "MONTH": "", "PACCGID": "", "ACCATTRIBUTE": "", //科目属性(资产、负债、共同、权益、成本、损益) //"ISENABLE": "", "id": "", "NAME": "", "ACCTYPE": "", //科目类别 "leaf": "", "expanded": "", "DR": "", "CR": "", "PACCNAME": "" }; this.storeCwAccitems.insert(0, data); }, scope: this }); this.comboxACCNAME = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '科目名称', store: this.storeCwAccitems, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'ACCID', name: 'ACCID', valueField: 'ACCID', displayField: 'ACCIDNAME', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }); //币别 this.storeCodeCurrency = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeCurrencyModel', proxy: { url: '/MvcShipping/RptCwGL/GetCodeCurrencyList' } }); this.storeCodeCurrency.load(); this.comboxCodeCurrency = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.storeCodeCurrency, forceSelection: true, name: 'CURRENCY', valueField: 'CODENAME', displayField: 'CODENAME', value: '综合本位币', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }); //#endregion //#region 定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'RptCwGLModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/RptCwGL/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //#endregion //#region 定义列 this.girdcolums = [{ sortable: true, dataIndex: 'GID', header: '唯一编码', width: 0 }, { sortable: true, dataIndex: 'LINKCODE', header: '科目代码', width: 120 }, { sortable: false, dataIndex: 'LINKNAME', header: '科目名称', width: 300 }, { sortable: false, dataIndex: 'ACCDATE', header: '会计期间', align: 'center', width: 60 }, { sortable: false, dataIndex: 'EXPLAN', header: '摘要', align: 'center', width: 80 }, { sortable: true, dataIndex: 'DR', header: '借方', align: 'right', width: 100, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CR', header: '贷方', align: 'right', width: 100, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'DC', header: '方向', align: 'center', width: 30 }, { sortable: true, dataIndex: 'BLC', header: '余额', align: 'right', width: 100, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }]; //#endregion //#region List列表显示信息 Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, enableHdMenu: false, //是否显示表格列的菜单 stripeRows: true, //斑马线效果 rowLines: true, columnLines: true, columns: this.girdcolums, viewConfig: { enableTextSelection: true, //允许复制数据 autoFill: true }, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridList.reconfigure(this.storeList, this.girdcolums); //this.gridList.columns[0] = new Ext.grid.RowNumberer(); //////////////////////////////////////////////// //#endregion //#region formSearch 查询面板 this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 60, msgTarget: 'qtip' }, items: [{//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '会计期间', xtype: 'monthfield', editable: false, allowBlank: false, //是否允许为空 id: 'ACCDATEbgn', name: 'ACCDATEbgn', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { fieldLabel: '至', labelWidth: 20, xtype: 'monthfield', editable: false, allowBlank: false, //是否允许为空 id: 'ACCDATEend', name: 'ACCDATEend', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, this.comboxCodeCurrency, this.comboxACCNAME] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: "checkbox", //checkbox控件 id: "cbHSKM", name: "cbHSKM", boxLabel: "包括核算科目", fieldLabel: "", inputValue: "true", //选中的值 uncheckedValue: "false" //未选中的值 //checked: true //绘制时的选中状态 }, { xtype: "checkbox", //checkbox控件 id: "cbZKM", name: "cbZKM", boxLabel: "包括子科目", fieldLabel: "", inputValue: "true", //选中的值 uncheckedValue: "false" //未选中的值 //checked: true //绘制时的选中状态 }, { xtype: "checkbox", //checkbox控件 id: "cbJZFS", name: "cbJZFS", boxLabel: "包括余额和本期发生额均为零的科目", fieldLabel: "", inputValue: "true", //选中的值 uncheckedValue: "false" //未选中的值 //checked: true //绘制时的选中状态 }, { xtype: 'hiddenfield'}] }] }]//end items(fieldset 1) }); //#endregion formSearch //#region 按钮工具条 this.CheckSaveQuery = new Ext.form.Checkbox({ fieldLabel: '记忆查询条件', checked: true, width: 120 }); this.panelBtn = new Ext.Panel({ region: "center", border: false, tbar: [{ text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); var isvisible = false; var issavevalue = false; if (this.CheckSaveQuery.checked) { issavevalue = true } saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, '-', { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick2(button, event); }, scope: this }, { text: "打印", iconCls: 'btnprint', handler: function (button, event) { this.Print(); }, scope: this }, '-', this.CheckSaveQuery] }); //#endregion //#region 页面布局 this.panelZQ = new Ext.Panel({ layout: "border", region: "east", width: 500, style: 'text-align:right;', border: false, items: [{ xtype: 'displayfield', id: 'lbTitle2', name: 'lbTitle2', value: "  " }] }); this.panelTopF = new Ext.Panel({ layout: "border", region: "north", height: 26, //border: false, items: [this.panelBtn, this.panelZQ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 95, border: false, items: [this.panelTopF, this.formSearch] }); Ext.apply(this, { border: false, items: [this.panelTop, this.gridList] }); //this.onRefreshClick(); //#endregion //#region 页面加载 this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); var ACCDATEbgn = this.getACCDATEbgn(); var ACCDATEend = this.getACCDATEend(); var strCbHSKM = this.getCbHSKM(); var strCURRENCY = this.getCURRENCY(); if (sql.toString() != "") { Ext.apply(store.proxy.extraParams, { condition: sql, ACCDATEbgn: ACCDATEbgn, ACCDATEend: ACCDATEend, strCbHSKM: strCbHSKM, strCURRENCY: strCURRENCY }); } }, this); // this.storeList.on('refresh', function (store) { //mergeCells(this.gridList, [1, 2, 3, 7]); // 加载完成后,执行函数 mergeCells(this.gridList, [2, 3, 4, 8]); // 加载完成后,执行函数 }, this) //加载事件 this.InitData(); LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery); //#endregion }, //end initUIComponents //#region 加载事件 InitData: function () { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/RptCwGenlegAccitems/GetData', callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { return; } data = result.data; var arrtmp = data.toString().split("&"); this.strCwSTARTGID = arrtmp[0].toString(); var strCwSTARTNAME = arrtmp[1].toString(); var strCwACCDATE = arrtmp[2].toString(); var sYear = arrtmp[3].toString(); var sMonth = arrtmp[4].toString(); // var sZQ = "  当前登录账套:“" + strCwSTARTNAME + "”  当前财务账期:“" + sYear + "年第" + sMonth + "期”  "; Ext.getCmp("lbTitle2").setValue(sZQ); Ext.getCmp("ACCDATEbgn").setValue(strCwACCDATE); Ext.getCmp("ACCDATEend").setValue(strCwACCDATE); // this.onRefreshClick(); } else { //Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, async: false, scope: this }); }, //end InitData //#endregion //#region 执行查询 onRefreshClick: function (button, event) { //var girdcolums = this.gridList.getColumnMode(); var sql = this.getCondition(); var ACCDATEbgn = this.getACCDATEbgn(); var ACCDATEend = this.getACCDATEend(); var strCbHSKM = this.getCbHSKM(); var strCURRENCY = this.getCURRENCY(); if (sql.toString() != "") { this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql, ACCDATEbgn: ACCDATEbgn, ACCDATEend: ACCDATEend, strCbHSKM: strCbHSKM, strCURRENCY: strCURRENCY }, waitMsg: "正在查询数据...", scope: this }); } }, //#endregion //#region 查询 getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; //#region formSearch 查询面板 //会计期间 var ACCDATEbgn = form.findField('ACCDATEbgn').getRawValue(); var ACCDATEend = form.findField('ACCDATEend').getRawValue(); if (ACCDATEbgn.toString() == "" || ACCDATEend.toString() == "") { alert('请先选择会计期间!'); return ''; } sql = sql + getAndConSql(sql, ACCDATEbgn, "ACCDATE>='" + ACCDATEbgn + "'"); sql = sql + getAndConSql(sql, ACCDATEend, "ACCDATE<='" + ACCDATEend + "'"); var sACCID = this.formSearch.getForm().findField('ACCID').getValue(); if (sACCID != null) { if (sACCID != "") { sql = sql + getAndConSql(sql, sACCID, "LINKGID in (select GID from cw_accitems_gl where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4) and ACCID like '" + sACCID + "%')"); } } // var LINKCODE = form.findField('LINKCODE').getValue(); // sql = sql + getAndConSql(sql, LINKCODE, "LINKGID in (select GID from cw_accitems_gl where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4) and ACCID like '%" + LINKCODE + "%')"); // var LINKNAME = form.findField('LINKNAME').getValue(); // sql = sql + getAndConSql(sql, LINKNAME, "LINKGID in (select GID from cw_accitems_gl where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4) and ACCNAME like '%" + LINKNAME + "%')"); var strCbJZFS = form.findField('cbJZFS').getValue(); if (!strCbJZFS) { sql = sql + " and (QTYLASTBLC<>0 OR QTYDR<>0 OR QTYCR<>0 or QTYLASTDR<>0 or QTYLASTCR<>0)"; } //#endregion formSearch return sql; }, getACCDATEbgn: function () { var form = this.formSearch.getForm(); //会计期间 var ACCDATEbgn = form.findField('ACCDATEbgn').getRawValue(); if (ACCDATEbgn.toString() == "") { alert('请先选择会计期间!'); return ''; } ACCDATEbgn = " and ACCDATE='" + ACCDATEbgn + "'"; return ACCDATEbgn; }, getACCDATEend: function () { var form = this.formSearch.getForm(); //会计期间 var ACCDATEend = form.findField('ACCDATEend').getRawValue(); if (ACCDATEend.toString() == "") { alert('请先选择会计期间!'); return ''; } ACCDATEend = " and ACCDATE='" + ACCDATEend + "'"; return ACCDATEend; }, getCbHSKM: function () { var form = this.formSearch.getForm(); var ACCDATEbgn = form.findField('ACCDATEbgn').getRawValue(); var strCbHSKM = form.findField('cbHSKM').getValue(); var strCbZKM = form.findField('cbZKM').getValue(); if (strCbHSKM) { if (strCbZKM) { strCbHSKM = " and (LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4)) or DEPTACC<>'' or EMPLACC<>'' or CORPACC<>'' or ITEMACC<>'')"; } else { strCbHSKM = " and (LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4) and (PACCGID='zc' or PACCGID='FZ' or PACCGID='QY' or PACCGID='CB' or PACCGID='SY')) or DEPTACC<>'' or EMPLACC<>'' or CORPACC<>'' or ITEMACC<>'')"; } } else { if (strCbZKM) { strCbHSKM = " and LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4))"; } else { strCbHSKM = " and LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + ACCDATEbgn + "',1,4) and (PACCGID='zc' or PACCGID='FZ' or PACCGID='QY' or PACCGID='CB' or PACCGID='SY'))"; } } return strCbHSKM; }, getCURRENCY: function () { var form = this.formSearch.getForm(); var strCURRENCY = form.findField('CURRENCY').getValue(); return strCURRENCY; }, //#endregion //#region 重置条件 onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); this.InitData(); }, //onDeleteClick //#endregion //#region 导出Excel onExportClick: function (button, event) { if (this.storeList.getCount() == 0) { return; } var ACCDATEbgn = this.getACCDATEbgn(); var ACCDATEend = this.getACCDATEend(); var strCbHSKM = this.getCbHSKM(); var strCURRENCY = this.getCURRENCY(); //Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据, 请稍侯...', url: '/MvcShipping/RptCwGL/GetDataListSQL', params: { condition: this.sqlcontext, ACCDATEbgn: ACCDATEbgn, ACCDATEend: ACCDATEend, strCbHSKM: strCbHSKM, strCURRENCY: strCURRENCY, printstr: 'true' }, callback: function (options, success, response) { if (success) { var ddd = Ext.MessageBox.isVisible(); if (Ext.MessageBox.isVisible()) { Ext.MessageBox.hide(); } var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnStr = jsonresult.data; if (returnStr.toString() != "") { var openSet = "height=1, width=400, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=" + (screen.height - 200) / 2 + ",Left=" + (screen.width - 400) / 2; var openType = "_blank"; var condition1 = returnStr.toString().replace(/\+/g, "%2B"); //将+号替换为十六进制 condition1 = escape(condition1); var openUrl = "../../Reports/RptExport.aspx?handle=RptCwGLIndex&formname=" + this.formname + "&condition1=" + condition1; window.open(openUrl, openType, openSet); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } }, scope: this }); }, //ExtJs 自带的导出当前页的excel导出函数 onExportClick2: function (button, event) { GridExportExcelPage(this.gridList); }, //#endregion //#region 打印 Print: function () { if (this.storeList.getCount() == 0) { return; } var ACCDATEbgn = this.getACCDATEbgn(); var ACCDATEend = this.getACCDATEend(); var strCbHSKM = this.getCbHSKM(); var strCURRENCY = this.getCURRENCY(); var sACCID = this.formSearch.getForm().findField('ACCID').getValue(); var ACCDATEFR = this.formSearch.getForm().findField('ACCDATEbgn').getRawValue(); var ACCDATETO = this.formSearch.getForm().findField('ACCDATEend').getRawValue(); //Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据, 请稍侯...', url: '/MvcShipping/RptCwGL/GetDataListStr', params: { condition: this.sqlcontext, ACCDATEbgn: ACCDATEbgn, ACCDATEend: ACCDATEend, strCbHSKM: strCbHSKM, strCURRENCY: strCURRENCY, printstr: 'true' }, callback: function (options, success, response) { if (success) { var ddd = Ext.MessageBox.isVisible(); if (Ext.MessageBox.isVisible()) { Ext.MessageBox.hide(); } var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnStr = jsonresult.data; var printType = 'RptCwGLList'; var sql1 = returnStr; var sql2 = "select '" + ACCDATEFR + "' ACCDATEFR,'" + ACCDATETO + "' ACCDATETO,'" + strCURRENCY + "' CURRENCY,'" + sACCID + "' ACCID"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } }, scope: this }); }, //#endregion OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });