Ext.namespace('Shipping'); String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); } Shipping.MsCwVouchersGlIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCwVouchersGlIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCwVouchersGlIndex, Ext.Panel, { PageSize: 500, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', strCwSTARTGID: '', initUIComponents: function () { this.formname = "formMsCwVouchersGlIndex"; //总账凭证列表 //#region formSearch 下拉框信息加载 //键值维护表_凭证字 this.storeCrmKeyCodeCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CrmKeyCodeModel', proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' } }); this.storeCrmKeyCodeCode.load({ params: { condition: " and KEYTYPE='凭证字'"} }); this.comboxVKNO = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '凭证字', store: this.storeCrmKeyCodeCode, forceSelection: true, name: 'VKNO', width: 100, labelAlign: 'right', //labelWidth: 40, valueField: 'KEYVALUE', displayField: 'KEYVALUE', value: '记', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } //allowBlank: false, }); //审核状态 Ext.define('ISCHECKEDModel', { extend: 'Ext.data.Model', fields: [ { name: 'Name', type: 'string' } ] }); var dataISCHECKED = [{ "Name": "未审核" }, { "Name": "审核" }, { "Name": ""}]; var storeISCHECKED = Ext.create('Ext.data.Store', { model: 'ISCHECKEDModel', data: dataISCHECKED }); this.comboxISCHECKED = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '审核', forceSelection: true, store: storeISCHECKED, id: 'ISCHECKED2', name: 'ISCHECKED2', width: 100, labelAlign: 'right', //labelWidth: 30, valueField: 'Name', displayField: 'Name', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }); //导出状态 Ext.define('ISEXPORTModel', { extend: 'Ext.data.Model', fields: [ { name: 'Name', type: 'string' } ] }); var dataISEXPORT = [{ "Name": "未导出" }, { "Name": "已导出" }, { "Name": ""}]; var storeISEXPORT = Ext.create('Ext.data.Store', { model: 'ISEXPORTModel', data: dataISEXPORT }); this.comboxISEXPORT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '导出', forceSelection: true, store: storeISEXPORT, id: 'ISEXPORT', name: 'ISEXPORT', flex:1, labelAlign: 'right', //labelWidth: 30, valueField: 'Name', displayField: 'Name', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }); //制单人 this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.comboxZhiDanRen = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: "制单人", store: this.storeOpCode, // forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'PREPARED', flex: 1, valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeOpCode.load(); //#endregion //#region formSearch 查询面板 this.formSearch = Ext.widget('form', { frame: true, region: 'center', border: false, 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.comboxVKNO, { id: 'EXPLAN2', fieldLabel: '摘要', labelAlign: 'right', //labelWidth: 30, name: 'EXPLAN2', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, this.comboxISCHECKED] }, { xtype: 'container', layout: 'hbox', flex:1, defaultType: 'textfield', items: [{ name: 'AMTDRCRbgn', fieldLabel: '金额范围', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { fieldLabel: '至', //labelWidth: 20, name: 'AMTDRCRend', flex: 1, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { id: 'VOUNO_NO', fieldLabel: '凭证号', labelAlign: 'right', //labelWidth: 40, name: 'VOUNO_NO', flex: 1, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, this.comboxISEXPORT, this.comboxZhiDanRen] }]//end items(fieldset 1) }]//end root items }); var _this = this; this.formSearch2 = Ext.widget('form', { frame: true, region: "west", border: false, width: 80, items: [{ xtype: 'radiogroup', id: 'rdLBYS', name: 'rdLBYS', //fieldLabel: '列表样式', //flex: 2, columns: 1, //vertical: true, horizontal: true, items: [ { id: 'rdoHJ', boxLabel: '合计列', name: 'OBJNUM', inputValue: '合计列' }, { id: 'rdoMX', boxLabel: '明细列', name: 'OBJNUM', inputValue: '明细列', checked: true}// ], listeners: { change: function (rd, newValue, oldValue, eOpts) { saveQuerySetting(_this.formname, _this.formSearch2, false, true); _this.onRefreshClick(); if (newValue.OBJNUM.toString() == "合计列") { _this.gridListHJ.show(); //显示按钮 _this.gridList.hide(); //隐藏按钮 } else { _this.gridList.show(); //显示按钮 _this.gridListHJ.hide(); //隐藏按钮 } } } }]//end root items }); //#endregion formSearch //#region 合计列 //#region 定义数据集 //列表加载 this.storeListHJ = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsCwVVModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCwVouchersGl/GetDataListHJ', reader: { id: 'ORDNO', root: 'data', totalProperty: 'totalCount' } } }); //#endregion //#region 列定义 this.GridCheckBoxModelHJ = Ext.create('Ext.selection.CheckboxModel'); this.girdcolumsHJ = [{ sortable: false, dataIndex: 'ORDNO', header: '', //唯一编码 hidden: true, width: 0 }, { sortable: false, dataIndex: 'VOUALLNO', header: '', //凭证号 hidden: true, width: 0 }, { sortable: false, dataIndex: 'VOUDATE', header: '凭证日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), align: 'center', width: 100 }, { sortable: false, dataIndex: 'VKNO', header: '凭证字', align: 'center', width: 50 }, { sortable: false, dataIndex: 'VOUNO', header: '凭证号', align: 'center', width: 50 }, { sortable: false, dataIndex: 'AMTDR', header: '本位币借方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'AMTCR', header: '本位币贷方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'FCYDR', header: '外币借方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'FCYCR', header: '外币贷方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'QTYDR', header: '综合本位币借方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'QTYCR', header: '综合本位币贷方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'PREPARED', header: '制单人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'MODIFIEDUSERNAME', header: '改单人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'CHECKED', header: '审核人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'ATTACHS', header: '附单据数', align: 'center', width: 60 }, { sortable: false, dataIndex: 'ISEXPORT', header: '导出凭证', //是否 xtype: "booleancolumn", align: 'center', width: 60, trueText: "是", falseText: " " }, { sortable: false, dataIndex: 'ISCHECKED', header: '', //是否审核 hidden: true, width: 0 }]; //#endregion //#region gridList列表显示信息 this.gridListHJ = new Ext.grid.GridPanel({ store: this.storeListHJ, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, columns: this.girdcolumsHJ, selModel: this.GridCheckBoxModelHJ, columnLines: true, //是否显示列分割线,默认为false iconCls: 'icon-grid', renderTo: Ext.getBody(), bbar: Ext.create('Ext.PagingToolbar', { store: this.storeListHJ, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.gridListHJ.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsCwVouchersGl/Edit', "凭证录入", "", "940", "10", "10"); }, this); //#endregion //#endregion //#region 明细列 //#region 定义数据集 //权限范围 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', //proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' } }); this.StoreOpRange.load({ params: { optype: "MsCwVouchersGlCHECKED"} }); this.StoreOpRange2 = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', //proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' } }); this.StoreOpRange2.load({ params: { optype: "MsCwVouchersGlNotCHECKED"} }); //列表加载 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsCwVVModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCwVouchersGl/GetDataCwVVList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } //,autoLoad: true //自动加载 }); //#endregion //#region 列定义 //Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.girdcolums = [{ sortable: false, dataIndex: 'GID', header: '', //唯一编码 hidden: true, width: 0 }, { sortable: false, dataIndex: 'VOUALLNO', header: '', //凭证号 hidden: true, width: 0 }, { sortable: false, dataIndex: 'VOUDATE', header: '凭证日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), align: 'center', width: 100 }, { sortable: false, dataIndex: 'VKNO', header: '凭证字', align: 'center', width: 50 }, { sortable: false, dataIndex: 'VOUNO', header: '凭证号', align: 'center', width: 50 }, { sortable: false, dataIndex: 'EXPLAN', header: '摘要', //align: 'center', width: 300 }, { sortable: false, dataIndex: 'ACCALL', header: '会计科目', //align: 'center', width: 200 }, { sortable: false, dataIndex: 'AMTDR', header: '借方金额', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { //return '' + value + ''; //return Ext.util.Format.number(value, '0,000.00'); //var fff = Ext.util.Format.number(value, '0,000.00') + ".00"; value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'AMTCR', header: '贷方金额', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { //return Ext.util.Format.number(value, '0,000.00'); //var fff = Ext.util.Format.number(value, '0,000.00') + ".00"; value = usMoney(value, 2, '', true); return value; } }, { sortable: false, dataIndex: 'PREPARED', header: '制单人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'MODIFIEDUSERNAME', header: '改单人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'CHECKED', header: '审核人', align: 'center', width: 80 }, { sortable: false, dataIndex: 'ATTACHS', header: '附单据数', align: 'center', width: 60 }, { sortable: false, dataIndex: 'ISEXPORT', header: '导出凭证', //是否 xtype: "booleancolumn", align: 'center', width: 60, trueText: "是", falseText: " " }, { sortable: false, dataIndex: 'ORDNO', header: '', //唯一编码 hidden: true, width: 0 }, { sortable: false, dataIndex: 'ISCHECKED', header: '', //是否审核 hidden: true, width: 0 }]; //#endregion //#region gridList列表显示信息 this.gridList = new Ext.grid.GridPanel({ store: this.storeList, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, columns: this.girdcolums, selModel: this.GridCheckBoxModel, columnLines: true, //是否显示列分割线,默认为false iconCls: 'icon-grid', renderTo: Ext.getBody(), viewConfig: { enableTextSelection: true, //允许复制数据 autoFill: true }, 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[1] = new Ext.grid.RowNumberer(); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsCwVouchersGl/Edit', "凭证录入", "", "940", "10", "10"); }, this); //#endregion //#endregion //#region 按钮工具条/页面布局 this.panelBtn = new Ext.Panel({ layout: "border", region: "center", border: false, tbar: [{ text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/MvcShipping/MsCwVouchersGl/Edit', "凭证录入", "", "940", "10", "10"); }, scope: this }, '-', { text: "查询", id: "btnRefresh", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, '-', { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, { text: "导出", id: "btnExportExcel", iconCls: 'btnexportexcel', menu: [{ text: "合计列表", handler: function (menu, event) { _this.onExportClick(1); } }, { text: "明细列表", handler: function (menu, event) { _this.onExportClick(2); } }, { text: "财务软件", handler: function (menu, event) { _this.onExportClick3(); } }], scope: this }, { text: '打印', tooltip: '打印', id: "btnprint", iconCls: "btnprint", menu: [{ text: "合计列表", handler: function (menu, event) { _this.Print(1); } }, { text: "明细列表", handler: function (menu, event) { _this.Print(2); } }], scope: this }, '-', { text: "审核", iconCls: "btislock", handler: function (button, event) { this.setISCHECKED(1); }, scope: this }, { text: "返审", iconCls: "btnotislock", handler: function (button, event) { this.setISCHECKED(0); }, scope: this }] }); 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: 100, border: false, items: [this.panelTopF, this.formSearch2, this.formSearch] }); Ext.apply(this, { border: false, items: [this.panelTop, this.gridList, this.gridListHJ] }); //#endregion //#region 页面加载 this.gridList.show(); //显示按钮 this.gridListHJ.hide(); //隐藏按钮 this.InitData(); //#endregion //#region 下载窗体 this.formDownloadShow = Ext.widget('form', { frame: true, region: 'center', height: 100, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [{ xtype: 'container', defaultType: 'textfield', layout: 'anchor', id: 'downloadfile', defaults: { anchor: '100%' }, items: [{ xtype: 'label', html: '', width: 120, text: '' }] }] }); me = this; this.winDownloadShow = Ext.create('Ext.window.Window', { title: "下载文件", width: 450, height: 120, //plain : true, iconCls: "addicon", resizable: false, // draggable:false,// 是否可以拖动 collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formDownloadShow], buttons: [{ text: "关闭", minWidth: 70, handler: function () { me.winDownloadShow.close(); } }] }); //#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(); // Ext.getCmp("ACCDATEbgn").setValue(strCwACCDATE); Ext.getCmp("ACCDATEend").setValue(strCwACCDATE); var sZQ = "  当前登录账套:“" + strCwSTARTNAME + "”  当前财务账期:“" + sYear + "年第" + sMonth + "期”  "; Ext.getCmp("lbTitle2").setValue(sZQ); LoadQueryData(this.formname, this.formSearch2, this.CheckSaveQuery); // this.storeListHJ.on('beforeload', function (store) { var sql = this.getCondition(); this.sqlcontext = sql; if (sql.toString() != "") { Ext.apply(store.proxy.extraParams, { condition: sql }); } }, this); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); this.sqlcontext = sql; if (sql.toString() != "") { Ext.apply(store.proxy.extraParams, { condition: sql }); } }, this); // this.storeList.on('refresh', function (store) { mergeCells(this.gridList, [2, 3, 4, 5, 10, 11, 12, 13, 14, 0]); // 加载完成后,执行函数 }, this) this.onRefreshClick(); } else { //Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, //end InitData //#endregion //#region 查询 onRefreshClick: function () { var sql = this.getCondition(); this.sqlcontext = sql; if (Ext.getCmp('rdLBYS').getValue().OBJNUM.toString() == "合计列") { this.storeListHJ.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在刷新数据...", timeout: 6000000, //30秒 scope: this }); } else { this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在刷新数据...", timeout: 6000000, //30秒 scope: this }); } }, getCondition: function () { var sql = ''; //凭证号 var VKNO = this.formSearch.getForm().findField('VKNO').getValue(); if (VKNO != null) { if (VKNO != "") { sql = sql + getAndConSql(sql, VKNO, "VKNO='" + VKNO.toString().trim() + "'"); } } //凭证号 var VOUNO = Ext.getCmp("VOUNO_NO").value; if (VOUNO != null) { if (VOUNO != "") { //sql = sql + getAndConSql(sql, VOUNO, "VOUNO like '%" + VOUNO.toString().trim() + "%'"); sql = sql + getAndConSql(sql, VOUNO, "VOUNO='" + VOUNO.toString().trim() + "'"); //烟台爱德林要求2016-03-22改 } } //摘要 var EXPLAN2 = Ext.getCmp("EXPLAN2").value; if (EXPLAN2 != null) { if (EXPLAN2 != "") { sql = sql + getAndConSql(sql, EXPLAN2, "EXPLAN like '%" + EXPLAN2.toString().trim() + "%'"); } } //审核状态 var ISCHECKED2 = this.formSearch.getForm().findField('ISCHECKED2').getValue(); if (ISCHECKED2 != null) { if (ISCHECKED2 == "审核") { sql = sql + getAndConSql(sql, ISCHECKED2, "ISCHECKED=1"); } else if (ISCHECKED2 == "未审核") { sql = sql + getAndConSql(sql, ISCHECKED2, "ISCHECKED=0"); } } //会计期间 //var ACCDATEbgn = Ext.getCmp("ACCDATEbgn").value; var ACCDATEbgn = this.formSearch.getForm().findField('ACCDATEbgn').getRawValue(); if (ACCDATEbgn != null) { if (ACCDATEbgn != "") { //sql = sql + getAndConSql(sql, ACCDATEbgn, "SUBSTRING(convert(char(10),VOUDATE,120),1,7) >='" + ACCDATEbgn.toString().trim() + "'"); sql = sql + getAndConSql(sql, ACCDATEbgn, "ACCDATE >='" + ACCDATEbgn.toString().trim() + "'"); } } //var ACCDATEend = Ext.getCmp("ACCDATEend").value; var ACCDATEend = this.formSearch.getForm().findField('ACCDATEend').getRawValue(); if (ACCDATEend != null) { if (ACCDATEend != "") { //sql = sql + getAndConSql(sql, ACCDATEend, "SUBSTRING(convert(char(10),VOUDATE,120),1,7) <='" + ACCDATEend.toString().trim() + "'"); sql = sql + getAndConSql(sql, ACCDATEend, "ACCDATE <='" + ACCDATEend.toString().trim() + "'"); } } //导出状态 var ISEXPORT2 = this.formSearch.getForm().findField('ISEXPORT').getValue(); if (ISEXPORT2 != null) { if (ISEXPORT2 == "已导出") { sql = sql + getAndConSql(sql, ISEXPORT2, "ISEXPORT=1"); } else if (ISEXPORT2 == "未导出") { sql = sql + getAndConSql(sql, ISEXPORT2, "ISEXPORT=0"); } } //金额范围 var AMTDRCRbgn = this.formSearch.getForm().findField('AMTDRCRbgn').getValue(); var AMTDRCRend = this.formSearch.getForm().findField('AMTDRCRend').getValue(); if (AMTDRCRbgn != null && AMTDRCRend != null) { if (AMTDRCRbgn != "" && AMTDRCRend != "") { if (Ext.getCmp('rdLBYS').getValue().OBJNUM.toString() == "合计列") { sql = sql + getAndConSql(sql, AMTDRCRbgn, "ORDNO in (select ORDNO from VW_cw_vouchers_vouitems_gl where ( (AMTDR>=" + AMTDRCRbgn.toString().trim() + " and AMTDR<=" + AMTDRCRend.toString().trim() + ") or (AMTCR>=" + AMTDRCRbgn.toString().trim() + " and AMTCR<=" + AMTDRCRend.toString().trim() + ") or (FCYDR>=" + AMTDRCRbgn.toString().trim() + " and FCYDR<=" + AMTDRCRend.toString().trim() + ") or (FCYCR>=" + AMTDRCRbgn.toString().trim() + " and FCYCR<=" + AMTDRCRend.toString().trim() + ") ))"); } else { sql = sql + getAndConSql(sql, AMTDRCRbgn, "( (AMTDR>=" + AMTDRCRbgn.toString().trim() + " and AMTDR<=" + AMTDRCRend.toString().trim() + ") or (AMTCR>=" + AMTDRCRbgn.toString().trim() + " and AMTCR<=" + AMTDRCRend.toString().trim() + ") or (FCYDR>=" + AMTDRCRbgn.toString().trim() + " and FCYDR<=" + AMTDRCRend.toString().trim() + ") or (FCYCR>=" + AMTDRCRbgn.toString().trim() + " and FCYCR<=" + AMTDRCRend.toString().trim() + ") )"); } } else { if (AMTDRCRbgn != "" || AMTDRCRend != "") { Ext.Msg.show({ title: '提示', msg: '金额范围查询,两个范围框都不允许为空!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); //Ext.Msg.hide(); return; } } } else { if (AMTDRCRbgn != null || AMTDRCRend != null) { Ext.Msg.show({ title: '提示', msg: '金额范围查询,两个范围框都不允许为空!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); //Ext.Msg.hide(); return; } } //制单人 var PREPARED = this.formSearch.getForm().findField('PREPARED').getValue(); if (PREPARED != null) { if (PREPARED != "") { sql = sql + getAndConSql(sql, PREPARED, "PREPARED like '%" + PREPARED.toString().trim() + "%'"); } } return sql; }, onClearSql: function () { //this.formSearch.getForm().findField('VKNO').setValue("记"); //this.formSearch.getForm().findField('VOUNO_NO').setValue(""); //this.formSearch.getForm().findField('ACCDATEbgn').setValue(""); //this.formSearch.getForm().findField('ACCDATEend').setValue(""); var form = this.formSearch.getForm(); form.reset(); this.InitData(); }, //#endregion //#region 删除 onDeleteClick: function (button, event) { var selections; if (Ext.getCmp('rdLBYS').getValue().OBJNUM.toString() == "合计列") { selections = this.gridListHJ.getSelectionModel().getSelection(); } else { selections = this.gridList.getSelectionModel().getSelection(); } if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // var gids = ""; var sError = ""; for (var i = 0; i < selections.length; i++) { var record = selections[i]; if (record.get('ISCHECKED').toString() != "true") { if (i == 0) { gids = record.get('ORDNO'); } else { gids += "," + record.get('ORDNO'); } } else { sError = "(注:已经审核的业务不允许删除!)"; } } // if (gids.trim() == "") { Ext.Msg.show({ title: '提示', msg: '请选择未审核业务!' + sError, icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } else { Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsCwVouchersGl/Delete', params: { gids: gids }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //this.storeList.remove(record); this.onRefreshClick(); Ext.Msg.show({ title: '提示', msg: jsonresult.Message + sError, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); } }, //#endregion //#region 审核/返审 setISCHECKED: function (iTYPE) { var selectedRecords; if (Ext.getCmp('rdLBYS').getValue().OBJNUM.toString() == "合计列") { selectedRecords = this.gridListHJ.getSelectionModel().getSelection(); } else { selectedRecords = this.gridList.getSelectionModel().getSelection(); } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // 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 iError = 0; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; var kjqj = rec.get('VOUDATE').toString().substr(0, 7); if (kjqj < strCwACCDATE) { iError++; } } if (iError > 0) { Ext.Msg.show({ title: '警告', msg: '已经结转的期间凭证,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // var sNAME = "审核"; if (iTYPE == 0) { sNAME = "返审"; if (this.StoreOpRange2.getCount() == 0) { Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } } else {//审核 if (this.StoreOpRange.getCount() == 0) { Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } } // var iOK = 0; var iSkip = 0; var strGIDs = ""; var strGIDs2 = ""; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if ((!rec.get('ISCHECKED') && sNAME == "审核")) { if (strGIDs == "") { var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', rec.get('PREPARED')); //制单人 if (records.getCount() > 0) { } else { iSkip++; continue; } // strGIDs = rec.get('ORDNO'); iOK++; } else { if (strGIDs.indexOf(rec.get('ORDNO')) < 0) { var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', rec.get('PREPARED')); //制单人 if (records.getCount() > 0) { } else { iSkip++; continue; } // strGIDs = strGIDs + "," + rec.get('ORDNO'); iOK++; } } } else if ((rec.get('ISCHECKED') && sNAME == "返审")) { if (strGIDs == "") { var records = DsStoreQueryBy(this.StoreOpRange2, 'OPID', rec.get('PREPARED')); //制单人 if (records.getCount() > 0) { } else { iSkip++; continue; } // strGIDs = rec.get('ORDNO'); iOK++; } else { if (strGIDs.indexOf(rec.get('ORDNO')) < 0) { var records = DsStoreQueryBy(this.StoreOpRange2, 'OPID', rec.get('PREPARED')); //制单人 if (records.getCount() > 0) { } else { iSkip++; continue; } // strGIDs = strGIDs + "," + rec.get('ORDNO'); iOK++; } } } else { if (strGIDs2.indexOf(rec.get('ORDNO').toString()) < 0) { strGIDs2 += "," + rec.get('ORDNO'); iSkip++; } } } // if (strGIDs.toString().trim() == "") { //Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); Ext.Msg.hide(); return; } else { Ext.MessageBox.confirm('提示', '确定' + sNAME + '吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在' + sNAME + '...'); Ext.Ajax.request({ waitMsg: '正在' + sNAME + '...', url: '/MvcShipping/MsCwVouchersGl/setISCHECKED', params: { gids: strGIDs, iTYPE: iTYPE, iOK: iOK, iSkip: iSkip }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //var msgs = '操作完成!成功:' + iOK + '条,跳过:' + iSkip + '条。'; this.onRefreshClick(); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { this.onRefreshClick(); } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); } }, this); } } else { //Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, //#endregion //#region 导出Excel onExportClick: function (iType) { var strHandle = "MsCwVouchersGlIndex"; if (iType == 1) { if (this.storeListHJ.getCount() == 0) { return; } strHandle = "MsCwVouchersGlIndexHJ"; } else if (iType == 2) { if (this.storeList.getCount() == 0) { return; } } var strGIDs = ""; var sql = escape(this.getCondition()); 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 openUrl = "../../Reports/RptExport.aspx?handle=" + strHandle + "&formname=" + this.formname + "&condition1=" + sql + "&gids=" + strGIDs; window.open(openUrl, openType, openSet); }, //ExtJs 自带的导出当前页的excel导出函数 onExportClick2: function (iType) { if (iType == 1) { if (this.storeListHJ.getCount() == 0) { return; } GridExportExcelPage(this.gridListHJ); } else { if (this.storeList.getCount() == 0) { return; } GridExportExcelPage(this.gridList); } }, //导出财务接口 onExportClick3: function () { var selections; if (Ext.getCmp('rdLBYS').getValue().OBJNUM.toString() == "合计列") { selections = this.gridListHJ.getSelectionModel().getSelection(); } else { selections = this.gridList.getSelectionModel().getSelection(); } if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // var gids = ""; if (selections.length > 0) { for (var i = 0; i < selections.length; i++) { var record = selections[i]; if (i == 0) { if (record.get('CHECKED').toString().trim() != "") { gids = record.get('ORDNO'); } } else { if (gids.indexOf(record.get('ORDNO')) < 0) { if (record.get('CHECKED').toString().trim() != "") { gids += "," + record.get('ORDNO'); } } } } } if (gids.toString().trim() == "") { Ext.Msg.show({ title: '警告', msg: '请选择已审核的凭证!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // Ext.Msg.wait('正在导出数据...'); Ext.Ajax.request({ waitMsg: '正在导出数据...', url: '/MvcShipping/MsCwVouchersGl/getIsExport', params: { condition: this.getCondition(), gids: gids }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //var sql = escape(this.getCondition()); //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 openUrl = "../../Reports/RptExport.aspx?handle=MsCwVouchersGlIndex3&formname=" + this.formname + "&condition1=" + sql + "&gids=" + gids; //window.open(openUrl, openType, openSet); //this.onRefreshClick(); //Ext.Msg.hide(); // Ext.Msg.wait('正在导出数据...'); Ext.Ajax.request({ waitMsg: '正在导出数据...', url: '/MvcShipping/MsCwVouchersGl/setExcelReportGl', params: { strCondition: this.getCondition(), gids: gids }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var downloadfile = Ext.getCmp('downloadfile'); var children = downloadfile.items; if (children) { for (var i = 0, len = children.length; i < len; i++) { downloadfile.remove(children.items[i], true); } } var downloadfiles = '' + jsonresult.Message + ''; var htmla = Ext.widget('label', { html: downloadfiles, width: 120, text: '' }); downloadfile.items.add(htmla); this.winDownloadShow.show(); // Ext.Msg.hide(); this.onRefreshClick(); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); }, //#endregion //#region 打印 Print: function (iType) { var sql = this.getCondition(); this.sqlcontext = sql; // if (iType == 1) { if (this.storeListHJ.getCount() == 0) { return; } // Ext.Ajax.request({ waitMsg: '正在组织数据, 请稍侯...', url: '/MvcShipping/MsCwVouchersGl/GetDataListStrHJ', params: { condition: sql, 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 = 'MsCwVouchersGlIndexHJ'; var sql1 = returnStr; var sql2 = ""; 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 }); } else { if (this.storeList.getCount() == 0) { return; } // Ext.Ajax.request({ waitMsg: '正在组织数据, 请稍侯...', url: '/MvcShipping/MsCwVouchersGl/GetDataListStr', params: { condition: sql, 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 = 'MsCwVouchersGlIndex'; var sql1 = returnStr; var sql2 = ""; 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 //#region 获取 YYYY-mm-dd 格式的日期 GetDateStr: function (sdate, AddDayCount) { var dd = new Date(sdate); //获取选择的时期对象 dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 sdate = dd.toISOString(); sdate = sdate.toString().substr(0, 10); return sdate; }, //#endregion OprationSwapJK: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.sqlcontext; ret[4] = Ext.getCmp('btnRefresh'); ret[5] = null; ret[6] = null; ret[7] = null; ret[8] = null; ret[9] = null; ret[10] = null; return ret; } });