Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.RptWmsSettleIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.RptWmsSettleIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.RptWmsSettleIndex, Ext.Panel, {
PageSize: 20, //每页的条数
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
//页面加载
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptWmsSettleListEntity',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptWmsSettle/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//对账客户
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' }
});
this.storeCustCode.load({ params: { condition: "" } });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '对账客户',
store: this.storeCustCode,
forceSelection: true,
minChars: 0,
id: 'CUSTOMERNAME',
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
allowBlank: true,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var data = combo.value;
Ext.getCmp('ARCLIENT').setValue(combo.value);
}
}
}
});
//#region List列表显示信息
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
//定义每页记录数设置
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: Zi.LAN.bottles, //'每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
features: [{
ftype: 'summary'
}],
stripeRows: true, //斑马线效果
stateful: false,
//bbar: Ext.create('Ext.PagingToolbar', {
// store: this.storeList,
// displayInfo: true,
// displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
// emptyMsg: "没有数据"
//}),
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum],
columns: [{
sortable: false,
dataIndex: 'ISLOCK',
header: '',
width: 0
}, {
sortable: true,
dataIndex: 'ISLOCK',
header: '入账',
width: 35
}, {
sortable: true,
dataIndex: 'DUINO',
header: '对账编号',
width: 150
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '对账客户',
width: 150
}, {
sortable: true,
dataIndex: 'STARTBILLINGDATE',
header: '开始计费日期',
//renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 90
}, {
sortable: true,
dataIndex: 'ENDBILLINGDATE',
header: '结束计费日期',
//renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 90
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200
}, {
sortable: true,
dataIndex: 'MAKEOUTUSER',
header: '生成人',
width: 80
}, {
sortable: true,
dataIndex: 'MAKEOUTTIME',
header: '生成时间',
width: 150
}, {
sortable: true,
dataIndex: 'YWCOUNT',
header: '业务数量',
width: 60
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 120,
align: 'right',
summaryType: 'sum',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return '
' + usMoney(value, 2, '', true) + '
';
}
}, {
hidden:true,
dataIndex: 'YWSTR',
header: 'YWSTR',
width: 0
}]
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/RptWmsSettle/RptWmsSettleEdit');
}, this);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
//#region formSearch
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
labelWidth: 60,
fieldLabel: '对账编号',
name: 'DUINO',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}, this.comboxCustCode
, {
fieldLabel: '开始计费日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'STARTBILLINGDATE'
}, {
fieldLabel: '结束计费日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ENDBILLINGDATE'
}, {
labelWidth: 30,
fieldLabel: '备注',
name: 'REMARK2',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}]
}]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
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: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/RptWmsSettle/RptWmsSettleEdit');
},
scope: this
}, {
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.onRefreshClick();
}, //end initUIComponents
//查询
onRefreshClick: function (button, event) {
_this = this;
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.doSetGrid();
},
scope: this
});
},
doSetGrid: function () {
SetGridTip(this.storeList,"DUINO","AMOUNT","YWSTR");
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
//删除
onDeleteClick: function (button, event) {
var selectedRecords = this.gridList.getSelectionModel().getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
var strGIDs = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.ISLOCK.toString().trim() == "") {
if (strGIDs == "") {
strGIDs = rec.get('GID');
}
else {
strGIDs = strGIDs + "," + rec.get('GID');
}
}
else {
Ext.Msg.show({ title: '提示', msg: '已入账的数据不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
}
//
if (strGIDs.toString().trim() != "") {
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/RptWmsSettle/Delete_Main',
params: {
gids: strGIDs
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeList.remove(rec);
}
//
Ext.Msg.show({ title: '提示', msg: '删除成功!', 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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
}, //onDeleteClick
//费用入账
//查询条件
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
//
var sql = "";
var DUINO = form.findField('DUINO').getValue();
sql = sql + getAndConSql(sql, DUINO, "DUINO like '%" + DUINO + "%'");
var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, "CUSTOMERNAME like '%" + CUSTOMERNAME + "%'");
var STARTBILLINGDATE = form.findField('STARTBILLINGDATE').getRawValue();
sql = sql + getAndConSql(sql, STARTBILLINGDATE, "CONVERT(char(10), STARTBILLINGDATE, 20) >='" + STARTBILLINGDATE + "'");
var ENDBILLINGDATE = form.findField('ENDBILLINGDATE').getRawValue();
sql = sql + getAndConSql(sql, ENDBILLINGDATE, "CONVERT(char(10), ENDBILLINGDATE, 20) <='" + ENDBILLINGDATE + "'");
var REMARK2 = form.findField('REMARK2').getValue();
sql = sql + getAndConSql(sql, REMARK2, "REMARK like '%" + REMARK2 + "%'");
return sql;
},
//给exit传输数据
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});