quarterlyAnalysisCtrl.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. angular.module('push')
  2. .controller('quarterlyAnalysisCtrl', function ($scope, $stateParams, ConfigService, $ionicActionSheet, CommentService, statisticsReportService, $ionicPopup, taskModuleService, UtilService, $timeout, CommonService) {
  3. $scope.indexlist = [];
  4. $scope.timelist = [];
  5. $scope.year = [];
  6. $scope.yearValue = $scope.year[0];
  7. $scope.choiceyearmonthList = [];
  8. taskModuleService.getAnalysisIndex().then(function (res) {
  9. if (res.code == 3350) {
  10. angular.forEach(res.data, function (value) {
  11. var temphtml = {
  12. name: value.dataname,
  13. id: value.id,
  14. isselected: false
  15. };
  16. $scope.indexlist.push(temphtml);
  17. })
  18. }
  19. })
  20. var getAnalysisTime = function () {
  21. $scope.nametemplist = [];
  22. angular.forEach($scope.namelist, function (val) {
  23. if (val.isselected) {
  24. $scope.nametemplist.push(val.name);
  25. }
  26. })
  27. if ($scope.nametemplist.length == 0) {
  28. $ionicPopup.alert({
  29. title: '提示',
  30. template: '请先选择企业'
  31. });
  32. $scope.value--;
  33. return;
  34. }
  35. taskModuleService.getAnalysisYear($scope.nametemplist).then(function (res) {
  36. if (res.code == 3350) {
  37. $scope.year = res.data;
  38. if (!$scope.yearValue) {
  39. $scope.yearValue = $scope.year[0];
  40. }
  41. taskModuleService.getAnalysisTime($scope.yearValue, $scope.nametemplist).then(function (res) {
  42. if (res.code == 3350) {
  43. if (res.data.length == 0) {
  44. $ionicPopup.alert({
  45. title: '提示',
  46. template: '暂无数据!'
  47. });
  48. return;
  49. } else {
  50. var flag0 = false;
  51. angular.forEach($scope.choiceyearmonthList, function (val) {
  52. if (val.year == $scope.yearValue) {
  53. flag0 = true;
  54. }
  55. })
  56. if (!flag0) {
  57. angular.forEach(res.data, function (value) {
  58. $scope.choiceyearmonthList.push({"year": $scope.yearValue, "month": value, "isselected": false});
  59. })
  60. }
  61. }
  62. }
  63. })
  64. }
  65. })
  66. }
  67. $scope.showyearlist = function () {
  68. var yearlist = [];
  69. var year = $scope.year;
  70. angular.forEach(year, function (val) {
  71. yearlist.push({
  72. text: '<a class="action-sheet-push">' + val + '</a>'
  73. })
  74. })
  75. $ionicActionSheet.show({
  76. cancelOnStateChange: true,
  77. cssClass: 'action_s',
  78. cancelText: '取消',
  79. buttons: yearlist,
  80. buttonClicked: function (index) {
  81. $scope.yearValue = year[index];
  82. $scope.flag2 = true;
  83. getAnalysisTime();
  84. return true;
  85. }
  86. });
  87. }
  88. $scope.seeDetail = function (index) {
  89. //获取月报表数据中的年份数据(false)
  90. $scope.resourceDetail = {};
  91. $scope.baseInfoModel = {};
  92. $scope.baseInfoModel.oid = $scope.idlist[index];
  93. $scope.resourceDetail.baseInfoModel = $scope.baseInfoModel;
  94. statisticsReportService.getTongLuReportYear($scope.idlist[index], false).then(function (res) {
  95. if (res.code == 3350) {
  96. if (res.data.length != 0) {
  97. $scope.go('tongluMonthReport', {resource: $scope.resourceDetail});
  98. } else {
  99. if ($scope.app) {
  100. UtilService.showMess('');
  101. } else {
  102. CommonService.showMessage('暂无月报数据', $scope)
  103. }
  104. }
  105. }
  106. })
  107. }
  108. $scope.agreeOrg = function (index) {
  109. $scope.namelist[index].isselected = !$scope.namelist[index].isselected;
  110. }
  111. $scope.orgtypelist = [
  112. {name: "全部企业", isselected: false},
  113. {name: "规上", isselected: false},
  114. {name: "规下", isselected: false},
  115. {name: "电子信息", isselected: false},
  116. {name: "生物与新医药", isselected: false},
  117. {name: "航空航天", isselected: false},
  118. {name: "新材料", isselected: false},
  119. {name: "高技术服务", isselected: false},
  120. {name: "新能源与节能", isselected: false},
  121. {name: "资源与环境", isselected: false},
  122. {name: "先进制造与自动化", isselected: false}
  123. ]
  124. $scope.orgtypelist[0].isselected = true;
  125. $scope.flag = true;
  126. $scope.flag1 = true;
  127. $scope.flag2 = true;
  128. $scope.agreeClickOrgType = function (index) {
  129. $scope.orgtypelist[index].isselected = !$scope.orgtypelist[index].isselected;
  130. if (index == 0) {
  131. if ($scope.orgtypelist[index].isselected) {
  132. angular.forEach($scope.orgtypelist, function (val) {
  133. val.isselected = false;
  134. })
  135. $scope.orgtypelist[index].isselected = true;
  136. $scope.namelist = [];
  137. angular.forEach($scope.orgnamelist, function (val) {
  138. var temphtml = {
  139. name: val.name,
  140. isselected: false
  141. };
  142. $scope.namelist.push(temphtml);
  143. })
  144. }
  145. } else {
  146. if ($scope.orgtypelist[index].isselected) {
  147. $scope.orgtypelist[0].isselected = false;
  148. }
  149. $scope.orgtypetemplist = [];
  150. angular.forEach($scope.orgtypelist, function (val) {
  151. if (val.isselected) {
  152. $scope.orgtypetemplist.push(val.name);
  153. }
  154. })
  155. var orgtypevalue = 0;
  156. angular.forEach($scope.orgtypetemplist, function (val) {
  157. if (val == "规上" || val == "规下") {
  158. orgtypevalue++;
  159. }
  160. })
  161. if (orgtypevalue == 2) {
  162. $scope.namelist = [];
  163. angular.forEach($scope.orgnametemplist, function (val) {
  164. var temphtml = {
  165. name: val,
  166. isselected: false
  167. };
  168. $scope.namelist.push(temphtml);
  169. })
  170. } else {
  171. taskModuleService.getOrgListByOrgType($scope.orgnametemplist, $scope.orgtypetemplist).then(function (res) {
  172. if (res.code == 3350) {
  173. $scope.namelist = [];
  174. angular.forEach(res.data, function (val) {
  175. var temphtml = {
  176. name: val,
  177. isselected: false
  178. };
  179. $scope.namelist.push(temphtml);
  180. })
  181. }
  182. })
  183. }
  184. }
  185. }
  186. $scope.agreeClickIndex = function (index) {
  187. $scope.indexlist[index].isselected = !$scope.indexlist[index].isselected;
  188. }
  189. $scope.agreeClickTime = function (time) {
  190. time.isselected = !time.isselected;
  191. }
  192. $scope.goQuarterlyImport = function () {
  193. $scope.go("quarterlyImport");
  194. }
  195. $scope.choiceAll = function () {
  196. if ($scope.flag) {
  197. angular.forEach($scope.namelist, function (val) {
  198. val.isselected = true;
  199. })
  200. } else {
  201. angular.forEach($scope.namelist, function (val) {
  202. val.isselected = false;
  203. })
  204. }
  205. $scope.flag = !$scope.flag;
  206. }
  207. $scope.choiceAll1 = function () {
  208. if ($scope.flag1) {
  209. angular.forEach($scope.indexlist, function (val) {
  210. val.isselected = true;
  211. })
  212. } else {
  213. angular.forEach($scope.indexlist, function (val) {
  214. val.isselected = false;
  215. })
  216. }
  217. $scope.flag1 = !$scope.flag1;
  218. }
  219. $scope.choiceAll2 = function () {
  220. console.log(33333)
  221. if ($scope.flag2) {
  222. angular.forEach($scope.choiceyearmonthList, function (val) {
  223. val.isselected = true;
  224. })
  225. } else {
  226. angular.forEach($scope.choiceyearmonthList, function (val) {
  227. val.isselected = false;
  228. })
  229. }
  230. $scope.flag2 = !$scope.flag2;
  231. }
  232. //进入页面,获取当前节点的所有企业数据
  233. var getOrgStatsDataList = function () {
  234. taskModuleService.getOrgStatsDataList().then(function (res) {
  235. if (res.code == 3350) {
  236. $scope.orgnamelist = res.data;
  237. $scope.orgnametemplist = [];
  238. $scope.namelist = [];
  239. angular.forEach($scope.orgnamelist, function (val) {
  240. var temphtml = {
  241. name: val.name,
  242. isselected: false
  243. };
  244. $scope.namelist.push(temphtml);
  245. })
  246. angular.forEach($scope.orgnamelist, function (val) {
  247. $scope.orgnametemplist.push(val.name);
  248. })
  249. }
  250. })
  251. }
  252. getOrgStatsDataList();
  253. $scope.value = 1;
  254. $scope.goBackPage = function () {
  255. $scope.value--;
  256. }
  257. $scope.goNextPage = function () {
  258. $scope.value++;
  259. getAnalysisTime();
  260. }
  261. $scope.doAnalysis = function () {
  262. $scope.namebackuplist = [];
  263. $scope.indexbackuplist = [];
  264. $scope.timebackuplist = [];
  265. angular.forEach($scope.namelist, function (val) {
  266. if (val.isselected) {
  267. $scope.namebackuplist.push(val.name);
  268. }
  269. })
  270. angular.forEach($scope.indexlist, function (val) {
  271. if (val.isselected) {
  272. $scope.indexbackuplist.push(val.id);
  273. }
  274. })
  275. angular.forEach($scope.timelist, function (val) {
  276. if (val.isselected) {
  277. $scope.timebackuplist.push(val.name);
  278. }
  279. })
  280. if ($scope.indexbackuplist.length == 0) {
  281. $ionicPopup.alert({
  282. title: '提示',
  283. template: '请选择指标!'
  284. });
  285. return;
  286. }
  287. angular.forEach($scope.choiceyearmonthList, function (val) {
  288. if(val.isselected){
  289. $scope.timebackuplist.push(val);
  290. }
  291. })
  292. if ($scope.timebackuplist.length == 0) {
  293. $ionicPopup.alert({
  294. title: '提示',
  295. template: '请选择时间!'
  296. });
  297. return;
  298. }
  299. $scope.showLoadingToastUtilEnd();
  300. taskModuleService.downloadExcel($scope.namebackuplist, $scope.indexbackuplist, $scope.timebackuplist).then(function (res) {
  301. $scope.hideLoadingToast();
  302. if (res.code == 3350) {
  303. var file = res.data;
  304. $scope.url = ConfigService.imgurl + file.sourceName;
  305. if ($scope.app || $scope.isapp){
  306. $ionicPopup.alert({
  307. title: '分析结果',
  308. template: '<a href="{{url}}">点击查看分析结果!</a>'
  309. });
  310. return;
  311. }else {
  312. window.open($scope.url);
  313. }
  314. $scope.go('quarterlyAnalysis');
  315. } else {
  316. $ionicPopup.alert({
  317. title: '提示',
  318. template: '导出失败!'
  319. })
  320. return;
  321. }
  322. }).catch(function (res){
  323. $scope.hideLoadingToast();
  324. $ionicPopup.alert({
  325. title: '提示',
  326. template: "服务器错误"
  327. });
  328. })
  329. }
  330. }
  331. )
  332. ;