123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- angular.module('push')
- .controller('quarterlyAnalysisCtrl', function ($scope, $stateParams, ConfigService, $ionicActionSheet, CommentService, statisticsReportService, $ionicPopup, taskModuleService, UtilService, $timeout, CommonService) {
- $scope.indexlist = [];
- $scope.timelist = [];
- $scope.year = [];
- $scope.yearValue = $scope.year[0];
- $scope.choiceyearmonthList = [];
- taskModuleService.getAnalysisIndex().then(function (res) {
- if (res.code == 3350) {
- angular.forEach(res.data, function (value) {
- var temphtml = {
- name: value.dataname,
- id: value.id,
- isselected: false
- };
- $scope.indexlist.push(temphtml);
- })
- }
- })
- var getAnalysisTime = function () {
- $scope.nametemplist = [];
- angular.forEach($scope.namelist, function (val) {
- if (val.isselected) {
- $scope.nametemplist.push(val.name);
- }
- })
- if ($scope.nametemplist.length == 0) {
- $ionicPopup.alert({
- title: '提示',
- template: '请先选择企业'
- });
- $scope.value--;
- return;
- }
- taskModuleService.getAnalysisYear($scope.nametemplist).then(function (res) {
- if (res.code == 3350) {
- $scope.year = res.data;
- if (!$scope.yearValue) {
- $scope.yearValue = $scope.year[0];
- }
- taskModuleService.getAnalysisTime($scope.yearValue, $scope.nametemplist).then(function (res) {
- if (res.code == 3350) {
- if (res.data.length == 0) {
- $ionicPopup.alert({
- title: '提示',
- template: '暂无数据!'
- });
- return;
- } else {
- var flag0 = false;
- angular.forEach($scope.choiceyearmonthList, function (val) {
- if (val.year == $scope.yearValue) {
- flag0 = true;
- }
- })
- if (!flag0) {
- angular.forEach(res.data, function (value) {
- $scope.choiceyearmonthList.push({"year": $scope.yearValue, "month": value, "isselected": false});
- })
- }
- }
- }
- })
- }
- })
- }
- $scope.showyearlist = function () {
- var yearlist = [];
- var year = $scope.year;
- angular.forEach(year, function (val) {
- yearlist.push({
- text: '<a class="action-sheet-push">' + val + '</a>'
- })
- })
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: yearlist,
- buttonClicked: function (index) {
- $scope.yearValue = year[index];
- $scope.flag2 = true;
- getAnalysisTime();
- return true;
- }
- });
- }
- $scope.seeDetail = function (index) {
- //获取月报表数据中的年份数据(false)
- $scope.resourceDetail = {};
- $scope.baseInfoModel = {};
- $scope.baseInfoModel.oid = $scope.idlist[index];
- $scope.resourceDetail.baseInfoModel = $scope.baseInfoModel;
- statisticsReportService.getTongLuReportYear($scope.idlist[index], false).then(function (res) {
- if (res.code == 3350) {
- if (res.data.length != 0) {
- $scope.go('tongluMonthReport', {resource: $scope.resourceDetail});
- } else {
- if ($scope.app) {
- UtilService.showMess('');
- } else {
- CommonService.showMessage('暂无月报数据', $scope)
- }
- }
- }
- })
- }
- $scope.agreeOrg = function (index) {
- $scope.namelist[index].isselected = !$scope.namelist[index].isselected;
- }
- $scope.orgtypelist = [
- {name: "全部企业", isselected: false},
- {name: "规上", isselected: false},
- {name: "规下", isselected: false},
- {name: "电子信息", isselected: false},
- {name: "生物与新医药", isselected: false},
- {name: "航空航天", isselected: false},
- {name: "新材料", isselected: false},
- {name: "高技术服务", isselected: false},
- {name: "新能源与节能", isselected: false},
- {name: "资源与环境", isselected: false},
- {name: "先进制造与自动化", isselected: false}
- ]
- $scope.orgtypelist[0].isselected = true;
- $scope.flag = true;
- $scope.flag1 = true;
- $scope.flag2 = true;
- $scope.agreeClickOrgType = function (index) {
- $scope.orgtypelist[index].isselected = !$scope.orgtypelist[index].isselected;
- if (index == 0) {
- if ($scope.orgtypelist[index].isselected) {
- angular.forEach($scope.orgtypelist, function (val) {
- val.isselected = false;
- })
- $scope.orgtypelist[index].isselected = true;
- $scope.namelist = [];
- angular.forEach($scope.orgnamelist, function (val) {
- var temphtml = {
- name: val.name,
- isselected: false
- };
- $scope.namelist.push(temphtml);
- })
- }
- } else {
- if ($scope.orgtypelist[index].isselected) {
- $scope.orgtypelist[0].isselected = false;
- }
- $scope.orgtypetemplist = [];
- angular.forEach($scope.orgtypelist, function (val) {
- if (val.isselected) {
- $scope.orgtypetemplist.push(val.name);
- }
- })
- var orgtypevalue = 0;
- angular.forEach($scope.orgtypetemplist, function (val) {
- if (val == "规上" || val == "规下") {
- orgtypevalue++;
- }
- })
- if (orgtypevalue == 2) {
- $scope.namelist = [];
- angular.forEach($scope.orgnametemplist, function (val) {
- var temphtml = {
- name: val,
- isselected: false
- };
- $scope.namelist.push(temphtml);
- })
- } else {
- taskModuleService.getOrgListByOrgType($scope.orgnametemplist, $scope.orgtypetemplist).then(function (res) {
- if (res.code == 3350) {
- $scope.namelist = [];
- angular.forEach(res.data, function (val) {
- var temphtml = {
- name: val,
- isselected: false
- };
- $scope.namelist.push(temphtml);
- })
- }
- })
- }
- }
- }
- $scope.agreeClickIndex = function (index) {
- $scope.indexlist[index].isselected = !$scope.indexlist[index].isselected;
- }
- $scope.agreeClickTime = function (time) {
- time.isselected = !time.isselected;
- }
- $scope.goQuarterlyImport = function () {
- $scope.go("quarterlyImport");
- }
- $scope.choiceAll = function () {
- if ($scope.flag) {
- angular.forEach($scope.namelist, function (val) {
- val.isselected = true;
- })
- } else {
- angular.forEach($scope.namelist, function (val) {
- val.isselected = false;
- })
- }
- $scope.flag = !$scope.flag;
- }
- $scope.choiceAll1 = function () {
- if ($scope.flag1) {
- angular.forEach($scope.indexlist, function (val) {
- val.isselected = true;
- })
- } else {
- angular.forEach($scope.indexlist, function (val) {
- val.isselected = false;
- })
- }
- $scope.flag1 = !$scope.flag1;
- }
- $scope.choiceAll2 = function () {
- console.log(33333)
- if ($scope.flag2) {
- angular.forEach($scope.choiceyearmonthList, function (val) {
- val.isselected = true;
- })
- } else {
- angular.forEach($scope.choiceyearmonthList, function (val) {
- val.isselected = false;
- })
- }
- $scope.flag2 = !$scope.flag2;
- }
- //进入页面,获取当前节点的所有企业数据
- var getOrgStatsDataList = function () {
- taskModuleService.getOrgStatsDataList().then(function (res) {
- if (res.code == 3350) {
- $scope.orgnamelist = res.data;
- $scope.orgnametemplist = [];
- $scope.namelist = [];
- angular.forEach($scope.orgnamelist, function (val) {
- var temphtml = {
- name: val.name,
- isselected: false
- };
- $scope.namelist.push(temphtml);
- })
- angular.forEach($scope.orgnamelist, function (val) {
- $scope.orgnametemplist.push(val.name);
- })
- }
- })
- }
- getOrgStatsDataList();
- $scope.value = 1;
- $scope.goBackPage = function () {
- $scope.value--;
- }
- $scope.goNextPage = function () {
- $scope.value++;
- getAnalysisTime();
- }
- $scope.doAnalysis = function () {
- $scope.namebackuplist = [];
- $scope.indexbackuplist = [];
- $scope.timebackuplist = [];
- angular.forEach($scope.namelist, function (val) {
- if (val.isselected) {
- $scope.namebackuplist.push(val.name);
- }
- })
- angular.forEach($scope.indexlist, function (val) {
- if (val.isselected) {
- $scope.indexbackuplist.push(val.id);
- }
- })
- angular.forEach($scope.timelist, function (val) {
- if (val.isselected) {
- $scope.timebackuplist.push(val.name);
- }
- })
- if ($scope.indexbackuplist.length == 0) {
- $ionicPopup.alert({
- title: '提示',
- template: '请选择指标!'
- });
- return;
- }
- angular.forEach($scope.choiceyearmonthList, function (val) {
- if(val.isselected){
- $scope.timebackuplist.push(val);
- }
- })
- if ($scope.timebackuplist.length == 0) {
- $ionicPopup.alert({
- title: '提示',
- template: '请选择时间!'
- });
- return;
- }
- $scope.showLoadingToastUtilEnd();
- taskModuleService.downloadExcel($scope.namebackuplist, $scope.indexbackuplist, $scope.timebackuplist).then(function (res) {
- $scope.hideLoadingToast();
- if (res.code == 3350) {
- var file = res.data;
- $scope.url = ConfigService.imgurl + file.sourceName;
- if ($scope.app || $scope.isapp){
- $ionicPopup.alert({
- title: '分析结果',
- template: '<a href="{{url}}">点击查看分析结果!</a>'
- });
- return;
- }else {
- window.open($scope.url);
- }
- $scope.go('quarterlyAnalysis');
- } else {
- $ionicPopup.alert({
- title: '提示',
- template: '导出失败!'
- })
- return;
- }
- }).catch(function (res){
- $scope.hideLoadingToast();
- $ionicPopup.alert({
- title: '提示',
- template: "服务器错误"
- });
- })
- }
- }
- )
- ;
|