Ext . namespace ( 'Shipping' ) ;
Shipping . MsOpCtnBsCardProfitIndex = function ( config ) {
Ext . applyIf ( this , config ) ;
this . initUIComponents ( ) ;
window . Shipping . MsOpCtnBsCardProfitIndex . superclass . constructor . call ( this ) ;
} ;
Ext . extend ( Shipping . MsOpCtnBsCardProfitIndex , Ext . Panel , {
OprationStatus : null , //仅当弹出界面时使用
SelectedRecord : null ,
sqlcontext : '' ,
PageSize : 100 ,
sortfield : '' ,
sortdire : '' ,
initUIComponents : function ( ) {
this . formname = "formMsOpCtnBsCardProfitIndex" ; //页面名称
//定义数据集
this . storeList = Ext . create ( 'Ext.data.Store' , {
model : 'MsOpCtnBsCard' ,
pageSize : this . PageSize ,
remoteSort : true ,
proxy : {
type : 'ajax' ,
url : '/MvcContainer/MsOpCtnBsCard/GetDataFeeList' ,
reader : {
id : 'GID' ,
root : 'data' ,
totalProperty : 'totalCount'
}
}
} ) ;
Ext . grid . RowNumberer = Ext . extend ( Ext . grid . RowNumberer , {
width : 30
} ) ;
this . Pagenum = Ext . create ( 'Ext.form.field.Number' , {
name : 'bottles' ,
fieldLabel : '每页记录数' ,
labelAlign : 'right' ,
value : this . PageSize ,
maxValue : 100000 ,
width : 170 ,
minValue : 0 ,
listeners : {
specialkey : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} )
this . initgirdcolums = [ {
sortable : true ,
id : '' ,
dataIndex : '' ,
header : '' ,
width : 0
} , {
sortable : true ,
dataIndex : 'GID' ,
header : 'GID' ,
hidden : true ,
width : 120
} , {
sortable : true ,
dataIndex : 'COMPANYID' ,
header : 'COMPANYID' ,
hidden : true ,
width : 120
} , {
sortable : true ,
dataIndex : 'PORTLOAD' ,
header : '起运港' ,
width : 200
} , {
sortable : true ,
dataIndex : 'DESTPORT' ,
header : '目的港' ,
width : 130
} , {
sortable : true ,
dataIndex : 'CTNNO' ,
header : '罐号' ,
width : 100
} , {
sortable : true ,
dataIndex : 'CUSTNO' ,
header : '委托编号' ,
width : 120
} , {
sortable : true ,
dataIndex : 'CUSTOMERNAME' ,
header : '委托单位' ,
width : 200
} , {
sortable : true ,
dataIndex : 'GOODSNAME' ,
header : '货物名称' ,
width : 100
} , {
sortable : true ,
dataIndex : 'AGENTNAME' ,
header : '代理' ,
width : 100
} , {
sortable : true ,
dataIndex : 'LINES' ,
header : '线路' ,
width : 200
} , {
sortable : true ,
dataIndex : 'PORTLOAD_CNT_TIME' ,
header : '提箱日期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'ETD' ,
header : '开船日期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'RTCNT_TIME' ,
header : '空罐返场站日期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'NPORTLOAD_CNT_TIME' ,
header : '下循环提箱日期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'NETD' ,
header : '下循环开船日期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'CYCLE_CNTDAY' ,
header : '闲置天数' ,
width : 100
} , {
sortable : true ,
dataIndex : 'CYCLE_DAY' ,
header : '周期' ,
width : 100
} , {
sortable : true ,
dataIndex : 'APPLYNO' ,
header : '放箱申请单号' ,
width : 100
} , {
sortable : true ,
dataIndex : 'GXFUSDDR' ,
text : '罐箱收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'XSFDRTTLINUSD' ,
text : '超期箱使费收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'HDFDR' ,
text : '换单费收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'OTDRTTLINUSD' ,
text : '其他收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'TTLCRINUSD' ,
text : '成本' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'PROFITINUSD' ,
text : '总租金收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'DAYPROFITINUSD' ,
text : '日租金收入' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'RENTPROFITINUSD' ,
text : '实际租金' ,
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 ; } ,
align : 'right' ,
width : 80
} , {
sortable : true ,
dataIndex : 'OPPROFITINUSD' ,
text : '租金盈亏' ,
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 ; } ,
align : 'right' ,
width : 80
}
] ;
this . girdcolums = this . initgirdcolums ;
this . GridCheckBoxModel = Ext . create ( 'Ext.selection.CheckboxModel' ) ;
_this = this ;
//定义Grid
this . gridList = new Ext . grid . GridPanel ( {
store : this . storeList ,
enableHdMenu : false ,
region : 'center' ,
loadMask : { msg : "数据加载中,请稍等..." } ,
trackMouseOver : true ,
disableSelection : false ,
selModel : this . GridCheckBoxModel ,
columns : this . girdcolums
,
// paging bar on the bottom
bbar : [ Ext . create ( 'Ext.PagingToolbar' , {
store : this . storeList ,
displayInfo : true ,
displayMsg : '当前显示 {0} - {1}条记录 /共 {2}条记录' ,
emptyMsg : "没有数据"
} ) , this . Pagenum ]
} ) ;
this . girdcolums = DsTruck . GetGridPanel ( USERID , this . formname , this . girdcolums , 1 ) ; //使用者id, 表名, 中间column数组, 跳过一开始的几列
this . girdcolums . unshift ( new Ext . grid . RowNumberer ( ) ) ;
this . gridList . reconfigure ( this . storeList , this . girdcolums ) ;
this . gridList . addListener ( 'itemdblclick' , function ( dataview , record , item , index , e , b ) {
this . SelectedRecord = record ;
this . OprationStatus = 'edit' ;
DsOpenEditWin ( '/MvcContainer/MsOpCtnBsCard/CtnStatusEdit' , record . data . GID ) ;
} , this ) ;
// this.gridList.columns[1] = new Ext.grid.RowNumberer();
//#region formSearch 查询面板
_this = this ;
//客户加载_委托单位
this . storeCustCode = Ext . create ( 'DsExt.ux.RefTableStore' , {
model : 'DsShipping.ux.CustomRefModel' ,
proxy : { url : '/CommMng/BasicDataRef/GetCustomRefList' }
} ) ;
this . storeCustCode . load ( { params : { condition : "ISCONTROLLER='1'" } } ) ;
//委托单位
_this = this ;
this . comboxCustCode = Ext . create ( 'DsExt.ux.RefTableCombox' , {
fieldLabel : '委托单位' ,
store : this . storeCustCode ,
forceSelection : true ,
name : 'CUSTOMERNAME' ,
valueField : 'CustName' ,
displayField : 'CodeAndName' ,
enableKeyEvents : true ,
listeners : {
keyup : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} ) ;
this . StoreDateType = Ext . create ( 'Ext.data.Store' , {
fields : [ 'ID' , 'NAME' ]
} ) ;
this . StoreDateType . add ( { "ID" : "CNT" , "NAME" : "提箱日期" } ) ;
this . StoreDateType . add ( { "ID" : "ETD" , "NAME" : "开船日期" } ) ;
this . comboxDateType = Ext . create ( 'DsExt.ux.RefTableCombox' , {
fieldLabel : '周期计算' ,
store : this . StoreDateType ,
forceSelection : true ,
name : 'DATETYPE' ,
value : 'ETD' ,
valueField : 'ID' ,
displayField : 'NAME' ,
enableKeyEvents : true ,
listeners : {
keyup : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} ) ;
this . formSearch = Ext . widget ( 'form' , {
frame : true ,
region : 'center' ,
bodyPadding : 5 ,
fieldDefaults : {
margins : '2 2 2 2' ,
labelAlign : 'right' ,
flex : 1 ,
labelWidth : 60 ,
msgTarget : 'qtip'
} ,
items : [ { //fieldset 1
xtype : 'container' ,
defaultType : 'textfield' ,
layout : 'anchor' ,
defaults : {
anchor : '100%'
} ,
items : [ {
xtype : 'container' ,
layout : 'hbox' ,
defaultType : 'textfield' ,
items : [ {
fieldLabel : '箱号' ,
name : 'CTNNO' ,
enableKeyEvents : true ,
listeners : {
specialkey : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} , {
fieldLabel : '编号' ,
name : 'BSNO' ,
enableKeyEvents : true ,
listeners : {
specialkey : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} , this . comboxCustCode , {
fieldLabel : '开船日期' ,
format : 'Y-m-d' ,
xtype : 'datefield' ,
name : 'ETDbgn' ,
enableKeyEvents : true ,
listeners : {
specialkey : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} , {
fieldLabel : '到' ,
format : 'Y-m-d' ,
xtype : 'datefield' ,
name : 'ETDend' ,
enableKeyEvents : true ,
listeners : {
specialkey : function ( field , e ) {
if ( e . getKey ( ) == e . ENTER ) {
_this . onRefreshClick ( ) ;
}
}
}
} , this . comboxDateType , {
xtype : 'button' ,
width : 90 ,
text : "执行查询" ,
iconCls : "btnrefresh" ,
handler : function ( button , event ) {
this . onRefreshClick ( button , event ) ;
} ,
scope : this
} , {
xtype : 'button' ,
width : 90 ,
text : "高级查询" ,
iconCls : "btnmore" ,
handler : function ( button , event ) {
var sql = this . getCondition ( ) ;
var winAccess = new Shipping . DsQuery ( {
} ) ;
winAccess . StoreList = this . storeList ;
winAccess . formname = this . formname ;
winAccess . condition = sql ;
winAccess . show ( ) ;
return ;
} ,
scope : this
} ]
}
] //end items(fieldset 1)
} ] //end root items
} ) ;
//#endregion formSearch
//查询工具条
this . panelBtn = new Ext . Panel ( {
region : "north" ,
tbar : [
{
text : "执行查询" ,
iconCls : "btnrefresh" ,
handler : function ( button , event ) {
this . onRefreshClick ( button , event ) ;
} ,
scope : this
} ,
{
text : "重置条件" ,
iconCls : "btnreset" ,
handler : function ( button , event ) {
} ,
scope : this
} , '-' ,
{
text : "打印" ,
iconCls : 'btnprint' ,
menu : [
{ text : "全部" ,
handler : function ( menu , event ) {
_this . Print ( ) ;
}
} , { text : "选择打印" ,
handler : function ( menu , event ) {
_this . PrintSelect ( ) ;
}
} ] ,
scope : this
} , '-' , {
text : "保存列表样式" ,
id : "btntest" ,
menu : [
{ text : "保存" ,
handler : function ( button , event ) {
this . girdcolums = DsTruck . SaveGridPanel ( USERID , _this . formname , _this . gridList . columns , _this . girdcolums , 1 , true ) ;
}
} , { text : "初始化" ,
handler : function ( menu , event ) {
_this . InitGrid ( _this . initgirdcolums ) ;
_this . girdcolums = DsTruck . SaveGridPanel ( USERID , _this . formname , _this . gridList . columns , _this . initgirdcolums , 1 , true ) ;
}
} ] ,
scope : this
} , '-' , {
text : "导出Excel" ,
id : "btnExportExcel" ,
iconCls : 'btnexportexcel' ,
handler : function ( button , event ) {
this . onExportClick ( button , event ) ;
} ,
scope : this
}
]
} ) ;
this . panelTop = new Ext . Panel ( {
layout : "border" ,
region : "north" ,
height : 75 ,
items : [ this . formSearch , this . panelBtn ]
} ) ;
Ext . apply ( this , {
items : [ this . panelTop , this . gridList ]
} ) ;
this . sqlcontext = '' ;
this . storeList . on ( 'beforeload' , function ( store ) {
var datetype = this . formSearch . getForm ( ) . findField ( 'DATETYPE' ) . getValue ( ) ;
Ext . apply ( store . proxy . extraParams , { condition : _this . sqlcontext , datatype : datetype } ) ;
} , this ) ;
this . onRefreshClick ( ) ;
} , //end initUIComponents
InitGrid : function ( grid ) {
var agirdcolums = grid ;
this . gridList . reconfigure ( this . storeList , agirdcolums ) ;
} ,
onRefreshClick : function ( button , event ) {
var sql = this . getCondition ( ) ;
this . sqlcontext = sql ;
this . PageSize = this . Pagenum . getValue ( ) ;
this . storeList . pageSize = this . PageSize ;
var datetype = this . formSearch . getForm ( ) . findField ( 'DATETYPE' ) . getValue ( ) ;
this . storeList . load ( {
params : { start : 0 , limit : this . PageSize , sort : '' , condition : sql , datetype : datetype } ,
waitMsg : "正在查询数据..." ,
scope : this
} ) ;
} ,
onDsQuery : function ( ) {
var sql = this . sqlcontext ;
var datetype = this . formSearch . getForm ( ) . findField ( 'DATETYPE' ) . getValue ( ) ;
this . PageSize = this . Pagenum . getValue ( ) ;
this . storeList . pageSize = this . PageSize ;
this . storeList . load ( {
params : { start : 0 , limit : this . PageSize , sort : '' , condition : sql , datetype : datetype } ,
waitMsg : "正在查询数据..." ,
scope : this
} ) ;
} ,
getCondition : function ( ) {
var form = this . formSearch . getForm ( ) ;
if ( ! form . isValid ( ) ) {
Ext . Msg . alert ( '提示' , '查询条件赋值错误,请检查。' ) ;
return '' ;
}
var sql = '' ;
var BSNO = form . findField ( 'BSNO' ) . getValue ( ) ;
sql = sql + getAndConSql ( sql , BSNO , " (b.BSNO like '%" + BSNO + "%' or b.CUSTNO like '%" + BSNO + "%' or b.I_CUSTNO like '%" + BSNO + "%' or b.MBLNO like '%" + BSNO + "%' ) " ) ;
var CTNNO = form . findField ( 'CTNNO' ) . getValue ( ) ;
sql = sql + getAndConSql ( sql , CTNNO , "b.CTNNO like '%" + CTNNO + "%'" ) ;
var CUSTOMERNAME = form . findField ( 'CUSTOMERNAME' ) . getValue ( ) ;
sql = sql + getAndConSql ( sql , CUSTOMERNAME , "b.CUSTOMERNAME='" + CUSTOMERNAME + "'" ) ;
var expDateBgn = form . findField ( 'ETDbgn' ) . getRawValue ( ) ;
sql = sql + getAndConSql ( sql , expDateBgn , "b.ETD>='" + expDateBgn + "'" ) ;
var expDateEnd = form . findField ( 'ETDend' ) . getRawValue ( ) ;
sql = sql + getAndConSql ( sql , expDateEnd , "b.ETD<='" + expDateEnd + " 23:59:59'" ) ;
return sql ;
} ,
OprationSwap : function ( ) {
var ret = new Array ( ) ;
ret [ 0 ] = this . OprationStatus ;
ret [ 1 ] = this . storeList ;
ret [ 2 ] = this . SelectedRecord ;
return ret ;
} ,
onExportClick : function ( button , event ) {
_this = this ;
GridExportExcelPage ( this . gridList ) ;
} ,
Print : function ( ) {
_this = this ;
if ( this . storeList . getCount ( ) == 0 ) {
return ;
}
var bsno = '11111' ;
var selections = this . gridList . getSelectionModel ( ) . getSelection ( ) ;
if ( selections . length != 0 ) {
var record = selections [ 0 ] ;
bsno = record . data . GID ;
}
var datetype = this . formSearch . getForm ( ) . findField ( 'DATETYPE' ) . getValue ( ) ;
var sortstr = '' ;
if ( this . sortfield != '' && this . sortdire != '' ) {
sortstr = this . sortfield + ' ' + this . sortdire ;
}
Ext . Msg . wait ( '正在组织数据, 请稍侯..' ) ;
Ext . Ajax . request ( {
waitMsg : '正在组织数据...' ,
url : '/MvcContainer/MsOpCtnBsCard/GetDataFeeListStr' ,
scope : this ,
params : {
condition : _this . sqlcontext ,
printstr : 'true' ,
datetype : datetype ,
sort : sortstr
} ,
callback : function ( options , success , response ) {
if ( success ) {
Ext . MessageBox . hide ( ) ;
var jsonresult = Ext . JSON . decode ( response . responseText ) ;
if ( jsonresult . Success ) {
var returnstr = jsonresult . data ;
var printType = 'MSOPCTNBSCARDPR' ;
var sql1 = returnstr ;
var sql2 = "select * from op_ctnbscard where GID='" + bsno + "'" ;
var sql3 = "" ;
var sql4 = "" ;
var sql5 = "" ;
var sql6 = "" ;
PrintComm ( printType , sql1 , sql2 , sql3 , sql4 , sql5 , sql6 ) ;
} 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
} ) ;
}
}
} ) ;
} ,
PrintSelect : function ( ) {
_this = this ;
if ( this . storeList . getCount ( ) == 0 ) {
return ;
}
var selectedRecords = [ ] ;
var storeadd = null ;
selectedRecords = this . GridCheckBoxModel . selected . items ;
if ( selectedRecords . length == 0 ) {
Ext . Msg . show ( { title : '提示' , msg : '请先选择要打印的业务!' , icon : Ext . Msg . INFO , buttons : Ext . Msg . OK } ) ;
return ;
}
var sortstr = 'INPUTTIME ' ;
if ( this . sortfield != '' && this . sortdire != '' ) {
sortstr = this . sortfield + ' ' + this . sortdire ;
}
var feeGidSql = '' ;
for ( var i = 0 ; i < selectedRecords . length ; i ++ ) {
var record = selectedRecords [ i ] ;
var feeGId = "'" + record . get ( 'GID' ) + "'" ;
if ( feeGidSql == '' ) {
feeGidSql = feeGId ;
} else {
feeGidSql = feeGidSql + "," + feeGId ;
}
} ;
var bsno = '11111' ;
var selections = this . gridList . getSelectionModel ( ) . getSelection ( ) ;
if ( selections . length != 0 ) {
var record = selections [ 0 ] ;
bsno = record . data . GID ;
}
var printType = 'MSOPCTNBSCARDPRSELECT' ;
var sql1 = "select * from op_ctnbscard WHERE GID IN (" + feeGidSql + ") order by " + sortstr ;
var sql2 = "select * from op_ctnbscard where GID='" + bsno + "'" ;
var sql3 = "" ;
var sql4 = "" ;
var sql5 = "" ;
var sql6 = "" ;
PrintComm ( printType , sql1 , sql2 , sql3 , sql4 , sql5 , sql6 ) ;
}
} ) ;