Browse Source

处理搜索空格能进行搜索的bug

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@8475 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 9 years ago
parent
commit
3b3845b2b6
1 changed files with 12 additions and 6 deletions
  1. 12 6
      src/main/webapp/resources/js/index/app.js

+ 12 - 6
src/main/webapp/resources/js/index/app.js

@@ -720,7 +720,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	  }
 	});
 	
-	app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', function($scope, $rootScope, $modal) {
+	app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', 'toaster', function($scope, $rootScope, $modal, toaster) {
 		$rootScope.$on('$locationChangeSuccess', function(evt, newUrl) {
 			var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
 			if (routeState.indexOf('/') > -1)
@@ -731,9 +731,11 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		});
 		
 		$scope.search = function(keyword) {
-			if(keyword != null ) {
+			if(keyword != null && keyword != '') {
 				$rootScope.searchKeyword = keyword;
 				window.location.hash = '#/search?keyword='+keyword;
+			} else {
+				toaster.pop('info', '提示', '请输入有效字符');
 			}
 		};
 
@@ -13798,10 +13800,14 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
 		// 搜索框回车
 		$scope.onSearch = function(keyword) {
-			$rootScope.searchKeyword = keyword;
-			$scope.keyword = keyword;
-			$scope.tableParams.page(1);
-			$scope.tableParams.reload();
+			if($scope.keyword != null && $scope.keyword != '') {
+				$rootScope.searchKeyword = keyword;
+				$scope.keyword = keyword;
+				$scope.tableParams.page(1);
+				$scope.tableParams.reload();
+			} else {
+				toaster.pop('info', '提示', '请输入有效字符');
+			}
 		};
 		
 		// 添加合作关系