Ext.namespace('Shipping'); String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); } Shipping.MsCtBankStatementIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCtBankStatementIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCtBankStatementIndex, Ext.Panel, { PageSize: 2000, SelectedRecord: null, sqlcontext: '', sCondition: '', isInitial: 0, strSTARTNAME: '', strACCDATE: '', strACCDAY: '', strACCTODAY: '', initUIComponents: function () { this.formname = "formMsCtBankStatementIndex"; //页面名称 //#region formSearch 下拉框信息加载 //银行存款科目加载 this.storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems.load({ params: { condition: "DETAILED=1 and ISENABLE=1 and ISBANK=1"} }); this.comboxACCNAME = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '银行科目', store: this.storeCwAccitems, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'ACCNAME', name: 'ACCNAME', valueField: 'ACCID', displayField: 'ACCIDNAME', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'select': function (_Field, newValue, eOpts) { if (_Field.value != null) { var sGID = ""; var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', _Field.value.toString()); if (AccitemsList.length > 0) { var AccitemsRaw = AccitemsList.getAt(0).raw; sGID = AccitemsRaw.GID.toString(); } if (sGID != "") { this.storeCwAccitemsCurrency.load({ params: { condition: "LINKGID = '" + sGID + "'" }, callback: function (options, success, response) { var combo = Ext.getCmp("FCYNO"); combo.setValue(options[0].data.CURRENCY.toString()); //选中 }, scope: this }); } } } } }); //币别选项 this.storeCwAccitemsCurrency = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsCurrencyModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsCurrencyList' } }); //this.storeCwAccitemsCurrency.load({ params: { condition: ""} }); this.comboxCwAccitemsCurrency = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.storeCwAccitemsCurrency, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'FCYNO', name: 'FCYNO', valueField: 'CURRENCY', displayField: 'CURRENCY', allowBlank: false }); //借贷方向 Ext.define('DCModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] }); var dataDC = [{ "Name": "借" }, { "Name": "贷" }, { "Name": ""}]; var storeDC = Ext.create('Ext.data.Store', { model: 'DCModel', data: dataDC }); this.comboxDC = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '方向', forceSelection: true, store: storeDC, id: 'DC', name: 'DC', valueField: 'Name', displayField: 'Name' //allowBlank: false, }); //是否对账 Ext.define('CHECKINGModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] }); var dataCHECKING = [{ "Name": "" }, { "Name": "已达" }, { "Name": "未达"}]; var storeCHECKING = Ext.create('Ext.data.Store', { model: 'CHECKINGModel', data: dataCHECKING }); this.comboxCHECKING = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '是否对账', forceSelection: true, store: storeCHECKING, name: 'CHECKING', valueField: 'Name', displayField: 'Name' //allowBlank: false, }); //时间范围 Ext.define('TimeFrameModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] }); var dataTimeFrame = [{ "Name": "按期间" }, { "Name": "按日期" }, { "Name": "按未达天数"}]; var storeTimeFrame = Ext.create('Ext.data.Store', { model: 'TimeFrameModel', data: dataTimeFrame }); this.comboxTimeFrame = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '时间范围', forceSelection: true, store: storeTimeFrame, id: 'TimeFrame', name: 'TimeFrame', valueField: 'Name', displayField: 'Name', value: '按期间', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'select': function (_Field, newValue, eOpts) { if (_Field.value == "按期间") { Ext.getCmp('ACCDATEbgn').show(); Ext.getCmp('ACCDATEend').show(); Ext.getCmp('VOUDATEbgn').hide(); Ext.getCmp('VOUDATEend').hide(); Ext.getCmp('DaysOf').hide(); } else if (_Field.value == "按日期") { Ext.getCmp('ACCDATEbgn').hide(); Ext.getCmp('ACCDATEend').hide(); Ext.getCmp('VOUDATEbgn').show(); Ext.getCmp('VOUDATEend').show(); Ext.getCmp('DaysOf').hide(); } else if (_Field.value == "按未达天数") { Ext.getCmp('ACCDATEbgn').hide(); Ext.getCmp('ACCDATEend').hide(); Ext.getCmp('VOUDATEbgn').hide(); Ext.getCmp('VOUDATEend').show(); Ext.getCmp('DaysOf').show(); } }, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }); //结算方式 this.StoreStlMode = Ext.create('DsExt.ux.RefTableStore', { model: 'STLMODE', proxy: { url: '/MvcShipping/MsBaseInfo/GetStlModeList' } }); this.StoreStlMode.load({ params: { condition: ""} }); this.comboxStlMode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '结算方式', store: this.StoreStlMode, forceSelection: true, id: 'SETTLETYPE', name: 'SETTLETYPE', valueField: 'STLCODE', displayField: 'STLNAME' }); //经手人信息加载 this.storeENTERED = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeENTERED.load(); this.comboxENTERED = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '经手人', store: this.storeENTERED, forceSelection: true, id: 'ENTERED', name: 'ENTERED', valueField: 'UserName', displayField: 'CodeAndName' }); //制单人信息加载 this.storeCREATEUSER = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeCREATEUSER.load(); this.comboxCREATEUSER = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '制单人', store: this.storeCREATEUSER, forceSelection: true, id: 'CREATEUSERNAME', name: 'CREATEUSERNAME', valueField: 'UserName', displayField: 'CodeAndName' }); //键值维护表_凭证字 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', 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, }); //#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: [this.comboxACCNAME, this.comboxCwAccitemsCurrency, this.comboxDC, this.comboxCHECKING, { id: 'EXPLAN', name: 'EXPLAN', fieldLabel: '摘要', labelAlign: 'right', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxENTERED, this.comboxCREATEUSER, this.comboxTimeFrame, { 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: '至', 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 } } }, { fieldLabel: '结算日期', id: 'VOUDATEbgn', name: 'VOUDATEbgn', xtype: 'datefield', format: 'Y-m-d', allowBlank: false, //是否允许为空 enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { fieldLabel: '截止日期', id: 'VOUDATEend', name: 'VOUDATEend', xtype: 'datefield', format: 'Y-m-d', allowBlank: false, //是否允许为空 enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { fieldLabel: '未达天数', //(以上) id: 'DaysOf', name: 'DaysOf', xtype: 'numberfield', allowBlank: false, //是否允许为空 enableKeyEvents: true, //激活键盘事件 selectOnFocus: true, //得到焦点时自动选择文本 allowDecimals: false, //允许输入小数 hideTrigger: true, //是否隐藏上下调节按钮 nanText: '请输入有效数值', minValue: 0, value: 0, listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxStlMode, { id: 'BILLNObgn', name: 'BILLNObgn', fieldLabel: '结算号', labelAlign: 'right', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { id: 'BILLNOend', name: 'BILLNOend', fieldLabel: '至', labelAlign: 'right', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { id: 'BLCbgn', name: 'BLCbgn', fieldLabel: '金额', labelAlign: 'right', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }, { id: 'BLCend', name: 'BLCend', fieldLabel: '至', labelAlign: 'right', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 13) { this.onRefreshClick(); } }, scope: this } } }] }] }] }); //#endregion formSearch //#region 定义数据集 //列表加载 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsCtBankStatementModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCtBankStatement/GetDataList', 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: true, dataIndex: 'GID', header: '', //唯一编码 hidden: true, width: 0 }, { sortable: true, dataIndex: 'ISCHECKING', header: '对账', width: 40 }, { sortable: true, dataIndex: 'ISIMPORTNAME', header: '导入', width: 40 }, { sortable: true, dataIndex: 'ITEMNO', header: '序号', width: 35 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 60 }, { sortable: true, dataIndex: 'VOUDATE', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), align: 'center', header: '结算日期', width: 150 }, { sortable: true, dataIndex: 'EXPLAN', header: '摘要', width: 170 }, { sortable: true, dataIndex: 'SETTLETYPENAME', header: '结算方式', width: 60 }, { sortable: true, dataIndex: 'BILLNO', header: '结算号', width: 80 }, { sortable: true, dataIndex: 'DR', header: '银行借方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CR', header: '银行贷方', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'DC', header: '方向', width: 35 }, { sortable: true, dataIndex: 'BLC', header: '余额', align: 'right', width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'ENTERED', header: '经手人', align: 'center', width: 80 }, { sortable: true, dataIndex: 'CREATEUSERNAME', header: '制单人', align: 'center', width: 80 }]; //#endregion //#region gridList列表显示信息 this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: '每页记录数',//每页记录数 labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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(), bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示条数据', //当前显示条数据 emptyMsg: '没有数据'//没有数据 }), this.Pagenum] }); /////////////以下部分为获取存储的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) { var sISCHECKING = record.get('ISCHECKING'); if (sISCHECKING == "**" || sISCHECKING == "*") { return; } //判断是否轧账 Ext.Ajax.request({ waitMsg: '正在判断数据...', url: '/MvcShipping/MsCtCarryOver/onIsCARRY', async: false, params: { gid: record.get('GID'), voudate: '', tablename: 'ct_bank_statement' }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.sCondition = this.getCondition2(); this.SelectedRecord = record; this.isInitial = 0; DsOpenEditWin('/MvcShipping/MsCtBankStatement/Edit', "银行对账单", "700", "950", "10", "10"); } else { if (jsonresult.Message.toString() != "") { Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } } }, scope: this }); }, this); //#endregion //#region 按钮工具条/页面布局 this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ 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: "btnadd", handler: function (button, event) { this.sCondition = this.getCondition2(); this.isInitial = 0; DsOpenEditWin('/MvcShipping/MsCtBankStatement/Edit', "银行对账单", "700", "950", "10", "10"); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, { text: "导入", id: "btnImportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onImportExcelData(button, event); }, scope: this } // , { // text: "导出", // id: "btnExportExcel", // iconCls: 'btnexportexcel', // handler: function (button, event) { // this.onExportClick(button, event); // }, // scope: this // } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 130, items: [this.panelBtn, this.formSearch] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); //#endregion //#region 页面加载 this.InitData(); // this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); this.sqlcontext = sql; if (sql.toString() != "") { Ext.apply(store.proxy.extraParams, { condition: sql }); } }, this); //#endregion }, //end initUIComponents //#region 加载事件 InitData: function () { Ext.Ajax.request({ waitMsg: '正在查询...', //url: '/MvcShipping/MsCtBankStatement/GetInitData', url: '/MvcShipping/MsCtBankJournal/GetInitData', params: { isInitial: this.isInitial }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { return; } //var data = result.data; var strArg = result.data.toString().split(","); this.strCtSTARTGID = strArg[0].toString(); this.strACCDATE = strArg[1].toString(); this.strACCDAY = strArg[2].toString(); this.strACCTODAY = strArg[3].toString(); // Ext.getCmp("ACCDATEbgn").setValue(this.strACCDATE); Ext.getCmp("ACCDATEend").setValue(this.strACCDATE); Ext.getCmp("VOUDATEbgn").setValue(this.strACCDATE + "-01"); Ext.getCmp("VOUDATEend").setValue(this.strACCDAY); // Ext.getCmp('ACCDATEbgn').show(); Ext.getCmp('ACCDATEend').show(); Ext.getCmp('VOUDATEbgn').hide(); Ext.getCmp('VOUDATEend').hide(); Ext.getCmp('DaysOf').hide(); // this.onRefreshClick(); } else { //Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, //end InitData //#endregion //#region 按钮函数 onRefreshClick: function () { var sql = this.getCondition(); this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在刷新数据...", scope: this }); }, getCondition: function () { if (!this.formSearch.getForm().isValid()) { return "1<0"; } var sql = ''; //银行科目 var sACCID = this.formSearch.getForm().findField('ACCNAME').getValue(); if (sACCID != null) { if (sACCID != "") { //var sGID = ""; //var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', sACCID); //if (AccitemsList.length > 0) { // var AccitemsRaw = AccitemsList.getAt(0).raw; // sGID = AccitemsRaw.GID.toString(); //} //if (sGID != "") { // sql = sql + getAndConSql(sql, sGID, "ACCGID='" + sGID.trim() + "'"); //} sql = sql + getAndConSql(sql, sACCID, "ACCGID in (select GID FROM cw_accitems_gl WHERE ACCID='" + sACCID.trim() + "')"); } } //币别 var sFCYNO = this.formSearch.getForm().findField('FCYNO').getValue(); if (sFCYNO != null) { if (sFCYNO != "") { sql = sql + getAndConSql(sql, sFCYNO, "FCYNO='" + sFCYNO.toString().trim() + "'"); } } //方向 var sDC = this.formSearch.getForm().findField('DC').getValue(); if (sDC != null) { if (sDC != "") { sql = sql + getAndConSql(sql, sDC, "DC='" + sDC.toString().trim() + "'"); } } //是否对账 var sCHECKING = this.formSearch.getForm().findField('CHECKING').getValue(); if (sCHECKING != null) { if (sCHECKING == "已达") { sql = sql + getAndConSql(sql, sCHECKING, "(CHECKINGGID<>'' and CHECKINGGID is not null)"); } if (sCHECKING == "未达") { sql = sql + getAndConSql(sql, sCHECKING, "(CHECKINGGID='' or CHECKINGGID is null)"); } } //摘要 var sEXPLAN = this.formSearch.getForm().findField('EXPLAN').getValue(); if (sEXPLAN != null) { if (sEXPLAN != "") { sql = sql + getAndConSql(sql, sEXPLAN, "EXPLAN like '%" + sEXPLAN.toString().trim() + "%'"); } } //经手人 var sENTERED = this.formSearch.getForm().findField('ENTERED').getValue(); if (sENTERED != null) { if (sENTERED != "") { sql = sql + getAndConSql(sql, sENTERED, "ENTERED='" + sENTERED.toString().trim() + "'"); } } //制单人 var sMODIFIEDUSER = this.formSearch.getForm().findField('CREATEUSERNAME').getValue(); if (sMODIFIEDUSER != null) { if (sMODIFIEDUSER != "") { sql = sql + getAndConSql(sql, sMODIFIEDUSER, "MODIFIEDUSER=(select top 1 gid from [user] where SHOWNAME='" + sMODIFIEDUSER.toString().trim() + "')"); } } //时间范围 var sTimeFrame = this.formSearch.getForm().findField('TimeFrame').getValue(); if (sTimeFrame != null) { if (sTimeFrame == "") { sql = sql + getAndConSql(sql, sTimeFrame, "MODIFIEDUSER=(select top 1 gid from [user] where SHOWNAME='" + sMODIFIEDUSER.toString().trim() + "')"); } if (sTimeFrame == "按期间") { var ACCDATEbgn = this.formSearch.getForm().findField('ACCDATEbgn').getRawValue(); if (ACCDATEbgn != null) { if (ACCDATEbgn != "") { sql = sql + getAndConSql(sql, ACCDATEbgn, "ACCDATE >='" + ACCDATEbgn.toString().trim() + "'"); } } var ACCDATEend = this.formSearch.getForm().findField('ACCDATEend').getRawValue(); if (ACCDATEend != null) { if (ACCDATEend != "") { sql = sql + getAndConSql(sql, ACCDATEend, "ACCDATE <='" + ACCDATEend.toString().trim() + "'"); } } } else if (sTimeFrame == "按日期") { var VOUDATEbgn = this.formSearch.getForm().findField('VOUDATEbgn').getRawValue(); if (VOUDATEbgn != null) { if (VOUDATEbgn != "") { sql = sql + getAndConSql(sql, VOUDATEbgn, "convert(varchar,VOUDATE,23)>='" + VOUDATEbgn.toString().trim() + "'"); } } var VOUDATEend = this.formSearch.getForm().findField('VOUDATEend').getRawValue(); if (VOUDATEend != null) { if (VOUDATEend != "") { sql = sql + getAndConSql(sql, VOUDATEend, "convert(varchar,VOUDATE,23)<='" + VOUDATEend.toString().trim() + "'"); } } } else if (sTimeFrame == "按未达天数") { var sDaysOf = this.formSearch.getForm().findField('DaysOf').getValue(); var VOUDATEend = this.formSearch.getForm().findField('VOUDATEend').getRawValue(); if (VOUDATEend != null) { if (VOUDATEend != "") { sql = sql + getAndConSql(sql, VOUDATEend, "convert(varchar,VOUDATE,23)<=convert(varchar(10),DateAdd(dd,(-" + sDaysOf + "),'" + VOUDATEend.toString().trim() + "'),23)"); } } } } //结算方式 var sSETTLETYPE = this.formSearch.getForm().findField('SETTLETYPE').getValue(); if (sSETTLETYPE != null) { if (sSETTLETYPE != "") { sql = sql + getAndConSql(sql, sSETTLETYPE, "SETTLETYPE='" + sSETTLETYPE.toString().trim() + "'"); } } //结算单号 var BILLNObgn = this.formSearch.getForm().findField('BILLNObgn').getValue(); if (BILLNObgn != null) { if (BILLNObgn != "") { sql = sql + getAndConSql(sql, BILLNObgn, "BILLNO >='" + BILLNObgn.toString().trim() + "'"); } } var BILLNOend = this.formSearch.getForm().findField('BILLNOend').getValue(); if (BILLNOend != null) { if (BILLNOend != "") { sql = sql + getAndConSql(sql, BILLNOend, "BILLNO <='" + BILLNOend.toString().trim() + "'"); } } //金额 var BLCbgn = this.formSearch.getForm().findField('BLCbgn').getValue(); var BLCend = this.formSearch.getForm().findField('BLCend').getValue(); if (BLCbgn != null && BLCend != null) { if (BLCbgn != "" && BLCend != "") { sql = sql + getAndConSql(sql, BLCbgn, "((DR >='" + BLCbgn.toString().trim() + "' and DR <='" + BLCend.toString().trim() + "') OR (CR >='" + BLCbgn.toString().trim() + "' and CR <='" + BLCend.toString().trim() + "'))"); } else { if (BLCbgn != "") { sql = sql + getAndConSql(sql, BLCbgn, "(DR >='" + BLCbgn.toString().trim() + "' OR CR >='" + BLCbgn.toString().trim() + "')"); } if (BLCend != "") { sql = sql + getAndConSql(sql, BLCend, "(DR <='" + BLCend.toString().trim() + "' OR CR <='" + BLCend.toString().trim() + "')"); } } } else { if (BLCbgn != null) { if (BLCbgn != "") { sql = sql + getAndConSql(sql, BLCbgn, "(DR >='" + BLCbgn.toString().trim() + "' OR CR >='" + BLCbgn.toString().trim() + "')"); } } if (BLCend != null) { if (BLCend != "") { sql = sql + getAndConSql(sql, BLCend, "(DR <='" + BLCend.toString().trim() + "' OR CR <='" + BLCend.toString().trim() + "')"); } } } return sql; }, getCondition2: function () { //if (!this.formSearch.getForm().isValid()) { // return "1<0"; //} var sql = ''; //银行科目 var sACCID = this.formSearch.getForm().findField('ACCNAME').getValue(); if (sACCID != null) { if (sACCID != "") { var sGID = ""; var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', sACCID); if (AccitemsList.length > 0) { var AccitemsRaw = AccitemsList.getAt(0).raw; sGID = AccitemsRaw.GID.toString(); } if (sGID != "") { sql = sql + getAndConSql(sql, sGID, "ACCGID='" + sGID.trim() + "'"); } } } //币别 var sFCYNO = this.formSearch.getForm().findField('FCYNO').getValue(); if (sFCYNO != null) { if (sFCYNO != "") { sql = sql + getAndConSql(sql, sFCYNO, "FCYNO='" + sFCYNO.toString().trim() + "'"); } } //时间范围 var sTimeFrame = this.formSearch.getForm().findField('TimeFrame').getValue(); if (sTimeFrame != null) { if (sTimeFrame == "") { sql = sql + getAndConSql(sql, sTimeFrame, "MODIFIEDUSER=(select top 1 gid from [user] where SHOWNAME='" + sMODIFIEDUSER.toString().trim() + "')"); } if (sTimeFrame == "按期间") { var ACCDATEbgn = this.formSearch.getForm().findField('ACCDATEbgn').getRawValue(); if (ACCDATEbgn != null) { if (ACCDATEbgn != "") { sql = sql + getAndConSql(sql, ACCDATEbgn, "ACCDATE >='" + ACCDATEbgn.toString().trim() + "'"); } } var ACCDATEend = this.formSearch.getForm().findField('ACCDATEend').getRawValue(); if (ACCDATEend != null) { if (ACCDATEend != "") { sql = sql + getAndConSql(sql, ACCDATEend, "ACCDATE <='" + ACCDATEend.toString().trim() + "'"); } } } else if (sTimeFrame == "按日期") { var VOUDATEbgn = this.formSearch.getForm().findField('VOUDATEbgn').getRawValue(); if (VOUDATEbgn != null) { if (VOUDATEbgn != "") { sql = sql + getAndConSql(sql, VOUDATEbgn, "convert(varchar,VOUDATE,23)>='" + VOUDATEbgn.toString().trim() + "'"); } } var VOUDATEend = this.formSearch.getForm().findField('VOUDATEend').getRawValue(); if (VOUDATEend != null) { if (VOUDATEend != "") { sql = sql + getAndConSql(sql, VOUDATEend, "convert(varchar,VOUDATE,23)<='" + VOUDATEend.toString().trim() + "'"); } } } else if (sTimeFrame == "按未达天数") { var sDaysOf = this.formSearch.getForm().findField('DaysOf').getRawValue(); var VOUDATEend = this.formSearch.getForm().findField('VOUDATEend').getRawValue(); if (VOUDATEend != null) { if (VOUDATEend != "") { sql = sql + getAndConSql(sql, VOUDATEend, "convert(varchar,VOUDATE,23)<=convert(varchar(10),DateAdd(dd,(-" + sDaysOf + "),'" + VOUDATEend.toString().trim() + "'),23)"); } } } } //未达账 sql += " and (CHECKINGGID='' or CHECKINGGID is null)"; //是否期初 sql += " and ISINITIAL=0"; //导入的数据不允许修改 //sql += " and ISIMPORT=0"; return sql; }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); this.InitData(); }, onDeleteClick: function (button, event) { var 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 (i == 0) { gids = record.get('GID'); } else { gids += "," + record.get('GID'); } } // Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', //async: false, //同步请求数据 url: '/MvcShipping/MsCtBankStatement/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 }); } } }, timeout: 3000000,//30秒 scope: this }); //end Ext.Ajax.request } }, this); }, //#endregion //#region 导入Excel onImportExcelData: function (button, event) { this.showContactForm(false); }, showContactForm: function (win) { var required = '*'; if (!win) { //#region formSearch 下拉框信息加载 //银行存款科目加载 this.storeCwAccitems2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems2.load({ params: { condition: "DETAILED=1 and ISENABLE=1 and ISBANK=1"} }); this.comboxACCNAME2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '银行科目', store: this.storeCwAccitems2, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'ACCNAME2', name: 'ACCNAME2', valueField: 'ACCID', displayField: 'ACCIDNAME', anchor: '100%', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'select': function (_Field, newValue, eOpts) { if (_Field.value != null) { var sGID = ""; var AccitemsList = DsStoreQueryBy(this.storeCwAccitems2, 'ACCID', _Field.value.toString()); if (AccitemsList.length > 0) { var AccitemsRaw = AccitemsList.getAt(0).raw; sGID = AccitemsRaw.GID.toString(); } if (sGID != "") { this.storeCwAccitemsCurrency2.load({ params: { condition: "LINKGID = '" + sGID + "'" }, callback: function (options, success, response) { var combo = Ext.getCmp("FCYNO2"); combo.setValue(options[0].data.CURRENCY.toString()); //选中 }, scope: this }); } } } } }); //币别选项 this.storeCwAccitemsCurrency2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsCurrencyModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsCurrencyList' } }); //this.storeCwAccitemsCurrency.load({ params: { condition: ""} }); this.comboxCwAccitemsCurrency2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.storeCwAccitemsCurrency2, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'FCYNO2', name: 'FCYNO2', valueField: 'CURRENCY', displayField: 'CURRENCY', anchor: '100%', allowBlank: false }); //#endregion //#region 编辑formDiv 基本信息 var formDiv = Ext.widget('form', { id: 'importForm', border: false, bodyPadding: 10, fieldDefaults: { //flex: 1, labelAlign: 'right', labelWidth: 60, labelStyle: 'font-weight:bold' }, items: [this.comboxACCNAME2, this.comboxCwAccitemsCurrency2, { xtype: 'filefield', id: 'file', name: 'file', fieldLabel: 'Excel文件', anchor: '100%', allowBlank: false, buttonText: '选择文件...' }], buttons: [{ text: '取消', handler: function () { this.up('form').getForm().reset(); //this.up('window').hide(); this.up('window').close(); } }, { text: '导入', handler: function (options, success, response) { var form = Ext.getCmp("importForm").getForm(); if (!form.isValid()) { Ext.Msg.show({ title: '错误', msg: "科目、币别、路径信息都不允许为空!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } //银行科目 var strACCGID2 = ""; var comboxList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', Ext.getCmp('ACCNAME2').getValue()); if (comboxList.length > 0) { var comboxRaw = comboxList.getAt(0).raw; strACCGID2 = comboxRaw.GID.toString(); } var strFCYNO2 = Ext.getCmp('FCYNO2').getValue(); var strfile = Ext.getCmp('file').getValue(); // form.submit({ waitMsg: '正在处理数据...', url: '/MvcShipping/MsCtBankStatement/onImportExcelData', params: { strACCGID: strACCGID2, strFCYNO: strFCYNO2, strfile: strfile }, success: function (f, a) { var result = a.result; this.onRefreshClick(); Ext.Msg.alert('Success', result.Message); // //this.up('form').getForm().reset(); form.reset(); //this.up('window').close(); win.close(); }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); }, scope: this }); }, scope: this }] }); //#endregion win = Ext.widget('window', { title: '导入银行对账单', closeAction: 'destroy', //hide, width: 400, height: 200, layout: 'fit', resizable: true, modal: true, closable: false, //为false时tab上不显示叉号 resizable: false, //是否可改变列宽,默认为true items: formDiv //draggable: false,//不允许窗体被拖拽 //获取当前鼠标坐标并设置为其生产的初始位置 //x: 250, //y: 150, }); } win.show(); }, //#endregion //#region 导出Excel onExportClick: function (button, event) { 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=MsCtBankStatementIndex&formname=" + this.formname + "&condition1=" + sql + "&gids=" + strGIDs; window.open(openUrl, openType, openSet); }, //#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 OprationSwap: function () { var ret = new Array(); ret[0] = this.storeList; ret[1] = this.SelectedRecord; ret[2] = this.sqlcontext; ret[3] = this.sCondition; ret[4] = this.isInitial; ret[5] = Ext.getCmp('btnRefresh'); return ret; } });