holiday config

master
yixian 4 years ago
parent 2f87d50253
commit 56210da57d

@ -413,12 +413,15 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
app.controller('settleDateConfigCtrl', ['$scope', '$http', '$filter', '$uibModal', 'commonDialog', function ($scope, $http, $filter, $uibModal, commonDialog) { app.controller('settleDateConfigCtrl', ['$scope', '$http', '$filter', '$uibModal', 'commonDialog', function ($scope, $http, $filter, $uibModal, commonDialog) {
$scope.loadMonthPlan = function (mon) { $scope.loadMonthPlan = function (mon) {
$http.get('/sysconfig/clear_days/months/' + $filter('date')(mon, 'yyyy-MM')).then(function (resp) { $http.get('/sysconfig/clear_days/months/' + $filter('date')(mon, 'yyyy-MM')).then(function (resp) {
$scope.activeDates = resp.data; $scope.activeDates = resp.data.reduce((map, item) => {
map[item.holiday] = item;
return map;
}, {});
}); });
$scope.currentMonth = mon; $scope.currentMonth = mon;
}; };
$scope.configHoliday = function (date) { $scope.configHoliday = function (date) {
let holiday = $scope.getHoliday(date); let holiday = $scope.activeDates[$filter('date')(date, 'yyyy/MM/dd')];
if (holiday == null) { if (holiday == null) {
holiday = {'holiday': date, regions: []} holiday = {'holiday': date, regions: []}
} }
@ -451,14 +454,14 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} }
}).result.then(function (operation) { }).result.then(function (operation) {
if (operation.operation === 'modify') { if (operation.operation === 'modify') {
$http.put('/sysconfig/clear_days/holidays/' + (operation.holiday.holiday.replace('/', '-')), operation.holiday).then(function () { $http.put('/sysconfig/holidays/' + (operation.holiday.holiday.replace(/\//g, '-')), operation.holiday).then(function () {
$scope.loadMonthPlan($scope.currentMonth); $scope.loadMonthPlan($scope.currentMonth);
commonDialog.alert({title: 'Success', content: 'Modified Holiday successful', type: 'success'}) commonDialog.alert({title: 'Success', content: 'Modified Holiday successful', type: 'success'})
}, function (resp) { }, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
}) })
} else if (operation.operation === 'delete') { } else if (operation.operation === 'delete') {
$http['delete']('/sysconfig/clear_days/holidays/' + operation.holiday).then(function () { $http['delete']('/sysconfig/holidays/' + operation.holiday).then(function () {
$scope.loadMonthPlan($scope.currentMonth); $scope.loadMonthPlan($scope.currentMonth);
}, function (resp) { }, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
@ -466,16 +469,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
} }
}) })
}; };
$scope.getHoliday = function (date) {
let dateStr = $filter('date')(date, 'yyyy/MM/dd');
for (let holiday of $scope.activeDates) {
if (holiday.holiday === dateStr) {
return holiday;
}
}
return null;
};
}]); }]);
app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', 'settleLogs', function ($scope, $http, $rootScope, $stateParams, settleLogs) { app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', 'settleLogs', function ($scope, $http, $rootScope, $stateParams, settleLogs) {
$scope.settleLogs = settleLogs.map(log => { $scope.settleLogs = settleLogs.map(log => {
@ -520,6 +513,33 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}); });
}; };
}]); }]);
app.directive('holidayBox', ['$parse', function ($parse) {
return {
restrict: 'EA',
scope: true,
templateUrl: '/static/analysis/templates/holiday_directive.html',
replace: true,
link: function ($scope, $elem, $attr) {
$scope.$watch($attr.holidayList, function (holidayList) {
$scope.self = $scope;
if (holidayList == null) {
return;
}
$scope.holiday = holidayList[$parse($attr.date)($scope)];
})
}
}
}]);
app.filter('holiday_filter', function () {
return function (holiday) {
console.log('holiday:', holiday);
debugger
return holiday
}
})
app.filter('channel_image', function () { app.filter('channel_image', function () {
return function (channel) { return function (channel) {

@ -3,7 +3,7 @@
*/ */
define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monitoring'], function (angular, echarts, $) { define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monitoring'], function (angular, echarts, $) {
'use strict'; 'use strict';
var app = angular.module('clientRatesModule', ['ui.router']); let app = angular.module('clientRatesModule', ['ui.router']);
app.config(['$stateProvider', function ($stateProvider) { app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('analysis_monitoring.client_rates', { $stateProvider.state('analysis_monitoring.client_rates', {
controller: 'clientRateRootCtrl', controller: 'clientRateRootCtrl',
@ -28,13 +28,13 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}) })
}; };
$scope.loadOrgChild = function () { $scope.loadOrgChild = function () {
var params = angular.copy($scope.params); let params = angular.copy($scope.params);
$http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) {
$scope.orgs_child = resp.data; $scope.orgs_child = resp.data;
}) })
}; };
$scope.loadBDUsers = function () { $scope.loadBDUsers = function () {
var params = angular.copy($scope.params); let params = angular.copy($scope.params);
params.begin = $filter('date')(params.begin, 'yyyyMMdd'); params.begin = $filter('date')(params.begin, 'yyyyMMdd');
params.end = $filter('date')(params.end, 'yyyyMMdd'); params.end = $filter('date')(params.end, 'yyyyMMdd');
if (!params.org_id) { if (!params.org_id) {
@ -51,7 +51,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}; };
$scope.chooseLastDays = function (days) { $scope.chooseLastDays = function (days) {
$scope.params.end = new Date(); $scope.params.end = new Date();
var begin = new Date(); let begin = new Date();
begin.setDate(begin.getDate() - days); begin.setDate(begin.getDate() - days);
$scope.params.begin = begin; $scope.params.begin = begin;
$scope.dateRangeChanged(); $scope.dateRangeChanged();
@ -111,7 +111,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}); });
$scope.loadDaysAnalysis = function () { $scope.loadDaysAnalysis = function () {
$scope.loading = true; $scope.loading = true;
var params = {}; let params = {};
params.begin = $filter('date')($scope.params.begin, 'yyyyMMdd'); params.begin = $filter('date')($scope.params.begin, 'yyyyMMdd');
params.end = $filter('date')($scope.params.end, 'yyyyMMdd'); params.end = $filter('date')($scope.params.end, 'yyyyMMdd');
if ($scope.extParams.noactive.enable) { if ($scope.extParams.noactive.enable) {
@ -148,7 +148,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
$scope.review = {review_date: new Date()}; $scope.review = {review_date: new Date()};
$scope.submit = function () { $scope.submit = function () {
$scope.errmsg = null; $scope.errmsg = null;
var review = angular.copy($scope.review); let review = angular.copy($scope.review);
review.review_date = $filter('date')(review.review_date, 'yyyyMMdd'); review.review_date = $filter('date')(review.review_date, 'yyyyMMdd');
$http.post('/analysis/client_rates/clients/' + client.client_moniker + '/review_events', review).then(function () { $http.post('/analysis/client_rates/clients/' + client.client_moniker + '/review_events', review).then(function () {
$scope.$close(); $scope.$close();
@ -189,7 +189,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
if (!$scope.extParams.noactive.enable && !$scope.extParams.transaction.enable) { if (!$scope.extParams.noactive.enable && !$scope.extParams.transaction.enable) {
return; return;
} }
var params = {}; let params = {};
params.begin = $filter('date')($scope.params.begin, 'yyyyMMdd'); params.begin = $filter('date')($scope.params.begin, 'yyyyMMdd');
params.end = $filter('date')($scope.params.end, 'yyyyMMdd'); params.end = $filter('date')($scope.params.end, 'yyyyMMdd');
if ($scope.extParams.noactive.enable) { if ($scope.extParams.noactive.enable) {
@ -220,10 +220,10 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}, },
link: function ($scope, $element, $attr) { link: function ($scope, $element, $attr) {
$scope.ctrl = {}; $scope.ctrl = {};
var resize = function () { let resize = function () {
setTimeout(function () { setTimeout(function () {
$('.analysis-box').width($('.active-rate-view').innerWidth() - $('.client-names').outerWidth() - 1) $('.analysis-box').width($('.active-rate-view').innerWidth() - $('.client-names').outerWidth() - 1)
},500); }, 500);
}; };
$($element).resize(resize); $($element).resize(resize);
@ -242,7 +242,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
return; return;
} }
$scope.clients = []; $scope.clients = [];
var maxRate = 0; let maxRate = 0;
angular.forEach(data.clients, function (client) { angular.forEach(data.clients, function (client) {
angular.forEach(client.trade_analysis, function (trade) { angular.forEach(client.trade_analysis, function (trade) {
maxRate = Math.max(maxRate, Math.log(Number(trade.total_amount))); maxRate = Math.max(maxRate, Math.log(Number(trade.total_amount)));
@ -250,19 +250,19 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}); });
angular.forEach(data.clients, function (client) { angular.forEach(data.clients, function (client) {
var cli = {client_moniker: client.client_moniker, trade_analysis: {}}; let cli = {client_moniker: client.client_moniker, trade_analysis: {}};
angular.forEach(client.trade_analysis, function (trade) { angular.forEach(client.trade_analysis, function (trade) {
trade = angular.copy(trade); trade = angular.copy(trade);
cli.trade_analysis[$filter('date')(new Date(trade.create_date), 'yyyyMMdd')] = trade; cli.trade_analysis[$filter('date')(new Date(trade.create_date), 'yyyyMMdd')] = trade;
var rate = Math.log(Number(trade.total_amount)); let rate = Math.log(Number(trade.total_amount));
var h = 45 - parseInt(45 * rate / maxRate); let h = 45 - parseInt(45 * rate / maxRate);
trade.style = {background: 'hsl(' + h + ',70%,60%)'}; trade.style = {background: 'hsl(' + h + ',70%,60%)'};
trade.client = cli; trade.client = cli;
}); });
angular.forEach(client.events, function (evt) { angular.forEach(client.events, function (evt) {
var date = new Date(evt.date); let date = new Date(evt.date);
var trade = cli.trade_analysis[$filter('date')(date, 'yyyyMMdd')]; let trade = cli.trade_analysis[$filter('date')(date, 'yyyyMMdd')];
if (!trade) { if (!trade) {
trade = { trade = {
create_date: $filter('date')(date, 'yyyy/MM/dd'), create_date: $filter('date')(date, 'yyyy/MM/dd'),
@ -272,7 +272,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
cli.trade_analysis[$filter('date')(date, 'yyyyMMdd')] = trade; cli.trade_analysis[$filter('date')(date, 'yyyyMMdd')] = trade;
} }
trade.events = trade.events || []; trade.events = trade.events || [];
var evtItem = $filter('clientRateEventFilter')(evt); let evtItem = $filter('clientRateEventFilter')(evt);
if (evtItem) { if (evtItem) {
trade.events.push(evtItem); trade.events.push(evtItem);
} }
@ -293,13 +293,13 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
}); });
$element.on('mousemove', function (evt) { $element.on('mousemove', function (evt) {
var x = evt.pageX; let x = evt.pageX;
var y = evt.pageY; let y = evt.pageY;
x -= $element.offset().left; x -= $element.offset().left;
y -= $element.offset().top; y -= $element.offset().top;
var infobox = $('.trade-info-box'); let infobox = $('.trade-info-box');
var position = {left: x + 10, top: y + 10}; let position = {left: x + 10, top: y + 10};
var size = {width: infobox.width(), height: infobox.height()}; let size = {width: infobox.width(), height: infobox.height()};
if (position.left + size.width > $element.width() - 10) { if (position.left + size.width > $element.width() - 10) {
position.left -= (size.width + 25) position.left -= (size.width + 25)
} }
@ -314,7 +314,7 @@ define(['angular', 'echarts', 'jquery', 'uiRouter','./monitoring/analysis-monito
} }
}]); }]);
app.filter('clientRateEventFilter', ['$uibModal', function ($uibModal) { app.filter('clientRateEventFilter', ['$uibModal', function ($uibModal) {
var hash = { let hash = {
'create': {display: 'text-green', label: '新增商户', symbol: 'text-success fa fa-plus'}, 'create': {display: 'text-green', label: '新增商户', symbol: 'text-success fa fa-plus'},
'review': { 'review': {
display: '', display: '',

@ -3,8 +3,9 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="holidayDescription" class="control-label">Holiday Description</label>
<input title="Description" class="form-control" placeholder="Description" <input title="Description" class="form-control" placeholder="Description"
ng-model="holiday.description"> ng-model="holiday.description" id="holidayDescription">
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,8 @@
<dl ng-if="holiday">
<dt ng-bind="holiday.description"></dt>
<dd>
<span class="label label-success"
ng-repeat="region in holiday.regions"
ng-bind="region"></span>
</dd>
</dl>

@ -12,13 +12,7 @@
<div class="col-xs-12"> <div class="col-xs-12">
<div royal-calendar month-change="loadMonthPlan($month)"> <div royal-calendar month-change="loadMonthPlan($month)">
<div class="rc-full" style="color: green" ng-click="configHoliday(day)"> <div class="rc-full" style="color: green" ng-click="configHoliday(day)">
<dl ng-init="holiday=getHoliday(day)" ng-show="holiday!=null"> <holiday-box date="day|date:'yyyy/MM/dd'" holiday-list="activeDates"></holiday-box>
<dt ng-bind="holiday.description"></dt>
<dd>
<span class="label label-success" ng-repeat="region in holiday.regions"
ng-bind="region"></span>
</dd>
</dl>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save