@ -243,8 +243,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} ] ) ;
app . controller ( 'settlementDetailCtrl' , [ '$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 . hasSentMail = false ;
$scope . sendNotice = false ;
@ -252,9 +250,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope . analysisFilter = { } ;
$scope . currentAnalysis = $scope . detail ;
$scope . pageCtrl = { visible : { } } ;
var t1Amount = 0 ;
var t2Amount = 0 ;
var t3Amount = 0 ;
function getAnalysisTemplate ( ) {
return [
@ -271,45 +266,35 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} ;
angular . forEach ( $scope . detail . logs , function ( batch ) {
$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 ) {
var settleDays = settleItem . clear _days ;
attachAnalysis ( $scope . settleAnalysis [ Math . min ( settleDays - 1 , 2 ) ] ) ;
attachAnalysis ( $scope . batchAnalysis [ settleItem . clearing _id + '' ] [ Math . min ( settleDays - 1 , 2 ) ] ) ;
$scope . endIndexMap = { } ;
$scope . initEndIndex = 20 ;
function attachAnalysis ( analysisItem ) {
analysisItem . settles . push ( settleItem ) ;
analysisItem . clients ++ ;
analysisItem . settleAmount = Decimal . add ( analysisItem . settleAmount , settleItem . clearing _amount ) . toFixed ( 2 , Decimal . ROUND _FLOOR ) ;
$scope . more = function ( key ) {
var endIndex = $scope . endIndexMap [ key ] + $scope . initEndIndex ;
$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 ( ) {
angular . forEach ( $scope . settleAnalysis , function ( list ) {
list . settles . splice ( 20 , list . settles . length ) ;
list . clients = 20 ;
} ) ;
$scope . settleAnalysis [ 0 ] . settleAmount = t1Amount ;
$scope . settleAnalysis [ 1 ] . settleAmount = t2Amount ;
$scope . settleAnalysis [ 2 ] . settleAmount = t3Amount ;
$scope . allButton = false ;
$scope . limitButton = true ;
$scope . packup = function ( key ) {
$scope . endIndexMap [ key ] = $scope . initEndIndex ;
var length = $scope . clientsMap [ key ] ;
if ( length <= $scope . initEndIndex )
$scope . endIndexMap [ key ] = length ;
} ;
$scope . displayAll = function ( key ) {
var length = $scope . clientsMap [ key ] . clients ;
$scope . endIndexMap [ key ] = length ;
} ;
angular . forEach ( $scope . detail . details , function ( settleItem ) {
var settleDays = settleItem . clear _days ;
attachAnalysis ( $scope . settleAnalysis [ Math . min ( settleDays - 1 , 2 ) ] ) ;
@ -322,9 +307,16 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}
} ) ;
t1Amount = $scope . settleAnalysis [ 0 ] . settleAmount ;
t2Amount = $scope . settleAnalysis [ 1 ] . settleAmount ;
t3Amount = $scope . settleAnalysis [ 2 ] . settleAmount ;
$scope . clientsMap = $scope . settleAnalysis ;
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" ) ;
$scope . datePattern = $stateParams . date ;
if ( $scope . datePattern == nowStr ) {