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

890 lines
30 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.SeaePLHistryFee = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.SeaePLHistryFee.superclass.constructor.call(this);
};
Ext.extend(Shipping.SeaePLHistryFee, Ext.Panel, {
PageSize: 10,
ParentWin: null,
feeType: 0,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
StoreFee: null,
StoreFeeUnit: null,
StoreFeeCust: null,
EditRecord: null,
StoreDateCurr: null,
StoreCurr: null,
storeCustomerNameRef: null,
stroplb: '',
initUIComponents: function () {
this.formname = "formSeaePLHistryFee"; //页面名称
this.DEFORDERCUST = "";
this.sqlcontext = '';
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpSeaeModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSeae/GetFenList',
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: 'north',
height: 268,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true
},
columns: [{
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 130
}, {
sortable: true,
dataIndex: 'CUSTOMNO',
header: '报关单号',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 130
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTOMDATE',
header: '报关日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 86
}, {
sortable: true,
dataIndex: 'CUSTOMSER',
header: '报关行',
width: 120
}, {
sortable: true,
dataIndex: 'VESSEL',
header: '船名',
width: 130
}, {
sortable: true,
dataIndex: 'VOYNO',
header: '航次',
width: 50
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 86
},
{
sortable: true,
id: '',
dataIndex: 'PORTDISCHARGE',
header: '卸货港',
width: 100
},
{
sortable: true,
id: '',
dataIndex: 'CNTRTOTAL',
header: '集装箱',
width: 80
}, {
sortable: true,
dataIndex: 'BSTYPE',
header: '业务类型',
width: 120
}, {
sortable: true,
dataIndex: 'INPUTBY',
header: '录入人',
width: 80
}, {
sortable: true,
dataIndex: 'CREATETIME',
header: '录入日期',
width: 86
}, {
sortable: true,
dataIndex: 'OP',
header: '操作',
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region 固定费用明细表
//#region 费用表
//明细表表格相关
this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} });
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeFeeTypeRef,
name: 'FeeType'
});
//明细表-数据集
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChFee/GetDataList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.radiogroup = new Ext.form.RadioGroup({
fieldLabel: '引入方式',
width: 380,
columns: 2,
items: [
{ boxLabel: '全部引入', name: 'rb', id: 'rdall', inputValue: '1' },
{ boxLabel: '不引入客户', name: 'rb', id: 'rdfee', inputValue: '2', checked: true },
]
});
_this = 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',
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return Shipping.FeeGetRowClass(feeStatus);
}
},
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeType',
header: '收付',
renderer: function (value, p, record) {
if (value==1)
return '收';
if (value == 2)
return '付';
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
width: 100
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
width: 100
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
width: 120
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
width: 60,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
sortable: true,
dataIndex: 'Quantity',
header: '数量',
width: 60
}, {
sortable: true,
dataIndex: 'TaxRate',
header: '税率',
width: 80
}, {
sortable: true,
dataIndex: 'NoTaxAmount',
header: '不含税金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
width: 60,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 60
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
width: 60
}, {
sortable: true,
dataIndex: 'Tax',
header: '税额',
width: 80
}, {
sortable: true,
dataIndex: 'AccTaxRate',
header: '财务税率',
width: 80
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150
}, {
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
width: 100
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '录入时间',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'MANAGERREF',
header: '责任人',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '录入时间',
hidden: true,
width: 200
}
],
// paging bar on the bottom
bbar: [this.radiogroup, '-', {
xtype: "button",
id: "button_add",
iconCls: "btnadd",
text: "引入费用",
handler: function (button, event) {
_this.onAddDetailClick(button, event);
}
},
'-',
{
xtype: "button",
id: "button_close",
text: "取消退出",
handler: function (button, event) {
window.close();
}
}
]
});
//#endregion
//#region formSearch
//#region formSearch枚举参照相关
// this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
// model: 'DsShipping.ux.CodeLoadportModel',
// proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
// });
// this.storeCodeLoadport.load();
// this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
// fieldLabel: '装货港', //'装货港',
// store: this.storeCodeLoadport,
// name: 'PORTLOAD',
// valueField: 'PORT',
// displayField: 'CodeAndName',
// // forceSelection: true,
// matchFieldWidth: false
// });
// this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
// model: 'DsShipping.ux.CodeDisportModel',
// proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
// });
// this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
// fieldLabel: '卸货港', //'卸货港',
// store: this.storeCodeDisport,
// name: 'PORTDISCHARGE',
// // forceSelection: true,
// valueField: 'PORT',
// queryMode: 'remote',
// minChars: 1,
// queryParam: 'PORT',
// displayField: 'CodeAndName'
// });
//#endregion
//客户加载_委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' }
});
// this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
// this.storeCustCode.loadData(mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").data.items);
//委托单位
_this = this;
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '委托单位', //'委托单位',
store: this.storeCustCode,
queryMode: 'remote',
matchFieldWidth: false,
minChars: 1,
queryParam: 'CODENAME',
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
//,
//'beforequery': function (e) {
// return FilterCombox(e,2);//在beforequery使用此方法
//}
, specialkey: function (field, e) {
//if (e.getKey() == e.ENTER) {
// e.keyCode = 9;
//}
if (e.keyCode == 9) {
if (field.value == null) {
_rec = _this.storeCustCode.getAt(0);
_this.formSearch.getForm().findField('CUSTOMERNAME').setValue(_rec.data.CustName);
}
}
}
}
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '编号',
name: 'MblNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxCustCode, {
fieldLabel: '从开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CustDate_Min',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '至开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CustDate_Max',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '装货港',
name: 'PORTLOAD',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '卸货港',
name: 'PORTDISCHARGE',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
xtype: 'button',
width: 30,
// text: "高级查询",
iconCls: "btnmore",
handler: function (button, event) {
if (this.bsnosql == undefined) {
var sql = this.getCondition();
} else {
var sql = this.sqlcontext;
}
var winAccess = new Shipping.DsQuery({
});
winAccess.StoreList = this.storeBodyAddList;
winAccess.formname = this.formname;
winAccess.condition = sql;
winAccess.show();
return;
},
scope: this
}
]
}]
}]
});
//#endregion formSearch
//#region 按钮ToolBar
//#endregion
this.storeBodyAddList = Ext.create('Ext.data.Store', {
model: 'MsOpBill',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpBill/GetBLListData',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 55,
items: [this.formSearch]
});
this.panelBodyChFee = new Ext.Panel({
title: '费用明细',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridListChFee]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelBodyChFee
]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.panelFee]
});
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.storeDefValue.load({ params: { condition: "BSTYPE='费用信息'" } });
//#endregion
//#region 事件绑定
this.storeList.on('beforeload', function (store) {
var sql = this.sqlcontext;
Ext.apply(store.proxy.extraParams, { condition: sql });
}, 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.BSNO;
this.storeBodyChFee.load({ params: { billno: bsno, type: 3, optype: ''} });
}, this);
//#endregion
//#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示)
parentWin = window.parent.opener;
this.onAutoRefresh();
//#endregion
// this.SetBtnRight();
}, //end initUIComponents
onAutoRefresh: function () {
if (parentWin) {
var ret = parentWin.OprationSwap();
_this.strbsno = ret[3];
_this.storeBodyAddList.load({
params: { start: 0, limit: 1000, sort: '', condition: _this.strbsno },
waitMsg: "正在查询数据...",
callback: function (r, options, success) {
if (success) {
}
},
scope: this
});
}
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onDsQuery: function (button, event) {
var sql = this.sqlcontext;
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 = '';
var selectedRecords = this.feeGridCheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
this.feeGridCheckBoxModel.selectAll();
selectedRecords = this.feeGridCheckBoxModel.selected.items;
}
for (i = 0; i < selectedRecords.length; i += 1) {
var memberyf = selectedRecords[i];
bodyDrChFeeDatas.push(memberyf);
}
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);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsChFee/PLHistryAdd',
scope: this,
params: {
bill: jsonbodyBill,
body: jsonChFeeBody
},
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
});
}
}
});
window.closeAction = 'destroy';
window.close();
},
GetHandleSerialNo: function (store, type) {
var result = 0;
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.Sort > result) {
result = member.data.Sort;
}
}
}
result = parseInt(result) + 1;
return result;
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var custName = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, custName, "CUSTOMERNAME='" + custName + "'");
var mblNo = form.findField('MblNo').getValue();
sql = sql + getAndConSql(sql, mblNo, " (CUSTNO like '%" + mblNo + "%' or CUSTOMNO like '%" + mblNo + "%' or MBLNO like '%" + mblNo + "%' or HBLNO like '%" + mblNo + "%') ");
var custDate_Min = form.findField('CustDate_Min').getRawValue();
sql = sql + getAndConSql(sql, custDate_Min, "ETD>= '" + custDate_Min + "'");
var custDate_Max = form.findField('CustDate_Max').getRawValue();
sql = sql + getAndConSql(sql, custDate_Max, "ETD <= '" + custDate_Max + " 23:59:59'");
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 + "%'");
return sql;
}
});