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.

924 lines
30 KiB
JavaScript

11 months ago
Ext.namespace('Shipping');
Shipping.MsOpSeaeCustomEdiIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpSeaeCustomEdiIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpSeaeCustomEdiIndex, Ext.Panel, {
PageSize: 20,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
isShowAdvancedQuery: 0, //是否显示高级查询面板
IsAudit: false,
BillType: 1,
OrType: 2,
editype: '',
initUIComponents: function () {
this.formname = "formMsOpSeaeCustomEdiIndex"; //页面名称
//定义数据集
this.storectndisp = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CtnDispModel',
proxy: { url: '/CommMng/BasicDataRef/GetCtnDisp' }
});
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsSeaeEdiModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSeaeEdi/GetDataList',
reader: {
id: 'MFNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region List列表显示信息
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
this.girdcolums = [{
sortable: true,
dataIndex: 'MFNO',
header: '业务编号',
width: 0
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 120
},
{
sortable: true,
dataIndex: 'EDISTATUS',
header: 'EDI状态',
width: 80
},
{
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
},
{
sortable: true,
dataIndex: 'HBLNO',
header: '分提单号',
width: 120
},
{
sortable: true,
dataIndex: 'ORDERNO',
header: '订舱编号',
width: 100
},
{
sortable: true,
dataIndex: 'VESSEL',
header: '船名',
width: 120
},
{
sortable: true,
dataIndex: 'VOYNO',
header: '航次',
width: 60
},
{
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
width: 100
},
{
sortable: true,
dataIndex: 'PORTLOAD',
header: '装货港',
width: 100
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '卸货港',
width: 100
},
{
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
},
{
sortable: true,
dataIndex: 'KGS',
header: '毛重',
width: 80
},
{
sortable: true,
dataIndex: 'CBM',
header: '尺码',
width: 60
},
{
sortable: true,
dataIndex: 'INPUTBY',
header: '录入人',
width: 80
},
{
sortable: true,
dataIndex: 'INPUTDATE',
header: '录入日期',
width: 80
}];
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,
listeners: {
cellclick: function (thisTab, record, item, index, e, eOpts) {
if (index == 10) {//设置按钮列
// alert('用户编号=' + this.getStore().getAt(rowIndex).data.usercode);
}
}
},
columns: this.girdcolums,
// 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('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpSeaeEdi/CustomEdit');
// window.open('/MvcShipping/MsOpSubSeaOrder/Edit', "ORDER EDIT", 'width=1200,height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
}, this);
//录入人
this.comboxINPUTBY = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '录入人',
store: this.storeOpCode,
forceSelection: true,
name: 'INPUTBY',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.StoreStatus = Ext.create('Ext.data.Store', {
fields: ['STATUS']
});
this.StoreStatus.add({ "STATUS": "未发送" });
this.StoreStatus.add({ "STATUS": "已保存文件" });
this.StoreStatus.add({ "STATUS": "已发送" });
this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreStatus,
fieldLabel: 'EDI状态',
forceSelection: true,
name: 'EDISTATUS',
valueField: 'STATUS',
displayField: 'STATUS'
});
//#endregion
//#region formSearch 查询面板
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.VesselModel',
proxy: { url: '/CommMng/BasicDataRef/GetVesselList' }
});
this.storeVoyVeg.load({ params: { condition: ""} });
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船 名',
store: this.storeVoyVeg,
name: 'VESSEL',
valueField: 'VESSEL',
flex: 1,
displayField: 'VESSEL'
});
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: [{
fieldLabel: '主提单号',
name: 'MblNo'
}, {
fieldLabel: '分提单号',
name: 'HblNo'
}, {
fieldLabel: '船代',
name: 'FORWARDER'
}, this.comboxStatus]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '录入日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'INPUTbgn'
}, {
fieldLabel: '到',
format: 'Y-m-d',
xtype: 'datefield',
name: 'INPUTend'
}, {
fieldLabel: '开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDbgn'
}, {
fieldLabel: '到',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDend'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxVoyVeg, {
fieldLabel: '航次',
name: 'VOYNO'
}, {
fieldLabel: '箱号',
name: 'CTNNO'
}, { xtype: 'hiddenfield'}]
}]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
_this = this;
//按钮工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
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) {
this.onClearSql(button, event);
},
scope: this
}, '-', {
text: '船代舱单',
tooltip: '船代舱单',
menu: [
{ text: "外代CN2101",
handler: function (menu, event) {
_this.onCreateEDIClick("WD2101");
}
}, { text: "外代CN1101",
handler: function (menu, event) {
_this.onCreateEDIClick("WD1101");
}
}, { text: "外代釜山货",
handler: function (menu, event) {
_this.onCreateEDIClick("WDKR");
}
}, { text: "中远",
handler: function (menu, event) {
_this.onCreateEDIClick("COSCO");
}
}, { text: "中通",
handler: function (menu, event) {
_this.onCreateEDIClick("ZTCUSTOM");
}
}, { text: "锦江航运",
handler: function (menu, event) {
_this.onCreateEDIClick("JJCUSTOM");
}
}],
scope: this
}, '-', {
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, true);
},
scope: this
}]
});
//#region 生成EDI
this.formEdiShow = 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: [{
xtype: 'radiogroup',
fieldLabel: '文件功能',
id:'rFILEROLE',
defaults: {
flex: 1
},
layout: 'hbox',
items: [
{
boxLabel: '原始',
name: 'FILEROLE',
inputValue: '9',
checked: true,
id: 'radio3'
}, {
boxLabel: '增加',
name: 'FILEROLE',
inputValue: '2',
id: 'radio4'
}, {
boxLabel: '删除',
name: 'FILEROLE',
inputValue: '3',
id: 'radio5'
}, {
boxLabel: '更新',
name: 'FILEROLE',
inputValue: '4',
id: 'radio6'
}
]
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
this.winEDIShow = Ext.create('Ext.window.Window', {
title: "生成EDI",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formEdiShow],
buttons: [{
text: "上传EDI",
minWidth: 70,
handler: function () {
var cgFILEROLE = Ext.getCmp('rFILEROLE');
var FILEROLE = cgFILEROLE.getValue();
me.onSendEDI(me.editype, FILEROLE.FILEROLE);
}
}, {
text: "保存EDI文件",
minWidth: 70,
handler: function () {
var cgFILEROLE = Ext.getCmp('rFILEROLE');
var FILEROLE = cgFILEROLE.getValue();
me.onSaveEDI(me.editype, FILEROLE.FILEROLE);
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winEDIShow.close();
}
}]
});
//#endregion
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 125,
items: [this.panelBtn, this.formSearch]
});
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, billtype: this.BillType, ortype: this.OrType });
}, this);
this.formDownloadShow = 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',
id: 'downloadfile',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'label',
html: '',
width: 120,
text: ''
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
this.winDownloadShow = Ext.create('Ext.window.Window', {
title: "下载文件",
width: 450,
height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formDownloadShow],
buttons: [{
text: "关闭",
minWidth: 70,
handler: function () {
me.winDownloadShow.close();
}
}]
});
}, //end initUIComponents
onRefreshClick: function (button, event) {
//var girdcolums = this.gridList.getColumnMode();
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql, billtype: this.BillType, ortype: this.OrType },
waitMsg: "正在查询数据...",
scope: this
});
},
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 bsnos = '';
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.EDISTATUS == '已发送') {
Ext.Msg.show({ title: '警告', msg: rec.data.MBLNO + ',此业务已发送,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
} else {
var bsno = rec.data.MFNO;
if (bsnos == '') {
bsnos = bsno;
} else {
bsnos = bsnos + "," + bsno;
}
}
}
Ext.MessageBox.confirm('提示', '确定删除选中记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpSeaeEdi/DeletePiLiang',
params: {
bsnos: bsnos
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.onRefreshClick();
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);
},
onCreateEDIClick: function (type) {
this.editype = type;
this.winEDIShow.show();
},
onSendEDI: function (type,filerole) {
var GidStr = '';
var records = this.GridCheckBoxModel.selected.items;
if (records.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要上传的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var insert;
var bodyAddDatas = [];
var j = 0;
var Mblno = '';
for (var i = 0; i < records.length; i++) {
var rec = records[i];
var EDISTATUS = rec.data.EDISTATUS;
if (EDISTATUS == "已发送") {
j = j + 1;
}
Mblno = rec.data.MBLNO;
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var msg = '';
if (j > 0) {
msg = j + '票业务已经发送,确认要重新发送吗?';
} else {
msg = '确定FTP上传吗';
}
_this = this;
Ext.MessageBox.confirm('提示', msg, function (btn) {
if (btn == 'yes') {
Ext.Ajax.request({
waitMsg: '生成中..',
url: '/MvcShipping/MsOpSeaeEdi/CustomEdiSend',
params: {
headData: jsonbodyAddDatas,
mblno: Mblno,
type: type,
filerole:filerole
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
_this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('The Server Response Error, Please Try Again', response.responseText);
}
},
scope: this
});
}
}, this);
},
onSaveEDI: function (type, filerole) {
var GidStr = '';
var records = this.GridCheckBoxModel.selected.items;
if (records.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要存为文件的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var insert;
var bodyAddDatas = [];
var j = 0;
var Mblno = '';
for (var i = 0; i < records.length; i++) {
var rec = records[i];
var EDISTATUS = rec.data.EDISTATUS;
if (EDISTATUS == "已发送") {
j = j + 1;
}
Mblno = rec.data.MBLNO;
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var msg = '';
msg = '确定要保存EDI文件吗';
var strlo = window.location.host;
_this = this;
Ext.Ajax.request({
waitMsg: 'Changing...',
url: '/MvcShipping/MsOpSeaeEdi/CustomEdiSave',
params: {
headData: jsonbodyAddDatas,
mblno: Mblno,
type: type,
filerole: filerole
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
// var downloadfile = Ext.getCmp('downloadfile');
// var filehtml = '<a href="' + result.Data + '" style=' + '"text-decoration:none"' + '>' + result.Message + '</a>'
// downloadfile.html = filehtml;
// this.winDownloadShow.show();
var downloadfile = Ext.getCmp('downloadfile');
var children = downloadfile.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
downloadfile.remove(children.items[i], true);
}
}
var downloadfiles = '<a href="' + result.Data + '" style=' + '"text-decoration:none"' + '>' + result.Message + '</a>';
var htmla = Ext.widget('label', {
html: downloadfiles,
width: 120,
text: ''
});
downloadfile.items.add(htmla);
this.winDownloadShow.show();
}
} else {
Ext.MessageBox.alert('The Server Response Error, Please Try Again', response.responseText);
}
},
scope: this
});
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = " EDITYPE='CN' ";
//#region formSearch 查询面板
//编号包括(主提单号)
var MblNo = form.findField('MblNo').getValue();
sql = sql + getAndConSql(sql, MblNo, "(MBLNO like '%" + MblNo + "%' )");
var HblNo = form.findField('HblNo').getValue();
sql = sql + getAndConSql(sql, HblNo, "(HBLNO like '%" + HblNo + "%' )");
var FORWARDER = form.findField('FORWARDER').getValue();
sql = sql + getAndConSql(sql, FORWARDER, "(FORWARDER like '%" + FORWARDER + "%' )");
var CTNNO = form.findField('CTNNO').getValue();
sql = sql + getAndConSql(sql, CTNNO, " MFNO IN (SELECT MFNO FROM OP_SEAE_EDI_CTN WHERE CTNNO like '%" + CTNNO + "%' )");
//状态
var ORSTATUS = form.findField('EDISTATUS').getValue();
sql = sql + getAndConSql(sql, ORSTATUS, "EDISTATUS='" + ORSTATUS + "'");
//到港日期
var ETDbgn = form.findField('ETDbgn').getRawValue();
sql = sql + getAndConSql(sql, ETDbgn, "ETD >='" + ETDbgn + "'");
var ETDend = form.findField('ETDend').getRawValue();
sql = sql + getAndConSql(sql, ETDend, "ETD <='" + ETDend + "'");
var INPUTbgn = form.findField('INPUTbgn').getRawValue();
sql = sql + getAndConSql(sql, INPUTbgn, "INPUTDATE>='" + INPUTbgn + "'");
var INPUTend = form.findField('INPUTend').getRawValue();
sql = sql + getAndConSql(sql, INPUTend, "INPUTDATE<='" + INPUTend + "'");
//船名
var VESSEL = form.findField('VESSEL').getValue();
sql = sql + getAndConSql(sql, VESSEL, "VESSEL like '%" + VESSEL + "%'");
//航次
var VOYNO = form.findField('VOYNO').getValue();
sql = sql + getAndConSql(sql, VOYNO, "VOYNO like '%" + VOYNO + "%'");
return sql;
},
setIsShowAdvancedQuery: function () {
if (this.isShowAdvancedQuery == 0) {
this.panelSearch.show();
this.isShowAdvancedQuery = 1;
} else {
this.panelSearch.hide();
this.isShowAdvancedQuery = 0;
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.IsAudit;
ret[4] = this.BillType;
ret[5] = this.OrType;
return ret;
}
});