@ -243,8 +243,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} ] ) ;
} ] ) ;
app . controller ( 'settlementDetailCtrl' , [ '$scope' , '$stateParams' , '$http' , '$uibModal' , '$filter' , '$state' , 'detail' , 'commonDialog' ,
app . controller ( 'settlementDetailCtrl' , [ '$scope' , '$stateParams' , '$http' , '$uibModal' , '$filter' , '$state' , 'detail' , 'commonDialog' ,
function ( $scope , $stateParams , $http , $uibModal , $filter , $state , detail , commonDialog ) {
function ( $scope , $stateParams , $http , $uibModal , $filter , $state , detail , commonDialog ) {
$scope . allButton = false ;
$scope . limitButton = true ;
$scope . detail = detail . data ;
$scope . detail = detail . data ;
$scope . hasSentMail = false ;
$scope . hasSentMail = false ;
$scope . sendNotice = false ;
$scope . sendNotice = false ;
@ -252,9 +250,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope . analysisFilter = { } ;
$scope . analysisFilter = { } ;
$scope . currentAnalysis = $scope . detail ;
$scope . currentAnalysis = $scope . detail ;
$scope . pageCtrl = { visible : { } } ;
$scope . pageCtrl = { visible : { } } ;
var t1Amount = 0 ;
var t2Amount = 0 ;
var t3Amount = 0 ;
function getAnalysisTemplate ( ) {
function getAnalysisTemplate ( ) {
return [
return [
@ -271,45 +266,35 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} ;
} ;
angular . forEach ( $scope . detail . logs , function ( batch ) {
angular . forEach ( $scope . detail . logs , function ( batch ) {
$scope . batchAnalysis [ batch . clearing _id + '' ] = getAnalysisTemplate ( ) ;
$scope . batchAnalysis [ batch . clearing _id + '' ] = getAnalysisTemplate ( ) ;
} ) ;
$scope . allClearing = function ( ) {
$http . get ( '/sys/settlement/reports/' + $stateParams . date + '/all' ) . then ( function ( resp ) {
angular . forEach ( $scope . settleAnalysis , function ( list ) {
list . settles . splice ( 0 , list . settles . length ) ;
list . clients = 0 ;
list . settleAmount = 0 ;
} ) ;
} ) ;
angular . forEach ( resp . data . details , function ( settleItem ) {
$scope . endIndexMap = { } ;
var settleDays = settleItem . clear _days ;
$scope . initEndIndex = 20 ;
attachAnalysis ( $scope . settleAnalysis [ Math . min ( settleDays - 1 , 2 ) ] ) ;
attachAnalysis ( $scope . batchAnalysis [ settleItem . clearing _id + '' ] [ Math . min ( settleDays - 1 , 2 ) ] ) ;
function attachAnalysis ( analysisItem ) {
$scope . more = function ( key ) {
analysisItem . settles . push ( settleItem ) ;
analysisItem . clients ++ ;
var endIndex = $scope . endIndexMap [ key ] + $scope . initEndIndex ;
analysisItem . settleAmount = Decimal . add ( analysisItem . settleAmount , settleItem . clearing _amount ) . toFixed ( 2 , Decimal . ROUND _FLOOR ) ;
$scope . endIndexMap [ key ] = endIndex ;
if ( endIndex > $scope . clientsMap [ key ] . clients ) {
$scope . endIndexMap [ key ] = $scope . clientsMap [ key ] . clients ;
}
}
} ) ;
$scope . allButton = true ;
$scope . limitButton = false ;
} ) ;
} ;
} ;
$scope . packup = function ( ) {
$scope . packup = function ( key ) {
angular . forEach ( $scope . settleAnalysis , function ( list ) {
$scope . endIndexMap [ key ] = $scope . initEndIndex ;
list . settles . splice ( 20 , list . settles . length ) ;
var length = $scope . clientsMap [ key ] ;
list . clients = 20 ;
if ( length <= $scope . initEndIndex )
} ) ;
$scope . endIndexMap [ key ] = length ;
$scope . settleAnalysis [ 0 ] . settleAmount = t1Amount ;
} ;
$scope . settleAnalysis [ 1 ] . settleAmount = t2Amount ;
$scope . settleAnalysis [ 2 ] . settleAmount = t3Amount ;
$scope . allButton = false ;
$scope . limitButton = true ;
$scope . displayAll = function ( key ) {
var length = $scope . clientsMap [ key ] . clients ;
$scope . endIndexMap [ key ] = length ;
} ;
} ;
angular . forEach ( $scope . detail . details , function ( settleItem ) {
angular . forEach ( $scope . detail . details , function ( settleItem ) {
var settleDays = settleItem . clear _days ;
var settleDays = settleItem . clear _days ;
attachAnalysis ( $scope . settleAnalysis [ Math . min ( settleDays - 1 , 2 ) ] ) ;
attachAnalysis ( $scope . settleAnalysis [ Math . min ( settleDays - 1 , 2 ) ] ) ;
@ -322,9 +307,16 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}
}
} ) ;
} ) ;
t1Amount = $scope . settleAnalysis [ 0 ] . settleAmount ;
$scope . clientsMap = $scope . settleAnalysis ;
t2Amount = $scope . settleAnalysis [ 1 ] . settleAmount ;
t3Amount = $scope . settleAnalysis [ 2 ] . settleAmount ;
for ( var key in $scope . clientsMap ) {
$scope . endIndexMap [ key ] = $scope . initEndIndex ;
var length = $scope . clientsMap [ key ] . clients ;
if ( length <= $scope . initEndIndex )
$scope . endIndexMap [ key ] = length ;
}
var nowStr = $filter ( 'date' ) ( new Date ( ) , "yyyy-MM-dd" ) ;
var nowStr = $filter ( 'date' ) ( new Date ( ) , "yyyy-MM-dd" ) ;
$scope . datePattern = $stateParams . date ;
$scope . datePattern = $stateParams . date ;
if ( $scope . datePattern == nowStr ) {
if ( $scope . datePattern == nowStr ) {