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/RptCwCfs/RptCwCfsIndex.js

1450 lines
56 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.RptCwCfsIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.RptCwCfsIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.RptCwCfsIndex, Ext.Panel, {
PageSize: 1000,
SelectedRecord: null,
sqlcontext: '',
strCwSTARTGID: '',
initUIComponents: function () {
this.formname = "formRptCwCfsIndex"; //现金流量表
//#region formSearch 下拉框信息加载
//科目加载
this.storeCwCfsModel = Ext.create('DsExt.ux.RefTableStore', {
model: 'RptCwCfsModelModel',
proxy: { url: '/MvcShipping/RptCwCfs/GetCwCfsModelList' }
});
this.storeCwCfsModel.load({ params: { condition: ""} });
this.comboxCwCfsModel = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '项目方案',
store: this.storeCwCfsModel,
forceSelection: true, //输入值是否严格为待选列表中存在的值
allowBlank: false,
id: 'MODELNAME',
name: 'MODELNAME',
valueField: 'MODELNAME',
displayField: 'MODELNAME',
value: '默认方案',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (combo.value.toString() != "") {
var sMODELGID = "";
var sISDEFAULT = "false";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', combo.value.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
sISDEFAULT = AccitemsRaw.data.ISDEFAULT.toString();
}
}
this.storeCwCfsModelItemList.load({ params: { sMODELGID: sMODELGID }, waitMsg: "正在查询数据...", scope: this });
this.storeCwCfsModelItemList2.removeAll();
//
if (sISDEFAULT == "true") {
this.setBtnStatusDisableItem(true);
}
else {
this.setBtnStatusDisableItem(false);
}
//
this.onRefreshClick();
}
},
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
});
//项目属性
Ext.define('ITEMTYPEModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] });
var dataITEMTYPE = [{ "Name": "现金流入" }, { "Name": "现金流出"}];
var storeITEMTYPE = Ext.create('Ext.data.Store', { model: 'ITEMTYPEModel', data: dataITEMTYPE });
this.comboxITEMTYPE = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '项目属性',
forceSelection: true,
allowBlank: false,
store: storeITEMTYPE,
id: 'ITEMTYPE',
name: 'ITEMTYPE',
valueField: 'Name',
displayField: 'Name',
value: "现金流入"
});
//#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: [{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCwCfsModel, {
fieldLabel: '会计期间',
xtype: 'monthfield',
editable: false,
allowBlank: false, //是否允许为空
id: 'ACCDATE',
name: 'ACCDATE',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}, {
xtype: 'displayfield',
id: 'lbTitle1',
name: 'lbTitle1',
value: "(注意:报表不平衡)",
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return '<SPAN style="COLOR: red; Font-size:18px; Font-weight:bold;">' + value + '</SPAN>';
}
}]
}]
}]
});
//#endregion formSearch
//#region 报表 列表
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptVWCwCfsTemplateModelItemModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwCfs/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 定义列
this.girdcolums = [{
sortable: false,
hidden: true,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ITEMNAME',
header: '项目',
width: 350
}, {
sortable: false,
dataIndex: 'QTYBLC',
header: '本月金额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (record.data.ITEMNAME == "一、经营活动产生的现金流量:" || record.data.ITEMNAME == "二、投资活动产生的现金流量:" || record.data.ITEMNAME == "三、筹资活动产生的现金流量:") {
return '';
}
else {
value = usMoney(value, 2, '', true);
}
return value;
}
}, {
sortable: false,
dataIndex: 'QTYLASTBLC',
header: '本年累计金额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (record.data.ITEMNAME == "一、经营活动产生的现金流量:" || record.data.ITEMNAME == "二、投资活动产生的现金流量:" || record.data.ITEMNAME == "三、筹资活动产生的现金流量:") {
return '';
}
else {
value = usMoney(value, 2, '', true);
}
return value;
}
}, {
sortable: false,
hidden: true,
dataIndex: 'DETAILED',
header: '是否末级项目',
width: 0
}, {
sortable: false,
hidden: true,
dataIndex: 'ITEMTYPE',
header: '项目属性',
width: 0
}];
//#endregion
//#region List列表显示信息
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
region: 'center',
border: false,
loadMask: { msg: "数据加载中,请稍等..." },
enableHdMenu: false, //是否显示表格列的菜单
stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
columns: this.girdcolums,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
}
});
//#endregion
//#endregion
//#region 调整 列表
//#region 定义数据集
this.storeListTZ = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptVWCwCfsTemplateModelItemModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwCfs/GetDataListTZ',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 定义列
this.girdcolumsTZ = [{
sortable: false,
hidden: true,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ITEMNAME',
header: '项目',
width: 350,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
if (record.data.DETAILED == true && record.data.ITEMTYPE != "") {
return '<SPAN style="text-decoration:underline; COLOR: red">' + value + '</SPAN>';
}
return value;
}
}, {
sortable: false,
dataIndex: 'QTYBLC',
header: '本月金额(合计)',
align: 'right',
width: 120,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYLASTBLC',
header: '本年累计金额(合计)',
align: 'right',
width: 140,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYBLC_S',
header: '本月金额(默认)',
align: 'right',
width: 120,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYLASTBLC_S',
header: '本年累计金额(默认)',
align: 'right',
width: 140,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYBLC_H',
header: '本月金额(调整差)',
align: 'right',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true,
allowBlank: false
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYLASTBLC_H',
header: '本年累计金额(调整差)',
align: 'right',
width: 140,
editor: {
xtype: 'textfield',
selectOnFocus: true,
allowBlank: false
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
hidden: true,
dataIndex: 'DETAILED',
header: '是否末级项目',
width: 0
}, {
sortable: false,
hidden: true,
dataIndex: 'ITEMTYPE',
header: '项目属性',
width: 0
}, {
sortable: false,
hidden: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 0
}, {
sortable: false,
hidden: true,
dataIndex: 'MODELGID',
header: '',
width: 0
}, {
sortable: false,
hidden: true,
dataIndex: 'ITEMGID',
header: '',
width: 0
}];
//#endregion
//#region List列表显示信息
this.gridListCellEditing2 = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
//定义Grid
this.gridListTZ = new Ext.grid.GridPanel({
store: this.storeListTZ,
region: 'center',
border: false,
loadMask: { msg: "数据加载中,请稍等..." },
enableHdMenu: false, //是否显示表格列的菜单
stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
plugins: [this.gridListCellEditing2],
selType: 'cellmodel',
columns: this.girdcolumsTZ,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
listeners: {
scope: this,
'cellclick': function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
if (cellIndex == 6 || cellIndex == 7) {
if (record.data.DETAILED == false || record.data.ITEMTYPE == "") {
return false;
}
}
},
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
if (e.colIdx == 6) {
var dQTYBLC_S = parseFloat(e.record.data['QTYBLC_S']);
var dQTYBLC_H = parseFloat(e.record.data['QTYBLC_H']);
e.record.set('QTYBLC', (dQTYBLC_S + dQTYBLC_H));
}
else if (e.colIdx == 7) {
var dQTYLASTBLC_S = parseFloat(e.record.data['QTYLASTBLC_S']);
var dQTYLASTBLC_H = parseFloat(e.record.data['QTYLASTBLC_H']);
e.record.set('QTYLASTBLC', (dQTYLASTBLC_S + dQTYLASTBLC_H));
}
//保存
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/RptCwCfs/SaveRowTZ',
scope: this,
params: {
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) {
this.onRefreshClick();
} 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.gridListTZ.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
this.gridListTZ.addListener('cellClick', function (grid, td, columnIndex, record, tr, rowIndex, b, Object) {
if (columnIndex == 1) {
if (record.data.DETAILED == true && record.data.ITEMTYPE != "") {
this.SelectedRecord = record;
DsOpenEditWin('/MvcShipping/RptCwCfs/Edit', "编辑公式", "500", "940", "10", "10");
}
}
}, this);
//#endregion
//#endregion
//#region 项目维护列表
//#region 定义数据集
this.storeCwCfsModelItemList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptCwCfsModelItemModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwCfs/GetCwCfsModelItemList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeCwCfsModelItemList2 = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptCwCfsModelItemModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwCfs/GetCwCfsModelItemList2',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 定义列
this.girdcolumsCwCfsModelItem = [{
sortable: false,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ITEMNAME',
header: '项目',
width: 200
}];
this.girdcolumsCwCfsModelItem2 = [{
sortable: false,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
allowBlank: false,
text: '项目属性',
dataIndex: 'ITEMTYPE',
//width: 100,
align: 'center',
editor: this.comboxITEMTYPE
}, {
sortable: false,
allowBlank: false,
text: '子项目',
dataIndex: 'ITEMNAME',
width: 400,
editor: {
xtype: 'textfield',
selectOnFocus: true,
allowBlank: false
}
}];
//#endregion
//#region List列表显示信息
//定义Grid
this.gridCwCfsModelItemList = new Ext.grid.GridPanel({
store: this.storeCwCfsModelItemList,
region: "west",
//region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
enableHdMenu: false, //是否显示表格列的菜单
stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
columns: this.girdcolumsCwCfsModelItem,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
}
});
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridCwCfsModelItemList2 = new Ext.grid.GridPanel({
store: this.storeCwCfsModelItemList2,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
enableHdMenu: false, //是否显示表格列的菜单
stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
enableDragDrop: true, //激活行拖动
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolumsCwCfsModelItem2
});
this.gridCwCfsModelItemList2.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
this.gridCwCfsModelItemList.addListener('cellClick', function (grid, td, columnIndex, record, tr, rowIndex, b, Object) {
this.storeCwCfsModelItemList2.load({ params: { sITEMGID: record.data.GID.toString() }, waitMsg: "正在查询数据...", scope: this });
}, this);
//#endregion
//#endregion
//#region 按钮工具条
this.panelBtn = new Ext.Panel({
region: "center",
border: false,
tbar: [{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, '-', {
text: "新建方案",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddModel(button, event);
},
scope: this
}, {
id: "btnAlter",
text: "调整",
iconCls: "btnsave",
handler: function (button, event) {
this.onALTERModel(button, event);
},
scope: this
}, {
id: "btnSave2",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.onALTERModel2(button, event);
},
scope: this
}, '-', {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, {
text: "打印",
iconCls: 'btnprint',
handler: function (button, event) {
this.Print();
},
scope: this
}]
});
this.panelBtn2 = new Ext.Panel({
region: "north",
tbar: [{
text: '操作子项目:',
scope: this
}, '-', {
text: '添加',
tooltip: '添加',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}, {
id: 'btnSave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save();
},
scope: this
}, {
text: '删除',
tooltip: '删除',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}, '-', {
text: "上移",
id: "btPrevious",
handler: function (button, event) {
this.onPrevious();
},
scope: this
}, {
text: "下移",
id: "btLast",
handler: function (button, event) {
this.onLast();
},
scope: this
}]
});
this.panelBtn3 = new Ext.Panel({
region: "north",
border: false,
tbar: [{
text: '调整操作:',
scope: this
}, {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
text: "重新计算(保存)",
iconCls: "btnadd",
handler: function (button, event) {
this.getRecount(button, event);
},
scope: this
}, {
id: 'btTitle1',
text: "自动调平",
iconCls: "btnadd",
handler: function (button, event) {
this.onAutoLevel(button, event);
},
scope: this
}]
});
//#endregion
//#region 页面布局
this.panelZQ = new Ext.Panel({
layout: "border",
region: "east",
width: 500,
style: 'text-align:right;',
border: false,
items: [{
xtype: 'displayfield',
id: 'lbTitle2',
name: 'lbTitle2',
value: "&nbsp;&nbsp;"
}]
});
this.panelTopF = new Ext.Panel({
layout: "border",
region: "north",
height: 26,
//border: false,
items: [this.panelBtn, this.panelZQ]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 65,
border: false,
items: [this.panelTopF, this.formSearch]
});
this.panelpage = new Ext.Panel({
id: 'panelpage1',
title: '报表',
layout: "border",
region: 'center',
animate: true,
autoScroll: false, //允许显示滚动条
autoDestroy: false, //不让它销毁
//containerScroll: true,
border: false,
frame: false,
items: [this.gridList]
});
this.panelpage2 = new Ext.Panel({
id: 'panelpage2',
title: '调整',
layout: "border",
region: 'center',
animate: true,
autoScroll: false, //允许显示滚动条
autoDestroy: false, //不让它销毁
//containerScroll: true,
border: false,
frame: false,
items: [this.panelBtn3, this.gridListTZ]
});
this.panelTop2 = new Ext.Panel({
layout: "border",
region: "center",
height: 65,
border: false,
items: [this.panelBtn2, this.gridCwCfsModelItemList2]
});
this.panelpage3 = new Ext.Panel({
id: 'panelpage3',
title: '项目维护',
layout: "border",
region: 'center',
animate: true,
autoScroll: false, //允许显示滚动条
autoDestroy: false, //不让它销毁
//containerScroll: true,
border: false,
frame: false,
items: [this.gridCwCfsModelItemList, this.panelTop2]
});
this.tabPanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
border: false,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelpage,
this.panelpage2,
this.panelpage3
]
});
Ext.apply(this, {
border: false,
items: [this.panelTop, this.tabPanel]
});
//#endregion
//#region 页面加载
this.InitData();
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/RptCwGenlegAccitems/GetData',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
return;
}
data = result.data;
var arrtmp = data.toString().split("&");
this.strCwSTARTGID = arrtmp[0].toString();
var strCwSTARTNAME = arrtmp[1].toString();
var strCwACCDATE = arrtmp[2].toString();
var sYear = arrtmp[3].toString();
var sMonth = arrtmp[4].toString();
//
var sZQ = "&nbsp;&nbsp;当前登录账套:“" + strCwSTARTNAME + "”&nbsp;&nbsp;当前财务账期:“" + sYear + "年第" + sMonth + "期”&nbsp;&nbsp;";
Ext.getCmp("lbTitle2").setValue(sZQ);
Ext.getCmp("ACCDATE").setValue(strCwACCDATE);
//
var sMODELGID = "";
var sISDEFAULT = "false";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
sISDEFAULT = AccitemsRaw.data.ISDEFAULT.toString();
}
}
this.storeCwCfsModelItemList.load({ params: { sMODELGID: sMODELGID }, waitMsg: "正在查询数据...", scope: this });
if (sISDEFAULT == "true") {
this.setBtnStatusDisableItem(true);
}
else {
this.setBtnStatusDisableItem(false);
}
//
this.setBtnStatusDisableTZ(false);
//
this.onRefreshClick();
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, //end InitData
//#endregion
//#region 执行查询
onRefreshClick: function (button, event) {
if (!this.formSearch.getForm().isValid()) {
return false;
}
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', sMODELGID: sMODELGID, sACCDATE: sACCDATE }, waitMsg: "正在查询数据...", scope: this });
this.storeListTZ.load({
params: { start: 0, limit: this.PageSize, sort: '', sMODELGID: sMODELGID, sACCDATE: sACCDATE },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
this.setBtnStatusDisablePH();
},
scope: this
});
},
//#endregion
//#region 调整 按钮函数
setBtnStatusDisableTZ: function (enable) {
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
var sACCDATE_Now = Ext.getCmp("lbTitle2").getValue().toString();
var iVar = sACCDATE_Now.indexOf("年");
var sACCDATE_Now = sACCDATE_Now.substr((iVar - 4), 4);
if (sACCDATE.indexOf(sACCDATE_Now) < 0) {
Ext.Msg.show({ title: '提示', msg: '要操作的“会计期间”不属于当前会计年,请先“返结转”到要调整的会计期间!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
else {
if (enable) {
Ext.getCmp('btnAlter').hide();
Ext.getCmp('btnSave2').show();
Ext.getCmp('panelpage1').disable();
Ext.getCmp('panelpage2').enable();
Ext.getCmp('panelpage1').hide();
Ext.getCmp('panelpage2').show();
} else {
Ext.getCmp('btnAlter').show();
Ext.getCmp('btnSave2').hide();
Ext.getCmp('panelpage1').enable();
Ext.getCmp('panelpage2').disable();
Ext.getCmp('panelpage1').show();
Ext.getCmp('panelpage2').hide();
}
//
var sISDEFAULT = "false";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
sISDEFAULT = AccitemsRaw.data.ISDEFAULT.toString();
}
}
if (sISDEFAULT == "true") {
this.setBtnStatusDisableItem(true);
}
else {
this.setBtnStatusDisableItem(enable);
}
}
},
setBtnStatusDisablePH: function () {
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
Ext.Ajax.request({
waitMsg: '正在判断资产负债表是否平衡...',
url: '/MvcShipping/RptCwCfs/onIsCwSofp',
params: { sACCDATE: sACCDATE },
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.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var dlQTYLASTBLC = result.data.toString();
var dlQTYLASTBLC2 = this.storeListTZ.data.items[this.storeListTZ.data.length - 1].data.QTYLASTBLC;
if (dlQTYLASTBLC != dlQTYLASTBLC2) {
Ext.getCmp('lbTitle1').show();
Ext.getCmp('btTitle1').show();
} else {
Ext.getCmp('lbTitle1').hide();
Ext.getCmp('btTitle1').hide();
}
//
Ext.Msg.hide();
} else {
Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
},
scope: this
});
},
onALTERModel: function () {
this.setBtnStatusDisableTZ(true);
//
},
onALTERModel2: function () {
this.setBtnStatusDisableTZ(false);
//
},
onAutoLevel: function () {
this.setBtnStatusDisableTZ(true);
//
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
if (sACCDATE.toString() != "") {
this.sqlcontext = sACCDATE;
Ext.Msg.wait('正在计算数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在计算数据...',
url: '/MvcShipping/RptCwCfs/onAutoLevel',
params: { sMODELGID: sMODELGID, sACCDATE: sACCDATE },
callback: function (options, success, response) {
if (success) {
this.onRefreshClick();
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
Ext.Msg.hide();
},
timeout: 3000000, //30秒
scope: this
});
}
},
//#region 重新计算
getRecount: function () {
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
if (sACCDATE.toString() != "") {
this.sqlcontext = sACCDATE;
Ext.Msg.wait('正在计算数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在计算数据...',
url: '/MvcShipping/RptCwCfs/GetRecount',
params: { sMODELGID: sMODELGID, sACCDATE: sACCDATE },
callback: function (options, success, response) {
if (success) {
this.onRefreshClick();
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
Ext.Msg.hide();
},
timeout: 3000000, //30秒
scope: this
});
}
},
//#endregion
//#endregion
//#region 项目维护 按钮函数
onAddModel: function () {
this.showContactForm(false, this);
},
//#region 层_显示信息
showContactForm: function (win, _this) {
var required = '<span style="color:red;font-weight:bold;" data-qtip="Required">*</span>';
if (!win) {
//#region 编辑formDiv 基本信息
var formDiv = Ext.widget('form', {
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 60,
labelStyle: 'font-weight:bold'
},
items: [{
id: 'FANAME',
fieldLabel: '方案名称',
xtype: 'textfield',
allowBlank: false
}],
buttons: [{
text: '提交',
handler: function (options, success, response) {
if (!this.up('form').getForm().isValid()) {
return;
}
var dataDiv = Ext.getCmp("FANAME").getValue();
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/RptCwCfs/onAddModel',
scope: this,
params: {
dataDiv: Ext.JSON.encode(dataDiv)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
_this.storeCwCfsModel.load({
params: { condition: "" },
callback: function (options, success, response) {
Ext.getCmp("MODELNAME").setValue(dataDiv);
//
var sMODELGID = "";
var sISDEFAULT = "false";
var AccitemsList = DsStoreQueryBy(_this.storeCwCfsModel, 'MODELNAME', dataDiv);
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
sISDEFAULT = AccitemsRaw.data.ISDEFAULT.toString();
}
}
_this.storeCwCfsModelItemList.load({ params: { sMODELGID: sMODELGID }, waitMsg: "正在查询数据...", scope: this });
_this.storeCwCfsModelItemList2.removeAll();
//
if (sISDEFAULT == "true") {
_this.setBtnStatusDisableItem(true);
}
else {
_this.setBtnStatusDisableItem(false);
}
//
_this.onRefreshClick();
},
scope: this
});
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
Ext.Msg.hide();
} else {
Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
});
//
this.up('form').getForm().reset();
this.up('window').close();
}
}, {
text: '取消',
handler: function () {
this.up('form').getForm().reset();
this.up('window').close();
}
}]
});
//#endregion
win = Ext.widget('window', {
title: '新增方案',
width: 250,
height: 110,
layout: 'fit',
closeAction: 'destroy', //hide,
resizable: true,
modal: true,
closable: false,
items: formDiv
});
}
win.show();
},
//#endregion
setBtnStatusDisableItem: function (enable) {
if (enable) {
Ext.getCmp('btnadd').disable();
Ext.getCmp('btnSave').disable();
Ext.getCmp('btndel').disable();
Ext.getCmp('btPrevious').disable();
Ext.getCmp('btLast').disable();
} else {
Ext.getCmp('btnadd').enable();
Ext.getCmp('btnSave').enable();
Ext.getCmp('btndel').enable();
Ext.getCmp('btPrevious').enable();
Ext.getCmp('btLast').enable();
}
},
onAddClick: function () {
var record = Ext.create('RptCwCfsModelItemModel', {
GID: '*',
ITEMTYPE: '',
ITEMNAME: ''
});
this.storeCwCfsModelItemList2.add(record);
var n = this.storeCwCfsModelItemList2.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
},
Save: function () {
if (!this.formSearch.getForm().isValid()) {
return false;
}
//
var selectedRecords = this.gridCwCfsModelItemList.getSelectionModel().getSelection(); //获得选中的项
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择所属项目!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0];
var sITEMGID = rec.data.GID.toString();
var sLINENUM = rec.data.LINENUM.toString();
//
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
//
var bodydatas = [];
for (var i = 0; i < this.storeCwCfsModelItemList2.getCount(); i += 1) {
var member = this.storeCwCfsModelItemList2.getAt(i);
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/RptCwCfs/SaveItem',
scope: this,
params: {
body: jsonBody,
sMODELGID: sMODELGID,
sITEMGID: sITEMGID,
sLINENUM: sLINENUM
},
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.storeCwCfsModelItemList2.load({ params: { sITEMGID: sITEMGID }, 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
onDelClick: function () {
var selectedRecords = this.gridCwCfsModelItemList2.getSelectionModel().getSelection(); //获得选中的项
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/RptCwCfs/DeleteItem',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var selectedRecords = this.gridCwCfsModelItemList.getSelectionModel().getSelection();
var rec = selectedRecords[0];
this.storeCwCfsModelItemList2.load({ params: { sITEMGID: rec.data.GID.toString() }, waitMsg: "正在查询数据...", scope: this });
//this.girdcolumsCwCfsModelItem2.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 });
}
}
Ext.Msg.hide();
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
});
}
}, this);
},
onPrevious: function () {
var records = this.gridCwCfsModelItemList2.getSelectionModel().getSelection();
for (var i in records) {
var record = records[i];
var index = this.storeCwCfsModelItemList2.indexOf(record);
if (index > 0) {
this.storeCwCfsModelItemList2.removeAt(index);
this.storeCwCfsModelItemList2.insert(index - 1, record);
this.gridCwCfsModelItemList2.getView().refresh();
this.gridCwCfsModelItemList2.getSelectionModel().selectRange(index - 1, index - 1);
}
}
},
onLast: function () {
var records = this.gridCwCfsModelItemList2.getSelectionModel().getSelection();
for (var i in records) {
var record = records[i];
var index = this.storeCwCfsModelItemList2.indexOf(record);
if (index < this.storeCwCfsModelItemList2.getCount() - 1) {
this.storeCwCfsModelItemList2.removeAt(index);
this.storeCwCfsModelItemList2.insert(index + 1, record);
this.gridCwCfsModelItemList2.getView().refresh();
this.gridCwCfsModelItemList2.getSelectionModel().selectRange(index + 1, index + 1);
}
}
},
//#endregion
//#region 重置条件
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
//#endregion
//#region 导出Excel
onExportClick: function (button, event) {
if (this.storeList.getCount() == 0) {
return;
}
//
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
//
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/RptCwCfs/GetDataListSQL',
params: { sMODELGID: sMODELGID, sACCDATE: sACCDATE, printstr: 'false' },
callback: function (options, success, response) {
if (success) {
var ddd = Ext.MessageBox.isVisible();
if (Ext.MessageBox.isVisible()) {
Ext.MessageBox.hide();
}
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnStr = jsonresult.data;
if (returnStr.toString() != "") {
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 condition1 = escape(returnStr.toString());
var openUrl = "../../Reports/RptExport.aspx?handle=RptCwCfsIndex&formname=" + this.formname + "&condition1=" + condition1;
window.open(openUrl, openType, openSet);
}
} 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
});
}
},
scope: this
});
},
//ExtJs 自带的导出当前页的excel导出函数
onExportClick2: function (button, event) {
GridExportExcelPage(this.gridList);
},
//#endregion
//#region 打印
Print: function () {
if (this.storeList.getCount() == 0) {
return;
}
//
var sMODELGID = "";
var AccitemsList = DsStoreQueryBy(this.storeCwCfsModel, 'MODELNAME', Ext.getCmp("MODELNAME").getValue());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
sMODELGID = AccitemsRaw.data.GID.toString();
}
}
var sACCDATE = Ext.getCmp("ACCDATE").getRawValue();
//
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/RptCwCfs/GetDataListStr',
params: { sMODELGID: sMODELGID, sACCDATE: sACCDATE, printstr: 'true' },
callback: function (options, success, response) {
if (success) {
var ddd = Ext.MessageBox.isVisible();
if (Ext.MessageBox.isVisible()) {
Ext.MessageBox.hide();
}
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnStr = jsonresult.data;
var printType = 'RptCwCfsList';
var sql1 = returnStr;
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} 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
});
}
},
scope: this
});
},
//#endregion
OprationSwap: function () {
var ret = new Array();
ret[0] = this.SelectedRecord;
return ret;
}
});