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/MsOpLetter/MsOpLetterTruckEdit.js

1203 lines
47 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
Shipping.MsOpLetterTruckEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpLetterTruckEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpLetterTruckEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
MainEditRecord: null,
oplb: '',
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' }
});
//客户加载_车队
this.storeTRUCKER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeTRUCKER.load({ params: { condition: "ISTRUCK='1'"} });
//车队
this.comboxTRUCKER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '车队',
store: this.storeTRUCKER,
name: 'HEAD_TO',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.formEdit.getForm().findField('TRUCK').setValue(combo.value);
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')";
this.storeInfoClientContact.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContact.getCount() > 0) {
var member = this.storeInfoClientContact.getAt(0);
this.comboxInfoClientContact.setValue(member.data.SHOWNAME);
this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(member.data.TEL);
this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(member.data.FAX);
} else {
this.comboxInfoClientContact.setValue('');
this.formHead.getForm().findField('HEAD_ATTNTEL').setValue('');
this.formHead.getForm().findField('HEAD_ATTNFAX').setValue('');
}
}
},
scope: this
});
}
}
}
});
//委托单位_联系人
this.storeInfoClientContact = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
this.comboxInfoClientContact = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'ATTN',
store: this.storeInfoClientContact,
name: 'HEAD_ATTN',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var Cargoinforecords = DsStoreQueryBy(this.storeInfoClientContact, 'GID', records[0].data.GID);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(Cargoinfodata.TEL);
this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(Cargoinfodata.FAX);
} else {
// this.formHead.getForm().findField('HEAD_ATTNTEL').setValue('');
// this.formHead.getForm().findField('HEAD_ATTNFAX').setValue('');
}
}
}
}
});
this.StoreTRUCKSTATUS = Ext.create('Ext.data.Store', {
fields: ['BLTYPE']
});
this.StoreTRUCKSTATUS.add({ "BLTYPE": "待派车" });
this.StoreTRUCKSTATUS.add({ "BLTYPE": "提交派车" });
this.StoreTRUCKSTATUS.add({ "BLTYPE": "已发单" });
this.StoreTRUCKSTATUS.add({ "BLTYPE": "已接单" });
this.StoreTRUCKSTATUS.add({ "BLTYPE": "已派车" });
this.StoreTRUCKSTATUS.add({ "BLTYPE": "派车中" });
this.comboxTRUCKSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '派车状态',
store: this.StoreTRUCKSTATUS,
forceSelection: true,
name: 'TRUCKSTATUS',
valueField: 'BLTYPE',
displayField: 'BLTYPE',
value: '待派车'
});
//#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: 'INPUTTIME',
hidden: true,
name: 'INPUTTIME'
}, {
fieldLabel: 'LETTERNAME',
hidden: true,
name: 'LETTERNAME',
value: '派车通知'
}, this.comboxTRUCKER]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxInfoClientContact, {
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
//客户加载_场站
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomYardRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomYardRefList' }
});
this.storeYARD.load({ params: { condition: "ISYARD='1'"} });
//船公司
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '提箱场站',
store: this.storeYARD,
// forceSelection: true,
name: 'YARD',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var data = combo.value;
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')";
this.storeInfoClientContactYard.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContactYard.getCount() > 0) {
var member = this.storeInfoClientContactYard.getAt(0);
this.comboxInfoClientContactYard.setValue(member.data.SHOWNAME);
this.formEdit.getForm().findField('YARDTEL').setValue(member.data.TEL);
} else {
this.comboxInfoClientContactYard.setValue('');
this.formEdit.getForm().findField('YARDTEL').setValue('');
}
}
},
scope: this
});
}
}
}
});
//委托单位_联系人
this.storeInfoClientContactYard = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
this.comboxInfoClientContactYard = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '联系人',
store: this.storeInfoClientContactYard,
name: 'YARDATTN',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.formEdit.getForm().findField('YARDTEL').setValue(records[0].data.TEL);
}
}
}
});
//客户加载_场站
this.storeYARD2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomYardRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomYardRefList' }
});
this.storeYARD2.load({ params: { condition: "ISYARD='1'"} });
//船公司
this.comboxYARD2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '入货场站',
store: this.storeYARD,
// forceSelection: true,
name: 'RETURNYARD',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var data = combo.value;
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')";
this.storeInfoClientContactYard2.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContactYard2.getCount() > 0) {
var member = this.storeInfoClientContactYard2.getAt(0);
this.comboxInfoClientContactYard2.setValue(member.data.SHOWNAME);
this.formEdit.getForm().findField('RETURNTEL').setValue(member.data.TEL);
} else {
this.comboxInfoClientContactYard2.setValue('');
this.formEdit.getForm().findField('RETURNTEL').setValue('');
}
}
},
scope: this
});
}
}
}
});
//委托单位_联系人
this.storeInfoClientContactYard2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
this.comboxInfoClientContactYard2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '联系人',
store: this.storeInfoClientContactYard,
name: 'RETURNATTN',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.formEdit.getForm().findField('RETURNTEL').setValue(records[0].data.TEL);
}
}
}
});
var companyname = '工厂';
if (this.oplb == "海运进口" || this.oplb == "空运进口") {
companyname = '卸货工厂'
}
//客户加载_工厂
this.storeFactry = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeFactry',
proxy: { url: '/MvcShipping/MsCodeFactry/GetDataList' }
});
this.storeFactry.load();
//工厂
this.comboxFactry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: companyname,
store: this.storeFactry,
name: 'FACTRYNAME',
valueField: 'FACTRYNAME',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var FACTRYADDR = this.formEdit.getForm().findField('FACTRYADDR');
FACTRYADDR.setValue(records[0].data.FACTRYADDR);
var FACTRYATTN = this.formEdit.getForm().findField('FACTRYATTN');
FACTRYATTN.setValue(records[0].data.FACTRYATTN);
var FACTRYTEL = this.formEdit.getForm().findField('FACTRYTEL');
FACTRYTEL.setValue(records[0].data.FACTRYTEL);
}
}
}
});
//#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: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'LE_ID',
hidden: true,
name: 'LE_ID'
}, {
fieldLabel: 'TRUCK',
hidden: true,
name: 'TRUCK'
}, {
fieldLabel: 'OTHERFEE',
hidden: true,
name: 'OTHERFEE'
}, {
fieldLabel: 'CUSTOMERNAME',
hidden: true,
name: 'CUSTOMERNAME'
}
, {
fieldLabel: '箱型箱量',
name: 'CTNS'
}
, {
fieldLabel: '陆运费',
xtype: 'numberfield',
name: 'TRUCKFEE',
value: 0
}
, {
fieldLabel: '支付方式',
name: 'PAYTYPE'
},{
fieldLabel: '派车日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'TRUCKDATE'
}
]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxYARD, this.comboxInfoClientContactYard, {
fieldLabel: '电话',
name: 'YARDTEL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxFactry]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '工厂地址',
name: 'FACTRYADDR'
}, {
fieldLabel: '要求到达时间', labelWidth: 80,
name: 'FACTRYTIME'
}]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '工厂联系人',
name: 'FACTRYATTN'
}, {
fieldLabel: '联系方式',
name: 'FACTRYTEL'
}, {
fieldLabel: '返场时间',
name: 'RETRUNYARDTIME'
}]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxYARD2, this.comboxInfoClientContactYard2, {
fieldLabel: '电话',
name: 'RETURNTEL'
}]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '截港日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datetimefield',
name: 'CLOSINGDATE'
}, {
fieldLabel: '提货日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'CARGODATE'
}, this.comboxTRUCKSTATUS]
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '注意事项',
height: 60,
name: 'TRUCKDETAIL',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '备注',
height: 300,
name: 'REMARK',
anchor: '100%'
}, {
xtype: 'textfield', hidden: true,
fieldLabel: '件数',
name: 'PKGS',
anchor: '100%'
}, {
xtype: 'textfield', hidden: true,
fieldLabel: '重量',
name: 'KGS',
anchor: '100%'
}, {
xtype: 'textfield', hidden: true,
fieldLabel: '尺码',
name: 'CBM',
anchor: '100%'
}
]//end items(fieldset 1)
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: '集运派车',
handler: function (button, event) {
this.SavePC();
},
scope: this
}, {
text: '散货派车',
handler: function (button, event) {
this.SavePC_SH();
},
scope: this
}]
});
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: "刷新委托信息",
handler: function (button, event) {
this.LoadinitData();
},
scope: this
}, '-',
{
text: "生成派车单", menu: menu1, 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];
this.oplb = ret[4];
}
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('HEAD_TO').setValue(this.MainEditRecord.get('TRUCKER'));
this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.get('BSNO'));
var trucker = this.MainEditRecord.get('TRUCKER');
if (trucker != '') {
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + trucker + "')";
this.storeInfoClientContact.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContact.getCount() > 0) {
var member = this.storeInfoClientContact.getAt(0);
this.comboxInfoClientContact.setValue(member.data.SHOWNAME);
this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(member.data.TEL);
this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(member.data.FAX);
}
}
},
scope: this
});
}
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();
var yard = this.MainEditRecord.get('YARD');
this.formEdit.getForm().findField('CTNS').setValue(this.MainEditRecord.get('CNTRTOTAL'));
this.formEdit.getForm().findField('YARD').setValue(yard);
this.formEdit.getForm().findField('RETURNYARD').setValue(yard);
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr);
if (yard != '') {
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + yard + "')";
this.storeInfoClientContactYard2.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContactYard2.getCount() > 0) {
var member = this.storeInfoClientContactYard2.getAt(0);
this.formEdit.getForm().findField('YARDATTN').setValue(member.data.SHOWNAME);
this.formEdit.getForm().findField('YARDTEL').setValue(member.data.TEL);
this.formEdit.getForm().findField('RETURNATTN').setValue(member.data.SHOWNAME);
this.formEdit.getForm().findField('RETURNTEL').setValue(member.data.TEL);
} else {
this.formEdit.getForm().findField('YARDATTN').setValue('');
this.formEdit.getForm().findField('YARDTEL').setValue('');
this.formEdit.getForm().findField('RETURNATTN').setValue('');
this.formEdit.getForm().findField('RETURNTEL').setValue('');
}
}
},
scope: this
});
}
this.formEdit.getForm().findField('REMARK').setValue('');
} 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.formEdit.getForm().findField('CUSTOMERNAME').setValue(this.MainEditRecord.get('CUSTOMERNAME'));
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpLetter/GetTruckData',
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
});
}
//20160219 获取业务主表内的件数重量尺码,用于在生成散货派车单时传递
//this.formEdit.getForm().findField('PKGS').setValue(this.MainEditRecord.get('PKGS'));
//this.formEdit.getForm().findField('KGS').setValue(this.MainEditRecord.get('KGS'));
//this.formEdit.getForm().findField('CBM').setValue(this.MainEditRecord.get('CBM'));
}, // 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/SaveTruck',
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', '');
}
this.GetEditStatus();
} 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
SavePC: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var url = '/MvcShipping/MsOpLetter/SavePC';
if (this.oplb == '空运出口' || this.oplb == '空运出口') {
url = '/MvcShipping/MsOpLetter/SaveAirPC';
}
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
if (TRUCKSTATUS != "待派车") {
Ext.Msg.show({ title: '警告', msg: '只有在待派车状态才允许生成派车单 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
_this = this;
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bs = this.MainEditRecord.data;
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: url,
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body),
bs: Ext.JSON.encode(bs),
oplb: _this.oplb
},
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();
}
this.opStatus = 'edit';
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 });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
SavePC_SH: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var url = '/MvcShipping/MsOpLetter/SavePC_SH';
if (this.oplb == '空运出口' || this.oplb == '空运出口') {
url = '/MvcShipping/MsOpLetter/SaveAirPC_SH';
}
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
if (TRUCKSTATUS != "待派车") {
Ext.Msg.show({ title: '警告', msg: '只有在待派车状态才允许生成派车单 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
_this = this;
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bs = this.MainEditRecord.data;
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: url,
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body),
bs: Ext.JSON.encode(bs),
oplb: _this.oplb
},
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();
}
this.opStatus = 'edit';
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 });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
//#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('RETURNYARD').getValue();
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD2 + "')";
this.storeInfoClientContactYard2.load({ params: { condition: s} });
},
LoadinitData: function () {
var yard = this.MainEditRecord.get('YARD');
this.formEdit.getForm().findField('CTNS').setValue(this.MainEditRecord.get('CNTRTOTAL'));
this.formEdit.getForm().findField('YARD').setValue(yard);
this.formEdit.getForm().findField('RETURNYARD').setValue(yard);
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr);
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
var inputby = this.formHead.getForm().findField('INPUTBY').getValue();
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
if (TRUCKSTATUS != '待派车') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.setSaveBtnStatus(true);
}
_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 = 'MSOPLETTERTRUCK';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'";
var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_truck WHERE LE_ID = '" + billNo + "'";
var sql3 = "";
if (this.oplb == "海运进口")
sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_seai WHERE BSNO = '" + bsNo + "'";
else if (this.oplb == "空运进口")
sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_airi WHERE BSNO = '" + bsNo + "'";
else if (this.oplb == "空运出口")
sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_aire WHERE BSNO = '" + bsNo + "'";
else
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
});