Просмотр исходного кода

求购默认选择全部的问题

huangb 7 лет назад
Родитель
Сommit
5f2b8066fa

+ 61 - 58
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -18,6 +18,37 @@ define(['app/app', 'clipboard', 'QRCode'], function (app, clipboard, QRCode) {
           }
           $rootScope.ShaRETimer = {}
 
+            // 筛选
+            var _formatDate = function (date, fmt) {
+                if (!date) {
+                    return null;
+                }
+                if (typeof date === 'string') {
+                    date = new Date(Date.parse(date.replace(/-/g, '/')));
+                }
+                var o = {
+                    'M+': date.getMonth() + 1, // 月份
+                    'd+': date.getDate(), // 日
+                    'h+': date.getHours(), // 小时
+                    'm+': date.getMinutes(), // 分
+                    's+': date.getSeconds(), // 秒
+                    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
+                    'S': date.getMilliseconds() // 毫秒
+                }
+                if (/(y+)/.test(fmt)) {
+                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
+                }
+                for (var k in o) {
+                    if (new RegExp('(' + k + ')').test(fmt)) {
+                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
+                    }
+                }
+                return fmt;
+            }
+
+            var _getClearDay = function (date) {
+                return new Date(_formatDate(date, 'yyyy-MM-dd')).getTime() - 8 * 60 * 60 * 1000
+            }
           var clearSeekStatus = function () {
             // if ($scope.seekListData) {}
             angular.forEach($scope.seekListData.content, function (item) {
@@ -38,11 +69,38 @@ define(['app/app', 'clipboard', 'QRCode'], function (app, clipboard, QRCode) {
           $scope.vendorType = 'self'
           $scope.onVendorTypeChange = function () {
             $scope.keyword = '';
-            $scope.startDate = null;
-            $scope.endDate = null;
             $scope.seekPurchaseTableParams.page(1);
             $scope.seekPurchaseTableParams.reload();
           }
+            $scope.setFilters = function (type, val, flag) {
+                $scope[type] = val;
+                if (type == 'dateArea') {
+                    // 时间筛选
+                    var currentTime = _getClearDay(new Date());
+                    var endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
+                    if (val == 'ALL' || val == 'autoDay') {
+                        $scope.startDate = null;
+                        $scope.endDate = null;
+                    } else if (val == 'oneDay') {
+                        $scope.startDate = new Date(currentTime - 24 * 60 * 60 * 1000);
+                        $scope.endDate = endDate;
+                    } else if (val == 'threeDay') {
+                        $scope.startDate = new Date(currentTime - 3 * 24 * 60 * 60 * 1000);
+                        $scope.endDate = endDate;
+                    } else if (val == 'sevenDay') {
+                        $scope.startDate = new Date(currentTime - 7 * 24 * 60 * 60 * 1000);
+                        $scope.endDate = endDate;
+                    } else {
+                        $scope.startDate = null;
+                        $scope.endDate = null;
+                    }
+                }
+                if (flag) return
+                $scope.seekPurchaseTableParams.page(1);
+                $scope.seekPurchaseTableParams.reload();
+            }
+            $scope.setFilters('dateArea', 'sevenDay', '1')
+
           seekPurchase.getSeekUrl({}, function(data) {
             var seekUrl = data.url;
             //   var seekUrl = 'http://10.1.51.82:24002';
@@ -1163,63 +1221,8 @@ define(['app/app', 'clipboard', 'QRCode'], function (app, clipboard, QRCode) {
             })
           }
           });
-            // 筛选
-            var _formatDate = function (date, fmt) {
-                if (!date) {
-                    return null;
-                }
-                if (typeof date === 'string') {
-                    date = new Date(Date.parse(date.replace(/-/g, '/')));
-                }
-                var o = {
-                    'M+': date.getMonth() + 1, // 月份
-                    'd+': date.getDate(), // 日
-                    'h+': date.getHours(), // 小时
-                    'm+': date.getMinutes(), // 分
-                    's+': date.getSeconds(), // 秒
-                    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
-                    'S': date.getMilliseconds() // 毫秒
-                }
-                if (/(y+)/.test(fmt)) {
-                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
-                }
-                for (var k in o) {
-                    if (new RegExp('(' + k + ')').test(fmt)) {
-                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
-                    }
-                }
-                return fmt;
-            }
 
-            var _getClearDay = function (date) {
-                return new Date(_formatDate(date, 'yyyy-MM-dd')).getTime() - 8 * 60 * 60 * 1000
-            }
 
-            $scope.setFilters = function (type, val) {
-                $scope[type] = val;
-                if (type == 'dateArea') {
-                    // 时间筛选
-                    var currentTime = _getClearDay(new Date());
-                    var endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
-                    if (val == 'ALL' || val == 'autoDay') {
-                        $scope.startDate = null;
-                        $scope.endDate = null;
-                    } else if (val == 'oneDay') {
-                        $scope.startDate = new Date(currentTime - 24 * 60 * 60 * 1000);
-                        $scope.endDate = endDate;
-                    } else if (val == 'threeDay') {
-                        $scope.startDate = new Date(currentTime - 3 * 24 * 60 * 60 * 1000);
-                        $scope.endDate = endDate;
-                    } else if (val == 'sevenDay') {
-                        $scope.startDate = new Date(currentTime - 7 * 24 * 60 * 60 * 1000);
-                        $scope.endDate = endDate;
-                    } else {
-                        $scope.startDate = null;
-                        $scope.endDate = null;
-                    }
-                }
-                $scope.seekPurchaseTableParams.page(1);
-                $scope.seekPurchaseTableParams.reload();
-            }
+
         }]);
 });