|
|
@@ -945,7 +945,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
angular.forEach(inquiry.attachs, function(attach){
|
|
|
attach.type = attach.name.substr(attach.name.lastIndexOf('.')+1);
|
|
|
});
|
|
|
- console.log(inquiry);
|
|
|
$scope.inquiry = inquiry;
|
|
|
});
|
|
|
};
|
|
|
@@ -1976,7 +1975,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- app.controller('UserCtrl', function($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http){
|
|
|
+ app.controller('UserCtrl', function($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert){
|
|
|
$scope.editing = false;
|
|
|
$scope.loading = true;
|
|
|
AuthenticationService.getAuthentication().success(function(data) {
|
|
|
@@ -2001,23 +2000,23 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$defer.resolve($scope.users);
|
|
|
}
|
|
|
});
|
|
|
- AccountUser.getAll({}, function(data){
|
|
|
- users = data;
|
|
|
- $scope.tableParams.reload();
|
|
|
- $scope.loading = false;
|
|
|
- });
|
|
|
+ var loadUsers = function() {
|
|
|
+ AccountUser.query({}, function(data){
|
|
|
+ users = data;
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ $scope.loading = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadUsers();
|
|
|
$scope.saveUser = function(){
|
|
|
$scope.loading = true;
|
|
|
- AccountUser.saveUser({}, $scope.user, function(data){
|
|
|
+ AccountUser.update({}, $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();
|
|
|
- });
|
|
|
+ loadUsers();
|
|
|
$scope.editing = false;
|
|
|
}, function(reponse){
|
|
|
$scope.loading = false;
|
|
|
@@ -2047,14 +2046,10 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
*/
|
|
|
$scope.addUser = function() {
|
|
|
$scope.adding = true;
|
|
|
- console.log($scope.newUser);
|
|
|
- AccountUser.add({}, $scope.newUser, function(){
|
|
|
+ AccountUser.save({}, $scope.newUser, function(){
|
|
|
toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
|
|
|
$scope.newUser = {userSex: 'M'};
|
|
|
- AccountUser.getAll({}, function(data){
|
|
|
- users = data;
|
|
|
- $scope.tableParams.reload();
|
|
|
- });
|
|
|
+ loadUsers();
|
|
|
$scope.adding = false;
|
|
|
$scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
$scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
@@ -2071,7 +2066,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
* 验证手机号是否可用
|
|
|
*/
|
|
|
$scope.telValid = function(tel) {
|
|
|
- console.log($scope.newUser);
|
|
|
if(tel) {
|
|
|
$http.get('account/user/telEnable', {
|
|
|
params: {
|
|
|
@@ -2131,18 +2125,93 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
/**
|
|
|
* 删除用户
|
|
|
*/
|
|
|
- $scope.removeUser = function(uu) {
|
|
|
- AccountUser.remove({uu: uu}, function(){
|
|
|
- toaster.pop('success', '提示', '删除用户成功。');
|
|
|
- AccountUser.getAll({}, function(data){
|
|
|
- users = data;
|
|
|
- $scope.tableParams.reload();
|
|
|
- });
|
|
|
+ $scope.removeUser = function(user) {
|
|
|
+ new ngAlert({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定删除用户(' + user.userName + ')吗?'
|
|
|
}, function(){
|
|
|
- toaster.pop('error', '提示', '删除用户失败。');
|
|
|
+ AccountUser.remove({uu: user.userUU}, function(){
|
|
|
+ toaster.pop('success', '提示', '用户删除成功。');
|
|
|
+ loadUsers();
|
|
|
+ }, function(response){
|
|
|
+ toaster.pop('error', '删除失败', response.data);
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+ // 编辑用户的角色
|
|
|
+ $scope.editUserRole = function(user) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/user_role.html',
|
|
|
+ controller: 'UserRoleCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function() {
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(changed, checked){
|
|
|
+ if(changed) {
|
|
|
+ if(checked)
|
|
|
+ $scope.newUser.roles = checked;
|
|
|
+ else
|
|
|
+ loadUsers();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ app.controller('UserRoleCtrl', function($scope, $modalInstance, user, AccountRole, AccountUser, toaster){
|
|
|
+ $scope.checked = [];
|
|
|
+ $scope.master = [];
|
|
|
+ AccountRole.query({}, function(data){
|
|
|
+ if(user && data) {
|
|
|
+ var rs = [], checked = [];
|
|
|
+ angular.forEach(user.roles, function(r){
|
|
|
+ rs.push(r.id);
|
|
|
+ });
|
|
|
+ angular.forEach(data, function(d){
|
|
|
+ if(rs.indexOf(d.id) > -1) {
|
|
|
+ d.$checked = true;
|
|
|
+ checked.push(d);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $scope.roles = data;
|
|
|
+ $scope.checked = checked;
|
|
|
+ $scope.master = angular.copy($scope.checked);
|
|
|
+ });
|
|
|
+ $scope.select = function(role) {
|
|
|
+ role.$checked = !role.$checked;
|
|
|
+ if(role.$checked) {
|
|
|
+ $scope.checked.push(role);
|
|
|
+ } else {
|
|
|
+ angular.forEach($scope.checked, function(c, i){
|
|
|
+ if(c.id == role.id)
|
|
|
+ $scope.checked.splice(i, 1);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $scope.isChanged = function() {
|
|
|
+ return !angular.equals($scope.master, $scope.checked);
|
|
|
+ };
|
|
|
+ $scope.close = function(save) {
|
|
|
+ if(save) {
|
|
|
+ if(user.userUU) {
|
|
|
+ user.roles = $scope.checked;
|
|
|
+ AccountUser.update({}, user, function(){
|
|
|
+ toaster.pop('success', '提示', '保存成功');
|
|
|
+ $modalInstance.close(true);
|
|
|
+ }, function(response){
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $modalInstance.close(true, $scope.checked);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $modalInstance.close(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
});
|
|
|
|
|
|
app.controller('PasswordCtrl', function($scope, $modalInstance, user, AccountUser, toaster){
|
|
|
@@ -2166,8 +2235,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
|
|
|
//修改密码
|
|
|
$scope.ok = function () {
|
|
|
- console.log($scope.user.newPassword);
|
|
|
- console.log($scope.user.newPassword1);
|
|
|
if($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
|
|
|
AccountUser.updatePassword({password: $scope.user.password, newPassword: $scope.user.newPassword}, {}, function(data){
|
|
|
toaster.pop('success', '成功', '修改密码成功,请牢记您的新密码。');
|
|
|
@@ -2234,7 +2301,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
});
|
|
|
|
|
|
app.controller('ResourceCtrl', function($scope, AccountResource){
|
|
|
- AccountResource.getAll({}, function(data){
|
|
|
+ AccountResource.query({}, function(data){
|
|
|
if(data && data.length > 0) {
|
|
|
data[0].$open = true;
|
|
|
}
|
|
|
@@ -2245,7 +2312,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
app.controller('RoleCtrl', function($scope, $modal, AccountRole){
|
|
|
$scope.roles = {};
|
|
|
var getData = function() {
|
|
|
- AccountRole.getAll({}, function(data){
|
|
|
+ AccountRole.query({}, function(data){
|
|
|
var defaults = [], custom = [];
|
|
|
angular.forEach(data, function(d){
|
|
|
if(d.isdefault == 1)
|
|
|
@@ -2281,7 +2348,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.cancel = function() {
|
|
|
$modalInstance.close(false);
|
|
|
};
|
|
|
- AccountResource.getAll({}, function(data){
|
|
|
+ AccountResource.query({}, function(data){
|
|
|
if(data && data.length > 0) {
|
|
|
if(role && role.resourceItems) {
|
|
|
var rs = [];// 已分配的资源的id
|