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.

282 lines
11 KiB
JavaScript

12 months ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCwCurrencyRateIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwCurrencyRateIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCwCurrencyRateIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
strACCDATE: null,
initUIComponents: function () {
this.formname = "formMsCwCurrencyRateIndex"; //期初汇率维护
//#region formSearch 下拉框信息加载
this.storeCodeCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCurrencyModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCurrencyList' }
});
this.storeCodeCurrency.load({ params: { condition: "CODENAME<>'RMB'"} });
this.comboxCodeCurrency = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.storeCodeCurrency,
forceSelection: true, //输入值是否严格为待选列表中存在的值
id: 'CURRENCY',
name: 'CURRENCY',
valueField: 'CODENAME',
displayField: 'CODENAME',
value: 'USD',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'change': function (combo, records, eOpts, kk, hg) {
this.storeList.load({ params: { currency: combo.value }, waitMsg: "正在查询数据...", scope: this });
}
}
});
//#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',
items: [this.comboxCodeCurrency]
}]//end items(fieldset 1)
});
//#endregion formSearch
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCwCurrencyRateModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwCurrencyRate/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
text: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ACCDATE',
text: '会计期间',
align: 'center',
width: 80
}, {
sortable: false,
dataIndex: 'BEGRATE',
header: '期初汇率',
align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 5, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
width: 100,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
decimalPrecision: 5, //允许保留的小数位数,并四舍五入
nanText: '请输入有效小数',
minValue: 0.00000,
//maxValue: 100000,
value: 0.00000,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true //是否隐藏上下调节按钮
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 5, '', false);
return value;
}
}, {
text: '期末汇率',
dataIndex: 'ENDRATE',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 5, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 5, '', false);
return value;
}
}];
//#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,
'cellclick': function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var iMonth = this.strACCDATE.toString().substr(5, 2);
iMonth = iMonth-1;
for (var i = 0; i < iMonth; i++) {
if (rowIndex == i) {
return false;
}
}
}
}
});
var currency = Ext.getCmp('CURRENCY').getValue();
this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { currency: currency }); }, this);
this.storeList.load({ params: { currency: currency }, waitMsg: "正在查询数据...", scope: this });
//#endregion
//#region 按钮工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-', {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
}]
});
//#endregion
//#region 页面布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 70,
items: [this.panelBtn, this.formSearch]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
//#endregion
//加载事件
this.InitData();
}, //end initUIComponents
//#region 加载事件
InitData: function () {
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwCurrencyRate/GetACCDATE',
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//if (jsonresult.data.toString() == "") {
// Ext.Msg.show({ title: '错误', msg: "请先设置启用账套!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
// window.close();
//}
//else {
this.strACCDATE = jsonresult.data;
//}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
Ext.MessageBox.hide();
} else {
Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
},
scope: this
});
},
//#endregion
//#region 按钮函数
onRefreshClick: function () {
var currency = Ext.getCmp('CURRENCY').getValue();
this.storeList.load({ params: { currency: currency }, waitMsg: "正在刷新数据...", scope: this });
},
Save: function () {
var currency = Ext.getCmp('CURRENCY').getValue();
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwCurrencyRate/Save',
scope: this,
params: {
body: jsonBody,
currency: currency
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//var returnData = jsonresult.Data;
var currency = Ext.getCmp('CURRENCY').getValue();
this.storeList.load({ params: { currency: currency }, 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
//#endregion
});