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.

791 lines
32 KiB
JavaScript

11 months ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCwGenlegAccitemsIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwGenlegAccitemsIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCwGenlegAccitemsIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
initUIComponents: function () {
this.formname = "formMsCwGenlegAccitemsIndex"; //期初录入
//#region 定义数据集
this.storeTreeList = Ext.create('Ext.data.TreeStore', {
model: 'MsCwAccitemsModel',
nodeParam: 'PACCGID',
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwGenlegAccitems/GetDataListCA',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: true,
folderSort: false, //将叶子节点排列到非叶子节点后面 默认为false
root: {
name: '根节点',
expanded: true,
//checked: false,
id: '0'
}
});
this.storeListHJ = Ext.create('Ext.data.Store', {
model: 'MsCwAccitemsModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwGenlegAccitems/GetDataListHJ',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: true,
dataIndex: 'GID',
text: '唯一编码',
hidden: true,
width: 0
}, {
xtype: 'treecolumn', //这是我们知道列将显示树
text: '科目',
//sortable: true,
dataIndex: 'NAME',
width: 300
}, {
text: '方向',
//sortable: true,
dataIndex: 'DC',
width: 40,
align: 'center'
}, {
text: '属性',
dataIndex: 'ACCATTRIBUTE',
width: 40,
align: 'center'
}, {
text: '类别',
dataIndex: 'ACCTYPE',
//sortable: true,
width: 80,
align: 'center',
hidden: true,
width: 0
}, {
text: '借',
dataIndex: 'DR',
width: 100,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00,
listeners: {
scope: this,
'blur': function blur(_field, e) {
if (_field.value == null) {
_field.setValue("0");
}
else {
if(_field.value.toString() == "")
{
_field.setValue("0");
}
}
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '贷',
dataIndex: 'CR',
width: 100,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00,
listeners: {
scope: this,
'blur': function blur(_field, e) {
if (_field.value == null) {
_field.setValue("0");
}
else {
if (_field.value.toString() == "") {
_field.setValue("0");
}
}
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '损益类累计借方',
dataIndex: 'PFADR',
width: 100,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00,
listeners: {
scope: this,
'blur': function blur(_field, e) {
if (_field.value == null) {
_field.setValue("0");
}
else {
if (_field.value.toString() == "") {
_field.setValue("0");
}
}
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '损益类累计贷方',
dataIndex: 'PFACR',
width: 100,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00,
listeners: {
scope: this,
'blur': function blur(_field, e) {
if (_field.value == null) {
_field.setValue("0");
}
else {
if (_field.value.toString() == "") {
_field.setValue("0");
}
}
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '核算外币',
dataIndex: 'ISFCY',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '核算部门',
dataIndex: 'ISDEPTACC',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '核算人员',
dataIndex: 'ISEMPLACC',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '核算客户',
dataIndex: 'ISCORPACC',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '核算项目',
dataIndex: 'ISITEMACC',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '是否入账',
dataIndex: 'ISENABLE',
//xtype: 'checkcolumn',
xtype: "booleancolumn",
trueText: "是",
falseText: " ",
//sortable: true,
width: 60,
align: 'center'
}, {
text: '末级科目',
dataIndex: 'DETAILED',
hidden: true,
width: 0
}, {
text: '月',
dataIndex: 'MONTH',
hidden: true,
width: 0
}];
this.girdcolumsHJ = [{
sortable: true,
dataIndex: 'GID',
text: '科目状态',
width: 100,
align: 'center'
}, {
text: '借',
dataIndex: 'DR',
width: 120,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '贷',
dataIndex: 'CR',
width: 120,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '损益类科目本年累计数借方',
dataIndex: 'PFADR',
width: 150,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
text: '损益类科目本年累计数贷方',
dataIndex: 'PFACR',
width: 150,
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}];
//#endregion
//#region treeList列表显示信息
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.treeList = new Ext.tree.Panel({
region: 'center',
split: true,
store: this.storeTreeList,
//collapsible: true, //允许展开和收缩
rootVisible: false, //false不显示根节点,默认为true
hideHeaders: false,
animate: false,
lines: true,
columnLines: true,
rowLines: true,
useArrows: true, //使用箭头样式
trackMouseOver: true, //高亮显示鼠标所在的行默认为true,
//enableHdMenu: true,//显示表格列的菜单
//stripeRows: true, //斑马线效果
//multiSelect: true, //动态增加列表项
//singleExpand: true, //若已展开一个结点A此时去点击另一个同级或更高等级的结点B会将A结点收起并展开B结点若B结点有子结点
//disableSelection: false,//禁止行选择默认为false
//viewConfig: {
// enableTextSelection: true, //允许复制数据
// autoFill: true
//},
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
listeners: {
scope: this,
'cellclick': function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
if (record.data.DETAILED == false && (cellIndex == 5 || cellIndex == 6 || cellIndex == 7 || cellIndex == 8)) {
return false;
}
else {
if ((cellIndex == 5 || cellIndex == 7) && record.data.DC == '贷') {
return false;
}
//
if ((cellIndex == 6 || cellIndex == 8) && record.data.DC == '借') {
return false;
}
//
if (record.data.ISFCY == true || record.data.ISDEPTACC == true || record.data.ISEMPLACC == true || record.data.ISCORPACC == true || record.data.ISITEMACC == true) {
return false;
}
//
if ((cellIndex == 5 || cellIndex == 6) && record.data.ACCATTRIBUTE == '损益') {
return false;
}
//
if ((cellIndex == 7 || cellIndex == 8) && record.data.ACCATTRIBUTE != '损益') {
return false;
}
//
if (record.data.ISENABLE) {
return false;
}
return true;
}
},
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
//需要自己实现里面的事件
//var bodydatas = [];
//bodydatas.push(e.record);
//var jsonBody = ConvertRecordsToJsonAll(bodydatas);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwGenlegAccitems/SaveRow',
scope: this,
params: {
//body: jsonBody
data: Ext.JSON.encode(e.record.data)
},
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.treeList.commit();
//this.storeTreeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
this.storeListHJ.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
});
}
}
});
}
}
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeListHJ,
enableHdMenu: false,
region: 'south',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolumsHJ,
height: 60
});
//#endregion
//#region 按钮工具条/页面布局
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
}, {
text: "期初入账",
id: 'btSubmit',
name: 'btSubmit',
iconCls: "btnsubmit",
handler: function (button, event) {
this.onISENABLEClick("1");
},
scope: this
}
//, {
// text: "取消入账",
// iconCls: "btnsubmit",
// handler: function (button, event) {
// this.onISENABLEClick("0");
// },
// scope: this
//}
//, '-', '帐套启用年月:', {
// xtype: 'monthfield',
// id: 'STARTMONTH',
// name: 'STARTMONTH',
// editable: false,
// hideLabel: true,
// width: 100
//}, {
// text: "启用",
// id: "btnSTARTMONTH",
// iconCls: "btnsubmit",
// handler: function (button, event) {
// this.onSTARTMONTHClick(1);
// },
// scope: this
//}, {
// text: "取消启用",
// id: "btnNotSTARTMONTH",
// iconCls: "btnsubmit",
// handler: function (button, event) {
// this.onSTARTMONTHClick(0);
// },
// scope: this
//}
]
});
Ext.apply(this, {
items: [this.panelBtn, this.treeList, this.gridList]
});
//#endregion
//#region 页面加载
this.gridList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: "" });
}, this);
this.InitGrid();
this.treeList.addListener('itemdblclick', function (dataview, record, item, cellIndex, e, b) {
if ((record.data.ISFCY || record.data.ISDEPTACC || record.data.ISEMPLACC || record.data.ISCORPACC || record.data.ISITEMACC) && record.data.DETAILED) {
this.SelectedRecord = record.data;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsCwGenlegAccitems/Edit', "科目信息录入", "300", "600", "200", "200");
}
}, this);
//#endregion
}, //end initUIComponents
//#region 按钮函数
InitGrid: function () {
this.storeListHJ.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
Ext.Ajax.request({
waitMsg: '正在查询启用的账套...',
url: '/MvcShipping/MsCwGenlegAccitems/GetSTARTMONTH',
params: {
STARTGID: ""
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
//Ext.getCmp("btnNotSTARTMONTH").hide();
Ext.getCmp("btSubmit").disable();
return;
}
//
//data = result.data;
//Ext.getCmp('STARTMONTH').setValue(data);
//Ext.getCmp("STARTMONTH").disable(); //置灰
//Ext.getCmp("btnSTARTMONTH").hide(); //隐藏
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
this.onISENABLEHide();
},
onColumnsHidden: function () {
//var record = this.storeTreeList.getAt(0);
var table = this.storeTreeList.tree; //.root.data
var elems = table.getNodes();
var record = table.getRecord(elems[0]);
var colu = this.gridList.columns; //获取列对象
if (record.MONTH.toString() == '01' || record.MONTH.toString() == '1') {
colu[7].hidden = true; //设置第几列隐藏
colu[8].hidden = true; //设置第几列隐藏
}
else {
colu[7].hidden = false; //设置第几列隐藏
colu[8].hidden = false; //设置第几列隐藏
}
},
onISENABLEHide: function () {
Ext.Ajax.request({
waitMsg: '正在判断是否有未入账的数据...',
url: '/MvcShipping/MsCwGenlegAccitems/GetISENABLE',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success) {
Ext.getCmp("btSubmit").enable();
}
else {
Ext.getCmp("btSubmit").disable();
//Ext.getCmp("btnNotSTARTMONTH").hide();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onRefreshClick: function () {
this.storeTreeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
this.storeListHJ.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
this.onISENABLEHide();
},
onISENABLEClick: function (ISENABLE) {
this.storeListHJ.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
if (ISENABLE == "0") {
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/MsCwGenlegAccitems/setISENABLE',
params: {
ISENABLE: ISENABLE
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeTreeList.load({ params: { condition: '' }, waitMsg: "正在刷新数据...", scope: this });
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);
}
else {
var record = this.storeListHJ.getAt(0); //获取索引的数据对象
var sDR = record.get("DR"); //获取字段的名字
var sCR = record.get("CR"); //获取字段的名字
if (sDR == sCR) {
Ext.MessageBox.confirm('提示', '确定入账吗?(提示:已经入账的将不予以操作!)', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在入账数据...');
Ext.Ajax.request({
waitMsg: '正在入账数据...',
url: '/MvcShipping/MsCwGenlegAccitems/setISENABLE',
params: {
ISENABLE: ISENABLE
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeTreeList.load({ params: { condition: '' }, waitMsg: "正在刷新数据...", scope: this });
this.onISENABLEHide();
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);
}
else {
alert("“借贷不平衡”不允许入账!");
return false;
}
}
},
//启用账套 暂时屏蔽不使用
onSTARTMONTHClick: function (isSTART) {
var sSTARTMONTH = Ext.getCmp('STARTMONTH');
if (sSTARTMONTH.rawValue == null) {
Ext.MessageBox.alert('提示', '请先选择帐套启用年月!');
return;
}
else {
if (sSTARTMONTH.rawValue.toString().trim() == "") {
Ext.MessageBox.alert('提示', '请先选择帐套启用年月!');
return;
}
}
//
if (isSTART == 1) {
Ext.MessageBox.confirm('提示', '确定启用帐套吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在启用帐套...');
Ext.Ajax.request({
waitMsg: '正在启用帐套...',
url: '/MvcShipping/MsCwGenlegAccitems/setSTARTMONTH',
params: {
isSTART: isSTART,
STARTMONTH: sSTARTMONTH.rawValue.toString().trim()
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("btSubmit").enable();
Ext.getCmp("STARTMONTH").disable(); //置灰
Ext.getCmp("btnSTARTMONTH").hide(); //隐藏
Ext.getCmp("btnNotSTARTMONTH").show(); //显示按钮
//
this.storeTreeList.load({ params: { condition: '' }, waitMsg: "正在刷新数据...", scope: this });
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);
}
else {
Ext.MessageBox.confirm('提示', '确定取消已启用的帐套吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在取消帐套...');
Ext.Ajax.request({
waitMsg: '正在取消帐套...',
url: '/MvcShipping/MsCwGenlegAccitems/setSTARTMONTH',
params: {
isSTART: isSTART,
STARTMONTH: sSTARTMONTH.rawValue.toString().trim()
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("btSubmit").disable();
Ext.getCmp("STARTMONTH").enable(); //置灰
Ext.getCmp("btnSTARTMONTH").show();
Ext.getCmp("btnNotSTARTMONTH").hide();
//
this.storeTreeList.load({ params: { condition: '' }, waitMsg: "正在刷新数据...", scope: this });
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);
}
},
//#region 获取 YYYY-mm-dd 格式的日期
GetDateStr: function (sdate, AddDayCount) {
var dd = new Date(sdate); //获取选择的时期对象
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var sdate = dd.toISOString();
sdate = sdate.toString().substr(0, 10);
return sdate;
},
//#endregion
//#endregion
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeTreeList;
ret[2] = this.SelectedRecord;
return ret;
}
});