mainindex.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. (function ($app) {
  2. 'use strict';
  3. $app.module('ylmis').controller('mainindexCtrl', function ($scope, $state, $filter, $alert, AuthUser, flowaudit, $http, $ocLazyLoad, $loading, $window, $modal, $bsRouterState, $timeout) {
  4. $scope.noticeList = [];
  5. $scope.cdOption = {
  6. width: 580,
  7. height: 250,
  8. data: [],
  9. onSelected: function (view, date, data) {
  10. var d = $filter('date')(date, 'yyyy-MM-dd');
  11. $bsRouterState.$closeTab("home.dispatcher_log");
  12. $timeout(function () {
  13. $bsRouterState.go('home.dispatcher_log', {
  14. startDate: d + " 00:00",
  15. endDate: d + " 00:00",
  16. },1);
  17. }, 100);
  18. }
  19. };
  20. $scope.filterHtml = function (content) {
  21. content = content.replace(/<[^>]+>/g, "");
  22. content = content.replace(/&nbsp;/ig, "");
  23. return content;
  24. }
  25. $scope.getAnnouncementList = function () {
  26. $http
  27. ({
  28. method: 'post', url: '../../api/systemsetting/Notice/GetList', data: {
  29. pageIndex: 1,
  30. pageSize:7,
  31. nowDate: new Date()
  32. }
  33. }).then(function (result) {
  34. $scope.noticeList = result.data.Data.rows;
  35. if ($scope.noticeList.length > 0) {
  36. $scope.noticeList[0].select = true;
  37. }
  38. angular.forEach($scope.noticeList, function (x) { x.htmlContent = x.Content ? $scope.filterHtml(x.Content) : ""; });
  39. });
  40. };
  41. $scope.$on('tabChildReloadData', function (event, data) {
  42. if (data.name == 'mainindexCtrl') {
  43. $scope.getAnnouncementList();
  44. }
  45. });
  46. $scope.openToDo = function (url, pid, fid, kid) {
  47. $bsRouterState.$closeTabName(url);
  48. $timeout(function () {
  49. $bsRouterState.go(url, {
  50. pid: pid,
  51. fid: fid,
  52. kid: kid,
  53. reload: $scope.getAnnouncementList
  54. });
  55. }, 100);
  56. };
  57. $scope.selectRow = function (it) {
  58. angular.forEach($scope.noticeList, function (item) {
  59. item.select = false;
  60. })
  61. it.select = true;
  62. }
  63. $scope.moreNotice = function () {
  64. $bsRouterState.$closeTabName("home.mynotice");
  65. $timeout(function () {
  66. $bsRouterState.go('home.mynotice', {
  67. });
  68. }, 100);
  69. };
  70. $scope.getDispatcherDailySummary = function () {
  71. $http
  72. ({
  73. method: 'post', url: '../../api/report/RDispatcher/GetDispatcherDailySummary', data: {
  74. }
  75. }).then(function (result) {
  76. $scope.parseOption(result.data.Data.rows);
  77. });
  78. };
  79. $scope.pieOption = {};
  80. $scope.parseOption = function (dataList) {
  81. var series = new Array();
  82. var days = $.map(dataList, function (x) { return x.day; });
  83. var numbers = $.map(dataList, function (x) { return x.number; });
  84. var colors = ['#FF9801', '#2a579a', '#01BCD4']
  85. series.push({
  86. type: 'bar', barWidth: 35, itemStyle: {
  87. color: colors[2], normal: {
  88. color: colors[1],
  89. label: {
  90. show: true, //开启显示
  91. position: 'top', //在上方显示
  92. }
  93. }
  94. }, data: numbers
  95. });
  96. $scope.pieOption = {
  97. tooltip: {},
  98. xAxis: {
  99. type: 'category',
  100. data: days,
  101. axisLabel: {
  102. formatter: function (d) {
  103. return d.substr(0, 6) + "\n" + d.substr(6)
  104. },
  105. }
  106. },
  107. yAxis: [{
  108. type: 'value',
  109. name: '次数',
  110. axisLabel: {
  111. formatter: '{value}'
  112. }
  113. }],
  114. grid: { // 控制图的大小,调整下面这些值就可以,
  115. x: 40,
  116. x2: 10,
  117. },
  118. series: series
  119. };
  120. }
  121. $scope.getTugboatReport = function () {
  122. $http
  123. ({
  124. method: 'post', url: '../../api/dispatcher/tugboat/GetTugboatReport', data: {
  125. curDate: new Date()
  126. }
  127. }).then(function (result) {
  128. $scope.parseTugboatOption(result.data);
  129. });
  130. };
  131. $scope.tugboatOption = {};
  132. $scope.parseTugboatOption = function (data) {
  133. var product = ["product", "去年同期", "本年", "本月", "本周"];
  134. var source = new Array();
  135. source.push(product);
  136. angular.forEach(data, function (item, index) {
  137. source.push([item.TugboatName, item.同期数量, item.本年, item.本月, item.本周]);
  138. })
  139. $scope.tugboatOption = {
  140. tooltip: {},
  141. dataset: {
  142. source: source
  143. },
  144. legend: {
  145. bottom: 0,
  146. left: 'center',
  147. selected: { '本月': false, '本周': false }
  148. },
  149. xAxis: { type: 'category' },
  150. yAxis: {},
  151. grid: {
  152. x: 40,
  153. x2: 10,
  154. y: 20
  155. },
  156. series: [
  157. {
  158. type: 'bar', barWidth: 15, color: '#4572A7', barGap: 0, label: {
  159. show: true,
  160. position: 'top',
  161. }
  162. },
  163. {
  164. type: 'bar', barWidth: 15, color: '#AA4643', label: {
  165. show: true,
  166. position: 'top',
  167. }
  168. },
  169. {
  170. type: 'bar', barWidth: 15, color: '#89A54E', label: {
  171. show: true,
  172. position: 'top',
  173. }
  174. },
  175. {
  176. type: 'bar', barWidth: 15, color: '#80699B', label: {
  177. show: true, //开启显示
  178. position: 'top', //在上方显示
  179. }
  180. }
  181. ]
  182. };
  183. }
  184. $scope.getTugboatUsageReport = function () {
  185. $http
  186. ({
  187. method: 'post', url: '../../api/dispatcher/tugboat/GetTugboatUsageReport', data: {
  188. curDate: new Date()
  189. }
  190. }).then(function (result) {
  191. $scope.parseTugboatUsageOption(result.data);
  192. });
  193. };
  194. $scope.tugboatUsageOption = {};
  195. $scope.parseTugboatUsageOption = function (data) {
  196. var product = ["product", "本年", "目标值", "去年"];
  197. var source = new Array();
  198. source.push(product);
  199. angular.forEach(data, function (item, index) {
  200. source.push([item.number, item.本年, item.目标值, item.去年]);
  201. })
  202. $scope.tugboatUsageOption = {
  203. tooltip: {},
  204. dataset: {
  205. source: source
  206. },
  207. legend: {
  208. bottom: 0,
  209. left: 'center',
  210. },
  211. xAxis: { type: 'category' },
  212. yAxis: {},
  213. grid: {
  214. x: 40,
  215. x2: 10,
  216. y: 20
  217. },
  218. series: [
  219. {
  220. type: 'line', barWidth: 15, color: '#4572A7', label: {
  221. show: true,
  222. position: 'top',
  223. }
  224. },
  225. {
  226. type: 'line', barWidth: 15, color: '#AA4643', label: {
  227. show: false,
  228. position: 'top',
  229. }
  230. },
  231. {
  232. type: 'line', barWidth: 15, color: '#89A54E', label: {
  233. show: true,
  234. position: 'bottom',
  235. }
  236. }
  237. ]
  238. };
  239. }
  240. //$scope.getTugboatUsageReport();
  241. $scope.getTugboatReport();
  242. //$scope.getDispatcherDailySummary();
  243. var selectModal;
  244. $scope.showContent = function (it) {
  245. selectModal = $modal({
  246. resolve: {
  247. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  248. }]
  249. },
  250. scope: $scope,
  251. controller: selectCtrl,
  252. templateUrl: 'tmpShow.html',
  253. show: false,
  254. animation: 'am-fade-and-slide-top'
  255. });
  256. selectModal.params = it;
  257. selectModal.$promise.then(selectModal.show);
  258. };
  259. var selectCtrl = function ($scope, $http, $filter, $loading) {
  260. $scope.params = selectModal.params;
  261. };
  262. selectCtrl.$inject = ['$scope', '$http', '$filter', '$loading'];
  263. $scope.getAnnouncementList();
  264. });
  265. })(angular);