You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Import/Viewsjs/ImportTrade/ImportTradeEdit.js

4811 lines
182 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
Shipping.ImportTradeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.ImportTradeEdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(Shipping.ImportTradeEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
stroplb: '进口贸易',
VISIBLERANGE: 4,
OPERATERANGE: 4,
initUIComponents: function () {
this.serialNo = 0;
this.CargoDel = [];
this.itemindex = 1;
this.initloaddata = 0;
this.Exporter = "";
this.PICURL = "ftp://bjes:@120.27.53.37/dhm-11111/2.jpg";
this.Loading = true;
this.CargoListName = "CargoList_ImportTrade"
//#region 信息加载
this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMainstate.load({ params: { enumTypeId: 28} });
this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '合同货物状态',
forceSelection: true,
store: this.storeMainstate,
name: 'Mainstate'
});
this.storeBuy_Type = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBuy_Type.load({ params: { enumTypeId: 29} });
this.comboxBuy_Type = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '采购类型',
forceSelection: true,
store: this.storeBuy_Type,
name: 'Buy_Type',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeDefValue = Ext.create('Ext.data.Store', {
model: 'DsShipping.ux.OpDefValue',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeOpDef/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeMustBe = Ext.create('Ext.data.Store', {
model: 'DsShipping.ux.OpDefValue',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeOpMustField/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modImport"} });
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
//采购
this.comboxcreator = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '录入人',
store: this.storeOpCode,
forceSelection: true,
name: 'creator',
valueField: 'UserCode',
displayField: 'CodeAndName',
value: SHOWNAME
});
//操 作
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '操 作',
store: this.storeOpCode,
forceSelection: true,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
//采购人
this.comboxBuy_Op = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '采购人',
store: this.storeOpCode,
forceSelection: true,
name: 'Buy_Op',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
//客户加载_购货方
this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.comboxBuyer = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '购货方',
id: "buyer",
readOnly: true,
store: this.storeBuyer,
forceSelection: true,
name: 'buyer',
valueField: 'CustName',
displayField: 'CodeAndName',
allowBlank: true
});
this.storeseller = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.comboxseller = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '供应商',
store: this.storeseller,
forceSelection: true,
name: 'seller',
valueField: 'CustName',
displayField: 'CodeAndName',
allowBlank: true
});
//客户加载_代理
this.storeagent = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.comboxAgent = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '代理公司',
store: this.storeagent,
forceSelection: true,
name: 'Agent', id: "Agent",
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.comboxAgent2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '代理公司2',
store: this.storeagent,
forceSelection: true,
name: 'Agent2', id: "Agent2",
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.comboxAgent3 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '代理公司3',
store: this.storeagent,
forceSelection: true,
name: 'Agent3', id: "Agent3",
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.comboxispinxiang = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '是否拼柜',
store: new Ext.data.ArrayStore({
fields: ['value', 'text'],
data: [["0", '否'], ["1", '是']]
}),
forceSelection: true,
valueField: 'value',
displayField: 'text',
name: 'ispinxiang', id: "ispinxiang"
});
this.comboxispinxiang.setValue('0');
//客户加载_船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
forceSelection: true,
name: 'ShipCompany_id',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '进口国',
forceSelection: true,
store: this.storeCountry,
name: 'countryid',
valueField: 'countryid',
displayField: 'country_idandname'
});
this.storeport = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeport.load({ params: { enumTypeId: 10} });
this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '目的港',
forceSelection: true,
store: this.storeport,
name: 'port'
});
//包装
this.storeCodePackage = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodePackageModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodePackageList' }
});
this.storeCodePackage.load();
this.comboxKINDPKGS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCodePackage,
name: 'KINDPKGS',
valueField: 'PKGS',
displayField: 'PKGS'
});
//箱型_集装箱列表中的下拉框加载
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '箱型',
store: this.storeCodeCtn,
forceSelection: true,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN'
});
this.storeCargoType = Ext.create("Ext.data.Store", {
fields: ["Value"],
data: [
{ Value: "猪" },
{ Value: "牛" },
{ Value: "羊" },
{ Value: "鸡" }
]
});
this.comboxCargoType = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '商品类型',
store: this.storeCargoType,
forceSelection: true,
name: 'CargoType',
valueField: 'Value',
displayField: 'Value'
});
this.storeTransactionMethod = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTransactionMethod.load({ params: { enumTypeId: 1 }
, callback: function (options, success, response) {
if (Ext.getCmp("TransactionMethod").getValue() == "") {
Ext.getCmp("TransactionMethod").setValue(1);
}
}
});
this.comboxTransactionMethod = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '成交方式', //readOnly: true,
forceSelection: true,
store: this.storeTransactionMethod,
name: 'TransactionMethod', id: "TransactionMethod",
valueField: 'EnumValueId',
displayField: 'EnumValueName',
triggerAction: 'all',
selectOnFocus: true,
flex: 1
});
this.storeBillType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBillType.load({ params: { enumTypeId: 6} });
this.comboxBillType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '提单提交方式',
forceSelection: true,
store: this.storeBillType,
name: 'BillType', flex: 1
});
this.storeSampling_need = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeSampling_need.load({ params: { enumTypeId: 0} });
this.comboxSampling_need = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '海关是否验货',
forceSelection: true,
store: this.storeSampling_need,
name: 'Sampling_need'
});
this.storeInspection_Storage = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeInspection_Storage.load({ params: { enumTypeId: 0} });
this.comboxInspection_Storage = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '是否商检慢检', flex: 1,
//labelWidth: 77,
forceSelection: true,
store: this.storeInspection_Storage,
name: 'Inspection_Storage'
});
//#endregion
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
region: 'north', id: "formHead",
frame: true,
bodyPadding: 5,
collapsed: false,
collapsible: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'id',
name: 'id', hidden: true
}, {
fieldLabel: 'FEESTATUS', //费用状态 1未锁定 暂时使用固定值
name: 'FEESTATUS', hidden: true
}, {
fieldLabel: 'ContractNo', hidden: true, id: "ContractNo",
name: 'ContractNo', readOnly: true
}, {
fieldLabel: 'CORPID', hidden: true, id: "CORPID",
name: 'CORPID', readOnly: true
}, {
fieldLabel: '合同号',
allowblank: false,
name: 'HTH'
}, {
fieldLabel: '供应商合同号',
name: 'Supplier_Billno'
}, {
fieldLabel: '分公司合同号',
name: 'Other_Billno'
},
{
fieldLabel: '合同编码',
name: 'remark_4'
}
, this.comboxcreator
, this.comboxOP
, {
fieldLabel: '业务锁定', hidden: true,
disabled: true,
readOnly: true,
name: 'BSSTATUSREF'
}, {
fieldLabel: '费用锁定', hidden: true,
readOnly: true,
disabled: true,
name: 'FEESTATUSREF'
}, {
fieldLabel: '会计期间', hidden: true,
xtype: 'monthfield',
name: 'ACCDATE'
}, {
fieldLabel: 'TimeMark',
name: 'TimeMark', hidden: true
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxMainstate,
{
fieldLabel: '已售(kg)',
readOnly: true,
name: 'Selled_Ref'
},
{
fieldLabel: '合同签订日期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'creattime', flex: 1
}, this.comboxBuy_Type
, this.comboxBuy_Op
, {
fieldLabel: '预计付预付日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Prepaydate', flex: 1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCountry
, this.comboxport
, this.comboxCARRIER, {
fieldLabel: '船名',
name: 'Vessel', flex: 1
},
{
fieldLabel: '航次',
name: 'Voyage', flex: 1
}, {
fieldLabel: '预计付尾款日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Paydate', flex: 1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '提单号',
name: 'BillNo'
}, {
fieldLabel: '箱号',
name: 'ContainerNo'
},
{
fieldLabel: '铅封号',
name: 'SealNo'
}, {
fieldLabel: '预计开船日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Ex_sailingdate'
}, {
fieldLabel: '开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Sailingdate', flex: 1
},
{
fieldLabel: '到港日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ArrivalDate', flex: 1
,
listeners: {
//添加日期选择事件
"blur": function () {
var form = Ext.getCmp("formHead");
var startdate = form.getForm().findField('ArrivalDate').getRawValue();
var enddate = form.getForm().findField('RecDate').getRawValue();
if (startdate != "" && enddate != "") {
var _e = Ext.util.Format.date(startdate); //格式化日期控件值
var _s = Ext.util.Format.date(enddate); //格式化日期控件值
var end = new Date(_s);
var start = new Date(_e);
var elapsed = Math.round((end.getTime() - start.getTime()) / (86400000)) + 1; // 计算间隔日数
//e.record.set('text',_s);
form.getForm().findField('PortDays').setValue(elapsed);
}
}
}
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield', //Receiptremark
items: [{
fieldLabel: '单据快递号',
name: 'Bill_ExpressNo'
}, {
fieldLabel: '收单据时间',
format: 'Y-m-d',
xtype: 'datefield',
name: 'BillTime', flex: 1
},
{
fieldLabel: '单据确认时间',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Audittime', flex: 1
}, this.comboxBuyer, this.comboxseller
, this.comboxTransactionMethod
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxAgent
, {
fieldLabel: '向代理商付_预付', readOnly: true, labelWidth: 100,
name: 'paydate_ref', flex: 1
}, {
fieldLabel: '向代理商付_尾款', readOnly: true, labelWidth: 100,
name: 'paydate_b_ref', flex: 1
}, {
fieldLabel: '代理商付汇_预付', labelWidth: 100,
format: 'Y-m-d',
xtype: 'datefield',
name: 'Agents_paydate', flex: 1
}, {
fieldLabel: '代理商付汇_尾款', labelWidth: 100,
format: 'Y-m-d',
xtype: 'datefield',
name: 'Agents_b_paydate', flex: 1
}
, this.comboxBillType
//, { xtype: 'hiddenfield', flex: 1}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '出税日期',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
name: 'tax_date'
},
{
fieldLabel: '付税日期',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
name: 'tax_paydate'
}
//,this.comboxSecurityDeposit
, this.comboxSampling_need, {
fieldLabel: '海关确定抽检',
format: 'Y-m-d',
xtype: 'datefield',
name: 'SamplingDate_Plan'
},
{
fieldLabel: '海关实际验货',
format: 'Y-m-d',
xtype: 'datefield',
name: 'SamplingDate_Act'
}, {
fieldLabel: '海关放行日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CustomsReleaseDate'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxInspection_Storage
, {
fieldLabel: '商检验货日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'inspection_date'
},
{
fieldLabel: '商检放行日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'Unsealdate', flex: 1
}, this.comboxAgent2
, this.comboxAgent3
, this.comboxispinxiang]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '报关单号',
name: 'DeclareNumber'
}, {
fieldLabel: '回空日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'RecDate',
listeners: {
//添加日期选择事件
"blur": function () {
var form = Ext.getCmp("formHead");
var startdate = form.getForm().findField('ArrivalDate').getRawValue();
var enddate = form.getForm().findField('RecDate').getRawValue();
if (startdate != "" && enddate != "") {
var _e = Ext.util.Format.date(startdate); //格式化日期控件值
var _s = Ext.util.Format.date(enddate); //格式化日期控件值
var end = new Date(_s);
var start = new Date(_e);
var elapsed = Math.round((end.getTime() - start.getTime()) / (86400000)) + 1; // 计算间隔日数
//e.record.set('text',_s);
form.getForm().findField('PortDays').setValue(elapsed);
}
}
}
},
{
fieldLabel: '港口天数', flex: 1,
name: 'PortDays',
readOnly: true
}, {
fieldLabel: '免箱期', flex: 1,
xtype: 'numberfield',
name: 'Freetime'
}, {
xtype: 'checkbox', flex: 1,
fieldLabel: '是否锁汇',
name: 'LOCK_EXCHANGERATE'
}, {
flex: 1,
fieldLabel: '锁汇汇率',
name: 'EXCHANGERATE'
}//, { xtype: 'hiddenfield', flex: 1 }
//,{ xtype: 'hiddenfield', flex: 1 }
, {
fieldLabel: '送货日', hidden: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'DeliveryDate'
}, {
fieldLabel: '送货地址', hidden: true,
name: 'DeliveryAddress'
}, {
fieldLabel: '送货联系人', hidden: true,
name: 'Contacter',
flex: 1
}, {
fieldLabel: '送货电话', hidden: true,
name: 'Tel', flex: 1
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '冷藏费开始日', hidden: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'STOCKDATE_1'
}, {
fieldLabel: '冷藏费截止日', hidden: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'STOCKDATE_2'
}, {
fieldLabel: '资金利息开始日', hidden: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'FUNDDATE_1'
}, {
fieldLabel: '资金利息截止日', hidden: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'FUNDDATE_2'
}, { xtype: 'hiddenfield', flex: 2, hidden: true }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textareafield',
grow: true,
height: 84,
items: [{
fieldLabel: '溢短装',
height: 80,
labelWidth: 40,
name: 'Overfilled'
}, {
fieldLabel: '单据问题',
height: 80,
labelWidth: 55,
name: 'Receiptremark'
}, {
xtype: 'textareafield',
fieldLabel: '船期备注',
grow: true,
height: 80,
labelWidth: 55,
name: 'remark'
}]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
grow: true,
height: 92,
items: [{
xtype: 'textareafield',
fieldLabel: '备注2',
grow: true,
height: 90,
labelWidth: 40,
name: 'remark_2'
}, {
xtype: 'textareafield',
fieldLabel: '备注3',
grow: true,
height: 90,
labelWidth: 40,
name: 'remark_3'
}, {
xtype: 'textareafield',
fieldLabel: '备注4',
grow: true,
height: 90,
labelWidth: 40,
name: 'remark_5'
}, {
xtype: 'textareafield',
fieldLabel: '备注5',
grow: true,
height: 90,
labelWidth: 40,
name: 'remark_6'
}]
}
]//end items(fieldset 1)
}); //end this.formHead
//#endregion
//#region 商品信息
//数据集
this.storeCargo = Ext.create('Ext.data.Store', {
model: 'Cargomb2',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetCargoList2',
reader: {
id: 'id,ContractNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeCargo_temp = Ext.create('Ext.data.Store', {
model: 'Cargomb2',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetCargoList2',
reader: {
id: 'id,ContractNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 相关控件
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: 'codename'
});
this.storeFactoryNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'FactoryNomb',
proxy: { url: '/Import/CargoName/GetFactoryNoList' }
});
this.comboxFactoryNo = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '厂号',
autosize: true,
//bodyPadding: 5,
//flex: 1,
//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: 'CargoNamemb',
proxy: { url: '/Import/CargoName/GetCargoNameList' }
});
//this.storeCargoName.load({ params: { condition: " isenterp=1 "} });
this.comboxCargoName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '出口商',
//forceSelection: true,
store: this.storeCargoName,
name: 'name',
valueField: 'CNNAME',
displayField: 'CNNAME'
});
this.comboxCargoENName = Ext.create('DsExt.ux.RefTableCombox', {
//forceSelection: true,
store: this.storeCargoName,
name: 'Ename',
valueField: 'ENNAME',
displayField: 'ENNAME'
});
this.storeUnit = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeUnit.load({ params: { enumTypeId: 11} });
this.comboxUnit = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeUnit,
forceSelection: true,
name: 'Unit'
, value: '2'
});
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,
forceSelection: true,
name: 'currid',
valueField: 'codename',
displayField: 'codename'
//币别
});
/*
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.CargoColumns = [
{
dataIndex: 'id',
header: '自增序列号',
width: 80,
hidden: true
}, {
dataIndex: 'ISLOCKED',
header: '已锁定',
width: 60,
renderer: function (value, cellmeta) {
if (value == "1") {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
}, {
dataIndex: 'GID',
header: 'GID',
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
}
}, {
dataIndex: 'Exporter',
header: '出口商',
width: 110,
editor: this.comboxExporter
}, {
dataIndex: 'FactoryNo',
header: '厂号',
width: 80,
editor: this.comboxFactoryNo
}, {
dataIndex: 'name',
header: '产品描述(中文)',
width: 100,
editor: this.comboxCargoName
}, {
dataIndex: 'Ename',
header: '产品描述(英文)',
width: 100,
editor: this.comboxCargoENName
}, {
dataIndex: 'CargoType',
header: '产品类型',
width: 50,
editor: this.comboxCargoType
}, {
dataIndex: 'SPECIFICATIONS',
header: '商品规格',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'SBYS', hidden: true,
header: '申报要素',
width: 160,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'Unit',
header: '重量单位',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.UnitRef;
},
editor: this.comboxUnit,
width: 60
}, {
dataIndex: 'currid',
header: '币别',
editor: this.comboxcurr,
width: 50
}, {
dataIndex: 'Exchangerate',
header: '汇率_商务',
width: 75,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4
}
}, {
dataIndex: 'Exchangerate_Customs',
header: '汇率_海关',
width: 75,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4
}
}, {
dataIndex: 'U_PRICE', hidden: true,
header: '购货单价(重量单位)',
width: 90,
//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: 90,
allowBlank: false,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 6, '', true);
return value;
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 6
}
}, {
dataIndex: 'WEIGHT_HT',
header: '合同净重(kg)',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 4, '', true);
return value;
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4
}
}, {
dataIndex: 'BOXCOUNT_HT',
header: '合同件数',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'weight',
header: '单据净重(kg)',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4
}
}, {
dataIndex: 'm_weight',
header: '毛重',
width: 50,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'BoxCount',
header: '单据件数',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'MOREORLESS',
header: '短装重量(kg)',
tooltip: '溢装填负值,短装填正值',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
renderer: function (value) {
if (parseFloat(value) > 0) {
return "<a><font color='#FF0000'>" + value + "</font></a>";
} else if (parseFloat(value) <= 0) {
return "<a><font color='#00FFFF'>" + value + "</font></a>";
} else {
return "";
}
}
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 80,
editor: this.comboxKINDPKGS
}, {
dataIndex: 'WEIGHT_ACT',
header: '实际入库重量',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'BOXCOUNT_ACT',
header: '实际入库件数',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'WEIGHT_REMAIN',
header: '可售重量',
width: 80
}, {
dataIndex: 'BOXCOUNT_REMAIN',
header: '可售件数',
width: 80
}, {
dataIndex: 'BoxWeight', hidden: true,
header: '规格',
width: 50,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'price_agio',
header: '对客户卖价',
width: 50,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 6
}
}, {
dataIndex: 'price_limit',
header: '海关限价',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'Amount',
header: '合同金额',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'tax_Amount',
header: '完税价格',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'baolv',
header: '保率',
width: 55,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4
}
}, {
dataIndex: 'pay_Amount',
header: '购货款$(对供应商)',
width: 120,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'PreProportion',
header: '预付比例(%)',
width: 80,
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'prepayments',
header: '预付款(收客户)',
width: 80,
//hidden: true,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'balance',
header: '尾款(收客户)',
width: 80,
//hidden: true,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'pay_prepayments',
header: '预付款(付代理)',
width: 80,
//hidden: true,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'pay_balance',
header: '尾款(付代理)',
width: 80,
//hidden: true,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'AGENCRATE',
header: '付代理费率(元/吨)',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 2
}
}, {
dataIndex: 'Paypart',
header: '付款方式', hidden: true,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.paypartRef;
},
editor: this.comboxpaypart,
width: 50
}, {
dataIndex: 'tariff',
header: '关税类型',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'tax',
header: '关税税率(从价)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'tax_CL',
header: '关税(从量税)',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'tax_zz',
header: '增值税税率',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'tax_1',
header: '关税(应收)',
width: 80
}, {
dataIndex: 'tax_zz_1',
header: '增值税(应收)',
width: 80
}, {
dataIndex: 'tax_2',
header: '关税(应付)',
width: 80
},
{
dataIndex: 'tax_zz_2',
header: '增值税(应付)',
width: 80
}, {
dataIndex: 'Productiondate_min',
header: '生产日期 起',
width: 110,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
}, {
dataIndex: 'Productiondate_max',
header: '生产日期 止',
width: 110,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
}, {
dataIndex: 'ExpirationDate',
header: '保质期',
width: 110,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
}, {
dataIndex: 'ExpirationDates',
header: '保质天数',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: false,
decimalPrecision: 0
}
}, {
dataIndex: 'Exchangerate_Cust',
header: '应收账单汇率',
width: 100,
editor: {
xtype: 'numberfield',
decimalPrecision: 4,
selectOnFocus: true
}
}, {
dataIndex: 'AGENCRATE_Cust',
header: '应收代理费率',
width: 100,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
}, {
dataIndex: 'STOCKDATE_1',
header: '冷藏费开始日期',
width: 110,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
}, {
dataIndex: 'STOCKDATE_2',
header: '冷藏费截止日期',
width: 110,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
dataIndex: 'BZTCHNO', hidden: true,
header: '批号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'Declarenumber', hidden: true,
header: '报关单号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'AMOUNT_WRITEOFFS', hidden: true,
header: '申证金额', hidden: true,
width: 80
},
{
dataIndex: 'REMARK', hidden: true,
header: '备注',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
var _this = this;
this.cellEditingCargo = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.cargoCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formCargo = new Ext.grid.GridPanel({
store: this.storeCargo,
enableHdMenu: false,
layout: 'border',
region: 'center', //bodyStyle: 'background:#FFF',
trackResetOnLoad: true,
height: 320,
autoScroll: true,
//title: '商品信息',
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: '生成应付(预付)',
tooltip: '生成应付',
iconCls: "btnCWStart", id: "CWStart_YF",
handler: function (button, event) {
this.MakeFee("预付");
},
scope: this
}, {
text: '生成应付(尾款)',
tooltip: '生成应付',
iconCls: "btnCWStart", id: "CWStart_WK",
handler: function (button, event) {
this.MakeFee("尾款");
},
scope: this
}, {
text: '生成补税/退税',
tooltip: '根据目前应收应付的税金和',
iconCls: "btnCWStart", id: "CWStart_TAX",
handler: function (button, event) {
this.MakeTax();
},
scope: this
}, '-', {
text: '生成库存',
tooltip: '生成库存,锁定货物状态',
iconCls: "btnCargoLock", id: "CargoLock",
handler: function (button, event) {
//this.CargoLock(button, event);
var formHead = this.formHead.getForm();
/*
var buyer = formHead.findField('buyer').getValue();
if (buyer == "") {
Ext.MessageBox.confirm('提示', '没有录入购货方,因此生成的库存信息将会缺少货主。确定吗?', function (btn) {
if (btn == 'yes') {
_this.winSTORAGEShow.show();
}
});
} else*/
this.winSTORAGEShow.show();
},
scope: this
}, {
text: '取消生成库存',
tooltip: '生成库存的反操作。注意:如果库存已被提取则无法成功,必须先删除库存取用信息。',
iconCls: "btnCargoUnLock", id: "CargoUnLock",
handler: function (button, event) {
this.CargoUnLock(button, event);
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btnsavelist",
handler: function (button, event) {
var tempcolumns = this.formCargo.columns;
DsTruck.SaveGridPanel(USERID, _this.CargoListName, tempcolumns);
},
scope: this
}],
columns: this.CargoColumns
});
this.CargoColumns = DsTruck.GetGridPanel(USERID, this.CargoListName, this.CargoColumns);
//使用者id表名 中间column数组跳过一开始的几列
this.formCargo.reconfigure(this.storeCargo, this.CargoColumns);
//#endregion
//#region 编辑formEdit 基本信息
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
layout: 'border',
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [{//1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '96%'
},
items: [{//2
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
xtype: 'container',
layout: 'hbox',
flex: 1,
defaultType: 'textfield',
items: [{//3
fieldLabel: '联系人',
name: 'Contacter',
flex: 1
}, {
fieldLabel: '电话',
name: 'Tel', flex: 1
}]
}]
}]
}
, this.panelCargo
]
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnEPrev',
text: "上一票",
tooltip: '注意,翻页后未保存的信息将会丢失',
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一票",
tooltip: '注意,翻页后未保存的信息将会丢失',
handler: function (button, event) {
this.NextRecord();
},
scope: this
}, {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
//this.SaveAms('0');
this.Save('0');
},
scope: this
}, {
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
//this.SaveAms('1');
this.Save('1');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
//this.SaveAms('2');
this.Save('2');
},
scope: this
}, {
id: 'btnECopyNew',
text: "复制新建",
handler: function (button, event) {
var btnESave = Ext.getCmp('btnESave');
if (btnESave.isDisabled() || this.getIsModify == '') {
var basicForm = this.formHead.getForm();
this.opStatus = 'add';
//basicForm.findField('ContractNo').setDisabled(false);
var field = basicForm.findField('ContractNo');
field.setValue("");
field = basicForm.findField('HTH');
field.setValue("");
field = basicForm.findField('creator');
field.setValue(SHOWNAME);
field = basicForm.findField('OP');
field.setValue(SHOWNAME);
var field = basicForm.findField('Selled_Ref');
field.setValue("0");
var field = basicForm.findField('BillNo');
field.setValue('');
var field = basicForm.findField('ContainerNo');
field.setValue('');
var field = basicForm.findField('SealNo');
field.setValue('');
//this.storeCargo.removeAll();
//改为遍历storeCargo
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
this.storeCargo.getAt(i).set("ContractNo", "");
this.storeCargo.getAt(i).set("id", "");
this.storeCargo.getAt(i).set("GID", NewGuid());
this.storeCargo.getAt(i).set("weight", "0");
}
this.GetEditStatus();
} else {
this.CopyNew();
}
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
var basicForm = this.formEdit.getForm();
//basicForm.findField('ContractNo').setDisabled(false);
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}, '-', {
text: "生成期货销售单",
iconCls: "btnprint",
handler: function (button, event) {
this.MakeSales();
},
scope: this
}, '-']
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
//#region 编辑formedi edi信息
this.formEDI = Ext.widget('form', {
region: 'north',
title: 'EDI信息',
frame: true,
bodyPadding: 5,
collapsed: false,
collapsible: true,
layout: 'hbox',
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [{
xtype: 'textareafield',
grow: true,
fieldLabel: 'EDI备注',
height: 60,
name: 'EDIREMARK',
anchor: '100%'
}
]//end items(fieldset 1)
}); //end this.formEdit
this.StoreAMSCOUNTRY = Ext.create('Ext.data.Store', {
fields: ['COUNTRY']
});
this.StoreAMSCOUNTRY.add({ "COUNTRY": "USD" });
this.StoreAMSCOUNTRY.add({ "COUNTRY": "CANADA" });
this.StoreAMSCOUNTRY.add({ "COUNTRY": "BRAZIL" });
this.comboxAMSCOUNTRY = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所在国家',
store: this.StoreAMSCOUNTRY,
forceSelection: true,
name: 'BYCOUNTRY',
valueField: 'COUNTRY',
displayField: 'COUNTRY'
});
//#endregion
//#region 明细表-单据档案管理
this.storeReceiptid = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptid.load({ params: { enumTypeId: 2} });
this.comboxReceiptid = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeReceiptid,
name: 'RECEIPTTYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
enableHdMenu: false,
region: 'west',
width: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '添加',
tooltip: '添加',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFileClick(button, event);
},
scope: this
}, '-', {
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '保存',
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'RECEIPTTYPE',
header: '单据类型',
editor: this.comboxReceiptid,
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 140,
editor: {
xtype: 'textfield'
}
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '修改人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '修改时间',
width: 85
}
]
});
this.gridDocList.getSelectionModel().on('select', function (model, record, index) {
if (this.Loading == true) {
return;
}
var PICURL = record.data.Driect_URL;
Ext.getCmp('panelPic').body.update(' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + PICURL + '"> </iframe>');
}, this);
//#endregion
this.panelCargo = new Ext.Panel({
//title: '集装箱信息',
layout: "border",
height: 270,
//margin: '5 10',
frame: true,
items: [this.formCargo]
});
this.panelPic = new Ext.Panel({
id: "panelPic",
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + this.PICURL + '"> </iframe>'//ftp://bjes:@120.27.53.37/dhm-11111/2.jpg
});
this.panelpage = new Ext.Panel({
title: '商品信息',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.formCargo
//, this.formCargo
]
});
this.panelpage2 = new Ext.Panel({
title: '单据附件信息',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridDocList, this.panelPic
]
});
this.tabSeaeWTpanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
//border: true,
frame: false,
region: 'center',
//enableTabScroll: true,
items:
[
this.panelpage
, this.panelpage2
]
});
this.panelSeae = new Ext.Panel({
title: '委托信息',
id: 'pnlmodNewOpSeaeInfo',
layout: "border",
region: 'center',
animate: true,
//autoScroll: true,
frame: false,
//closable:true,
items: [this.panelBtn, this.formHead
, this.tabSeaeWTpanel
]
});
//#region 左边树形结构
this.treestore = new Ext.data.TreeStore({
model: 'DsShipping.ux.ModuleModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
url: '/MvcShipping/MsBaseInfo/GetModuTreeRefList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: true,
root: {
name: '根节点',
expanded: true,
id: '3603938C-D36A-4625-AB95-3F29B7332A45'
}
});
this.tabtree = new Ext.tree.Panel({
region: 'west',
title: '业务信息',
split: true,
width: 180,
collapsible: true,
margins: '0 0 0 0',
store: this.treestore,
rootVisible: false,
hideHeaders: true,
animate: false,
lines: false,
columns: [{
xtype: 'treecolumn',
text: '模块名称',
width: 178,
dataIndex: 'DESCRIPTION'
}],
listeners: {
scope: this,
'itemclick': function (_this, record, item, index, e, eOpts) {
var finded = false;
if (record.data.MODULEURL == '@') {
this.tabSeaepanel.setActiveTab(0);
} else if (record.data.MODULEURL != '#') {
var children = this.tabSeaepanel.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children.items[i].id) {
if (children.items[i].id == 'pnl' + record.data.NAME) {
this.tabSeaepanel.setActiveTab(i);
finded = true;
}
}
}
}
if (finded == false) {
if (this.formHead.getForm().findField('ContractNo').getValue() == "") {
Ext.Msg.show({ title: '注意', msg: '请先保存业务信息后再打开其他模块!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
} else {
if (record.data.NAME == 'modImportTradeAllFee') {
var paneltabitems = new Shipping.SeaeFee({
id: 'pnl' + record.data.NAME,
layout: "border",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION
});
} else if (record.data.NAME == 'modSeaeAmendFee') {
var paneltabitems = new Shipping.SeaeAmendFee({
id: 'pnl' + record.data.NAME,
layout: "border",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION
});
} else if (record.data.NAME == 'BILLOFLOADING') {
var paneltabitems = new Shipping.MsOpBillIndex({
id: 'pnl' + record.data.NAME,
layout: "border",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION
});
} else if (record.data.NAME == 'modOpSeaeFenList') {
var paneltabitems = new Shipping.MsOpSeaeFenIndex({
id: 'pnl' + record.data.NAME,
layout: "border",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION
});
} else {
var paneltabitems = new Ext.Panel({
id: 'pnl' + record.data.NAME,
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION,
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + record.data.MODULEURL + '"> </iframe>'
});
}
this.tabSeaepanel.add(paneltabitems);
this.tabSeaepanel.setActiveTab(paneltabitems);
this.tabSeaepanel.doLayout();
}
}
}
}
}
});
this.tabSeaepanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
id: "TabSeaePanel",
enableTabScroll: true,
items:
[
this.panelSeae
],
listeners: {
scope: this,
'beforetabchange': function (tabPanel, newCard, oldCard, eOpts) {
if (oldCard.id == "pnlmodSeaeAllFee") {
var feemodify = oldCard.panelFee.getModifyStatus();
if (feemodify) {
Ext.Msg.show({ title: '警告', msg: '费用未保存,请先保存费用!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return false;
}
}
if (oldCard.id == "pnlmodSeaeAmendFee") {
var feemodify = oldCard.panelFee.getModifyStatus();
if (feemodify) {
Ext.Msg.show({ title: '警告', msg: '费用未保存,请先保存费用!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return false;
}
}
}
}
});
//#endregion
Ext.apply(this, {
items: [this.tabtree, this.tabSeaepanel]
});
//#endregion
this.LoadInitData();
//#region 其他
parentWin = window.parent.opener._this;
this.InitData();
//绑定事件
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);
//#endregion
//#region 锁定货物状态时的弹出窗口
this.storeSTORAGENAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeSTORAGENAME.load({ params: { condition: " ISWAREHOUSE=1 "} });
this.comboxSTORAGENAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '仓库名称',
store: this.storeSTORAGENAME,
allowBlank: false,
forceSelection: true,
name: 'STORAGENAME', id: "STORAGENAME",
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.formSTORAGE = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{
xtype: "label",
height: 20,
text: "请选择仓库:"
},
this.comboxSTORAGENAME
,
{
fieldLabel: '入库日期', id: "WMSDATE",
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'WMSDATE',
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
//this.formHead.getForm().findField('STOCKDATE_1').setValue(field.rawValue);
}
},
scope: this
}
}]
});
me = this;
this.winSTORAGEShow = Ext.create('Ext.window.Window', {
title: "生成库存",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formSTORAGE],
buttons: [
{
text: "确定",
minWidth: 70,
handler: function () {
_this.CargoLock(Ext.getCmp("STORAGENAME").getValue(), Ext.getCmp("WMSDATE").getRawValue());
}
}, {
text: "取消",
minWidth: 70,
handler: function () {
me.winSTORAGEShow.Close();
}
}]
});
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit') {
condition = "M.ContractNo='" + this.editRecord.get('ContractNo') + "'";
//this.storeCargo.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
this.LoadMustBe();
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
//this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/ImportTrade/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
data = result.data;
if (this.opStatus == 'add') {
data.TransactionMethod = "1";
data.ispinxiang="0";
}
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
//this.formEDI.getForm().reset();
//this.formEDI.getForm().setValues(data);
if (this.opStatus == 'add') {
this.LoadDefValue();
}
this.LoadInit(data);
this.Editdata = data;
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var gid = '*';
if (this.opStatus == 'edit') {
//billno = this.editRecord.get('BSNO');
var condition = this.editRecord.get('ContractNo');
this.storeCargo.load({ params: { condition: condition} });
var condition2 = " BSNO='" + condition + "' ";
this.Loading = true;
this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
this.Loading = false;
}
});
} else {
condition = "xx";
this.storeCargo.load({ params: { condition: condition} });
}
}, // end LoadDate
//#endregion
LoadInitData: function () {
this.storeBuyer.load({ params: { condition: "ISCONTROLLER='1'"} }); //客户 委托单位
this.storeseller.load({ params: { condition: "ISAGENT='1'"} }); //国外代理 供货商
this.storeagent.load({ params: { condition: "ISAGENTCN='1'"} }); //国内代理 代理商
this.storeExporter.load({ params: { condition: "ISSHIPPER='1'"} }); //生产商
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} }); //船公司
this.storeOpCode.load({ params: { condition: "(ISDELETED=0 and ISDISABLE=0)"} }); //船公司//((ISDELETED=0 and ISDISABLE=0));
//this.storeYARD.load({ params: { condition: "ISYARD='1'"} });
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
var me = this;
Ext.Ajax.request({
waitMsg: '正在查询用户权限...',
url: '/CommMng/BasicDataRef/GetAuthorityRange',
params: {
modName: "modImportTrade",
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
rec = result.data;
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
this.setBtnEnable();
}
else
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
},
scope: this
}); //request over
},
setBtnEnable: function (button, event) {
if (this.OPERATERANGE == "0") {
Ext.getCmp("btnESave").enable();
Ext.getCmp("btnESaveAndClose").enable();
Ext.getCmp("btnESaveAndNew").enable();
Ext.getCmp("btnECopyNew").enable();
} else {
Ext.getCmp("btnESave").disable();
Ext.getCmp("btnESaveAndClose").disable();
Ext.getCmp("btnESaveAndNew").disable();
Ext.getCmp("btnECopyNew").disable();
}
},
checkedit: function (HTHCount) {
if (HTHCount > 0) {
alert("合同号重复");
return 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_HT == "0") {
alert("请填写货物的合同重量,请注意单位是千克");
return false;
} else
if (cargomember.name == "") {
alert("请填写货名。");
return false;
}
} //end for
return true;
} //end if
},
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
var basicForm2 = this.formHead.getForm();
if (!basicForm.isValid()) {
return;
}
if (!basicForm2.isValid()) {
return;
}
var data = this.formHead.getForm().getValues();
var HTH = data.HTH;
var ContractNo = data.ContractNo;
if (HTH != "") {
if (this.opStatus == 'add') {
var sql = " HTH ='" + HTH + "' ";
} else {
var sql = " HTH ='" + HTH + "' and ContractNo<>'" + ContractNo + "'";
}
}
var HTHCount = 0;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/XXH/GetData_HT',
scope: this,
async: false,
params: { condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
HTHCount = parseInt(returnData.Count);
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
if (HTH != "") {
if (!this.checkedit(HTHCount)) {
return;
}
}
//
var bodydatas = [];
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var member = this.storeCargo.getAt(i);
bodydatas.push(member);
}
//
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
//var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
//this.formHead.getForm().findField('ContractNo').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
//var data2 = this.formEdit.getForm().getValues(false, false, false);
//var data3 = this.formEDI.getForm().getValues(false, false, false);
//this.formHead.getForm().findField('ContractNo').setDisabled(true);
var Cargodatas = [];
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var member = this.storeCargo.getAt(i);
Cargodatas.push(member);
}
//商品明细
var CargoBody = ConvertRecordsToJson(Cargodatas);
var CargoDelBody = ConvertRecordsToJsonAll(this.CargoDel);
data.LOCK_EXCHANGERATE = this.formHead.getForm().findField('LOCK_EXCHANGERATE').getValue() ? 1 : 0;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportTrade/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
CargoBody: CargoBody,
CargoDelBody: CargoDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(returnData);
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//this.formEDI.getForm().reset();
//this.formEDI.getForm().setValues(returnData);
this.Editdata = returnData;
//this.storeCargo.commitChanges();
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('ImportTrademb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
//basicForm2.findField('ContractNo').setDisabled(true);
for (var j = 0; j < this.storeCargo.getCount(); j += 1) {
var memberbody = this.storeCargo.getAt(j);
memberbody.set("ContractNo", this.editRecord.get('ContractNo'));
memberbody.commit();
};
var condition = this.editRecord.get('ContractNo');
this.storeCargo.load({ params: { condition: condition} });
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
} else if (type == '3') {//保存并新建,同时保留合同基础信息、货物信息、许可证使用信息
/*
this.formEdit.getForm().setValues({ ContractNo: '' });
this.opStatus = 'add';
this.formEdit.getForm().findField('ContractNo').setDisabled(true);
this.CargoDel = [];
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
this.storeCargo.getAt(i).set("ContractNo", "");
this.storeCargo.getAt(i).set("GID", NewGuid());
}
alert('注意,提单号、箱号、铅封号等信息不要重复');*/
var basicForm = this.formHead.getForm();
this.opStatus = 'add';
var field = basicForm.findField('ContractNo');
field.setValue("");
field = basicForm.findField('HTH');
field.setValue("");
field = basicForm.findField('creator');
field.setValue(SHOWNAME);
field = basicForm.findField('OP');
field.setValue(SHOWNAME);
var field = basicForm.findField('Selled_Ref');
field.setValue("0");
var field = basicForm.findField('BillNo');
field.setValue('');
var field = basicForm.findField('ContainerNo');
field.setValue('');
var field = basicForm.findField('SealNo');
field.setValue('');
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var _C = this.storeCargo.getAt(i);
_C.set('weight', "0");
_C.set('WEIGHT_HT', "-1");
_C.set('WEIGHT_ACT', "0");
_C.set('GID', NewGuid());
_C.set('ContractNo', "");
}
this.storeCargo.commitChanges();
for (var i = 0; i < this.storeCargo_temp.getCount(); i += 1) {
var member = this.storeCargo_temp.getAt(i);
var id = member.data.id;
for (var j = 0; j < this.storeCargo.getCount(); j += 1) {
var _C = this.storeCargo.getAt(j);
if (_C.get('id') == id) {
_C.set('WEIGHT_HT', member.data.WEIGHT_HT);
_C.set('id', '');
}
}
}
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
/*
SaveAms: function (type) {
var basicForm = this.formAMS.getForm();
if (!basicForm.isValid()) {
return;
}
var bsno = this.formHead.getForm().findField('ContractNo').getValue();
this.formAMS.getForm().findField('AMSNO').setDisabled(false);
var data = this.formAMS.getForm().getValues(false, false, false);
this.formAMS.getForm().findField('AMSNO').setDisabled(true);
Ext.Ajax.request({
url: '/Import/ImportTrade/SaveAms',
scope: this,
params: {
data: Ext.JSON.encode(data),
bsno: bsno
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formAMS.getForm().reset();
this.formAMS.getForm().setValues(returnData);
} else {
}
} else {
}
}
});
}, //end save
*/
//#endregion
//#region 复制新建
CopyNew: function () {
var basicForm = this.formEdit.getForm();
var basicForm2 = this.formHead.getForm();
if (!basicForm.isValid()) {
return;
}
if (!basicForm2.isValid()) {
return;
}
//
var bodydatas = [];
//this.storeCargo_temp //
this.storeCargo_temp.removeAll();
/*
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var member = this.storeCargo.getAt(i);
bodydatas.push(member);
this.storeCargo_temp.add(member);
}*/
var records = [];
this.storeCargo.each(function (r) { records.push(r.copy()); });
this.storeCargo_temp.add(records);
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
//this.formHead.getForm().findField('ContractNo').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
var data2 = this.formEdit.getForm().getValues(false, false, false);
var data3 = this.formEDI.getForm().getValues(false, false, false);
//this.formHead.getForm().findField('ContractNo').setDisabled(true);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportTrade/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
data2: Ext.JSON.encode(data2),
data3: Ext.JSON.encode(data3),
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(returnData);
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
this.formEDI.getForm().reset();
this.formEDI.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('ImportTrademb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
var basicForm = this.formHead.getForm();
this.opStatus = 'add';
var field = basicForm.findField('ContractNo');
field.setValue("");
field = basicForm.findField('HTH');
field.setValue("");
field = basicForm.findField('creator');
field.setValue(SHOWNAME);
field = basicForm.findField('OP');
field.setValue(SHOWNAME);
var field = basicForm.findField('Selled_Ref');
field.setValue("0");
var field = basicForm.findField('BillNo');
field.setValue('');
var field = basicForm.findField('ContainerNo');
field.setValue('');
var field = basicForm.findField('SealNo');
field.setValue('');
//this.storeCargo.removeAll();
/*
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
this.storeCargo.getAt(i).set("ContractNo", "");
this.storeCargo.getAt(i).set("id", "");
this.storeCargo.getAt(i).set("GID", NewGuid());
this.storeCargo.getAt(i).set("WEIGHT", "0");
}*/
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var _C = this.storeCargo.getAt(i);
_C.set('weight', "0");
_C.set('WEIGHT_HT', "-1");
_C.set('WEIGHT_ACT', "0");
_C.set('GID', NewGuid());
_C.set('ContractNo', "");
}
this.storeCargo.commitChanges();
for (var i = 0; i < this.storeCargo_temp.getCount(); i += 1) {
var member = this.storeCargo_temp.getAt(i);
var id = member.data.id;
for (var j = 0; j < this.storeCargo.getCount(); j += 1) {
var _C = this.storeCargo.getAt(j);
if (_C.get('id') == id) {
_C.set('WEIGHT_HT', member.data.WEIGHT_HT);
_C.set('WEIGHT_ACT', member.data.WEIGHT_ACT);
_C.set('id', "");
}
}
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
//#endregion
//#region 直发舱单EDI
onSendDS: function (carrier, iscgvessel, remarks) {
var BSNO = this.formHead.getForm().findField('ContractNo').getValue();
Ext.Ajax.request({
waitMsg: '正在生成...',
url: '/Import/ImportTradeEdi/CustomEdiMail',
params: {
bsnos: BSNO,
dcarrier: carrier,
iscvessel: iscgvessel,
remarks: remarks
},
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;
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#region
LoadDefValue: function () {
this.storeDefValue.load({ params: { condition: "BSTYPE='海运出口'" },
callback: function (r, options, success) {
if (success) {
if (this.storeDefValue.getCount() > 0) {
for (var j = 0; j < this.storeDefValue.getCount(); j += 1) {
var member = this.storeDefValue.getAt(j);
var headfield = this.formHead.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.setValue(member.data.DEFVALUE);
var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.setValue(member.data.DEFVALUE);
var headfield = this.formEDI.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.setValue(member.data.DEFVALUE);
};
} else {
}
}
},
scope: this
});
},
LoadMustBe: function () {
this.storeMustBe.load({ params: { condition: "BSTYPE='海运出口'" },
callback: function (r, options, success) {
if (success) {
if (this.storeMustBe.getCount() > 0) {
for (var j = 0; j < this.storeMustBe.getCount(); j += 1) {
var member = this.storeMustBe.getAt(j);
var headfield = this.formHead.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.allowBlank = false;
var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.allowBlank = false;
var headfield = this.formEDI.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null)
headfield.allowBlank = false;
};
} else {
}
}
},
scope: this
});
},
LoadInit: function (data) {
/*
var CUSTOMERNAME = this.formHead.getForm().findField('CUSTOMERNAME').getValue();
var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + CUSTOMERNAME + "')";
this.storeInfoClientContact.load({ params: { condition: s} });
var sF = " ISFINANCIALSTAFF=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + CUSTOMERNAME + "')";
this.storeInfoClientContactFF.load({ params: { condition: sF} });
this.storeShipper.load({ params: { condition: "shippertype=2 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('SHIPPERID').setValue(data.SHIPPERID);
}
},
scope: this
});
this.storeConsignee.load({ params: { condition: "shippertype=1 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('CONSIGNEEID').setValue(data.CONSIGNEEID);
}
},
scope: this
});
this.storenotifyparty.load({ params: { condition: "shippertype=3 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('NOTIFYPARTYID').setValue(data.NOTIFYPARTYID);
}
},
scope: this
});
this.storeagent.load({ params: { condition: "shippertype=4 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='" + CUSTOMERNAME + "') )" },
callback: function (r, options, success) {
if (success) {
this.formEdit.getForm().findField('AGENTID').setValue(data.AGENTID);
}
},
scope: this
});
var BLTYPE = this.formHead.getForm().findField('BLTYPE').getValue();
if (BLTYPE == "拼箱单票" || BLTYPE == "拼箱分票") {
this.ImportTradeModel.js.hide();
}
else {
this.ImportTradeModel.js.show();
}
var CARGOID = this.formEdit.getForm().findField('CARGOID').getValue();
if (CARGOID == 'R') {
this.panelBodyDr.setVisible(false);
this.panelBodyRf.setVisible(true);
} else if (CARGOID == 'D') {
this.panelBodyDr.setVisible(true);
this.panelBodyRf.setVisible(false);
} else {
this.panelBodyDr.setVisible(false);
this.panelBodyRf.setVisible(false);
}
*/
},
//#endregion
//#region 转换成大写字符
onUpCaseClick: function (menu, event) {
this.formEdit.getForm().findField('SHIPPER').setValue(this.formEdit.getForm().findField('SHIPPER').getValue().toUpperCase());
this.formEdit.getForm().findField('CONSIGNEE').setValue(this.formEdit.getForm().findField('CONSIGNEE').getValue().toUpperCase());
this.formEdit.getForm().findField('NOTIFYPARTY').setValue(this.formEdit.getForm().findField('NOTIFYPARTY').getValue().toUpperCase());
this.formEdit.getForm().findField('AGENT').setValue(this.formEdit.getForm().findField('AGENT').getValue().toUpperCase());
this.formEdit.getForm().findField('MARKS').setValue(this.formEdit.getForm().findField('MARKS').getValue().toUpperCase());
this.formEdit.getForm().findField('DESCRIPTION').setValue(this.formEdit.getForm().findField('DESCRIPTION').getValue().toUpperCase());
},
//#endregion
//#region 报文
onCreateAfrClick: function (menu, event, type) {
var BSNO = this.formHead.getForm().findField('ContractNo').getValue();
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('ContractNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,无法生成报文', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
Ext.Ajax.request({
waitMsg: '正在生成...',
url: '/Import/ImportTrade/CreateAfrList',
params: {
BSNOS: BSNO,
type: type
},
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;
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onCreateCustomClick: function (menu, event, type) {
var BSNO = this.formHead.getForm().findField('ContractNo').getValue();
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('ContractNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,无法生成报文', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
Ext.Ajax.request({
waitMsg: '正在生成...',
url: '/Import/ImportTrade/CreateCustomList',
params: {
BSNOS: BSNO,
type: type
},
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;
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#region 保存报关
SaveBG: function (type) {
var basicForm = this.formEdit.getForm();
var basicForm2 = this.formHead.getForm();
if (!basicForm.isValid()) {
return;
}
if (!basicForm2.isValid()) {
return;
}
//this.formHead.getForm().findField('ContractNo').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
var data2 = this.formEdit.getForm().getValues(false, false, false);
var data3 = this.formEDI.getForm().getValues(false, false, false);
//this.formHead.getForm().findField('ContractNo').setDisabled(true);
Ext.Msg.wait('正在生成数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在生成数据...',
url: '/Import/ImportTrade/SaveBG',
scope: this,
params: {
data: Ext.JSON.encode(data),
data2: Ext.JSON.encode(data2),
data3: Ext.JSON.encode(data3)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
//var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue();
var BSSTATUS = this.formHead.getForm().findField('BSSTATUSREF').getValue();
var creator = this.formHead.getForm().findField('creator').getValue();
var op = this.formHead.getForm().findField('OP').getValue();
_this = this;
if (BSSTATUS == '锁定') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modImport" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', creator);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
}
},
GetStringNum: function (str) {
var num = 0;
if (str == null || str == '') return num;
if (str.length == 0) return num;
var if_find = false;
var str_num = '';
for (var i = 0; i < str.length; i += 1) {
var member = str.substr(i, 1);
if ((member == '0') || (member == '1') || (member == '2') || (member == '3')
|| (member == '4') || (member == '5') || (member == '6') || (member == '7')
|| (member == '8') || (member == '9') || (member == '.') || (member == '-')) {
if (!if_find) {
str_num = str_num + member;
}
} else {
if_find = true;
}
}
return str_num;
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
var btnEUpDetail = Ext.getCmp('btnadddetail2');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
//btnEAddDetail.enable();
//btnEDeleteDetail.enable();
//btnEUpDetail.enable();
} else {
//btnESave.disable();
//btnESaveAndClose.disable();
//btnESaveAndNew.disable();
//btnEAddDetail.disable();
//btnEDeleteDetail.disable();
//btnEUpDetail.disable();
}
},
//#endregion
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var children = this.tabSeaepanel.items;
if (children) {
for (var i = children.length - 1, len = 0; i >= len; i--) {
if (children.items[i].id) {
if (children.items[i].id == 'pnlmodNewOpSeaeInfo') {
} else {
children.items[i].close();
}
}
}
}
this.tabSeaepanel.doLayout();
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "M.ContractNo='" + this.editRecord.get('ContractNo') + "'";
//this.storeCargo.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
NextRecord: function () {
/*
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}*/
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.count - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var children = this.tabSeaepanel.items;
if (children) {
for (var i = children.length - 1, len = 0; i >= len; i--) {
if (children.items[i].id) {
if (children.items[i].id == 'pnlmodNewOpSeaeInfo') {
// this.tabSeaepanel.setActiveTab(i);
} else {
children.items[i].close();
}
}
}
}
this.tabSeaepanel.doLayout();
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "M.ContractNo='" + this.editRecord.get('ContractNo') + "'";
//this.storeCargo.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
getIsModify: function () {
var feepanel = Ext.getCmp('pnlmodSeaeAllFee');
if (feepanel != NaN && feepanel != null) {
var feemodify = feepanel.panelFee.getModifyStatus();
if (feemodify) {
return '费用信息';
}
}
var feeamendpanel = Ext.getCmp('pnlmodSeaeAmendFee');
if (feeamendpanel != NaN && feeamendpanel != null) {
var feemodify = feeamendpanel.panelFee.getModifyStatus();
if (feemodify) {
return '更改单信息';
}
}
var drmodify = this.storeCargo.getModifiedRecords();
if (panelEdit.formEdit.getForm().isDirty() == true || panelEdit.formHead.getForm().isDirty() == true || panelEdit.formEDI.getForm().isDirty() == true || drmodify.length != 0) {
return '业务信息';
}
else return '';
},
reLine: function (button, event) {
var _L = 1;
this.storeCargo.each(function (record) {
var ln = _L + "";
_L = _L + 1;
record.set('SEQUENCE', ln);
});
},
onAddCargoClick: function (button, event) {
var TransactionMethod = this.formHead.getForm().findField('TransactionMethod').getRawValue();
var EXCHANGERATE = this.formHead.getForm().findField('EXCHANGERATE').getRawValue();
var baolv = '1.000';
if (TransactionMethod == 'CFR') {
baolv = '1.003';
}
var linenum = this.storeCargo.getCount() + 1;
var _r = this.reLine();
var record = Ext.create('Cargomb2', {
'id': '',
'GID': NewGuid(),
'ContractNo': '',
'SEQUENCE': linenum,
'cargoinfo_id': '',
'name': '',
'Ename': '',
'SBYS': '部位: 瘦肉率: % 带肉率: %',
'price': '0',
'price_agio': '0',
'price_limit': '0',
'amount': '0',
'weight': '0',
'Unit': '2',
'UnitRef': '吨',
'UnitRate': '1000',
'BoxCount': '0',
'WEIGHT_ACT': '0',
'BOXCOUNT_ACT': '0',
'WEIGHT_HT': '0',
'BOXCOUNT_HT': '0',
'BoxWeight': '0',
'Exporter': '',
'FactoryNo': '',
'Productiondate': '',
'baolv': baolv,
'tax': '0.12',
'tax_zz': '0.13',
'tax_1': '0.0',
'tax_zz_1': '0.0',
'tax_2': '0.0',
'tax_zz_2': '0.0',
'currid': 'USD',
'codename': 'USD',
'Exchangerate': EXCHANGERATE,
'prepayments': '0',
'balance': '0',
'PreProportion': '0',
'AMOUNT_WRITEOFFS': '0',
'MOREORLESS': '0',
'AGENCRATE': '0',
'pay_prepayments': '0',
'pay_balance': '0',
'Exchangerate_Cust': '0',
'AGENCRATE_Cust': '0'
});
this.storeCargo.add(record);
var n = this.storeCargo.getCount();
this.cellEditingCargo.startEditByPosition({ row: n - 1, column: 3 });
//aftereditform();
}
, onDelCargoClick: function (button, event) {
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];
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CargoDel.push(rec);
}
this.storeCargo.remove(selectedRecords[i]);
}
var _r = this.reLine();
}
}, this);
//aftereditform();
}
, CargoBeforeEdit: function (editor, e) {
var cargo_id = e.record.get('id');
if (cargo_id == '') { cargo_id = -1; }
var canedit = true;
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') {
var HS_ID = e.record.get('cargoinfo_id');
if (HS_ID == null) { HS_ID = ""; }
if (e.record.get('FactoryNo') == "" || e.record.get('FactoryNo') == null) {
var Ename = e.record.get('Ename');
if (Ename == "" || Ename == null) {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: ""
}
});
} else {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: "HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
} else {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " ENNAME='" + Ename + "'"
}
});
} else {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " ENNAME='" + Ename + "' and HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
}
} else {
//if (this.FactoryNo!=e.record.get('FactoryNo'))
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') "
} //
});
} else {
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') {
var HS_ID = e.record.get('cargoinfo_id');
if (HS_ID == null) { HS_ID = ""; }
if (e.record.get('FactoryNo') == "" || e.record.get('FactoryNo') == null) {
var name = e.record.get('name');
if (name == "" || name == null) {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: ""
}
});
} else {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: "HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
} else {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " CNNAME='" + Ename + "'"
}
});
} else {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " CNNAME='" + Ename + "' and HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
}
} else {
//if (this.FactoryNo!=e.record.get('FactoryNo'))
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeCargoName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') "
} //
});
} else {
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 (this.opStatus == 'edit') {
var basicForm = this.formHead.getForm();
var Mainstate = basicForm.findField('Mainstate').getValue();
if (Mainstate == 1) {
//canedit = false;
//alert("注意,转为现货之后请谨慎修改货物信息");
}
}
if (e.field == 'WEIGHT_ACT' || e.field == "BOXCOUNT_ACT" || e.field == 'weight' || e.field == 'BoxCount') {
if (e.record.get('ISLOCKED') == "1") {
alert("已经生成库存,请不要修改商品信息的实际入库数据");
canedit = false;
}
}
return canedit;
}
, CargoAfterEdit: function (editor, e, eOpts) {
//if (e.value==e.originalValue){return;}
function decimal(str, length) {
var _r = round2(str, length);
return (_r);
}
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 Unitrecords = DsStoreQueryBy(this.storeUnit, 'EnumValueId', e.value);
if (Unitrecords.getCount() > 0) {
var Unitdata = Unitrecords.getAt(0).data;
e.record.set('UnitRef', Unitdata.EnumValueName);
} else {
e.record.set('UnitRef', "");
}
}
if (e.field == 'Unit' || e.field == 'U_weight') {
//var WEIGHT_HT = "0";
var U_weight = parseFloat(e.record.get('U_weight'));
var weight = e.record.get('weight');
//var WEIGHT_HT = e.record.get('WEIGHT_HT');
var WEIGHT_ACT = e.record.get('WEIGHT_ACT');
var Unit = e.record.get('Unit');
var UnitRef = e.record.get('UnitRef');
if (Unit != "" && UnitRef != "") {
if (UnitRef == '磅') {
e.record.set('UnitRate', '0.4535970244035199');
//var weight = Mul(U_weight, 0.4535970244035199);
weight = Mul(U_weight, 0.4535970244035199);
}
if (UnitRef == '吨') {
e.record.set('UnitRate', '1000');
weight = Mul(U_weight, 1000);
//e.record.set('WEIGHT_ACT', weight);
}
if (UnitRef == 'KG') {
e.record.set('UnitRate', '1');
weight = Mul(U_weight, 1);
//e.record.set('weight', weight);
}
e.record.set('weight', weight);
/*
if (parseFloat(weight) == 0) {
e.record.set('weight', weight);
}
if (parseFloat(WEIGHT_ACT) == 0) {
e.record.set('WEIGHT_ACT', WEIGHT_ACT);
}*/
} 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 UnitRef = e.record.get('UnitRef');
var UnitRate = 1;
if (UnitRef == '磅') {
UnitRate = 0.4535970244035199;
}
if (UnitRef == '吨') {
UnitRate = 1000;
}
if (UnitRef == 'KG') {
UnitRate = 1;
}
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 = parseFloat(e.record.get('weight'));
//if (e.record.get('Unit') != '1') {//不是磅
//var weight = Mul(U_weight, UnitRate);
var WEIGHT_HT = Mul(U_weight, UnitRate);
if (weight == 0) {
e.record.set('weight', WEIGHT_HT);
}
if (U_PRICE > 0) {
var price = Div(U_PRICE, UnitRate, 6);
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 == 'Unit' || e.field == 'U_weight' || e.field == 'weight') {
//如果实际重量为0 自动计算实际重量
var weight = e.record.get('weight');
var WEIGHT_ACT = e.record.get('WEIGHT_ACT');
if (parseFloat(WEIGHT_ACT) == 0) {
e.record.set('WEIGHT_ACT', weight);
} else {
}
}
if (e.field == 'WEIGHT_HT') {
//如果实际重量为0 自动计算实际重量
var WEIGHT_HT = e.record.get('WEIGHT_HT');
var weight = e.record.get('weight');
var WEIGHT_ACT = e.record.get('WEIGHT_ACT');
if (parseFloat(WEIGHT_ACT) == 0) {
e.record.set('WEIGHT_ACT', WEIGHT_HT);
} else {
}
/*
if (parseFloat(weight) == 0) {
e.record.set('weight', WEIGHT_HT);
} else {
}
*/
}
if (e.field == 'weight' || e.field == 'BoxCount') {
//计算规格 只舍不进
var BoxCount = e.record.get('BoxCount');
var weight = e.record.get('weight');
if (e.record.get('ISLOCKED') != "1") {
e.record.set('WEIGHT_ACT', weight);
e.record.set('BOXCOUNT_ACT', 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_CL' || e.field == 'tax_zz' || e.field == 'Unit'
|| e.field == 'WEIGHT_HT'
) {
var UNIT = e.record.get('UnitRef');
if (UNIT != '磅') {
var price = parseFloat(e.record.get('price'));
var price_agio = parseFloat(e.record.get('price_agio'));
if (price > price_agio) {
price_agio = price;
}
var price_limit = parseFloat(e.record.get('price_limit'));
var baolv = parseFloat(e.record.get('baolv'));
var weight = 0;
if (e.field == 'WEIGHT_HT') {
weight = parseFloat(e.record.get('WEIGHT_HT'));
} else {
weight = parseFloat(e.record.get('weight'));
}
var WEIGHT_ACT = parseFloat(e.record.get('WEIGHT_ACT'));
var WEIGHT_HT = parseFloat(e.record.get('WEIGHT_HT'));
if (price_agio == 0) {
var amount = Mul(WEIGHT_HT, price);
} //Mul(price_limit,weight,baolv,2)
else { amount = Mul(WEIGHT_HT, 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 = 1;
var UnitRef = e.record.get('UnitRef');
var UnitRate = 1;
if (UnitRef == '磅') {
UnitRate = 0.4535970244035199;
}
if (UnitRef == '吨') {
UnitRate = 1000;
}
if (UnitRef == 'KG') {
UnitRate = 1;
}
if (e.field == 'WEIGHT_HT') {
weight = parseFloat(e.record.get('WEIGHT_HT'));
} else {
weight = parseFloat(e.record.get('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 WEIGHT_ACT = parseFloat(e.record.get('WEIGHT_ACT'));
var WEIGHT_HT = parseFloat(e.record.get('WEIGHT_HT'));
var amount = Mul(WEIGHT_HT, price);
var amount_writeoffs = Mul(weight, price);
var tax_amount = 0;
var pay_amount = Mul(weight, price); //贸易商价格x重量x单价
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(price, weight, baolv, 2);
}
} else {
if (price_limit != 0 && price_limit > price_agio) {
tax_amount = Mul3(price_limit, weight, baolv, 2);
} else {
tax_amount = Mul3(price, weight, baolv, 2);
}
if (price_agio > price) {
amount = Mul(WEIGHT_HT, price_agio);
} else {
amount = Mul(WEIGHT_HT, 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 Exchangerate_Customs = e.record.get('Exchangerate_Customs'); //海关汇率
var isChicken = false;
var tax_CL = parseFloat(e.record.get('tax_CL')); //从量税率
var ChickenTax = parseFloat('0.0');
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;
} 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);
if (price_agio != 0 && price_agio > price) {
var prepayments = parseFloat(parseFloat(e.record.get('prepayments')).toFixed(2));
var balance = Cut(Mul(price_agio, weight), prepayments);
e.record.set('balance', balance);
}
else {
var prepayments = parseFloat(parseFloat(e.record.get('prepayments')).toFixed(2));
var balance = Cut(Mul(price, weight), 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') {
//alert(e.field);
var prepayments = e.record.get('prepayments');
var price = e.record.get('price');
var weight = e.record.get('weight');
var Amount = Mul(price, weight);
var balance = Cut(pay_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') {
var price = e.record.get('price');
var weight = e.record.get('weight');
var WEIGHT_HT = e.record.get('WEIGHT_HT');
var Amount = Mul(price, WEIGHT_HT);
var pay_Amount = Mul(price, weight);
var prepayments = Mul3(Amount, e.record.get('PreProportion'), 0.01, 2);
var balance = Cut(pay_Amount, prepayments);
e.record.set('prepayments', prepayments);
e.record.set('balance', balance);
//var pay_Amount =parseFloat(e.record.get('pay_Amount'));
var pay_prepayments = parseFloat(e.record.get('pay_prepayments'));
var pay_balance = 0;
if (parseFloat(pay_prepayments) == 0) {
pay_prepayments = Mul3(Amount, e.record.get('PreProportion'), 0.01, 2);
pay_balance = Cut(pay_Amount, pay_prepayments);
e.record.set('pay_prepayments', pay_prepayments);
e.record.set('pay_balance', pay_balance);
} else {
pay_balance = Cut(pay_Amount, pay_prepayments);
//e.record.set('pay_prepayments', pay_prepayments);
e.record.set('pay_balance', pay_balance);
}
}
if (e.field == 'BOXCOUNT_ACT') {
var BoxCount = e.record.get('BoxCount');
var weight = e.record.get('weight');
var BOXCOUNT_ACT = e.record.get('BOXCOUNT_ACT');
if (parseFloat(BoxCount) > 0 && parseFloat(BOXCOUNT_ACT) > 0) {
var WEIGHT_ACT = Div(Mul(weight, BOXCOUNT_ACT), BoxCount)
e.record.set('WEIGHT_ACT', WEIGHT_ACT);
}
}
}
, MakeFee: function (Type) { //初始化应收应付,
var selectedRecords = this.formCargo.selModel.getSelection();
var prepayments_1 = 0;
var prepayments_2 = 0; var preRemark = '';
var balance_1 = 0;
var balance_2 = 0; var balanceRemark = '';
var taxAmount = 0;
var tax = 0; var taxRemark = '';
var tax_zz = 0; var tax_zzRemark = '';
var weight = 0;
var Paytax = 0; var Gettax = 0;
var Paytax_zz = 0; var Gettax_zz = 0;
var Exchangerate = 0;
var taxprice = 0; var sellprice = 0; var payprice = 0;
var WEIGHT_ACT = 0;
var AGENCRATE = 0;
var AGENCFEE = 0;
var usd_tax_1 = 0; var usd_tax_zz_1 = 0;
var usd_tax_2 = 0; var usd_tax_zz_2 = 0;
var isChicken = false;
var codename = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
weight = parseFloat(rec.get('weight'));
WEIGHT_ACT = parseFloat(rec.get('WEIGHT_ACT'));
taxAmount = rec.get('tax_Amount');
Amount = rec.get('Amount');
AGENCRATE = rec.get('AGENCRATE');
AGENCFEE = Add(AGENCFEE, Mul((weight / 1000).toFixed(4), AGENCRATE, 2));
preRemark = preRemark + rec.get('prepayments') + ' ';
prepayments_1 = prepayments_1 + parseFloat(rec.get('prepayments'));
if (parseFloat(rec.get('price_agio')) == 0) {
//有差价时,预付收付金额相同,尾款收付金额不相同
prepayments_2 = prepayments_2 + parseFloat(rec.get('prepayments'));
} else {
//有差价时,预付与尾款同比例的算法
prepayments_2 = prepayments_2 + round2(parseFloat(rec.get('pay_Amount')) * parseFloat(rec.get('PreProportion')) / 100, 2);
}
Exchangerate = parseFloat(rec.get('Exchangerate'));
Exchangerate_customs = parseFloat(rec.get('Exchangerate_Customs'));
balance_1 = balance_1 + parseFloat(rec.get('balance'));
if (parseFloat(rec.get('price_agio')) == 0) {
//有差价时,预付收付金额相同,尾款收付金额不相同
balance_2 = balance_2 + parseFloat(rec.get('pay_Amount')) - parseFloat(rec.get('prepayments'));
} else
//预付与尾款有差价时同比例的算法
{ balance_2 = balance_2 + parseFloat(rec.get('pay_Amount')) - (round2(parseFloat(rec.get('pay_Amount')) * parseFloat(rec.get('PreProportion')) / 100, 2)); }
//balance_2 = balance_2 + arseFloat(rec.get('pay_balance'));
if (parseFloat(rec.get('price_agio')) > 0) {
balanceRemark = balanceRemark + '差价' + rec.get('price_agio') + ' ';
}
tax = parseFloat(rec.get('tax'));
tax_zz = parseFloat(rec.get('tax_zz'));
//alert(rec.get('cicode'));
var HS = rec.get('cicode');
/*鸡翅 800/吨 HS编码 0207142100
鸡爪 1000/吨 HS编码 0207142200
鸡胗 1300/吨 HS编码 0207142900*/
var tax_weight = parseFloat(rec.get('weight'));
Paytax = Paytax + parseFloat(rec.get('tax_2'));
Paytax_zz = Paytax_zz + parseFloat(rec.get('tax_zz_2'));
Gettax = Gettax + parseFloat(rec.get('tax_1'));
Gettax_zz = Gettax_zz + parseFloat(rec.get('tax_zz_1'));
//if (taxAmount>Amount){
usd_tax_1 = usd_tax_1 + round2(taxAmount * tax, 2);
usd_tax_zz_1 = usd_tax_zz_1 + round2(taxAmount * (1 + tax) * tax_zz, 2);
/*}else
{
usd_tax_1=usd_tax_1+ round2(Amount*tax,2);
usd_tax_zz_1=usd_tax_zz_1+ round2(Amount*(1+tax)*tax_zz,2);
} */
usd_tax_2 = usd_tax_2 + round2(taxAmount * tax, 2);
usd_tax_zz_2 = usd_tax_zz_2 + round2(taxAmount * (1 + tax) * tax_zz, 2);
codename = rec.get('currid');
}
if (Type == "预付") {//预付按合同金额的预付比例计算
this.addChFee(2, 'RMB', 1, '预付款', Mul(prepayments_2, Exchangerate), 1, round2(prepayments_2, 2) + codename);
var SXF = Div(Mul(prepayments_2, Exchangerate), 1000);
if (SXF > 1000) {
SXF = 1000;
}
this.addChFee(2, 'RMB', 1, '手续费', SXF, 1, "预付款手续费");
if (Mul(prepayments_2, Exchangerate) > 0) {
this.addChFee(2, 'RMB', 1, '电汇费', 150, 1, "预付款电汇费");
}
}
if (Type == "尾款") {
//_Balance = weight *
this.addChFee(2, 'RMB', 1, '尾款', Mul(balance_2, Exchangerate), 1, round2(balance_2, 2) + codename + " " + balanceRemark);
var SXF = Div(Mul(balance_2, Exchangerate), 1000);
if (SXF > 1000) {
SXF = 1000;
}
this.addChFee(2, 'RMB', 1, '手续费', SXF, 1, "尾款手续费");
if (Mul(balance_2, Exchangerate) > 0) {
this.addChFee(2, 'RMB', 1, '电汇费', 150, 1, "尾款电汇费");
}
if (isChicken) {
this.addChFee(2, 'RMB', 1, '关税', round2(Paytax, 2), 1, '');
this.addChFee(2, 'RMB', 1, '增值税', round2(Paytax_zz, 2), 1, '');
//this.addChFee(1, 'RMB', 1, '关税', round2(Gettax, 2), 1, '');
//this.addChFee(1, 'RMB', 1, '增值税', round2(Gettax_zz, 2), 1, '');
} else {
this.addChFee(2, 'RMB', 1, '关税', round2(Paytax, 2), 1, usd_tax_2 + ' USD');
this.addChFee(2, 'RMB', 1, '增值税', round2(Paytax_zz, 2), 1, usd_tax_zz_2 + ' USD');
//this.addChFee(1, 'RMB', 1, '关税', round2(Gettax, 2), 1, usd_tax_1 + ' USD');
//this.addChFee(1, 'RMB', 1, '增值税', round2(Gettax_zz, 2), 1, usd_tax_zz_1 + ' USD');
}
this.addChFee(2, 'RMB', 1, '代理费', AGENCFEE, 1, "代理费");
}
}
, addChFee: function (FeeType, Currency, Exchangerate, FeeName, price, Quantity, Remark, FeeDescription, feedate) {
if (price < 0) {
//return;
}
var _CustomerName = "";
if (parseFloat(price) == 0) {
return;
}
if (FeeType == 1) {
_CustomerName = Ext.getCmp("buyer").getValue();
} else {
_CustomerName = Ext.getCmp("Agent").getValue();
}
var _Amount = 0;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
if (feedate == "" || typeof (feedate) == "undefined") {
EnterDate = GetDateStr(0);
} else {
EnterDate = feedate;
}
var ContractNo = Ext.getCmp("ContractNo").getValue();
var field = " (GId,BsNo,FeeStatus,FeeType,FeeName,FeeDescription,CustomerType,CustomerName,Unit,UnitPrice,TaxUnitPrice,Quantity "
field = field + " ,Amount,NoTaxAmount,Currency,ExChangerate,Reason,Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice "
field = field + " ,Auditoperator,EnterOperator,EnterDate,DebitNo,IsDebit,IsOpen,IsAdvancedpay,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus) "
var _value = " values ('" + NewGuid() + "','" + ContractNo + "',1," + FeeType + ",'" + FeeName + "','','','" + _CustomerName + "',''," + price + "," + price + "," + Quantity + ""
_value = _value + "," + price + "*" + Quantity + "," + price + "*" + Quantity + ",'" + Currency + "'," + Exchangerate + ",'','" + Remark + "',0,0,0,0,0"
_value = _value + ",'','" + USERID + "','" + EnterDate + "','',0,0,0,0,'PP',0,0)"
var SQL = " Insert into ch_fee " + field + _value;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSync/SaveSync',
scope: this,
params: {
SQL: SQL
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
, MakeTax: function (button, event) {//根据商品信息的税和 生成补税/退税
this.Save("0");
var tax = 0;
var tax_zz = 0;
var ContractNo = "";
for (var i = 0; i < this.storeCargo.getCount(); i += 1) {
var member = this.storeCargo.getAt(i);
tax = Add(tax, member.data.tax_2);
tax_zz = Add(tax_zz, member.data.tax_zz_2);
ContractNo = member.data.ContractNo;
}
Ext.Ajax.request({//
waitMsg: '正在初始化库存数据...',
url: '/Import/ImportTrade/MakeTax',
params: {
ContractNo: ContractNo,
tax: tax,
tax_zz: tax_zz
},
callback: function (_count) {
alert('生成完毕');
//重新load库存表的store
//this.storeKC.load({ params: { condition: "K.ContractNo = '" + this.editRecord.get('ContractNo') + "' and K.corpid='" + COMPANYID + "'"} });
},
scope: this
}); //request over
}
, CargoLock: function (STORAGENAME, WMSDATE) { //生成入库信息
//20160707 修改
//如无对应销售信息,货主为操作者的“本公司”
//如有对应销售信息,则首先判断销售重量是否大于等于实际入库重量。
//如剩余重量小于等于1kg则全部按销售重量和销售客户按比例生成。
//如剩余重量大于1kg则剩余部分按货主为操作者的“本公司”处理。
var selectedRecords = this.formCargo.selModel.getSelection();
var Cargodatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.ISLOCKED == "1") {
alert("注意,已经锁定的货物信息不可重复锁定");
} else
Cargodatas.push(rec);
}
if (Cargodatas == []) {
return;
}
//商品明细
var CargoBody = ConvertRecordsToJsonAll(Cargodatas);
var CUSTOMERNAME = this.formHead.getForm().findField('buyer').getValue();
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportTrade/LockCargo',
scope: this,
params: {
CUSTOMERNAME: CUSTOMERNAME,
STORAGENAME: STORAGENAME,
WMSDATE: WMSDATE,
CargoBody: CargoBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
_this.winSTORAGEShow.close();
var condition = _this.editRecord.get('ContractNo');
_this.storeCargo.load({ params: { condition: condition} });
_this.Save('0');
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
, CargoUnLock: function (button, event) {
//如果相关库存信息已经“费用入账”
//则不允许进行解锁操作
var selections = this.formCargo.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择商品!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var _L = selections.length;
Ext.MessageBox.confirm('提示', '确定解锁这' + _L + '条记录吗?', function (btn) {
if (btn == 'yes') {
//var record = selections[0];
for (var i = 0; i < _L; i++) {
var record = selections[i];
var CARGO_GID = record.data.GID;
//var sql = " CARGO_GID='" + CARGO_GID + "'";
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/ImportTrade/GetLocked',
scope: this,
async: false,
params: { CARGO_GID: CARGO_GID },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
this.ChfeeCount = parseInt(returnData.Count);
if (returnData > 0) {
alert("<" + record.data.name + ">的库存已经锁定,不能进行取消操作,请联系入库审核人员解锁该入库。");
return;
} else {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/ImportTrade/DeleteWMS',
params: {
CARGO_GID: CARGO_GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.remove(record);
var condition = _this.editRecord.get('ContractNo');
_this.storeCargo.load({ params: { condition: condition} });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
}
//this.storeList.remove(record);
//if (i >= _L ) {
// Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
//}
};
Ext.Msg.show({ title: '提示', msg: "数据处理结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
this.onRefreshClick(button, event);
}, this);
}
, onAddFileClick: function (button, event) {
var billno = this.formHead.getForm().findField('ContractNo').value;
//var myDate = new Date();
var record = Ext.create('ReceiptDocmb', {
GID: NewGuid(),
RECEIPTTYPE: '',
R_GID: '',
BSNO: '', //ContractNo
URL: '',
Driect_URL: '',
MODIFIEDUSER: SHOWNAME,
MODIFIEDTIME: currdate.format('yyyy-MM-dd hh:mm:ss')
});
this.storeDocList.add(record);
var n = this.storeDocList.getCount();
this.DocListCellEditing.startEditByPosition({ row: n - 1, column: 5 });
}
, onPostFileClick: function (button, event) {
if (USERID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
var billno = this.formHead.getForm().findField('ContractNo').value;
var bodyDatas = [];
var i;
for (i = 0; i < this.storeDocList.getCount(); i += 1) {
var memberyf = this.storeDocList.getAt(i);
bodyDatas.push(memberyf);
var FILENAME = memberyf.data.FILENAME;
if (FILENAME == '') {
Ext.Msg.show({ title: '警告',
msg: '文件名称不能为空',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var DocBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
//var Docdatas = [];
//var DocBody = ConvertRecordsToJson(Docdatas);
//var DocBodyDel = ConvertRecordsToJsonAll(this.DocDel);
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ReceiptDoc/SaveDoc',
scope: this,
params: {
BSNO: billno,
DocBody: DocBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var condition = _this.editRecord.get('ContractNo');
var condition2 = " BSNO='" + condition + "' ";
_this.Loading = true;
_this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
_this.Loading = false;
}
});
} 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
, onDelFileClick: function (button, event) {
var feeGidSql = '';
var selectedRecords = [];
selectedRecords = this.DocCM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的附件吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDocList.remove(selectedRecords[i]);
} else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_this = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/ImportTrade/DeleteUploadFile',
params: {
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeDocList.remove(selectedRecords[i]);
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
}
, onUpLoadFileClick: function (button, event) {
var billno = this.formHead.getForm().findField('ContractNo').value;
var selections = this.gridDocList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要上传的单据类型!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var BSNO = record.data.BSNO;
var HTH = this.formHead.getForm().findField('HTH').value;
var RECEIPTTYPE = record.data.RECEIPTTYPE;
if (BSNO == '') {
Ext.Msg.show({ title: '提示', msg: '请先保存,再上传!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var GID = record.data.GID;
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadImage',
name: 'LoadImage',
emptyText: '请选择图片',
fieldLabel: '图片',
buttonText: '选择文件',
allowBlank: false,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}, {
xtype: 'textfield',
id: 'fileName_EX',
name: 'fileName_EX',
emptyText: '请填写文件后缀(如_g等)',
fieldLabel: '文件后缀名',
allowBlank: true
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadImage').getValue();
if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) {
Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/Import/ImportTrade/UploadFile',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
fileGid: GID
, HTH: HTH
, RECEIPTTYPE: RECEIPTTYPE
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
var condition = me.editRecord.get('ContractNo');
var condition2 = " BSNO='" + condition + "' ";
me.Loading = true;
me.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
me.Loading = false;
}
});
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传图片",
width: 360,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
//#region 打印
,
Print: function () {
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var printdate = GetDateStr(0);
var basicForm = this.formHead.getForm();
var billNo = basicForm.findField('ContractNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'Print_importtrade_KHZD2'; //期货 牛羊
var sql1 = " select HTH 合同号,Supplier_Billno 供应商合同号,Other_Billno 分公司合同号 ";
sql1 = sql1 + " ,dbo.F_BOXCount(m.ContractNo) 单据件数 ";
sql1 = sql1 + " ,(select top 1 customername from Import_Sales where SALESNO in(select distinct salesno from Import_Saledetail where bsno=m.ContractNo)) 销售对象,m.buyer 购货方 ";
sql1 = sql1 + " ,convert(numeric(18,2),convert(numeric(18,6),dbo.F_weight(m.ContractNo))*1000) 单据重量 ";
sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) 目的港 ";
sql1 = sql1 + " ,m.ArrivalDate 到港日,m.ContainerNo 箱号 ";
sql1 = sql1 + " ,(select substring(country,0,(charindex('(',country)) ) from code_country where countryid=m.countryid) 进口国 ";
sql1 = sql1 + " ,dbo.F_Str(M.ContractNo) 品名,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=1 and EnumValueID=M.TransactionMethod) 成交方式 ";
sql1 = sql1 + " ,dbo.F_Saleprice(M.ContractNo) 价格,(select top 1 SALER from Import_Sales where SALESNO in(select distinct salesno from Import_Saledetail where bsno=m.ContractNo)) 销售员 ";
sql1 = sql1 + " ,case (select top 1 CURRENCY from Import_Sales where SALESNO in(select salesno from Import_Saledetail where BSNO=m.ContractNo)) when 'USD' then '$' when 'RMB' then '¥' when 'EUR' then '€' else '' end 币别符号 ";
sql1 = sql1 + " from import_main m ";
sql1 = sql1 + " where M.contractno ='" + billNo + "' ";
var sql2 = " select SD.price*1000 单价吨,convert(numeric(18,2),SD.weight) 千克数,convert(varchar(20),convert(numeric(18,5),SD.weight/1000)) 吨数 ";
sql2 = sql2 + " ,ic.Exchangerate_Cust 应收汇率,SD.AMOUNT 单据金额,SD.CURRENCY 币别 ";
sql2 = sql2 + " ,SD.AMOUNTRMB 货款RMB ";
sql2 = sql2 + " ,dbo.[F_GetFee](c.contractno,2,'手续费')*dbo.f_cargoamount(c.gid)/dbo.f_mainamount(c.contractno) 手续费 ";
sql2 = sql2 + " ,dbo.[F_GetFee](c.contractno,2,'电汇费')*dbo.f_cargoamount(c.gid)/dbo.f_mainamount(c.contractno) 电汇费 ";
sql2 = sql2 + " ,c.costCargo 总货款,c.price_limit*1000 海关限价吨,c.Exchangerate_Customs 海关汇率 ";
sql2 = sql2 + " ,c.tax 关税税率,c.tax_1 应收关税,c.tax_zz 增值税税率,c.tax_zz_2 应收增值税 ";
sql2 = sql2 + " ,ic.AGENCRATE_Cust 代理费单价 ,convert(numeric(18,2),ic.AGENCRATE_Cust*c.weight/1000) 代理费,c.STOCKDATE_1 冷藏费开始日,w.STORAGENAME 冷库 ";
sql2 = sql2 + " ,w.GOODSPACK 入库件数,dbo.trimdate(m.inspection_date) 商检验货日期,dbo.trimdate(m.Unsealdate) 商检放行日期,c.STOCKDATE_2 冷藏费截止日 ";
sql2 = sql2 + " ,sd.PRICEREMARK 价格备注 ";
sql2 = sql2 + " ,(select substring(sd.PRICEREMARK,charindex('+',sd.PRICEREMARK)+1,len(sd.PRICEREMARK)) ) 价格备注费率 ";
sql2 = sql2 + " ,dbo.[Get_ClientFee](w.STORAGENAME,'冷藏费')*c.weight/1000*(isnull(DATEDIFF(DAY,m.STOCKDATE_1,m.STOCKDATE_2),0)+1) 冷藏费 ";
sql2 = sql2 + " ,dbo.[Get_ClientFee](w.STORAGENAME,'冷藏费') 冷库默认费率 ";
sql2 = sql2 + " ,dbo.[Get_ClientFee](w.STORAGENAME,'出入库费') 出入库费率 ";
sql2 = sql2 + " ,dbo.[Get_ClientFee](w.STORAGENAME,'倒柜费') 倒柜费率 ";
sql2 = sql2 + " ,isnull(DATEDIFF(DAY, c.STOCKDATE_1, c.STOCKDATE_2), 0) + 1 冷藏天数 ";
sql2 = sql2 + " ,c.weight*c.price 单据金额,dbo.trimdate(m.STOCKDATE_2) 出库时间 ";
sql2 = sql2 + " ,dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'预付款') 向代理商付预付款结算时间 ";
sql2 = sql2 + " ,dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'尾款') 向代理商付尾款结算时间 ";
sql2 = sql2 + " ,isnull(case when dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'预付款')<>'' and dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'尾款')='' then datediff(day,dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'预付款'),m.STOCKDATE_2)+1 ";
sql2 = sql2 + " else datediff(day,dbo.[F_SettlementDate_Import](m.contractno,m.Agent,'尾款'),m.STOCKDATE_2)+1 end,0) 资金占用时间 ";
sql2 = sql2 + " ,s.PREPAYMENT 定金,sd.PRICE 销售价格,s.currency 销售币别,s.FUNDRATE 资金利息利率 ";
sql2 = sql2 + " from importtrade_cargo c ";
sql2 = sql2 + " left join import_cargo ic on ic.GID=c.GID ";
sql2 = sql2 + " left join import_main m on m.ContractNo=c.ContractNo ";
sql2 = sql2 + " left join wms w on w.Cargo_gid=c.GID ";
sql2 = sql2 + " left join Import_Saledetail sd on sd.CARGO_GID=c.gid ";
sql2 = sql2 + " left join Import_Sales s on s.SALESNO=sd.SALESNO ";
sql2 = sql2 + " where c.contractno ='" + billNo + "' ";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "select '" + SHOWNAME + "' showname,'" + printdate + "' printdate";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
//#endregion
});