Browse Source

修改密码

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@747 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
suntg 11 years ago
parent
commit
e6dace95d6

+ 70 - 1
src/main/webapp/resources/js/index/app.js

@@ -1822,8 +1822,11 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 		});
 		});
 	});
 	});
 	
 	
-	app.controller('UserCtrl', function($scope, $rootScope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams){
+	app.controller('UserCtrl', function($scope, $rootScope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal){
+		$scope.editing = false;
+		$scope.loading = true;
 		AuthenticationService.getAuthentication().success(function(data) {
 		AuthenticationService.getAuthentication().success(function(data) {
+			$scope.loading = false;
 			$scope.user = data;
 			$scope.user = data;
 		});
 		});
 		var users = [];
 		var users = [];
@@ -1847,7 +1850,73 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 		AccountUser.getAll({}, function(data){
 		AccountUser.getAll({}, function(data){
 			users = data;
 			users = data;
 			$scope.tableParams.reload();
 			$scope.tableParams.reload();
+			$scope.loading = false;
 		});
 		});
+		$scope.saveUser = function(){
+			$scope.loading = true;
+			AccountUser.saveUser({}, $scope.user, function(data){
+				$scope.loading = false;
+				toaster.pop('success', '提示', '修改用户信息成功');
+				AuthenticationService.getAuthentication().success(function(data) {
+					$scope.user = data;
+				});
+				AccountUser.getAll({}, function(data){
+					users = data;
+					$scope.tableParams.reload();
+				});
+				$scope.editing = false;
+			}, function(reponse){
+				$scope.loading = false;
+				toaster.pop('error', '失败', reponse.data);
+			});
+		};
+		
+		$scope.updatePassword = function(){
+			var modalInstance = $modal.open({
+				animation: true,
+				templateUrl: 'updatePassword.html',
+				controller: 'PasswordCtrl',
+				resolve: {
+					user: function(){return $scope.user;}
+				}
+			});
+			
+			modalInstance.result.then(function(){
+				$scope.tableParams.reload();
+			}, function(){
+				
+			});
+		};
+	});
+	
+	app.controller('PasswordCtrl', function($scope, $modalInstance, user, AccountUser, toaster){
+		$scope.user = user;
+		$scope.checking = false;
+		//输入原密码后验证原密码是否正确
+		$scope.checkPassword = function(password) {
+			$scope.checking = true;
+			$scope.checkSuccess = false;
+			$scope.checkFailed = false;
+			console.log(password);
+			AccountUser.checkPassword({password: password}, function(data){
+				$scope.checkSuccess = true;
+				$scope.checking = false;
+				$scope.checkFailed = false;
+			}, function(response){
+				$scope.checkFailed = true;
+				$scope.checking = false;
+				$scope.checkSuccess = false;
+			});
+		};
+		
+		//确认送样
+		$scope.ok = function () {
+			
+  		};
+
+  		$scope.cancel = function () {
+    		$modalInstance.dismiss();
+  		};
 	});
 	});
 	
 	
 	app.controller('LogCtrl', function($scope, $rootScope, BaseService, ngTableParams, ErpLog, UsageLog){
 	app.controller('LogCtrl', function($scope, $rootScope, BaseService, ngTableParams, ErpLog, UsageLog){

+ 8 - 0
src/main/webapp/resources/js/index/services/Account.js

@@ -6,6 +6,14 @@ define([ 'ngResource' ], function() {
 			getAll: {
 			getAll: {
 				isArray: true
 				isArray: true
 			},
 			},
+			saveUser: {
+				url: 'account/user/saveUser',
+				method: 'POST'
+			},
+			checkPassword: {
+				url: 'account/user/checkPassword',
+				method: 'GET'
+			}
 		});
 		});
 	}).factory('ErpLog', function($resource) {
 	}).factory('ErpLog', function($resource) {
 		return $resource('log/erp', {});
 		return $resource('log/erp', {});