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.

705 lines
25 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpCtnBsCardDetailEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnBsCardDetailEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnBsCardDetailEdit, 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.PGID = this.MainEditRecord.get('GID');
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 空返
this.storeCodeDisportPORTLOAD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
autoLoad: true,
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.storeCodeDisportDESTPORT = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
autoLoad: true,
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
//客户加载_船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
//this.storeICARRIER.load({ params: { condition: "ISCARRIER='1'"} });
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeDisportPORTLOAD,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'I_PORTLOAD',
valueField: 'PORT',
displayField: 'PORT'
});
this.comboxDESTPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisportDESTPORT,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'I_DESTPORT',
valueField: 'PORT',
displayField: 'PORT'
});
//客户加载_场站
this.store_PORTLOAD_STATOIN = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
//this.store_PORTLOAD_STATOIN.load({ params: { condition: "ISYARD='1'"} });
//场站
this.comboxPORTLOAD_STATOIN = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港场站',
store: this.store_PORTLOAD_STATOIN,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'PORTLOAD_STATOIN',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeDESTPORT_STATOIN = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
//this.storeI_DESTPORT_STATOIN.load({ params: { condition: "ISYARD='1'"} });
//场站
this.comboxDESTPORT_STATOIN = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港场站',
store: this.storeDESTPORT_STATOIN,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'DESTPORT_STATOIN',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeCONTRACT = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListAgent' }
});
//this.storeI_CONTRACT.load({ params: { condition: "ISAGENT='1'"} });
this.comboxCONTRACT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '运费约价',
store: this.storeCONTRACT,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'CONTRACT',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeCUSTOMER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' }
});
this.comboxCUSTOMER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '空返委托单位',
store: this.storeCUSTOMER,
//forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'CUSTNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
_this = this;
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
height: 115,
// title: '空返信息',
bodyPadding: 5,
// autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 100,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '空返委托编号',
name: 'CUSTNO'
}, {
fieldLabel: '空返提单号',
name: 'MBLNO'
}, this.comboxCUSTOMER, this.comboxCARRIER, this.comboxCONTRACT, { xtype: 'hiddenfield' }]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '起运港提箱日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'PORTLOAD_CNT_TIME'
}, this.comboxPORTLOAD, {
fieldLabel: '空返开船日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'ETD'
}, this.comboxDESTPORT, {
fieldLabel: '预计开船日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'PREETD'
}, {
fieldLabel: '预抵日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'PREETA'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '空返到港日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'ETA'
}, this.comboxDESTPORT_STATOIN, {
fieldLabel: '目的港提箱日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'DEST_CNT_TIME'
}, {
fieldLabel: '目的港还箱日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'DEST_RTCNT_TIME'
}, {
fieldLabel: '清洗日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'CLEARNTIME'
}, {
fieldLabel: '是否目的港清洗',
inputValue: true,
xtype: 'checkboxfield',
//flex: 0.5,
name: 'IS_POD_CLEAN'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //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: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
},
scope: this
}, '-', {
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
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.gridList, this.panelpage]
});
//#endregion
//#region 其他
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
this.storeList.load({
params: { condition: "B.PGID='" + this.PGID + "'" },
callback: function (r, options, success) {
if (success) {
if (this.storeList.getCount() > 0) {
var member = this.storeList.getAt(0);
_this.LoadData("edit", "GID='" + member.data.GID + "'");
} 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.formEdit.getForm().reset();
this.formEdit.getForm().findField('PGID').setValue(this.MainEditRecord.get('GID'));
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcContainer/MsOpCtnBsCard/GetRtData',
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.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.formEdit.getForm().getValues(false, false, false);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsOpCtnBsCard/SaveRt',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
var editp = Ext.create('MsOpCtnBsCardDetail', returnData);
this.formEdit.getForm().findField('GID').setValue(editp.get('GID'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpCtnBsCardDetail', returnData);
}
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 保存
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;
}
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);
},
//#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);
}
},
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
});