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.

2879 lines
100 KiB
JavaScript

10 months ago
Ext.namespace('Shipping');
Shipping.MsPrice_ContractEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsPrice_ContractEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsPrice_ContractEdit, Ext.Panel, {
parentWin: null,
opStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
MainEditRecord: null,
stroplb: '合约管理',///与视图 V_op_bs 的OPLBNAME相同 依赖于枚举类型96005
isfen: false,
PageSize: 100,
selectWay: { ID: '0',BSNO:'', PODLOAD: '', PORTDISCHARGE: '', VIA: '', VIA2: '' },
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
this.initloaddata = 0;
this.accdatesameetd = 0;
this.MsPeriod = null;
this.SALEORDERDEPTBYOP = 0;
this.formname = "MsPrice_ContractEdit";
_this = this;
parentWin = window.parent.opener;
mainWin = getMainForm(parentWin);
opflex = 0.6;//上方几个用户下拉框 《操作》等的宽度
ViaWidth = 90;//中转港信息的的标签宽度
//#region 信息加载
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
//this.StoreOpRange.load({ params: { optype: "modOrderManagement" } });
//#region 船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
//this.storeCARRIER.loadData(mainWin.GetPubStore("INFOCLIENT_CARRIER").data.items);
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
forceSelection: true,
//queryMode: 'remote',
//minChars: 1,
//queryParam: 'CODENAME',
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//#endregion
//#region 起运港 目的港
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
//this.storeCodeLoadport.loadData(mainWin.GetPubStore("CODE_PORTLOAD").data.items);
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
//flex:1,
//fieldLabel: '起运港',
matchFieldWidth: false,
forceSelection: true,
store: this.storeCodeLoadport,
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'CodeAndName'
});
this.storeCodePort = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
//this.storeCodePort.loadData(mainWin.GetPubStore("CODE_PORTDISCHARGE").data.items);
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '目的港',
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
matchFieldWidth: false,
forceSelection: true,
store: this.storeCodePort,
name: 'PORTDISCHARGE',
valueField: 'PORT',
displayField: 'CodeAndName',
listeners: {
scope: this,
blur: function (field, The, eOpts) {
field.setRawValue(field.value);
},
'select': function (combo, records, eOpts) {
}
,
//beforequery: function (e) {
// return FilterCombox(e, 2);//在beforequery使用此方法
//},
specialkey: function (field, e) {
}
}
});
this.storeVIA = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
//this.storeVIA.loadData(mainWin.GetPubStore("CODE_PORTDISCHARGE").data.items);
this.comboxVIA = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '中转港',
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
matchFieldWidth: false,
forceSelection: true,
store: this.storeVIA,
name: 'PORTDISCHARGE',
valueField: 'PORT',
displayField: 'CodeAndName',
listeners: {
scope: this,
blur: function (field, The, eOpts) {
field.setRawValue(field.value);
},
'select': function (combo, records, eOpts) {
}
,
//beforequery: function (e) {
// return FilterCombox(e, 2);//在beforequery使用此方法
//},
specialkey: function (field, e) {
}
}
});
this.storeVIA2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
//this.storeVIA2.loadData(mainWin.GetPubStore("CODE_PORTDISCHARGE").data.items);
this.comboxVIA2 = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '中转港',
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
matchFieldWidth: false,
forceSelection: true,
store: this.storeVIA2,
name: 'PORTDISCHARGE',
valueField: 'PORT',
displayField: 'CodeAndName',
listeners: {
scope: this,
blur: function (field, The, eOpts) {
field.setRawValue(field.value);
},
'select': function (combo, records, eOpts) {
}
,
//beforequery: function (e) {
// return FilterCombox(e, 2);//在beforequery使用此方法
//},
specialkey: function (field, e) {
}
}
});
//#endregion
//#region 费用名称
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefListNew' }
});
this.comboxFeeNameRef = Ext.create('DsExt.ux.DCombox', {
store: this.storeFeeNameRef,
minChars: 1,
matchFieldWidth: false,
forceSelection: true,
//queryParam: 'Name',
lazyRender: false,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
//#endregion
//加载业务信息
//#endregion
//#region 起运港列表
this.columnLoad = [
{
sortable: true,
dataIndex: 'PORT',
header: '起运港列表',
width: 240
}
];
this.storePortLoad = Ext.create('Ext.data.Store', {
pageSize: 9999,
model: 'PORTLOADmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '',
reader: {
id: 'PORT',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formPortLoad = new Ext.grid.GridPanel({
flex: 1,
height:200,
store: this.storePortLoad,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
columns: this.columnLoad
});
//#endregion
//#region 目的港列表
this.columnDischarge = [
{
sortable: true,
dataIndex: 'PORT',
header: '目的港列表',
width: 240
}
];
this.storePortDischarge = Ext.create('Ext.data.Store', {
pageSize: 9999,
model: 'PORTDISCHARGEmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '',
reader: {
id: 'PORT',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formPortDischarge = new Ext.grid.GridPanel({
store: this.storePortDischarge,
flex: 1,
height: 200,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
columns: this.columnDischarge
});
//#endregion
//#region 主表信息
this.formHead = Ext.widget('form', {
//layout: "border",
region: 'north',
height:100,
title:'合约信息',
//height:300,
frame: true,
bodyPadding: 5,
//collapsed: false,
//collapsible: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 3 2 0',
labelAlign: 'right',
flex: 1,
labelWidth: 65,
msgTarget: 'qtip'
},
items: [
{
//第一格
xtype: 'container',
//title:'委托信息',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: 'TIMEMARK',
name: 'TIMEMARK', hidden: true
}, {
fieldLabel: 'CSTATUS',
name: 'CSTATUS', hidden: true
}, {
fieldLabel: 'MadePrice',
name: 'MadePrice', hidden: true
},
{
fieldLabel: '合约编号', flex: 1,
allowBlank: false,
name: 'CONTRACTNO'
}, {
fieldLabel: '约号编码', flex: 1,readOnly:true,
name: 'BSNO'
}, this.comboxCARRIER
, {
fieldLabel: '生效日期',
format: 'Y-m-d',
flex: 0.5,
xtype: 'datefield',
name: 'EFFECTIVEDATE'
}, {
fieldLabel: '失效时间',
format: 'Y-m-d',
flex: 0.5,
xtype: 'datefield',
name: 'VALIDDATE'
}
]
}
]
},
{
//第2格
xtype: 'container',hidden:true,
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'fieldset',
title: '起运港',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
flex:1,
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'container',
layout: 'anchor',
flex:1,
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [
//this.comboxPORTLOAD,
{
xtype: 'container',
layout: 'hbox',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'hiddenfield', flex:4
},
{
xtype: 'container',
layout: 'anchor',
flex:1,
items: [
{
xtype: 'button',
//text: "tianjia",//添加
id: "btnedit_right",
//iconCls: "edit_right",
cls: "arrow_right",
width: 26,
height: 26,
handler: function (button, event) {
port = _this.formHead.getForm().findField("PORTLOAD").getValue();
_this.PortLoadListAdd(port);
},
scope: this
}, {
xtype: 'hiddenfield', width: 20
}, {
xtype: 'button',
id: "btnedit_left",
cls: "arrow_red_left",
width: 26,
height: 26,
handler: function (button, event) {
_this.PortLoadListDel();
},
scope: this
}]
}
]
}
]
}
, this.formPortLoad
]
}]
},
{
xtype: 'fieldset',
title: '目的港',
defaultType: 'textfield',
layout: 'anchor',
flex: 1,
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'container',
layout: 'anchor',
flex: 1,
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [
//this.comboxPORTDISCHARGE,
{
xtype: 'container',
layout: 'hbox',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'hiddenfield', flex: 4
},
{
xtype: 'container',
layout: 'anchor',
flex: 1,
items: [
{
xtype: 'button',
//text: "tianjia",//添加
id: "btnedit_right2",
//iconCls: "edit_right",
cls: "arrow_right",
width: 26,
height: 26,
handler: function (button, event) {
port = _this.formHead.getForm().findField("PORTDISCHARGE").getValue();
_this.PortDischargeListAdd(port);
},
scope: this
}, {
xtype: 'hiddenfield', width: 20
}, {
xtype: 'button',
id: "btnedit_left2",
cls: "arrow_red_left",
width: 26,
height: 26,
handler: function (button, event) {
_this.PortDischargeListDel();
},
scope: this
}]
}
]
}
]
}
, this.formPortDischarge
]
}
]
}
]
}
,
{
//第3格
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [
{
fieldLabel: '备注',
name: 'REMARK'
}
]
}
]//end items(fieldset 1)
}); //end this.formHead
//#endregion
//#region 路径表
this.cellEditing_Way = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.column_Way = [
{
dataIndex: 'ID',
header: 'ID',
width: 80,hidden: true
},
{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'PODLOAD',
header: '起运港',
width: 120,
editor: this.comboxPORTLOAD
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 120,
editor: this.comboxPORTDISCHARGE
},
{
sortable: true,
dataIndex: 'VIA',
header: '中转港',
width: 120,
editor: this.comboxVIA
},
{
sortable: true,
dataIndex: 'VIA2',
header: '中转港2',
width: 120,
editor: this.comboxVIA2
},
{
sortable: true,
dataIndex: 'ETD',
header: 'ETD',
width: 120,
editor: {
xtype:'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'TT',
header: 'TT',
width: 60,
editor: {
xtype: 'numberfield',
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: false //允许输入小数
//decimalPrecision: 2 //允许保留的小数位数,并四舍五入
}
}
];
this.storeWay = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Waymb',
remoteSort: false,
//groupField: 'GroupDate',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetContractWayList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
var _this = this;
this.formWay = new Ext.grid.GridPanel({
store: this.storeWay,
region: "center",
flex:2,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing_Way],
//selModel: //this.cargoCheckBoxModel,
selType: 'cellmodel',
//features: [{
// ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
//}],
tbar: [
{
text: '增加明细',
tooltip: '如果要复制增加一条,请先选中要复制的记录,再点击增加明细',
id: "btnaddWay",
iconCls: "btnadddetail",
handler: function (button, event) {
//this.Save('4');
this.onAddWayClick();
},
scope: this
}, '-',
{
text: '删除明细',
tooltip: '删除明细为直接执行,删除后不需要再次点击保存',
id: 'btndelWay',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelWayClick(button, event);
},
scope: this
}, '-',{
id: 'btnSaveDetail_1',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.SaveDetail();
},
scope: this
}
],
columns: this.column_Way
,
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeWay,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})]
});
this.formWay.reconfigure(this.storeWay, this.column_Way);
//#endregion
//#region 合约运价明细
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
//this.cargoCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.column = [
{
dataIndex: 'GID',
header: 'GID',
width: 80,hidden: true
},
{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'PODLOAD',
header: 'PODLOAD',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: 'PORTDISCHARGE',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'VIA',
header: 'VIA',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'VIA2',
header: 'VIA2',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'SEQUENCE',
header: '顺序号',
width: 40,
editor: {
xtype: 'numberfield',
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: false //允许输入小数
//decimalPrecision: 2 //允许保留的小数位数,并四舍五入
}
},
{
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
width: 80,
editor: this.comboxFeeNameRef
},
{
sortable: true,
dataIndex: 'CTN0',
header: '小柜',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true, //允许输入小数
decimalPrecision: 2,
nanText: '请输入有效小数',
selectOnFocus: true,
minValue: 0
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'CTN1',
header: '大柜',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true, //允许输入小数
decimalPrecision: 2,
nanText: '请输入有效小数',
selectOnFocus: true,
minValue: 0
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'CTN2',
header: '超高',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true, //允许输入小数
decimalPrecision: 2,
nanText: '请输入有效小数',
selectOnFocus: true,
minValue: 0
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'CTN3',
header: '小冻',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true, //允许输入小数
decimalPrecision: 2,
nanText: '请输入有效小数',
selectOnFocus: true,
minValue: 0
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'CTN4',
header: '超冻',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true, //允许输入小数
decimalPrecision: 2,
nanText: '请输入有效小数',
selectOnFocus: true,
minValue: 0
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryType: 'sum', align: 'right',
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}
];
this.storeBody = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsPrice_Contract_Detailmb',
remoteSort: false,
//groupField: 'GroupDate',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetContractDetailList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formDetail = new Ext.grid.GridPanel({
store: this.storeBody,
enableHdMenu: false,
region: "center",
flex:3,
//title: '运价明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
//selModel: //this.cargoCheckBoxModel,
selType: 'cellmodel',
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [
{
text: '增加明细',
tooltip: '增加明细',
id:"btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-',
{
text: '删除明细',
tooltip: '删除明细',
id: 'btndeletedetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event);
},
scope: this
}, '-', {
id: 'btnSaveDetail_2',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.SaveDetail();
},
scope: this
}
],
columns: this.column,
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeBody,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})]
});
this.storeBody_Model = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsPrice_Contract_Detailmb',
remoteSort: false,
//groupField: 'GroupDate',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetContractDetailList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditing_Model = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.formDetail_Model = new Ext.grid.GridPanel({
store: this.storeBody_Model,
enableHdMenu: false,
region: "center",
//flex: 3,
//title: '运价明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing_Model],
//selModel: //this.cargoCheckBoxModel,
selType: 'cellmodel',
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [
{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetail_Model",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-',
{
text: '删除明细',
tooltip: '删除明细',
id: 'btndeletedetail_Model',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick_Model(button, event);
},
scope: this
}
],
columns: this.column,
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeBody_Model,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})]
});
//#endregion
//#region 目的港免箱期
this.cellEditing_PortDetention = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.column_PortDetention = [
{
dataIndex: 'ID',
header: 'ID',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 160,
editor: this.comboxPORTDISCHARGE
},
{
sortable: true,
dataIndex: 'CTN0',
header: '小柜',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CTN1',
header: '大柜',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CTN2',
header: '超高',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CTN3',
header: '小冻',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CTN4',
header: '超冻',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
this.storePortDetention = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'PortDetentionmb',
remoteSort: false,
//groupField: 'GroupDate',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsPrice/GetContractPortDetentionList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: 'ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formPortDetention = new Ext.grid.GridPanel({
store: this.storePortDetention,
title:"目的港免箱期",
region: "center",
flex: 2,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing_PortDetention],
//selModel: //this.cargoCheckBoxModel,
selType: 'cellmodel',
//features: [{
// ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
//}],
tbar: [
{
text: '增加明细',
id: "btnaddPD",
iconCls: "btnadddetail",
handler: function (button, event) {
//this.Save('4');
this.onAddPortDetentionClick();
},
scope: this
}, '-',
{
text: '删除明细',
tooltip: '删除明细为直接执行,删除后不需要再次点击保存',
id: 'btndelPD',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelPortDetentionClick(button, event);
},
scope: this
}
],
columns: this.column_PortDetention
,
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeWay,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})]
});
this.formPortDetention.reconfigure(this.storePortDetention, this.column_PortDetention);
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
height:28,
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
},
{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
, '-',
{
id: 'btnCopyNew',
text: "复制新建",
iconCls: "btncopy",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-',
{
id: 'btnLock',
text: "锁定",
handler: function (button, event) {
this.PushState("3101");
},
scope: this
},
{
id: 'btnUnlock',
text: "解锁",
handler: function (button, event) {
this.PushState("3100");
},
scope: this
}, '-',
{
text: "生成运价",id:"btnMAKEPRICE",
handler: function (button, event) {
this.MakePrice();
},
scope: this
}, '-',
{
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
this.panel_Way = new Ext.Panel({
layout: "border",
region: "west",
frame: true,
split: true,
//width:520,
flex: 5,
title: "港口信息",
items: [
this.formWay
]
});
this.page_1 = new Ext.Panel({
layout: "border",
region: "center",
id:"pnlModel",
//frame: true,
//split: true,
//flex: 3,
title: "费用模板",
items: [
this.formDetail_Model
]
});
this.page_2 = new Ext.Panel({
layout: "border",
region: "center",
id:"pnlFee",
//frame: true,
//split: true,
//flex: 3,
title: "费用信息",
items: [
this.formDetail
]
});
this.panelTab_Fee = new Ext.tab.Panel({
layout: "border",
region: "center",
split: true,
flex: 4,
items: [this.page_1, this.page_2],
listeners: {
scope: this,
'beforetabchange': function (tabPanel, newCard, oldCard, eOpts) {
if (oldCard.id == "pnlModel") {
var feemodify = _this.storeBody_Model.getModifiedRecords();
if (feemodify.length>0) {
//_this.Save('3');
}
}
if (oldCard.id == "pndFee") {
var feemodify = _this.storeBody.getModifiedRecords();
if (feemodify.length > 0) {
//_this.Save('3');
}
}
if (newCard.id == "pndFee") {
//看看左边路径表是否有选中值
var selectedRecords = this.formWay.selModel.getSelection();
if (selectedRecords.length > 0) {
record = selectedRecords[0];
var bsno = _this.Editdata.BSNO;
var PODLOAD = record.data.PODLOAD;
var PORTDISCHARGE = record.data.PORTDISCHARGE;
var VIA = record.data.VIA;
var VIA2 = record.data.VIA2;
_this.loadDetail(bsno);
}
}
}
}
});
this.panelBottom = new Ext.Panel({
layout: "border",
title:"运价信息",
region: 'center',
items: [
this.panel_Way
, this.panelTab_Fee
]
});
this.panelTab_All = new Ext.tab.Panel({
layout: "border",
region: "center",
split: true,
flex: 4,
items: [this.panelBottom, this.formPortDetention]
});
this.panelHead = new Ext.Panel({
border: true,
region: 'north',
height: 126,
items:
[
this.panelBtn,
this.formHead
]
});
Ext.apply(this,
{
items: [
this.panelHead, this.panelTab_All
]
});
//#endregion
//this.LoadInitData();
this.InitData();
//#region 绑定方法
this.formWay.on('edit', function (editor, e, eOpts) {
this.WayAfterEdit(editor, e, eOpts);
}, this);
this.formWay.getSelectionModel().on('select', function (model, record, index) {
if (record.data.ID == this.selectWay.ID) return;//同一行选中不做处理
//如果左右两边有一边没有保存 先save4
//var feemodify1 = _this.storeBody.getModifiedRecords();
//var feemodify2 = _this.storeWay.getModifiedRecords();
//var feemodify3 = _this.storeBody_Model.getModifiedRecords();
//if (feemodify1.length + feemodify2.length + feemodify3.length>0) {
// _this.Save('3');
//}
//如新选中的行
BSNO = this.editRecord.get("BSNO");
this.selectWay.ID = record.data.ID;
this.selectWay.BSNO = record.data.BSNO;
this.selectWay.PODLOAD = record.data.PODLOAD;
this.selectWay.PORTDISCHARGE = record.data.PORTDISCHARGE;
this.selectWay.VIA = record.data.VIA;
this.selectWay.VIA2 = record.data.VIA2;
this.selectWay.ETD = record.data.ETD;
this.selectWay.TT = record.data.TT;
_this.loadDetail(BSNO);
setTabActive(this.panelTab_Fee, "pnlFee");
}, this);
this.storeWay.on('beforeload', function (store) {
BSNO = this.editRecord.get('BSNO');
sql = " BSNO='" + BSNO + "' ";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
_storeFeeNameRef = ret[3];
this.storeFeeNameRef.loadData(_storeFeeNameRef.data.items);
// ret[5] = this.storeCustCode;
//ret[6] = this.storeCodeLoadport;
// ret[7] = this.storePORTDISCHARGE;
_storeCustCode = ret[5];
this.storeCARRIER.loadData(_storeCustCode.data.items);
_storeCodeLoadport = ret[6];
this.storeCodeLoadport.loadData(_storeCodeLoadport.data.items);
//_storePORTDISCHARGE = ret[7];
//this.storeCodePort.loadData(_storePORTDISCHARGE.data.items);
//this.storePortDischarge.loadData(_storePORTDISCHARGE.data.items);
//this.storeVIA.loadData(_storePORTDISCHARGE.data.items);
//this.storeVIA2.loadData(_storePORTDISCHARGE.data.items);
}
if (this.opStatus == 'edit') {
Headcondition = "BSNO='" + this.editRecord.get('BSNO') + "'";
Bodycondition = this.editRecord.get('BSNO');
} else {
Headcondition = "";
Bodycondition = "**";
}
this.LoadData(this.opStatus, Headcondition, Bodycondition);
}, //end InitData
LoadData: function (opStatus, condition, BSNO) {
this.serialNo = 0;
//this.bodyDel = [];
this.opStatus = opStatus;
if (this.opStatus == 'edit') {
//var BSNO = this.editRecord.get('BSNO').toString().trim();
if (BSNO != "") {
document.title = "合约序列号:" + this.editRecord.get('BSNO').toString().trim();
}
}
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsPrice/GetContractData',
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;
}
this.Editdata = result.data;
//this.LoadInit(data);
this.formHead.getForm().reset();
this.formHead.getForm().setValues(this.Editdata);
//this.ShowPort(this.Editdata);
this.SetLockStatus(this.Editdata);
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
this.loadBody(BSNO);
},
SetLockStatus: function (data) {
//if (isTrue(data.FEESTATUS))
// this.formHead.getForm().findField('FEESTATUSREF').setValue("是");
//else
// this.formHead.getForm().findField('FEESTATUSREF').setValue("否");
//if (isTrue(data.BSSTATUS))
// this.formHead.getForm().findField('BSSTATUSREF').setValue("是");
//else
// this.formHead.getForm().findField('BSSTATUSREF').setValue("否");
if (data.CSTATUS == '3101')
{
this.setLock();
}
else
{
this.setUnlock();
}
},
setLock() {
Ext.getCmp("btnLock").disable();
Ext.getCmp("btnUnlock").enable();
Ext.getCmp("btnESave").disable();
Ext.getCmp("btnESaveAndClose").disable();
Ext.getCmp("btnadddetail").disable();
Ext.getCmp("btndeletedetail").disable();
Ext.getCmp("btnaddWay").disable();
Ext.getCmp("btndelWay").disable();
Ext.getCmp("btnadddetail_Model").disable();
Ext.getCmp("btndeletedetail_Model").disable();
},
setUnlock() {
Ext.getCmp("btnLock").enable();
Ext.getCmp("btnUnlock").disable();
Ext.getCmp("btnESave").enable();
Ext.getCmp("btnESaveAndClose").enable();
Ext.getCmp("btnadddetail").enable();
Ext.getCmp("btndeletedetail").enable();
Ext.getCmp("btnaddWay").enable();
Ext.getCmp("btndelWay").enable();
Ext.getCmp("btnadddetail_Model").enable();
Ext.getCmp("btndeletedetail_Model").enable();
}
,
loadBody: function (BSNO) {
//this.loadDetail_Model(BSNO);
this.storeWay.load({
params: { condition: " BSNO='" + BSNO + "' " }
, callback: function (options, success, response) {
//如果之前选中了一条 则继续选中
_this.storeWay.each(function (rec) {
if (rec.get("PODLOAD") == _this.selectWay.PODLOAD && rec.get("PORTDISCHARGE") == _this.selectWay.PORTDISCHARGE && rec.get("VIA") == _this.selectWay.VIA && rec.get("VIA2") == _this.selectWay.VIA2) {
_this.formWay.getSelectionModel().select(rec, true);
_this.loadDetail(BSNO);
}
});
}
});
this.loadPortDetention(BSNO);
this.loadDetail_Model(BSNO);
},
loadWay: function (BSNO,Type) {
//this.loadDetail_Model(BSNO);
this.storeWay.load({
params: { condition: " BSNO='" + BSNO + "' " }
, callback: function (options, success, response) {
if (Type == "4") {
//代表这是新增路径之后的载入 需要改为选中第一个没有PORTDISCHARGE的
_this.storeWay.each(function (rec) {
if ( rec.get("PORTDISCHARGE") == "") {
_this.formWay.getSelectionModel().select(rec, true);
}
});
}
else {
//如果之前选中了一条 则继续选中
_this.storeWay.each(function (rec) {
if (rec.get("PODLOAD") == _this.selectWay.PODLOAD && rec.get("PORTDISCHARGE") == _this.selectWay.PORTDISCHARGE && rec.get("VIA") == _this.selectWay.VIA && rec.get("VIA2") == _this.selectWay.VIA2) {
_this.formWay.getSelectionModel().select(rec, true);
}
});
}
}
});
},
loadDetail_Model: function (BSNO) {
_this = this;
condition_Model = " BSNO='" + BSNO + "' and isnull(PODLOAD,'')='' and isnull(PORTDISCHARGE,'')='' and isnull(VIA,'')='' and isnull(VIA2,'')='' ";
this.storeBody_Model.load({
params: { condition: condition_Model }
, callback: function (options, success, response) {
}
});
},
loadDetail: function (BSNO) {
_this = this;
condition_Detail = " BSNO='" + BSNO + "' and PODLOAD='" + this.selectWay.PODLOAD + "' and PORTDISCHARGE='" + this.selectWay.PORTDISCHARGE + "' and VIA='" + this.selectWay.VIA + "'" + " and VIA2='" + this.selectWay.VIA2 + "'";
if (!isNullorEmpty(_this.selectWay.PODLOAD) || !isNullorEmpty(_this.selectWay.PORTDISCHARGE)) {
_this.storeBody.load({
params: { condition: condition_Detail }
, callback: function (options, success, response) {
if (_this.storeBody.getCount() == 0 && _this.storeBody_Model.getCount() > 0) {
_this.storeBody_Model.each(function (record) {
newdetail = Ext.create('MsPrice_Contract_Detailmb', {
'GID': NewGuid(),
'SEQUENCE': record.data.SEQUENCE,
'BSNO': '',
'FEENAME': record.data.FEENAME,
'CTN0': '0',//record.data.CTN0
'CTN1': '0',
'CTN2': '0',
'CTN3': '0',
'CTN4': '0',
'PODLOAD': _this.selectWay.PODLOAD,
'PORTDISCHARGE': _this.selectWay.PORTDISCHARGE,
'VIA': _this.selectWay.VIA,
'VIA2': _this.selectWay.VIA2
});
_this.storeBody.add(newdetail);
});
_this.storeBody.each(function (record) {
_this.storeBody_Model.each(function (modelrecord) {
if (modelrecord.data.FEENAME == record.data.FEENAME) {
record.set('CTN0',modelrecord.data.CTN0);
record.set('CTN1',modelrecord.data.CTN1);
record.set('CTN2',modelrecord.data.CTN2);
record.set('CTN3',modelrecord.data.CTN3);
record.set('CTN4',modelrecord.data.CTN4);
}
});
});
}
}
});
}
},
loadPortDetention: function (BSNO) {
_this = this;
condition_Detail = " BSNO='" + BSNO + "' ";
_this.storePortDetention.load({
params: { condition: condition_Detail }
, callback: function (options, success, response) {
}
});
},
//#region 显示港口列表
ShowPort: function (data) {
this.storePortLoad.removeAll();
var arr = data.PORTLOADCOMMASTR.split(';');
if (arr.length > 0) {
for (_i = 0; _i < arr.length; _i++) {
this.PortLoadListAdd(arr[_i]);
}
}
this.storePortDischarge.removeAll();
var arr2 = data.PORTDISCHARGECOMMASTR.split(';');
if (arr.length > 0) {
for (_i = 0; _i < arr2.length; _i++) {
this.PortDischargeListAdd(arr2[_i]);
}
}
},
PortLoadListAdd: function (PORT) {
if (isNullorEmpty(PORT)) return;
item = Ext.create('PORTLOADmb', {
'PORT': PORT
});
var field = this.storePortLoad.findRecord('PORT', PORT, 0, false, false, true);
if (!field) {
this.storePortLoad.add(item);
}
},
PortDischargeListAdd: function (PORT) {
if (isNullorEmpty(PORT)) return;
item = Ext.create('PORTDISCHARGEmb', {
'PORT': PORT
});
var field = this.storePortDischarge.findRecord('PORT', PORT, 0, false, false, true);
if (!field) {
this.storePortDischarge.add(item);
}
},
PortLoadListDel: function () {
var selections = this.formPortLoad.getSelectionModel().getSelection();
if (selections.length == 0) {
return;
}
var delrecord = selections[0];
this.storePortLoad.remove(delrecord);
},
PortDischargeListDel: function (PORT) {
var selections = this.formPortDischarge.getSelectionModel().getSelection();
if (selections.length == 0) {
return;
}
var delrecord = selections[0];
this.storePortDischarge.remove(delrecord);
},
PortLoadGetStr: function () {
var result = "";
this.storePortLoad.each(function (record) {
if (!isNullorEmpty(result)) result += ";";
result += record.get('PORT');
});
return result;
},
PortDischargeGetStr: function () {
var result = "";
this.storePortDischarge.each(function (record) {
if (!isNullorEmpty(result)) result += ";";
result += record.get('PORT');
});
return result;
},
//#endregion
// end LoadDate
//#endregion
LoadInitData: function () {
},
//#region 保存/添加/删除
Save: function (type) {
var Form = this.formHead.getForm();
if (!Form.isValid() ) {
return;
}
var data = Form.getValues();
//data.PORTLOADCOMMASTR = this.PortLoadGetStr();
//data.PORTDISCHARGECOMMASTR = this.PortDischargeGetStr();
var Bodydatas = [];
for (var i = 0; i < this.storeBody_Model.getCount(); i += 1) {
var member = this.storeBody_Model.getAt(i);
Bodydatas.push(member);
}
for (var i = 0; i < this.storeBody.getCount(); i += 1) {
var member = this.storeBody.getAt(i);
if (isNullorEmpty(member.get("PODLOAD")) || isNullorEmpty(member.get("PODLOAD"))) {
} else {
Bodydatas.push(member);
}
}
var jsonBody = ConvertRecordsToJson(Bodydatas);
var Waydatas = [];
for (var i = 0; i < this.storeWay.getCount(); i += 1) {
var member = this.storeWay.getAt(i);
if (isNullorEmpty(member.data.PODLOAD) || isNullorEmpty(member.data.PORTDISCHARGE)) {
Ext.Msg.show({
title: '错误',
msg: '运输路径必须包括起运港和目的港',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
Waydatas.push(member);
}
var jsonWay = ConvertRecordsToJson(Waydatas);
var PDdatas = [];
for (var i = 0; i < this.storePortDetention.getCount(); i += 1) {
var member = this.storePortDetention.getAt(i);
if (isNullorEmpty(member.data.PORTDISCHARGE) ) {
Ext.Msg.show({
title: '错误',
msg: '请选择目的港',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
PDdatas.push(member);
}
var jsonPortTention = ConvertRecordsToJson(PDdatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/SaveContract_ef',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
Body: jsonBody,
Way: jsonWay,
PORTDETENTION:jsonPortTention
},
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.Editdata = returnData;
this.Editdata.EFFECTIVEDATE = this.Editdata.EFFECTIVEDATE.replace(" 00:00:00", "");
this.Editdata.VALIDDATE = this.Editdata.VALIDDATE.replace(" 00:00:00", "");
this.formHead.getForm().reset();
this.formHead.getForm().setValues(this.Editdata);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
this.opStatus = 'edit';
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsPrice_ContractIndexmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'BSNO')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
//this.Editdata = result.data;
}
this.GetEditStatus();
if (type == '0') {
//this.storeBody.removeAll();
this.loadBody(this.editRecord.get('BSNO').toString().trim());
//this.loadDetail(this.editRecord.get('BSNO'));
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.CopyNew(this.editRecord.get('BSNO'));
} else if (type == '3') {
BSNO = this.editRecord.get('BSNO');
//this.loadDetail_Model(BSNO);
this.loadDetail(BSNO);
}
else if (type == '4') {
BSNO = this.editRecord.get('BSNO');
//this.loadDetail_Model(BSNO);
this.storeWay.load({
params: { condition: " BSNO='" + BSNO + "' " }
, callback: function (options, success, response) {
_this.storeWay.each(function (rec) {
if (rec.get("PODLOAD") == _this.selectWay.PODLOAD && rec.get("PORTDISCHARGE") == _this.selectWay.PORTDISCHARGE && rec.get("VIA") == _this.selectWay.VIA && rec.get("VIA2") == _this.selectWay.VIA2)
_this.formWay.getSelectionModel().select(rec, true);
});
_this.onAddWayClick();
}
});
this.storeBody.removeAll();
this.loadDetail(this.editRecord.get('BSNO'));
}
} 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
CopyNew: function (OLDBSNO) {
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/CopyNew_Contract',
scope: this,
params: {
OLDBSNO: OLDBSNO
},
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.Editdata = returnData;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(this.Editdata);
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
}
}
});
}
,
SaveDetail: function (type) {
var Form = this.formHead.getForm();
var _this = this;
if (!Form.isValid()) {
return;
}
var data = Form.getValues();
var Way = this.selectWay;
if (this.opStatus != 'edit') {
Ext.Msg.show({ title: '错误', msg: "该功能仅用于明细修改,请先保存此业务。", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
for (var i = 0; i < this.storeWay.getCount(); i += 1) {
var member = this.storeWay.getAt(i);
if (isNullorEmpty(member.data.PODLOAD) || isNullorEmpty(member.data.PORTDISCHARGE)) {
Ext.Msg.show({
title: '错误',
msg: '运输路径必须包括起运港和目的港',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (Way.ID == member.data.ID) {
Way = member.data;
break;
}
}
//data.PORTLOADCOMMASTR = this.PortLoadGetStr();
//data.PORTDISCHARGECOMMASTR = this.PortDischargeGetStr();
var Bodydatas = [];
for (var i = 0; i < this.storeBody_Model.getCount(); i += 1) {
var member = this.storeBody_Model.getAt(i);
Bodydatas.push(member);
}
for (var i = 0; i < this.storeBody.getCount(); i += 1) {
var member = this.storeBody.getAt(i);
if (isNullorEmpty(member.get("PODLOAD")) || isNullorEmpty(member.get("PODLOAD"))) {
} else {
Bodydatas.push(member);
}
}
var jsonBody = ConvertRecordsToJson(Bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/SaveContract_Detail',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
Body: jsonBody,
Way: Ext.JSON.encode(Way),
Type: type
},
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.loadWay(this.editRecord.get('BSNO').toString().trim(), "4");
this.loadDetail(this.editRecord.get('BSNO').toString().trim());
} 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
AddDetail: function (type) {
var Form = this.formHead.getForm();
var _this = this;
if (!Form.isValid()) {
return;
}
var data = Form.getValues();
var Way = this.selectWay;
if (this.opStatus != 'edit') {
Ext.Msg.show({ title: '错误', msg: "该功能仅用于明细修改,请先保存此业务。", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
for (var i = 0; i < this.storeWay.getCount(); i += 1) {
var member = this.storeWay.getAt(i);
if (isNullorEmpty(member.data.PODLOAD) || isNullorEmpty(member.data.PORTDISCHARGE)) {
Ext.Msg.show({
title: '错误',
msg: '运输路径必须包括起运港和目的港',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (Way.ID == member.data.ID) {
Way = member.data;
break;
}
}
//data.PORTLOADCOMMASTR = this.PortLoadGetStr();
//data.PORTDISCHARGECOMMASTR = this.PortDischargeGetStr();
var Bodydatas = [];
for (var i = 0; i < this.storeBody_Model.getCount(); i += 1) {
var member = this.storeBody_Model.getAt(i);
Bodydatas.push(member);
}
for (var i = 0; i < this.storeBody.getCount(); i += 1) {
var member = this.storeBody.getAt(i);
if (isNullorEmpty(member.get("PODLOAD")) || isNullorEmpty(member.get("PODLOAD"))) {
} else {
Bodydatas.push(member);
}
}
var jsonBody = ConvertRecordsToJson(Bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/SaveContract_Detail',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
Body: jsonBody,
Way: Ext.JSON.encode(Way)
},
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.loadBody(this.editRecord.get('BSNO').toString().trim());
if (type == '4') {
var selectedRecords = this.formWay.selModel.getSelection();
if (selectedRecords.length > 0) {
record = selectedRecords[0];
this.CopyAddWayClick(record.data);
//return;
} else {
this.AddWayClick();
}
}
} 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 合约明细 添加/复制添加/删除
onAddDetailClick: function (button, event) {
if (this.panelTab_Fee.getActiveTab().id == "pnlFee") {
this.doAddDetailClick(button, event);
}
if (this.panelTab_Fee.getActiveTab().id == "pnlModel") {
this.doAddDetailModelClick(button, event);
}
},
doAddDetailClick: function (button, event) {
//20191009 首先判断是否已选中一行 如有 则将其作为参数 传递给onCopy 以实现复制添加
_this = this;
var selectedRecords = this.formDetail.selModel.getSelection();
if (selectedRecords.length > 0) {
record = selectedRecords[0];
this.onCopyAddClick(record.data);
//return;
} else {
var linenum = this.storeBody.getCount() + 1;
var _r = this.reLine();
var record = Ext.create('MsPrice_Contract_Detailmb', {
'GID': NewGuid(),
'SEQUENCE': linenum,
'BSNO': '',
'FEENAME': '',
'CTN0': '0',
'CTN1': '0',
'CTN2': '0',
'CTN3': '0',
'CTN4': '0',
'PODLOAD': _this.selectWay.PODLOAD,
'PORTDISCHARGE': _this.selectWay.PORTDISCHARGE,
'VIA': _this.selectWay.VIA,
'VIA2': _this.selectWay.VIA2
});
this.storeBody.add(record);
var n = this.storeBody.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 4 });
}
},
doAddDetailModelClick: function (button, event) {
var linenum = this.storeBody_Model.getCount() + 1;
var _r = this.reLine();
var record = Ext.create('MsPrice_Contract_Detailmb', {
'GID': NewGuid(),
'SEQUENCE': linenum,
'BSNO': '',
'FEENAME': '',
'CTN0': '0',
'CTN1': '0',
'CTN2': '0',
'CTN3': '0',
'CTN4': '0',
'PODLOAD': '',
'PORTDISCHARGE': '',
'VIA': ''
});
this.storeBody_Model.add(record);
var n = this.storeBody_Model.getCount();
this.cellEditing_Model.startEditByPosition({ row: n - 1, column: 4 });
},
onCopyAddClick: function (oldrecord) {
var linenum = this.storeBody.getCount() + 1;
var _r = this.reLine();
var record = Ext.create('MsPrice_Contract_Detailmb', {
'GID': NewGuid(),
'SEQUENCE': linenum,
'BSNO': '',
'FEENAME': oldrecord.FEENAME,
'CTN0': oldrecord.CTN0,
'CTN1': oldrecord.CTN1,
'CTN2': oldrecord.CTN2,
'CTN3': oldrecord.CTN3,
'CTN4': oldrecord.CTN4
});
this.storeBody.add(record);
var n = this.storeBody.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 4 });
},
onDelDetailClick: function (button, event) {
var selectedRecords = this.formDetail.selModel.getSelection();
this.doDelDetail(selectedRecords);
},
onDelDetailClick_Model: function (button, event) {
var selectedRecords = this.formDetail_Model.selModel.getSelection();
this.doDelDetail(selectedRecords);
},
doDelDetail: function (selectedRecords) {
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
var GIDList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (GIDList != "") {
GIDList += ",";
}
GIDList += "'" + rec.data.GID + "'";
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/DelContractDetail',
scope: this,
params: {
data: Ext.JSON.encode(this.Editdata),
GID: GIDList
},
callback: function (options, success, response) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.loadBody(this.editRecord.get('BSNO'));
//this.loadDetail(this.editRecord.get('BSNO'));
} else {
Ext.Msg.show({
title: '请重试',
msg: jsonresult.Message,
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
}, this);
},
reLine: function (button, event) {
var _L = 1;
this.storeBody.each(function (record) {
var ln = _L + "";
_L = _L + 1;
record.set('SEQUENCE', ln);
});
},
//#endregion
//#region 运输路径 添加/复制添加/删除
onAddWayClick: function (button, event) {
//20191009 首先判断是否已选中一行 如有 则将其作为参数 传递给onCopy 以实现复制添加
//20210325 如果是全新的 则执行save4//如果是编辑 则执行savedetail4
if (this.opStatus == 'add') {
this.Save('4');
} else {
this.SaveDetail('4');
}
},
AddWayClick: function () {
var linenum = this.storeWay.getCount() + 1;
var record = Ext.create('Waymb', {
'ID': '',
'BSNO': '',
'PODLOAD': '',
'PORTDISCHARGE': '',
'VIA': '',
'VIA2': ''
});
this.storeWay.add(record);
this.selectWay = record.data;
var n = this.storeWay.getCount();
this.cellEditing_Way.startEditByPosition({ row: n - 1, column: 2 });
this.storeBody.removeAll();
if (this.storeBody_Model.getCount() > 0) {
this.storeBody_Model.each(function (record) {
newdetail = Ext.create('MsPrice_Contract_Detailmb', {
'GID': '',
'SEQUENCE': record.data.SEQUENCE,
'BSNO': '',
'FEENAME': record.data.FEENAME,
'CTN0': record.data.CTN0,
'CTN1': record.data.CTN1,
'CTN2': record.data.CTN2,
'CTN3': record.data.CTN3,
'CTN4': record.data.CTN4,
'PODLOAD': '',
'PORTDISCHARGE': '',
'VIA': ''
});
_this.storeBody.add(newdetail);
});
this.storeBody.each(function (record) {
record.set("GID", NewGuid());
});
}
},
CopyAddWayClick: function (oldrecord) {
var linenum = this.storeWay.getCount() + 1;
var record = Ext.create('Waymb', {
'ID': '',
'BSNO': '',
'PODLOAD': oldrecord.PODLOAD,
'PORTDISCHARGE': '',
'VIA': '',
'VIA2': ''
});
this.storeWay.add(record);
this.selectWay = record.data;
var n = this.storeWay.getCount();
this.cellEditing_Way.startEditByPosition({ row: n - 1, column: 2 });
this.storeBody.removeAll();
if (this.storeBody_Model.getCount() > 0) {
this.storeBody_Model.each(function (record) {
newdetail = Ext.create('MsPrice_Contract_Detailmb', {
'GID': '',
'SEQUENCE': record.data.SEQUENCE,
'BSNO': '',
'FEENAME': record.data.FEENAME,
'CTN0': record.data.CTN0,
'CTN1': record.data.CTN1,
'CTN2': record.data.CTN2,
'CTN3': record.data.CTN3,
'CTN4': record.data.CTN4,
'PODLOAD': oldrecord.PODLOAD,
'PORTDISCHARGE': '',
'VIA': ''
});
_this.storeBody.add(newdetail);
});
this.storeBody.each(function (record) {
record.set("GID", NewGuid());
});
}
},
onDelWayClick: function (button, event) {
//注意需要先判断是否已生成运价
var selectedRecords = this.formWay.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
var GIDList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (GIDList != "") {
GIDList += ",";
}
GIDList += "" + rec.data.ID + "";
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/DelContractWay',
scope: this,
params: {
data: Ext.JSON.encode(this.Editdata),
ID: GIDList
},
callback: function (options, success, response) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//var returnData = jsonresult.Data;
//this.Editdata = returnData;
this.loadBody(this.editRecord.get('BSNO'));
this.ClearSelectWay();
//this.loadDetail(this.editRecord.get('BSNO'));
//this.formHead.getForm().reset();
//this.formHead.getForm().setValues(this.Editdata);
//this.loadBody(" BSNO='" + this.editRecord.get('BSNO').toString().trim() + "' ");
} else {
Ext.Msg.show({
title: '请重试',
msg: jsonresult.Message,
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
}, this);
},
ClearSelectWay() {
this.selectWay.ID = "0";
this.selectWay.BSNO = "";
this.selectWay.PODLOAD = "";
this.selectWay.PORTDISCHARGE = "";
this.selectWay.VIA = "";
this.selectWay.VIA2 = "";
this.selectWay.ETD = "";
this.selectWay.TT = "0";
},
//#endregion
//#region 运输路径 添加/复制添加/删除
onAddPortDetentionClick: function (button, event) {
var selectedRecords = this.formPortDetention.selModel.getSelection();
if (selectedRecords.length > 0) {
record = selectedRecords[0];
this.CopyAddPortDetentionClick(record.data);
//return;
} else {
this.AddPortDetentionClick();
}
},
AddPortDetentionClick: function () {
var linenum = this.storePortDetention.getCount() + 1;
var record = Ext.create('PortDetentionmb', {
'ID': '',
'BSNO': '',
'PORTDISCHARGE': '',
'CTN0': '',
'CTN1': '',
'CTN2': '',
'CTN3': '',
'CTN4': ''
});
this.storePortDetention.add(record);
},
CopyAddPortDetentionClick: function (oldrecord) {
var linenum = this.storeWay.getCount() + 1;
var record = Ext.create('PortDetentionmb', {
'ID': '',
'BSNO': '',
'PORTDISCHARGE': '',
'CTN0': oldrecord.CTN0,
'CTN1': oldrecord.CTN1,
'CTN2': oldrecord.CTN2,
'CTN3': oldrecord.CTN3,
'CTN4': oldrecord.CTN4
});
this.storePortDetention.add(record);
},
onDelPortDetentionClick: function (button, event) {
var selectedRecords = this.formPortDetention.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
var GIDList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (GIDList != "") {
GIDList += ",";
}
GIDList += "" + rec.data.ID + "";
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/DelContractPORTDETENTION',
scope: this,
params: {
data: Ext.JSON.encode(this.Editdata),
ID: GIDList
},
callback: function (options, success, response) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.loadPortDetention(this.editRecord.get('BSNO'));
} else {
Ext.Msg.show({
title: '请重试',
msg: jsonresult.Message,
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
}, this);
},
//#endregion
//#region 锁定 解锁
PushState: function (execution) {
_this = this;
var Form1 = this.formHead.getForm();
if (!Form1.isValid() ) {
return;
}
var data1 = Form1.getValues(false, false, false);
var Head = Ext.JSON.encode(this.Editdata);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/PushState',
scope: this,
params: {
data: Head,
Execution: execution
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Headcondition = "BSNO='" + _this.editRecord.get('BSNO') + "'";
Bodycondition = _this.editRecord.get('BSNO');
this.LoadData('edit', Headcondition, Bodycondition);
} 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
});
}
}
});
},
//#endregion
//#region 生成运价
MakePrice: function () {
var Form1 = this.formHead.getForm();
if (!Form1.isValid()) {
return;
}
var data1 = Form1.getValues(false, false, false);
var BSNO = "'" + data1.BSNO + "'";
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsPrice/MakePrice',
scope: this,
params: {
BSNOList: BSNO
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.InitData();
} 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
});
}
}
});
},
//#endregion
//#region 运输路径 afteredit
WayAfterEdit: function (editor, e, eOpts) {
//当左边的路径值改变时 相应改变右边的路径值
if (e.value == e.originalValue) { return; }
if (e.field == 'PODLOAD' ) {
this.selectWay.PODLOAD = e.value;
}
if (e.field == 'PORTDISCHARGE') {
this.selectWay.PORTDISCHARGE = e.value;
}
if (e.field == 'VIA') {
this.selectWay.VIA = e.value;
}
if (e.field == 'VIA2') {
this.selectWay.VIA2 = e.value;
}
if (e.field == 'PODLOAD' || e.field == 'PORTDISCHARGE' || e.field == 'VIA' || e.field == 'VIA2') {
this.ChangeDetailWay(e.field, e.value);
}
},
ChangeDetailWay: function (fieldname, value) {
if (this.storeBody.getCount()>0)
this.storeBody.each(function (record) {
record.set(fieldname, value);
});
},
//#endregion
//#region 载入初始信息
LoadInit: function (data) {
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
_this = this;
var op = USERID;
this.StoreOpRange.load({
params: { optype: "modPrice_Contract" },
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 { 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 btndeletedetail = Ext.getCmp('btndeletedetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btndeletedetail.enable();
this.SetLockStatus(this.Editdata);
} else {
btnESave.disable();
btnESaveAndClose.disable();
btndeletedetail.disable();
}
},
//#endregion
//#region 打印
Print: function () {
var basicForm = this.formHead.getForm();
var BSNO = basicForm.findField('BSNO').value;
if (BSNO == '*' || BSNO == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'Op_Price_Contract';
var sql1 = "";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsPrice/GetPrintSql',
params: {
printname: "Print1",
BSNOList: "'" + BSNO+"'"
},
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;
}
//this.Editdata = result.data;
//this.LoadInit(data);
sql1 = result.Data.sql1;
sql2 = result.Data.sql2;
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#region 选中路径或者选择费用/模板的切换方法
//0:最初状态 左边未选择 右边显示费用模板
//1:左边选择路径 右边切换至费用信息 并载入
//this.tabSeaepanel.setActiveTab(i);
//setTabActive(this.tabSeaepanel,'feetab');
//#endregion
});