tongluMonthReportCtrl.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**
  2. * Created by pushkeji on 2018/8/24.
  3. */
  4. angular.module('push')
  5. .controller('tongluMonthReportCtrl', ['$scope', 'statisticsReportService', '$stateParams', '$ionicScrollDelegate', 'CommonService', function ($scope, statisticsReportService, $stateParams, $ionicScrollDelegate, CommonService) {
  6. //虚拟搜索框
  7. $scope.resource = $stateParams.resource;
  8. // if($stateParams.pageTitle){
  9. // sessionStorage.pageTitle=$stateParams.pageTitle;
  10. // $scope.pageTitle=$stateParams.pageTitle;
  11. // }else{
  12. // $scope.pageTitle=sessionStorage.pageTitle;
  13. // }\
  14. console.log($stateParams);
  15. //TODO 放开注释
  16. if ($scope.app) {
  17. if (device.platform != "Android") {
  18. $scope.isIos = true;
  19. } else {
  20. $scope.isIos = false;
  21. }
  22. }
  23. $scope.month = [];
  24. $scope.year = [];
  25. $scope.select = {
  26. timeOfYear: '',
  27. timeOfMonth: ''
  28. }
  29. var getTongLuReportMonths = function () {
  30. //获取月报表数据中的年份数据(false)
  31. statisticsReportService.getTongLuReportYear($scope.resource.baseInfoModel.oid, false).then(function (yearRes) {
  32. if (yearRes.code == 3350) {
  33. $scope.yearList = yearRes.data;
  34. for (var i = 0; i < $scope.yearList.length; i++) {
  35. $scope.year.push({value: $scope.yearList[i], label: $scope.yearList[i]})
  36. }
  37. statisticsReportService.getTongLuReportMonths($scope.resource.baseInfoModel.oid, $scope.yearList[0]).then(function (res) {
  38. if (res.code == 3350) {
  39. $scope.monthList = res.data;
  40. for (var i = 0; i < $scope.monthList.length; i++) {
  41. $scope.month.push({value: $scope.monthList[i], label: $scope.monthList[i]})
  42. }
  43. $scope.select = {
  44. timeOfYear: $scope.yearList[0],
  45. timeOfMonth: $scope.monthList[0]
  46. }
  47. if ($scope.yearList.length == 0) {
  48. if ($scope.app) {
  49. UtilService.showMess('暂无报表信息');
  50. } else {
  51. CommonService.showMessage('暂无报表信息', $scope)
  52. }
  53. } else {
  54. getData($stateParams.orgid, 0);
  55. }
  56. }
  57. })
  58. }
  59. })
  60. }
  61. getTongLuReportMonths();
  62. var itemIndex = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一'];
  63. var translateData;
  64. // 获取表单信息
  65. var getData = function () {
  66. $scope.showLoadingToast();
  67. statisticsReportService.getTongLuMonthReport($scope.resource.baseInfoModel.oid, $scope.select.timeOfYear, $scope.select.timeOfMonth).then(function (res) {
  68. if (res.code == 3350) {
  69. console.log(res);
  70. if (res.data.length == 0) {
  71. if ($scope.app) {
  72. UtilService.showMess('暂无报表信息');
  73. } else {
  74. CommonService.showMessage('暂无报表信息', $scope)
  75. }
  76. }
  77. for (var i = 0; i < res.data.length; i++) {
  78. if (res.data[i].datavalue != null || res.data[i].refervalue != null) {
  79. $scope.datausername = res.data[i].datausername;
  80. $scope.datauserphone = res.data[i].datauserphone;
  81. $scope.datacreatetime = res.data[i].datacreatetime;
  82. $scope.select.timeOfYear = res.data[i].datatimeyear;
  83. $scope.select.timeOfMonth = res.data[i].datatimemonth;
  84. break;
  85. } else {
  86. $scope.datausername = '';
  87. $scope.datauserphone = '';
  88. $scope.datacreatetime = '';
  89. }
  90. }
  91. translateData = res.data;
  92. var data = res.data;
  93. $scope.targetList = [];
  94. angular.forEach(data, function (val) {
  95. var idx = val.datakind;
  96. // $scope.targetList[idx-1]={};
  97. // $scope.targetList[idx-1].title='指标'+itemIndex[idx-1]+':'+val.datatypename;
  98. // $scope.targetList[idx-1].top=idx==1?true:false;
  99. // $scope.targetList[idx-1].timeOfyear=val.datatimeyear;
  100. // $scope.targetList[idx-1].timeOfMonth=val.datatimemonth;
  101. // $scope.targetList[idx-1].datakind=idx;
  102. $scope.targetList[idx - 1] = {
  103. title: '指标' + itemIndex[idx - 1] + ':' + val.datatypename,
  104. top: idx == 1 ? true : false,
  105. timeOfyear: val.datatimeyear,
  106. timeOfMonth: val.datatimemonth,
  107. datakind: idx,
  108. }
  109. })
  110. angular.forEach($scope.targetList, function (value, index) {
  111. var temp = data.filter(function (v, i, arr) {
  112. return v.datakind == index + 1;
  113. })
  114. temp.sort(function (a, b) {
  115. return a.dataparmcode - b.dataparmcode;
  116. })
  117. value.items = [];
  118. angular.forEach(temp, function (vv) {
  119. value.items.push({
  120. title: vv.dataname + '(' + vv.untit + ')',
  121. value: vv.datavalue,
  122. lastYear: vv.refervalue,
  123. rate: vv.rate
  124. })
  125. })
  126. })
  127. console.log($scope.targetList);
  128. }
  129. $scope.hideLoadingToast();
  130. })
  131. }
  132. // 获取数据
  133. $scope.getSectionData = function () {
  134. if (!$scope.select.timeOfYear) {
  135. if ($scope.app) {
  136. UtilService.showMess('请选择年份');
  137. } else {
  138. CommonService.showMessage('请选择年份', $scope)
  139. }
  140. return;
  141. }
  142. if (!$scope.select.timeOfMonth) {
  143. if ($scope.app) {
  144. UtilService.showMess('请选择月份');
  145. } else {
  146. CommonService.showMessage('请选择月份', $scope)
  147. }
  148. return;
  149. }
  150. getData();
  151. }
  152. var year = document.getElementById("year");
  153. year.onchange = function() {
  154. statisticsReportService.getTongLuReportMonths($scope.resource.baseInfoModel.oid, year.value).then(function (res) {
  155. if (res.code == 3350) {
  156. $scope.monthList = res.data;
  157. $scope.month = [];
  158. for (var i = 0; i < $scope.monthList.length; i++) {
  159. $scope.month.push({value: $scope.monthList[i], label: $scope.monthList[i]})
  160. }
  161. $scope.select = {
  162. timeOfYear: year.value,
  163. timeOfMonth: $scope.monthList[0]
  164. }
  165. }
  166. })
  167. }
  168. }]);