year select

master
yixian 7 years ago
parent 116d1d74c4
commit 633c3420c7

@ -15,6 +15,7 @@ define(['angular', 'decimal', 'uiRouter', './report/analysis-report'], function
$scope.params = {year: new Date().getFullYear()}; $scope.params = {year: new Date().getFullYear()};
$scope.availableYears = [new Date().getFullYear() - 1, new Date().getFullYear()]; $scope.availableYears = [new Date().getFullYear() - 1, new Date().getFullYear()];
$scope.initMonth = function (year) { $scope.initMonth = function (year) {
$scope.params.year = year;
$scope.months = []; $scope.months = [];
for (var i = 1; i < 13; i++) { for (var i = 1; i < 13; i++) {
var mon = '00' + i; var mon = '00' + i;
@ -22,9 +23,9 @@ define(['angular', 'decimal', 'uiRouter', './report/analysis-report'], function
$scope.months.push(year + '-' + mon); $scope.months.push(year + '-' + mon);
} }
}; };
$scope.initMonth($scope.params.year); $scope.initMonth(new Date().getFullYear());
$scope.hasReport = function (mon) { $scope.hasReport = function (mon) {
var start = '2017-02'; var start = '2017-02';//todo modify in different country
var end = $filter('date')(new Date(), 'yyyy-MM'); var end = $filter('date')(new Date(), 'yyyy-MM');
return start <= mon && end >= mon return start <= mon && end >= mon
}; };

@ -5,7 +5,7 @@
<div uib-dropdown> <div uib-dropdown>
<button class="btn btn-primary" uib-dropdown-toggle type="button" ng-bind="params.year"></button> <button class="btn btn-primary" uib-dropdown-toggle type="button" ng-bind="params.year"></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu"> <ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li ng-repeat="year in availableYears" role="menuitem"><a role="button" ng-click="params.year=year" ng-bind="year"></a></li> <li ng-repeat="year in availableYears" role="menuitem"><a role="button" ng-click="initMonth(year)" ng-bind="year"></a></li>
</ul> </ul>
</div> </div>
</div> </div>

@ -41,7 +41,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', function ($scope, $http, $uibModal, commonDialog) { app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', function ($scope, $http, $uibModal, commonDialog) {
$scope.params = {year: new Date().getFullYear()}; $scope.params = {year: new Date().getFullYear()};
$scope.availableYears = [new Date().getFullYear() - 1, new Date().getFullYear()];
$scope.initMonth = function (year) { $scope.initMonth = function (year) {
$scope.params.year = year;
$scope.months = []; $scope.months = [];
for (var i = 1; i < 13; i++) { for (var i = 1; i < 13; i++) {
var mon = '00' + i; var mon = '00' + i;
@ -68,7 +70,7 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
$scope.reportMonths = resp.data.data; $scope.reportMonths = resp.data.data;
}) })
}; };
$scope.getYearReports($scope.params.year); $scope.getYearReports(new Date().getFullYear());
$scope.generateReport = function () { $scope.generateReport = function () {
commonDialog.confirm({ commonDialog.confirm({
title: 'Warning', title: 'Warning',
@ -193,6 +195,7 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
// $scope.bdmon; // $scope.bdmon;
// $scope.newSwitch; // $scope.newSwitch;
$scope.initMonth = function (year) { $scope.initMonth = function (year) {
$scope.params.year = year;
$scope.months = []; $scope.months = [];
for (var i = 1; i < 13; i++) { for (var i = 1; i < 13; i++) {
var mon = '00' + i; var mon = '00' + i;
@ -200,9 +203,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
$scope.months.push(year + '-' + mon); $scope.months.push(year + '-' + mon);
} }
}; };
$scope.initMonth($scope.params.year); $scope.initMonth(new Date().getFullYear());
$scope.hasReport = function (mon) { $scope.hasReport = function (mon) {
var start = '2017-01'; var start = '2017-01';//todo change for different country
var end = $filter('date')(new Date(), 'yyyy-MM'); var end = $filter('date')(new Date(), 'yyyy-MM');
return start <= mon && end >= mon return start <= mon && end >= mon
}; };

@ -16,7 +16,14 @@
</div> </div>
</div> </div>
<div class="box box-default" ng-if="'1000'|withRole"> <div class="box box-default" ng-if="'1000'|withRole">
<div class="box-header" ng-bind="params.year"></div> <div class="box-header">
<div uib-dropdown>
<button class="btn btn-primary" uib-dropdown-toggle type="button" ng-bind="params.year"></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li ng-repeat="year in availableYears" role="menuitem"><a role="button" ng-click="getYearReports(year)" ng-bind="year"></a></li>
</ul>
</div>
</div>
<div class="box-body"> <div class="box-body">
<div class="row"> <div class="row">
<div class="col-xs-2" ng-repeat="mon in months"> <div class="col-xs-2" ng-repeat="mon in months">

Loading…
Cancel
Save