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/RptWms/RptWmsSettlementListIndex.js

494 lines
19 KiB
JavaScript

Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.RptWmsSettlementListIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.RptWmsSettlementListIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.RptWmsSettlementListIndex, Ext.Panel, {
PageSize: 20, //每页的条数
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
//页面加载
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'RptWmsSettlementListEntity',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/RptWms/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region List列表显示信息
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
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
},
stripeRows: true, //斑马线效果
stateful: false,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}),
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
}]
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/RptWms/RptWmsSettlementListEdit');
}, 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
}
}
}, {
labelWidth: 60,
fieldLabel: '对账客户',
name: 'CUSTOMERNAME',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onRefreshClick();
}
},
scope: this
}
}
}, {
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/RptWms/RptWmsSettlementListEdit');
},
scope: this
}, {
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "费用入账",
iconCls: "btislock",
handler: function (button, event) {
this.setislock(button, event);
},
scope: this
}, {
text: "取消入账",
iconCls: "btnotislock",
handler: function (button, event) {
this.setnotlock(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) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
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/RptWms/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
//费用入账
setislock: 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 (strGIDs == "") {
strGIDs = rec.get('GID');
}
else {
strGIDs = strGIDs + "," + rec.get('GID');
}
}
//
Ext.MessageBox.confirm('提示', '确定入账该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在入账数据...');
Ext.Ajax.request({
waitMsg: '正在入账数据...',
url: '/MvcShipping/RptWms/setislock',
params: {
gids: strGIDs
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.onRefreshClick();
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
});
}
}, this);
},
//取消入账
setnotlock: 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 (strGIDs == "") {
strGIDs = rec.get('GID');
}
else {
strGIDs = strGIDs + "," + rec.get('GID');
}
}
//
Ext.MessageBox.confirm('提示', '确定取消入账吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在取消入账数据...');
Ext.Ajax.request({
waitMsg: '正在取消入账数据...',
url: '/MvcShipping/RptWms/setnotlock',
params: {
gids: strGIDs
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.onRefreshClick();
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
});
}
}, this);
},
//查询条件
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;
}
});