You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsOpSocCtn/MsOpSocCtnBsEdit.js

1396 lines
47 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpSocCtnBsEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpSocCtnBsEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpSocCtnBsEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
sqlcontext: '',
PageSize: 30,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
//权限范围
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisport,
matchFieldWidth: false,
name: 'PORTDISCHARGE',
allowBlank: false,
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
valueField: 'PORT',
displayField: 'PORT'
});
this.storeCodeDisport2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeDisport2,
matchFieldWidth: false,
allowBlank: true,
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'PORT'
});
this.storeCodeDisport3 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxTRANSPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '中转港',
store: this.storeCodeDisport3,
matchFieldWidth: false,
allowBlank: true,
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
name: 'TRANSPORT',
valueField: 'PORT',
displayField: 'PORT'
});
_this = this;
this.storeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCtn.load();
//箱型
this.comboxCTN = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCtn,
forceSelection: true,
fieldLabel: '箱型',
allowBlank: true,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN'
});
//表参照相关(编辑form)
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.VesselModel',
proxy: { url: '/CommMng/BasicDataRef/GetVesselList' }
});
this.storeVoyVeg.load();
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船名', //'船 名',
store: this.storeVoyVeg,
allowBlank: false,
name: 'VESSEL',
valueField: 'VESSEL',
displayField: 'VESSEL'
});
this.storeAgent = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
this.storeAgent.load();
//委托单位
this.comboxAgent= Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '国外代理',
store: this.storeAgent,
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//客户加载_场站
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
// this.storeYARD.loadData(this.mainWin.GetPubStore("OPSEAE_YARD").data.items);
this.storeYARD.load();
//
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '还箱地点', //'场站',
store: this.storeYARD,
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'RTCTNYARD',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
// autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth:70,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'BSNO',
name: 'BSNO', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'CORPID',
name: 'CORPID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'INPUTBY',
name: 'INPUTBY', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '提单号',
labelWidth: 70,
allowBlank: false,
name: 'MBLNO'
}, this.comboxVoyVeg, {
fieldLabel: '航次',
allowBlank: false,
name: 'VOYNO'
}, {
fieldLabel: '开船日期',
allowBlank: false,
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'ETD'
}, {
fieldLabel: '业务状态',
readOnly: true,
name: 'BSSTATUS'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxPORTLOAD, this.comboxPORTDISCHARGE, this.comboxTRANSPORT, {
fieldLabel: '到港日期',
format: 'Y-m-d',
allowBlank: false,
flex: 1,
xtype: 'datefield',
name: 'ETA'
}, this.comboxAgent
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '还箱日期',
format: 'Y-m-d',
allowBlank: true,
flex: 1,
xtype: 'datefield',
name: 'RTCTNDATE'
}, this.comboxYARD,{
fieldLabel: '箱型箱量',
readOnly: true,
name: 'CNTRTOTAL'
}, {
fieldLabel: '录入人',
readOnly: true,
disabled: true,
name: 'CREATEUSERREF'
}, {
fieldLabel: '录入日期',
readOnly: true,
disabled: true,
name: 'CREATETIME'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
flex: 3,
name: 'REMARKS'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnEPrev',
text: "上一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
},
{
text: "保存",
iconCls: "btnsave",
id: 'btnsave',
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
id: 'btnsaveandclose',
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
id: 'btnsaveandnew',
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
text: "复制并新建",
id: 'btncopyandsave',
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
basicForm.findField('BSNO').setDisabled(false);
var field = basicForm.findField('BSNO');
var BSNO = NewGuid();
field.setValue(BSNO);
basicForm.findField('BSNO').setValue('')
basicForm.findField('BSNO').setDisabled(true);
this.storeBodyList.removeAll();
this.storeBodyCtnList.removeAll();
this.formEdit.getForm().findField('BSSTATUS').setValue('新建');
this.formEdit.getForm().findField('CREATEUSERREF').setValue(SHOWNAME);
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsOpSocCtnCtnDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSocCtn/GetOpSocCtnCtnDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCodeCtn,
forceSelection: true,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN',
enableKeyEvents: true
});
this.storeDetailYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
this.storeDetailYARD.load();
this.comboxRETURNYARDDetail = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDetailYARD,
forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'RETURNYARD',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListBodyCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListBody = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListBodyCheckBoxModel,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: '取消加入',
tooltip: '取消加入',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleDetailClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'CTNGID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'CTN_ID',
header: '编号2',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'CTNSTATUS',
header: '状态',
width: 80
}, {
sortable: true,
dataIndex: 'CNTRNO',
header: '箱号',
width: 140
}, {
sortable: true,
dataIndex: 'CTNALL',
header: '箱型',
width: 100
}, {
sortable: true,
dataIndex: 'INPUTYARDDATE',
header: '进场时间',
width: 100
}, {
sortable: true,
dataIndex: 'OUTYARDDATE',
header: '出场时间',
width: 100
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 100
}, {
sortable: true,
dataIndex: 'RTCTNDATE',
header: '还箱日期',
editor: {
xtype: 'datefield',
format: 'Y-m-d'
},
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'RTCTNYARD',
header: '还箱场站',
editor: this.comboxRETURNYARDDetail,
width: 100
}, {
dataIndex: 'DEPOSITPRICE',
header: '单箱租金', //'箱量',
width: 100
}]
});
this.gridListBody.on('edit', function (editor, e, eOpts) {
this.gridListAfterEdit(editor, e, eOpts);
}, this);
this.panelBodygz = new Ext.Panel({
title: '集装箱信息',
layout: "border",
region: 'north',
height:280,
animate: true,
minHeight: 150,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridListBody]
});
//#endregion
//#region 集装箱明细信息
this.storeBodyCtnList = Ext.create('Ext.data.Store', {
model: 'MsOpSocCtnCtnDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSocCtn/GetOpSocCtnCtnDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//明细表表格
this.gridListCtnCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListCtnBody = new Ext.grid.GridPanel({
store: this.storeBodyCtnList,
enableHdMenu: false,
region: 'center',
selModel: this.gridListCtnCheckBoxModel,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
text: '加入业务',
tooltip: '添加',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpdateDetailClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'CTNGID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'CTN_ID',
header: '编号2',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'CTNSTATUS',
header: '状态',
width: 80
},{
sortable: true,
dataIndex: 'CNTRNO',
header: '箱号',
width: 140
}, {
sortable: true,
dataIndex: 'CTNALL',
header: '箱型',
width: 100
}, {
sortable: true,
dataIndex: 'INPUTYARDDATE',
header: '进场时间',
width: 100
}, {
sortable: true,
dataIndex: 'OUTYARDDATE',
header: '出场时间',
width: 100
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 100
}, {
sortable: true,
dataIndex: 'RTCTNDATE',
header: '还箱日期',
width: 100
}, {
sortable: true,
dataIndex: 'RTCTNYARD',
header: '还箱场站',
width: 100
}, {
dataIndex: 'DEPOSITPRICE',
header: '单箱租金', //'箱量',
width: 100
}],
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
// paging bar on the bottom
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
// this.gridListCtnBody.on('edit', function (editor, e, eOpts) {
// this.gridListAfterEdit(editor, e, eOpts);
// }, this);
this.gridListCtnBody.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
}, this);
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型', //'箱型',
store: this.storeCodeCtn,
forceSelection: true,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeBSSTATUS = Ext.create('Ext.data.Store', {
fields: ['FSTATUS', 'NAME']
});
this.storeBSSTATUS.add({ "FSTATUS": "未入场", "NAME": "未入场" });
this.storeBSSTATUS.add({ "FSTATUS": "待使用", "NAME": "待使用" });
this.storeBSSTATUS.add({ "FSTATUS": "使用中", "NAME": "使用中" });
this.storeBSSTATUS.add({ "FSTATUS": "已还箱", "NAME": "已还箱" });
this.comboxBSSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '状态',
store: this.storeBSSTATUS,
valueField: 'FSTATUS',
displayField: 'NAME',
forceSelection: true,
name: 'CTNSTATUS',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
this.storeYARD.load();
//
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '场站', //'场站',
store: this.storeYARD,
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'YARD',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeCodeDisport2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxPORTDISCHARGE2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '卸货港', //'卸货港',
store: this.storeCodeDisport2,
name: 'PORTDISCHARGE',
valueField: 'PORT',
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'north',
height:40,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 45,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱号',
name: 'CNTRNO',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '合同号',
name: 'CONTRACTNO',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxCTNALL, this.comboxYARD, this.comboxBSSTATUS, this.comboxPORTDISCHARGE2,{
xtype: 'button',
width: 90,
text: "查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
text: "重置",
xtype: 'button',
width: 90,
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}]
}]
}]
});
this.panelCtnBody = new Ext.Panel({
title: '集装箱明细',
layout: "border",
region: 'center',
// height: 320,
animate: true,
minHeight: 250,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formSearch,this.gridListCtnBody]
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 28,
items: [this.panelBtn]
});
this.panelBodyAll = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
containerScroll: true,
frame: false,
items: [this.formEdit, this.panelBodygz , this.panelCtnBody]
});
Ext.apply(this, {
items: [this.panelTop, this.panelBodyAll]
});
//#endregion
//绑定查询窗体
this.storeBodyList.on('beforeload', function (store) {
var acondition = " D.BS_BSNO='" + this.editRecord.get('BSNO') + "'";
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.storeBodyCtnList.on('beforeload', function (store) {
var acondition = this.sqlcontext;
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.sqlcontext = " ISNULL(D.BS_BSNO,'')='' and ISNULL(D.CNTRNO,'')<>'' ";
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " BSNO='" + this.editRecord.get('BSNO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpSocCtn/GetBsData',
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;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
var acondition = "";
if (this.opStatus == 'edit') {
var acondition = " D.BS_BSNO='" + this.editRecord.get('BSNO') + "'";
}
else
acondition = " D.BS_BSNO='11111'";
this.storeBodyList.load({ params: { condition: acondition} });
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('BSNO').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('BSNO').setDisabled(true);
if (this.opStatus == 'add') {
data.BSNO = NewGuid();
}
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
var RTCTNDATE = member.data.RTCTNDATE;
if (RTCTNDATE != '')
RTCTNDATE = Ext.util.Format.date(RTCTNDATE, 'Y-m-d');
member.data.RTCTNDATE = RTCTNDATE;
j = j + 1;
bodydatas.push(member);
}
// if (j == 0) {
// Ext.Msg.show({ title: '提示', msg: '改装要求不能为空,请先录入改装要求!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
// }
//
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpSocCtn/SaveBs',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody
},
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().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('MsOpSocCtnBs', 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();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('BSNO').setDisabled(true);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
//memberbody.set("BS_BSNO", this.editRecord.get('BSNO'));
memberbody.commit();
};
} else if (type == '1') {
this.opStatus = 'edit';
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
//memberbody.set("BS_BSNO", this.editRecord.get('BSNO'));
memberbody.commit();
};
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('BSNO').setDisabled(false);
}
} 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 () {
var record = Ext.create('MsOpSocCtnCtn', {
CTN_ID: NewGuid(),
BSNO: '*',
REMARKS: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
gridListAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
if (e.field == 'CTNNUM' || e.field == 'DEPOSITPRICE') {
var CTNNUM = e.record.data['CTNNUM'];
var DEPOSITPRICE = e.record.data['DEPOSITPRICE'];
var DEPOSIT = Mul(CTNNUM, DEPOSITPRICE);
e.record.set('DEPOSIT', DEPOSIT);
}
},
onDeleDetailClick: function () {
var selections = this.gridListBody.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要取消加入的集装箱信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var BSNO = this.editRecord.get('BSNO');
Ext.MessageBox.confirm('提示', '确定取消加入选中的集装箱吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在操作数据...');
Ext.Ajax.request({
waitMsg: '正在操作数据...',
url: '/MvcShipping/MsOpSocCtn/UpdateOpSocCtnBsCtn',
params: {
data: jsonbodyAddDatas,
bsno: BSNO,
type: '0'
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " BSNO='" + this.editRecord.get('BSNO') + "'";
//this.storeBodyList.load({ params: { condition: acondition } });
//condition = " BSNO='" + this.editRecord.get('BSNO') + "'";
this.LoadData('edit', acondition);
this.storeBodyCtnList.reload();
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);
},
onUpdateDetailClick: function () {
var selections = this.gridListCtnBody.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要添加的集装箱信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var BSNO = this.editRecord.get('BSNO');
Ext.MessageBox.confirm('提示', '确定添加选中的集装箱吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在操作数据...');
Ext.Ajax.request({
waitMsg: '正在操作数据...',
url: '/MvcShipping/MsOpSocCtn/UpdateOpSocCtnBsCtn',
params: {
data: jsonbodyAddDatas,
bsno: BSNO,
type: '1'
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " BSNO='" + this.editRecord.get('BSNO') + "'";
this.LoadData('edit', acondition);
this.storeBodyCtnList.reload();
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);
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.PageSize = this.Pagenum.getValue();
this.storeBodyCtnList.pageSize = this.PageSize;
this.storeBodyCtnList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onDsQuery: function () {
//var girdcolums = this.gridList.getColumnMode();
var sql = this.sqlcontext;
this.PageSize = this.Pagenum.getValue();
this.storeBodyCtnList.pageSize = this.PageSize;
this.storeBodyCtnList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = " ISNULL(D.BS_BSNO,'')='' and ISNULL(D.CNTRNO,'')<>'' AND CTNSTATUS='待使用' ";
var CNTRNO = form.findField('CNTRNO').getValue();
sql = sql + getAndConSql(sql, CNTRNO, "CNTRNO like '%" + CNTRNO + "%'");
var CONTRACTNO = form.findField('CONTRACTNO').getValue();
sql = sql + getAndConSql(sql, CONTRACTNO, "C.CONTRACTNO='" + CONTRACTNO + "'");
var CTNALL = form.findField('CTNALL').getValue();
sql = sql + getAndConSql(sql, CTNALL, "CTNALL='" + CTNALL + "'");
var YARD = form.findField('YARD').getValue();
sql = sql + getAndConSql(sql, YARD, "YARD='" + YARD + "'");
var CTNSTATUS = form.findField('CTNSTATUS').getValue();
sql = sql + getAndConSql(sql, CTNSTATUS, "CTNSTATUS= '" + CTNSTATUS + "'");
var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue();
sql = sql + getAndConSql(sql, PORTDISCHARGE, "PORTDISCHARGE like '%" + PORTDISCHARGE + "%'");
return sql;
},
//#endregion
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "BSNO='" + this.editRecord.get('BSNO') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
// #region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
var op = this.formEdit.getForm().findField('CREATEUSER').getValue();
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnsave');
var btnESaveAndClose = Ext.getCmp('btnsaveandclose');
var btnESaveAndNew = Ext.getCmp('btnsaveandnew');
var btnECopyAndNew = Ext.getCmp('btncopyandsave');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
},
//#endregion
NextRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "BSNO='" + this.editRecord.get('BSNO') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
getIsModify: function () {
var drmodify = this.storeBodyList.getModifiedRecords();
if (drmodify.length != 0)
return '改装要求';
if (panelEdit.formEdit.getForm().isDirty() == true)
return '申请信息';
else return '';
} //
});