Ext.namespace('Shipping');
Shipping.MsOpLetterSurEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpLetterSurEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpLetterSurEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
MainEditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modOrderManagement"} });
this.storeFM = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserLinkRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
collapsed: false,
collapsible: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '业务编号',
name: 'BSNO', hidden: true
}, {
fieldLabel: 'LE_ID',
hidden: true,
name: 'LE_ID'
}, {
fieldLabel: 'LETTERNAME',
hidden: true,
name: 'LETTERNAME',
value: '电放保函'
}, {
fieldLabel: 'INPUTTIME',
hidden: true,
name: 'INPUTTIME'
}, {
fieldLabel: 'TO',
name: 'HEAD_TO'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'ATTN',
name: 'HEAD_ATTN'
}, {
fieldLabel: 'ATTN电话',
name: 'HEAD_ATTNTEL'
}, {
fieldLabel: 'ATTN传真',
name: 'HEAD_ATTNFAX'
}, { xtype: 'hiddenfield'}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'FROM',
name: 'INPUTBY'
}, {
fieldLabel: 'FROM电话',
name: 'HEAD_FMTEL'
}, {
fieldLabel: 'FROM传真',
name: 'HEAD_FMFAX'
}, {
fieldLabel: 'EMAIL',
name: 'HEAD_FMEMAIL'
}]
}
]//end items(fieldset 1)
}); //end this.formEdit
//#endregion
//#region 编辑formEdit 电放保函
this.formEdit = Ext.widget('form', {
region: 'north',
height: 460,
frame: true,
bodyPadding: 5,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [{
xtype: 'label',
html: '致:
对下述货物'
},{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'LE_ID',
hidden: true,
name: 'LE_ID'
} , {
fieldLabel: '船名航次',
name: 'VESSELVOYNO'
}
, {
fieldLabel: '提单号',
name: 'MBLNO'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '装货港',
name: 'PORTLOAD'
}, {
fieldLabel: '卸货港',
name: 'PORTDISCHARGE'
}]
}, {
xtype: 'label',
html: '我司申请贵司给予办理电报放货事项,收货人如下:'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '',
height: 90,
name: 'CONSIGNEE',
anchor: '100%'
}, {
xtype: 'label',
html: '担保条款(详见报表)
备注'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '',
height: 60,
name: 'REMARK',
anchor: '100%'
}
]//end items(fieldset 1)
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
this.panelpage = new Ext.Panel({
title: '电放保函详细信息',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formEdit]
});
Ext.apply(this, {
items: [this.panelBtn, this.formHead, this.panelpage]
});
//#endregion
//#region 其他
parentWin = window.parent.opener;
this.InitData();
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
this.MainEditRecord = ret[3];
}
if (this.opStatus == 'edit') {
condition = "LE_ID='" + this.editRecord.get('LE_ID') + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
//this.bodyDel = [];
this.opStatus = opstatus;
if (this.opStatus == 'add') {
this.formHead.getForm().reset();
this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.get('BSNO'));
this.formHead.getForm().findField('INPUTBY').setValue(SHOWNAME);
this.storeFM.load({ params: { condition: '' },
callback: function (r, options, success) {
if (success) {
if (this.storeFM.getCount() > 0) {
var Cargoinforecords = DsStoreQueryBy(this.storeFM, 'UserName', SHOWNAME);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
this.formHead.getForm().findField('HEAD_FMTEL').setValue(Cargoinfodata.Tel);
this.formHead.getForm().findField('HEAD_FMFAX').setValue(Cargoinfodata.Fax);
this.formHead.getForm().findField('HEAD_FMEMAIL').setValue(Cargoinfodata.Email);
} else {
}
}
}
},
scope: this
});
this.formEdit.getForm().reset();
this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.get('VESSEL') + ' ' + this.MainEditRecord.get('VOYNO'));
this.formEdit.getForm().findField('MBLNO').setValue(this.MainEditRecord.get('MBLNO') );
this.formEdit.getForm().findField('PORTLOAD').setValue(this.MainEditRecord.get('PORTLOAD'));
this.formEdit.getForm().findField('PORTDISCHARGE').setValue(this.MainEditRecord.get('PORTDISCHARGE'));
this.formEdit.getForm().findField('CONSIGNEE').setValue(this.MainEditRecord.get('CONSIGNEE'));
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpLetter/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
// this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpLetter/GetSurData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
this.LoadInit();
// this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}, // end LoadDate
//#endregion
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpLetter/SaveSur',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body)
},
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.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpLetter', returnData);
this.formEdit.getForm().findField('LE_ID').setValue(editp.get('LE_ID'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpLetter', 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';
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
//#endregion
//#region
LoadInit: function () {
var CUSTOMERNAME = this.MainEditRecord.get('CUSTOMERNAME');
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + CUSTOMERNAME + "')";
this.storeInfoClientContact.load({ params: { condition: s} });
var YARD = this.formEdit.getForm().findField('YARD').getValue();
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD + "')";
this.storeInfoClientContactYard.load({ params: { condition: s} });
var YARD2 = this.formEdit.getForm().findField('YARD2').getValue();
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD2 + "')";
this.storeInfoClientContactYard2.load({ params: { condition: s} });
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
var BSSTATUS = this.formHead.getForm().findField('BSSTATUSREF').getValue();
var inputby = this.formHead.getForm().findField('INPUTBY').getValue();
var op = this.formHead.getForm().findField('OP').getValue();
_this = this;
if (BSSTATUS == '锁定') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modOrderManagement" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', inputby);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
}
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
//#endregion
//#region 打印
Print: function () {
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('LE_ID').value;
var bsNo = basicForm.findField('BSNO').value;
if (billNo == '*' || billNo == '' || billNo == NaN) {
Ext.Msg.show({ title: '错误', msg: '电放保函还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var op = this.MainEditRecord.get('OP');
var MBLNO = this.MainEditRecord.get('MBLNO') + '电放保函';
var printType = 'MSOPLETTERSUR';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'";
var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_sur WHERE LE_ID = '" + billNo + "'";
var sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_seae WHERE BSNO = '" + bsNo + "'";
var sql4 = "SELECT [user].USERNAME,[user].CODENAME,[user].PASSWORD,[user].SHOWNAME,[user].ENROLLTIME,[user].CREATEUSER,[user].MODIFIEDUSER, [user].MODIFIEDTIME, [user].ISDELETED, [user].ISDISABLE, user_baseinfo.GID,user_baseinfo.USERID,user_baseinfo.COMPANYNAME, user_baseinfo.DEPTNAME, user_baseinfo.OFFICEPHONE, user_baseinfo.HOMEPHONE, user_baseinfo.MOBILE, user_baseinfo.FAX, user_baseinfo.EMAIL1, user_baseinfo.EMAIL2, user_baseinfo.HOMEADDRESS, user_baseinfo.REMARK, user_baseinfo.EMERGUSER, user_baseinfo.EMERGPHONE,user_baseinfo.EMERGEMAIL, user_baseinfo.POSTCODE, user_baseinfo.QQ, user_baseinfo.MSN, user_baseinfo.FINANCESOFTCODE FROM [user] INNER JOIN user_baseinfo ON [user].GID = user_baseinfo.USERID where [user].SHOWNAME='" + op + "' ";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, MBLNO, '', '', '', bsNo);
}
// #endregion
});