123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- /**
- * Created by pushkeji on 2018/8/24.
- */
- angular.module('push')
- .controller('tongluYearReportCtrl', ['$scope', 'statisticsReportService', '$stateParams', '$ionicScrollDelegate', 'CommonService', function ($scope, statisticsReportService, $stateParams, $ionicScrollDelegate, CommonService) {
- $scope.title = $stateParams.title;
- $scope.datalist = $stateParams.datalist;
- $scope.orgid = $stateParams.orgid;
- //获取年报表数据中的年份数据(用true表示)
- $scope.year = [];
- $scope.select = {
- timeOfYear: '',
- }
- $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
- }
- ]
- statisticsReportService.getTongLuReportYear($scope.orgid, true).then(function (res) {
- console.log(res)
- $scope.yearlist = res.data;
- for (var i = 0; i < $scope.yearlist.length; i++) {
- $scope.year.push({value: $scope.yearlist[i], label: $scope.yearlist[i]})
- $scope.select.timeOfYear = $scope.yearlist[0];
- getData();
- }
- })
- $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);
- }
- var itemIndex = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一'];
- var getData = function () {
- $scope.newdatalist = [];
- angular.forEach($scope.datalist, function (data) {
- if (data.datatimeyear == $scope.select.timeOfYear) {
- $scope.newdatalist.push(data);
- }
- })
- if ($scope.newdatalist.length > 0) {
- $scope.datausername = $scope.newdatalist[0].datausername;
- $scope.datauserphone = $scope.newdatalist[0].datauserphone;
- $scope.datacreatetime = $scope.newdatalist[0].datacreatetime;
- } else {
- $scope.datausername = '';
- $scope.datauserphone = '';
- $scope.datacreatetime = '';
- }
- statisticsReportService.getTongLuMonthReport($scope.orgid, $scope.select.timeOfYear, -1).then(function (res) {
- if (res.code == 3350) {
- console.log(res);
- if (res.data.length == 0) {
- if ($scope.app) {
- UtilService.showMess('暂无报表信息');
- } else {
- CommonService.showMessage('暂无报表信息', $scope)
- }
- }
- 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,
- value: vv.datavalue,
- lastYear: vv.refervalue,
- rate: vv.rate
- })
- })
- })
- console.log($scope.targetList);
- }
- $scope.hideLoadingToast();
- })
- }
- // 获取数据
- $scope.getSelectionData = function () {
- if (!$scope.select.timeOfYear) {
- if ($scope.app) {
- UtilService.showMess('请选择年份');
- } else {
- CommonService.showMessage('请选择年份', $scope)
- }
- return;
- }
- getData();
- }
- }]);
|