tongluYearReportCtrl.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /**
  2. * Created by pushkeji on 2018/8/24.
  3. */
  4. angular.module('push')
  5. .controller('tongluYearReportCtrl', ['$scope', 'statisticsReportService', '$stateParams', '$ionicScrollDelegate', 'CommonService', function ($scope, statisticsReportService, $stateParams, $ionicScrollDelegate, CommonService) {
  6. $scope.title = $stateParams.title;
  7. $scope.datalist = $stateParams.datalist;
  8. $scope.orgid = $stateParams.orgid;
  9. //获取年报表数据中的年份数据(用true表示)
  10. $scope.year = [];
  11. $scope.select = {
  12. timeOfYear: '',
  13. }
  14. $scope.toplist=[
  15. {
  16. label:'指标一',
  17. value:0,
  18. selected:true
  19. },{
  20. label:'指标二',
  21. value:1,
  22. selected:false
  23. },{
  24. label:'指标三',
  25. value:2,
  26. selected:false
  27. },{
  28. label:'指标四',
  29. value:3,
  30. selected:false
  31. },{
  32. label:'指标五',
  33. value:4,
  34. selected:false
  35. },{
  36. label:'指标六',
  37. value:5,
  38. selected:false
  39. },{
  40. label:'指标七',
  41. value:6,
  42. selected:false
  43. },{
  44. label:'指标八',
  45. value:7,
  46. selected:false
  47. },{
  48. label:'指标九',
  49. value:8,
  50. selected:false
  51. }
  52. ]
  53. statisticsReportService.getTongLuReportYear($scope.orgid, true).then(function (res) {
  54. console.log(res)
  55. $scope.yearlist = res.data;
  56. for (var i = 0; i < $scope.yearlist.length; i++) {
  57. $scope.year.push({value: $scope.yearlist[i], label: $scope.yearlist[i]})
  58. $scope.select.timeOfYear = $scope.yearlist[0];
  59. getData();
  60. }
  61. })
  62. $scope.changeSelected=function(index){
  63. angular.forEach($scope.toplist,function(val){
  64. val.selected=false;
  65. })
  66. $scope.toplist[index].selected=true;
  67. // 滚到头部
  68. if($scope.app){
  69. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
  70. var tablength = $scope.toplist.length;//标题个数
  71. var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
  72. var OffLeft = $(".main-select").eq(index).offset().left;//获取当前点击标题距离父容器左边框的距离
  73. var SelfWidth = $(".main-select").eq(index).width();//获取当前点击标题宽度
  74. var startTranform = $(".visitModule_header .scroll").offset().left+25;
  75. var movewidth = OffLeft - middlewidth + SelfWidth / 2;
  76. startTranform -= movewidth;
  77. if (startTranform <= 0) {
  78. if (index < tablength - 1) {
  79. $('.visitModule_header .scroll').css({
  80. 'transform': 'translate3d(' + startTranform + 'px,0,0)'
  81. });
  82. }
  83. } else if (index < 4) {
  84. $('.visitModule_header .scroll').css({
  85. 'transform': 'translate3d(0,0,0)'
  86. });
  87. }
  88. }
  89. var scrollheight=document.getElementById('item'+index).offsetTop;
  90. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTo(top,scrollheight);
  91. }
  92. var itemIndex = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一'];
  93. var getData = function () {
  94. $scope.newdatalist = [];
  95. angular.forEach($scope.datalist, function (data) {
  96. if (data.datatimeyear == $scope.select.timeOfYear) {
  97. $scope.newdatalist.push(data);
  98. }
  99. })
  100. if ($scope.newdatalist.length > 0) {
  101. $scope.datausername = $scope.newdatalist[0].datausername;
  102. $scope.datauserphone = $scope.newdatalist[0].datauserphone;
  103. $scope.datacreatetime = $scope.newdatalist[0].datacreatetime;
  104. } else {
  105. $scope.datausername = '';
  106. $scope.datauserphone = '';
  107. $scope.datacreatetime = '';
  108. }
  109. statisticsReportService.getTongLuMonthReport($scope.orgid, $scope.select.timeOfYear, -1).then(function (res) {
  110. if (res.code == 3350) {
  111. console.log(res);
  112. if (res.data.length == 0) {
  113. if ($scope.app) {
  114. UtilService.showMess('暂无报表信息');
  115. } else {
  116. CommonService.showMessage('暂无报表信息', $scope)
  117. }
  118. }
  119. translateData = res.data;
  120. var data = res.data;
  121. $scope.targetList = [];
  122. angular.forEach(data, function (val) {
  123. var idx = val.datakind;
  124. // $scope.targetList[idx-1]={};
  125. // $scope.targetList[idx-1].title='指标'+itemIndex[idx-1]+':'+val.datatypename;
  126. // $scope.targetList[idx-1].top=idx==1?true:false;
  127. // $scope.targetList[idx-1].timeOfyear=val.datatimeyear;
  128. // $scope.targetList[idx-1].timeOfMonth=val.datatimemonth;
  129. // $scope.targetList[idx-1].datakind=idx;
  130. $scope.targetList[idx - 1] = {
  131. title: '指标' + itemIndex[idx - 1] + ':' + val.datatypename,
  132. top: idx == 1 ? true : false,
  133. timeOfyear: val.datatimeyear,
  134. timeOfMonth: val.datatimemonth,
  135. datakind: idx,
  136. }
  137. })
  138. angular.forEach($scope.targetList, function (value, index) {
  139. var temp = data.filter(function (v, i, arr) {
  140. return v.datakind == index + 1;
  141. })
  142. temp.sort(function (a, b) {
  143. return a.dataparmcode - b.dataparmcode;
  144. })
  145. value.items = [];
  146. angular.forEach(temp, function (vv) {
  147. value.items.push({
  148. title: vv.dataname,
  149. value: vv.datavalue,
  150. lastYear: vv.refervalue,
  151. rate: vv.rate
  152. })
  153. })
  154. })
  155. console.log($scope.targetList);
  156. }
  157. $scope.hideLoadingToast();
  158. })
  159. }
  160. // 获取数据
  161. $scope.getSelectionData = function () {
  162. if (!$scope.select.timeOfYear) {
  163. if ($scope.app) {
  164. UtilService.showMess('请选择年份');
  165. } else {
  166. CommonService.showMessage('请选择年份', $scope)
  167. }
  168. return;
  169. }
  170. getData();
  171. }
  172. }]);