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.

428 lines
14 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpCtnEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.bodyDel = [];
//枚举参照相关
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱主',
store: this.storeCARRIER,
name: 'cntrowner',
valueField: 'CustName',
displayField: 'CustName'
});
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeCodeCtn,
forceSelection: true,
name: 'cntype',
valueField: 'CTN',
displayField: 'CTN'
});
this.StoreCNSOURCE = Ext.create('Ext.data.Store', {
fields: ['SOURCE']
});
this.StoreCNSOURCE.add({ "SOURCE": "自备箱" });
this.StoreCNSOURCE.add({ "SOURCE": "长租箱" });
this.StoreCNSOURCE.add({ "SOURCE": "短租箱" });
this.StoreCNSOURCE.add({ "SOURCE": "租买箱" });
this.StoreCNSOURCE.add({ "SOURCE": "FreeUse箱" });
this.comboxCNSOURCE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱源',
store: this.StoreCNSOURCE,
forceSelection: true,
name: 'cnsource',
valueField: 'SOURCE',
displayField: 'SOURCE'
});
this.StoreStatus = Ext.create('Ext.data.Store', {
fields: ['ID', 'NAME']
});
this.StoreStatus.add({ "NAME": "可用" });
this.StoreStatus.add({ "ID": 2, "NAME": "已用" });
this.StoreStatus.add({ "ID": 3, "NAME": "维修" });
this.StoreStatus.add({ "ID": 4, "NAME": "停用" });
this.StoreStatus.add({ "ID": 5, "NAME": "退租" });
this.StoreStatus.add({ "ID": 6, "NAME": "灭失" });
this.StoreStatus.add({ "ID": 7, "NAME": "卖出" });
this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreStatus,
fieldLabel: '状态',
forceSelection: true,
name: 'status',
valueField: 'NAME',
displayField: 'NAME'
});
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.PortRefModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetPortRefList' }
});
this.storeCodeDisport.load();
this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '位置',
store: this.storeCodeDisport,
forceSelection: true,
name: 'position',
valueField: 'PORTID',
queryMode: 'local',
displayField: 'PORT'
});
this.storeCodeDisport2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.PortRefModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetPortRefList' }
});
this.storeCodeDisport2.load();
this.comboxBEGINPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '启用位置',
store: this.storeCodeDisport2,
forceSelection: true,
name: 'beginpostion',
valueField: 'PORTID',
queryMode: 'local',
displayField: 'PORT'
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '编码',
name: 'cntrid', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '箱号',
name: 'cntrno'
}, this.comboxCARRIER, this.comboxCTNTYPE
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCNSOURCE, this.comboxBEGINPORT, { xtype: 'hiddenfield'}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '购买时间',
format: 'Y-m-d',
xtype: 'datefield',
name: 'buytime'
}, {
fieldLabel: '租用开始',
format: 'Y-m-d',
xtype: 'datefield',
name: 'rent_begintime'
}, {
fieldLabel: '租用结束',
format: 'Y-m-d',
xtype: 'datefield',
name: 'rent_endtime'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '卖出时间',
format: 'Y-m-d',
xtype: 'datefield',
name: 'selltime'
},
this.comboxStatus, this.comboxPORT,
{ xtype: 'hiddenfield',hidden:true }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARK'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//按钮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
},
'-',
{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
},
{
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
var basicForm = this.formEdit.getForm();
basicForm.findField('cntrid').setDisabled(false);
},
scope: this
}
]
}); //end 按钮Toolbar
Ext.apply(this, {
items: [this.panelBtn, this.formEdit]
});
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponen
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " cntrid='" + this.editRecord.get('cntrid') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnStatus/GetCtnData',
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);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpCtnStatus/SaveCtn',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
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('MsCtn', 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('cntrid').setDisabled(true);
} else if (type == '1') {
window.close();
} else {
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
,
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEbtnEAccount = Ext.getCmp('btnEAccount');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEbtnEAccount.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEbtnEAccount.disable();
}
},
Print: function () {
}
});