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/MsOpBulk/MsOpBulkIndex.js

728 lines
24 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpBulkIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpBulkIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpBulkIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
selectbsno: '',
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpBulk',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpBulk/GetDataList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 130
}, {
sortable: true,
dataIndex: 'ORDERNO',
header: '订舱编号',
width: 130
}, {
sortable: true,
dataIndex: 'BSDATE',
header: '录入日期',
width: 90
}, {
sortable: true,
dataIndex: 'TRANSTYPE',
header: '运输方式',
width: 90
}, {
sortable: true,
dataIndex: 'OPSTATUS',
header: '托单状态',
width: 90
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 80
}, {
sortable: true,
dataIndex: 'OPDATE',
header: '业务日期',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: '起运日期',
width: 90
}, {
sortable: true,
dataIndex: 'LASTETD',
header: '最晚结束时间',
width: 90
}, {
sortable: true,
dataIndex: 'PORTLOAD',
header: '起运地',
width: 100
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的地',
width: 100
}, {
sortable: true,
dataIndex: 'OP',
header: '操作',
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: '销售',
width: 80
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 100
}, {
sortable: true,
dataIndex: 'BSSOURCEDETAIL',
header: '来源明细',
width: 80
}, {
sortable: true,
dataIndex: 'GOODSNAME',
header: '商品名称',
width: 80
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
}, {
sortable: true,
dataIndex: 'KGS',
header: '吨数',
width: 80
}, {
sortable: true,
dataIndex: 'OVERKGS',
header: '完成吨数',
width: 80
}, {
sortable: true,
dataIndex: 'CBM',
header: '尺码',
width: 80
}
];
//定义Grid
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
selModel: this.GridCheckBoxModel,
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: "没有数据"
})
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpBulk/Edit');
}, this);
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modOpBulkOpwt"} });
this.storeTransType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTransType.load({ params: { enumTypeId: 97002} });
this.comboxTransType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '运输方式',
store: this.storeTransType,
name: 'TransType'
});
this.storeBsStatus = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsStatus.load({ params: { enumTypeId: 97001} });
this.comboxBsStatus = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '托单状态',
store: this.storeBsStatus,
name: 'OpStatus'
});
//状态_业务状态
Ext.define('BSSTATUSModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Name', type: 'string' }
]
});
var dataBSSTATUS = [{ "Name": "未锁定" }, { "Name": "锁定" }, { "Name": ""}];
var storeBSSTATUS = Ext.create('Ext.data.Store', {
model: 'BSSTATUSModel',
data: dataBSSTATUS
});
//业务状态
this.comboxBSSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '业务锁定',
forceSelection: true,
store: storeBSSTATUS,
name: 'BSSTATUS',
valueField: 'Name',
displayField: 'Name'
});
//费用状态
this.comboxFEESTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '费用锁定',
forceSelection: true,
store: storeBSSTATUS,
name: 'FEESTATUS',
valueField: 'Name',
displayField: 'Name'
});
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: [{
fieldLabel: '委托编号',
name: 'CustNo'
}, this.comboxBsStatus, {
fieldLabel: '从发运日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn'
}, {
fieldLabel: '到发运日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd'
}, {
fieldLabel: '订舱编号',
name: 'OrderNo'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '委托单位',
name: 'CustName'
}, this.comboxTransType, {
fieldLabel: '从业务日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'OpDateBgn'
}, {
fieldLabel: '到业务日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'OpDateEnd'
}, {
fieldLabel: '会计期间',
format: 'Y-m',
xtype: 'datefield',
name: 'ACCDATE',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxBSSTATUS, this.comboxFEESTATUS, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
_this = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpBulk/Edit');
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
var form = _this.formSearch.getForm();
form.reset();
},
scope: this
}, '-',
{
text: "打印",
iconCls: 'btnprint',
handler: function (button, event) {
this.Print();
},
scope: this
}, '-', {
text: "其他操作",
menu: [
{ text: "批量状态更新",
handler: function (menu, event) {
_this.onUpOpStatusClick(menu, event, 1);
}
}, { text: "费用编辑",
handler: function (menu, event) {
_this.onFeeEditClick(menu, event);
}
}, { text: "批量费用提交",
handler: function (menu, event) {
_this.onPiLiangSubmitClick(menu, event, 1);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 126,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.onRefreshClick();
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
onRefreshClick: function (button, event) {
// var girdcolums = this.gridList.getColumnMode();
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
if (record.data.BSSTATUS == '1') {
Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
if (record.data.OPSTATUS != '新建') {
Ext.Msg.show({ title: '警告', msg: '托单状态不是新建状态,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
if (record.data.FEESTATUS == '1') {
Ext.Msg.show({ title: '警告', msg: '费用已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
if (this.StoreOpRange.getCount() == 0) {
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
} else {
var op = record.data.OP;
var inputby = record.data.INPUTBY;
var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
} else {
var recordins = DsStoreQueryBy(this.StoreOpRange, 'OPID', inputby);
if (recordins.getCount() > 0) {
} else {
canedit = false;
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
}
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpBulk/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
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 });
}
}
},
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
onUpOpStatusClick: function (menu, event, type) {
var selections = this.GridCheckBoxModel.selected.items;
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var BSNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BSNO = "'" + rec.data.BSNO + "'";
if (BSNOStr == '')
BSNOStr = BSNO;
else {
BSNOStr = BSNOStr + ',' + BSNO;
}
}
if (BSNOStr == '') {
Ext.Msg.show({ title: '提示', msg: '没有要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
} else {
this.selectbsno = " BSNO IN (" + BSNOStr + ")";
window.open('/MvcShipping/MsOpStatus/PiLiang', "PILIANGOPSTATUS", 'width=1200,height=600,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
}
},
onPiLiangSubmitClick: function (menu, event, type) {
var selections = this.GridCheckBoxModel.selected.items;
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var BSNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BSNO = "'" + rec.data.BSNO + "'";
if (BSNOStr == '')
BSNOStr = BSNO;
else {
BSNOStr = BSNOStr + ',' + BSNO;
}
}
if (BSNOStr == '') {
Ext.Msg.show({ title: '提示', msg: '没有要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
} else {
this.selectbsno = " BSNO IN (" + BSNOStr + ")";
window.open('/Account/Chfee_Audit/PiLiangSubmit', "PILIANGSUBMIT", 'width=1200,height=600,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
}
},
onFeeEditClick: function (menu, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpBulk/PiLiangFeeEdit');
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var billNo = form.findField('CustNo').getValue();
sql = sql + getAndConSql(sql, billNo, "CustNo like '%" + billNo + "%'");
var billNo = form.findField('OrderNo').getValue();
sql = sql + getAndConSql(sql, billNo, "orderNo like '%" + billNo + "%'");
var TransType = form.findField('TransType').getValue();
sql = sql + getAndConSql(sql, TransType, "TRANSTYPE= '" + TransType + "'");
var OpStatus = form.findField('OpStatus').getValue();
sql = sql + getAndConSql(sql, OpStatus, "OpStatus= '" + OpStatus + "'");
var custName = form.findField('CustName').getValue();
sql = sql + getAndConSql(sql, custName, "CUSTOMERNAME like '%" + custName + "%'");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "ETD>='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "ETD <='" + expDateEnd + "'");
var opDateBgn = form.findField('OpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, opDateBgn, "OPDATE >='" + opDateBgn + "'");
var opDateEnd = form.findField('OpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, opDateEnd, "OPDATE <='" + opDateEnd + "'");
//会计期间
var ACCDATE = form.findField('ACCDATE').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, "ACCDATE='" + ACCDATE + "'");
//业务状态
var BSSTATUS = form.findField('BSSTATUS').getValue();
if (BSSTATUS != null) {
if (BSSTATUS.toString().trim() == "锁定") {
sql = sql + getAndConSql(sql, BSSTATUS, "BSSTATUS=1");
}
else if (BSSTATUS.toString().trim() == "未锁定") {
sql = sql + getAndConSql(sql, BSSTATUS, "BSSTATUS=0");
}
}
//费用状态
var FEESTATUS = form.findField('FEESTATUS').getValue();
if (FEESTATUS != null) {
if (FEESTATUS.toString().trim() == "锁定") {
sql = sql + getAndConSql(sql, FEESTATUS, "FEESTATUS=1");
}
else if (FEESTATUS.toString().trim() == "未锁定") {
sql = sql + getAndConSql(sql, FEESTATUS, "FEESTATUS=0");
}
}
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.selectbsno;
ret[4] = 'op_bulk';
return ret;
},
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/MvcShipping/MsOpBulk/GetDataListStr',
scope: this,
params: {
condition: _this.sqlcontext,
printstr: 'true'
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnstr = jsonresult.data;
var printType = 'MSOPBULKLIST';
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
});
}
}
});
}
});