commit
7ea9605207
@ -1,204 +1,253 @@
|
||||
/**
|
||||
* Created by yixian on 2017-03-08.
|
||||
*/
|
||||
var commissionTypeMap = [{
|
||||
"label": 1,
|
||||
"value": "渠道计算法"
|
||||
var commissionTypeMap = [
|
||||
{
|
||||
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';
|
||||
var app = angular.module('orgcommission', ['ui.router']);
|
||||
app.config(['$stateProvider', function ($stateProvider) {
|
||||
$stateProvider.state('analysis_org.commission', {
|
||||
'use strict'
|
||||
var app = angular.module('orgcommission', ['ui.router'])
|
||||
app.config([
|
||||
'$stateProvider',
|
||||
function ($stateProvider) {
|
||||
$stateProvider
|
||||
.state('analysis_org.commission', {
|
||||
url: '/org_commissions',
|
||||
templateUrl: '/static/config/orgcommission/templates/org_commission_root.html',
|
||||
controller: 'orgCommissionRootCtrl'
|
||||
}).state('analysis_org.commission.month', {
|
||||
controller: 'orgCommissionRootCtrl',
|
||||
})
|
||||
.state('analysis_org.commission.month', {
|
||||
url: '/commissionorg/months/{monthStr}',
|
||||
templateUrl: '/static/config/orgcommission/templates/org_commission_month_root.html',
|
||||
controller: 'commissionMonthRootCtrl'
|
||||
}).state('analysis_org.info', {
|
||||
controller: 'commissionMonthRootCtrl',
|
||||
})
|
||||
.state('analysis_org.info', {
|
||||
url: '/commissionorg/info',
|
||||
templateUrl: '/static/config/orgcommission/templates/org_commission_info.html',
|
||||
controller: 'commissionMonthRootCtrl'
|
||||
}).state('analysis_org.commission.month.org', {
|
||||
controller: 'commissionMonthRootCtrl',
|
||||
})
|
||||
.state('analysis_org.commission.month.org', {
|
||||
url: '/org',
|
||||
templateUrl: '/static/config/orgcommission/templates/org_commission_month.html',
|
||||
controller: 'orgCommissionMonthViewCtrl',
|
||||
resolve: {
|
||||
monthData: ['$http', '$stateParams', function ($http, $stateParams) {
|
||||
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr);
|
||||
}]
|
||||
}
|
||||
}).state('analysis_org.commission.month.referrer', {
|
||||
monthData: [
|
||||
'$http',
|
||||
'$stateParams',
|
||||
function ($http, $stateParams) {
|
||||
return $http.get('/sys/citypartner_prizes/months/' + $stateParams.monthStr)
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.state('analysis_org.commission.month.referrer', {
|
||||
url: '/referrer',
|
||||
templateUrl: '/static/config/referrercommission/templates/referrer_commission_month.html',
|
||||
controller: 'referrerCommissionMonthViewCtrl',
|
||||
resolve: {
|
||||
monthData: ['$http', '$stateParams', function ($http, $stateParams) {
|
||||
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr);
|
||||
}]
|
||||
}
|
||||
}).state('analysis_org.commission.month.org.orgdetail', {
|
||||
monthData: [
|
||||
'$http',
|
||||
'$stateParams',
|
||||
function ($http, $stateParams) {
|
||||
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr)
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.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', {
|
||||
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', {
|
||||
url: '/referrer_commissions/{orgId}',
|
||||
templateUrl: '/static/config/referrercommission/templates/referrer_commission_detail.html',
|
||||
controller: 'referrerCommissionOrgDetailCtrl',
|
||||
resolve: {
|
||||
detail: ['$http', '$stateParams', function ($http, $stateParams) {
|
||||
return $http.get('/sys/citypartner_prizes/referrer/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId);
|
||||
}]
|
||||
}
|
||||
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) {
|
||||
},
|
||||
])
|
||||
app.controller('commissionMonthRootCtrl', [
|
||||
'$scope',
|
||||
'$state',
|
||||
function ($scope, $state) {
|
||||
if ($state.is('analysis_org.commission.month')) {
|
||||
$state.go('.org');
|
||||
$state.go('.org')
|
||||
}
|
||||
}]);
|
||||
app.controller('orgCommissionRootCtrl', ['$scope', '$http', '$filter', '$state', 'commonDialog',
|
||||
},
|
||||
])
|
||||
app.controller('orgCommissionRootCtrl', [
|
||||
'$scope',
|
||||
'$http',
|
||||
'$filter',
|
||||
'$state',
|
||||
'commonDialog',
|
||||
function ($scope, $http, $filter, $state, commonDialog) {
|
||||
$scope.generate = {};
|
||||
$scope.generate = {}
|
||||
$scope.generateOrgCommission = function () {
|
||||
$scope.generate.status = {};
|
||||
$scope.generate.status = {}
|
||||
if (!$scope.generate.month) {
|
||||
commonDialog.alert({
|
||||
type: 'error', title: 'Error', content: 'Select a month first!'
|
||||
});
|
||||
return;
|
||||
type: 'error',
|
||||
title: 'Error',
|
||||
content: 'Select a month first!',
|
||||
})
|
||||
return
|
||||
}
|
||||
commonDialog.confirm({
|
||||
commonDialog
|
||||
.confirm({
|
||||
title: 'Confirm',
|
||||
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 () {
|
||||
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.generate.status = null;
|
||||
}, function (resp) {
|
||||
commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message});
|
||||
})
|
||||
})
|
||||
};
|
||||
$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.generate.status = null
|
||||
},
|
||||
function (resp) {
|
||||
commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message })
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
$scope.params = { year: new Date() }
|
||||
$scope.loadAvailableMonths = function () {
|
||||
const year = $scope.params.year.getFullYear()
|
||||
$http.get('/sys/citypartner_prizes/months', { params: { year: year } }).then(function (resp) {
|
||||
$scope.availableMonths = resp.data
|
||||
})
|
||||
}
|
||||
|
||||
$scope.loadAvailableMonths(new Date().getFullYear());
|
||||
$scope.loadAvailableMonths()
|
||||
$scope.months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
$scope.hasReport = function (mon) {
|
||||
var has = false;
|
||||
var has = false
|
||||
angular.forEach($scope.availableMonths, function (m) {
|
||||
if (mon == m.month) {
|
||||
has = true;
|
||||
has = true
|
||||
}
|
||||
})
|
||||
return has
|
||||
}
|
||||
});
|
||||
return has;
|
||||
};
|
||||
$scope.gotoMonth = function (mon) {
|
||||
if (mon) {
|
||||
$scope.params.month = mon;
|
||||
$scope.params.month = mon
|
||||
}
|
||||
var monthStr = $scope.params.year + '-' + $scope.params.month;
|
||||
var monthStr = $scope.params.year.getFullYear() + '-' + $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 = {};
|
||||
}
|
||||
},
|
||||
])
|
||||
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;
|
||||
$scope.seniors = resp.data
|
||||
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id == log.org_id) {
|
||||
$scope.ctrl.activeLog=null;
|
||||
return;
|
||||
$scope.ctrl.activeLog = null
|
||||
return
|
||||
}
|
||||
$scope.ctrl.activeLog=log;
|
||||
$scope.ctrl.activeLog = log
|
||||
})
|
||||
|
||||
}
|
||||
}]);
|
||||
app.controller('orgCommissionOrgDetailCtrl', ['$scope', 'detail', function ($scope, detail) {
|
||||
$scope.detail = detail.data;
|
||||
$scope.ctrl = {};
|
||||
},
|
||||
])
|
||||
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 = null
|
||||
return
|
||||
}
|
||||
$scope.ctrl.activeLog=log;
|
||||
$scope.ctrl.activeLog = log
|
||||
}
|
||||
}]);
|
||||
},
|
||||
])
|
||||
|
||||
app.controller('referrerCommissionMonthViewCtrl', ['$scope', 'monthData', function ($scope, monthData) {
|
||||
$scope.monthData = monthData.data;
|
||||
$scope.ctrl = {};
|
||||
app.controller('referrerCommissionMonthViewCtrl', [
|
||||
'$scope',
|
||||
'monthData',
|
||||
function ($scope, monthData) {
|
||||
$scope.monthData = monthData.data
|
||||
$scope.ctrl = {}
|
||||
$scope.active = function (log) {
|
||||
if ($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id == log.org_id) {
|
||||
$scope.ctrl.activeLog=null;
|
||||
return;
|
||||
$scope.ctrl.activeLog = null
|
||||
return
|
||||
}
|
||||
$scope.ctrl.activeLog=log;
|
||||
$scope.ctrl.activeLog = log
|
||||
}
|
||||
}]);
|
||||
},
|
||||
])
|
||||
|
||||
app.controller('referrerCommissionOrgDetailCtrl', ['$scope', 'detail', function ($scope, detail) {
|
||||
$scope.detail = detail.data;
|
||||
$scope.ctrl = {};
|
||||
app.controller('referrerCommissionOrgDetailCtrl', [
|
||||
'$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 = null
|
||||
return
|
||||
}
|
||||
$scope.ctrl.activeLog=log;
|
||||
$scope.ctrl.activeLog = log
|
||||
}
|
||||
}]);
|
||||
},
|
||||
])
|
||||
|
||||
app.filter('commission_type_filter', function () {
|
||||
return function (sectorValue) {
|
||||
var sectorLabel = '';
|
||||
var sectorLabel = ''
|
||||
angular.forEach(commissionTypeMap, function (sector) {
|
||||
if (sector.label == sectorValue) {
|
||||
sectorLabel = sector.value;
|
||||
sectorLabel = sector.value
|
||||
}
|
||||
});
|
||||
return sectorLabel;
|
||||
})
|
||||
return sectorLabel
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return app;
|
||||
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
return app
|
||||
})
|
||||
|
Loading…
Reference in new issue