(function ($app) { 'use strict'; $app.module('ylmis').controller('mainindexCtrl', function ($scope, $state, $filter, $alert, AuthUser, flowaudit, $http, $ocLazyLoad, $loading, $window, $modal, $bsRouterState, $timeout) { $scope.noticeList = []; $scope.cdOption = { width: 580, height: 250, data: [], onSelected: function (view, date, data) { var d = $filter('date')(date, 'yyyy-MM-dd'); $bsRouterState.$closeTab("home.dispatcher_log"); $timeout(function () { $bsRouterState.go('home.dispatcher_log', { startDate: d + " 00:00", endDate: d + " 00:00", },1); }, 100); } }; $scope.filterHtml = function (content) { content = content.replace(/<[^>]+>/g, ""); content = content.replace(/ /ig, ""); return content; } $scope.getAnnouncementList = function () { $http ({ method: 'post', url: '../../api/systemsetting/Notice/GetList', data: { pageIndex: 1, pageSize:7, nowDate: new Date() } }).then(function (result) { $scope.noticeList = result.data.Data.rows; if ($scope.noticeList.length > 0) { $scope.noticeList[0].select = true; } angular.forEach($scope.noticeList, function (x) { x.htmlContent = x.Content ? $scope.filterHtml(x.Content) : ""; }); }); }; $scope.$on('tabChildReloadData', function (event, data) { if (data.name == 'mainindexCtrl') { $scope.getAnnouncementList(); } }); $scope.openToDo = function (url, pid, fid, kid) { $bsRouterState.$closeTabName(url); $timeout(function () { $bsRouterState.go(url, { pid: pid, fid: fid, kid: kid, reload: $scope.getAnnouncementList }); }, 100); }; $scope.selectRow = function (it) { angular.forEach($scope.noticeList, function (item) { item.select = false; }) it.select = true; } $scope.moreNotice = function () { $bsRouterState.$closeTabName("home.mynotice"); $timeout(function () { $bsRouterState.go('home.mynotice', { }); }, 100); }; $scope.getDispatcherDailySummary = function () { $http ({ method: 'post', url: '../../api/report/RDispatcher/GetDispatcherDailySummary', data: { } }).then(function (result) { $scope.parseOption(result.data.Data.rows); }); }; $scope.pieOption = {}; $scope.parseOption = function (dataList) { var series = new Array(); var days = $.map(dataList, function (x) { return x.day; }); var numbers = $.map(dataList, function (x) { return x.number; }); var colors = ['#FF9801', '#2a579a', '#01BCD4'] series.push({ type: 'bar', barWidth: 35, itemStyle: { color: colors[2], normal: { color: colors[1], label: { show: true, //开启显示 position: 'top', //在上方显示 } } }, data: numbers }); $scope.pieOption = { tooltip: {}, xAxis: { type: 'category', data: days, axisLabel: { formatter: function (d) { return d.substr(0, 6) + "\n" + d.substr(6) }, } }, yAxis: [{ type: 'value', name: '次数', axisLabel: { formatter: '{value}' } }], grid: { // 控制图的大小,调整下面这些值就可以, x: 40, x2: 10, }, series: series }; } $scope.getTugboatReport = function () { $http ({ method: 'post', url: '../../api/dispatcher/tugboat/GetTugboatReport', data: { curDate: new Date() } }).then(function (result) { $scope.parseTugboatOption(result.data); }); }; $scope.tugboatOption = {}; $scope.parseTugboatOption = function (data) { var product = ["product", "去年同期", "本年", "本月", "本周"]; var source = new Array(); source.push(product); angular.forEach(data, function (item, index) { source.push([item.TugboatName, item.同期数量, item.本年, item.本月, item.本周]); }) $scope.tugboatOption = { tooltip: {}, dataset: { source: source }, legend: { bottom: 0, left: 'center', selected: { '本月': false, '本周': false } }, xAxis: { type: 'category' }, yAxis: {}, grid: { x: 40, x2: 10, y: 20 }, series: [ { type: 'bar', barWidth: 15, color: '#4572A7', barGap: 0, label: { show: true, position: 'top', } }, { type: 'bar', barWidth: 15, color: '#AA4643', label: { show: true, position: 'top', } }, { type: 'bar', barWidth: 15, color: '#89A54E', label: { show: true, position: 'top', } }, { type: 'bar', barWidth: 15, color: '#80699B', label: { show: true, //开启显示 position: 'top', //在上方显示 } } ] }; } $scope.getTugboatUsageReport = function () { $http ({ method: 'post', url: '../../api/dispatcher/tugboat/GetTugboatUsageReport', data: { curDate: new Date() } }).then(function (result) { $scope.parseTugboatUsageOption(result.data); }); }; $scope.tugboatUsageOption = {}; $scope.parseTugboatUsageOption = function (data) { var product = ["product", "本年", "目标值", "去年"]; var source = new Array(); source.push(product); angular.forEach(data, function (item, index) { source.push([item.number, item.本年, item.目标值, item.去年]); }) $scope.tugboatUsageOption = { tooltip: {}, dataset: { source: source }, legend: { bottom: 0, left: 'center', }, xAxis: { type: 'category' }, yAxis: {}, grid: { x: 40, x2: 10, y: 20 }, series: [ { type: 'line', barWidth: 15, color: '#4572A7', label: { show: true, position: 'top', } }, { type: 'line', barWidth: 15, color: '#AA4643', label: { show: false, position: 'top', } }, { type: 'line', barWidth: 15, color: '#89A54E', label: { show: true, position: 'bottom', } } ] }; } //$scope.getTugboatUsageReport(); $scope.getTugboatReport(); //$scope.getDispatcherDailySummary(); var selectModal; $scope.showContent = function (it) { selectModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { }] }, scope: $scope, controller: selectCtrl, templateUrl: 'tmpShow.html', show: false, animation: 'am-fade-and-slide-top' }); selectModal.params = it; selectModal.$promise.then(selectModal.show); }; var selectCtrl = function ($scope, $http, $filter, $loading) { $scope.params = selectModal.params; }; selectCtrl.$inject = ['$scope', '$http', '$filter', '$loading']; $scope.getAnnouncementList(); }); })(angular);