You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsCtBankDeploy/MsCtBankDeployIndex.js

654 lines
26 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCtBankDeployIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCtBankDeployIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCtBankDeployIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "formMsCtBankDeployIndex"; //页面名称
//#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,
allowBlank: false,
forceSelection: true, //输入值是否严格为待选列表中存在的值
matchFieldWidth: false, //下拉框本身宽度不会变,下拉之后的宽度会根据文本中最大的字符长度自适应
id: 'cbACCNAME',
name: 'cbACCNAME',
valueField: 'ACCNAME',
displayField: 'ACCIDNAME',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function (_Field, Arrays, obj) {
if (Arrays.length > 0) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
//是不是外币都默认为RMB?
var sFCYNO = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + Arrays[0].data.GID.toString() + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
sFCYNO = selections[0].data.FCYNO.toString();
break;
}
sFCYNO = options[0].data.CURRENCY;
}
}
else {
sFCYNO = "RMB";
}
combo.setValue(sFCYNO); //选中
selections[0].set('FCYNO', sFCYNO);
},
scope: this
});
this.onNextKeyClick(2);
}
},
'keyup': {
fn: function (_field, e, eOpts) {
if (e.getKey() == 13) {
var newValue = _field.rawValue.toString();
var inv = newValue.indexOf("-");
if (inv > -1) {
newValue = newValue.substr(inv + 1);
}
if (newValue != "") {
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCNAME', newValue);
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var sFCYNO = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
sFCYNO = selections[0].data.FCYNO.toString();
break;
}
sFCYNO = options[0].data.CURRENCY;
}
}
else {
sFCYNO = "RMB";
}
combo.setValue(sFCYNO); //选中
selections[0].set('FCYNO', sFCYNO);
},
scope: this
});
this.onNextKeyClick(2);
}
}
//
}
},
scope: this
}
}
});
//币别选项
this.storeCwAccitemsCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsCurrencyModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsCurrencyList' }
});
this.storeCwAccitemsCurrency.load({ params: { condition: "LINKGID=''"} });
this.comboxCodeCurrency = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '币别',
store: this.storeCwAccitemsCurrency,
forceSelection: true, //输入值是否严格为待选列表中存在的值
matchFieldWidth: false, //下拉框本身宽度不会变,下拉之后的宽度会根据文本中最大的字符长度自适应
id: 'CURRENCY',
name: 'CURRENCY',
valueField: 'CURRENCY',
displayField: 'CURRENCY',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': function (_this, eOpts) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var sCURRENCY = selections[0].data.FCYNO.toString().trim();
var sACCNAME = selections[0].data.ACCNAME2.toString().trim();
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCNAME', sACCNAME);
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
var ssCURRENCY = sCURRENCY;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
ssCURRENCY = selections[0].data.FCYNO.toString();
break;
}
ssCURRENCY = options[0].data.CURRENCY;
}
}
else {
ssCURRENCY = "RMB";
}
sCURRENCY = ssCURRENCY;
combo.setValue(ssCURRENCY); //选中
},
scope: this
});
}
},
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onNextKeyClick(3);
}
},
scope: this
}
}
});
//#endregion
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCtBankDeployModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCtBankDeploy/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
text: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ACCNAME2', //BANKNAME
header: '银行',
//align: 'center',
editor: this.comboxACCNAME//comboxBANK
}, {
sortable: false,
dataIndex: 'FCYNO',
header: '币别',
//align: 'center',
editor: this.comboxCodeCurrency
}, {
sortable: false,
dataIndex: 'STARTROW',
header: '开始行',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(4);
}
},
scope: this
}
}
}
}, {
sortable: false,
text: '结算日期',
dataIndex: 'VOUDATE',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(5);
}
},
scope: this
}
}
}
}, {
sortable: false,
text: '结算时间',
dataIndex: 'VOUTIME',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(6);
}
},
scope: this
}
}
}
}, {
sortable: false,
dataIndex: 'EXPLAN',
header: '摘要',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
}
}, {
text: '借方',
dataIndex: 'DR',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(8);
}
},
scope: this
}
}
}
}, {
text: '贷方',
dataIndex: 'CR',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(9);
}
},
scope: this
}
}
}
}, {
text: '余额',
dataIndex: 'BLC',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onAddClick();
}
},
scope: this
}
}
}
}, {
text: '借贷方向',
dataIndex: 'DC',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onAddClick();
}
},
scope: this
}
}
}
}, {
text: '借方关键字',
dataIndex: 'DRGJZ',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onAddClick();
}
},
scope: this
}
}
}
}, {
text: '贷方关键字',
dataIndex: 'CRGJZ',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onAddClick();
}
},
scope: this
}
}
}
},
{
sortable: true,
dataIndex: 'ACCGID',
header: '',
hidden: true,
width: 0
}];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridList = new Ext.grid.GridPanel({
region: 'center',
store: this.storeList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
listeners: {
scope: this,
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
if (e.field == 'FCYNO') {
var sCURRENCY = Ext.getCmp("CURRENCY").getValue();
e.record.set('FCYNO', sCURRENCY);
}
//
}
}
});
this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, this);
this.storeList.load({ params: { condition: "" }, waitMsg: "正在查询数据...", scope: this });
//#endregion
//#region 按钮工具条/页面布局
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: '添加',
tooltip: '添加',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}, '-', {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-', {
text: '删除',
tooltip: '删除',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}]
}); //end 按钮Toolbar
Ext.apply(this, {
items: [this.panelBtn, this.gridList]
});
//#endregion
}, //end initUIComponents
//#region 按钮函数
Save: function () {
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
//银行科目
sName = member.data.ACCNAME2.toString();
var comboxList = DsStoreQueryBy(this.storeCwAccitems, 'ACCNAME', sName);
if (comboxList.length > 0) {
var comboxRaw = comboxList.getAt(0).raw;
member.set("ACCGID", comboxRaw.GID.toString());
}
//
var sDR = member.data.DR.toString();
var sCR = member.data.CR.toString();
if (sDR == sCR) {
var sDC = member.data.DC.toString();
var sDRGJZ = member.data.DRGJZ.toString();
var sCRGJZ = member.data.CRGJZ.toString();
if (sDC.trim() == "" || sDRGJZ.trim() == "" || sCRGJZ.trim() == "") {
Ext.Msg.show({ title: '请重试', msg: '如果“借方”与“贷方”相同,则“借贷方向、借方关键字、贷方关键字”不允许为空,请重新填写!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return false;
}
}
//
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCtBankDeploy/Save',
scope: this,
params: {
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//var returnData = jsonresult.Data;
this.storeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
} 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 });
}
}
});
}
}, //end save
onAddClick: function () {
var record = Ext.create('MsCtBankDeployModel', {
GID: '*',
ACCOUNT: '',
VOUDATE: '',
VOUTIME: '',
EXPLAN: '',
DR: 0,
CR: 0,
BLC: 0,
DC: '', //借贷方向
DRGJZ: '', //借方关键字
CRGJZ: '', //贷方关键字
ACCGID: ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCtBankDeploy/Delete',
params: {
dataER: Ext.JSON.encode(this.EditRecord),
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(rec);
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 });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
onNextKeyClick: function (col) {
var rows = this.gridList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridList.getStore();
var number = s.indexOf(row);
this.gridListCellEditing.startEditByPosition({ row: number, column: col });
},
//#endregion
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeTreeList;
ret[2] = this.SelectedRecord;
return ret;
}
});