@ -243,6 +243,8 @@ 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 ;
@ -250,6 +252,9 @@ 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 [
@ -266,7 +271,44 @@ 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 ) ] ) ;
function attachAnalysis ( analysisItem ) {
analysisItem . settles . push ( settleItem ) ;
analysisItem . clients ++ ;
analysisItem . settleAmount = Decimal . add ( analysisItem . settleAmount , settleItem . clearing _amount ) . toFixed ( 2 , Decimal . ROUND _FLOOR ) ;
}
} ) ;
$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 ;
} ;
angular . forEach ( $scope . detail . details , function ( settleItem ) {
var settleDays = settleItem . clear _days ;
@ -279,6 +321,10 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
analysisItem . settleAmount = Decimal . add ( analysisItem . settleAmount , settleItem . clearing _amount ) . toFixed ( 2 , Decimal . ROUND _FLOOR ) ;
}
} ) ;
t1Amount = $scope . settleAnalysis [ 0 ] . settleAmount ;
t2Amount = $scope . settleAnalysis [ 1 ] . settleAmount ;
t3Amount = $scope . settleAnalysis [ 2 ] . settleAmount ;
var nowStr = $filter ( 'date' ) ( new Date ( ) , "yyyy-MM-dd" ) ;
$scope . datePattern = $stateParams . date ;
if ( $scope . datePattern == nowStr ) {