Browse Source

更新前端产品导出参数拼接方法

hejq 7 years ago
parent
commit
e87f09887c

+ 11 - 1
src/main/webapp/resources/js/admin/controllers/product/brandProductsCountCtrl.js

@@ -24,7 +24,17 @@ define(['app/app'], function(app) {
 
             // 导出
             $scope.exportXls = function () {
-                window.location.href = '/trade/goods/brandProductsCount/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate;
+                var url = "/trade/goods/brandProductsCount/export";
+                if (angular.isDefined($scope.startFormatDate)) {
+                    url = url + '?startTime=' + $scope.startFormatDate;
+                }
+                if (angular.isDefined($scope.startFormatDate) && angular.isDefined($scope.endFormatDate)) {
+                    url = url + "&endTime=" + $scope.endFormatDate;
+                }
+                if (!angular.isDefined($scope.startFormatDate) && angular.isDefined($scope.endFormatDate)) {
+                    url = url + "?endTime=" + $scope.endFormatDate;
+                }
+                window.open(url);
             }
         }])
 })

+ 11 - 1
src/main/webapp/resources/js/admin/controllers/product/categoryNumberCtrl.js

@@ -24,7 +24,17 @@ define(['app/app'], function(app) {
 
             // 导出
             $scope.exportXls = function () {
-                window.location.href = '/trade/goods/kindProductsCount/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate;
+                var url = "/trade/goods/kindProductsCount/export";
+                if (angular.isDefined($scope.startFormatDate)) {
+                    url = url + '?startTime=' + $scope.startFormatDate;
+                }
+                if (angular.isDefined($scope.startFormatDate) && angular.isDefined($scope.endFormatDate)) {
+                    url = url + "&endTime=" + $scope.endFormatDate;
+                }
+                if (!angular.isDefined($scope.startFormatDate) && angular.isDefined($scope.endFormatDate)) {
+                    url = url + "?endTime=" + $scope.endFormatDate;
+                }
+                window.open(url);
             }
         }])
 })

+ 7 - 2
src/main/webapp/resources/js/admin/controllers/product/productManageCtrl.js

@@ -318,8 +318,13 @@ define(['app/app'], function(app) {
         // 产品导出事件
         $scope.exportClick = function () {
             // 拼装链接
-            var url = '/trade/goods/background/download?startTime=' + $scope.startDate.getTime() + "&endTime=" + $scope.endDate.getTime()
-                + "&page=" + $scope.pageParams.page + "&count=" + $scope.pageParams.count + "&sorting=" + encodeURIComponent(angular.toJson($scope.pageParams.sorting));
+            var url = "/trade/goods/background/download?page=" + $scope.pageParams.page + "&count=" + $scope.pageParams.count + "&sorting=" + encodeURIComponent(angular.toJson($scope.pageParams.sorting));
+            if (angular.isDefined($scope.startDate) && null != $scope.startDate) {
+                url = url + "&startTime=" + $scope.startDate.getTime();
+            }
+            if (angular.isDefined($scope.endDate) && null != $scope.endDate) {
+                url = url + "&endTime=" + $scope.endDate.getTime();
+            }
             if (angular.isDefined($scope.goodsFilter.kindUuid)) {
                 url = url + "&kindUuid=" + $scope.goodsFilter.kindUuid;
             }