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.

483 lines
17 KiB
JavaScript

11 months ago
Ext.namespace('Shipping');
Shipping.RptCwSofpIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.RptCwSofpIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.RptCwSofpIndex, Ext.Panel, {
PageSize: 1000,
SelectedRecord: null,
OprationStatus: null,
sqlcontext: '',
strCwSTARTGID: '',
initUIComponents: function () {
this.formname = "formRptCwSofpIndex"; //资产负债表
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptCwSofpModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwSofp/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 定义列
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ACCTYPE',
header: '资产',
width: 200
}, {
sortable: false,
dataIndex: 'LINENUM1',
header: '行次',
width: 30
}, {
sortable: false,
dataIndex: 'QTYLASTBLC',
header: '期末余额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYYEARBLC',
header: '年初余额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'ACCTYPE2',
header: '负债和所有者权益(或股东权益)',
width: 220
}, {
sortable: false,
dataIndex: 'LINENUM2',
header: '行次',
width: 30
}, {
sortable: false,
dataIndex: 'QTYLASTBLC2',
header: '期末余额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'QTYYEARBLC2',
header: '年初余额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}];
//#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',
loadMask: { msg: "数据加载中,请稍等..." },
enableHdMenu: false, //是否显示表格列的菜单
stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
columns: this.girdcolums,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id表名中间column数组跳过一开始的几列
this.gridList.reconfigure(this.storeList, this.girdcolums);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
this.gridList.addListener('cellClick', function (grid, td, columnIndex, record, tr, rowIndex, b, Object) {
if (columnIndex == 1) {
// if (rowIndex != 0 && rowIndex != 11 && rowIndex != 12 && rowIndex != 15 && rowIndex != 16 && rowIndex != 19 && rowIndex != 23 && rowIndex != 24 && rowIndex != 28 && rowIndex != 29) {
this.SelectedRecord = record;
this.OprationStatus = record.data.LINENUM1;
DsOpenEditWin('/MvcShipping/RptCwSofp/Edit', "编辑公式", "500", "940", "10", "10");
// }
}
else if (columnIndex == 5) {
// if (rowIndex != 0 && rowIndex != 13 && rowIndex != 14 && rowIndex != 18 && rowIndex != 19 && rowIndex != 20 && rowIndex != 21 && rowIndex != 22 && rowIndex != 28 && rowIndex != 29) {
this.SelectedRecord = record;
this.OprationStatus = record.data.LINENUM2;
DsOpenEditWin('/MvcShipping/RptCwSofp/Edit', "编辑公式", "500", "940", "20", "20");
// }
}
}, 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: [{
fieldLabel: '会计期间',
xtype: 'monthfield',
editable: false,
id: 'ACCDATE',
name: 'ACCDATE',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}]
}]//end items(fieldset 1)
});
//#endregion formSearch
//#region 按钮工具条
this.panelBtn = new Ext.Panel({
region: "center",
border: false,
tbar: [{
text: "重新计算",
iconCls: "btnadd",
handler: function (button, event) {
this.getRecount(button, event);
},
scope: this
}, {
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}
// , {
// text: "重置条件",
// iconCls: "btnreset",
// handler: function (button, event) {
// this.onClearSql(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
}]
});
//#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: "  "
}]
});
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]
});
Ext.apply(this, {
border: false,
items: [this.panelTop, this.gridList]
});
//this.onRefreshClick();
//#endregion
//#region 页面加载
this.storeList.on('beforeload', function (store) {
var sACCDATE = this.getACCDATE();
if (sACCDATE.toString() != "") {
Ext.apply(store.proxy.extraParams, { TEMPLATE: this.formname, ACCDATE: sACCDATE });
}
}, this);
//加载事件
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 = "  当前登录账套:“" + strCwSTARTNAME + "”  当前财务账期:“" + sYear + "年第" + sMonth + "期”  ";
Ext.getCmp("lbTitle2").setValue(sZQ);
Ext.getCmp("ACCDATE").setValue(strCwACCDATE);
//
this.onRefreshClick();
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, //end InitData
//#endregion
//#region 执行查询
onRefreshClick: function (button, event) {
var sACCDATE = this.getACCDATE();
if (sACCDATE.toString() != "") {
this.sqlcontext = sACCDATE;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', TEMPLATE: this.formname, ACCDATE: sACCDATE },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
var returnData = options[options.length-1].data;
if (returnData.QTYLASTBLC != returnData.QTYLASTBLC2) {
Ext.Msg.show({ title: '注意', msg: "资产负债表不平,请检查账务处理或报表项目公式设置", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
},
scope: this
});
}
},
//#endregion
//#region 重置条件
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
//#endregion
//#region getACCDATE
getACCDATE: function () {
var form = this.formSearch.getForm();
//会计期间
var sACCDATE = form.findField('ACCDATE').getRawValue();
if (sACCDATE.toString() == "") {
alert('请先选择会计期间!');
return '';
}
//sACCDATE = " and ACCDATE='" + sACCDATE + "'";
return sACCDATE;
},
//#endregion
//#region 重新计算
getRecount: function () {
var sACCDATE = this.getACCDATE();
if (sACCDATE.toString() != "") {
this.sqlcontext = sACCDATE;
Ext.Msg.wait('正在计算数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在计算数据...',
url: '/MvcShipping/RptCwSofp/GetRecount',
params: { TEMPLATE: this.formname, ACCDATE: 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
//#region 导出Excel
onExportClick: function (button, event) {
if (this.storeList.getCount() == 0) {
return;
}
var sACCDATE = this.getACCDATE();
//Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/RptCwSofp/GetDataListSQL',
params: { TEMPLATE: this.formname, ACCDATE: 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;
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=RptCwSofpIndex&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
});
},
//#endregion
//#region 打印
Print: function () {
if (this.storeList.getCount() == 0) {
return;
}
var sACCDATE = this.getACCDATE();
//Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/RptCwSofp/GetDataListStr',
params: { TEMPLATE: this.formname, ACCDATE: 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 = 'RptCwSofpList';
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;
ret[1] = this.OprationStatus;
return ret;
}
});