statisticsController.js 11.5 KB
"use strict";
var statisticsControllers = angular.module('statisticsController',["highcharts-ng"]);

statisticsControllers.controller('statisticsController', [
 	'$rootScope',
	'$scope',
	'StatisticsService',
	'CategoryService',
	function($rootScope, $scope, StatisticsService,CategoryService) {
 		$scope.chartConfig={
 				 options: {
 				      chart: {
 				          type: 'column'
 				      },
 				      tooltip: {
 				    	  headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
 				            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
 				                '<td style="padding:0"><b>{point.y:.1f} 件</b></td></tr>',
 				            footerFormat: '</table>',
 				            shared: true,
 				            useHTML: true
 				      },
 				     colors: ['#7cb5ec','#90ed7d', '#f7a35c'],
 				  },
 				 
 				  series: [],
 			       title: {
 			            text: '商品销售图表'
 			        },
 			       
 		
 				  loading: false,
 		
 			       xAxis: {
 			            categories: [
 			               
 			            ],
 			            crosshair: true
 			        },
 			        
 			       yAxis: {
 			            min: 0,
 			            title: {
 			                text: '销售数量 (件)'
 			            }
 			        },
 			       lang: {
 			            noData: "没有商品数据"
 			        },
 			        noData: {
 			            style: {
 			                fontWeight: 'bold',
 			                fontSize: '15px',
 			                color: '#303030'
 			            }
 			        },
 				  useHighStocks: false,
 				  size: {
 				   width: 1052,
 				   height: 600
 				  },
 				  plotOptions: {
 			            column: {
 			                pointPadding: 0.2,
 			                borderWidth: 0
 			            }
 			        },
 				  func: function (chart) {
 					 chart.showLoading();
 				  }
 				};
 		$scope.currentPage = 1;
 	    $scope.numPages = 1;
 	    $scope.pageSize = 10;
 	    $scope.totalRecord = 0;
 	    $scope.pages = [];
 	   $scope.productQuery={
				categoryId:'',
				keyword:'',
				erpCode:'',
				isHot:'',
				isShow:'',
				isCopy:0,
				pageNow:1,
				pageSize:10
		};
		$scope.onChangeCategoryId=function() {
			var categoryId = "";
			if($scope.parentCategoryObj) {
				categoryId = $scope.parentCategoryObj.imCategoryId;
				CategoryService.listChildren(categoryId);
				$scope.$on('childrenCategory.list', function() {
					$scope.childrenCategory = CategoryService.childrenCategory;
				});
			}
			$scope.productQuery.categoryId=categoryId;
		};
		$scope.onChangeChildCategory=function() {
			var categoryId = "";
			if($scope.childrenCategoryObj) {
				categoryId = $scope.childrenCategoryObj.imCategoryId;
			}
			$scope.productQuery.categoryId=categoryId;
		};
 		CategoryService.listParent();
		$scope.$on('parentCategory.list', function() {
			$scope.parentCategory = CategoryService.parentCategory;
		});
		
		$scope.searchProduct=function() {
			$scope.productQuery.pageNow = 1;
			StatisticsService.pagerProduct($scope.productQuery);
		};
		
 	  StatisticsService.pagerProduct($scope.productQuery);
		$scope.$on('product.list', function() {
			$scope.numPages = StatisticsService.products.totalPage;
			$scope.totalRecord = StatisticsService.products.totalRecord;
			var productStatBean =StatisticsService.products.datas[0];
			if(productStatBean){
				var saleMap=productStatBean.saleMap;
				for(var i=0;i<saleMap.length;i++){
					saleMap[i].dataLabels={ enabled: true, rotation: -90, color: '#FFFFFF', align: 'right', x: 3, y: 2, style: { fontSize: '10px', fontFamily: 'Verdana, sans-serif', textShadow: '0 0 3px black' }};
				}
				$scope.chartConfig.series = saleMap;
				$scope.chartConfig.xAxis.categories=productStatBean.productNames;
			}else{
				$scope.chartConfig.series = [];
				$scope.chartConfig.xAxis.categories=[];
			}
		
			
		});
	    $scope.onSelectPage = function(page) {
 	    	$scope.productQuery.pageNow=page;
 	    	StatisticsService.pagerProduct($scope.productQuery);
		};
		$scope.isActive = function(page) {
			return $scope.currentPage === page;
		};
	}]
);

statisticsControllers.controller('statisticsListController', [
           	'$rootScope',
          	'$scope',
          	'StatisticsService',
          	'CategoryService',
          	function($rootScope, $scope, StatisticsService,CategoryService) {
           		$scope.currentPage = 1;
           	    $scope.numPages = 1;
           	    $scope.pageSize = 10;
           	    $scope.totalRecord = 0;
           	    $scope.pages = [];
           	    $scope.productBeans=[];
           	   $scope.productQuery={
          				categoryId:'',
          				keyword:'',
          				erpCode:'',
          				isHot:'',
          				isShow:'',
          				isCopy:0,
          				pageNow:1,
          				pageSize:10
          		};
          		$scope.onChangeCategoryId=function() {
          			var categoryId = "";
          			if($scope.parentCategoryObj) {
          				categoryId = $scope.parentCategoryObj.imCategoryId;
          				CategoryService.listChildren(categoryId);
          				$scope.$on('childrenCategory.list', function() {
          					$scope.childrenCategory = CategoryService.childrenCategory;
          				});
          			}
          			$scope.productQuery.categoryId=categoryId;
          		};
          		$scope.onChangeChildCategory=function() {
          			var categoryId = "";
          			if($scope.childrenCategoryObj) {
          				categoryId = $scope.childrenCategoryObj.imCategoryId;
          			}
          			$scope.productQuery.categoryId=categoryId;
          		};
           		CategoryService.listParent();
          		$scope.$on('parentCategory.list', function() {
          			$scope.parentCategory = CategoryService.parentCategory;
          		});
          		
          		$scope.searchProduct=function() {
          			$scope.productQuery.pageNow = 1;
          			StatisticsService.pagerProductList($scope.productQuery);
          		};
           	  StatisticsService.pagerProductList($scope.productQuery);
          		$scope.$on('product.list', function() {
          			$scope.numPages = StatisticsService.products.totalPage;
          			$scope.totalRecord = StatisticsService.products.totalRecord;
          			$scope.productBeans=StatisticsService.products.datas;
      
          		});
          	    $scope.onSelectPage = function(page) {
           	    	$scope.productQuery.pageNow=page;
           	    	StatisticsService.pagerProductList($scope.productQuery);
          		};
          		$scope.isActive = function(page) {
          			return $scope.currentPage === page;
          		};
          		
        		$scope.exportProductExcel=function() {
    				if(confirm("小主,导出数据很多,请耐心等待...")) {
    					window.open("../template/exportSaleProductExcel?keyword="+$scope.productQuery.keyword+
    							"&erpCode="+$scope.productQuery.erpCode+
    							"&categoryId="+$scope.productQuery.categoryId+
    							"&pageNow=1"+
    							"&pageSize=50000"
    							);
    				}
        		}
          	}]
 );

statisticsControllers.controller('orderStatisticsController', [
 	'$rootScope',
	'$scope',
	'StatisticsService',
	function($rootScope, $scope, StatisticsService) {
 		$scope.currentOrder = {};
 		$scope.integralOrder = {};
 		$scope.moneyOrder = {};
 		StatisticsService.getCurrentOrderStatictis();
  		$scope.$on('orderCount:statictis', function() {
  			$scope.currentOrder = StatisticsService.orderStatictis;
  		});
  		StatisticsService.getIntegralOrderStatictis();
  		$scope.$on('integralOrderCount:statictis', function() {
  			$scope.integralOrder = StatisticsService.orderStatictis;
  		});
  		StatisticsService.getMoneyOrderStatictis();
  		$scope.$on('moneyOrderCount:statictis', function() {
  			$scope.moneyOrder = StatisticsService.orderStatictis;
  		});
 	}]
);

statisticsControllers.controller('productSearchController', [
    '$rootScope',
    '$scope',
    'StatisticsService',
    function($rootScope, $scope, StatisticsService) {
        $scope.currentPage = 1;
        $scope.numPages = 1;
        $scope.pageSize = 15;
        $scope.totalRecord = 0;
        $scope.pages = [];
        $scope.searchEndDt = '';
        $scope.searchStartDt = '',
        StatisticsService.listProductSearch($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        $scope.$on('productSearchs.list', function() {
            $scope.productSearchs = StatisticsService.productSearchs.datas;
            $scope.numPages = StatisticsService.productSearchs.totalPage;
            $scope.totalRecord = StatisticsService.productSearchs.totalRecord;
        });
        $scope.onSelectPage = function(page) {
            $scope.currentPage=page;
            StatisticsService.listProductSearch($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        };
        $scope.isActive = function(page) {
            return $scope.currentPage === page;
        };

        $scope.searchProductSearch=function(){
            $scope.currentPage=1;
            $scope.searchStartDt = $('#datepickfrom').val();
            $scope.searchEndDt   = $('#datepickto').val();
            StatisticsService.listProductSearch($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        };

        $scope.exportProductSearch=function() {
            $scope.searchStartDt = $('#datepickfrom').val();
            $scope.searchEndDt   = $('#datepickto').val();
            if(confirm("小主,导出数据很多,请耐心等待...")) {
                window.open("../templateRecord/exportProductSearchExcel?erpCode="+"?pageNow=1&pageSize=5000&searchStartDt="+$scope.searchStartDt+"&searchEndDt="+$scope.searchEndDt);
            }

        }
    }]
);

statisticsControllers.controller('memberShopcartController', [
    '$rootScope',
    '$scope',
    'StatisticsService',
    function($rootScope, $scope, StatisticsService) {
        $scope.currentPage = 1;
        $scope.numPages = 1;
        $scope.pageSize = 15;
        $scope.totalRecord = 0;
        $scope.pages = [];
        $scope.searchEndDt = '';
        $scope.searchStartDt = '',

		StatisticsService.listMemberShopcart($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        $scope.$on('memberShopcarts.list', function() {
            $scope.memberShopcarts = StatisticsService.memberShopcarts.datas;
            $scope.numPages = StatisticsService.memberShopcarts.totalPage;
            $scope.totalRecord = StatisticsService.memberShopcarts.totalRecord;
        });
        $scope.onSelectPage = function(page) {
            $scope.currentPage=page;
            StatisticsService.listMemberShopcart($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        };
        $scope.isActive = function(page) {
            return $scope.currentPage === page;
        };

        $scope.searchMemberShopcart=function(){
            $scope.currentPage=1;
            $scope.searchStartDt = $('#datepickfrom').val();
            $scope.searchEndDt   = $('#datepickto').val();
            StatisticsService.listMemberShopcart($scope.currentPage, $scope.pageSize, $scope.searchStartDt, $scope.searchEndDt);
        };

        $scope.exportMemberShopcart=function() {
            $scope.searchStartDt = $('#datepickfrom').val();
            $scope.searchEndDt   = $('#datepickto').val();
            if(confirm("小主,导出数据很多,请耐心等待...")) {
                window.open("../templateRecord/exportMemberShopcartExcel?erpCode="+"?pageNow=1&pageSize=5000&searchStartDt="+$scope.searchStartDt+"&searchEndDt="+$scope.searchEndDt);
            }

        }
    }]
);