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/MsOpLetterTruckLSEdit.js

1895 lines
74 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpLetterTruckLSEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpLetterTruckLSEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpLetterTruckLSEdit, 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;
var mainform = window.parent.panelEdit;
this.MainEditRecord = mainform.editRecord;
this.BsNo = this.MainEditRecord.get('BSNO');
this.oplb = mainform.stroplb;
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
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,
readOnly:true,
name: 'TRUCKSTATUS',
valueField: 'BLTYPE',
displayField: 'BLTYPE',
value: '待派车'
});
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpLetterTruck',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpLetter/GetTruckList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'LE_ID',
header: 'LE_ID',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'TRUCK',
header: '车队',
width: 120
}, {
sortable: true,
dataIndex: 'CTNS',
header: '集装箱',
width: 120
}, {
sortable: true,
dataIndex: 'FACTRYNAME',
header: '工厂',
width: 120
}, {
sortable: true,
dataIndex: 'INPUTBYREF',
header: '录入人',
width: 80
}, {
sortable: true,
dataIndex: 'INPUTTIME',
header: '录入日期',
width: 80
}
];
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'west',
width: 300,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
_this = this;
this.gridList.addListener('itemclick', function (dataview, record, item, index, e, b) {
_this.editRecord = record;
_this.OpStatus = 'edit';
_this.LoadData("edit", "LE_ID='" + record.data.LE_ID + "'");
}, this);
this.storeList.on('beforeload', function (store) {
var sql = "t.BSNO='" + this.BsNo + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//#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'"} });
//船公司
var yardname = '提箱场站';
if (this.oplb == "海运进口" || this.oplb == "空运进口") {
yardname = '提箱码头'
}
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: yardname,
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);
}
}
}
});
Ext.define('MsOpSeaeDetail', {
extend: 'Ext.data.Model',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'CTN_ID', type: 'string' },
{ name: 'CTNNUM', type: 'number' },
{ name: 'KGS', type: 'number' },
{ name: 'CTNALL', type: 'string' }
]
});
this.storeCtnList = Ext.create('Ext.data.Store', {
model: 'MsOpSeaeDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpLetter/GetLetterCtnList',
reader: {
id: 'CTN_ID',
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', {
//fieldLabel: Zi.LAN.CTNALL, //'箱型',
store: this.storeCodeCtn,
forceSelection: true,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN'
});
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListCtn = new Ext.grid.GridPanel({
store: this.storeCtnList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [
{
text: '增加明细', //'增加明细',
tooltip: '增加明细', //'增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetail();
},
scope: this
}, '-', {
text: '删除明细', //'删除明细',
tooltip: '删除明细', //'删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.deleteDetail();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'CTN_ID',
header: '编号',
hidden: true,
width: 0
}, {
dataIndex: 'CTNALL',
header: '箱型', //'箱型',
width: 125,
editor: this.comboxCTNALL
}, {
dataIndex: 'CTNNUM',
header: '箱量', //'箱量',
width: 100,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
}, {
dataIndex: 'KGS',
header: '重量', //'重量',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}]
});
this.storeCtnList.on('beforeload', function (store) {
var billNo = this.formEdit.getForm().findField('LE_ID').getValue();
var condition = "LE_ID='" + billNo + "'";
Ext.apply(store.proxy.extraParams, { condition: condition });
}, this);
this.panelBodyCtn = new Ext.Panel({
// title: '集装箱信息', //'集装箱信息',
layout: "border",
height: 120,
flex: 1,
margin: '5 20',
frame: true,
items: [this.gridListCtn]
});
//#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: '业务编号',
name: 'BSNO', hidden: true
}, {
fieldLabel: 'LE_ID',
hidden: true,
name: 'LE_ID'
}, {
fieldLabel: 'TRUCK',
hidden: true,
name: 'TRUCK'
}, {
fieldLabel: 'OTHERFEE',
hidden: true,
name: 'OTHERFEE'
}, {
fieldLabel: 'ISFEE',
hidden: true,
name: 'ISFEE'
}, {
fieldLabel: 'CUSTOMERNAME',
hidden: true,
name: 'CUSTOMERNAME'
}, {
fieldLabel: 'MBLNO',
hidden: true,
name: 'MBLNO'
}
, {
fieldLabel: '箱型箱量',
readOnly:true,
name: 'CTNS'
}, {
fieldLabel: '吨数',
name: 'KGS'
}
, {
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: [{
xtype: 'textareafield',
grow: true,
flex: 2,
fieldLabel: '工厂地址',
height: 60,
name: 'FACTRYADDR',
anchor: '100%'
}, {
fieldLabel: '要求到达时间', labelWidth: 80,
format: 'Y-m-d',
flex: 1,
xtype: 'datetimefield',
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: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.panelBodyCtn,{
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
flex: 1,
fieldLabel: '注意事项',
height: 60,
name: 'TRUCKDETAIL',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '备注',
height: 60,
name: 'REMARK',
anchor: '100%'
}]
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '调度',
readOnly:true,
name: 'DDOP'
}, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' } ]
}, {
xtype: 'textfield', hidden: true,
fieldLabel: '件数',
name: 'PKGS',
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: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
},
scope: this
}, {
text: "复制新建",
handler: function (button, event) {
this.opStatus = 'add';
for (var j = 0; j < this.storeCtnList.getCount(); j += 1) {
var memberbody = this.storeCtnList.getAt(j);
memberbody.set("CTN_ID", NewGuid());
memberbody.set("LE_ID", '*');
memberbody.commit();
};
},
scope: this
}, '-', {
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, {
text: "刷新委托信息",
handler: function (button, event) {
this.LoadinitData();
},
scope: this
}, '-',
{
text: "生成派车单",id:'btncreatetruck', menu: menu1, scope: this
}, {
text: "提交派车",
handler: function (button, event) {
this.SubmitPc();
},
scope: this
}, {
text: "撤销提交",
handler: function (button, event) {
this.CancelSubmitPc();
},
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]
});
this.paneltruckdetail = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formHead, this.panelpage]
});
Ext.apply(this, {
items: [this.panelBtn, this.gridList, this.paneltruckdetail]
});
//#endregion
//#region 其他
parentWin = window.parent.opener;
this.InitData();
var btncreatetruck = Ext.getCmp('btncreatetruck');
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsSysParamSet/GetData',
params: {
condition: "PARAMNAME='NOOPTRUCK'"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
} else {
var data = result.data;
if (data.PARAMVALUE == '1') {
btncreatetruck.disable();
} else {
}
}
} else {
}
},
scope: this
});
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
this.storeList.load({ params: { condition: "t.BSNO='" + this.BsNo + "'" },
callback: function (r, options, success) {
if (success) {
if (this.storeList.getCount() > 0) {
var member = this.storeList.getAt(0);
_this.LoadData("edit", "LE_ID='" + member.data.LE_ID + "'");
} else {
_this.LoadData('add', '');
}
}
},
scope: this
});
}, //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.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsOpSeaeDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSeae/GetBodyListSum',
reader: {
id: 'BSNO,CTNCODE,CTN_ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeCtnList.removeAll();
this.storeBodyList.load({
params: { condition: "BSNO='" + this.BsNo + "'" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
for (var j = 0; j < _this.storeBodyList.getCount(); j += 1) {
var memberbody = _this.storeBodyList.getAt(j);
var kgs = memberbody.data.KGS;
kgs = Div(kgs, 1000);
var record = Ext.create('MsOpSeaeDetail', {
CTN_ID: NewGuid(),
LE_ID: '*',
CTNALL: memberbody.data.CTNALL,
CTNNUM: memberbody.data.CTNNUM,
KGS: kgs
});
_this.storeCtnList.add(record);
};
}
}
}
});
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);
this.formEdit.getForm().findField('TRUCKSTATUS').setValue('待派车');
this.GetEditStatus();
var kgs = this.MainEditRecord.get('KGS');
kgs = Div(kgs, 1000);
this.formEdit.getForm().findField('KGS').setValue(kgs);
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr);
this.formEdit.getForm().findField('CLOSINGDATE').setValue(this.MainEditRecord.get('CLOSINGDATE'));
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.storeInfoClientContactYard.load({ params: { condition: s} });
}
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'));
var yard = this.formEdit.getForm().findField('RETURNYARD').getValue();
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) {
}
},
scope: this
});
}
this.storeCtnList.load({ params: { condition: "LE_ID='" + data.LE_ID + "'" } });
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);
if (opstatus == 'add') this.formEdit.getForm().findField('TRUCKSTATUS').setValue('待派车');
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
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 kgs = this.MainEditRecord.get('KGS');
kgs = Div(kgs, 1000);
this.formEdit.getForm().findField('KGS').setValue(kgs);
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr);
this.formEdit.getForm().findField('CLOSINGDATE').setValue(this.MainEditRecord.get('CLOSINGDATE'));
},
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
this.setAllTotal();
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bodydatas = [];
for (var i = 0; i < this.storeCtnList.getCount(); i += 1) {
var member = this.storeCtnList.getAt(i);
bodydatas.push(member);
}
var jsonBodyCtn = ConvertRecordsToJsonAll(bodydatas);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpLetter/SaveBLTruck',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body),
ctn: jsonBodyCtn
},
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().reset();
this.formEdit.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpLetterTruck', returnData);
this.formHead.getForm().findField('LE_ID').setValue(editp.get('LE_ID'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpLetterTruck', 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();
}
var LE_ID = this.formHead.getForm().findField('LE_ID').getValue();
for (var j = 0; j < this.storeCtnList.getCount(); j += 1) {
var memberbody = this.storeCtnList.getAt(j);
memberbody.set("LE_ID", LE_ID);
memberbody.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 保存
SubmitPc: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
if (TRUCKSTATUS != '待派车') {
Ext.Msg.show({ title: '提示', msg: '当前状态,不允许提交派车!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.setAllTotal();
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bodydatas = [];
for (var i = 0; i < this.storeCtnList.getCount(); i += 1) {
var member = this.storeCtnList.getAt(i);
bodydatas.push(member);
}
var jsonBodyCtn = ConvertRecordsToJsonAll(bodydatas);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpLetter/SubmitPcBLTruck',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body),
ctn: jsonBodyCtn
},
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().reset();
this.formEdit.getForm().setValues(returnData);
this.GetEditStatus();
//
if (this.opStatus == 'add') {
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpLetterTruck', returnData);
this.formHead.getForm().findField('LE_ID').setValue(editp.get('LE_ID'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpLetterTruck', returnData);
}
this.opStatus = 'edit';
var LE_ID = this.formHead.getForm().findField('LE_ID').getValue();
for (var j = 0; j < this.storeCtnList.getCount(); j += 1) {
var memberbody = this.storeCtnList.getAt(j);
memberbody.set("LE_ID", LE_ID);
memberbody.commit();
};
} 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
CancelSubmitPc: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
if (TRUCKSTATUS != '提交派车') {
Ext.Msg.show({ title: '提示', msg: '当前状态,不允许撤销提交派车!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.setAllTotal();
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bodydatas = [];
for (var i = 0; i < this.storeCtnList.getCount(); i += 1) {
var member = this.storeCtnList.getAt(i);
bodydatas.push(member);
}
var jsonBodyCtn = ConvertRecordsToJsonAll(bodydatas);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpLetter/CancelSubmitPcBLTruck',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: Ext.JSON.encode(body),
ctn: jsonBodyCtn
},
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().reset();
this.formEdit.getForm().setValues(returnData);
this.GetEditStatus();
//
if (this.opStatus == 'add') {
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpLetterTruck', returnData);
this.formHead.getForm().findField('LE_ID').setValue(editp.get('LE_ID'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpLetterTruck', returnData);
}
this.opStatus = 'edit';
var LE_ID = this.formHead.getForm().findField('LE_ID').getValue();
for (var j = 0; j < this.storeCtnList.getCount(); j += 1) {
var memberbody = this.storeCtnList.getAt(j);
memberbody.set("LE_ID", LE_ID);
memberbody.commit();
};
} 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
onDeleteClick: function (button, event) {
var selections = this.gridList.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 TRUCKSTATUS = record.data.TRUCKSTATUS;
if (TRUCKSTATUS != '待派车') {
Ext.Msg.show({ title: '提示', msg: '当前状态,不允许删除派车!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//if (this.StoreOpRange.getCount() == 0) {
// Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
// return;
//} else {
// var inputby = record.data.INPUTBY;
// var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', inputby);
// if (records.getCount() > 0) {
// } else {
// canedit = false;
// Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
// return;
// }
//}
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpLetter/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
if (this.storeList.getCount() > 0) {
var member = this.storeList.getAt(0);
this.LoadData("edit", "AS_ID='" + member.data.AS_ID + "'");
this.editRecord = member;
} else {
this.LoadData('add', '');
}
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);
},
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;
}
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
var bs = this.MainEditRecord.data;
_this = this;
//
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.formEdit.getForm().reset();
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
// var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpLetter', returnData);
this.formHead.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;
}
var data = this.formHead.getForm().getValues(false, false, false);
var body = this.formEdit.getForm().getValues(false, false, false);
_this = this;
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
addDetail: function () {
var record = Ext.create('MsOpSeaeDetail', {
CTN_ID: NewGuid(),
LE_ID: '*',
CTNALL: '',
CTNNUM: 1,
KGS: 0
});
this.storeCtnList.add(record);
var n = this.storeCtnList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
deleteDetail: function () {
var selectedRecords = this.gridListCtn.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.LE_ID == "" || rec.data.LE_ID == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeCtnList.remove(selectedRecords[i]);
this.setAllTotal();
}
else {
Ext.MessageBox.confirm('提示','确定要删除此记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在操作数据');
Ext.Ajax.request({
waitMsg: '正在操作数据', //'正在删除数据...',
url: '/MvcShipping/MsOpLetter/DeleteLetterCtn',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeCtnList.remove(rec);
this.setAllTotal();
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 });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//this.storeBodyList.remove(selectedRecords[i]);
}
},
setAllTotal: function () {
var cntrstr = '';
var kgs = 0;
for (var j = 0; j < _this.storeCtnList.getCount(); j += 1) {
var memberbody = _this.storeCtnList.getAt(j);
if (cntrstr == '')
cntrstr = memberbody.data.CTNALL + '*' + memberbody.data.CTNNUM;
else
cntrstr = cntrstr + ' ' + memberbody.data.CTNALL + '*' + memberbody.data.CTNNUM;
kgs = Add(kgs, memberbody.data.KGS);
}
this.formEdit.getForm().findField('CTNS').setValue(cntrstr);
this.formEdit.getForm().findField('KGS').setValue(kgs);
},
//#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} });
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue();
_this = this;
if (TRUCKSTATUS != '待派车') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.setSaveBtnStatus(true);
//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 btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndNew.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';
if (this.oplb == "海运进口") {
printType = 'MSOPLETTERTRUCKSEAI'
} else if (this.oplb == "空运进口") {
printType = 'MSOPLETTERTRUCKAIRI'
} else if (this.oplb == "空运出口") {
printType = 'MSOPLETTERTRUCKAIRE'
}
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
});