|
|
@@ -1878,7 +1878,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- app.controller('UserCtrl', function($scope, $rootScope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal){
|
|
|
+ app.controller('UserCtrl', function($scope, $rootScope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http){
|
|
|
$scope.editing = false;
|
|
|
$scope.loading = true;
|
|
|
AuthenticationService.getAuthentication().success(function(data) {
|
|
|
@@ -1942,8 +1942,107 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- $scope.addUser = function(newUser) {
|
|
|
+ $scope.newUser = {};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加用户
|
|
|
+ */
|
|
|
+ $scope.addUser = function() {
|
|
|
$scope.adding = true;
|
|
|
+ console.log($scope.newUser);
|
|
|
+ AccountUser.add({}, $scope.newUser, function(){
|
|
|
+ toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
|
|
|
+ $scope.newUser = {userSex: 'M'};
|
|
|
+ AccountUser.getAll({}, function(data){
|
|
|
+ users = data;
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ });
|
|
|
+ $scope.adding = false;
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ }, function(response){
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证手机号是否可用
|
|
|
+ */
|
|
|
+ $scope.telValid = function(tel) {
|
|
|
+ console.log($scope.newUser);
|
|
|
+ if(tel) {
|
|
|
+ $http.get('account/user/telEnable', {
|
|
|
+ params: {
|
|
|
+ tel: tel
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ data = eval(data);
|
|
|
+ if(data == true) {
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available', true);
|
|
|
+ $scope.userTelSuccess = true;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ } else {
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
+ $scope.userTelError = true;
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ }
|
|
|
+ }).error(function(){
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证邮箱是否可用
|
|
|
+ */
|
|
|
+ $scope.emailValid = function(email) {
|
|
|
+ if(email) {
|
|
|
+ $http.get('account/user/emailEnable', {
|
|
|
+ params: {
|
|
|
+ email: email
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ data = eval(data);
|
|
|
+ if(data == true) {
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available', true);
|
|
|
+ $scope.userEmailSuccess = true;
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ } else {
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
+ $scope.userEmailError = true;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ }
|
|
|
+ }).error(function(){
|
|
|
+ $scope.userEmailError = true;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除用户
|
|
|
+ */
|
|
|
+ $scope.removeUser = function(uu) {
|
|
|
+ AccountUser.remove({uu: uu}, function(){
|
|
|
+ toaster.pop('success', '提示', '删除用户成功。');
|
|
|
+ AccountUser.getAll({}, function(data){
|
|
|
+ users = data;
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ });
|
|
|
+ }, function(){
|
|
|
+ toaster.pop('error', '提示', '删除用户失败。');
|
|
|
+ });
|
|
|
};
|
|
|
});
|
|
|
|