123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- /**
- * Created by pushkeji on 2018/8/24.
- */
- angular.module('push')
- .controller('reportDetailCtrl', ['$scope','statisticsReportService','$stateParams','$ionicScrollDelegate','CommonService',function($scope,statisticsReportService,$stateParams,$ionicScrollDelegate,CommonService){
- //虚拟搜索框
- $scope.pageTitle=$stateParams.pageTitle;
- // if($stateParams.pageTitle){
- // sessionStorage.pageTitle=$stateParams.pageTitle;
- // $scope.pageTitle=$stateParams.pageTitle;
- // }else{
- // $scope.pageTitle=sessionStorage.pageTitle;
- // }\
- console.log($stateParams);
- $scope.isedit=$stateParams.isedit;
- //TODO 放开注释
- if($scope.app){
- if (device.platform != "Android") {
- $scope.isIos=true;
- }else{
- $scope.isIos=false;
- }
- }
- $scope.select={
- timeOfyear:'',
- timeOfMonth:''
- }
- $scope.toplist=[
- {
- label:'指标一',
- value:0,
- selected:true
- },{
- label:'指标二',
- value:1,
- selected:false
- },{
- label:'指标三',
- value:2,
- selected:false
- },{
- label:'指标四',
- value:3,
- selected:false
- },{
- label:'指标五',
- value:4,
- selected:false
- },{
- label:'指标六',
- value:5,
- selected:false
- },{
- label:'指标七',
- value:6,
- selected:false
- },{
- label:'指标八',
- value:7,
- selected:false
- },{
- label:'指标九',
- value:8,
- selected:false
- }
- ]
- $scope.year=[
- { value:'2018',label:'2018'},
- { value:'2017',label:'2017'},
- { value:'2016',label:'2016'},
- { value:'2015',label:'2015'},
- { value:'2014',label:'2014'},
- { value:'2013',label:'2013'},
- { value:'2012',label:'2012'},
- { value:'2011',label:'2011'},
- { value:'2010',label:'2010'},
- { value:'2008',label:'2008'},
- { value:'2007',label:'2007'},
- { value:'2006',label:'2006'},
- { value:'2005',label:'2005'},
- ]
- $scope.month=[
- { value:'1-1月',label:'1-1月'},
- { value:'1-2月',label:'1-2月'},
- { value:'1-3月',label:'1-3月'},
- { value:'1-4月',label:'1-4月'},
- { value:'1-5月',label:'1-5月'},
- { value:'1-6月',label:'1-6月'},
- { value:'1-7月',label:'1-7月'},
- { value:'1-8月',label:'1-8月'},
- { value:'1-9月',label:'1-9月'},
- { value:'1-10月',label:'1-10月'},
- { value:'1-11月',label:'1-11月'},
- { value:'1-12月',label:'1-12月'},
- ]
- var itemIndex=['一','二','三','四','五','六','七','八','九','十','十一'];
- var year=new Date().getFullYear();
- var mon='1-'+(new Date().getMonth()+1)+'月';
- var translateData;
- // 获取表单信息
- // statisticsReportService.getCompayReport(orgid,datatype,datatimeyear,datatimemonth).then(function(res){
- var getData=function(orgid,datatype,datatimeyear,datatimemonth){
- // console.log($stateParams.orgid);
- $scope.showLoadingToast();
- statisticsReportService.getCompayReport(orgid,datatype,datatimeyear,datatimemonth).then(function(res){
- if(res.code==3350){
- console.log(res);
- if(!res.data){
- if($scope.app){
- UtilService.showMess('该公司无报表信息');
- }else{
- CommonService.showMessage('该公司无报表信息',$scope)
- }
- }
- for(var i=0;i<res.data.length;i++){
- if(res.data[i].datavalue!=null||res.data[i].refervalue!=null){
- $scope.datausername=res.data[i].datausername;
- $scope.datauserphone=res.data[i].datauserphone;
- $scope.datacreatetime=res.data[i].datacreatetime;
- $scope.select.timeOfyear=res.data[i].datatimeyear;
- $scope.select.timeOfMonth=res.data[i].datatimemonth;
- // console.log(res.data[i]);
- break;
- }else{
- $scope.datausername='';
- $scope.datauserphone='';
- $scope.datacreatetime='';
- }
- }
- translateData=res.data;
- var data=res.data;
- $scope.targetList=[];
- angular.forEach(data,function(val){
- var idx=val.datakind;
- // $scope.targetList[idx-1]={};
- // $scope.targetList[idx-1].title='指标'+itemIndex[idx-1]+':'+val.datatypename;
- // $scope.targetList[idx-1].top=idx==1?true:false;
- // $scope.targetList[idx-1].timeOfyear=val.datatimeyear;
- // $scope.targetList[idx-1].timeOfMonth=val.datatimemonth;
- // $scope.targetList[idx-1].datakind=idx;
- $scope.targetList[idx-1]={
- title:'指标'+itemIndex[idx-1]+':'+val.datatypename,
- top:idx==1?true:false,
- timeOfyear:val.datatimeyear,
- timeOfMonth:val.datatimemonth,
- datakind:idx,
- }
- })
- angular.forEach($scope.targetList,function(value,index){
- var temp=data.filter(function(v,i,arr){
- return v.datakind==index+1;
- })
- temp.sort(function(a,b){
- return a.dataparmcode-b.dataparmcode;
- })
- value.items=[];
- angular.forEach(temp,function(vv){
- value.items.push({
- title:vv.dataname+'('+vv.untit+')',
- value:vv.datavalue,
- lastYear:vv.refervalue,
- rate:vv.rate
- })
- })
- })
- console.log($scope.targetList);
- }
- $scope.hideLoadingToast();
- })
- }
- getData($stateParams.orgid,0);
- // 获取数据
- $scope.getSectionData=function(index){
- console.log($scope.targetList[index]);
- if(!$scope.select.timeOfyear){
- if($scope.app){
- UtilService.showMess('请选择年份');
- }else{
- CommonService.showMessage('请选择年份',$scope)
- }
- return;
- }
- if(!$scope.select.timeOfMonth){
- if($scope.app){
- UtilService.showMess('请选择月份');
- }else{
- CommonService.showMessage('请选择月份',$scope)
- }
- return;
- }
- getData($stateParams.orgid,0,$scope.select.timeOfyear,$scope.select.timeOfMonth);
- // statisticsReportService.getCompayReport($stateParams.orgid,0,$scope.targetList[index].timeOfyear,$scope.targetList[index].timeOfMonth).then(function(res){
- // console.log(res);
- // $scope.targetList[index].items=[];
- // if(res.code==3350&&res.data&&res.data.length>0){
- // for(var i=0;i<data.length;i++){
- // if(data[i].datavalue!=null||data[i].refervalue!=null){
- // $scope.datausername=data[i].datausername;
- // $scope.datauserphone=data[i].datauserphone;
- // $scope.datacreatetime=data[i].datacreatetime;
- // console.log(data[i]);
- // break;
- // }
- // }
- // var tempData=data.filter(function(val,i,arr){
- // return val.datakind==$scope.targetList[index].datakind;
- // })
- // tempData.sort(function(a,b){
- // return a.dataparmcode-b.dataparmcode;
- // })
- // angular.forEach(tempData,function(vv){
- // $scope.targetList[index].items.push({
- // title:vv.dataname+'('+vv.untit+')',
- // value:vv.datavalue,
- // lastYear:vv.refervalue,
- // rate:vv.rate
- // })
- // })
- // console.log($scope.targetList);
- // }
- // })
- }
- $scope.changeSelected=function(index){
- angular.forEach($scope.toplist,function(val){
- val.selected=false;
- })
- $scope.toplist[index].selected=true;
- // 滚到头部
- if($scope.app){
- $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
- var tablength = $scope.toplist.length;//标题个数
- var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
- var OffLeft = $(".main-select").eq(index).offset().left;//获取当前点击标题距离父容器左边框的距离
- var SelfWidth = $(".main-select").eq(index).width();//获取当前点击标题宽度
- var startTranform = $(".visitModule_header .scroll").offset().left+25;
- var movewidth = OffLeft - middlewidth + SelfWidth / 2;
- startTranform -= movewidth;
- if (startTranform <= 0) {
- if (index < tablength - 1) {
- $('.visitModule_header .scroll').css({
- 'transform': 'translate3d(' + startTranform + 'px,0,0)'
- });
- }
- } else if (index < 4) {
- $('.visitModule_header .scroll').css({
- 'transform': 'translate3d(0,0,0)'
- });
- }
- }
- var scrollheight=document.getElementById('item'+index).offsetTop;
- $ionicScrollDelegate.$getByHandle('mainScroll').scrollTo(top,scrollheight);
- }
- $scope.editReportInfo=function(){
- $scope.go('reportEditModal',{pageTitle:'报表录入',isEdit:1,data:JSON.stringify(translateData),comName:$stateParams.pageTitle,pageid:$stateParams.pageid})
- }
- }]);
|