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/CRM_QUOTATION/CRM_QUOTATION_CARRIEREdit.js

2161 lines
77 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.CRM_QUOTATION_CARRIEREdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.CRM_QUOTATION_CARRIEREdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(Shipping.CRM_QUOTATION_CARRIEREdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
MainEditRecord: null,
stroplb: '客户询价',
isfen: false,
MainOpStatus: 'add',
parentgid: "",
//HBLNO:"",
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
this.initloaddata = 0;
this.DetailDel = [];
//#region 枚举类型定义
//客户加载_委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
//委托单位
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '询价对象', //hidden: true,
store: this.storeCustCode,
forceSelection: true,
name: 'CLIENTGID', id: "CLIENTGID",
valueField: 'GId',
displayField: 'CodeAndName',
allowBlank: false,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var data = combo.value;
this.formEdit.getForm().findField('SALE').setValue(records[0].data.SALE);
this.formEdit.getForm().findField('SHORTNAME').setValue(records[0].data.CustName);
this.formEdit.getForm().findField('DESCRIPTION').setValue(records[0].data.DESCRIPTION);
}
}
}
});
//委托单位_联系人
this.storeInfoClientContact = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
this.comboxInfoClientContact = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '联系人',
store: this.storeInfoClientContact,
forceSelection: true,
name: 'OPERATORCODE',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME'
});
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '揽货人',
store: this.storeOpCode,
forceSelection: true,
name: 'SALE',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeOpCode2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '创建人', readOnly: true,
store: this.storeOpCode2,
forceSelection: true,
name: 'CREATEUSER',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
this.storeCodeLoadport.load();
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '装货港',
allowBlank: false,
store: this.storeCodeLoadport,
name: 'PORTLOAD',
valueField: 'EDICODE',
displayField: 'CodeAndName',
forceSelection: true,
matchFieldWidth: false
});
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeDisport.load();
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '卸货港',
allowBlank: false,
store: this.storeCodeDisport,
name: 'PORTDISCHARGE',
forceSelection: true,
valueField: 'EDICODE',
queryMode: 'local',
displayField: 'CodeAndName'
});
this.storeENTREPORT = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeENTREPORT.load();
this.comboxENTREPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '中转港',
store: this.storeENTREPORT,
name: 'ENTREPORT',
forceSelection: true,
valueField: 'EDICODE',
queryMode: 'local',
displayField: 'CodeAndName'
});
this.storeBLSTATUS = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeBLSTATUS.load({ params: { enumTypeId: 39} });
this.comboxBLSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '询价状态', hidden: true,
store: this.storeBLSTATUS,
forceSelection: true,
name: 'BLSTATUS',
valueField: 'EnumValueId',
displayField: 'EnumValueName'
});
this.StoreBLTYPE = Ext.create('Ext.data.Store', {
fields: ['BLTYPE']
});
//this.StoreBLTYPE.add({ "BLTYPE": "空运单票" });
this.StoreBLTYPE.add({ "BLTYPE": "客户询价" });
this.StoreBLTYPE.add({ "BLTYPE": "供应商报价" });
this.comboxBLTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '报价单类型',
readOnly: true,
store: this.StoreBLTYPE,
forceSelection: true,
name: 'BLTYPE',
valueField: 'BLTYPE',
displayField: 'BLTYPE',
value: BLTYPE
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所属分公司', hidden: true,
forceSelection: true,
store: this.storeCompany,
name: 'CORPID',
valueField: 'gid',
displayField: 'name'
});
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
forceSelection: true,
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//委托单位_联系人
this.storeInfoClientContact = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
//this.storeInfoClientContact.load();
this.comboxInfoClientContact = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '联系人',
store: this.storeInfoClientContact,
// forceSelection: true,
name: 'OPERATOR',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME'
});
this.storeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCtn.load();
this.comboxCtn = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '箱型',
autosize: true,
bodyPadding: 1,
flex: 2,
width: 80,
labelWidth: 70,
store: this.storeCtn,
queryMode: 'local',
triggerOnClick: false,
name: 'CTN',
valueField: 'CTN',
displayField: 'CTN'
//,value: ['TX', 'CA']
});
//#endregion
//#region 编辑formHead 基本信息
var _this = this;
this.formEdit = Ext.widget('form', {
region: 'north', id: "formEdit",
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: 'GID',
name: 'GID', hidden: true
}, {
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}, this.comboxBLTYPE
, this.comboxCARRIER
, this.comboxBLSTATUS
, this.comboxCustCode
, this.comboxInfoClientContact
, {
fieldLabel: '客户简称',
name: 'SHORTNAME', hidden: true
}, {
fieldLabel: '客户全称', hidden: true,
name: 'DESCRIPTION', flex: 1
}//, this.comboxSALE
, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '报价日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'QUOTATIONDATE'
}
, this.comboxCompany
, this.comboxPORTLOAD
, this.comboxPORTDISCHARGE
, this.comboxENTREPORT
, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '航线',
name: 'LANE'
}, {
fieldLabel: '开船日期',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'ETD',
listeners: {
scope: this,
'change': function (field, newValue, oldValue) {
var _d = new Date(field.rawValue);
var week = "星期" + "日一二三四五六".split("")[_d.getDay()];
_this.formEdit.getForm().findField('WEEK').setValue(week);
var form = Ext.getCmp("formEdit");
if (form.getForm().findField('ETA').getRawValue() != "") {
var startdate = form.getForm().findField('ETD').getRawValue();
var enddate = form.getForm().findField('ETA').getRawValue();
var _e = Ext.util.Format.date(startdate); //格式化日期控件值
var _s = Ext.util.Format.date(enddate); //格式化日期控件值
var end = new Date(_s);
var start = new Date(_e);
var elapsed = Math.round((end.getTime() - start.getTime()) / (86400000)) + 1; // 计算间隔日数
//e.record.set('text',_s);
form.getForm().findField('TT').setValue(elapsed);
}
}
}
}, {
fieldLabel: '开船日周几', readOnly: true,
name: 'WEEK'
}
, {
fieldLabel: '到港日期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'ETA',
listeners: {
//添加日期选择事件
"change": function () {
var form = Ext.getCmp("formEdit");
if (form.getForm().findField('ETD').getRawValue() != "") {
var startdate = form.getForm().findField('ETD').getRawValue();
var enddate = form.getForm().findField('ETA').getRawValue();
var _e = Ext.util.Format.date(startdate); //格式化日期控件值
var _s = Ext.util.Format.date(enddate); //格式化日期控件值
var end = new Date(_s);
var start = new Date(_e);
var elapsed = Math.round((end.getTime() - start.getTime()) / (86400000)) + 1; // 计算间隔日数
//e.record.set('text',_s);
form.getForm().findField('TT').setValue(elapsed);
}
}
}
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '航程',
name: 'TT'
}, {
fieldLabel: '品名',
name: 'GOODSNAME'
}, {
fieldLabel: '有效期起',
name: 'VALIDDATE',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield'
}, {
fieldLabel: '有效期止',
name: 'VALIDDATE_END',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield'
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox', labelWidth: 70,
defaultType: 'numberfield',
items: [
{
fieldLabel: '20GP',
name: '_20GP'
}, {
fieldLabel: '40GP',
name: '_40GP'
}, {
fieldLabel: '40HC',
name: '_40HC'
}, {
fieldLabel: '45',
name: '_45'
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
xtype: 'textareafield',
fieldLabel: '备注',
grow: true,
height: 50,
//labelWidth: 55,
name: 'REMARK', flex: 4
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCtn
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxOP
, {
fieldLabel: '创建时间',
name: 'CREATETIME', readOnly: true,
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s')
},
{
fieldLabel: '最后更新人',
name: 'MODIFIEDUSER', readOnly: true
},
{
fieldLabel: '最后更新',
format: 'Y-m-d H:i:s', readOnly: true,
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'MODIFIEDTIME'
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}
]//end items(fieldset 1)
}); //end this.formEdit
//#endregion
//#region 明细信息
//数据集
this.storeDetail = Ext.create('Ext.data.Store', {
model: 'CRM_QUOTATION_DETAILmb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/CRM_QUOTATION_CUST/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 枚举类型
this.storeCARRIER2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
//船公司
this.comboxCARRIER2 = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '船公司',
store: this.storeCARRIER2,
forceSelection: true,
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.StoreUnit = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeUnit',
proxy: { url: '/MvcShipping/MsChFee/GetCtnUnitList' }
});
this.StoreUnit.load({ params: { bsno: "1234567890123", bstype: ""} });
this.comboxUnit = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreUnit,
name: 'UNIT',
valueField: 'UNIT',
displayField: 'SUNIT'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCurr,
forceSelection: true,
name: 'Currency',
valueField: 'CURR',
displayField: 'CURR'
});
//箱型_集装箱列表中的下拉框加载
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: '箱型',
store: this.storeCodeCtn,
forceSelection: true,
name: 'CTN',
valueField: 'CTN',
displayField: 'CTN'
});
//#endregion
//表格
this.DetailColumns = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'LINKGID',
header: 'LINKGID',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'LINKGID2',
header: 'LINKGID2',
width: 80
}, {
sortable: true,
dataIndex: 'CARRIER',
header: '船公司',
width: 100,
editor: this.comboxCARRIER2
},
{
dataIndex: 'ETD', hidden: true,
header: 'ETD',
width: 90,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true, hidden: true,
dataIndex: 'FEETYPE',
header: '费用类型',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'FEENAME',
header: '费用中文名称',
width: 80,
editor: this.comboxFeeNameRef
},
{
sortable: true,
dataIndex: 'UNIT',
header: '单位标准',
width: 80,
editor: this.comboxUnit
},
{
sortable: true,
dataIndex: '_20GP',
header: '20GP',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: '_40GP',
header: '40GP',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: '_40HC',
header: '40HC',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: '_45',
header: '45',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
}, {
sortable: true, hidden: true,
dataIndex: 'CTN',
header: 'CTN',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'CTNPRICE',
header: 'CTNPRICE',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
}, {
sortable: true, hidden: true,
dataIndex: 'CTN2',
header: 'CTN2',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CTNPRICE2',
header: 'CTNPRICE2',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'UNITPRICE',
header: '单票',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80,
editor: this.comboxCurr
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CREATEUSER',
header: '创建人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '创建时间',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSER',
header: '最后一次更新操作人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '最后一次更新时间',
width: 80
}
];
this.cellEditingDetail = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DetailCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formDetail = new Ext.grid.GridPanel({
store: this.storeDetail,
enableHdMenu: false,
layout: 'border',
region: 'center', //bodyStyle: 'background:#FFF',
trackResetOnLoad: true,
//height: 160,
autoScroll: true,
//title: '商品信息',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingDetail],
selModel: this.DetailCheckBoxModel,
selType: 'cellmodel',
tbar: [{
xtype: 'label',
width: 60,
text: '报价明细'
}, {
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event);
},
scope: this
}],
columns: this.DetailColumns
});
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnEPrev',
text: "上一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
}, {
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
}, {
id: 'btnECopyNew',
text: "复制新建",
handler: function (button, event) {
var btnESave = Ext.getCmp('btnESave');
if (btnESave.isDisabled() || this.getIsModify == '') {
var basicForm = this.formHead.getForm();
this.OpStatus = 'add';
basicForm.findField('BSNO').setDisabled(false);
//var BSNO = 'topAirn' + NewGuid();
var field = basicForm.findField('BSNO');
var oldbsno = field.getValue();
var oldmasterno = basicForm.findField('MASTERNO').getValue();
field.setValue(BSNO);
if (oldbsno == oldmasterno) {
field = basicForm.findField('MASTERNO');
field.setValue(BSNO);
}
basicForm.findField('BSNO').setDisabled(true);
field = basicForm.findField('CUSTNO');
field.setValue('');
field = basicForm.findField('ORDERNO');
field.setValue('');
field = basicForm.findField('INPUTBY');
field.setValue(SHOWNAME);
field = basicForm.findField('OP');
field.setValue(SHOWNAME);
var field = basicForm.findField('BSSTATUSREF');
field.setValue('未锁定');
var field = basicForm.findField('FEESTATUSREF');
field.setValue('未锁定');
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m');
field = basicForm.findField('ACCDATE');
field.setValue(mydatestr);
this.GetEditStatus();
var children = this.tabSeaepanel.items;
if (children) {
for (var i = children.length - 1, len = 0; i >= len; i--) {
if (children.items[i].id) {
if (children.items[i].id == 'pnlmodNewOpAirnInfo') {
// this.tabSeaepanel.setActiveTab(i);
} else {
children.items[i].close();
}
}
}
}
this.tabSeaepanel.doLayout();
} else {
this.CopyNew();
}
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
var basicForm = this.formEdit.getForm();
basicForm.findField('BsNo').setDisabled(false);
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}, '-', {
text: "生成应收",
tooltip: '',
iconCls: "",
handler: function (button, event) {
this.MakeFee();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
this.panelDetail = new Ext.Panel({
//title: '委托详细信息',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formDetail]
});
this.panelpage = new Ext.Panel({
//title: '委托详细信息',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formEdit, this.panelDetail]
});
this.panelSeae = new Ext.Panel({
title: '供应商报价信息',
id: 'pnlmodNewOpAirnInfo',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
frame: false,
//closable:true,
items: [this.panelBtn, this.formHead, this.panelpage]
});
this.treestore = new Ext.data.TreeStore({
model: 'DsShipping.ux.ModuleModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
url: '/MvcShipping/MsBaseInfo/GetModuTreeRefList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: true,
root: {
name: '根节点',
expanded: true,
id: '24BBEDCD-EF77-4379-B3ED-26FF41A57220'
}
});
this.tabtree = new Ext.tree.Panel({
region: 'west',
title: '业务信息',
split: true,
width: 180,
collapsible: true,
margins: '0 0 0 0',
store: this.treestore,
rootVisible: false,
hideHeaders: true,
animate: false,
lines: false,
columns: [{
xtype: 'treecolumn',
text: '模块名称',
width: 178,
dataIndex: 'DESCRIPTION'
}],
listeners: {
scope: this,
'itemclick': function (_this, record, item, index, e, eOpts) {
var finded = false;
if (record.data.MODULEURL == '@') {
this.tabSeaepanel.setActiveTab(0);
} else if (record.data.MODULEURL != '#') {
var children = this.tabSeaepanel.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children.items[i].id) {
if (children.items[i].id == 'pnl' + record.data.NAME) {
this.tabSeaepanel.setActiveTab(i);
finded = true;
}
}
}
}
if (finded == false) {
if (this.formEdit.getForm().findField('GID').getValue() == "") {
Ext.Msg.show({ title: '注意', msg: '请先保存业务信息后再打开其他模块!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
} else {
if (record.data.NAME == 'modLinkCRMQUOTATIONInfo') {
var paneltabitems = new Shipping.LinkCRMList({
id: 'pnl' + record.data.NAME,
layout: "border",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION
});
} else {
var paneltabitems = new Ext.Panel({
id: 'pnl' + record.data.NAME,
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION,
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + record.data.MODULEURL + '"> </iframe>'
});
}
this.tabSeaepanel.add(paneltabitems);
this.tabSeaepanel.setActiveTab(paneltabitems);
this.tabSeaepanel.doLayout();
}
}
}
}
}
});
this.tabSeaepanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
id: "TabSeaePanel",
enableTabScroll: true,
items:
[
this.panelSeae
],
listeners: {
scope: this,
'beforetabchange': function (tabPanel, newCard, oldCard, eOpts) {
/*
if (oldCard.id == "modLinkCRMQUOTATIONInfo") {
var feemodify = oldCard.panelFee.getModifyStatus();
if (feemodify) {
Ext.Msg.show({ title: '警告', msg: '费用未保存,请先保存费用!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return false;
}
}
if (oldCard.id == "pnlmodAirnAmendFee") {
var feemodify = oldCard.panelFee.getModifyStatus();
if (feemodify) {
Ext.Msg.show({ title: '警告', msg: '费用未保存,请先保存费用!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return false;
}
}
*/
}
}
});
Ext.apply(this, {
items: [this.tabtree, this.tabSeaepanel]
});
//#endregion
this.LoadInitData();
//#region 其他
// parentWin = window.parent.opener._this;
parentWin = window.parent.opener;
if (parentWin == NaN || parentWin == null) {
parentWin = window.parent.opener._this;
} else {
this.isfen = true;
}
this.InitData();
this.formDetail.on('edit', function (editor, e, eOpts) {
this.DetailAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.OpStatus = 'add';
var condition = '';
_this = this;
if (parentWin.OprationSwap != null) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
if (this.isfen) this.MainEditRecord = ret[3];
if (this.OpStatus == 'edit') {
condition = " CQ.GID='" + this.editRecord.get('GID') + "' and BLTYPE='" + BLTYPE + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
} else {
this.OpStatus = 'edit';
condition = " CQ.GID='" + parentWin.CRMLINKGID + "' ";
//this.storeBodyList.load({ params: { condition: condition} });
}
if (this.OpStatus == 'copyadd') {
this.CopyNewData();
} else {
this.LoadData(this.OpStatus, condition);
}
//this.LoadMustBe();
// if (this.initloaddata == 0) {
// this.LoadInitData();
// this.initloaddata = 1;
// };
}, //end InitData
LoadData: function (OpStatus, condition) {
this.serialNo = 0;
//this.bodyDel = [];
this.OpStatus = OpStatus;
if (this.isfen && this.OpStatus == 'add') {
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(this.MainEditRecord.data);
var newBsNo = NewGuid();
this.formEdit.getForm().findField('GID').setValue(newBsNo);
this.formHead.getForm().findField('BLTYPE').setValue(BLTYPE);
this.formEdit.getForm().findField('BLTYPE').readOnly = true;
//this.formHead.getForm().findField('CUSTNO').setValue('');
this.LoadInit(this.MainEditRecord.data);
document.title = BLTYPE;
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/CRM_QUOTATION_CUST/GetData',
params: {
handle: OpStatus,
condition: condition,
BLTYPE: BLTYPE
},
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;
data.BLTYPE = BLTYPE;
if (data.CREATETIME == "") { data.CREATETIME = currdate.format('yyyy-MM-dd hh:mm:ss') };
if (data.CREATEUSER == "") { data.CREATEUSER = SHOWNAME };
//this.formHead.getForm().reset();
//this.formHead.getForm().setValues(data);
this.formEdit.getForm().reset();
data.CTN = this.splitStrValue(data.CTN);
this.formEdit.getForm().setValues(data);
//this.formEdit_2.getForm().reset();
//this.formEdit_2.getForm().setValues(data);
this.LoadInit(data);
this.Editdata = data;
this.GetEditStatus();
this.storeDetail.load({ params: { condition: " LINKGID='" + data.GID + "'"} });
document.title = "" + BLTYPE + "" + data.SHORTNAME + " " + data.PORTDISCHARGE + " ETD" + data.ETD;
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
var billno = '*';
var gid = '*';
}, // end LoadDate
//#endregion
LoadInitData: function () {
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
this.storeOpCode.load();
this.storeOpCode2.load();
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
this.storeCARRIER2.load({ params: { condition: "ISCARRIER='1'"} });
var SHORTNAME = this.formEdit.getForm().findField('SHORTNAME').getValue();
var s = " LINKID in (select gid from [info_client] where SHORTNAME='" + SHORTNAME + "')";
this.storeInfoClientContact.load({ params: { condition: s} });
var BLTYPE = this.formEdit.getForm().findField('BLTYPE').getValue();
var CREATETIME = this.formEdit.getForm().findField('CREATETIME').getValue();
if (CREATETIME == "") { this.formEdit.getForm().findField('BLTYPE').setValue(currdate.format('yyyy-MM-dd hh:mm:ss')) };
var CREATEUSER = this.formEdit.getForm().findField('CREATEUSER').getValue();
if (CREATEUSER == "") { this.formEdit.getForm().findField('CREATEUSER').setValue(SHOWNAME) };
if (BLTYPE == "客户询价" || BLTYPE == "供应商报价") {
}
else {
}
},
LoadInit: function (data) {
},
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//计算费用
//this.SetFee();
//this.formEdit.getForm().findField('BSNO').setDisabled(false);
var data = this.formEdit.getForm().getValues(false, false, false);
var _ctn = this.getStrValue(this.comboxCtn.getValue());
data.CTN = _ctn;
//data.MODIFIEDUSER = SHOWNAME;
//data.MODIFIEDTIME = currdate.format('yyyy-MM-dd hh:mm:ss');
//data2.SUPERVISE = this.formEdit.getForm().findField('SUPERVISE').getValue() ? 1 : 0;
//data2.TRANSFER = this.formEdit.getForm().findField('TRANSFER').getValue() ? 1 : 0;
//this.formHead.getForm().findField('BSNO').setDisabled(true);
var Detaildatas = [];
for (var i = 0; i < this.storeDetail.getCount(); i += 1) {
var member = this.storeDetail.getAt(i);
Detaildatas.push(member);
}
//商品明细
var DetailBody = ConvertRecordsToJson(Detaildatas);
var DetailDelBody = ConvertRecordsToJsonAll(this.DetailDel);
var _url = '';
if (this.parentgid != "") {
_url = '/MvcShipping/CRM_QUOTATION_CUST/SaveChild';
} else {
_url = '/MvcShipping/CRM_QUOTATION_CUST/Save';
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: _url,
scope: this,
params: {
opstatus: this.OpStatus,
data: Ext.JSON.encode(data),
DetailBody: DetailBody,
DetailDelBody: DetailDelBody,
parentgid: this.parentgid
},
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.formHead.getForm().reset();
//this.formHead.getForm().setValues(returnData);
this.Editdata = returnData;
//
if (this.OpStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
if (type == '0') {
this.OpStatus = 'edit';
//basicForm2.findField('BSNO').setDisabled(true);
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
}
if (type == '0') {
this.OpStatus = 'edit';
//basicForm2.findField('BSNO').setDisabled(true);
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
}
}
else if (this.OpStatus == 'edit') {
var editp = Ext.create('CRM_QUOTATIONmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'GID')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
if (type == '0') {
this.OpStatus = 'edit';
//basicForm2.findField('BSNO').setDisabled(true);
this.storeDetail.load({ params: { condition: " LINKGID='" + this.editRecord.get('GID') + "'"} });
} 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 复制新建
CopyNewData: function () {
var data = this.editRecord.data;
var basicForm = this.formEdit.getForm();
this.formEdit.getForm().reset();
data.CTN = this.splitStrValue(data.CTN);
this.formEdit.getForm().setValues(data);
this.storeDetail.load({ params: { condition: " LINKGID='" + data.GID + "'"} });
this.SetCopyNewDate();
},
CopyNew: function () {
var basicForm = this.formEdit.getForm();
var data = this.formEdit.getForm().getValues(false, false, false);
var Detaildatas = [];
for (var i = 0; i < this.storeDetail.getCount(); i += 1) {
var member = this.storeDetail.getAt(i);
Detaildatas.push(member);
}
//商品明细
var DetailBody = ConvertRecordsToJson(Detaildatas);
var DetailDelBody = ConvertRecordsToJsonAll(this.DetailDel);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/CRM_QUOTATION_CUST/Save',
scope: this,
params: {
opstatus: this.OpStatus,
data: Ext.JSON.encode(data),
DetailBody: DetailBody,
DetailDelBody: DetailDelBody
},
callback: function (options, success, response) {
if (success) {
this.DetailDel = [];
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().reset();
returnData.CTN = this.splitStrValue(returnData.CTN);
this.formEdit.getForm().setValues(returnData);
//this.formHead.getForm().reset();
//this.formHead.getForm().setValues(returnData);
this.Editdata = returnData;
this.SetCopyNewDate();
} 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
DetailAfterEdit: function (editor, e, eOpts) {
}
,
otfeechange: function (field, newValue, oldValue, eOpts) {
if (newValue == oldValue) return;
var s = '';
var ttl = 0.0;
var otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE1AMOUNT').getValue(), 0);
var otfee1 = this.formEdit_2.getForm().findField('OTFEE1').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE2AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE2').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE3AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE3').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE4AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE4').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE5AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE5').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE6AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE6').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE7AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE7').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
otfee1amount = parseFloatDef(this.formEdit_2.getForm().findField('OTFEE8AMOUNT').getValue(), 0);
otfee1 = this.formEdit_2.getForm().findField('OTFEE8').getValue();
if (otfee1 != '' && otfee1amount != 0) {
s = s + otfee1 + ':' + otfee1amount + ';';
ttl = Add(ttl, otfee1amount);
}
var BLFRT = this.formEdit_2.getForm().findField('BLFRT').getValue();
if (BLFRT == 'PP') {
if (ttl != 0)
this.formEdit_2.getForm().findField('POTFREIGHT').setValue(ttl);
} else if (BLFRT == 'CC') {
if (ttl != 0)
this.formEdit_2.getForm().findField('COTFREIGHT').setValue(ttl);
}
//this.formEdit_2.getForm().findField('OTFEE').setValue(s);
//this.SetFee();
},
SetFee: function () {
var YF = 0;
for (var i = 0; i < this.storeDetail.getCount(); i += 1) {
var member = this.storeDetail.getAt(i);
YF = Add(YF, member.data.AMOUNT);
}
var BLFRT = this.formEdit_2.getForm().findField('BLFRT').getValue();
if (BLFRT == 'PP') {
if (YF != 0)
this.formEdit_2.getForm().findField('PFREIGHT').setValue(YF);
} else if (BLFRT == 'CC') {
if (YF != 0)
this.formEdit_2.getForm().findField('CFREIGHT').setValue(YF);
}
var PTOTAL = 0;
var CTOTAL = 0;
var CFREIGHT = this.formEdit_2.getForm().findField('CFREIGHT').getValue();
var CVALUEFEE = this.formEdit_2.getForm().findField('CVALUEFEE').getValue();
var CCARRIEROT = this.formEdit_2.getForm().findField('CCARRIEROT').getValue();
var COTFREIGHT = this.formEdit_2.getForm().findField('COTFREIGHT').getValue();
//var CTOTAL = this.formEdit_2.getForm().findField('CTOTAL').getValue();
var PFREIGHT = this.formEdit_2.getForm().findField('PFREIGHT').getValue();
var PVALUEFEE = this.formEdit_2.getForm().findField('PVALUEFEE').getValue();
var PCARRIEROT = this.formEdit_2.getForm().findField('PCARRIEROT').getValue();
var POTFREIGHT = this.formEdit_2.getForm().findField('POTFREIGHT').getValue();
//var PTOTAL = this.formEdit_2.getForm().findField('PTOTAL').getValue();
PTOTAL = Add(Add(PFREIGHT, PVALUEFEE), Add(PCARRIEROT, POTFREIGHT));
CTOTAL = Add(Add(CFREIGHT, CVALUEFEE), Add(CCARRIEROT, COTFREIGHT));
this.formEdit_2.getForm().findField('PTOTAL').setValue(PTOTAL);
this.formEdit_2.getForm().findField('CTOTAL').setValue(CTOTAL);
},
MakeFee: function (button, event) {
var _CustomerName = this.formHead.getForm().findField('CUSTOMERNAME').getValue();
var BSNO = this.formHead.getForm().findField('BSNO').getValue();
var BLTYPE = this.formHead.getForm().findField('BLTYPE').getValue();
if (BLTYPE == "国内分单") {
var CFREIGHT = this.formEdit_2.getForm().findField('CFREIGHT').getValue();
if (parseFloat(CFREIGHT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "空运费", CFREIGHT, 1, "到付空运费", "", "");
}
var CVALUEFEE = this.formEdit_2.getForm().findField('CVALUEFEE').getValue();
if (parseFloat(CVALUEFEE) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "声明价值附加费", CVALUEFEE, 1, "到付声明价值附加费", "", "");
}
var CCARRIEROT = this.formEdit_2.getForm().findField('CCARRIEROT').getValue();
if (parseFloat(CCARRIEROT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "地面运费", CCARRIEROT, 1, "到付地面运费", "", "");
}
var COTFREIGHT = this.formEdit_2.getForm().findField('COTFREIGHT').getValue();
if (parseFloat(COTFREIGHT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "杂费", COTFREIGHT, 1, "到付杂费", "", "");
}
///////////
var PFREIGHT = this.formEdit_2.getForm().findField('PFREIGHT').getValue();
if (parseFloat(PFREIGHT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "空运费", PFREIGHT, 1, "预付空运费", "", "");
}
var PVALUEFEE = this.formEdit_2.getForm().findField('PVALUEFEE').getValue();
if (parseFloat(PVALUEFEE) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "声明价值附加费", PVALUEFEE, 1, "预付声明价值附加费", "", "");
}
var PCARRIEROT = this.formEdit_2.getForm().findField('PCARRIEROT').getValue();
if (parseFloat(PCARRIEROT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "地面运费", PCARRIEROT, 1, "预付地面运费", "", "");
}
var POTFREIGHT = this.formEdit_2.getForm().findField('POTFREIGHT').getValue();
if (parseFloat(POTFREIGHT) > 0) {
this.addChFee(1, _CustomerName, BSNO, "RMB", "1", "杂费", POTFREIGHT, 1, "预付杂费", "", "");
}
}
},
addChFee: function (FeeType, _CustomerName, BSNO, Currency, Exchangerate, FeeName, price, Quantity, Remark, FeeDescription, feedate) {
var _Amount = 0;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
if (feedate == "" || typeof (feedate) == "undefined") {
EnterDate = GetDateStr(0);
} else {
EnterDate = feedate;
}
//var ContractNo = Ext.getCmp("ContractNo").getValue();
var field = " (GId,BsNo,FeeStatus,FeeType,FeeName,FeeDescription,CustomerType,CustomerName,Unit,UnitPrice,NOTAXAMOUNT,TAXUNITPRICE,Quantity "
field = field + " ,Amount,Currency,ExChangerate,Reason,Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice "
field = field + " ,Auditoperator,EnterOperator,EnterDate,DebitNo,IsDebit,IsOpen,IsAdvancedpay,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus,SALESNO) "
var _value = " values ('" + NewGuid() + "','" + BSNO + "',1," + FeeType + ",'" + FeeName + "','','','" + _CustomerName + "',''," + price + "," + price + "," + price + "," + Quantity + ""
_value = _value + "," + price + "*" + Quantity + ",'" + Currency + "'," + Exchangerate + ",'','" + Remark + "',0,0,0,0,0 "
_value = _value + ",'','" + USERID + "','" + EnterDate + "','',0,0,0,0,'PP',0,0,'')"
var SQL = " Insert into ch_fee " + field + _value;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSync/SaveSync',
scope: this,
params: {
SQL: SQL
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
//刷新费用列表
//this.storeBodyChFee.load({ params: { SALESNO: SALESNO} });
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
//#region
/*
LoadMustBe: function () {
this.storeMustBe.load({ params: { condition: "BSTYPE='空运出口'" },
callback: function (r, options, success) {
if (success) {
if (this.storeMustBe.getCount() > 0) {
for (var j = 0; j < this.storeMustBe.getCount(); j += 1) {
var member = this.storeMustBe.getAt(j);
var headfield = this.formHead.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null) {
if (member.data.ISMUST == "1")
headfield.allowBlank = false;
if (member.data.ISCOLOR == "1")
headfield.setFieldStyle({ background: '#ffc' });
}
var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null) {
if (member.data.ISMUST == "1")
headfield.allowBlank = false;
if (member.data.ISCOLOR == "1")
headfield.setFieldStyle({ background: '#ffc' });
}
};
} else {
}
}
},
scope: this
});
},
*/
//#endregion
//#region 转换成大写字符
onUpCaseClick: function (menu, event) {
this.formEdit.getForm().findField('SHIPPER').setValue(this.formEdit.getForm().findField('SHIPPER').getValue().toUpperCase());
this.formEdit.getForm().findField('CONSIGNEE').setValue(this.formEdit.getForm().findField('CONSIGNEE').getValue().toUpperCase());
this.formEdit.getForm().findField('NOTIFYPARTY').setValue(this.formEdit.getForm().findField('NOTIFYPARTY').getValue().toUpperCase());
this.formEdit.getForm().findField('AGENT').setValue(this.formEdit.getForm().findField('AGENT').getValue().toUpperCase());
this.formEdit.getForm().findField('MARKS').setValue(this.formEdit.getForm().findField('MARKS').getValue().toUpperCase());
this.formEdit.getForm().findField('DESCRIPTION').setValue(this.formEdit.getForm().findField('DESCRIPTION').getValue().toUpperCase());
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
//var BLSTATUS = this.formEdit.getForm().findField('BLSTATUS').getValue();
//var inputby = this.formEdit.getForm().findField('INPUTBY').getValue();
//var op = this.formHead.getForm().findField('OP').getValue();
/*
_this = this;
if (BLSTATUS == '锁定') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modOpAirnList" },
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);
}
}
});
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsSysBillNoSet/GetData',
params: {
condition: "OPLBNAME='空运出口' AND RULEBLNO='委托编号'",
handle: 'edit'
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
var custno = _this.formHead.getForm().findField('CUSTNO');
custno.setReadOnly(true);
} else {
var data = result.data;
if (data.ISEDIT == '1') {
var custno = _this.formHead.getForm().findField('CUSTNO');
custno.setReadOnly(false);
} else {
if (data.RULEBLNO == '') {
var custno = _this.formHead.getForm().findField('CUSTNO');
custno.setReadOnly(false);
} else {
var custno = _this.formHead.getForm().findField('CUSTNO');
custno.setReadOnly(true);
}
}
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsBaseInfo/GetRuleEdit',
params: {
rulename: '分提单号',
ruletype: '1'
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
var hblno = _this.formHead.getForm().findField('HBLNO');
hblno.setReadOnly(true);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
*/
},
GetStringNum: function (str) {
var num = 0;
if (str == null || str == '') return num;
if (str.length == 0) return num;
var if_find = false;
var str_num = '';
for (var i = 0; i < str.length; i += 1) {
var member = str.substr(i, 1);
if ((member == '0') || (member == '1') || (member == '2') || (member == '3')
|| (member == '4') || (member == '5') || (member == '6') || (member == '7')
|| (member == '8') || (member == '9') || (member == '.') || (member == '-')) {
if (!if_find) {
str_num = str_num + member;
}
} else {
if_find = true;
}
}
return str_num;
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
},
//#endregion
//#region 打印
Print: function () {
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('BSNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MsOpAirn';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_Airn WHERE BSNO = '" + billNo + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
//#endregion
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var children = this.tabSeaepanel.items;
if (children) {
for (var i = children.length - 1, len = 0; i >= len; i--) {
if (children.items[i].id) {
if (children.items[i].id == 'pnlmodNewOpAirnInfo') {
} else {
children.items[i].close();
}
}
}
}
this.tabSeaepanel.doLayout();
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.OpStatus == 'edit') {
condition = "BSNO='" + this.editRecord.get('BSNO') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.OpStatus, condition);
},
NextRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var children = this.tabSeaepanel.items;
if (children) {
for (var i = children.length - 1, len = 0; i >= len; i--) {
if (children.items[i].id) {
if (children.items[i].id == 'pnlmodNewOpAirnInfo') {
// this.tabSeaepanel.setActiveTab(i);
} else {
children.items[i].close();
}
}
}
}
this.tabSeaepanel.doLayout();
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.OpStatus == 'edit') {
condition = "BSNO='" + this.editRecord.get('BSNO') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.OpStatus, condition);
},
getIsModify: function () {
var feepanel = Ext.getCmp('pnlmodAirnAllFee');
if (feepanel != NaN && feepanel != null) {
var feemodify = feepanel.panelFee.getModifyStatus();
if (feemodify) {
return '费用信息';
}
}
var feeamendpanel = Ext.getCmp('pnlmodAirnAmendFee');
if (feeamendpanel != NaN && feeamendpanel != null) {
var feemodify = feeamendpanel.panelFee.getModifyStatus();
if (feemodify) {
return '更改单信息';
}
}
if (panelEdit.formEdit.getForm().isDirty() == true || panelEdit.formHead.getForm().isDirty() == true) {
return '业务信息';
}
else return '';
}
,
reLine: function (button, event) {
var _L = 1;
this.storeDetail.each(function (record) {
var ln = _L + "";
_L = _L + 1;
record.set('SEQUENCE', ln);
});
},
onAddDetailClick: function (button, event) {
var _form = this.formEdit.getForm();
var _CARRIER = _form.findField('CARRIER').getValue();
var _ETD = _form.findField('ETD').getRawValue();
if (_ETD == "" || _CARRIER == "") {
alert("请先选择船公司和填写ETD");
return;
}
//var linenum = this.storeDetail.getCount() + 1;
//var _r = this.reLine();
var record = Ext.create('CRM_QUOTATION_DETAILmb', {
'GID': NewGuid(),
'CARRIER': _CARRIER,
'ETD': _ETD,
'LINKGID': "",
'FEETYPE': "",
'FEENAME': "",
'UNIT': "",
'UNITPRICE': 0,
'CURRENCY': "",
'REMARK': "",
'CREATEUSER': SHOWNAME,
'CREATETIME': currdate.format('yyyy-MM-dd hh:mm:ss'),
'MODIFIEDUSER': SHOWNAME,
'MODIFIEDTIME': currdate.format('yyyy-MM-dd hh:mm:ss')
});
this.storeDetail.add(record);
var n = this.storeDetail.getCount();
this.storeDetail.startEditByPosition({ row: n - 1, column: 2 });
//aftereditform();
},
onDelDetailClick: function (button, event) {
var selectedRecords = this.formDetail.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.LINKGID != "" && rec.data.LINKGID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.DetailDel.push(rec);
}
this.storeDetail.remove(selectedRecords[i]);
}
}
}, this);
//aftereditform();
}
,
getStrValue: function (list) {
var _list = "";
for (var _i = 0; _i < list.length; _i++) {
//_list.push("'" + list[_i] + "'");
if (_list == "") { _list = list[_i] } else { _list = _list + "," + list[_i] }
}
return _list;
},
splitStrValue: function (Str) {
var strs = new Array(); //定义一数组
strs = Str.split(","); //字符分割
return strs;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.MainOpStatus;
ret[1] = [];
ret[2] = [];
ret[3] = this.formEdit.getForm();
return ret;
}
});