123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- starter.controller('SigninReportCtrl', function ($scope, $state, $rootScope, showPopup, global, Tool, SigninReport) {
- $scope.loading = true;
- global.fetch_user().then(function () {
- $scope.get_data(4);
- });
- var beforeEnter = $scope.$on('$ionicView.beforeEnter', function () {
- showPopup.modalTemplate('templates/modal-filter.html', 'slide-in-right', $scope).then(function (modal) {
- $rootScope.commons.modal = modal;
- });
- });
- $scope.seedetail = function (item) {
- SigninReport.filter.trs_dd = item.trs_dd;
- SigninReport.filter.choice_date = $scope.acitve_date.key;
- $state.go('tab.signinreportdetail');
- };
- $scope.date_list = [
- {"value": "上季", "key": 7},
- {"value": "本季", "key": 6},
- {"value": "上月", "key": 5},
- {"value": "本月", "key": 4},
- {"value": "上周", "key": 3},
- {"value": "本周", "key": 2},
- {"value": "当日", "key": 1}
- ].reverse();
- $scope.acitve_date = $scope.date_list[3];
- $scope.change = function (item) {
- if ($scope.acitve_date.value == item.value) {
- $rootScope.commons.modal.hide();
- return;
- }
- $scope.acitve_date = item;
- $scope.loading = true;
- $scope.get_data(item.key);
- $rootScope.commons.modal.hide();
- console.log(JSON.stringify(item));
- };
- $scope.get_data = function (key) {
- SigninReport.report.query({"choice_date": $scope.acitve_date.key, "cz_list": ""}, function (data) {
- SigninReport.reportdata = angular.copy(data);
- get_results(data);
- }, function (err) {
- alert(JSON.stringify(err))
- }).$promise.finally(function (f) {
- $scope.loading = false;
- $scope.$broadcast('scroll.refreshComplete');
- })
- };
- function get_results(data) {
- var date_list = _.uniq(_.map(data, function (item) {
- item.daystr = Tool.getTranslateByKey("weekdays", new Date(item.trs_dd).getDay());
- item.date = item.trs_dd.substr(0, 7);
- return item.trs_dd.substr(0, 7);
- }));
- $scope.report = _.map(date_list, function (date) {
- return {"date": new Date(date), "items": _.filter(data, {"date": date})}
- });
- console.log($scope.report)
- }
- })
- .controller('SigninReportDetailCtrl', function ($scope, $state, $rootScope, $ionicHistory, showPopup, global, Tool, SigninReport) {
- global.fetch_user().then(function (data) {
- $scope.report = _.find(SigninReport.reportdata, {"trs_dd": SigninReport.filter.trs_dd});
- });
- $scope.goBack = function () {
- $ionicHistory.goBack()
- };
- })
- .controller('SigninReportDetailMoreCtrl', function ($scope, $state, $rootScope, $ionicHistory, showPopup, global, SigninReport, Tool) {
- global.fetch_user().then(function (data) {
- $scope.report = _.find(SigninReport.reportdata, {"trs_dd": SigninReport.filter.trs_dd});
- SigninReport.item.get(function (res) {
- $scope.items = res;
- })
- });
- $scope.openModal = function () {
- $rootScope.commons.modal.show();
- };
- showPopup.modalTemplate('templates/modal-items.html', 'slide-in-right', $scope).then(function (modal) {
- $rootScope.commons.modal = modal;
- });
- $scope.ok = function () {
- $rootScope.commons.modal.hide();
- $scope.loading = true;
- SigninReport.report.query({"choice_date": SigninReport.filter.choice_date, "cz_list": _.pluck(_.filter($scope.items.Data, {"selected": true}), "no").join(',')}, function (data) {
- SigninReport.reportdata = angular.copy(data);
- get_results(data);
- }, function (err) {
- alert(JSON.stringify(err))
- }).$promise.finally(function (f) {
- $scope.loading = false;
- })
- };
- $scope.loadMore = function () {
- Tool.get_nextpage($scope.items.next).then(function (res) {
- var old_data = angular.copy($scope.items.Data);
- $scope.items = res.Data;
- $scope.items.Data = old_data.concat(res.data.Data);
- }).finally(function (f) {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- })
- };
- $scope.goBack = function () {
- $ionicHistory.goBack()
- };
- function set_item() {
- }
- })
|