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.

1577 lines
55 KiB
JavaScript

12 months ago
Ext.namespace('Shipping');
Shipping.MsOpRailwayBillEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpRailwayBillEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpRailwayBillEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
MainEditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
//#region 信息加载
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modOrderManagement"} });
//品名
this.storeCodeGoodsList = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeGoodsModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeGoodsList' }
});
this.storeCodeGoodsList.load();
this.comboxGOODSNAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'Description of Goods (包装种类与货名)',
store: this.storeCodeGoodsList,
flex: 1.5,
labelWidth: 250,
forceSelection: true,
name: 'GOODSNAME',
valueField: 'GOODNAME',
displayField: 'CodeAndName'
});
//客户加载_发货人
this.storeShipper = Ext.create('DsExt.ux.RefTableStore', {
model: 'OpSeaeShipper',
proxy: { url: '/MvcShipping/MsOpSeae/GetShipperList' }
});
// this.storeShipper.load({ params: { condition: "ISCONTROLLER='1'"} });
//发货人
this.comboxShipper = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'Shipper (发货人)',
store: this.storeShipper,
forceSelection: true,
labelWidth: 150,
labelAlign: 'left',
name: 'SHIPPERID',
valueField: 'SHORTNAME',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var selectrecords = DsStoreQueryBy(this.storeShipper, 'SHORTNAME', combo.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
this.formEdit.getForm().findField('SHIPPER').setValue(selectdata.SHIPPERDETAIL);
} else {
this.formEdit.getForm().findField('SHIPPER').setValue('');
}
}
}
}
});
//客户加载_收货人
this.storeConsignee = Ext.create('DsExt.ux.RefTableStore', {
model: 'OpSeaeShipper',
proxy: { url: '/MvcShipping/MsOpSeae/GetShipperList' }
});
// this.storeShipper.load({ params: { condition: "ISCONTROLLER='1'"} });
//收货人
this.comboxConsignee = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'Consignee (收货人)',
labelWidth: 150,
labelAlign: 'left',
store: this.storeConsignee,
forceSelection: true,
name: 'CONSIGNEEID',
valueField: 'SHORTNAME',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var selectrecords = DsStoreQueryBy(this.storeConsignee, 'SHORTNAME', combo.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
this.formEdit.getForm().findField('CONSIGNEE').setValue(selectdata.SHIPPERDETAIL);
} else {
this.formEdit.getForm().findField('CONSIGNEE').setValue('');
}
}
}
}
});
//客户加载_通知人
this.storenotifyparty = Ext.create('DsExt.ux.RefTableStore', {
model: 'OpSeaeShipper',
proxy: { url: '/MvcShipping/MsOpSeae/GetShipperList' }
});
// this.storeShipper.load({ params: { condition: "ISCONTROLLER='1'"} });
//通知人
this.comboxNotifyParty = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'Notify Party (通知人)',
store: this.storenotifyparty,
labelWidth: 150,
labelAlign: 'left',
forceSelection: true,
name: 'NOTIFYPARTYID',
valueField: 'SHORTNAME',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var selectrecords = DsStoreQueryBy(this.storenotifyparty, 'SHORTNAME', combo.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
this.formEdit.getForm().findField('NOTIFYPARTY').setValue(selectdata.SHIPPERDETAIL);
} else {
this.formEdit.getForm().findField('NOTIFYPARTY').setValue('');
}
}
}
}
});
//#endregion
//件数包装
this.storeCodePackage = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodePackageModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodePackageList' }
});
this.storeCodePackage.load();
this.comboxKINDPKGS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '包 装',
labelWidth: 35,
store: this.storeCodePackage,
padding: '0 0 0 10',
forceSelection: true,
name: 'KINDPKGS',
valueField: 'PKGS',
displayField: 'PKGS'
});
this.storeBodyListTrack = Ext.create('Ext.data.Store', {
model: 'MsOpRailwayTracking',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpRailway/GetBodyTrackingList',
reader: {
id: 'TK_ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.comboxTRAINNO = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeBodyListTrack,
valueField: 'TRAINNO',
displayField: 'TRAINNO'
});
//#region 车辆信息
this.storeBodyTrain = Ext.create('Ext.data.Store', {
model: 'MsOpRailwayBillTrain',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpRailway/GetBodyTrainList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListTrainCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListTrain = new Ext.grid.GridPanel({
store: this.storeBodyTrain,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListTrainCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetailtrain",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailTrainClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndeldetailtrain",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailTrainClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'SORTNO',
header: '序号',
width: 30
}, {
dataIndex: 'TRAINNO',
header: '车辆',
width: 100,
editor: this.comboxTRAINNO
}, {
dataIndex: 'CARRIER',
header: '提供方',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'KGS',
header: '载重量',
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'SHAFTNUM',
header: '轴数',
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'TRAINKGS',
header: '自重',
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
}, {
dataIndex: 'TANKTYPE',
header: '罐车类型',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'AFTERKGS',
header: '换装后货物重量',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'AFTERPKGS',
header: '换装后件数',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
]
});
this.panelBodyTrain = new Ext.Panel({
layout: "border",
flex: 3,
height: 130,
frame: true,
items: [this.gridListTrain]
});
//#endregion
//#region 在途信息
this.storeBodyRoad = Ext.create('Ext.data.Store', {
model: 'MsOpRailwayBillRoad',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpRailway/GetBodyRoadList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListRoadCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListRoad = new Ext.grid.GridPanel({
store: this.storeBodyRoad,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListRoadCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'AS_ID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'SORTNO',
header: '序号',
width: 30
}, {
dataIndex: 'CARRIER',
header: '承运人',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'FRSTATION',
header: '区段始发站',
width: 180,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'FRSTATIONID',
header: '始发站代码',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'TOSTATION',
header: '区段到站',
width: 180,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'TOSTATIONID',
header: '到站代码',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}]
});
this.panelBodyRoad = new Ext.Panel({
layout: "border",
flex: 3,
height: 160,
frame: true,
items: [this.gridListRoad]
});
//#endregion
this.StorePLACETRANSIT = Ext.create('Ext.data.Store', {
fields: ['PORT', 'PORTID']
});
this.StorePLACETRANSIT.add({ "PORT": "Dostyk-eks", "PORTID": "ALASHANKOU" });
this.StorePLACETRANSIT.add({ "PORT": "Grodekovo", "PORTID": "SUIFENHE" });
this.StorePLACETRANSIT.add({ "PORT": "Dzamiin-Üüd", "PORTID": "ERLIAN" });
this.StorePLACETRANSIT.add({ "PORT": "Zabaykal'sk", "PORTID": "MANZHOULI" });
this.StorePLACETRANSIT.add({ "PORT": "Xinuiju", "PORTID": "DANDONG" });
this.StorePLACETRANSIT.add({ "PORT": "Brest-Tsentral'nny(V PNR)", "PORTID": "PINGXIANG" });
this.StorePLACETRANSIT.add({ "PORT": "Altynko-eks", "PORTID": "HORGOS" });
this.comboxPLACETRANSIT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '边境口岸',
store: this.StorePLACETRANSIT,
forceSelection: true,
name: 'PLACETRANSIT',
valueField: 'PORTID',
displayField: 'PORT'
});
this.formHead = Ext.widget('form', {
frame: true,
bodyPadding: 2,
region: 'north',
height: 110,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [
{ xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '件数',
name: 'PKGS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '重量',
name: 'KGS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '尺码',
name: 'CBM', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'JOB NO.',
readOnly: true,
name: 'CUSTNO'
}, {
fieldLabel: '客户参考信息',
readOnly: true,
name: 'ORDERNO'
},
{
fieldLabel: '箱型',
readOnly: true,
name: 'CTNALL'
},
{
fieldLabel: '箱量',
readOnly: true,
name: 'CTNNUM,'
}, {
fieldLabel: '箱源',
readOnly: true,
name: 'CTNSOURCE'
}
]
},
{ xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '揽货人',
readOnly: true,
name: 'SALE'
}, {
fieldLabel: '委托单位',
readOnly: true,
name: 'CUSTOMERNAME'
},
{
fieldLabel: '收货地',
readOnly: true,
name: 'PlACERECEIPT'
},
{
fieldLabel: '发站',
readOnly: true,
name: 'PLACELOAD'
}, this.comboxPLACETRANSIT
]
},
{ xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '中转地',
flex: 1,
readOnly: true,
name: 'FRPLACETRANSIT'
}, {
fieldLabel: '到达站',
flex: 1,
readOnly: true,
name: 'DESTINATION'
}, {
fieldLabel: '备注',
flex: 3,
readOnly: true,
name: 'REMARK'
}
]
}
]
}]
}); //end this.formEdit
//#region 编辑formEdit 基本信息
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 0,
layout: 'anchor',
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [{
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
fieldLabel: '业务编号',
name: 'BSNO', hidden: true
}, {
fieldLabel: 'INPUTBY',
name: 'INPUTBY', hidden: true
}, {
fieldLabel: 'AS_ID',
name: 'AS_ID', hidden: true
}, {
fieldLabel: 'CUSTNO',
name: 'CUSTNO', hidden: true
}, this.comboxShipper, {
xtype: 'textareafield',
grow: true,
labelWidth: 0,
height: 90,
name: 'SHIPPER',
anchor: '100%'
}, this.comboxConsignee, {
xtype: 'textareafield',
grow: true,
labelWidth: 0,
height: 90,
name: 'CONSIGNEE',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
height: 40,
fieldLabel: '到站',
name: 'DESTINATIONENAME',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
height: 30,
fieldLabel: '发站',
name: 'PLACELOADENAME',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
height: 180,
fieldLabel: '发货人的声明',
name: 'SHIPPERSTATEMENT',
anchor: '100%'
}
]
}
]
}, {
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 2,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>6 国境口岸站</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 130,
name: 'PLACETRANSITENAME',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 2,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '.'
}, this.panelBodyTrain
]
}
]
}, {
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 5,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>15 货物名称</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'DESCRIPTION',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '柜号',
height: 40,
name: 'CNTRTOTAL',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>16 包装种类</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 150,
name: 'NOPKGS',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>17 件数</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 150,
name: 'PKGS',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>18 重量</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 150,
name: 'KGS',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>19 封印</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 70,
name: 'SEALNO',
anchor: '100%'
}, {
xtype: 'label',
html: '<html>20 由何方装车</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 20,
name: 'LOADER',
anchor: '100%'
}, {
xtype: 'label',
html: '<html>21 确定重量方法</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 20,
name: 'WEIGHTMETHODS',
anchor: '100%'
}
]
}]
}, {
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>23 运费的支付</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'OTHERFIELD1',
anchor: '100%'
}, {
xtype: 'label',
html: '<html>24 发货人添附的文件</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'SHIPPERFILES',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [
this.panelBodyRoad,
{
xtype: 'label',
html: '<html>25 与承运人无关的信息 供货合同号</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 50,
name: 'CUSTCONTRACTNO',
anchor: '100%'
}
]
}]
}, {
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>26 缔结运输合同日期</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'CUSTCONTRACTNODATE',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>27 到达日期</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'ARRIVALDATE',
anchor: '100%'
}
]
}, {
xtype: 'container',
layout: 'anchor',
flex: 2,
defaultType: 'textfield',
items: [{
xtype: 'label',
html: '<html>28 办理海关和其他手续的记账</html>'
}, {
xtype: 'textareafield',
grow: true,
height: 100,
name: 'CUSTOMERRECORD',
anchor: '100%'
}
]
}]
}
]
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
id: 'btnECopyNew',
text: "复制新建",
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
basicForm.findField('AS_ID').setDisabled(false);
var field = basicForm.findField('AS_ID');
field.setValue('*');
basicForm.findField('AS_ID').setDisabled(true);
field = basicForm.findField('INPUTBY');
field.setValue(SHOWNAME);
// this.GetEditStatus();
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
this.panelpage = new Ext.Panel({
title: '运单信息',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formEdit]
});
Ext.apply(this, {
items: [this.panelBtn, this.formHead, this.panelpage]
});
//#endregion
//#region 其他
parentWin = window.parent.opener._this.tabSeaepanel.activeTab;
MparentWin = window.parent.opener._this;
this.InitData();
//绑定事件
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
this.MainEditRecord = MparentWin.Editdata;
}
if (this.opStatus == 'edit') {
condition = "AS_ID='" + this.editRecord.get('AS_ID') + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
//this.bodyDel = [];
this.opStatus = opstatus;
this.storeBodyListTrack.load({ params: { condition: "BSNO='" + this.MainEditRecord.BSNO + "'", isfirst: false} });
_this = this;
if (this.opStatus == 'add') {
this.formEdit.getForm().reset();
this.formEdit.getForm().findField('BSNO').setValue(this.MainEditRecord.BSNO);
this.formEdit.getForm().findField('CUSTNO').setValue(this.MainEditRecord.CUSTNO);
this.formEdit.getForm().findField('DESTINATIONENAME').setValue(this.MainEditRecord.DESTINATIONDETAIL);
this.formEdit.getForm().findField('PLACELOADENAME').setValue(this.MainEditRecord.PLACELOAD+ ' ' + this.MainEditRecord.PLACELOADENAME);
var storecustall = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomerRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
storecustall.load({ params: { condition: "SHORTNAME='" + this.MainEditRecord.CUSTOMERNAME + "'" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var custall = storecustall.getAt(0);
_this.formEdit.getForm().findField('SHIPPER').setValue(custall.data.DESCRIPTION);
}
}
}
});
if (this.MainEditRecord.PLACETRANSIT == 'MANZHOULI') {
this.formEdit.getForm().findField('PLACETRANSITENAME').setValue('满洲里-后贝加尔斯克 Manzhouli (КЖД) / Забайкальск (ЗабЖД) 947005');
}
if (this.MainEditRecord.PLACETRANSIT == 'ALASHANKOU') {
this.formEdit.getForm().findField('PLACETRANSITENAME').setValue('阿拉山口, ДОСТЫК ЭКСП.708507');
}
if (this.MainEditRecord.PLACETRANSIT == 'HORGOS') {
this.formEdit.getForm().findField('PLACETRANSITENAME').setValue('霍尔果斯/阿腾科里 Horgos/ Altynkol-eks');
}
if (this.MainEditRecord.PLACETRANSIT == 'ERLIAN') {
this.formEdit.getForm().findField('PLACETRANSITENAME').setValue('二连/扎门乌德 Эрлянь-Замын-Уде');
}
this.LoadInit(this.MainEditRecord);
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpRailway/GetBillData',
params: {
handle: opstatus,
condition: condition
},
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;
}
data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
this.storeBodyTrain.load({ params: { condition: "BSNO='" + data.AS_ID + "'", isfirst: false} });
this.storeBodyRoad.load({ params: { condition: "BSNO='" + data.AS_ID + "'"} });
this.LoadInit(data);
// this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
this.formHead.getForm().reset();
this.formHead.getForm().setValues(this.MainEditRecord);
}, // end LoadDate
//#endregion
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues(false, false, false);
var bodydatas = [];
for (var i = 0; i < this.storeBodyTrain.getCount(); i += 1) {
var member = this.storeBodyTrain.getAt(i);
bodydatas.push(member);
}
var bodydataroads = [];
for (var i = 0; i < this.storeBodyRoad.getCount(); i += 1) {
var member = this.storeBodyRoad.getAt(i);
bodydataroads.push(member);
}
//
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
var jsonBodyroad = ConvertRecordsToJsonAll(bodydataroads);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpRailway/BillSave',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody,
bodyroad: jsonBodyroad
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpRailwayBillModel', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
this.LoadInit(returnData);
}
if (type == '0') {
this.opStatus = 'edit';
for (var j = 0; j < this.storeBodyTrain.getCount(); j += 1) {
var memberbody = this.storeBodyTrain.getAt(j);
memberbody.set("BSNO", this.editRecord.get('AS_ID'));
memberbody.commit();
};
for (var j = 0; j < this.storeBodyRoad.getCount(); j += 1) {
var memberbody = this.storeBodyRoad.getAt(j);
memberbody.set("BSNO", this.editRecord.get('AS_ID'));
memberbody.commit();
};
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
}
} 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
});
}
}
});
}, //end save
//#endregion
//#region 按钮事件
onAddDetailTrainClick: function (button, event) {
this.addDetailTrain();
}, //end onAddDetailClick
onDelDetailTrainClick: function (button, event) {
this.deleteDetailTrain();
}, //onDelDetailClick
onAddDetailClick: function (button, event) {
this.addDetailRoad();
}, //end onAddDetailClick
onDelDetailClick: function (button, event) {
this.deleteDetailRoad();
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
},
addDetailTrain: function () {
var newSerialno = this.DsGetNewNo(this.storeBodyTrain);
this.serialNo = newSerialno;
var record = Ext.create('MsOpRailwayBillTrain', {
GID: NewGuid(),
BSNO: '*',
SORTNO: newSerialno,
TRAINNO: '',
CARRIER: '',
KGS: 0,
SHAFTNUM: 0,
TRAINKGS: 0,
TANKTYPE: '',
AFTERKGS: 0,
AFTERPKGS: 0,
REMARK: ''
});
this.storeBodyTrain.add(record);
var n = this.storeBodyTrain.getCount();
this.gridListTrainCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
addDetailRoad: function () {
var newSerialno = this.DsGetNewNo(this.storeBodyRoad);
this.serialNo = newSerialno;
var record = Ext.create('MsOpRailwayBillRoad', {
GID: NewGuid(),
BSNO: '*',
SORTNO: newSerialno,
CARRIER: '',
FRSTATION: '',
FRSTATIONID: '',
TOSTATION: '',
TOSTATIONID: '',
REMARK: ''
});
this.storeBodyRoad.add(record);
var n = this.storeBodyRoad.getCount();
this.gridListRoadCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
DsGetNewNo: function (store) {
var result = store.getCount();
if (result == 0) {
return 1;
}
var record = store.getAt(result - 1).data.SORTNO;
result = parseInt(record) + 1;
return result;
},
deleteDetailTrain: function () {
var selectedRecords = this.gridListTrain.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
//this.bodyDel.push(rec);
this.storeBodyTrain.remove(selectedRecords[i]);
}
else {
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpRailway/DeleteBillTrainDetail',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyTrain.remove(rec);
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 });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//this.storeBodyList.remove(selectedRecords[i]);
}
},
deleteDetailRoad: function () {
var selectedRecords = this.gridListRoad.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
//this.bodyDel.push(rec);
this.storeBodyRoad.remove(selectedRecords[i]);
}
else {
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpRailway/DeleteBillRoadDetail',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyRoad.remove(rec);
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 });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//this.storeBodyList.remove(selectedRecords[i]);
}
},
//#endregion
//#region
LoadInit: function (data) {
var CUSTOMERNAME = this.MainEditRecord.CUSTOMERNAME;
this.storeShipper.load({ params: { condition: "shippertype=2 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('SHIPPERID').setValue(data.SHIPPERID);
}
},
scope: this
});
this.storeConsignee.load({ params: { condition: "shippertype=1 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('CONSIGNEEID').setValue(data.CONSIGNEEID);
}
},
scope: this
});
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
var BSSTATUS = this.formHead.getForm().findField('BSSTATUSREF').getValue();
var inputby = this.formHead.getForm().findField('INPUTBY').getValue();
var op = this.formHead.getForm().findField('OP').getValue();
_this = this;
if (BSSTATUS == '锁定') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modOrderManagement" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', inputby);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
}
},
GetStringNum: function (str) {
var num = 0;
if (str == null || str == '') return num;
if (str.length == 0) return num;
var if_find = false;
var str_num = '';
for (var i = 0; i < str.length; i += 1) {
var member = str.substr(i, 1);
if ((member == '0') || (member == '1') || (member == '2') || (member == '3')
|| (member == '4') || (member == '5') || (member == '6') || (member == '7')
|| (member == '8') || (member == '9') || (member == '.') || (member == '-')) {
if (!if_find) {
str_num = str_num + member;
}
} else {
if_find = true;
}
}
return str_num;
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
//#endregion
//#region 打印
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('AS_ID').value;
var bsNo = basicForm.findField('BSNO').value;
if (billNo == '*' || billNo == '' || billNo == NaN) {
Ext.Msg.show({ title: '错误', msg: '提单还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSOPRAILWAYBILL';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_railway_bill WHERE AS_ID = '" + billNo + "'";
var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_railway_bill_train WHERE BSNO = '" + billNo + "' ORDER BY SORTNO ";
var sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_railway_bill_road WHERE BSNO = '" + billNo + "' ORDER BY SORTNO";
var sql4 = "SET LANGUAGE 'us_english' SELECT * FROM op_railway WHERE BSNO = '" + bsNo + "'";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
// #endregion
});