taskDetailedCtrl.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('taskDetailedListCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "api_bpm_data","api_doc_data","api_user_data","api_wechatfile","FileUploader","api_bpm_domain","$http","$stateParams","moment","api_task_export", function($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, api_bpm_data,api_doc_data,api_user_data,api_wechatfile,FileUploader,api_bpm_domain,$http,$stateParams,moment,api_task_export) {
  6. // $scope.ceshi="哈哈"
  7. $scope.monthList=[];//所有月份的集合
  8. $scope.yearList=[];//所有年份集合
  9. $scope.yearData={};//
  10. $scope.exeData=[];
  11. // $scope.monthIdx="";//月份选择
  12. $scope.nowYear=moment(new Date().getTime()).format('YYYY');
  13. $scope.nowMonth=moment(new Date().getTime()).format('MM');
  14. $scope.yearData.data={year:$scope.nowYear};//当前年份
  15. $scope.monthData=$scope.nowMonth;//当前月份
  16. $scope.monthIdx=$scope.nowMonth-1;
  17. // 所有月份
  18. for(var i=1;i<13;i++){
  19. $scope.monthList.push({"month":i})
  20. }
  21. //所有年份
  22. for(var i=1990;i<Number($scope.nowYear)+1;i++){
  23. $scope.yearList.push({"year":i})
  24. }
  25. // 换年份
  26. $scope.changeYear=function(){
  27. // console.log("ok")
  28. $scope.exeData=[];
  29. api_task_export.yearListSee($scope.yearData.data.year,$scope.monthData).then(function(res){
  30. if(res.status==200){
  31. $scope.exeData=res.data;
  32. for(var i=0;i<$scope.exeData.length;i++){
  33. $scope.exeData[i]["item"]=i+1
  34. }
  35. }
  36. })
  37. }
  38. // 点击获取表单
  39. $scope.selectMonth=function(value,idx){
  40. $scope.monthData=value;
  41. $scope.monthIdx=idx;
  42. $scope.exeData=[];
  43. api_task_export.yearListSee($scope.yearData.data.year,$scope.monthData).then(function(res){
  44. if(res.status==200){
  45. $scope.exeData=res.data;
  46. for(var i=0;i<$scope.exeData.length;i++){
  47. $scope.exeData[i]["item"]=i+1
  48. }
  49. }
  50. })
  51. }
  52. // 导出
  53. $scope.export=function(){
  54. $http({
  55. url: api_task_export.yearListExport($scope.yearData.data.year, $scope.monthData).getRequestedUrl(),
  56. method: 'GET',
  57. // data: JSON.stringify(filadata),
  58. headers: {
  59. // 'Content-type': 'application/xls',
  60. 'Accept': '*/*'
  61. },
  62. responseType: 'arraybuffer'
  63. }).success(function (data, status, headers, config) {
  64. // $scope.ldloading.zoom_in = false;
  65. var file = new Blob([data], {
  66. type: 'application/vnd.ms-excel'
  67. });
  68. //trick to download store a file having its URL
  69. var fileURL = URL.createObjectURL(file);
  70. var a = document.createElement('a');
  71. a.href = fileURL;
  72. a.target = '_blank';
  73. a.download = '任务清单.xls';
  74. document.body.appendChild(a);
  75. a.click();
  76. }).error(function (data, status, headers, config) {
  77. // $scope.ldloading.zoom_in = false;
  78. });
  79. }
  80. // 进来获取当前报表
  81. $scope.refash=function(){
  82. $scope.exeData=[];
  83. api_task_export.yearListSee($scope.yearData.data.year,$scope.monthData).then(function(res){
  84. if(res.status==200){
  85. $scope.exeData=res.data;
  86. for(var i=0;i<$scope.exeData.length;i++){
  87. $scope.exeData[i]["item"]=i+1
  88. }
  89. }
  90. })
  91. }
  92. $scope.refash()
  93. }]);