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.

818 lines
26 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.FeeTemplatePLAdd = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.FeeTemplatePLAdd.superclass.constructor.call(this);
};
Ext.extend(Shipping.FeeTemplatePLAdd, Ext.Panel, {
PageSize: 100,
ParentWin: null,
feeType: 0,
feeTypeRef: '',
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
StoreFee: null,
StoreFeeUnit: null,
StoreFeeCust: null,
StoreDateCurr: null,
storeCustomerNameRef: null,
StoreCurr: null,
EditRecord: null,
stroplb: '',
strGID: '',
initUIComponents: function () {
this.DEFORDERCUST = "";
this.SALECORP = "";
this.ACCTAXRATESAMETAXRATE = 0;
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsFeeTemplate',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsFeeTemplate/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 主grid
this.gridListCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
// height: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListCheckBoxModel,
tbar: [{
text:'确定引入', //删除账单明细
tooltip: Zi.LAN.sczdmingxi,
iconCls: "btnadd",
id: 'btnadd',
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, {
text: '确定引入(客户类别)', //删除账单明细
tooltip: Zi.LAN.sczdmingxi,
iconCls: "btnadd",
id: 'btnadd2',
handler: function (button, event) {
this.onAddDetailClick2(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'Name',
header: '模板名称',
width: 100
}, {
sortable: true,
dataIndex: 'Description',
header: '模板说明',
width: 120
}, {
sortable: true,
dataIndex: 'OpTyperef',
header: '业务类型',
width: 80
}, {
sortable: true,
dataIndex: 'FeeTyperef',
header: '费用类型',
width: 60
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 220
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region 固定费用明细表
//#region 费用表
//明细表-数据集
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsFeeTemplateDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsFeeTemplate/GetDetailDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
// this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_thisfeetemppl = this;
this.gridListChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
// selModel: this.feeGridCheckBoxModel,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'GID',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
width: 120
}, {
sortable: true,
dataIndex: 'FEEDESCRIPTION',
header: '费用英文名称',
width: 120
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
width: 120
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
width: 120
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
width: 60
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
width: 60
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 60
}, {
sortable: true,
dataIndex: 'ExchangeRate',
header: '汇率',
width: 60
}, {
sortable: true,
dataIndex: 'TaxRate',
header: '税率',
width: 60
}, {
sortable: true,
dataIndex: 'TaxUnitPrice',
header: '含税单价',
width: 60
}, {
sortable: true,
dataIndex: 'Tax',
header: '税额',
width: 60
}, {
sortable: true,
dataIndex: 'AccTaxRate',
header: '财务税率',
width: 60
}, {
sortable: true,
dataIndex: 'FEEFRT',
header: 'FRT',
width: 20
}, {
sortable: true,
dataIndex: 'SALECORP',
header: '核算单位',
width: 120
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150
}
]
});
this.storeBodyAddList = Ext.create('Ext.data.Store', {
model: 'MsSubSeaOrderModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSubSeaOrder/GetDataList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridAddList = new Ext.grid.GridPanel({
store: this.storeBodyAddList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 0
},
{
sortable: true,
dataIndex: 'SPCHARGE',
header: 'SPECIAL CHARGE',
renderer: function (value, p, record) {
if (value == true) {
return "YES"
} else { return "NO" }
},
width: 60
},
{
sortable: true,
id: '',
dataIndex: 'DRFEESTATUS',
header: 'DRFEESTATUS', //'应收费用',
align: 'center',
width: 60,
renderer: function (value, meta) {
if (value == '审核通过') {
meta.tdCls = 'feestatus_pass';
} else if (value == '录入状态') {
} else if (value == '提交审核') {
meta.tdCls = 'feestatus_refer';
} else if (value == '部分结算') {
meta.tdCls = 'feestatus_refer';
} else if (value == '结算完毕') {
meta.tdCls = 'feestatus_settle';
} else if (value == '未录入') {
} else if (value == '部分结算') {
meta.tdCls = 'feestatus_settle';
} else if (value == '部分审核') {
meta.tdCls = 'feestatus_refer';
} else if (value == '部分提交') {
meta.tdCls = 'feestatus_refer';
} else if (value == '驳回提交') {
meta.tdCls = 'feestatus_nopass';
}
return value;
}
},
{
sortable: true,
id: '',
dataIndex: 'CRFEESTATUS',
header: 'CRFEESTATUS', //'应付费用',
align: 'center',
width: 60,
renderer: function (value, meta) {
if (value == '审核通过') {
meta.tdCls = 'feestatus_pass';
} else if (value == '录入状态') {
} else if (value == '提交审核') {
meta.tdCls = 'feestatus_refer';
} else if (value == '部分结算') {
meta.tdCls = 'feestatus_refer';
} else if (value == '结算完毕') {
meta.tdCls = 'feestatus_settle';
} else if (value == '未录入') {
} else if (value == '部分结算') {
meta.tdCls = 'feestatus_settle';
} else if (value == '部分审核') {
meta.tdCls = 'feestatus_refer';
} else if (value == '部分提交') {
meta.tdCls = 'feestatus_refer';
} else if (value == '驳回提交') {
meta.tdCls = 'feestatus_nopass';
}
return value;
}
},
{
sortable: true,
dataIndex: 'MBLNO',
header: 'MBLNO',
width: 120
},
{
sortable: true,
dataIndex: 'ETD',
header: 'ETD',
width: 90
},
{
sortable: true,
dataIndex: 'BLFRT',
header: 'BLFRT',
width: 120
},
{
sortable: true,
dataIndex: 'CARGOID',
header: 'CARGO',
width: 60
},
{
sortable: true,
dataIndex: 'GOODSNAME',
header: 'GOODS NAME',
width: 120
},
{
sortable: true,
dataIndex: 'PKGS',
header: 'PKGS',
width: 80
},
{
sortable: true,
dataIndex: 'KGS',
header: 'KGS',
width: 80
},
{
sortable: true,
dataIndex: 'CNTRTOTAL',
header: 'CNTR',
width: 120
},
{
sortable: true,
dataIndex: 'INPUTBY',
header: 'INPUTBY',
width: 80
},
{
sortable: true,
dataIndex: 'VESSEL',
header: 'VESSEL',
width: 100
},
{
sortable: true,
dataIndex: 'VOYNO',
header: 'VOYNO',
width: 60
},
{
sortable: true,
dataIndex: 'PORTLOAD',
header: 'PORTLOAD',
width: 100
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: 'PORTDISCHARGE',
width: 100
},
{
sortable: true,
dataIndex: 'KINDPKGS',
header: 'KINDPKGS',
width: 60
}
]
});
//#endregion
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": "", "NAME": "全部" });
this.storeAddDCType.add({ "DC": "1", "NAME": "应收" });
this.storeAddDCType.add({ "DC": "2", "NAME": "应付" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收付',
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
// labelWidth: 50,
forceSelection: true,
name: 'DC',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfeetemppl.onRefreshClick();
}
}
}
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
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.comboxaddDCType,{
fieldLabel: '模板名称',
name: 'NAME'
}, {
fieldLabel: '模板说明',
name: 'DESCRIPTION'
}, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}
]
}]
}]
});
//#endregion formSearch
//#region 按钮ToolBar
//#endregion
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 55,
items: [this.formSearch]
});
this.panelBodyChFee = new Ext.Panel({
title: '费用明细',
layout: "border",
region: 'east',
width:600,
margin: '5 10',
items: [this.gridListChFee]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "north",
height:300,
items: [
this.gridList, this.panelBodyChFee
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelFee, this.gridAddList]
});
//#endregion
this.parentWin = window.parent.opener._thisfee;
//#region 事件绑定
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyAddList.on('beforeload', function (store) {
// var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: _thisfeetemppl.strbsno });
}, this);
this.storeBodyChFee.on('beforeload', function (store) {
// var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { TemplateID: _thisfeetemppl.strGID });
}, this);
this.storeList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
//this.gridListCheckBoxModel.selectAll();
}
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
//alert(record.data.BillNo);
var bsno = record.data.GID;
_thisfeetemppl.strGID = record.data.GID;
feeType = record.data.FeeType;
feeTypeRef = record.data.FeeTyperef;
this.storeBodyChFee.load({ params: { TemplateID: bsno} });
}, this);
//#endregion
//#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示)
parentWin = window.parent.opener;
this.onAutoRefresh();
//#endregion
}, //end initUIComponents
onAutoRefresh: function () {
if (parentWin) {
var ret = parentWin.OprationSwap();
_thisfeetemppl.BillType = ret[4];
_thisfeetemppl.OrType = ret[5];
_thisfeetemppl.strbsno = ret[6];
_thisfeetemppl.storeBodyAddList.load({
params: { start: 0, limit: 1000, sort: '', condition: _thisfeetemppl.strbsno, billtype: _thisfeetemppl.BillType, ortype: _thisfeetemppl.OrType },
waitMsg: "正在查询数据...",
callback: function (r, options, success) {
if (success) {
var memdata = _thisfeetemppl.storeBodyAddList.getAt(0);
var OPLBNAME = memdata.data.OPLB.toUpperCase();
this.stroplb = OPLBNAME;
var sql = '';
sql = ' OpType=1 ';
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
},
scope: this
});
}
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onAddDetailClick: function (button, event) {
var bodyDrChFeeDatas = [];
var i;
var bodyBillDatas = [];
var selections = this.gridListCheckBoxModel.selected.items;
if (selections.length == 0) {
Ext.Msg.show({ title:'提示', msg:'请选择费用模板', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //请先选择要生成的业务!
return;
}
var BSNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyDrChFeeDatas.push(rec);
}
for (i = 0; i < this.storeBodyAddList.getCount(); i += 1) {
var memberyf = this.storeBodyAddList.getAt(i);
bodyBillDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
var jsonbodyBill = ConvertRecordsToJsonAll(bodyBillDatas);
_thisfeetemppl = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpSubSeaOrder/PiliangAddFee',
scope: this,
params: {
bill: jsonbodyBill,
body: jsonChFeeBody,
isclienttype: '0'
},
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
});
return;
} 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
});
}
}
});
},
onAddDetailClick2: function (button, event) {
var bodyDrChFeeDatas = [];
var i;
var bodyBillDatas = [];
var selections = this.gridListCheckBoxModel.selected.items;
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请选择费用模板', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //请先选择要生成的业务!
return;
}
var BSNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyDrChFeeDatas.push(rec);
}
for (i = 0; i < this.storeBodyAddList.getCount(); i += 1) {
var memberyf = this.storeBodyAddList.getAt(i);
bodyBillDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
var jsonbodyBill = ConvertRecordsToJsonAll(bodyBillDatas);
_thisfeetemppl = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpSubSeaOrder/PiliangAddFee',
scope: this,
params: {
bill: jsonbodyBill,
body: jsonChFeeBody,
isclienttype:'1'
},
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
});
return;
} 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
});
}
}
});
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
sql = ' OpType=1 ';
var DC = form.findField('DC').getValue();
sql = sql + getAndConSql(sql, DC, "FeeType=" + DC);
//if (this.stroplb == 'op_Seae') {
// sql = ' OpType=1 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_Seai') {
// sql = ' OpType=2 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_Aire') {
// sql = ' OpType=3 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_Airi') {
// sql = ' OpType=4 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_Apply') {
// sql = ' OpType=4 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_Bulk') {
// sql = ' OpType=5 and FeeType=' + this.feeType;
//} else if (this.stroplb == 'op_other') {
// sql = ' OpType=6 and FeeType=' + this.feeType;
//}
var custName = form.findField('NAME').getValue();
sql = sql + getAndConSql(sql, custName, " Name like '%" + custName + "%'");
var mblNo = form.findField('DESCRIPTION').getValue();
sql = sql + getAndConSql(sql, mblNo, " Description like '%" + mblNo + "%'");
return sql;
}
});