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.

950 lines
31 KiB
JavaScript

12 months ago
//集运管理-路单查询
Ext.namespace('Shipping');
Shipping.MsCrmOpPriceAddIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCrmOpPriceAddIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCrmOpPriceAddIndex, Ext.Panel, {
PageSize: 2000,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '1=2',
MainEditRecord: null,
storeBodyCostList: null,
feeType: 0,
feeTypeRef: '',
StoreFee: null,
StoreFeeUnit: null,
StoreFeeCust: null,
StoreDateCurr: null,
storeCustomerNameRef: null,
StoreCurr: null,
EditRecord: null,
stroplb: '',
strGID: '',
initUIComponents: function () {
this.formname = 'MsCrmOpPriceAddIndex';
this.sqlcontext = '1=2';
//定义数据集
this.storeListSeae = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsCrmQuotationEntity',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCrmQuotation/GetDataList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeDateCurrList' }
});
this.StoreDateCurr.load();
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
//定义Grid
this.initgirdcolumsSeae = [{
sortable: false,
dataIndex: 'GID',
header: '惟一值',
align: 'center',
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'QUOTATIONCODE',
header: '报价编号',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'SHORTNAME',
header: '客户名称',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'TEL',
header: '联系方式',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'EMAIL',
header: '邮箱',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'SALE',
header: '报价人',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'CREATEUSER',
header: '录入人',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'CREATETIME',
header: '录入时间',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'PORTLOAD',
header: '起运港',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
align: 'center',
width: 150
},
{
sortable: false,
dataIndex: 'CARRIER',
header: '船公司',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'CTNCODE',
header: '箱型',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'CTNNUM',
header: '箱量',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'GOODSTYPE',
header: '产品类别',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'GOODSNAME',
header: '品名',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'UNNO',
header: 'UN', //需求编号SR2017080400003
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'DCLASS',
header: '危险品等级', //需求编号SR2017080400003
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'QUOTATIONDATE',
header: '报价时间',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'VALIDDATE',
header: '有效期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'SERVICE',
header: '运输条款',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'CTNSTATUS',
header: '箱状态',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'FORWARDER',
header: '使用代理',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'COMMISSIONRATE',
header: '佣金比率',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'FBPPORTLOAD',
header: '起运港免箱天数',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'CQPORTLOAD',
header: '起运港超期标准',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'FBPPORTDISCHARGE',
header: '目的港免箱天数',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'CQPORTDISCHARGE',
header: '目的港超期标准',
align: 'center',
width: 100
},
{
sortable: false,
dataIndex: 'RMBHJ',
header: 'RMB合计', //需求编号SR2017071700006-2、3、4
align: 'right',
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
},
{
sortable: false,
dataIndex: 'USDHJ',
header: 'USD合计', //需求编号SR2017071700006-2、3、4
align: 'right',
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
},
{
sortable: false,
dataIndex: 'REMARK',
header: '备注',
align: 'center',
width: 200
}];
this.girdcolumsSeae = this.initgirdcolumsSeae;
// this.girdcolumsSeae = DsTruck.GetGridPanel(USERID, this.formname + 'seae', this.initgirdcolumsSeae, 1);
this.gridListSeae = new Ext.grid.GridPanel({
store: this.storeListSeae,
enableHdMenu: false,
region: 'north',
height: 260,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolumsSeae,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeListSeae,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.girdcolumsSeae = DsTruck.GetGridPanel(USERID, this.formname + 'Sea', this.girdcolumsSeae, 1);
this.gridListSeae.reconfigure(this.storeListSeae, this.girdcolumsSeae);
this.gridListSeae.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
}, this);
this.gridListSeae.getSelectionModel().on('select', function (model, record, index) {
var GID = record.data.GID;
var sql = "";
sql = " LINKGID='" + GID + "' ";
this.storeBodyListSeae.load({ params: { condition: sql} });
}, this);
//#region 费用信息
this.storeBodyListSeae = Ext.create('Ext.data.Store', {
model: 'CrmQuotationDetailModel',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCrmQuotation/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCheckBoxModelSeae = Ext.create('Ext.selection.CheckboxModel');
this.gridListBodySeae = new Ext.grid.GridPanel({
store: this.storeBodyListSeae,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListCheckBoxModelSeae,
tbar: [{
text: '确认添加',
tooltip: '确认添加',
id: "btnadddetailSeae",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetailSeae();
},
scope: this
}],
columns: [{
sortable: false,
dataIndex: 'GID',
header: '', //唯一编码
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'FEENAME',
header: '费用名称',
align: 'center',
width: 200
},
{
sortable: false,
dataIndex: 'CURRENCY',
header: '币别',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'UNIT',
header: '单位',
align: 'center',
width: 80
},
{
sortable: false,
dataIndex: 'UNITPRICE',
header: '金额',
align: 'right',
width: 120,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'RMBHJ',
header: 'RMB金额', //需求编号SR2017071700006-2、3、4
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'USDHJ',
header: '折合USD金额', //需求编号SR2017071700006-2、3、4
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'LINKGID',
header: '', //唯一编码
hidden: true,
width: 0
}]
});
this.panelBodySeae = new Ext.Panel({
title: '运价详细信息',
layout: "border",
region: 'center',
animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridListBodySeae]
});
//#endregion
//#region formSearch 查询面板
//国内港口(起运港)//需求编号SR2017072600008-4
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
//model: 'DsShipping.ux.CodeLoadportModel',
//proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
//需求编号SR2017071700006-5
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeLoadport.load();
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeLoadport,
matchFieldWidth: false, //下拉款自适应宽度
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'PORT', //'CodeAndName',
//forceSelection: true,
listeners: {
scope: this,
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//国际港口(目的港)
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeDisport.load();
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisport,
name: 'PORTDISCHARGE',
matchFieldWidth: false, //下拉款自适应宽度
valueField: 'PORT',
displayField: 'PORT', //'CodeAndName',
//forceSelection: true,
listeners: {
scope: this,
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//品名code_msds//需求编号SR2017072600008-1
this.storeCodeGoodsList = Ext.create('DsExt.ux.RefTableStore', {
model: 'CodeMsdsModel',
proxy: { url: '/MvcShipping/MsCrmQuotation/GetCodeMsdsList' }
});
this.storeCodeGoodsList.load();
this.comboxGOODSNAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '品名',
store: this.storeCodeGoodsList,
matchFieldWidth: false, //下拉款自适应宽度
name: 'GOODSNAME',
valueField: 'CHEMICALCGOODSNAME', //GOODNAME
displayField: 'CodeAndName',
listeners: {
'render': function (_field, eOpts) {//自定义函数,定义双击事件
_field.getEl().on('dblclick', function (e, t, eOpts) {
var sValue = t.value.toString();
var sLen = sValue.indexOf("|");
if (sLen > -1) {
sValue = sValue.substring(0, (sLen - 1));
}
else {
sValue = "";
}
//
var openSet = "height=700, width=1224, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2
var openType = "_blank";
var openUrl = "";
openUrl = "../../MvcContainer/MsCodeMSDS/MsdsView?handle=check&goodsname=" + sValue;
window.open(openUrl, openType, openSet);
});
}
}
});
_this = this;
_this = this;
this.formSearchSeae = Ext.widget('form', {
frame: true,
region: 'north',
height: 40,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxPORTLOAD, this.comboxPORTDISCHARGE, this.comboxGOODSNAME, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClickSeae(button, event);
},
scope: this
}
, {
xtype: 'button',
text: "保存列表样式",
menu: [
{
text: "保存",
handler: function (button, event) {
this.girdcolumsSeae = DsTruck.SaveGridPanel(USERID, _this.formname + 'Sea', _this.gridListSeae.columns, _this.girdcolumsSeae, 1, true);
}
}, {
text: "初始化",
handler: function (menu, event) {
_this.gridListSeae.reconfigure(_this.storeListSeae, _this.initgirdcolumsSeae);
_this.girdcolumsSeae = DsTruck.SaveGridPanel(USERID, _this.formname + 'Sea', _this.gridListSeae.columns, _this.initgirdcolumsSeae, 1, true);
}
}]
}
]
}
]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
//定义Grid
this.panelBodySeae = new Ext.Panel({
title: '海运出口报价',
layout: "border",
region: 'center',
margin: '0 0',
frame: true,
items: [this.formSearchSeae, this.gridListSeae, this.panelBodySeae]
});
this.tabpanel = new Ext.TabPanel
({
activeTab: 0,
autoWidth: true,
border: false,
frame: false,
region: 'center',
id: "TabPanelID",
enableTabScroll: true,
items:
[
this.panelBodySeae
]
});
Ext.apply(this, {
items: [this.tabpanel]
});
_this = this;
this.storeListSeae.on('beforeload', function (store) {
var sql = this.getConditionSeae();
Ext.apply(store.proxy.extraParams, { condition: sql, pricetype: '1' });
}, this);
this.parentWin = window.parent.opener._thisfee;
if (this.parentWin) {
this.feeType = this.parentWin.feeType;
if (this.feeType == 1) {
this.StoreFee = this.parentWin.storeDrChFee;
} else if (this.feeType == 2) {
this.StoreFee = this.parentWin.storeCrChFee;
} else {
this.StoreFee = this.parentWin.storeBodyChFee;
}
this.StoreFeeUnit = this.parentWin.StoreUnit;
this.StoreFeeCust = this.parentWin.StoreCustType;
this.StoreDateCurr = this.parentWin.StoreDateCurr;
this.StoreCurr = this.parentWin.StoreCurr;
this.EditRecord = this.parentWin.EditRecord;
this.stroplb = this.parentWin.stroplb;
this.storeCustomerNameRef = this.parentWin.storeCustomerNameRef;
this.SALECORP = this.parentWin.SALECORP;
var form = this.formSearchSeae.getForm();
form.findField('PORTLOAD').setValue(this.EditRecord.get('PORTLOAD'));
form.findField('PORTDISCHARGE').setValue(this.EditRecord.get('PORTDISCHARGE'));
form.findField('GOODSNAME').setValue(this.EditRecord.get('GOODSNAME'));
}
window.closeAction = 'destroy';
}, //end initUIComponents
onRefreshClickSeae: function (button, event) {
if (!this.checkSearchConditionSeae())
return;
var sql = this.getConditionSeae();
this.sqlcontext = sql;
this.storeListSeae.load({
params: { start: 0, limit: this.PageSize, condition: sql, pricetype: '1' },
waitMsg: "正在查询数据...",
scope: this
});
},
addDetailSeae: function () {
var selectedRecords = [];
var storeadd = null;
selectedRecords = this.gridListCheckBoxModelSeae.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var feeTypeRef = '';
for (var i = 0; i < selectedRecords.length; i++) {
var memberyf = selectedRecords[i];
var record = null;
var records = DsStoreQueryBy(this.StoreFeeUnit, 'UNIT', memberyf.data.UNIT);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var quantity = data.QUANTITY;
} else {
var quantity = 1;
}
var taxrate =0;
// var taxrate = 0;
var acctaxrate = 0;
if (taxrate == null) taxrate = 0;
var taxrateb = Add(1, Div(taxrate, 100, 4), 4);
var TaxUnitPrice = 0;
TaxUnitPrice = memberyf.data.UNITPRICE;
var amount = Mul(TaxUnitPrice, quantity); //(parseFloat(unitPrice).mul(quantity)).toFixed(2);
var notaxamount = 0;
if (amount > 0) {
notaxamount = Div(amount, taxrateb);
} else {
notaxamount = Div(Math.abs(amount), taxrateb);
notaxamount = -notaxamount;
}
var tax = Add(amount, -notaxamount); //parseFloat(notaxamount).mul(taxrate);
var curr = memberyf.data.CURRENCY;
acctaxrate = taxrate;
var exrate = 0;
if (curr == LOCALCURR) { exrate = 1 } else {
exrate =0;
if (exrate == 0) {
var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', curr);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
if (this.feeType == 2)
exrate = ffdata.CRDEFRATE;
else
exrate = ffdata.DEFRATE;
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', curr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
if (this.feeType == 2)
exrate = dfdata.CRDEFRATE;
else
exrate = dfdata.DEFRATE;
} else {
}
}
}
};
var custtype = '委托单位';
if (this.feeType == 1)
custtype = '委托单位'
else
custtype = '订舱代理'
var records = DsStoreQueryBy(this.StoreFeeCust, 'CUSTTYPE', custtype);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var custname = this.EditRecord.get(data.CUSTNAME);
} else {
var custname = '';
}
var custfullname = '';
if (custname != '') {
var records = DsStoreQueryBy(this.storeCustomerNameRef, 'CustName', custname);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var DESCRIPTION = data.DESCRIPTION;
if (DESCRIPTION != '')
custfullname = DESCRIPTION;
}
}
var newsort = this.StoreFee.getCount() + 1;
record = Ext.create('MsChFee', {
GId: NewGuid(),
// BsNo: this.StoreBill.getAt(0).get('BSNO'),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: this.feeType,
FeeType_Ref: feeTypeRef,
FeeName: memberyf.data.FEENAME,
FeeDescription:'',
CustomerType: custtype,
CustomerName: custname,
CustomerFullName: custfullname,
Unit: memberyf.data.UNIT,
UnitPrice: memberyf.data.UNITPRICE,
TaxUnitPrice: TaxUnitPrice,
Quantity: quantity,
TaxRate: 0,
NoTaxAmount: notaxamount,
Amount: amount,
Tax: tax,
AccTaxRate: acctaxrate,
Currency: memberyf.data.CURRENCY,
ExChangerate: exrate,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
EnterDate: null,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
ISACC: "0",
IsAdvancedpay:"0",
Sort: newsort,
IsInvoice:"0",
FeeFrt:"PP",
SALECORP: this.SALECORP,
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
MANAGER:'',
MANAGERREF:'',
LOCALCURR: LOCALCURR,
WmsOutBsNo: ''
});
record.id = NewGuid();
record.internalId = NewGuid();
this.StoreFee.add(record);
};
Ext.Msg.alert('提示', '已加入!');
},
calExchange: function (curr) {
var result = 1;
if (curr != 'RMB') {
var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', curr);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
result = ffdata.DEFRATE;
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', curr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
result = dfdata.DEFRATE;
} else {
}
}
}
return result;
},
getConditionSeae: function () {
var form = this.formSearchSeae.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = "";
var PORTLOAD = form.findField('PORTLOAD').getValue();
sql = sql + getAndConSql(sql, PORTLOAD, " PORTLOAD like '%" + PORTLOAD + "%' ");
var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue();
sql = sql + getAndConSql(sql, PORTDISCHARGE, " PORTDISCHARGE like '%" + PORTDISCHARGE + "%' ");
//品名
var GOODSNAME = form.findField('GOODSNAME').getValue();
sql = sql + getAndConSql(sql, GOODSNAME, "GOODSNAME='" + GOODSNAME + "'");
return sql;
},
checkSearchConditionSeae: function () {
var form = this.formSearchSeae.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
onClearSqlSeae: function () {
var form = this.formSearchSeae.getForm();
form.reset();
}
});