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/RptCwVouchersGl/RptCwVouchersGlIndex.js

580 lines
20 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.RptCwVouchersGlIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.RptCwVouchersGlIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.RptCwVouchersGlIndex, Ext.Panel, {
PageSize: 1000,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
strCwSTARTGID: '',
initUIComponents: function () {
this.formname = "formRptCwVouchersGlIndex"; //凭证汇总表
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptCwVouchersGlModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwVouchersGl/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
/*
this.storeSumList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptCwVouchersGlModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptCwVouchersGl/GetDataSumList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
*/
//#endregion
//#region 定义列
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
header: '唯一编码',
width: 0
}, {
sortable: false,
dataIndex: 'ACCID',
header: '科目代码',
width: 120
}, {
sortable: false,
dataIndex: 'ACCNAME',
header: '科目名称',
width: 300
}, {
sortable: false,
dataIndex: 'DR',
header: '借方金额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'CR',
header: '贷方金额',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}];
/*
this.girdcolumsSum = [{
sortable: false,
dataIndex: 'GID',
header: '',
width: 80
}, {
sortable: false,
dataIndex: 'DR',
header: '借方',
align: 'right',
width: 100,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'CR',
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,
trackMouseOver: true,
disableSelection: false,
columnLines: true,
columns: this.girdcolums,
viewConfig: {
enableTextSelection: true //允许复制数据
//,autoFill: true
},
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.gridSumList = new Ext.grid.GridPanel({
store: this.storeSumList,
region: 'south',
height: 60,
loadMask: { msg: "数据加载中,请稍等..." },
columns: this.girdcolumsSum
});
*/
//#endregion
//#region formSearch 下拉框信息加载
//键值维护表_凭证字
this.storeCrmKeyCodeCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CrmKeyCodeModel',
proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' }
});
this.storeCrmKeyCodeCode.load({ params: { condition: " and KEYTYPE='凭证字'"} });
this.comboxVKNO = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '凭证字',
store: this.storeCrmKeyCodeCode,
forceSelection: true,
name: 'VKNO',
width: 100,
labelAlign: 'right',
labelWidth: 40,
valueField: 'KEYVALUE',
displayField: 'KEYVALUE',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
//allowBlank: false,
});
//#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',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxVKNO, {
fieldLabel: '凭证日期',
format: 'Y-m-d',
xtype: 'datefield',
editable: false,
allowBlank: false,
id: 'VOUDATEbgn',
name: 'VOUDATEbgn',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}, {
fieldLabel: '至',
labelWidth: 20,
format: 'Y-m-d',
xtype: 'datefield',
editable: false,
allowBlank: false,
id: 'VOUDATEend',
name: 'VOUDATEend',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}, {
xtype: "checkbox", //checkbox控件
id: "cbZKM",
name: "cbZKM",
boxLabel: "包括子科目",
fieldLabel: "",
inputValue: "true", //选中的值
uncheckedValue: "false" //未选中的值
//checked: true //绘制时的选中状态
}, {
xtype: 'displayfield',
id: 'lbTitle',
name: 'lbTitle',
//width: 200,
//labelWidth: 200,
value: "【凭证数0 张附件数0 张】",
allowBlank: false
}]
}]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
//#region 按钮工具条
this.CheckSaveQuery = new Ext.form.Checkbox({
fieldLabel: '记忆查询条件',
checked: true,
width: 120
});
this.panelBtn = new Ext.Panel({
region: "center",
border: false,
tbar: [{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
var isvisible = false;
var issavevalue = false;
if (this.CheckSaveQuery.checked) {
issavevalue = true
}
saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue);
},
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
}, '-', this.CheckSaveQuery]
});
//#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.gridSumList
});
//this.onRefreshClick();
//#endregion
//#region 页面加载
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
var strCbZKM = this.getCbZKM();
var VOUDATEbgn = Ext.getCmp('VOUDATEbgn').getRawValue();
if (sql.toString() != "") {
Ext.apply(store.proxy.extraParams, { condition: sql, strCbZKM: strCbZKM, VOUDATEbgn: VOUDATEbgn });
}
}, this);
//加载事件
this.InitData();
LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery);
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/RptCwVouchersGl/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 str1 = arrtmp[5].toString();
var str2 = arrtmp[6].toString();
//
var sZQ = "  当前登录账套:“" + strCwSTARTNAME + "”  当前财务账期:“" + sYear + "年第" + sMonth + "期”  ";
Ext.getCmp("lbTitle2").setValue(sZQ);
Ext.getCmp("VOUDATEbgn").setValue(str1);
Ext.getCmp("VOUDATEend").setValue(str2);
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
async: false,
scope: this
});
}, //end InitData
//#endregion
//#region 执行查询
onRefreshClick: function (button, event) {
var sql = this.getCondition();
var strCbZKM = this.getCbZKM();
var VOUDATEbgn = Ext.getCmp('VOUDATEbgn').getRawValue();
if (sql.toString() != "") {
this.storeList.load({ params: { condition: sql, strCbZKM: strCbZKM, VOUDATEbgn: VOUDATEbgn }, waitMsg: "正在查询数据...", scope: this });
//this.storeSumList.load({ params: { condition: sql, strCbZKM: strCbZKM }, waitMsg: "正在查询数据...", scope: this });
this.getlbTitle(sql, strCbZKM);
}
},
//#endregion
//#region 查询
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var VKNO = form.findField('VKNO').getValue();
sql = sql + getAndConSql(sql, VKNO, "VKNO='" + VKNO + "'");
//会计期间
var VOUDATEbgn = form.findField('VOUDATEbgn').getRawValue();
var VOUDATEend = form.findField('VOUDATEend').getRawValue();
sql = sql + getAndConSql(sql, VOUDATEbgn, "VOUDATE>='" + VOUDATEbgn + "'");
sql = sql + getAndConSql(sql, VOUDATEend, "VOUDATE<='" + VOUDATEend + "'");
return sql;
},
getCbZKM: function () {
var form = this.formSearch.getForm();
var strCbZKM = form.findField('cbZKM').getValue();
if (strCbZKM) {
strCbZKM = " or PACCGID is not NULL";
}
else {
strCbZKM = " or (PACCGID='ZC' or PACCGID='FZ' or PACCGID='GT' or PACCGID='QY' or PACCGID='CB' or PACCGID='SY')";
}
return strCbZKM;
},
//#endregion
//#region 重置条件
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
this.InitData();
}, //onDeleteClick
//#endregion
//#region 子科目
getlbTitle: function (sql, strCbZKM) {
Ext.Ajax.request({
params: { condition: sql, strCbZKM: strCbZKM },
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/RptCwVouchersGl/GetlbTitle',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) { return; }
data = result.data;
Ext.getCmp("lbTitle").setValue(data);
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, //end InitData
//#endregion
//#region 导出Excel
onExportClick: function (button, event) {
var sql = escape(this.getCondition());
var strCbZKM = escape(this.getCbZKM());
var VOUDATEbgn = Ext.getCmp('VOUDATEbgn').getRawValue();
if (sql.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 openUrl = "../../Reports/RptExport.aspx?handle=RptCwVouchersGlIndex&formname=" + this.formname + "&condition1=" + sql + "&condition2=" + strCbZKM + "&condition3=" + VOUDATEbgn;
window.open(openUrl, openType, openSet);
}
},
//ExtJs 自带的导出当前页的excel导出函数
onExportClick2: function (button, event) {
GridExportExcelPage(this.gridList);
},
//#endregion
//#region 打印
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
var sql = _this.getCondition();
var strCbZKM = _this.getCbZKM();
var VOUDATEbgn = Ext.getCmp('VOUDATEbgn').getRawValue();
var form = this.formSearch.getForm();
var VKNO = form.findField('VKNO').getValue();
var VOUDATEbgn = form.findField('VOUDATEbgn').getRawValue();
var VOUDATEend = form.findField('VOUDATEend').getRawValue();
//Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/RptCwVouchersGl/GetDataListStr',
params: { condition: sql, strCbZKM: strCbZKM, VOUDATEbgn: VOUDATEbgn, 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 = 'RptCwVouchersGlList';
var sql1 = returnStr;
var sql2 = "select '" + VKNO + "' VKNO,'" + VOUDATEbgn + "' VOUDATEbgn,'" + VOUDATEend + "' VOUDATEend ";
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.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});