parent
5cee205379
commit
c136dc6540
@ -1,204 +1,253 @@
|
|||||||
/**
|
/**
|
||||||
* Created by yixian on 2017-03-08.
|
* Created by yixian on 2017-03-08.
|
||||||
*/
|
*/
|
||||||
var commissionTypeMap = [{
|
var commissionTypeMap = [
|
||||||
"label": 1,
|
{
|
||||||
"value": "渠道计算法"
|
label: 1,
|
||||||
},
|
value: '渠道计算法',
|
||||||
{
|
},
|
||||||
"label": 2,
|
{
|
||||||
"value": "总交易额比例"
|
label: 2,
|
||||||
},
|
value: '总交易额比例',
|
||||||
{
|
},
|
||||||
"label": 3,
|
{
|
||||||
"value": "收益比例"
|
label: 3,
|
||||||
}
|
value: '收益比例',
|
||||||
];
|
},
|
||||||
define(['angular','../../analysis/org/analysis-org'], function (angular) {
|
]
|
||||||
'use strict';
|
define(['angular', '../../analysis/org/analysis-org'], function (angular) {
|
||||||
var app = angular.module('orgcommission', ['ui.router']);
|
'use strict'
|
||||||
app.config(['$stateProvider', function ($stateProvider) {
|
var app = angular.module('orgcommission', ['ui.router'])
|
||||||
$stateProvider.state('analysis_org.commission', {
|
app.config([
|
||||||
url: '/org_commissions',
|
'$stateProvider',
|
||||||
templateUrl: '/static/config/orgcommission/templates/org_commission_root.html',
|
function ($stateProvider) {
|
||||||
controller: 'orgCommissionRootCtrl'
|
$stateProvider
|
||||||
}).state('analysis_org.commission.month', {
|
.state('analysis_org.commission', {
|
||||||
url: '/commissionorg/months/{monthStr}',
|
url: '/org_commissions',
|
||||||
templateUrl: '/static/config/orgcommission/templates/org_commission_month_root.html',
|
templateUrl: '/static/config/orgcommission/templates/org_commission_root.html',
|
||||||
controller: 'commissionMonthRootCtrl'
|
controller: 'orgCommissionRootCtrl',
|
||||||
}).state('analysis_org.info', {
|
})
|
||||||
url: '/commissionorg/info',
|
.state('analysis_org.commission.month', {
|
||||||
templateUrl: '/static/config/orgcommission/templates/org_commission_info.html',
|
url: '/commissionorg/months/{monthStr}',
|
||||||
controller: 'commissionMonthRootCtrl'
|
templateUrl: '/static/config/orgcommission/templates/org_commission_month_root.html',
|
||||||
}).state('analysis_org.commission.month.org', {
|
controller: 'commissionMonthRootCtrl',
|
||||||
url: '/org',
|
})
|
||||||
templateUrl: '/static/config/orgcommission/templates/org_commission_month.html',
|
.state('analysis_org.info', {
|
||||||
controller: 'orgCommissionMonthViewCtrl',
|
url: '/commissionorg/info',
|
||||||
resolve: {
|
templateUrl: '/static/config/orgcommission/templates/org_commission_info.html',
|
||||||
monthData: ['$http', '$stateParams', function ($http, $stateParams) {
|
controller: 'commissionMonthRootCtrl',
|
||||||
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr);
|
})
|
||||||
}]
|
.state('analysis_org.commission.month.org', {
|
||||||
}
|
url: '/org',
|
||||||
}).state('analysis_org.commission.month.referrer', {
|
templateUrl: '/static/config/orgcommission/templates/org_commission_month.html',
|
||||||
url: '/referrer',
|
controller: 'orgCommissionMonthViewCtrl',
|
||||||
templateUrl: '/static/config/referrercommission/templates/referrer_commission_month.html',
|
resolve: {
|
||||||
controller: 'referrerCommissionMonthViewCtrl',
|
monthData: [
|
||||||
resolve: {
|
'$http',
|
||||||
monthData: ['$http', '$stateParams', function ($http, $stateParams) {
|
'$stateParams',
|
||||||
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr);
|
function ($http, $stateParams) {
|
||||||
}]
|
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr)
|
||||||
}
|
},
|
||||||
}).state('analysis_org.commission.month.org.orgdetail', {
|
],
|
||||||
url: '/citypartners/{orgId}',
|
},
|
||||||
templateUrl: '/static/config/orgcommission/templates/org_commission_detail.html',
|
})
|
||||||
controller: 'orgCommissionOrgDetailCtrl',
|
.state('analysis_org.commission.month.referrer', {
|
||||||
resolve: {
|
url: '/referrer',
|
||||||
detail: ['$http', '$stateParams', function ($http, $stateParams) {
|
templateUrl: '/static/config/referrercommission/templates/referrer_commission_month.html',
|
||||||
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId);
|
controller: 'referrerCommissionMonthViewCtrl',
|
||||||
}]
|
resolve: {
|
||||||
}
|
monthData: [
|
||||||
}).state('analysis_org.commission.month.referrer.referrerdetail', {
|
'$http',
|
||||||
url: '/referrer_commissions/{orgId}',
|
'$stateParams',
|
||||||
templateUrl: '/static/config/referrercommission/templates/referrer_commission_detail.html',
|
function ($http, $stateParams) {
|
||||||
controller: 'referrerCommissionOrgDetailCtrl',
|
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr)
|
||||||
resolve: {
|
},
|
||||||
detail: ['$http', '$stateParams', function ($http, $stateParams) {
|
],
|
||||||
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId);
|
},
|
||||||
}]
|
})
|
||||||
}
|
.state('analysis_org.commission.month.org.orgdetail', {
|
||||||
|
url: '/citypartners/{orgId}',
|
||||||
|
templateUrl: '/static/config/orgcommission/templates/org_commission_detail.html',
|
||||||
|
controller: 'orgCommissionOrgDetailCtrl',
|
||||||
|
resolve: {
|
||||||
|
detail: [
|
||||||
|
'$http',
|
||||||
|
'$stateParams',
|
||||||
|
function ($http, $stateParams) {
|
||||||
|
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId)
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}]);
|
.state('analysis_org.commission.month.referrer.referrerdetail', {
|
||||||
app.controller('commissionMonthRootCtrl', ['$scope', '$state', function ($scope, $state) {
|
url: '/referrer_commissions/{orgId}',
|
||||||
if($state.is('analysis_org.commission.month')){
|
templateUrl: '/static/config/referrercommission/templates/referrer_commission_detail.html',
|
||||||
$state.go('.org');
|
controller: 'referrerCommissionOrgDetailCtrl',
|
||||||
|
resolve: {
|
||||||
|
detail: [
|
||||||
|
'$http',
|
||||||
|
'$stateParams',
|
||||||
|
function ($http, $stateParams) {
|
||||||
|
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId)
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
])
|
||||||
|
app.controller('commissionMonthRootCtrl', [
|
||||||
|
'$scope',
|
||||||
|
'$state',
|
||||||
|
function ($scope, $state) {
|
||||||
|
if ($state.is('analysis_org.commission.month')) {
|
||||||
|
$state.go('.org')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
app.controller('orgCommissionRootCtrl', [
|
||||||
|
'$scope',
|
||||||
|
'$http',
|
||||||
|
'$filter',
|
||||||
|
'$state',
|
||||||
|
'commonDialog',
|
||||||
|
function ($scope, $http, $filter, $state, commonDialog) {
|
||||||
|
$scope.generate = {}
|
||||||
|
$scope.generateOrgCommission = function () {
|
||||||
|
$scope.generate.status = {}
|
||||||
|
if (!$scope.generate.month) {
|
||||||
|
commonDialog.alert({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Error',
|
||||||
|
content: 'Select a month first!',
|
||||||
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}]);
|
commonDialog
|
||||||
app.controller('orgCommissionRootCtrl', ['$scope', '$http', '$filter', '$state', 'commonDialog',
|
.confirm({
|
||||||
function ($scope, $http, $filter, $state, commonDialog) {
|
title: 'Confirm',
|
||||||
$scope.generate = {};
|
content: 'This operation will clear the data generated before, Are you sure?',
|
||||||
$scope.generateOrgCommission = function () {
|
})
|
||||||
$scope.generate.status = {};
|
.then(function () {
|
||||||
if (!$scope.generate.month) {
|
var params = { month: $filter('date')($scope.generate.month, 'yyyy-MM') }
|
||||||
commonDialog.alert({
|
$http.post('/sys/citypartner_prizes/generate', params).then(
|
||||||
type: 'error', title: 'Error', content: 'Select a month first!'
|
function () {
|
||||||
});
|
$state.go('.org.month', { monthStr: params.month })
|
||||||
return;
|
$scope.generate.status = null
|
||||||
}
|
},
|
||||||
commonDialog.confirm({
|
function (resp) {
|
||||||
title: 'Confirm',
|
commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message })
|
||||||
content: 'This operation will clear the data generated before, Are you sure?'
|
}
|
||||||
}).then(function () {
|
)
|
||||||
var params = {month: $filter('date')($scope.generate.month, 'yyyy-MM')};
|
})
|
||||||
$http.post('/sys/citypartner_prizes/generate', params).then(function () {
|
}
|
||||||
$state.go('.org.month', {monthStr: params.month})
|
$scope.params = { year: new Date() }
|
||||||
$scope.generate.status = null;
|
$scope.loadAvailableMonths = function () {
|
||||||
}, function (resp) {
|
const year = $scope.params.year.getFullYear()
|
||||||
commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message});
|
$http.get('/sys/citypartner_prizes/months', { params: { year: year } }).then(function (resp) {
|
||||||
})
|
$scope.availableMonths = resp.data
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
$scope.availableYears = [new Date().getFullYear()];
|
|
||||||
//当前年至2017年年份
|
|
||||||
for (var i = 1; i < new Date().getFullYear()-2017+1; i++) {
|
|
||||||
$scope.availableYears.push(new Date().getFullYear() - i);
|
|
||||||
}
|
|
||||||
$scope.params = {};
|
|
||||||
$scope.months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
||||||
$scope.loadAvailableMonths = function (year) {
|
|
||||||
$scope.params.year = year;
|
|
||||||
$http.get('/sys/citypartner_prizes/months', {params: {year: $scope.params.year}}).then(function (resp) {
|
|
||||||
$scope.availableMonths = resp.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.loadAvailableMonths(new Date().getFullYear());
|
|
||||||
$scope.hasReport = function (mon) {
|
|
||||||
var has = false;
|
|
||||||
angular.forEach($scope.availableMonths, function (m) {
|
|
||||||
if (mon == m.month) {
|
|
||||||
has = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return has;
|
|
||||||
};
|
|
||||||
$scope.gotoMonth = function (mon) {
|
|
||||||
if(mon){
|
|
||||||
$scope.params.month = mon;
|
|
||||||
}
|
|
||||||
var monthStr = $scope.params.year + '-' + $scope.params.month;
|
|
||||||
$state.go('analysis_org.commission.month', {monthStr: monthStr})
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}]);
|
|
||||||
app.controller('orgCommissionMonthViewCtrl', ['$scope', 'monthData','$http', function ($scope, monthData,$http) {
|
|
||||||
$scope.monthData = monthData.data;
|
|
||||||
$scope.ctrl = {};
|
|
||||||
$scope.commissionTypeMap = commissionTypeMap;
|
|
||||||
$scope.seniors = {};
|
|
||||||
$scope.active = function (log) {
|
|
||||||
$http.get('/sys/citypartner_prizes/senior/'+log.org_id+'/details?monthStr='+$scope.monthData.monthstr).then(function (resp) {
|
|
||||||
$scope.seniors = resp.data;
|
|
||||||
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){
|
|
||||||
$scope.ctrl.activeLog=null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.ctrl.activeLog=log;
|
|
||||||
})
|
|
||||||
|
|
||||||
|
$scope.loadAvailableMonths()
|
||||||
|
$scope.months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||||
|
$scope.hasReport = function (mon) {
|
||||||
|
var has = false
|
||||||
|
angular.forEach($scope.availableMonths, function (m) {
|
||||||
|
if (mon == m.month) {
|
||||||
|
has = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return has
|
||||||
|
}
|
||||||
|
$scope.gotoMonth = function (mon) {
|
||||||
|
if (mon) {
|
||||||
|
$scope.params.month = mon
|
||||||
}
|
}
|
||||||
}]);
|
var monthStr = $scope.params.year.getFullYear() + '-' + $scope.params.month
|
||||||
app.controller('orgCommissionOrgDetailCtrl', ['$scope', 'detail', function ($scope, detail) {
|
$state.go('analysis_org.commission.month', { monthStr: monthStr })
|
||||||
$scope.detail = detail.data;
|
}
|
||||||
$scope.ctrl = {};
|
},
|
||||||
$scope.active = function (log) {
|
])
|
||||||
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.client_moniker==log.client_moniker){
|
app.controller('orgCommissionMonthViewCtrl', [
|
||||||
$scope.ctrl.activeLog=null;
|
'$scope',
|
||||||
return;
|
'monthData',
|
||||||
}
|
'$http',
|
||||||
$scope.ctrl.activeLog=log;
|
function ($scope, monthData, $http) {
|
||||||
|
$scope.monthData = monthData.data
|
||||||
|
$scope.ctrl = {}
|
||||||
|
$scope.commissionTypeMap = commissionTypeMap
|
||||||
|
$scope.seniors = {}
|
||||||
|
$scope.active = function (log) {
|
||||||
|
$http.get('/sys/citypartner_prizes/senior/' + log.org_id + '/details?monthStr=' + $scope.monthData.monthstr).then(function (resp) {
|
||||||
|
$scope.seniors = resp.data
|
||||||
|
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id == log.org_id) {
|
||||||
|
$scope.ctrl.activeLog = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$scope.ctrl.activeLog = log
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
app.controller('orgCommissionOrgDetailCtrl', [
|
||||||
|
'$scope',
|
||||||
|
'detail',
|
||||||
|
function ($scope, detail) {
|
||||||
|
$scope.detail = detail.data
|
||||||
|
$scope.ctrl = {}
|
||||||
|
$scope.active = function (log) {
|
||||||
|
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.client_moniker == log.client_moniker) {
|
||||||
|
$scope.ctrl.activeLog = null
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}]);
|
$scope.ctrl.activeLog = log
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
app.controller('referrerCommissionMonthViewCtrl', ['$scope', 'monthData', function ($scope, monthData) {
|
app.controller('referrerCommissionMonthViewCtrl', [
|
||||||
$scope.monthData = monthData.data;
|
'$scope',
|
||||||
$scope.ctrl = {};
|
'monthData',
|
||||||
$scope.active = function (log) {
|
function ($scope, monthData) {
|
||||||
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){
|
$scope.monthData = monthData.data
|
||||||
$scope.ctrl.activeLog=null;
|
$scope.ctrl = {}
|
||||||
return;
|
$scope.active = function (log) {
|
||||||
}
|
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id == log.org_id) {
|
||||||
$scope.ctrl.activeLog=log;
|
$scope.ctrl.activeLog = null
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}]);
|
$scope.ctrl.activeLog = log
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
app.controller('referrerCommissionOrgDetailCtrl', ['$scope', 'detail', function ($scope, detail) {
|
app.controller('referrerCommissionOrgDetailCtrl', [
|
||||||
$scope.detail = detail.data;
|
'$scope',
|
||||||
$scope.ctrl = {};
|
'detail',
|
||||||
$scope.active = function (log) {
|
function ($scope, detail) {
|
||||||
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.client_moniker==log.client_moniker){
|
$scope.detail = detail.data
|
||||||
$scope.ctrl.activeLog=null;
|
$scope.ctrl = {}
|
||||||
return;
|
$scope.active = function (log) {
|
||||||
}
|
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.client_moniker == log.client_moniker) {
|
||||||
$scope.ctrl.activeLog=log;
|
$scope.ctrl.activeLog = null
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}]);
|
$scope.ctrl.activeLog = log
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
app.filter('commission_type_filter', function () {
|
app.filter('commission_type_filter', function () {
|
||||||
return function (sectorValue) {
|
return function (sectorValue) {
|
||||||
var sectorLabel = '';
|
var sectorLabel = ''
|
||||||
angular.forEach(commissionTypeMap, function (sector) {
|
angular.forEach(commissionTypeMap, function (sector) {
|
||||||
if (sector.label == sectorValue) {
|
if (sector.label == sectorValue) {
|
||||||
sectorLabel = sector.value;
|
sectorLabel = sector.value
|
||||||
}
|
|
||||||
});
|
|
||||||
return sectorLabel;
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
return sectorLabel
|
||||||
|
}
|
||||||
return app;
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
return app
|
||||||
|
})
|
||||||
|
Loading…
Reference in new issue