service_formCtrl.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. 'use strict';
  2. app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", 'api_user_data', function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_user_data) {
  3. //默认显示综合统计
  4. $scope.tap = 'ZHTJ';
  5. //默认显示上一周
  6. $scope.searchstate = 'none';
  7. //日期选择
  8. $scope.nowtimes = moment().format('YYYY-MM-DD')//当前日期;
  9. //上周
  10. $scope.week = function () {
  11. $scope.searchstate = "week";
  12. var weeks = new Date().getDay();
  13. $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  14. $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  15. }
  16. //上月
  17. $scope.month = function () {
  18. $scope.searchstate = "month";
  19. $scope.starttimes = moment().startOf('month').add(-1, 'M').format('YYYY-MM-DD');
  20. $scope.endtimes = moment().endOf('month').add(-1, 'M').format('YYYY-MM-DD');
  21. }
  22. //去年
  23. $scope.year = function () {
  24. $scope.searchstate = "year";
  25. $scope.starttimes = moment().startOf('year').add(-1, 'y').format('YYYY-MM-DD');
  26. $scope.endtimes = moment().endOf('year').add(-1, 'y').format('YYYY-MM-DD');
  27. }
  28. //近N日
  29. $scope.day = function (num) {
  30. num = num > 1 ? num : 1;
  31. $scope.searchstate = "none";
  32. $scope.starttimes = moment().subtract(num, "days").format("YYYY-MM-DD");
  33. $scope.endtimes = moment().subtract(1, "days").format("YYYY-MM-DD");
  34. }
  35. //默认显示最近7天
  36. $scope.day(7);
  37. //选择上一周,上个月,去年
  38. $scope.chooseDate = function (date) {
  39. switch (date) {
  40. case 'week':
  41. $scope.week();
  42. break;
  43. case 'month':
  44. $scope.month();
  45. break;
  46. case 'year':
  47. $scope.year();
  48. break;
  49. }
  50. };
  51. /**
  52. *日历
  53. */
  54. //打开开始日期选择框
  55. $scope.startOpen = function ($event) {
  56. $event.preventDefault();
  57. $event.stopPropagation();
  58. $scope.endOpened = false;
  59. $scope.startOpened = !$scope.startOpened;
  60. };
  61. //打开结束日期选择框
  62. $scope.endOpen = function ($event) {
  63. $event.preventDefault();
  64. $event.stopPropagation();
  65. $scope.startOpened = false;
  66. $scope.endOpened = !$scope.endOpened;
  67. };
  68. //重置
  69. $scope.reload = function(){
  70. $scope.day(7);
  71. $scope.searchstate = 'none';
  72. };
  73. //选择类型,综合统计,电话统计,微信/WEB统计,电话留言统计
  74. $scope.active = function (name) {
  75. $scope.tap = name;
  76. $scope.reload();
  77. if ($scope.tap == 'ZHTJ') {//综合统计
  78. console.log('ZHTJ');
  79. } else if ($scope.tap == 'DHTJ') {//电话统计
  80. console.log('DHTJ');
  81. }else if ($scope.tap == 'WEB') {//微信/WEB统计
  82. console.log('WEB');
  83. }else if ($scope.tap == 'DHLYTJ') {//电话留言统计
  84. console.log('DHLYTJ');
  85. }
  86. };
  87. //综合统计,无限滚动加载
  88. $scope.topEndComplete = function(){
  89. console.log('滚动');
  90. };
  91. // 请求人
  92. // api_user_data.fetchDataList('requester', {
  93. // "idx": 0,
  94. // "sum": 10
  95. // }).then(function (response) {
  96. // if (response) {
  97. // if (response.status = 200) {
  98. // $scope.requester = response.list;
  99. // }
  100. // }
  101. // })
  102. }])