|
|
@@ -2156,6 +2156,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
resolve: {
|
|
|
customer: function () {
|
|
|
return customer;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'purchase'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -2193,6 +2196,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
resolve: {
|
|
|
customer: function () {
|
|
|
return customer;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'purchase'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -2440,6 +2446,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
resolve: {
|
|
|
customer: function () {
|
|
|
return $scope.customerInfo;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'purchase'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -2466,18 +2475,32 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService',
|
|
|
- function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
|
|
|
+ app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type',
|
|
|
+ function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
|
|
|
AuthenticationService.getAuthentication().success(function (data) {
|
|
|
$scope.thisUser = data;
|
|
|
});
|
|
|
|
|
|
+ var urlData, urlSaveData, uuData;
|
|
|
+ var params = {};
|
|
|
+ if (type === 'sale') {
|
|
|
+ params = {id : customer.id};
|
|
|
+ urlSaveData = 'addSaleUserToVendor';
|
|
|
+ urlData = 'findSaleUsers';
|
|
|
+ uuData = customer.vendorEnterprise.uu;
|
|
|
+ } else {
|
|
|
+ params = {uu : customer.myEnterprise.uu};
|
|
|
+ urlSaveData = 'addUserToVendor';
|
|
|
+ urlData = 'findUsers';
|
|
|
+ uuData = customer.myEnterprise.uu;
|
|
|
+ }
|
|
|
+
|
|
|
$scope.checkboxes = {
|
|
|
checked: false
|
|
|
};
|
|
|
$scope.loading = true;
|
|
|
$scope.distribute = [];
|
|
|
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
|
|
|
+ AccountUser[urlData](params, null, function (data) {
|
|
|
$scope.userinfos = data;
|
|
|
var distribute = [];
|
|
|
angular.forEach($scope.userinfos, function (user, index) {
|
|
|
@@ -2526,13 +2549,13 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.close = function (save) {
|
|
|
var chooseResult = [];
|
|
|
if (save) {
|
|
|
- if (customer.myEnterprise.uu) {
|
|
|
+ if (uuData) {
|
|
|
angular.forEach($scope.userinfos, function (item, i) {
|
|
|
chooseResult.push(item);
|
|
|
});
|
|
|
if (chooseResult.length > 0) {
|
|
|
$scope.loading = true;
|
|
|
- AccountUser.addUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
|
|
|
+ AccountUser[urlSaveData]({uu: uuData}, chooseResult, function (data) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '提示', '保存成功');
|
|
|
$modalInstance.close(false);
|
|
|
@@ -2555,7 +2578,21 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}]);
|
|
|
|
|
|
// 转移权限
|
|
|
- app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
|
|
|
+ app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
|
|
|
+ var urlData, urlSaveData, uuData;
|
|
|
+ var params = {};
|
|
|
+ if (type === 'sale') {
|
|
|
+ params = {id : customer.id};
|
|
|
+ urlSaveData = 'transferSaleUserToVendor';
|
|
|
+ urlData = 'findSaleUsers';
|
|
|
+ uuData = customer.vendorEnterprise.uu;
|
|
|
+ } else {
|
|
|
+ params = {uu : customer.myEnterprise.uu};
|
|
|
+ urlSaveData = 'transferUserToVendor';
|
|
|
+ urlData = 'findUsers';
|
|
|
+ uuData = customer.myEnterprise.uu;
|
|
|
+ }
|
|
|
+
|
|
|
AuthenticationService.getAuthentication().success(function (data) {
|
|
|
$scope.loading = false;
|
|
|
$scope.thisUser = data;
|
|
|
@@ -2565,7 +2602,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
};
|
|
|
$scope.loading = true;
|
|
|
$scope.transfer = [];
|
|
|
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, {}, function (data) {
|
|
|
+ AccountUser[urlData](params, {}, function (data) {
|
|
|
$scope.userinfos = data;
|
|
|
var transfer = [];
|
|
|
angular.forEach($scope.userinfos, function (user, index) {
|
|
|
@@ -2642,7 +2679,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.close = function (save) {
|
|
|
var chooseResult = [];
|
|
|
if (save) {
|
|
|
- if (customer.myEnterprise.uu) {
|
|
|
+ if (uuData) {
|
|
|
// 当前用户是管理员时
|
|
|
if ($scope.thisUser.sys) {
|
|
|
angular.forEach($scope.userinfos, function (item, i) {
|
|
|
@@ -2650,7 +2687,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
});
|
|
|
if (chooseResult.length > 0) {
|
|
|
$scope.loading = true;
|
|
|
- AccountUser.transferUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
|
|
|
+ AccountUser[urlSaveData]({uu: uuData}, chooseResult, function (data) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '提示', '保存成功');
|
|
|
$modalInstance.close(false);
|
|
|
@@ -2663,6 +2700,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
toaster.pop('error', '保存失败', "您未勾选任何记录");
|
|
|
}
|
|
|
} else {
|
|
|
+ if(type === 'sale') {
|
|
|
+ toaster.pop('info', '提示', "您没有权限转移对象");
|
|
|
+ return
|
|
|
+ }
|
|
|
// 非管理员转移自己的权限时
|
|
|
angular.forEach($scope.userinfos, function (item, i) {
|
|
|
if (item.transfer && item.userUU !== $scope.thisUser.userUU) {
|
|
|
@@ -2673,7 +2714,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
toaster.pop('error', '保存失败', "您未选择权限转移对象");
|
|
|
} else {
|
|
|
$scope.loading = true;
|
|
|
- AccountUser.transferMyDistribute({custUU: customer.myEnterprise.uu, userUU: $scope.target.userUU}, {} ,function (data) {
|
|
|
+ AccountUser.transferMyDistribute({custUU: uuData, userUU: $scope.target.userUU}, {} ,function (data) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '提示', '保存成功');
|
|
|
$modalInstance.close(false);
|
|
|
@@ -14591,6 +14632,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
resolve: {
|
|
|
customer: function () {
|
|
|
return customer;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'purchase'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -14694,7 +14738,125 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.purcByEn = function (businessCode) {
|
|
|
$rootScope.businessCode = businessCode;
|
|
|
window.location.hash = "#/purc/addOrder";
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 分配用户
|
|
|
+ $scope.addUserInfo = function (customer) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/add_userInfo.html',
|
|
|
+ controller: 'AddUserInfoCtrl',
|
|
|
+ resolve: {
|
|
|
+ customer: function () {
|
|
|
+ return customer;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'sale'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (changed, checked) {
|
|
|
+ if (changed) {
|
|
|
+ if (checked)
|
|
|
+ $scope.newUser.roles = checked;
|
|
|
+ else
|
|
|
+ loadUsers();
|
|
|
+ }
|
|
|
+ $scope.customerParams.reload();
|
|
|
+ });
|
|
|
+ // if (!$scope.enabled) {
|
|
|
+ // toaster.pop('error', '您没有为当前客户分配用户的权限!');
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // 获取当前用户在当前企业是否被转移权限
|
|
|
+ // AccountUser.getEnTransfer({custUU: customer.myEnterprise.uu}, function (data) {
|
|
|
+ // customer.enTransfer = data.result;
|
|
|
+ // //是管理员,或者被转移了权限时
|
|
|
+ // if ($scope.enabled || customer.enTransfer) {
|
|
|
+ // var modalInstance = $modal.open({
|
|
|
+ // animation: true,
|
|
|
+ // templateUrl: 'static/tpl/index/account/add_userInfo.html',
|
|
|
+ // controller: 'AddUserInfoCtrl',
|
|
|
+ // resolve: {
|
|
|
+ // customer: function () {
|
|
|
+ // return customer;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // modalInstance.result.then(function (changed, checked) {
|
|
|
+ // if (changed) {
|
|
|
+ // if (checked)
|
|
|
+ // $scope.newUser.roles = checked;
|
|
|
+ // else
|
|
|
+ // loadUsers();
|
|
|
+ // }
|
|
|
+ // $scope.customerParams.reload();
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // toaster.pop('error', '您没有为当前客户分配用户的权限!');
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 转移权限
|
|
|
+ $scope.transferUserInfo = function (customer) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
|
|
|
+ controller: 'TransferUserInfoCtrl',
|
|
|
+ resolve: {
|
|
|
+ customer: function () {
|
|
|
+ return customer;
|
|
|
+ },
|
|
|
+ type: function () {
|
|
|
+ return 'sale'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (changed, checked) {
|
|
|
+ if (changed) {
|
|
|
+ if (checked)
|
|
|
+ $scope.newUser.roles = checked;
|
|
|
+ else
|
|
|
+ loadUsers();
|
|
|
+ }
|
|
|
+ $scope.customerParams.reload();
|
|
|
+ });
|
|
|
+
|
|
|
+ // customer.enDistribute = null;
|
|
|
+ // if (!$scope.enabled) {
|
|
|
+ // toaster.pop('error', '您没有转移当前客户权限的权限!');
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // 获取当前用户在当前企业是否被转移权限
|
|
|
+ // AccountUser.getDistribute ({custUU: customer.myEnterprise.uu}, function(data) {
|
|
|
+ // customer.enDistribute = data.result;
|
|
|
+ // //是管理员,或者被分配时
|
|
|
+ // if ($scope.enabled || customer.enDistribute) {
|
|
|
+ // var modalInstance = $modal.open({
|
|
|
+ // animation: true,
|
|
|
+ // templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
|
|
|
+ // controller: 'TransferUserInfoCtrl',
|
|
|
+ // resolve: {
|
|
|
+ // customer: function () {
|
|
|
+ // return customer;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // modalInstance.result.then(function (changed, checked) {
|
|
|
+ // if (changed) {
|
|
|
+ // if (checked)
|
|
|
+ // $scope.newUser.roles = checked;
|
|
|
+ // else
|
|
|
+ // loadUsers();
|
|
|
+ // }
|
|
|
+ // $scope.customerParams.reload();
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // toaster.pop('error', '您没有转移当前客户权限的权限!');
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ };
|
|
|
|
|
|
}]);
|
|
|
|