/** * Created by pushkeji on 2018/8/24. */ angular.module('push') .controller('tongluMonthReportCtrl', ['$scope', 'statisticsReportService', '$stateParams', '$ionicScrollDelegate', 'CommonService', function ($scope, statisticsReportService, $stateParams, $ionicScrollDelegate, CommonService) { //虚拟搜索框 $scope.resource = $stateParams.resource; // if($stateParams.pageTitle){ // sessionStorage.pageTitle=$stateParams.pageTitle; // $scope.pageTitle=$stateParams.pageTitle; // }else{ // $scope.pageTitle=sessionStorage.pageTitle; // }\ console.log($stateParams); //TODO 放开注释 if ($scope.app) { if (device.platform != "Android") { $scope.isIos = true; } else { $scope.isIos = false; } } $scope.month = []; $scope.year = []; $scope.select = { timeOfYear: '', timeOfMonth: '' } var getTongLuReportMonths = function () { //获取月报表数据中的年份数据(false) statisticsReportService.getTongLuReportYear($scope.resource.baseInfoModel.oid, false).then(function (yearRes) { if (yearRes.code == 3350) { $scope.yearList = yearRes.data; for (var i = 0; i < $scope.yearList.length; i++) { $scope.year.push({value: $scope.yearList[i], label: $scope.yearList[i]}) } statisticsReportService.getTongLuReportMonths($scope.resource.baseInfoModel.oid, $scope.yearList[0]).then(function (res) { if (res.code == 3350) { $scope.monthList = res.data; for (var i = 0; i < $scope.monthList.length; i++) { $scope.month.push({value: $scope.monthList[i], label: $scope.monthList[i]}) } $scope.select = { timeOfYear: $scope.yearList[0], timeOfMonth: $scope.monthList[0] } if ($scope.yearList.length == 0) { if ($scope.app) { UtilService.showMess('暂无报表信息'); } else { CommonService.showMessage('暂无报表信息', $scope) } } else { getData($stateParams.orgid, 0); } } }) } }) } getTongLuReportMonths(); var itemIndex = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一']; var translateData; // 获取表单信息 var getData = function () { $scope.showLoadingToast(); statisticsReportService.getTongLuMonthReport($scope.resource.baseInfoModel.oid, $scope.select.timeOfYear, $scope.select.timeOfMonth).then(function (res) { if (res.code == 3350) { console.log(res); if (res.data.length == 0) { 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; 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(); }) } // 获取数据 $scope.getSectionData = function () { 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(); } var year = document.getElementById("year"); year.onchange = function() { statisticsReportService.getTongLuReportMonths($scope.resource.baseInfoModel.oid, year.value).then(function (res) { if (res.code == 3350) { $scope.monthList = res.data; $scope.month = []; for (var i = 0; i < $scope.monthList.length; i++) { $scope.month.push({value: $scope.monthList[i], label: $scope.monthList[i]}) } $scope.select = { timeOfYear: year.value, timeOfMonth: $scope.monthList[0] } } }) } }]);