reportDetailCtrl.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. * Created by pushkeji on 2018/8/24.
  3. */
  4. angular.module('push')
  5. .controller('reportDetailCtrl', ['$scope','statisticsReportService','$stateParams','$ionicScrollDelegate','CommonService',function($scope,statisticsReportService,$stateParams,$ionicScrollDelegate,CommonService){
  6. //虚拟搜索框
  7. $scope.pageTitle=$stateParams.pageTitle;
  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. $scope.isedit=$stateParams.isedit;
  16. //TODO 放开注释
  17. if($scope.app){
  18. if (device.platform != "Android") {
  19. $scope.isIos=true;
  20. }else{
  21. $scope.isIos=false;
  22. }
  23. }
  24. $scope.select={
  25. timeOfyear:'',
  26. timeOfMonth:''
  27. }
  28. $scope.toplist=[
  29. {
  30. label:'指标一',
  31. value:0,
  32. selected:true
  33. },{
  34. label:'指标二',
  35. value:1,
  36. selected:false
  37. },{
  38. label:'指标三',
  39. value:2,
  40. selected:false
  41. },{
  42. label:'指标四',
  43. value:3,
  44. selected:false
  45. },{
  46. label:'指标五',
  47. value:4,
  48. selected:false
  49. },{
  50. label:'指标六',
  51. value:5,
  52. selected:false
  53. },{
  54. label:'指标七',
  55. value:6,
  56. selected:false
  57. },{
  58. label:'指标八',
  59. value:7,
  60. selected:false
  61. },{
  62. label:'指标九',
  63. value:8,
  64. selected:false
  65. }
  66. ]
  67. $scope.year=[
  68. { value:'2018',label:'2018'},
  69. { value:'2017',label:'2017'},
  70. { value:'2016',label:'2016'},
  71. { value:'2015',label:'2015'},
  72. { value:'2014',label:'2014'},
  73. { value:'2013',label:'2013'},
  74. { value:'2012',label:'2012'},
  75. { value:'2011',label:'2011'},
  76. { value:'2010',label:'2010'},
  77. { value:'2008',label:'2008'},
  78. { value:'2007',label:'2007'},
  79. { value:'2006',label:'2006'},
  80. { value:'2005',label:'2005'},
  81. ]
  82. $scope.month=[
  83. { value:'1-1月',label:'1-1月'},
  84. { value:'1-2月',label:'1-2月'},
  85. { value:'1-3月',label:'1-3月'},
  86. { value:'1-4月',label:'1-4月'},
  87. { value:'1-5月',label:'1-5月'},
  88. { value:'1-6月',label:'1-6月'},
  89. { value:'1-7月',label:'1-7月'},
  90. { value:'1-8月',label:'1-8月'},
  91. { value:'1-9月',label:'1-9月'},
  92. { value:'1-10月',label:'1-10月'},
  93. { value:'1-11月',label:'1-11月'},
  94. { value:'1-12月',label:'1-12月'},
  95. ]
  96. var itemIndex=['一','二','三','四','五','六','七','八','九','十','十一'];
  97. var year=new Date().getFullYear();
  98. var mon='1-'+(new Date().getMonth()+1)+'月';
  99. var translateData;
  100. // 获取表单信息
  101. // statisticsReportService.getCompayReport(orgid,datatype,datatimeyear,datatimemonth).then(function(res){
  102. var getData=function(orgid,datatype,datatimeyear,datatimemonth){
  103. // console.log($stateParams.orgid);
  104. $scope.showLoadingToast();
  105. statisticsReportService.getCompayReport(orgid,datatype,datatimeyear,datatimemonth).then(function(res){
  106. if(res.code==3350){
  107. console.log(res);
  108. if(!res.data){
  109. if($scope.app){
  110. UtilService.showMess('该公司无报表信息');
  111. }else{
  112. CommonService.showMessage('该公司无报表信息',$scope)
  113. }
  114. }
  115. for(var i=0;i<res.data.length;i++){
  116. if(res.data[i].datavalue!=null||res.data[i].refervalue!=null){
  117. $scope.datausername=res.data[i].datausername;
  118. $scope.datauserphone=res.data[i].datauserphone;
  119. $scope.datacreatetime=res.data[i].datacreatetime;
  120. $scope.select.timeOfyear=res.data[i].datatimeyear;
  121. $scope.select.timeOfMonth=res.data[i].datatimemonth;
  122. // console.log(res.data[i]);
  123. break;
  124. }else{
  125. $scope.datausername='';
  126. $scope.datauserphone='';
  127. $scope.datacreatetime='';
  128. }
  129. }
  130. translateData=res.data;
  131. var data=res.data;
  132. $scope.targetList=[];
  133. angular.forEach(data,function(val){
  134. var idx=val.datakind;
  135. // $scope.targetList[idx-1]={};
  136. // $scope.targetList[idx-1].title='指标'+itemIndex[idx-1]+':'+val.datatypename;
  137. // $scope.targetList[idx-1].top=idx==1?true:false;
  138. // $scope.targetList[idx-1].timeOfyear=val.datatimeyear;
  139. // $scope.targetList[idx-1].timeOfMonth=val.datatimemonth;
  140. // $scope.targetList[idx-1].datakind=idx;
  141. $scope.targetList[idx-1]={
  142. title:'指标'+itemIndex[idx-1]+':'+val.datatypename,
  143. top:idx==1?true:false,
  144. timeOfyear:val.datatimeyear,
  145. timeOfMonth:val.datatimemonth,
  146. datakind:idx,
  147. }
  148. })
  149. angular.forEach($scope.targetList,function(value,index){
  150. var temp=data.filter(function(v,i,arr){
  151. return v.datakind==index+1;
  152. })
  153. temp.sort(function(a,b){
  154. return a.dataparmcode-b.dataparmcode;
  155. })
  156. value.items=[];
  157. angular.forEach(temp,function(vv){
  158. value.items.push({
  159. title:vv.dataname+'('+vv.untit+')',
  160. value:vv.datavalue,
  161. lastYear:vv.refervalue,
  162. rate:vv.rate
  163. })
  164. })
  165. })
  166. console.log($scope.targetList);
  167. }
  168. $scope.hideLoadingToast();
  169. })
  170. }
  171. getData($stateParams.orgid,0);
  172. // 获取数据
  173. $scope.getSectionData=function(index){
  174. console.log($scope.targetList[index]);
  175. if(!$scope.select.timeOfyear){
  176. if($scope.app){
  177. UtilService.showMess('请选择年份');
  178. }else{
  179. CommonService.showMessage('请选择年份',$scope)
  180. }
  181. return;
  182. }
  183. if(!$scope.select.timeOfMonth){
  184. if($scope.app){
  185. UtilService.showMess('请选择月份');
  186. }else{
  187. CommonService.showMessage('请选择月份',$scope)
  188. }
  189. return;
  190. }
  191. getData($stateParams.orgid,0,$scope.select.timeOfyear,$scope.select.timeOfMonth);
  192. // statisticsReportService.getCompayReport($stateParams.orgid,0,$scope.targetList[index].timeOfyear,$scope.targetList[index].timeOfMonth).then(function(res){
  193. // console.log(res);
  194. // $scope.targetList[index].items=[];
  195. // if(res.code==3350&&res.data&&res.data.length>0){
  196. // for(var i=0;i<data.length;i++){
  197. // if(data[i].datavalue!=null||data[i].refervalue!=null){
  198. // $scope.datausername=data[i].datausername;
  199. // $scope.datauserphone=data[i].datauserphone;
  200. // $scope.datacreatetime=data[i].datacreatetime;
  201. // console.log(data[i]);
  202. // break;
  203. // }
  204. // }
  205. // var tempData=data.filter(function(val,i,arr){
  206. // return val.datakind==$scope.targetList[index].datakind;
  207. // })
  208. // tempData.sort(function(a,b){
  209. // return a.dataparmcode-b.dataparmcode;
  210. // })
  211. // angular.forEach(tempData,function(vv){
  212. // $scope.targetList[index].items.push({
  213. // title:vv.dataname+'('+vv.untit+')',
  214. // value:vv.datavalue,
  215. // lastYear:vv.refervalue,
  216. // rate:vv.rate
  217. // })
  218. // })
  219. // console.log($scope.targetList);
  220. // }
  221. // })
  222. }
  223. $scope.changeSelected=function(index){
  224. angular.forEach($scope.toplist,function(val){
  225. val.selected=false;
  226. })
  227. $scope.toplist[index].selected=true;
  228. // 滚到头部
  229. if($scope.app){
  230. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
  231. var tablength = $scope.toplist.length;//标题个数
  232. var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
  233. var OffLeft = $(".main-select").eq(index).offset().left;//获取当前点击标题距离父容器左边框的距离
  234. var SelfWidth = $(".main-select").eq(index).width();//获取当前点击标题宽度
  235. var startTranform = $(".visitModule_header .scroll").offset().left+25;
  236. var movewidth = OffLeft - middlewidth + SelfWidth / 2;
  237. startTranform -= movewidth;
  238. if (startTranform <= 0) {
  239. if (index < tablength - 1) {
  240. $('.visitModule_header .scroll').css({
  241. 'transform': 'translate3d(' + startTranform + 'px,0,0)'
  242. });
  243. }
  244. } else if (index < 4) {
  245. $('.visitModule_header .scroll').css({
  246. 'transform': 'translate3d(0,0,0)'
  247. });
  248. }
  249. }
  250. var scrollheight=document.getElementById('item'+index).offsetTop;
  251. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTo(top,scrollheight);
  252. }
  253. $scope.editReportInfo=function(){
  254. $scope.go('reportEditModal',{pageTitle:'报表录入',isEdit:1,data:JSON.stringify(translateData),comName:$stateParams.pageTitle,pageid:$stateParams.pageid})
  255. }
  256. }]);