Ext.namespace('DsTruck'); DsTruck.FinanceBankStlIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.FinanceBankStlIndex.superclass.constructor.call(this); }; Ext.extend(DsTruck.FinanceBankStlIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreOpRange.load({ params: { optype: "modFinanceAppList"} }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'FinanceBodymb', remoteSort: true, proxy: { type: 'ajax', url: '/Import/Finance/GetFinanceBody', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid var _this = this; 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, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: [{ sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 },{ sortable: true, dataIndex: 'F_NO', header: '还款单号', width: 120 }, { sortable: true, dataIndex: 'CUSTOMER', header: '银行名称', width: 100 }, { sortable: true, dataIndex: 'ENDDATE', header: '还款日期', width: 100 }, { sortable: true, dataIndex: 'F_CURRENCY', header: '还款币别', width: 80 }, { sortable: true, dataIndex: 'F_AMOUNT', header: '还款金额', width: 80 }, { sortable: true, dataIndex: 'INTERESTUSD', header: '本金利息', width: 80 }, { sortable: true, dataIndex: 'EXCHANGERATE', header: '汇率', width: 80 }, { sortable: true, dataIndex: 'RMBVALUE', header: '折合RMB', width: 100 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80 }, { sortable: true, dataIndex: 'OPREF', header: '操作人', width: 80 }, { sortable: true, dataIndex: 'ENTERDATE', header: '操作时间', width: 80 } ], // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/Import/Finance/BankStlEdit'); }, this); //#region formSearch //#region formSearch枚举参照相关 this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeBuyer.load({ params: { condition: " 1=1 "} }); this.comboxBuyer = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '银行名称', forceSelection: true, store: this.storeBuyer, name: 'CUSTOMER', valueField: 'name', displayField: 'codename' }); this.storeFinance = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFinance.load({ params: { enumTypeId: 16} }); this.storeFinance = Ext.create('Ext.data.Store', { fields: [ 'NAME'] }); this.storeFinance.add({ "DC": "", "NAME": "全部" }); this.storeFinance.add({ "DC": "新建还款", "NAME": "新建还款" }); this.storeFinance.add({ "DC": "锁定", "NAME": "锁定" }); this.comboxFinance = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '还款状态', store: this.storeFinance, valueField: 'DC', displayField: 'NAME', name: 'FinanceStatus' }); //#endregion this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [{ //fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '还款业务号', name: 'F_NO', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxBuyer, this.comboxFinance, { fieldLabel: '从..还款日期', format: 'Y-m-d', xtype: 'datefield', name: 'STARTDATE_Min', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到..还款日期', format: 'Y-m-d', xtype: 'datefield', name: 'STARTDATE_Max', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } ] }] } ] //end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Import/Finance/BankStlEdit'); }, scope: this }, '-', { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { var form = this.formSearch.getForm(); form.reset(); }, scope: this }, '-', { text: "删除", id: 'btndelete', iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 80, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.onInitRefreshClick(); }, //end initUIComponents onInitRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; // var billstatus = record.data.F_STATUS; // if (billstatus != '新建还款') { // Ext.Msg.show({ title: '提示', msg: '当前状态无法删除此单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); // return; // } Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Import/Finance/DeleteBankStl', params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); Ext.Msg.show({ title: '提示', msg: '删除成功!', 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.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, //onDeleteClick onSubmitAuditClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var BILLNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.F_NO; if (rec.data.F_STATUS == '新建还款' ) { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } } _this = this; if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/Finance/SubmitAuditBankStlList', params: { bills: BILLNOStr }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onSubmitAuditBackClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var BILLNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.F_NO; if (rec.data.F_STATUS == '锁定') { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } } _this = this; if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/Finance/AuditBackBankStlList', params: { bills: BILLNOStr }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }; }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql =" F_TYPE='3' "; var F_NO = form.findField('F_NO').getValue(); sql = sql + getAndConSql(sql, F_NO, "F_NO like '%" + F_NO + "%'"); var CUSTOMER = form.findField('CUSTOMER').getValue(); sql = sql + getAndConSql(sql, CUSTOMER, "CUSTOMER = '" + CUSTOMER + "'"); var FinanceStatus = form.findField('FinanceStatus').getValue(); sql = sql + getAndConSql(sql, FinanceStatus, "F_STATUS = '" + FinanceStatus + "'"); var STARTDATE_Min = form.findField('STARTDATE_Min').getRawValue(); sql = sql + getAndConSql(sql, STARTDATE_Min, "ENDDATE >= '" + STARTDATE_Min + "'"); var STARTDATE_Max = form.findField('STARTDATE_Max').getRawValue(); sql = sql + getAndConSql(sql, STARTDATE_Max, "ENDDATE <= '" + STARTDATE_Max + " 23:59:59'"); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });