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/MsOpSeaeRunBill/MsOpseaeRunBillEdit.js

703 lines
25 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpSeaeRunBillEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpSeaeRunBillEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpSeaeRunBillEdit, Ext.Panel, {
initUIComponents: function () {
this._labelWidth = 80;
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnSave',
text: Zi.LAN.Save, //"保存",
iconCls: "btnsave",
handler: function (button, event) {
this.saveData(0);
},
scope: this
}, {
id: 'btnDispatch',
text: Zi.LAN.Dispatch, //"派单",
handler: function (button, event) {
this.saveData(1);
},
scope: this
}, {
id: 'btnDispatchChange',
text: Zi.LAN.DispatchChange, //"转单",
handler: function (button, event) {
this.dispatchChange();
},
scope: this
}, {
text: Zi.LAN.Print, //"打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}, {
id: 'btnCancelDispatch',
text:'撤销'+Zi.LAN.Dispatch, //"派单",
handler: function (button, event) {
this.saveData(2);
},
scope: this
}, {
id: 'btnCancelDispatchChange',
text: '撤销' + Zi.LAN.DispatchChange, //"转单",
handler: function (button, event) {
this.CanceldispatchChange();
},
scope: this
}]
});
//#endregion
//客户加载_客户名称
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' }
});
this.storeCustCode.load();
//客户名称
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.CUSTOMERNAME, //'客户名称',
store: this.storeCustCode,
forceSelection: true,
queryMode: 'remote',
minChars: 0,
labelWidth: this._labelWidth,
flex: 1,
queryParam: 'CODENAME',
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
allowBlank: false,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var data = combo.value;
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsOpSeaeRunBill/GetCustomerInfo',
params: {
shortName: data
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
this.formHead.getForm().findField('ADDR').setValue(result.ADDR);
this.formHead.getForm().findField('CHIEF').setValue(result.CHIEF);
this.formHead.getForm().findField('TEL').setValue(result.TEL);
} else {
}
},
scope: this
});
}
}
}
});
//客户加载_船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
this.storeCARRIER.load();
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司', //'船公司',
store: this.storeCARRIER,
// forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//客户加载_订舱代理
this.storeFORWARDER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListFORWARDER' }
});
this.storeFORWARDER.load();
//船公司
this.comboxFORWARDER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '订舱代理', //'订舱代理',
store: this.storeFORWARDER,
// forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'FORWARDER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//跑单事由加载
this.storeRunReason = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeRunReason.load({ params: { enumTypeId: 92001 } });
//跑单事由
this.comboxRunReason = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.RunReason, //'跑单事由',
labelWidth: this._labelWidth,
store: this.storeRunReason,
name: 'REASON',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
}
}
},
allowBlank: false
});
//跑单人
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' }
});
this.storeOpCode.load();
this.comboxRunBillPerson = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.RunBillPerson, //'跑单人',
labelWidth: this._labelWidth,
store: this.storeOpCode,
name: 'USERNAME',
width: 80,
valueField: 'UserName',
displayField: 'CodeAndName',
allowBlank: false,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var userGID = records[0].data.GID;
this.formHead.getForm().findField('USERID').setValue(userGID);
debugger;
}
}
}
});
this.storeTF = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTF.load({ params: { enumTypeId: 0 } });
this.comboxSFDJ = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: Zi.LAN.SFDJ,//'有无随附单据',
labelWidth: this._labelWidth,
allowBlank: false,
forceSelection: true,
store: this.storeTF,
name: 'SFDJ'
});
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
title: Zi.LAN.RunBillBasicInfo,
region: 'center',
frame: true,
flex: 1,
bodyPadding: 5,
collapsed: false,
collapsible: false,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: this._labelWidth,
msgTarget: 'qtip'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: 'GID', //'GID',
name: 'GID',
hidden: true
}, {
fieldLabel: 'USERID', //'USERID',
name: 'USERID',
hidden: true
}, {
fieldLabel: 'STATUS', //'STATUS',
name: 'STATUS',
hidden: true
},
{
fieldLabel: Zi.LAN.BillNO, //'跑单编号'
flex: 2,
name: 'BillNO'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCustCode
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: Zi.LAN.CustomerAddr, //'客户地址'
flex: 2,
name: 'ADDR'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: Zi.LAN.CustomerContact, //'联系人'
flex: 1,
name: 'CHIEF'
}, {
fieldLabel: Zi.LAN.CustomerTel, //'联系电话'
flex: 1,
name: 'TEL'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: Zi.LAN.RunBillTime, //'跑单时间',
format: 'Y-m-d',
flex: 1,
xtype: 'datetimefield',
name: 'RUNTIME',
listeners: {
scope: this,
'select': function(combo, mdate) {
var mydate = new Date(mdate);
var mydatestr = Ext.util.Format.date(mydate, 'Y-m-d H:00:00');
combo.setValue(mydatestr);
}
},
allowBlank: false
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: Zi.LAN.CompleteTime, //'完成时间'
format: 'Y-m-d',
flex: 1,
xtype: 'datetimefield',
name: 'COMPLETETIME',
listeners: {
scope: this,
'select': function(combo, mdate) {
var mydate = new Date(mdate);
var mydatestr = Ext.util.Format.date(mydate, 'Y-m-d H:00:00');
combo.setValue(mydatestr);
}
},
allowBlank: true
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxRunBillPerson
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: Zi.LAN.REASONSFDJ, //'跑单事由'
xtype: 'textareafield',
flex: 1,
height: 40,
name: 'REASON'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
//{
// xtype: "checkbox", //checkbox控件
// id: "cbSFDJ",
// name:"SFDJ",
// fieldLabel: Zi.LAN.SFDJ,
// inputValue: "true", //选中的值
// uncheckedValue: "false", //未选中的值
// checked: false //绘制时的选中状态
//}
this.comboxSFDJ
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCARRIER, this.comboxFORWARDER
]
}]
});
//#endregion
this.panelBillItems = new Ext.Panel({
title: Zi.LAN.RunBillBasicInfo,
layout: "border",
region: 'center',
frame: false,
items: []
});
//列表
this.listcolumns = [{
id: '',
dataIndex: 'MBLNO',
header: Zi.LAN.MBLNO, //'主提单号',
width: 120,
filter: {
type: 'string',
dataIndex: 'MBLNO'
}
},
{
id: '',
dataIndex: 'CUSTOMERNAME',
header: Zi.LAN.CUSTOMERNAME, //'委托单位',
width: 120,
filter: {
type: 'string',
dataIndex: 'CUSTOMERNAME'
}
},
{
id: '',
dataIndex: 'VESSEL',
header: Zi.LAN.VESSEL, //'船名',
width: 100,
filter: true
},
{
id: '',
dataIndex: 'VOYNO',
header: Zi.LAN.VOYNO, //'航次',
width: 60,
filter: true
}];
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsOpSeaeModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSeaeRunBill/GetOpseadList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
}
},
autoLoad: { params: { strBSNO: strBSNO } }
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'south',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
height: 240,
columns: this.listcolumns
});
Ext.apply(this, {
items: [this.panelBtn, this.formHead, this.gridList]
});
if (bill != null) {
this.formHead.getForm().reset();
if (bill.SFDJ == true) { bill.SFDJ = "1"; }
if (bill.SFDJ == false) { bill.SFDJ = "0"; }
this.formHead.getForm().setValues(bill);
if (this.formHead.getForm().findField("STATUS").getValue() != 'Create') {
Ext.getCmp('btnSave').disable();
Ext.getCmp('btnDispatch').disable();
}
if (this.formHead.getForm().findField("STATUS").getValue() == 'Dispatch') {
Ext.getCmp('btnCancelDispatch').enable();
Ext.getCmp('btnCancelDispatchChange').disable();
} else {
Ext.getCmp('btnCancelDispatch').disable();
Ext.getCmp('btnCancelDispatchChange').enable();
}
} else {
//Ext.getCmp('btnDispatchChange').disable();
}
//#endregion
}, //end initUIComponents
saveData: function (isDispatch) {
var basicForm = this.formHead.getForm();
if (!basicForm.isValid()) {
Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingJianchaBiTianXiangMu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var fieldSta = basicForm.findField('STATUS');
if (isDispatch==1) {
fieldSta.setValue('Dispatch');
} else if (isDispatch == 2) {
fieldSta.setValue('Create');
}
else if (fieldSta.getValue() == null || fieldSta.getValue().length == 0) {
fieldSta.setValue('Create');
};
var data = basicForm.getValues(false, false, false);
if (data.SFDJ == "1") { data.SFDJ = true }
if (data.SFDJ == "0") { data.SFDJ = false }
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/MvcShipping/MsOpSeaeRunBill/Save',
scope: this,
params: {
data: Ext.JSON.encode(data),
strBSNO: strBSNO
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
if (returnData.SFDJ == true) { returnData.SFDJ = "1"; }
if (returnData.SFDJ == false) { returnData.SFDJ = "0"; }
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
if (isDispatch) {
Ext.getCmp('btnSave').disable();
Ext.getCmp('btnDispatch').disable();
Ext.getCmp('btnCancelDispatch').enable();
Ext.getCmp('btnCancelDispatchChange').enable();
}
} else {
Ext.Msg.show({ title: Zi.LAN.ChuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: Zi.LAN.JingGao, msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
});
},
dispatchChange: function () {
var _this = this;
var selRunBillPerson = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.RunBillPerson, //'跑单人',
store: this.storeOpCode,
id: 'disChgPerson',
name: 'USERNAME',
width: 280,
valueField: 'UserName',
displayField: 'CodeAndName',
allowBlank: false,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var userGID = records[0].data.GID;
Ext.getCmp('disChgUserId').setValue(userGID);
}
}
}
});
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 20,
frame: true,
autoScroll: false,
border: false,
fileUpload: true,
items: [{
xtype: 'hiddenfield',
name: 'USERID',
id: 'disChgUserId'
}, selRunBillPerson],
buttons: [{
text: Zi.LAN.DispatchChange, //'转单',
type: 'submit',
handler: function () {
var disChgUserId = Ext.getCmp('disChgUserId').getValue();
var disChgUserName = Ext.getCmp('disChgPerson').getValue();
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsOpSeaeRunBill/ChangeDispatch',
params: {
strGID: bill.GID, userid: disChgUserId, username: disChgUserName
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success) {
returnData = result.Data
if (returnData.SFDJ == true) { returnData.SFDJ = "1";}
if (returnData.SFDJ == false) { returnData.SFDJ = "0";}
_this.formHead.getForm().reset();
_this.formHead.getForm().setValues(returnData);
Ext.Msg.show({ title: Zi.LAN.TiShi, msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
} else {
Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: result.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
win.close(this);
},
scope: this
});
}
}, {
text: Zi.LAN.GuanBi, //'关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: Zi.LAN.DispatchChange, //"转单",
width: 380,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
},
CanceldispatchChange: function () {
var _this = this;
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsOpSeaeRunBill/CancelChangeDispatch',
params: {
strGID: bill.GID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success) {
returnData = result.Data
if (returnData.SFDJ == true) { returnData.SFDJ = "1"; }
if (returnData.SFDJ == false) { returnData.SFDJ = "0"; }
_this.formHead.getForm().reset();
_this.formHead.getForm().setValues(returnData);
Ext.Msg.show({ title: Zi.LAN.TiShi, msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
} else {
Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: result.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
win.close(this);
},
scope: this
});
},
Print: function () {
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('GID').value;
var printType = 'MSOPSEAERUNBILL';
var sql1 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill where gid='" + billNo + "'";
var sql2 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill_item where parentid='" + billNo + "'";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, billNo);
}
});