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.

4628 lines
172 KiB
JavaScript

10 months ago
///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
Ext.namespace('DsTruck');
var BillNoCount=0;
DsTruck.AuditEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.AuditEdit.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);
function getSaved(){
//var cargodirty=DsTruck.GetDirty(panelEdit.storeCargo,panelEdit.CargoDel);
//var appstatedirty=DsTruck.GetDirty(panelEdit.storeappstate,panelEdit.AppstateDel);
if (panelEdit.formEdit.getForm().isDirty()== true )
{
return true;
}
else return false;
}
Ext.extend(DsTruck.AuditEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'edit',
StoreList: null,
editRecord: null,
// parentfunction: null,
_First: true,
initUIComponents: function () {
this.bodyDel = [];
this.CargoDel = [];
this.AppstateDel = [];
this.KCDel = [];
this.AuditStatusBodyDel=[];
this.feeSerialNo = 0;
this.feeBodyDel = [];
this.FormName_1="Audit_CargoForm";
this.FormName_2="Audit_AppStateForm";
this.AuditStatusGID="";
this.AuditRECEIPTNAME="";
//#region 枚举参照相关(编辑form)
this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMainstate.load({ params: { enumTypeId: 3} });
this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '合同状态',
forceSelection: true,
store: this.storeMainstate,
name: 'Mainstate'
});
this.storeBillType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBillType.load({ params: { enumTypeId: 6} });
this.comboxBillType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '提单提交方式',
disabled: true,
forceSelection: true,
store: this.storeBillType,
name: 'BillType'
});
this.storeShipCompany = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeShipCompany.load({ params: { enumTypeId: 5} });
this.comboxShipCompany = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '船公司',
forceSelection: true,
store: this.storeShipCompany,
name: 'ShipCompany_id'
});
this.storeSecurityDeposit = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeSecurityDeposit.load({ params: { enumTypeId: 0} });
this.comboxSecurityDeposit = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '是否已交保证金',
disabled: true,
forceSelection: true,
store: this.storeSecurityDeposit,
name: 'SecurityDeposit'
});
this.storeMZBZ = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMZBZ.load({ params: { enumTypeId: 0} });
this.comboxMZBZ = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '是否木质包装',
forceSelection: true,
store: this.storeMZBZ,
name: 'MZBZ'
});
this.storeCIQ_canbesearch = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCIQ_canbesearch.load({ params: { enumTypeId: 0} });
this.comboxCIQ_canbesearch = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '卫生证是否可查',
store: this.storeCIQ_canbesearch,
name: 'CIQ_canbesearch'
});
this.storeTransactionMethod = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTransactionMethod.load({ params: { enumTypeId: 1} });
this.comboxTransactionMethod = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '成交方式',
forceSelection: true,
store: this.storeTransactionMethod,
name: 'TransactionMethod',
valueField: 'EnumValueId',
displayField: 'EnumValueName',
triggerAction: 'all',
selectOnFocus: true,
listeners: {
change: function (field, newValue, oldValue) {
this.setBaolv(field, newValue, oldValue);
},
scope: this
},
flex:1
});
this.storePaymentMethods = Ext.create('DsExt.ux.RefEnumStore', {});
this.storePaymentMethods.load({ params: { enumTypeId: 4} });
this.comboxPaymentMethods = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '付款方式',
disabled: true,
forceSelection: true,
store: this.storePaymentMethods,
name: 'PaymentMethods'
});
this.storeport = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeport.load({ params: { enumTypeId: 10} });
this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '目的港',
disabled: true,
forceSelection: true,
store: this.storeport,
name: 'port'
});
//表参照相关
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' } });
this.storeTradeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' } });
_this = this;
this.storeCountry.load({ params: { condition: "" }
,
callback: function (r, options, success) {
if (success) {
_this.storeTradeCountry.removeAll();
_this.storeTradeCountry.add(r);
}
},
scope: this
});
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '进口国',
//forceSelection: true,
store: this.storeCountry,
name: 'countryid',
valueField: 'countryid',
displayField: 'country_idandname'
});
this.comboxTradeCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '贸易国',//readOnly:true,
//forceSelection: true,
flex:1,
store: this.storeCountry,
name: 'TRADECOUNTRY',
valueField: 'countryid',
displayField: 'country_idandname'
});
this.comboxCountry.addListener('select', function (combo, record, index) {
var s = " countryid='" + combo.value+"'";
//alert(s);
//this.storeCargoinfo.removeAll();
this.storeCargoinfo.load({ params: { condition: s} });
//this.comboxCargoinfo.clearValue();
}, this);
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: "(ISDELETED=0 and ISDISABLE=0)"} });
this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '接单人',
disabled: true,
store: this.storeUser,
name: 'creator', flex: 4,
valueField: 'UserCode',
displayField: 'CodeAndName'
});
this.comboxAuditor = Ext.create('DsExt.ux.RefTableCombox', {
allowBlank: false,
fieldLabel: '审单人',
store: this.storeUser,
name: 'Auditor',
valueField: 'UserCode',
displayField: 'CodeAndName'
});
//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: '用证公司',
// disabled: true,
// forceSelection: true,
// store: this.storeCompany,
// name: 'company',
// valueField: 'gid',
// displayField: 'name',
// listeners: {
// focus: function (field, newValue, oldValue) {
// if (this.storeCompany.getCount() <= 1) {
// this.storeCompany.load();
// }
// },
// scope: this
// }
//});
this.storeSeller = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeSeller.load({ params: { condition: " isagent=1"} });
this.comboxSeller = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '贸易商',
disabled: true,
forceSelection: true,
store: this.storeSeller,
name: 'seller',
valueField: 'name',
displayField: 'codename',
listeners: {
blur: function (field, newValue, oldValue) {
if (field.displayTplData[0].ISSTOP=="True"){
alert("该往来单位已经停用");
}
},
scope: this
}
});
this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer.load({ params: { condition: " isagentcn=1 "} });
this.comboxBuyer = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户(购货方)',
disabled: true,
forceSelection: true,readOnly:true,
store: this.storeBuyer,
name: 'buyer',
valueField: 'name',
displayField: 'codename',
listeners: {
blur: function (field, newValue, oldValue) {
if (field.displayTplData[0].ISSTOP=="True"){
alert("该往来单位已经停用");
}
},
scope: this
}
});
this.storeTRADINGAGENCY = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeTRADINGAGENCY.load({ params: { condition: " ISTRADINGAGENCY=1 "} });
this.comboxTRADINGAGENCY = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '订货方(中间商)',
disabled: true,
forceSelection: true,
store: this.storeTRADINGAGENCY,
name: 'TRADINGAGENCY',
valueField: 'name',
displayField: 'codename',
listeners: {
blur: function (field, newValue, oldValue) {
if (field.displayTplData[0].ISSTOP=="True"){
alert("该往来单位已经停用");
}
},
scope: this
}
});
this.storeInspection_Buyer = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' } });
this.storeInspection_Buyer.load({ params: { condition: "" } });
this.comboxInspection_Buyer = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '商检收货单位',flex:1,disabled: true,
forceSelection: true,
store: this.storeInspection_Buyer,
name: 'Inspection_Buyer',
valueField: 'name',
displayField: 'codename',readOnly:true
});
this.storeContainerType = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CtnRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCtnDispList' }
});
this.storeContainerType.load({ params: { condition: ""} });
this.comboxContainerType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeContainerType,
name: 'CTN',
valueField: 'CtnName',
//disabled: true,
displayField: 'CtnName'
});
//#endregion
//国内港口(出口装货港、进口卸货港)
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
this.storeCodeLoadport.load();
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeLoadport,
name: 'PORTLOAD',
valueField: 'PORT',
queryMode: 'remote',
minChars: 1,
queryParam: 'PORT',
displayField: 'PORT'
});
///商务汇率 取当日的应付汇率
this.storeExchangerate = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCurrencyExchange',
proxy: { url: '/MvcShipping/MsCurrencyExchange/GetExchangeRate' }
});
this.comboxExchangerate = Ext.create('DsExt.ux.DCombox', {
store: this.storeExchangerate,
name: 'Exchangerate', //id: "ISPAYED",
matchFieldWidth: false,
forceSelection: false,
valueField: 'CRVALUE',
displayField: 'CrRef'
});
///海关汇率 取到港日的海关汇率
this.storeExchangerate2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCurrencyExchange',
proxy: { url: '/MvcShipping/MsCurrencyExchange/GetExchangeRate' }
});
this.comboxExchangerate2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeExchangerate2,
name: 'Exchangerate_Customs', //id: "ISPAYED",
matchFieldWidth: false,
forceSelection: false,
valueField: 'CUSTOMVALUE',
displayField: 'CustomRef'
});
//#region 编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
title:'业务基础信息',
region: 'north',
height:435,
collapsed: false,
collapsible: true,
frame: true,
bodyPadding: 3,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
//,split:true
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '合同序列号',
// allowBlank: false,
disabled: true,flex:4,
name: 'ContractNo'
}, {
fieldLabel: '合同号', flex: 4,
name: 'HTH'
}, {
fieldLabel: '合同日期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
flex: 4,
name: 'HTDATE'
}, this.comboxCreator,{
fieldLabel: '接单时间',
disabled: true,
format: 'Y-m-d',
xtype: 'datefield',
flex: 4,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'creattime'
},
/**/{
fieldLabel: 'id',
name: 'id', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'cgid',
name: 'cgid', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}
]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ this.comboxMainstate,
//this.comboxCompany,
{
name: 'companyname',
fieldLabel: '用证公司',
readOnly:true
},
{
name: 'company',
fieldLabel: 'company',
hidden: true
},
this.comboxCountry,
//this.comboxPrinted,
this.comboxport]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxAuditor, {
fieldLabel: '审单时间',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'Audittime'
},{
fieldLabel: '提单号',
name: 'BillNo'
},{
xtype : 'checkbox',flex:1,
fieldLabel: '提单号可重复',
name: 'MBLNOREPEAT'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '提单时间',
disabled: true,
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'BillTime'
},{
fieldLabel: '箱号',
name: 'ContainerNo'
}, {
fieldLabel: '铅封号',
name: 'SealNo'
},this.comboxMZBZ
]
},{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxSeller,
this.comboxBuyer,
this.comboxTRADINGAGENCY,
{
fieldLabel: '双抬头',
disabled: true,
name: 'STT'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxShipCompany,{
fieldLabel: '免箱期(日)',disabled: true,
name: 'Freetime',
},{
fieldLabel: '船名',
//disabled: true,
name: 'Vessel'
}, {
fieldLabel: '航次',
//disabled: true,
name: 'Voyage'
}
]
}, {
xtype: 'container',
layout: 'hbox',
items: [{
fieldLabel: '预计开船日',
disabled: true,
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'Ex_sailingdate'
}, {
fieldLabel: '开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Sailingdate'
},
{
fieldLabel: '到港日期',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
name: 'ArrivalDate'
},this.comboxSecurityDeposit]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '卫生证序列号',
name: 'CIQ_licence'
},this.comboxCIQ_canbesearch,
this.comboxTransactionMethod,
this.comboxPaymentMethods
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxTradeCountry,
{
fieldLabel: '卫生证签发日期',
format: 'Y-m-d',//readOnly:true,
xtype: 'datefield',
name: 'CIQDATE'
},{
flex:1,//readOnly:true,
fieldLabel: '兽医官签字',
name: 'VSIGN'
}, this.comboxPORTDISCHARGE
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ {
fieldLabel: '备注',
name: 'remark',id:"remark"
},{
fieldLabel: '回空日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'RecDate',hidden:true
},
{
fieldLabel: '港口天数',
name: 'PortDays',
readOnly:true,hidden:true
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ this.comboxContainerType
,{
fieldLabel: '国外寄单快递号',
name: 'BILLTRANCNO',id:"BILLTRANCNO"
}, this.comboxBillType
,{xtype:'hiddenfield',flex:1}]
},
{
xtype: 'container',
layout: 'hbox',
readOnly : true,
defaultType: 'textfield',
items: [{
fieldLabel: '报检号',disabled: true,
name: 'inspection_no',
flex:1
},this.comboxInspection_Buyer
,{
fieldLabel: '商检_电话',disabled: true,
name: 'Inspection_Tel',flex:1
},{
fieldLabel: '商检_Email',disabled: true,
name: 'Inspection_Email',flex:1
}]
} ,
{
xtype: 'container',
layout: 'hbox',
readOnly : true,
defaultType: 'textfield',
items: [{
fieldLabel: '商检_联系人',disabled: true,
name: 'Inspection_Contacter',
flex:1
},{
fieldLabel: '商检_组织机构代码',disabled: true,
name: 'Inspection_Code',flex:1
},{
fieldLabel: '商检_送货地址',disabled: true,
name: 'Inspection_DeliveryAddress',flex:2
}]
} ,
{
xtype: 'container',
layout: 'hbox',
readOnly : true,
defaultType: 'textfield',
items: [{
xtype : 'checkbox',flex:1,
fieldLabel: '已有合同',
name: 'HaveContract'
},
{
xtype : 'checkbox',flex:1,
fieldLabel: '有商品标签',
name: 'HaveCargoMark'
},{
fieldLabel: '寄单情况',
name: 'Receiptremark',
flex:6
},
{
xtype : 'checkbox',flex:1,
fieldLabel: '已做样本清单',
name: 'HAVESAMPLE'
},
{
xtype : 'checkbox',flex:1,
fieldLabel: '样本清单已检查',
name: 'CHECKSAMPLE'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 明细 <<<< 商品 >>>>
//#region 相关参照
this.storeCargoinfo = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoTax',
proxy: { url: '/CommMng/BasicDataRef/GetCargoTax' }
});
// this.storeCargoinfo.load({ params: { condition: ""} });
this.comboxCargoinfo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCargoinfo,
name: 'Cargoinfo_id',
valueField: 'id',
displayField: 'codeandname'
//HS代码
});
this.storeCargociq = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargociqRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' }
});
this.storeCargociq.load({ params: { condition: ""} });
this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCargociq,
name: 'Cargociq_id',
valueField: 'id',
displayField: 'codeandname'
//ciq代码
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storecurr,
name: 'currid',
valueField: 'gid',
displayField: 'codename'
//币别
});
//枚举参照
this.storeUnit = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeUnit.load({ params: { enumTypeId: 11} });
this.comboxUnit = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeUnit,
name: 'Unit'
});
this.storepaypart = Ext.create('DsExt.ux.RefEnumStore', {});
this.storepaypart.load({ params: { enumTypeId: 12} });
this.comboxpaypart = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storepaypart,
name: 'paypart'
});
this.storeExporter = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeExporter.load({ params: { condition: " isenterp=1 "} });
this.comboxExporter = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '出口商',
forceSelection: true,
store: this.storeExporter,
name: 'Exporter',
valueField: 'name',
displayField: 'codeEnName'
});
this.storeFactoryNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'FactoryNomb',
proxy: { url: '/Import/CargoName/GetFactoryNoList' }
});
this.storeFactoryNo.load({ params: { start:0,limit:5000,condition: ""} });
this.comboxFactoryNo = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '厂号',
//autosize: true,
//bodyPadding: 5,
//flex: 1,
//forceSelection: true,
width: 100,
//labelWidth: 90,
store: this.storeFactoryNo,
//queryMode: 'local',
//triggerOnClick: false,
name: 'FactoryNo',
valueField: 'FACTORYNO',
displayField: 'FACTORYNO'
});
this.storeCargoName = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoName_Cnmb',
proxy: { url: '/Import/CargoName/GetCargoNameList' }
});
//this.storeCargoName.load({ params: { condition: ""} });
this.comboxCargoName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '出口商',
forceSelection: true,
store: this.storeCargoName,
name: 'name',
valueField: 'CNNAME',
displayField: 'CNNAME'
});
this.storeCargoName_EN = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoName_Enmb',
proxy: { url: '/Import/CargoName/GetCargoNameList' }
});
this.comboxCargoENName = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeCargoName_EN,
name: 'Ename',
valueField: 'ENNAME',
displayField: 'ENNAME'
});
//商品规格 20160420
this.storeSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeSPECIFICATIONS.load({ params: { enumTypeId: 34} });
this.comboxSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeSPECIFICATIONS,
forceSelection: true,
name: 'SPECIFICATIONS',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//#endregion
//数据集
this.storeCargo = Ext.create('Ext.data.Store', {
model: 'Cargomb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/XXH/GetCargoList_Audit',
reader: {
id: 'id,ContractNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.Cargocolumns= [{
dataIndex: 'id',
header: '自增序列号',
width: 80,
hidden: true,
editor: {
xtype: 'textfield'
}
},
{
dataIndex: 'ContractNo',
header: '合同号',
width: 80,
hidden: true
},
{
dataIndex: 'SEQUENCE',
header: '序号',
width: 44,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'Exporter',
header: '出口商',
width: 150,
editor: this.comboxExporter,
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:80px;height:17px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},{
dataIndex: 'FactoryNo',
header: '厂号',
width: 80,
editor: this.comboxFactoryNo,
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:80px;height:17px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},{
dataIndex: 'Ename',
header: '英文品名',
width: 100,
editor: this.comboxCargoENName
,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'name',
header: '标签品名',
width: 80,
editor: this.comboxCargoName ,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
}, {
dataIndex: 'TAGPICURL',
header: '标签图片',
width: 60,
renderer: function (value, p, record) {
if (value == '' || typeof (value) == "undefined") {
//return '<input type="button" value="上传" onClick="javascript:this.UpLoadFile('+record.data.BillNo+')"';
return '';
} else
return '<a href="' + value + '" style=' + '"text-decoration:none" target="_blank"' + ' > 下载图片 </a>';
}
},{
dataIndex: 'SPECIFICATIONS',
header: '商品规格',
width: 60,
editor: this.comboxSPECIFICATIONS
}, {
dataIndex: 'CargoType',
header: '产品类型',
width: 50
},
{
dataIndex: 'cargoinfo_id',
header: 'HS代码',
renderer: function(value, p, record) {
if (value == null || value == '') return '';
else return "<a style=\"background-color:#B7B7B7\">"+record.data.cicodeandname+"&nbsp;</a>";
},
//editor: this.comboxCargoinfo,
width: 140
},
{
dataIndex: 'cargociq_id',
header: 'CIQ代码',
renderer: function(value, p, record) {
if (value == null || value == '') return '';
else return "<a style=\"background-color:#B7B7B7\">"+record.data.ciqcodeandname+"&nbsp;</a>";
},
//editor: this.comboxCargociq,
width: 140
},
{
dataIndex: 'Unit',
header: '重量单位',
renderer: function(value, p, record) {
if (value == null || value == '') return "<a style=\"display:block;width:60px;height:15px;background-color:#FF0000\">&nbsp;</a>";
else return "<a><font color='#0000FF'>"+record.data.UnitRef+"</font></a>";
},
editor: this.comboxUnit,
width: 60
},
{
dataIndex: 'currid',
header: '币别',
renderer: function(value, p, record) {
if (value == null || value == '')
{
return "<a style=\"display:block;width:50px;height:15px;background-color:#FF0000\">&nbsp;</a>";
}
else
{
return "<a><font color='#0000FF'>"+record.data.codename+"</font></a>";
}
},
editor: this.comboxcurr,
width: 50
},
{
dataIndex: 'Exchangerate',
header: '汇率_商务',
width: 75,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'Exchangerate_Customs',
header: '汇率_海关',
width: 75,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'U_PRICE',
header: '单价(重量单位)',
width: 80,
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'U_weight',
header: '净重(重量单位)',
width: 80,
editor: {
xtype: 'numberfield',
allowDecimals: true,
decimalPrecision: 6,
selectOnFocus: true
}
},
{
dataIndex: 'price',
header: '单价(币别/kg)',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:60px;height:15px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},
{
dataIndex: 'weight',
header: '净重(kg)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:60px;height:15px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},
{
dataIndex: 'm_weight',
header: '毛重',
width: 50,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'BoxCount',
header: '箱/件数',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'BoxWeight',
header: '规格',
width: 50,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'price_agio',
header: '单价(差价价格)',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'price_limit',
header: '海关估价',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'AMOUNT_WRITEOFFS',
header: '申证金额',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:60px;height:15px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},
{
dataIndex: 'pay_Amount',
header: '合同金额',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:60px;height:15px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},
{
dataIndex: 'tax_Amount',
header: '完税价格',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'baolv',
header: '保率',
width: 55,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'Amount',
header: '合同金额(对客户)',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'PreProportion',
header: '付预付比例%',
width: 80,
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
}, {
dataIndex: 'RecProportion',
header: '收预付比例%',
width: 80,
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function (value) {
return "<a style=\"background-color:#B7B7B7\">" + value + "&nbsp;</a>";
}
},{
dataIndex: 'prepayments',
header: '预付款(应收)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'balance',
header: '尾款(应收)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'pay_prepayments',
header: '预付款(应付)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'pay_balance',
header: '尾款(应付)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'Paypart',
header: '付款方式',
renderer: function(value, p, record) {
if (value == null || value == '') return '';
else return record.data.paypartRef;
},
editor: this.comboxpaypart,
width: 50,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'tariff',
header: '关税类型',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'tax',
header: '关税税率',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'tax_cl',
header: '从量税率',
tooltip: '如从量税率不为零,则关税按照此标准(分/kg),而非关税税率进行计算',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function (value) {
return "<a style=\"background-color:#B7B7B7\">" + value + "&nbsp;</a>";
}
},
{
dataIndex: 'tax_zz',
header: '增值税税率',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'tax_1',
header: '关税(应收)',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 2
}
},
{
dataIndex: 'tax_zz_1',
header: '增值税(应收)',
width: 100,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 2
}
},{
dataIndex: 'tax_2',
header: '关税(应付)',
width: 100,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 2
}
},
{
dataIndex: 'tax_zz_2',
header: '增值税(应付)',
width: 100,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 2
}
},
{
dataIndex: 'Productiondate',
header: '生产日期',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
if (value == "") {
return "<a style=\"display:block;width:80px;height:17px;background-color:#FF0000\">&nbsp;</a>";
}
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
},
{
dataIndex: 'BZTCHNO',
header: '批次号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'Declarenumber',
header: '报关单号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},{
dataIndex: 'REMARK',
header: '备注',
width: 140,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'AGENCRATE',hidden:true,
header: '代理费率(元/吨)',
width: 80
}];
//表格
this.cellEditingCargo = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.cargoCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.formCargo = new Ext.grid.GridPanel({
store: this.storeCargo,
enableHdMenu: false,
layout: "border",
//region: 'center',
anchor: '100% 50%',
//collapsible: true,
margin: '0 0',
//height: 260,
//title: '商品信息',
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingCargo],
selModel: this.cargoCheckBoxModel,
selType: 'cellmodel',
tbar: [
'商品信息',
{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCargoClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCargoClick(button, event);
},
scope: this
}, {
text: "保存列表样式",
id: "btnsavelist",
handler: function (button, event) {
var tempcolumns = this.formCargo.columns;
DsTruck.SaveGridPanel(USERID, _this.FormName_1, tempcolumns,1);
},
scope: this
}],
columns: this.Cargocolumns
});
this.Cargocolumns= DsTruck.GetGridPanel(USERID, this.FormName_1, this.Cargocolumns);
//使用者id表名 中间column数组跳过一开始的几列
this.formCargo.reconfigure(this.storeCargo, this.Cargocolumns);
this.formCargo.addListener('cellclick', function(view, cell, cellIdx, record, row, rowIdx, eOpts) {
if(cellIdx === 4){
//alert(record.get('cargoinfo_id'));
//if (!record.get('cargoinfo_id')>=0) return;
var s=" cargoinfoid="+record.get('cargoinfo_id');
//alert(s);
this.storeCargociq.load({ params: { condition: s} });
}
}, this);
/* listeners: {
beforecellmousedown: function(view, cell, cellIdx, record, row, rowIdx, eOpts){
if(cellIdx === 1){
alert("dfd");
}
}
} */
//#endregion 明细<<<< 商品 >>>>结束
//#region 明细 <<<< 许可证使用 >>>>
//表参照 可用许可证
this.storeApp = Ext.create('DsExt.ux.RefTableStore', {
model: 'Appmb',
proxy: { url: '/Import/XXH/GetApp' }
});
this.comboxApp = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeApp,
name: 'app_id',
valueField: 'app_id',
displayField: 'info'
});
this.comboxCargo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCargo,
name: 'cargo_id',
valueField: 'id',
displayField: 'name'
});
this.storecancellation = Ext.create('DsExt.ux.RefEnumStore', {});
this.storecancellation.load({ params: { enumTypeId: 13} });
this.comboxcancellation = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '许可证使用',
store: this.storecancellation,
name: 'cancellation'
});
//结果集
this.storeAppstate = Ext.create('Ext.data.Store', {
model: 'Appstatemb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/XXH/GetAppstate',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.AppStatecolumns= [
{ hidden: true, dataIndex: 'id', header: 'id', width: 80 },
{ dataIndex: 'SEQUENCE', header: '序号', width: 40 },
{ hidden: true, dataIndex: 'ContractNo', header: 'ContractNo', width: 80 },
{
dataIndex: 'app_id',
header: '许可证号',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return "<a style=\"background-color:#B7B7B7\">"+record.data.appno+"&nbsp;</a>";
},
//editor: this.comboxApp,
width: 180
},
// { hidden: true, dataIndex: 'app_id', header: 'app_id', width: 80 },
{
dataIndex: 'name',
header: '商品手册名称',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
//this.comboxCargo,
{
dataIndex: 'cargo_id',
header: '货名',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return "<a style=\"background-color:#B7B7B7\">"+record.data.cargoname;+"&nbsp;</a>";
},
editor: this.comboxCargo,
width: 80
},
{
dataIndex: 'appweight',
header: '许可证额度(吨)',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'appremain',
header: '未核销(吨)',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'canbeused',
header: '未配证(吨)',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'country',
header: '进口国',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
},
{
dataIndex: 'weight',
header: '使用重量(吨)'
,editor: {
xtype: 'textfield',
selectOnFocus: true
}
},{
dataIndex: 'cancellation',
header: '许可证使用状态',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return "<a style=\"background-color:#B7B7B7\">"+record.data.cancellationRef+"&nbsp;</a>";
},
editor: this.comboxcancellation,
width: 100
},{
dataIndex: 'validdate',
header: '有效期',
width: 80,
renderer: function(value){
return "<a style=\"background-color:#B7B7B7\">"+value+"&nbsp;</a>";
}
}
]
this.cellEditingAppstate = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.formAppstate = new Ext.grid.GridPanel({
store: this.storeAppstate,
enableHdMenu: false,
//layout: "border",
region: 'center',
//height: 140,
title: '许可证使用 (注意,商品信息保存后才能选择使用许可证和商品)',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingAppstate],
selType: 'cellmodel',
tbar: [{
text: "保存列表样式",
id: "btnsavelist2",
handler: function (button, event) {
var tempcolumns = _this.formAppstate.columns;
DsTruck.SaveGridPanel(USERID, _this.FormName_2, tempcolumns,1);
},
scope: this
}],
columns: this.AppStatecolumns
});
this.AppStatecolumns= DsTruck.GetGridPanel(USERID, this.FormName_2, this.AppStatecolumns);
//使用者id表名 中间column数组跳过一开始的几列
this.formAppstate.reconfigure(this.storeAppstate, this.AppStatecolumns);
//#endregion
//#region 明细<<<< 单据表 >>>>
//单据表表格相关
//#region 单据表用 枚举参照
this.storePaymentMethods = Ext.create('DsExt.ux.RefEnumStore', {});
this.storePaymentMethods.load({ params: { enumTypeId: 4} });
this.comboxPaymentMethods = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '付款方式',
store: this.storePaymentMethods,
name: 'PaymentMethods'
});
this.storeReceiptid = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptid.load({ params: { enumTypeId: 2} });
this.comboxReceiptid = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeReceiptid,
name: 'Receiptid'
});
this.storeReceiptstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptstate.load({ params: { enumTypeId: 7} });
this.comboxReceiptstate = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeReceiptstate,
name: 'state'
});
//#endregion
//单据表-数据集
this.storeReceipt = Ext.create('Ext.data.Store', {
model: 'Receiptmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/XXH/GetReceiptList',
reader: {
id: 'id,ContractNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//单据表表格
this.cellEditingReceipt = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
// this.ReceiptGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListReceipt = new Ext.grid.GridPanel({
store: this.storeReceipt,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingReceipt],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddReceiptClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelReceiptClick(button, event);
},
scope: this
}/*, {
text: 'AA',
tooltip: 'AA',
handler: function (button, event) {
var selectedRecords = this.gridListReceipt.selModel.getSelection();
// alert(selectedRecords.length);
},
scope: this
}*/],
columns: [
{
sortable: true,
hidden: true,
dataIndex: 'id',
header: 'id',
width: 80
},
{
sortable: true,
hidden: true,
dataIndex: 'ContractNo',
header: 'ContractNo',
width: 80
},
{
sortable: true,
dataIndex: 'Receiptid',
header: '单据类型/名称',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.ReceiptName;
},
editor: this.comboxReceiptid,
width: 80
},
{
sortable: true,
dataIndex: 'ReceiptNo',
header: '单据编号',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'state',
header: '收发状态',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.statename;
},
editor: this.comboxReceiptstate,
width: 80
},
{
sortable: true,
dataIndex: 'Send_date',
header: '发出时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'receive_date',
header: '收到时间',
editor: {
xtype: 'datefield',
format: 'Y-m-d',
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
},
{
sortable: true,
dataIndex: 'repeat_date',
header: '回复时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-n-j'),
editor: {
format: 'Y-n-j',
xtype: 'datefield'
}
},
{
sortable: true,
dataIndex: 'trancer',
header: '快递公司',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'trancNo',
header: '快递号',
width: 80,
editor: {
xtype: 'textfield'
}
}
]
});
//#endregion
//#region 明细表 审单状态
//#region 明细表表格相关
this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} });
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeFeeTypeRef,
name: 'FeeType'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/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.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeCustomerNameRef.load({ params: { condition: "isnull(ISSTOP,0)=0"} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
name: 'CustomerName',
valueField: 'name',
displayField: 'codename'
});
Ext.define('ASmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ASName', type: 'string' }
]
});
var ASData = [{ "ASName": "NO" },
{ "ASName": "OK" }
];
this.storeAS = Ext.create('Ext.data.Store', {
model: 'ASmb',
data: ASData
});
this.comboxAS = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '收付类型',
forceSelection: true,
store: this.storeAS,
name: 'AUDITSTATUS',
valueField: 'ASName',
displayField: 'ASName'
});
this.storeAS2 = Ext.create('Ext.data.Store', {
model: 'ASmb',
data: ASData
});
this.comboxAS2 = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '收付类型',
forceSelection: true,
store: this.storeAS2,
name: 'AUDITSTATUS',
valueField: 'ASName',
displayField: 'ASName'
});
//#endregion
//明细表-数据集
this.storeAuditStatus = Ext.create('Ext.data.Store', {
model: 'AuditStatusmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/audit/GetAuditStatusList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeAuditStatusBody = Ext.create('Ext.data.Store', {
model: 'AuditStatusBodymb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/audit/GetAuditStatusBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.cellEditingAuditStatus_Body = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.AuditStatusBody_CBM = Ext.create('Ext.selection.CheckboxModel');
this.gridAuditStatus = new Ext.grid.GridPanel({
store: this.storeAuditStatus,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
viewConfig: {
autoFill: true
},
tbar: [/*{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, '2');
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '2');
},
scope: this
}, '-', {
text: '提交审核',
tooltip: '提交审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onSubmitAuditClick(button, event);
},
scope: this
}*/],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务序列号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'RECEIPTNAME',
header: '单据名称',
width: 66
}, {
sortable: true,
dataIndex: 'AUDITSTATUS',
header: 'CHECK 状态',
width: 45,
editor:this.comboxAS2,
renderer: function (value) {
if (value == "NO") {
return "<a><font color='#FF0000'>"+value+"</font></a>";
} else if (value == "OK") {
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
}
}, {
sortable: true,
dataIndex: 'CZSTATUS',
header: 'CORRECTION 修改明细',
width: 250
}, {
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: 'TIME 审单时间',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 100
}, {
sortable: true,
dataIndex: 'MODIFIEDUSER',
header: '审单人',
width: 66
}
]
});
this.gridAuditStatusBody = new Ext.grid.GridPanel({
store: this.storeAuditStatusBody,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingAuditStatus_Body],
selType: 'cellmodel',
selModel: this.AuditStatusBody_CBM,
viewConfig: {
autoFill: true
},
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.addAuditStatusBody(button, event);
},
scope: this
},{
// id: "saveandclose",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-', {
text: '删除明细',hidden:true,
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.deleteAuditStatusBody(button, event);
},
scope: this
}, '-', { xtype: "label", id: "ReceiptName", text: "",
handler: function () { ; }
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务序列号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'LINKID',
header: 'LINKID',
hidden: true,
width: 66
}, {
sortable: true,
dataIndex: 'AUDITSTATUS',
header: 'CHECK 状态',
editor:this.comboxAS,
width: 45,
renderer: function (value) {
if (value == "NO") {
return "<a><font color='#FF0000'>"+value+"</font></a>";
} else if (value == "OK") {
return "<a><font color='#0000FF'>"+value+"</font></a>";
}
}
}, {
sortable: true,
dataIndex: 'CZSTATUS',
header: 'CORRECTION 修改明细',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 250
}, {
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: 'TIME 审单时间',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
editor: {
xtype: 'datetimefield',
selectOnFocus: true
},
width: 100
}, {
sortable: true,
dataIndex: 'MODIFIEDUSER',
header: '审单人',
width: 66
}
]
});
//#endregion
//公共按钮Toolbar:panelBtn
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",disabled:true,id:"SAVE1",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
// id: "saveandclose",
text: "保存并关闭",disabled:true,id:"SAVE2",
handler: function (button, event) {
this.Save('1');
},
scope: this
},/*
{
// id: "saveandclose",
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},{
// id: "saveandclose",
text: "保存并新建类似合同",
handler: function (button, event) {
this.Save('3');
},
scope: this
}, */'-',
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "打印",
handler: function (button, event) {
this.Print();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
/* 3 */
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 32,
items: [this.panelBtn]//, this.formEdit]
});
this.panelBodyReceipt = new Ext.Panel({
title: '票据管理',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridListReceipt]
});
this.panelAuditStatusMain = new Ext.Panel({
title: 'DOCUMENTS 单据种类',
layout: "border",
region: 'west',
margin: '0 0',
split: true,
width: 540,
items: [this.gridAuditStatus]
});
this.panelAuditStatusBody = new Ext.Panel({
layout: "border",
region: 'center',
margin: '0 0',
//height: 450,
width: 450,
split: true,
items: [this.gridAuditStatusBody]
});
this.panelAuditStatus = new Ext.Panel({
//
layout: "border",
region: 'center',
margin: '0 0',
height: 600, //width: 450,
split: true,
items: [this.panelAuditStatusMain, this.panelAuditStatusBody]
});
this.panelformAppstate = new Ext.Panel({
// title: '货物信息和许可证使用',
//layout: "border",
//region: 'center',
layout: "border",
anchor: '100% 50%',
margin: '0 0',
//height: 320,
split: true,
//autoScroll: true,
items: [this.formAppstate]
});
this.panelCargoandApp = new Ext.Panel({
// title: '货物信息和许可证使用',
layout: "anchor",
region: 'center',
//margin: '3 3',
//height: 420,
autoScroll: true,
split: true,
items: [this.formCargo, this.panelformAppstate]
});
this.page_1 = new Ext.Panel({
title: "合同基础信息",
autoScroll: true,
layout: "border",
region: 'center',
autoScroll: true,
split: true,
items: [this.formEdit, this.panelCargoandApp]
});
this.page_2 = new Ext.Panel({
title: "票据管理",
items: [this.gridListReceipt]
});
this.page_3 = new Ext.Panel({
title: "审单状态",
//autoScroll: true,
layout: "border",
region: 'center',
items: [this.panelAuditStatus]
});
this.panelReceipt = new Ext.Panel({
layout: "border",
region: "center",
items: [this.panelBodyReceipt]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [this.page_1
, this.page_2
, this.page_3
]
})
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定编辑后事件
this.gridListReceipt.on('edit', function (editor, e, eOpts) {
this.ReceiptAfterEdit(editor, e, eOpts);
}, this);
this.formCargo.on('edit', function (editor, e, eOpts) {
this.CargoAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingCargo.on('beforeedit', function (editor, e) {
return this.CargoBeforeEdit(editor, e);
}, this);
this.formAppstate.on('edit', function (editor, e, eOpts) {
this.AppstateAfterEdit(editor, e, eOpts);
}, this);
/*
this.formKC.on('edit', function (editor, e, eOpts) {
this.KCAfterEdit(editor, e, eOpts);
}, this);*/
var _this=this;
Ext.getCmp("remark").on('render', function(c){
c.getEl().on('dblclick', function(){
//alert('double click test');
var Remark = _this.formEdit.getForm().findField('remark').getValue();
_this.formEdit.getForm().findField('remark').setValue("审单OK"+Remark);
});
});
this.gridAuditStatus.getSelectionModel().on('select', function (model, record, index) {
var BodyDirty=DsTruck.GetDirty(this.storeAuditStatusBody,this.AuditStatusBodyDel);
if (BodyDirty== true){
alert("请先保存再接换项目");
return;
}else{
var LINKID=record.data.GID;
this.AuditStatusGID=LINKID;
this.AuditRECEIPTNAME=record.data.RECEIPTNAME;
Ext.getCmp("ReceiptName").setText(" 审单项目: "+this.AuditRECEIPTNAME);
this.storeAuditStatusBody.load({ params: { condition: " LINKID='"+LINKID+"'"} });
}
}, this);
this.gridAuditStatusBody.on('edit', function (editor, e, eOpts) {
this.AuditStatusBodyAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
//#region 商品表的相关方法
onAddCargoClick: function (button, event) {
var TransactionMethod = this.formEdit.getForm().findField('TransactionMethod').getRawValue();
var baolv='1.000';
if (TransactionMethod=='CFR') {
baolv='1.003';
}
var _r=this.reLine();
var record = Ext.create('Cargomb', {
'id': '',
'ContractNo': '',
'cargoinfo_id': '',
'SEQUENCE': _r,
'name': '',
'price': '0',
'price_agio': '0',
'price_limit': '0',
'amount': '0',
'weight': '',
'Unit':'0',
'UnitRate':'1',
'BoxCount': '0',
'BoxWeight': '0',
'Exporter': '',
'FactoryNo': '',
'Productiondate': '',
'baolv':'1.000',
'tax':'0.0',
'tax_zz':'0.0',
'Unit':'0',
'currid':'740DF21C-BDE4-4C3E-A258-683A183AD3B4',
'UnitRef':'KG',
'codename':'USD',
'Exchangerate':'6.15'
});
this.storeCargo.add(record);
var n = this.storeCargo.getCount();
this.cellEditingCargo.startEditByPosition({ row: n - 1, column: 2 });
},
onDelCargoClick: function (button, event) {
var selectedRecords = this.formCargo.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
var _Used=0;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var cargo_id=rec.data.id;
if (cargo_id==""||cargo_id==null){
//continue;
}else{
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/CommMng/BasicDataRef/GeneralSelect',
scope: this,
async:false,
params: {condition: "select Count(*) GVALUE,'' as GID from Import_appstate where isnull(cancellation,0)=0 and cargo_id="+cargo_id+" "} ,
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
var result = Ext.JSON.decode(response.responseText);
_Used=parseFloat(result.data[0].GVALUE);
}
});
}
if (parseFloat( _Used)>0){
alert("此商品已配证,不能删除");
}else{
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CargoDel.push(rec);
}
this.storeCargo.remove(selectedRecords[i]);
}
}
var _r=this.reLine();
}
}, this);
},
reLine: function (button, event) {
var _L=1;
this.storeCargo.each(function(record) {
var ln=_L+"";
_L=_L+1;
record.set('SEQUENCE',ln);
});
},
onKCStartClick: function (button,event){//初始化库存,
Ext.MessageBox.confirm('提示', '这将会清空该货物的所有库存重新开始记录。确定初始化库存吗?', function (btn) {
if (btn == 'yes') {
var selectedRecords = this.formCargo.selModel.getSelection();
if (selectedRecords.length==0){
alert('请选择至少一条商品记录');
return;
}
var cargoidlist='';
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (i==0) {
cargoidlist=rec.get('id');
}
else {
cargoidlist=cargoidlist+','+rec.get('id');
}
}
Ext.Ajax.request({//
waitMsg: '正在初始化库存数据...',
url: '/Import/XXH/KCStart',
params: {
cargo_id: cargoidlist
},
callback: function (_count) {
//alert('初始化完成');
//重新load库存表的store
this.storeKC.load({ params: { condition: this.editRecord.get('ContractNo')} });
},
scope: this
});//request over
}
}, this);//确认窗口over
},
onbtnCWStartClick: function(button, event) { //初始化应收应付,
Ext.MessageBox.confirm('提示', '这将会在应收应付列表增加一些内容,如不保存就不会真正增加。确定吗?',
function(btn) {
if (btn == 'yes') {
// addChFee: function(FeeType,Currency,FeeName,price,Quantity)
/* var selectedRecords = this.formCargo.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?',
function(btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
alert(rec.ContractNo);
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CargoDel.push(rec);
}
this.storeCargo.remove(selectedRecords[i]);
}
}
},
this);*/
var selectedRecords = this.formCargo.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.addChFee(1,rec.get('codename'),'预付款',rec.get('prepayments'),1,'单价'+rec.get('price')+'*重量'+rec.get('weight')+'='+rec.get('Amount'));
this.addChFee(1,rec.get('codename'),'尾款',rec.get('balance'),1,'');
this.addChFee(2,rec.get('codename'),'预付款',rec.get('prepayments'),1,'');
var Buybalance=parseFloat(rec.get('pay_Amount'))-parseFloat(rec.get('prepayments'))
this.addChFee(2,rec.get('codename'),'尾款',Buybalance,1,'差价'+rec.get('price_agio')+' 付贸易商购货款'+rec.get('pay_Amount'));
this.addChFee(1,'RMB','代理费',300,(rec.get('weight')/1000).toFixed(4));
this.addChFee(1,'RMB','THC',1280,1);
this.addChFee(1,'RMB','拖车费',1400,1);
this.addChFee(1,'RMB','验货费',620,1);
//var tax=parseFloat(rec.get('tax_Amount'))*parseFloat(rec.get('tax'));
var priceandtax=parseFloat(rec.get('tax_Amount'))*(1+parseFloat(rec.get('tax')));
var tax=parseFloat(rec.get('tax_Amount'))*(parseFloat(rec.get('tax')));
this.addChFee(1,rec.get('codename'),'关税',rec.get('tax_Amount'),rec.get('tax'),'海关估价'+rec.get('price_limit')+' 完税价格'+rec.get('tax_Amount'));
this.addChFee(1,rec.get('codename'),'增值税',priceandtax.toFixed(2),rec.get('tax_zz'),'完税价格'+rec.get('tax_Amount')+'+关税'+tax.toFixed(2)+'='+priceandtax.toFixed(2));
this.addChFee(2,rec.get('codename'),'关税',rec.get('tax_Amount'),rec.get('tax'));
this.addChFee(2,rec.get('codename'),'增值税',priceandtax.toFixed(2),rec.get('tax_zz'));
}
/*
//alert(this.editRecord.get('ContractNo'))
Ext.Ajax.request({ //
waitMsg: '正在初始化应收应付...',
url: '/Import/XXH/CWStart',
params: {
ContractNo: this.editRecord.get('ContractNo')
},
callback: function(_count) {
//alert('初始化完成');
//重新load库存表的store
this.storeBodyChFee.load({
params: {
billno: this.editRecord.get('ContractNo')
}
});
},
scope: this
}); //request over
*/
}
},
this); //确认窗口over
},
addChFee: function(FeeType,Currency,FeeName,price,Quantity,Remark) {
var _CustomerName='';
if (FeeType==1)
{
var _FeeType=1;
var _FeeType_Ref='应收';
_CustomerName=this.getCustName();
}
else {
var _FeeType=2;
var _FeeType_Ref='应付';
_CustomerName=this.getSellerName();
if (FeeName=='关税'||FeeName=='增值税'){_CustomerName='报关行';}
//CustomerName: this.formEdit.getForm().findField('seller');
};
//var _Amount=price*Quantity;
var _Amount=0;
record = Ext.create('MsChFee', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: _FeeType,
FeeType_Ref: _FeeType_Ref,
FeeName: FeeName,
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: _CustomerName,
//this.formEdit.getForm().findField('buyer');
CustomerName_Ref: '',
Unit: '',
price: 0,
UnitPrice: price,
Quantity: Quantity,
Amount: _Amount,
Currency: Currency,
ExChangerate: 1,
Reason: '',
Remark: Remark,
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
EnterDate: null,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
this.storeBodyChFee.add(record);
},
CargoAfterEdit: function(editor, e, eOpts) {
//if (e.value==e.originalValue){return;}
function decimal(str,length){
var _r=round2(str,length);
return(_r);
}
var _this=this;
var cargo_id = e.record.get('id');
APPUsing=0;
if (cargo_id==""||cargo_id==null)
{}
else
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/UseApproval/Getused',
scope: this,
async:false,
params: {cargo_id: cargo_id },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
this.APPUsing=parseFloat(returnData.Count);
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
var HSCODE=e.record.get('cicode');
if (e.field == 'weight'){
_weight=parseFloat(e.value);
_APPUsing = Mul(this.APPUsing,1000,2);
if (_weight>_APPUsing && _APPUsing>0 ) {//
alert("重量大于许可证用证重量:"+ this.APPUsing);
e.record.set('weight', e.originalValue);
return;
}
}
if ((e.field == 'name'||e.field == 'Ename')&&this.APPUsing>0){
var cicode=e.record.get('cicode');
if (cicode=="0203290090" ){
alert("HS代码0203290090的商品配证后不能修改品名");
canedit=false;
}else{
//canedit=true;
}
}
if (e.field == 'Exchangerate' && e.record.get('Exchangerate_Customs') == 0) {
e.record.set('Exchangerate_Customs', parseFloat(e.record.get('Exchangerate')))
}
if (e.field == 'Unit') {
var U_weight = parseFloat(e.record.get('U_weight'));
var Unitrecords = DsStoreQueryBy(this.storeUnit, 'EnumValueId', e.value);
if (Unitrecords.getCount() > 0) {
var Unitdata = Unitrecords.getAt(0).data;
e.record.set('UnitRef', Unitdata.EnumValueName);
if (Unitdata.EnumValueName == '磅') {
e.record.set('UnitRate', '0.4535970244035199');
var weight = Mul(U_weight,0.4535970244035199);
e.record.set('weight', weight);
}
if (Unitdata.EnumValueName == '吨') {
e.record.set('UnitRate', '1000');
var weight = Mul(U_weight,1000);
e.record.set('weight', weight);
}
if (Unitdata.EnumValueName == 'KG') {
e.record.set('UnitRate', '1');
var weight = Mul(U_weight,1);
e.record.set('weight', weight);
}
} else {
e.record.set('UnitRef', '');
e.record.set('UnitRate', '1');
}
}
if (e.field == 'U_weight'||e.field == 'U_PRICE') {
if (parseFloat(e.value)==0){
return;
}
var U_weight = parseFloat(e.record.get('U_weight'));
var U_PRICE = parseFloat(e.record.get('U_PRICE'));
var UnitRate = parseFloat(e.record.get('UnitRate'));
//if (e.record.get('Unit') != '1') {//不是磅
var weight = Mul(U_weight,UnitRate);
//decimal(U_weight * UnitRate, 2);
e.record.set('weight', weight);
var price = Div(U_PRICE,UnitRate,4);
e.record.set('price', price);
}
if (e.field == 'Unit'||e.field == 'U_weight'||e.field == 'weight'||e.field == 'BoxCount'){
//计算规格 只舍不进
var BoxCount=e.record.get('BoxCount');
var weight=e.record.get('weight');
var _boxcount=Div(weight,BoxCount,0);
if (parseFloat(_boxcount)>Div(weight,BoxCount,2)){
_boxcount=Cut(_boxcount,1,0);
}else{
}
e.record.set('BoxWeight', _boxcount);
}
if (e.field == 'currid') {
//alert(e.field);
var currrecords = DsStoreQueryBy(this.storecurr, 'gid', e.value);
if (currrecords.getCount() > 0) {
var currdata = currrecords.getAt(0).data;
e.record.set('codename', currdata.codename);
//e.record.set('Exchangerate', currdata.DEFRATE);
} else {
e.record.set('codename', '');
}
}
//price price_agio price_limit weight baolv
//单价 差价 估价 净重 保率
//amount tax_amount pax_amount
//合同金额 完税价格 购货价
if (e.field == 'price' || e.field == 'price_agio' || e.field == 'price_limit' || e.field == 'baolv' ||e.field == 'U_weight'||e.field == 'U_PRICE'
|| e.field == 'weight' || e.field == 'Exchangerate' || e.field == 'Exchangerate_Customs' || e.field == 'tax' || e.field == 'tax_zz' || e.field == 'tax_cl'||e.field == 'Unit') {
/*if (tax_CL > 0) {
isChicken = true;
var priceandtax = Mul(tax_amount, Exchangerate_Customs) + Div(Mul(weight, tax_CL), 1000);
var tax_1 = Div(Mul(weight, tax_CL), 1000);
var tax_zz_1 = Mul(priceandtax, tax_zz);
var tax_2 = tax_1;
var tax_zz_2 = tax_zz_1;
}*/
var UNIT= e.record.get('UnitRef');
if (UNIT!='磅') {
var price = parseFloat(e.record.get('price'));
var price_agio = parseFloat(e.record.get('price_agio'));
var price_limit = parseFloat(e.record.get('price_limit'));
var baolv = parseFloat(e.record.get('baolv'));
var weight = parseFloat(e.record.get('weight'));
if (price_agio==0){
var amount = Mul(weight,price);} //Mul(price_limit,weight,baolv,2)
else {amount = Mul(weight,price_agio);} //amount=对国内客户的合同金额
var amount_writeoffs=Mul(weight,price);
//get_tax_amount 用于向客户收税金的完税价格
//tax_amount 用于向海关交税金的完税价格
if (price_limit != 0 && price_limit > price) {
var tax_amount = Mul3(price_limit,weight,baolv,2);
if (price_agio!=0 && price_limit>price_agio){//海关限价最高
var get_tax_amount=tax_amount;
}else{var get_tax_amount= Mul3(price_agio,weight,baolv,2);}//差价(对国内客户)高于限价
} else {
var tax_amount = Mul3(price,weight,baolv,2);
if (price_agio!=0 ){
var get_tax_amount=Mul3(price_agio,weight,baolv,2);
}else{var get_tax_amount= tax_amount;}//差价(对国内客户)高于限价
}
var pay_amount = Mul(weight,price);//贸易商价格x重量x单价
e.record.set('Amount', amount);
e.record.set('tax_Amount', tax_amount);
e.record.set('pay_Amount', pay_amount);
}
else{
var U_weight = parseFloat(e.record.get('U_weight'));
var U_PRICE = parseFloat(e.record.get('U_PRICE'));
var UnitRate = parseFloat(e.record.get('UnitRate'));
//var weight = Mul(U_weight,UnitRate);
var weight = parseFloat(e.record.get('weight'));
//e.record.set('weight', weight);
var price = parseFloat(e.record.get('price'));
var price_agio = parseFloat(e.record.get('price_agio'));
var price_limit = parseFloat(e.record.get('price_limit'));
var baolv = parseFloat(e.record.get('baolv'));
var amount = Mul(U_weight,U_PRICE);
var amount_writeoffs=Mul(weight,price);
var tax_amount =0;
var pay_amount=Mul(U_weight,U_PRICE);
var UNIT= e.record.get('UnitRef');
if ((UNIT=='磅')&&(price_agio==0)) {
if (price_limit != 0 && price_limit > (price)) {
tax_amount = Mul3(price_limit,weight,baolv,2);
} else {
tax_amount = Mul3(U_weight,U_PRICE,baolv,2);
}
//var pay_amount = Mul(U_weight,U_PRICE);
}else{
if (price_limit != 0 && price_limit > price_agio) {
tax_amount = Mul3(price_limit,weight,baolv,2);
} else {
tax_amount = Mul3(U_weight,U_PRICE,baolv,2);
}
if (price_agio>price)
{
amount = Mul(weight,price_agio);
//pay_amount = Mul(U_weight,U_PRICE);
}else{
//amount = Mul(U_weight,U_PRICE);
//pay_amount = Mul(U_weight,U_PRICE);
}
}
e.record.set('Amount', amount);
e.record.set('AMOUNT_WRITEOFFS',amount_writeoffs);
e.record.set('tax_Amount', tax_amount);
e.record.set('pay_Amount', pay_amount);
amount=parseFloat(e.record.get('Amount'));
tax_amount=parseFloat(e.record.get('tax_Amount'));
pay_amount=parseFloat(e.record.get('pay_Amount'));
}
//if (amount>tax_amount){tax_amount=amount;}//确保tax_amount为给客户显示并使用的完税价格
var tax = parseFloat(e.record.get('tax'));//关税税率
var tax_zz = parseFloat(e.record.get('tax_zz'));//增值税税率
var tax_cl = parseFloat(e.record.get('tax_cl'));//从量税率 20190929
var Exchangerate_Customs = e.record.get('Exchangerate_Customs');//海关汇率
var HS = e.record.get('cicode');
var isChicken = false;
var ChickenTax = parseFloat('0.0');
if (tax_cl>0) {
isChicken = true;
ChickenTax = tax_cl;
}
if (isChicken) {
//Mul(weight,price);
var priceandtax = Mul(tax_amount, Exchangerate_Customs) + Div(Mul(weight,ChickenTax),100);
var tax_1 = Div(Mul(weight,ChickenTax),100);//因为从量税是分每千克 关税乘完要除以100
var tax_zz_1 = Mul(priceandtax,tax_zz);
var tax_2 = tax_1;
var tax_zz_2 = tax_zz_1;
} else {
var priceandtax =Mul(tax_amount,(1.0 + tax)); //完税价格x(1+关税税率)=含关税价格
//应付的
var tax_2 =Mul3(tax_amount,tax,Exchangerate_Customs,2); //关税
var tax_zz_2 =Mul4(tax_amount,(1.0 + tax) ,tax_zz,Exchangerate_Customs); //decimal(tax_amount * (1.0 + tax) * tax_zz * Exchangerate_Customs,2); //增值税
//向客户收取的
var weight = parseFloat(e.record.get('weight'));
var price_agio = parseFloat(e.record.get('price_agio'));
if (price_agio != 0 && price_agio>price_limit){//如果“差价(对国内客户价格)”不为零而且高于限价 关税的完税价格依据差价价格计算
var tax_1 = Mul3(Mul3(weight,price_agio,baolv),tax,Exchangerate_Customs); //应收关税
var tax_zz_1 = Mul4(Mul3(weight,price_agio,baolv),(1.0 + tax),tax_zz,Exchangerate_Customs);//应收增值税
}else
{
var tax_1 = tax_2;
var tax_zz_1 = tax_zz_2;
}
}
e.record.set('tax_1', tax_1);
e.record.set('tax_zz_1', tax_zz_1);
e.record.set('tax_2', tax_2);
e.record.set('tax_zz_2', tax_zz_2);
var prepayments = parseFloat(parseFloat( e.record.get('prepayments')).toFixed(2));
var balance = Cut(amount,prepayments);
e.record.set('balance', balance);
var pay_prepayments = parseFloat(parseFloat( e.record.get('pay_prepayments')).toFixed(2));
var pay_balance = Cut(pay_amount,pay_prepayments);
e.record.set('pay_balance', pay_balance);
}
if (e.field == 'prepayments'||e.field == 'Amount') {
//alert(e.field);
var prepayments = e.record.get('prepayments');
var Amount = e.record.get('Amount');
var balance = Cut(Amount,prepayments);
e.record.set('balance', balance);
}
if (e.field == 'pay_prepayments'||e.field == 'pay_Amount') {
//alert(e.field);
var pay_prepayments = e.record.get('pay_prepayments');
var pay_Amount = e.record.get('pay_Amount');
var pay_balance = Cut(pay_Amount,pay_prepayments);
e.record.set('pay_balance', pay_balance);
}
if (e.field == 'PreProportion') {
//alert(e.field);
var Amount = parseFloat(e.record.get('Amount'));
var prepayments = round2(Amount * parseFloat(e.record.get('PreProportion')) * 0.01, 2);
var balance = Amount - prepayments;
e.record.set('pay_prepayments', prepayments);
e.record.set('pay_balance', balance);
}
if (e.field == 'RecProportion') {
//alert(e.field);
var Amount = parseFloat(e.record.get('Amount'));
var prepayments = round2(Amount * parseFloat(e.record.get('RecProportion')) * 0.01, 2);
var balance = Amount - prepayments;
e.record.set('prepayments', prepayments);
e.record.set('balance', balance);
}
/*
if (e.field == 'name') {
var CargoNamerecords = DsStoreQueryBy(this.storeCargoName, 'CNNAME', e.value);
if (CargoNamerecords.getCount() > 0) {
var CargoNamedata = CargoNamerecords.getAt(0).data;
e.record.set('Ename', CargoNamedata.ENNAME);
} else {
//e.record.set('Ename', '');
}
}
if (e.field == 'Ename') {
var CargoNamerecords = DsStoreQueryBy(this.storeCargoName, 'ENNAME', e.value);
if (CargoNamerecords.getCount() > 0) {
var CargoNamedata = CargoNamerecords.getAt(0).data;
e.record.set('name', CargoNamedata.CNNAME);
} else {
//e.record.set('name', '');
}
}
if (e.field == 'Ename'|| e.field == 'name') {
//带出HS代码 CIQ代码 申报要素 税率
var CargoNamerecords = "";
if (e.field == 'Ename'){CargoNamerecords=DsStoreQueryBy(this.storeCargoName, 'ENNAME', e.value);}
if (e.field == 'name'){CargoNamerecords=DsStoreQueryBy(this.storeCargoName, 'CNNAME', e.value);}
if (CargoNamerecords.getCount() > 0) {
var CargoNamedata = CargoNamerecords.getAt(0).data;
if (CargoNamedata.HS_ID!="" && CargoNamedata.HS_ID!= undefined){
e.record.set('cargoinfo_id', CargoNamedata.HS_ID);
Cargoinforecords = DsStoreQueryBy(this.storeCargoinfo, 'id', CargoNamedata.HS_ID);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('cicodeandname', Cargoinfodata.codeandname);
e.record.set('tariff', Cargoinfodata.tariff);
e.record.set('tax', Cargoinfodata.tax);
e.record.set('tax_zz', Cargoinfodata.tax_zz);
e.record.set('CargoType', Cargoinfodata.CARGOTYPE);
}else {
e.record.set('ciqcodeandname', '');
}
}
if (CargoNamedata.CIQ_ID!="" && CargoNamedata.CIQ_ID!= undefined){
e.record.set('cargociq_id', CargoNamedata.CIQ_ID);
var Cargociqrecords = DsStoreQueryBy(this.storeCargociq, 'id', CargoNamedata.CIQ_ID);
if (Cargociqrecords.getCount() > 0) {
var Cargociqdata = Cargociqrecords.getAt(0).data;
e.record.set('ciqcodeandname', Cargociqdata.codeandname);
} else {
e.record.set('ciqcodeandname', '');
}
}
e.record.set('SBYS', CargoNamedata.SBYS);
} else {
//e.record.set('name', '');
}
}*/
if (e.field == 'name') {
var CargoNamerecords = DsStoreQueryBy(this.storeCargoName, 'CNNAME', e.value);
if (CargoNamerecords.getCount() > 0) {
var _CNRec = CargoNamerecords.getAt(0).data;
var _this=this;
//1 载入Ename
this.storeCargoName_EN.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " CNNAME='"+e.value+"'"}
});
//2 载入HS代码
var FactoryNo = e.record.get('FactoryNo');
var name = e.record.get('name');
if ((FactoryNo=="" || FactoryNo==null)&&(name!="" && name!=null)){
//如果没选厂号 选了中文品名
//根据品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where CNNAME='"+name+"')"
/*
this.storeCargoinfo.load({ params: { condition: s}
,
callback: function (options, success, response) {
if (success) {
if (_this.storeCargoinfo.getCount()==1){
var rec = _this.storeCargoinfo.getAt(0).data;
e.record.set('cargoinfo_id', rec.id);
e.record.set('cicodeandname', rec.codeandname);
e.record.set('cargociq_id', _CNRec.CIQ_ID);
e.record.set('ciqcodeandname', _CNRec.CIQREF);
e.record.set('tariff', rec.tariff);
e.record.set('tax', rec.tax);
e.record.set('tax_zz', rec.tax_zz);
e.record.set('CargoType', rec.CARGOTYPE);
e.record.set('Ename', _CNRec.ENNAME);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
*/
}
if ((FactoryNo!="" && FactoryNo!=null)&&(name!="" && name!=null)){
//如果选了厂号 选了中文品名
//根据厂号和品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where CNNAME='"+name+"' and FactoryNoGID in(select GID from Import_Factoryno where FactoryNo='"+FactoryNo+"')) "
/*
this.storeCargoinfo.load({ params: { condition: s}
,
callback: function (options, success, response) {
if (success) {
if (_this.storeCargoinfo.getCount()==1){
var rec = _this.storeCargoinfo.getAt(0).data;
e.record.set('cargoinfo_id', rec.id);
e.record.set('cicodeandname', rec.codeandname);
e.record.set('cargociq_id', _CNRec.CIQ_ID);
e.record.set('ciqcodeandname', _CNRec.CIQREF);
e.record.set('tariff', rec.tariff);
e.record.set('tax', rec.tax);
e.record.set('tax_zz', rec.tax_zz);
e.record.set('CargoType', rec.CARGOTYPE);
e.record.set('Ename', _CNRec.ENNAME);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
*/
}
} else {
//e.record.set('Ename', '');
}
}
if (e.field == 'FactoryNo') {
var FactoryNo = e.record.get('FactoryNo');
var name = e.record.get('name');
if ((FactoryNo!="" && FactoryNo!=null)&&(name!="" && name!=null)){
//如果选了厂号 选了中文品名
//根据厂号和品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where CNNAME='"+name+"' and FactoryNoGID in(select GID from Import_Factoryno where FactoryNo='"+FactoryNo+"')) "
/*
this.storeCargoinfo.load({ params: { condition: s}
,
callback: function (options, success, response) {
if (success) {
if (_this.storeCargoinfo.getCount()==1){
var rec = _this.storeCargoinfo.getAt(0).data;
e.record.set('cargoinfo_id', rec.id);
e.record.set('cicodeandname', rec.codeandname);
e.record.set('cargociq_id', _CNRec.CIQ_ID);
e.record.set('ciqcodeandname', _CNRec.CIQREF);
e.record.set('tariff', rec.tariff);
e.record.set('tax', rec.tax);
e.record.set('tax_zz', rec.tax_zz);
e.record.set('CargoType', rec.CARGOTYPE);
e.record.set('Ename', _CNRec.ENNAME);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
*/
}
}
if (this.APPUsing>0 && e.record.get('cicode')!=HSCODE){
alert("注意已配证商品的HS代码发生了改变请确认你的修改并及时通知单证部门");
}
/*
if (e.field == 'Ename') {
var CargoNamerecords = DsStoreQueryBy(this.storeCargoName_EN, 'ENNAME', e.value);
if (CargoNamerecords.getCount() > 0) {
var _this=this;
//1 载入Ename
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " ENNAME='"+e.value+"'"}
});
//2 载入HS代码
var FactoryNo = e.record.get('FactoryNo');
var Ename = e.record.get('Ename');
if ((FactoryNo=="" || FactoryNo==null)&&(Ename!="" && Ename!=null)){
//如果没选厂号 选了中文品名
//根据品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where ENNAME='"+Ename+"')"
this.storeCargoinfo.load({ params: { condition: s}
,
callback: function (options, success, response) {
if (success) {
if (_this.storeCargoinfo.getCount()==1){
var rec = _this.storeCargoinfo.getAt(0).data;
e.record.set('cargoinfo_id', rec.id);
e.record.set('cicodeandname', rec.codeandname);
e.record.set('tariff', rec.tariff);
e.record.set('tax', rec.tax);
e.record.set('tax_zz', rec.tax_zz);
e.record.set('CargoType', rec.CARGOTYPE);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
if ((FactoryNo!="" && FactoryNo!=null)&&(Ename!="" && Ename!=null)){
//如果选了厂号 选了中文品名
//根据厂号和品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where ENNAME='"+Ename+"' and FactoryNoGID in(select GID from Import_Factoryno where FactoryNo='"+FactoryNo+"')) "
this.storeCargoinfo.load({ params: { condition: s}
,
callback: function (options, success, response) {
if (success) {
if (_this.storeCargoinfo.getCount()==1){
var rec = _this.storeCargoinfo.getAt(0).data;
e.record.set('cargoinfo_id', rec.id);
e.record.set('cicodeandname', rec.codeandname);
e.record.set('tariff', rec.tariff);
e.record.set('tax', rec.tax);
e.record.set('tax_zz', rec.tax_zz);
e.record.set('CargoType', rec.CARGOTYPE);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
//e.record.set('Ename', '');
}
}*/
},
CargoBeforeEdit: function (editor, e) {
var cargo_id = e.record.get('id');
if (cargo_id=='') {cargo_id=-1;}
var canedit=true;
this.APPUsingCount=0;
if (e.field == 'cargociq_id'){
//20150112
var cargoinfoid=e.record.get('cargoinfo_id');
var s=" cargoinfoid="+cargoinfoid;
this.storeCargociq.load({ params: { condition: s} });
}
if (e.field == 'FactoryNo'){
if (e.record.get('Exporter')==""){
//canedit=false;
//alert("请先选择出口商!");
}else{
//this.storeFactoryNo.load({ params: { condition: " CLIENTGID=(select gid from info_client where shortname='"+e.record.get('Exporter')+"') "} });
}
}
if (e.field == 'name'){
if (e.record.get('FactoryNo')==""||e.record.get('FactoryNo')==null){
this.storeCargoName.load({
params: { start: 0, limit: 5000, sort: '',condition: "HS_ID="+e.record.get('cargoinfo_id') }
,
callback: function (options, success, response) {
if (success) {
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
//this.FactoryNo=e.record.get('FactoryNo');
}else{
//if (this.FactoryNo!=e.record.get('FactoryNo'))
{
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='"+e.record.get('FactoryNo')+"') and HS_ID="+e.record.get('cargoinfo_id')+" "} //
});
this.FactoryNo=e.record.get('FactoryNo');
}
}
}
if (e.field == 'Ename'){
if (e.record.get('FactoryNo')==""){
this.storeCargoName_EN.load({ params: {
start: 0, limit: 5000, sort: '',
condition: ""}
});
//this.FactoryNo=e.record.get('FactoryNo');
}else{
//if (this.FactoryNo!=e.record.get('FactoryNo'))
{
this.storeCargoName_EN.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='"+e.record.get('FactoryNo')+"') and HS_ID="+e.record.get('cargoinfo_id')+" "} //
});
this.FactoryNo=e.record.get('FactoryNo');
}
}
}
if (e.field == 'SPECIFICATIONS') {
var cicode = e.record.get('cicode');
if (cicode == "0203290090" || cicode == "0306120000" || cicode == "03051900" || cicode == "0306171900" || cicode == "0306172900") {
//alert("只有HS代码为0203290090的商品才能修改规格");
if (this.APPUsingCount > 0) {
canedit = true;
}
} else {
canedit = false;
}
}
if (e.field == 'cargoinfo_id'){
var FactoryNo = e.record.get('FactoryNo');
var name = e.record.get('name');
if ((FactoryNo=="" || FactoryNo==null)&&(name!="" && name!=null)){
//如果没选厂号 选了中文品名
//根据品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where CNNAME='"+name+"')"
this.storeCargoinfo.load({ params: { condition: s} });
}else
if ((FactoryNo!="" && FactoryNo!=null)&&(name!="" && name!=null)){
//如果选了厂号 选了中文品名
//根据厂号和品名确定范围
var s=" countryid='"+this.formEdit.getForm().findField('countryid').getValue()+"'";
s=s+" and ci.id in(select hs_id from Import_Cargoname where CNNAME='"+name+"' and FactoryNoGID in(select GID from Import_Factoryno where FactoryNo='"+FactoryNo+"')) "
this.storeCargoinfo.load({ params: { condition: s} });
}else{
this.storeCargoinfo.load({ params: { condition: ""} });
}
}
if (e.field == 'Exchangerate' || e.field == 'Exchangerate_Customs' || e.field == 'currid')
{
//商务汇率 编辑前载入汇率 但只载入一次
//如果不同商品使用不同币别,则会有错误隐患
if (this.storeExchangerate.getCount() == 0) {
this.storeExchangerate.load({
params: {
Date: currdate.format('yyyy-MM-dd'),
Currency: USDGID //传入币别GID
}
});
}
//海关汇率
if (this.storeExchangerate2.getCount() == 0) {
data = this.formEdit.getForm().getValues();
this.storeExchangerate2.load({
params: {
Date: data.ArrivalDate,
Currency: USDGID //传入币别GID
}
});
}
}
return canedit;
},
//#endregion 明细表<<<商品>>>的相关方法
//#region <<<许可证使用>>>明细表相关方法
onAddAppstateClick: function (button, event) {
var record = Ext.create('Appstatemb', {
'id': '',
'appno': '',
'cargoinfo_id': '',
'app_id': '',
'name': ' ',
'cargo_id': ' ',
'cargoname': ' ',
'appweight': '0 ',
'appremain': ' ',
'country': ' ',
'ValidDate': '',
'weight': '',
'info': ''
});
this.storeAppstate.add(record);
var n = this.storeAppstate.getCount();
this.cellEditingAppstate.startEditByPosition({ row: n - 1, column: 2 });
},
onDelAppstateClick: function (button, event) {
var selectedRecords = this.formAppstate.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
// alert(rec.ContractNo);
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.AppstateDel.push(rec);
}
//alert(i);
this.storeAppstate.remove(selectedRecords[i]);
}
},
AppstateAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'weight') {
var cargoweight=0;
var cargoweight_S="";
var cargo = DsStoreQueryBy(this.storeCargo, 'id', e.record.get('cargo_id'));
if (cargo.getCount() > 0) {
var cargodata = cargo.getAt(0).data;
cargoweight_S=cargodata.weight;
} else {
cargoweight_S="";
}
if (cargoweight_S=="") {cargoweight=0;}
else {
var _start=cargoweight_S.indexOf("重量:");
cargoweight_S=cargoweight_S.substr(_start+3);
cargoweight=parseFloat(cargoweight_S);
}
if (parseFloat(e.value)-cargoweight>1 ) {//
alert("许可证使用数量超过货物重量1吨以上请确认许可证使用数量:"+ e.value);
}else if (parseFloat(e.value)<cargoweight ) {
alert("请注意,货物重量"+ cargoweight_S + " 大于许可证使用数量:"+ e.value);
}
var canbeused=parseFloat(e.record.get('canbeused'));
if (parseFloat(e.value)-parseFloat(e.originalValue)>canbeused ){
alert("此次许可证新增使用数量"+ (parseFloat(e.value)-parseFloat(e.originalValue))+" 超过未配证数量:"+canbeused+",请认真核对");
return;
}
if (parseFloat(e.value)==0 ){
alert("配证重量不允许为0");
e.record.set('weight', e.originalValue);
return;
}
}
_this = this;
if (e.field == 'app_id') {
var apprecords = DsStoreQueryBy(this.storeApp, 'app_id', e.value);
if (apprecords.getCount() > 0) {
currcompany = this.formEdit.getForm().findField('company').getValue();
var appdata = apprecords.getAt(0).data;
if (appdata.company != currcompany) {
Ext.MessageBox.confirm('提示', '选用这个许可证将会更改用证公司,确定吗?', function (btn) {
if (btn == 'yes') {
e.record.set('app_id', appdata.app_id);
e.record.set('appno', appdata.appno);
e.record.set('name', appdata.name);
e.record.set('appweight', appdata.appweight);
e.record.set('appremain', appdata.appremain);
e.record.set('country', appdata.country);
e.record.set('validdate', appdata.validdate);
e.record.set('canbeused', appdata.canbeused);
_this.storeCompany.load();
_this.formEdit.getForm().findField('company').setValue(appdata.company);
} else { return; }
});
} else {
var appdata = apprecords.getAt(0).data;
e.record.set('app_id', appdata.app_id);
e.record.set('appno', appdata.appno);
e.record.set('name', appdata.name);
e.record.set('appweight', appdata.appweight);
e.record.set('appremain', appdata.appremain);
e.record.set('country', appdata.country);
e.record.set('validdate', appdata.validdate);
e.record.set('canbeused', appdata.canbeused);
}
} else {
e.record.set('name', ' ');
e.record.set('appweight', ' ');
e.record.set('appremain', ' ');
e.record.set('country', ' ');
e.record.set('validdate', ' ');
}
}
if (e.field == 'cargo_id') {
var cargo = DsStoreQueryBy(this.storeCargo, 'id', e.value);
if (cargo.getCount() > 0) {
var cargodata = cargo.getAt(0).data;
e.record.set('cargo_id', cargodata.id);
e.record.set('cargoname', cargodata.NAME_REF);
//alert(e.record.get('cargo_id'));
} else {
//alert(cargodata.name);
e.record.set('cargoname', ' ');
}
}
if (e.field == 'cancellation') {
var cancellationrecords = DsStoreQueryBy(this.storecancellation, 'EnumValueId', e.value);
if (cancellationrecords.getCount() > 0) {
var cancellationdata = cancellationrecords.getAt(0).data;
e.record.set('cancellationRef', cancellationdata.EnumValueName);
} else {
e.record.set('cancellationRef', '');
}
}
saved = false;
},
//#endregion ----明细表<<<许可证使用>>>的相关方法 over
//#region 单据表 明细表相关方法
onAddReceiptClick: function (button, event) {
this.addDetail();
}, //end onAddDetailClick
onDelReceiptClick: function (button, event) {
this.deleteDetail();
}, //onDelDetailClick
ReceiptAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'Receiptid') {
var Receiptrecords = DsStoreQueryBy(this.storeReceiptid, 'EnumValueId', e.value);
if (Receiptrecords.getCount() > 0) {
var Receiptdata = Receiptrecords.getAt(0).data;
e.record.set('ReceiptName', Receiptdata.EnumValueName);
} else {
e.record.set('ReceiptName', '');
}
}
if (e.field == 'state') {
var staterecords = DsStoreQueryBy(this.storeReceiptstate, 'EnumValueId', e.value);
if (staterecords.getCount() > 0) {
var statedata = staterecords.getAt(0).data;
e.record.set('statename', statedata.EnumValueName);
} else {
e.record.set('statename', '');
}
}
},
addDetail: function () {
// var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
// this.serialNo = newSerialno;
var record = Ext.create('Receiptmb', {
'id': '',
'ContractNo': '',
'Receiptid': '0',
'ReceiptName': '',
'ReceiptNo': '',
'state': '0',
'Send_date': '',
'receive_date': '',
'repeat_date': '',
'trancer': '',
'trancNo': ''
});
this.storeReceipt.add(record);
var n = this.storeReceipt.getCount();
this.cellEditingReceipt.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
var selectedRecords = this.gridListReceipt.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
// alert(rec.ContractNo);
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.bodyDel.push(rec);
}
//alert(i);
this.storeReceipt.remove(selectedRecords[i]);
}
},
//#endregion 单据表 明细表相关方法
// 明细表 <<<<<<<<<<<<<费用表相关方法
/*
onAddDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
if (type == 1) {
record = Ext.create('MsWlPcFixed', {
GId: NewGuid(),
BillNo: '*',
SerialNo: newSerialno,
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
AuditStatus: 0,
CreditDebit: "2",
CreditDebit_Ref: "应付",
FeeTypeCode: '',
FeeTypeCode_Ref: '',
FeeTypeName: '',
DistCount: 0,
Price: 0,
FsTotal: 0,
JsTotal: 0,
Remark: ''
});
} else if (type == 2) {//////////////////////
record = Ext.create('MsChFee', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeType_Ref: '应收',
FeeName: '',
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: this.getCustName(),
CustomerName_Ref: '',
Unit: '',
UnitPrice: 0,
Quantity: 1,
Amount: 0,
Currency: 'RMB',
ExChangerate: '1',
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
EnterDate: null,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
}
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
if (type == 1) {
cellediting = this.cellEditingFix;
editColumnIndex = 2;
} else if (type == 2) {
cellediting = this.cellEditingChFee;
editColumnIndex = 4;
}
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
GetHandleSerialNo: function (store, type) {
var result = 0;
if (type == 1) {
result = this.fixSerialNo;
} else if (type == 2) {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
result = result + 1;
if (type == 1) {
this.fixSerialNo = result;
} else if (type == 2) {
this.feeSerialNo = result;
}
return result;
},
onDelDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var result = 0;
if (type == '1') {
result = this.fixSerialNo;
} else if (type == '2') {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > this.giSerialNo) {
result = member.data.SerialNo;
}
}
}
if (type == '1') {
this.fixSerialNo = result;
} else if (type == '2') {
this.feeSerialNo = result;
}
var selectedRecords = [];
if (type == '1') {
selectedRecords = this.gridListFix.selModel.getSelection();
} else if (type == '2') {
selectedRecords = this.gridListChFee.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete(selectedRecords);
if (candelete == false)
return;
}
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (type == '1') {
this.fixBodyDel.push(rec);
} else if (type == '2') {
this.feeBodyDel.push(rec);
}
}
if (type == '1') {
this.storeBodyFix.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyChFee.remove(selectedRecords[i]);
}
}
}
},
onSubmitAuditClick: function (button, event) {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..');
},
getCustName: function () {
var custName = this.formEdit.getForm().findField('buyer');
return custName.getValue();
},
getAllowOperationDetail: function () {
var feeStatus = this.getFeeStatus();
if (feeStatus == '0')
return true;
else {
Ext.Msg.show({ title: '错误', msg: "费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return false;
}
return true;
},
getFeeStatus: function () {
//var basicForm = this.formEdit.getForm();
//var feeStatus = basicForm.findField('FeeStatus').value;
//return feeStatus;
return 0;
},
cellEditingChFeeBeforeEdit: function (editor, e) {
var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
if (canedit) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
canedit = feeStatus == '0' && billStatus == '0';
}
//return canedit;
return true;
},
gridListChFeeAfterEdit: function (editor, e, eOpts) {
if (e.field == 'FeeType') {
var records = DsStoreQueryBy(this.storeFeeTypeRef, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FeeType_Ref', data.EnumValueName);
} else {
e.record.set('FeeType_Ref', '');
}
} else if (e.field = 'UnitPrice' || e.field == 'Quantity' ) {
var unitPrice = e.record.data['UnitPrice'];
var quantity = e.record.data['Quantity'];
//var ExChangerate= e.record.data['ExChangerate'];
e.record.set('Amount', (unitPrice * quantity ).toFixed(2));
}
},
*/
// 明细表 费用表相关方法 end
//#region 添加审单情况
addAuditStatusBody: function () {
if (this.AuditStatusGID==""){
return;
}else{
var MODIFIEDTIME= currdate.format('yyyy-MM-dd hh:mm:ss');
record = Ext.create('AuditStatusBodymb', {
'GID': NewGuid(),
'BSNO': '',
'LINKID': this.AuditStatusGID,
'MODIFIEDTIME': MODIFIEDTIME,
'MODIFIEDUSER': '',
'AUDITSTATUS': 'NO',
'CZSTATUS': ''
});
this.storeAuditStatusBody.insert(0,record);
//var n = this.storeAuditStatusBody.getCount();
this.cellEditingAuditStatus_Body.startEditByPosition({ row: 0, column: 2 });
}
var islast=true;
var _date=Date.parse(MODIFIEDTIME);
for(var i=0;i<this.storeAuditStatusBody.getCount();i++){
_s=this.storeAuditStatusBody.getAt(i).data; //遍历每一行
_Bodydate=Date.parse(_s.MODIFIEDTIME);
if (_Bodydate>_date){
islast=false;
}
}
if (islast==true){
for(var i=0;i<this.storeAuditStatus.getCount();i++){
_s=this.storeAuditStatus.getAt(i); //遍历每一行
if (_s.get('GID')==this.AuditStatusGID){
_s.set('MODIFIEDTIME',MODIFIEDTIME);
_s.set('MODIFIEDUSER',SHOWNAME);
_s.set('AUDITSTATUS','NO');
_s.set('CZSTATUS','');
}
}
}
},
deleteAuditStatusBody: function () {
var selectedRecords = this.gridAuditStatusBody.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
// alert(rec.ContractNo);
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.AuditStatusBodyDel.push(rec);
}
//alert(i);
this.storeReceipt.remove(selectedRecords[i]);
}
},
AuditStatusBodyAfterEdit: function(editor, e, eOpts) {
//if (e.value==e.originalValue){return;}
/* MODIFIEDTIME
MODIFIEDUSER
AUDITSTATUS
CZSTATUS都进行更新*/
var MODIFIEDTIME= currdate.format('yyyy-MM-dd hh:mm:ss');
if (e.record.get('MODIFIEDTIME')==""||e.record.get('MODIFIEDTIME')==null)
e.record.set('MODIFIEDTIME', MODIFIEDTIME);
e.record.set('MODIFIEDUSER', SHOWNAME);
var _date=Date.parse(e.record.get('MODIFIEDTIME'));
var islast=true;
for(var i=0;i<this.storeAuditStatusBody.getCount();i++){
_s=this.storeAuditStatusBody.getAt(i).data; //遍历每一行
_Bodydate=Date.parse(_s.MODIFIEDTIME);
if (_Bodydate>_date){
islast=false;
}
}
if (islast==true){
for(var i=0;i<this.storeAuditStatus.getCount();i++){
_s=this.storeAuditStatus.getAt(i); //遍历每一行
if (_s.get('GID')==e.record.get('LINKID')){
_s.set('MODIFIEDTIME',e.record.get('MODIFIEDTIME'));
_s.set('MODIFIEDUSER',SHOWNAME);
_s.set('AUDITSTATUS',e.record.get('AUDITSTATUS'));
_s.set('CZSTATUS',e.record.get('CZSTATUS'));
}
}
}
},
//#endregion
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
setBaolv: function(field, newValue, oldValue){
//alert(field+'__'+newValue+'__'+oldValue);
if (newValue==0) {
this.storeCargo.each(function(record) {
//alert(record.get('baolv'));
record.set('baolv',1.003);
});
}else{
this.storeCargo.each(function(record) {
//alert(record.get('baolv'));
record.set('baolv',1.000);
});
}
},
InitData: function () {
this.opStatus = 'edit';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
// this.parentfunction = ret[3];
}
if (this.opStatus == 'edit')
condition = " m.id='" + this.editRecord.get('id') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
//载入数据
LoadData: function (opstatus, condition) {
this.formEdit.getForm().setValues(this.editRecord.data);
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/XXH/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;
}
var data = result.data;
// this.formEdit.getForm().reset();
if (data.audittime == "") { data.audittime = currdate.format('yyyy-MM-dd hh:mm:ss') };
if (data.Auditor == "") { data.Auditor = usercode };
if (data.HaveContract=='True'){
data.HaveContract='1';
}else{data.HaveContract='0'};
if (data.HaveCargoMark=='True'){
data.HaveCargoMark='1';
} else { data.HaveCargoMark = '0' };
//Data_Company = { gid: data.company, name: data.companyname };
//this.storeCompany.add(Data_Company);
this.formEdit.getForm().setValues(data);
function setsave(){ saved = true; }
var task = new Ext.util.DelayedTask(setsave);
task.delay(500);
Ext.getCmp("SAVE1").enable();
Ext.getCmp("SAVE2").enable();
//完成载入后,将状态设为已存储
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});//request over
if (this.opStatus == 'edit') {
this.formEdit.getForm().findField('ContractNo').setDisabled(false);
this.formEdit.getForm().findField('creator').setDisabled(false);
this.formEdit.getForm().findField('creattime').setDisabled(false);
this.formEdit.getForm().findField('company').setDisabled(false);
this.formEdit.getForm().findField('countryid').setDisabled(false);
this.formEdit.getForm().findField('port').setDisabled(false);
this.formEdit.getForm().findField('BillType').setDisabled(false);
this.formEdit.getForm().findField('BillTime').setDisabled(false);
this.formEdit.getForm().findField('seller').setDisabled(false);
this.formEdit.getForm().findField('buyer').setDisabled(false);
this.formEdit.getForm().findField('TRADINGAGENCY').setDisabled(false);
this.formEdit.getForm().findField('STT').setDisabled(false);
//this.formEdit.getForm().findField('Vessel').setDisabled(false);
//this.formEdit.getForm().findField('Voyage').setDisabled(false);
this.formEdit.getForm().findField('Ex_sailingdate').setDisabled(false);
this.formEdit.getForm().findField('SecurityDeposit').setDisabled(false);
this.formEdit.getForm().findField('PaymentMethods').setDisabled(false);
var ContractNo=this.editRecord.get('ContractNo');
this.storeReceipt.load({ params: { condition: ContractNo} });
this.storeCargo.load({ params: { condition: ContractNo} });
this.storeApp.load({ params: { condition: ContractNo} });
this.storeAppstate.load({ params: { condition: ContractNo} });
var _this=this;
this.storeAuditStatus.load({ params: { condition: " BSNO='"+ContractNo+"' "}
,callback: function (options, success, response) {
if (_this.storeAuditStatus.getCount()==0){
_this.AddAuditStatus("卫生证");
_this.AddAuditStatus("提单");
_this.AddAuditStatus("原产地证明");
_this.AddAuditStatus("发票");
_this.AddAuditStatus("装箱单");
_this.AddAuditStatus("装箱证明");
_this.AddAuditStatus("批次列表");
_this.AddAuditStatus("合同");
for(var i =0;i<_this.storeAuditStatus.getCount();i++){
_f=_this.storeAuditStatus.getAt(i); //遍历每一行
_f.set('CZSTATUS'," ");
}
}
}
});
this.storeAuditStatusBody.removeAll();
this.AuditStatusGID="";
var s=" countryid='"+this.editRecord.get('countryid')+"'";
this.storeCargoinfo.load({ params: { condition: s} });
this.formEdit.getForm().findField('ContractNo').setDisabled(true);
this.formEdit.getForm().findField('creator').setDisabled(true);
this.formEdit.getForm().findField('creattime').setDisabled(true);
this.formEdit.getForm().findField('company').setDisabled(true);
this.formEdit.getForm().findField('countryid').setDisabled(true);
this.formEdit.getForm().findField('port').setDisabled(true);0
this.formEdit.getForm().findField('BillType').setDisabled(true);
this.formEdit.getForm().findField('BillTime').setDisabled(true);
this.formEdit.getForm().findField('seller').setDisabled(true);
this.formEdit.getForm().findField('buyer').setDisabled(true);
this.formEdit.getForm().findField('TRADINGAGENCY').setDisabled(true);
this.formEdit.getForm().findField('STT').setDisabled(true);
//this.formEdit.getForm().findField('Vessel').setDisabled(true);
//this.formEdit.getForm().findField('Voyage').setDisabled(true);
this.formEdit.getForm().findField('Ex_sailingdate').setDisabled(true);
this.formEdit.getForm().findField('SecurityDeposit').setDisabled(true);
this.formEdit.getForm().findField('PaymentMethods').setDisabled(true);
}
}, // end LoadDate
AddAuditStatus:function(RECEIPTNAME){
record = Ext.create('AuditStatusmb', {
'GID': NewGuid(),
'BSNO': '',
'RECEIPTNAME': RECEIPTNAME,
'MODIFIEDTIME': '',
'MODIFIEDUSER': '',
'AUDITSTATUS': 'NO',
'CZSTATUS': ''
});
this.storeAuditStatus.add(record);
},
checkedit: function (){
var _r=true;
_form = this.formEdit.getForm();
var seller_name=_form.findField('seller').getValue();
var seller = DsStoreQueryBy(this.storeSeller, 'name',seller_name );
if (seller.getCount() > 0) {
var sellerdata = seller.getAt(0).data;
if (sellerdata.ISSTOP=="True"){
alert("你选择的贸易商已经停用");
_r=false;
//return;
}
}
var buyer_name=_form.findField('buyer').getValue();
var buyer = DsStoreQueryBy(this.storeBuyer, 'name', buyer_name);
if (buyer.getCount() > 0) {
var buyerdata = buyer.getAt(0).data;
if (buyerdata.ISSTOP=="True"){
alert("你选择的购货商已经停用");
//return;
_r=false;
}
}
var TRADINGAGENCY_name=_form.findField('TRADINGAGENCY').getValue();
var TRADINGAGENCY = DsStoreQueryBy(this.storeTRADINGAGENCY, 'name', TRADINGAGENCY_name);
if (TRADINGAGENCY.getCount() > 0) {
var buyerdata = TRADINGAGENCY.getAt(0).data;
if (buyerdata.ISSTOP=="True"){
alert("你选择的中间商已经停用");
//return;
_r=false;
}
}
if (this.storeCargo.getCount()==0){}//return true;
else{
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var cargomember = this.storeCargo.getAt(i).data;
if (cargomember.weight=="0") {
alert("请填写货物重量,请注意单位是千克");
_r= false;
}
if (cargomember.name=="") {
alert("请填写货名。");
_r= false;
}
}//end for
}//end if
for (var i = 0; i < this.storeAppstate.getCount(); i += 1) {
var Appstatemember = this.storeAppstate.getAt(i).data;
if ( Appstatemember.cargoname=="" || Appstatemember.cargo_id=="" ) {
alert("第"+(i+1)+"行 请选择货物名称");
_r = false;
//return result;
}
if ( Appstatemember.weight=="" || parseFloat(Appstatemember.weight)==0 ) {
alert("第"+(i+1)+"行 没有填写许可证使用重量");
_r = false;
//return result;
}
//20140110 增加对货物和许可证关系的验证
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/UseApproval/GetAppCargo',
scope: this,
async: false,
params: {app_id:Appstatemember.app_id,cargo_id:Appstatemember.cargo_id },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
var editp = Ext.create('AppCargomb', returnData);
//alert(editp.get('Match'));
var Match=editp.get('Match');
if (Match==0){
alert("第"+(i+1)+"行 商品与许可证的HS代码或CIQ代码不匹配");
_r=false;
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
} //end if
}//end callback
});
}
return _r;
},
Save: function (type) {
if (!this.checkedit()) {
return;
}
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
if (!validateEditorGridPanel(this.gridListReceipt)) {
return;
}
// alert('save');
basicForm.findField('ContractNo').setDisabled(false);
basicForm.findField('creator').setDisabled(false);
basicForm.findField('creattime').setDisabled(false);
basicForm.findField('company').setDisabled(false);
basicForm.findField('countryid').setDisabled(false);
basicForm.findField('port').setDisabled(false);
basicForm.findField('BillType').setDisabled(false);
basicForm.findField('BillTime').setDisabled(false);
basicForm.findField('seller').setDisabled(false);
basicForm.findField('buyer').setDisabled(false);
basicForm.findField('TRADINGAGENCY').setDisabled(false);
basicForm.findField('STT').setDisabled(false);
//basicForm.findField('Vessel').setDisabled(false);
//basicForm.findField('Voyage').setDisabled(false);
basicForm.findField('Ex_sailingdate').setDisabled(false);
basicForm.findField('SecurityDeposit').setDisabled(false);
basicForm.findField('PaymentMethods').setDisabled(false);
basicForm.findField('Freetime').setDisabled(false);
basicForm.findField('inspection_no').setDisabled(false);
basicForm.findField('Inspection_Buyer').setDisabled(false);
var data = this.formEdit.getForm().getValues();
var HTH = data.HTH;
var ContractNo = data.ContractNo;
basicForm.findField('ContractNo').setDisabled(true);
basicForm.findField('creator').setDisabled(true);
basicForm.findField('creattime').setDisabled(true);
basicForm.findField('company').setDisabled(true);
basicForm.findField('countryid').setDisabled(true);
basicForm.findField('port').setDisabled(true);
basicForm.findField('BillType').setDisabled(true);
basicForm.findField('BillTime').setDisabled(true);
basicForm.findField('seller').setDisabled(true);
basicForm.findField('buyer').setDisabled(true);
basicForm.findField('TRADINGAGENCY').setDisabled(true);
basicForm.findField('STT').setDisabled(true);
//basicForm.findField('Vessel').setDisabled(true);
//basicForm.findField('Voyage').setDisabled(true);
basicForm.findField('Ex_sailingdate').setDisabled(true);
basicForm.findField('SecurityDeposit').setDisabled(true);
basicForm.findField('PaymentMethods').setDisabled(true);
basicForm.findField('Freetime').setDisabled(true);
basicForm.findField('inspection_no').setDisabled(false);
basicForm.findField('Inspection_Buyer').setDisabled(false);
var _MBLNOREPEAT=this.formEdit.getForm().findField('MBLNOREPEAT').getValue()?1:0;
if (_MBLNOREPEAT==0){
this.BillNoCount=0;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/CommMng/BasicDataRef/GeneralSelect',
scope: this,
async:false,
params: {condition: "select BillNo as GVALUE,ContractNo as GID from Import_Main where BillNo='"+data.BillNo+"' and isnull(BillNo,'')<>'' and ContractNo<>'"+data.ContractNo+"'"},
//params: {condition: "select BillNo as GVALUE,ContractNo as GID from Import_Main "},
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.success==false){
}else{
var returnData = jsonresult.data;
//alert(returnData.Count);
this.BillNoCount=parseInt(returnData.length);
/*
if (this.BillNoCount>0){
alert("提单号重复!");
//return;
}*/
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
/*
/CommMng/BasicDataRef/GeneralSelect
loadstore的callback结果
callback: function (options, success, response) {
if (response==false){
this.BillNoCount=0;
}else{
var result = options[0].data;
this.BillNoCount=options.length;
alert("提单号重复");
return;
}
}*/
});
if (this.BillNoCount>0){
alert("提单号重复!");
return;
}
}
// #region 防止合同号重复
var HTHCount=0;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/CommMng/BasicDataRef/GeneralSelect',
scope: this,
async:false,
params: {condition: "select HTH as GVALUE,ContractNo as GID from Import_Main where HTH='"+data.HTH+"' and isnull(HTH,'')<>'' and ContractNo<>'"+data.ContractNo+"'"},
//params: {condition: "select BillNo as GVALUE,ContractNo as GID from Import_Main "},
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.success==false){
}else{
var returnData = jsonresult.data;
HTHCount=parseInt(returnData.length);
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
if (HTHCount>0){
alert("合同号重复!");
return;
}
//#endregion
var bodydatas = [];
for (var i = 0; i < this.storeReceipt.getCount(); i += 1) {
var member = this.storeReceipt.getAt(i);
bodydatas.push(member);
}
var Cargodatas = [];
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var member = this.storeCargo.getAt(i);
Cargodatas.push(member);
}
var Appstatedatas = [];
for (var i = 0; i < this.storeAppstate.getCount(); i += 1) {
var member = this.storeAppstate.getAt(i);
Appstatedatas.push(member);
}
/*
var KCdatas = [];
for (var i = 0; i < this.storeKC.getCount(); i += 1) {
var member = this.storeKC.getAt(i);
KCdatas.push(member);
}*/
var AuditStatusList = [];
for (var i = 0; i < this.storeAuditStatus.getCount(); i += 1) {
var member = this.storeAuditStatus.getAt(i);
AuditStatusList.push(member);
}
var AuditStatusBodyList = [];
for (var i = 0; i < this.storeAuditStatusBody.getCount(); i += 1) {
var member = this.storeAuditStatusBody.getAt(i);
AuditStatusBodyList.push(member);
}
//票据明细用
var jsonBody = ConvertRecordsToJson(bodydatas);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
//商品明细
var CargoBody = ConvertRecordsToJson(Cargodatas);
var CargoDelBody = ConvertRecordsToJsonAll(this.CargoDel);
//许可证使用
var AppstateBody = ConvertRecordsToJson(Appstatedatas);
var AppstateDelBody = ConvertRecordsToJsonAll(this.AppstateDel);
//库存记录
//var KCBody = ConvertRecordsToJson(KCdatas);
//var KCDelBody = ConvertRecordsToJsonAll(this.KCDel);
//库存记录
var AuditStatus = ConvertRecordsToJson(AuditStatusList);
var AuditStatusDel = "";
var AuditStatusBody = ConvertRecordsToJson(AuditStatusBodyList);
var AuditStatusDelBody = ConvertRecordsToJsonAll(this.AuditStatusBodyDel);
//费用
/*
var bodyChFeeDatas = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
bodyChFeeDatas.push(memberyf);
var amount = memberyf.data.Amount;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonChFeeBody = ConvertRecordsToJson(bodyChFeeDatas);
var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel);
*/
data.HaveContract=this.formEdit.getForm().findField('HaveContract').getValue()?1:0;
data.HaveCargoMark=this.formEdit.getForm().findField('HaveCargoMark').getValue()?1:0;
data.HAVESAMPLE=this.formEdit.getForm().findField('HAVESAMPLE').getValue()?1:0;
data.CHECKSAMPLE=this.formEdit.getForm().findField('CHECKSAMPLE').getValue()?1:0;
data.MBLNOREPEAT=this.formEdit.getForm().findField('MBLNOREPEAT').getValue()?1:0;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/audit/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
Receiptbody: jsonBody,
Receiptdelbody: jsonDelBody,
CargoBody: CargoBody,
CargoDelBody: CargoDelBody,
AppstateBody: AppstateBody,
AppstateDelBody: AppstateDelBody,
AuditStatus:AuditStatus,
AuditStatusDel:AuditStatusDel,
AuditStatusBody:AuditStatusBody,
AuditStatusDelBody:AuditStatusDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
// this.storeCargo.commitChanges();
this.storeReceipt.commitChanges();
this.storeAppstate.commitChanges();
//this.storeAuditStatus.commitChanges();
this.storeAuditStatus.load({ params: { condition: " BSNO='"+data.ContractNo+"' "}
,callback:function(){
for (var i = 0; i < this.storeAuditStatus.getCount(); i++) {
var row = this.storeAuditStatus.getAt(i);
var GID = row.get('GID' );
if (this.AuditStatusGID==GID) {
this.gridAuditStatus.selModel.select(i, true, false );
}
}
}
});
//this.storeAuditStatusBody.commitChanges();
this.storeAuditStatusBody.load({ params: { condition: " LINKID='"+this.AuditStatusGID+"'"} });
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
// alert(editRecord.get('ContractNo'));
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('XXHmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('ContractNo').setDisabled(false);
this.storeApp.load({ params: { condition: this.editRecord.get('ContractNo')} });
this.storeCargo.load({ params: { condition: this.editRecord.get('ContractNo')} });
basicForm.findField('ContractNo').setDisabled(true);
} else if (type == '1') {//保存并关闭
window.close();
} else if (type == '2'){//保存并全部新建
this.opStatus = 'add';
this.formEdit.getForm().reset();
//this.LoadData('add', '');
basicForm.findField('ContractNo').setDisabled(false);
this.storeCargo.removeAll();
this.storeApp.removeAll();
this.storeAppstate.removeAll();
this.storeKC.removeAll();
this.storeReceipt.removeAll();
} else if (type == '3'){//保存并新建,同时保留合同基础信息、货物信息、许可证使用信息
this.formEdit.getForm().setValues({ContractNo:''});
this.opStatus = 'add';
//this.LoadData('add', '');
this.formEdit.getForm().findField('ContractNo').setDisabled(true);
this.storeKC.removeAll();
this.storeReceipt.removeAll();
var Cargodatas = [];
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
this.storeCargo.getAt(i).set("ContractNo","");
}
var Appstatedatas = [];
for (var i = 0; i < this.storeAppstate.getCount(); i += 1) {
var member = this.storeAppstate.getAt(i).set("ContractNo","");
}
alert('注意,提单号、箱号、铅封号等信息不要重复');
}
} 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
});
}
//alert('03');
}
});
}, //end save
Print: function () {
var basicForm = this.formEdit.getForm();
var ContractNo = this.editRecord.get('ContractNo')
if (ContractNo == '*' || ContractNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'XXH_CW_YS';
//
var sql1 = "SET LANGUAGE 'us_english' SELECT price,weight,6.1667 as exchange FROM import_cargo WHERE contractno = '" + ContractNo + "' ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});