|
|
@@ -763,7 +763,80 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.count = date;
|
|
|
});
|
|
|
}]);
|
|
|
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService', 'ngTableParams', 'toaster', function($scope, VendorService, BaseService, ngTableParams, toaster){
|
|
|
+ app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
|
|
|
+ $scope.userInfoResult = true;
|
|
|
+ AuthenticationService.getAuthentication().success(function(data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ $scope.thisUser = data;
|
|
|
+ });
|
|
|
+ var getCustInfos = function(custuu) {
|
|
|
+ if(custuu) {
|
|
|
+ VendorService.userInfo.query({uu:custuu},null,function(data) {
|
|
|
+ $scope.custInfos = data;
|
|
|
+ var getPage = function(page, size){
|
|
|
+ if($scope.custInfos) {
|
|
|
+ var result = {};
|
|
|
+ result.totalCount = $scope.custInfos.length;
|
|
|
+ result.content = $scope.custInfos.slice((page - 1)*size, page * size);
|
|
|
+ if($scope.custInfos.length % size == 0) {
|
|
|
+ result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
|
|
|
+ }else {
|
|
|
+ result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
|
|
|
+ }
|
|
|
+ result.first = page == 1;
|
|
|
+ result.last = page == result.totalPage;
|
|
|
+ result.page = page;
|
|
|
+ result.next = page - 0 + 1;
|
|
|
+ result.pre = page - 1;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.userdata = getPage(1,4);
|
|
|
+ $scope.first = function (){
|
|
|
+ $scope.userdata = getPage($scope.userdata.pre,4);
|
|
|
+ }
|
|
|
+ $scope.last = function (){
|
|
|
+ $scope.userdata = getPage($scope.userdata.next,4);
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.addUserInfo = function(customer) {
|
|
|
+ //TODO
|
|
|
+ if ($scope.thisUser.sys) {
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '您不是管理员,无权限分配用户!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.showUserInfo = function(customer,boo) {
|
|
|
+ $scope.custInfo = customer;
|
|
|
+ if(boo) {
|
|
|
+ getCustInfos(customer.myEnterprise.uu);
|
|
|
+ $scope.userInfoResult = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
$scope.customerParams = new ngTableParams({
|
|
|
page : 1,
|
|
|
count : 10
|
|
|
@@ -786,6 +859,61 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
}
|
|
|
});
|
|
|
}]);
|
|
|
+ app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
|
|
|
+ $scope.checkboxes = {
|
|
|
+ checked : false
|
|
|
+ };
|
|
|
+ $scope.loading = true;
|
|
|
+ AccountUser.findUsers({uu:customer.myEnterprise.uu},null,function(data) {
|
|
|
+ $scope.userinfos = data;
|
|
|
+ $scope.loading = false;
|
|
|
+ })
|
|
|
+ // 点击勾选全部的复选框
|
|
|
+ $scope.checkAll = function() {
|
|
|
+ angular.forEach($scope.userinfos, function(item) {
|
|
|
+ item.distribute = $scope.checkboxes.checked;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 点击其中一个明细的复选框
|
|
|
+ $scope.checkOne = function(vendor){
|
|
|
+ var result = true;
|
|
|
+ angular.forEach($scope.userinfos, function(item) {
|
|
|
+ if(item.distribute != true){
|
|
|
+ result = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.checkboxes.checked = result;
|
|
|
+ };
|
|
|
+ $scope.close = function(save) {
|
|
|
+ var chooseResult = [];
|
|
|
+ if(save) {
|
|
|
+ if(customer.myEnterprise.uu) {
|
|
|
+ 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) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '提示', '保存成功');
|
|
|
+ $modalInstance.close(false);
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ $modalInstance.close(false);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '保存失败', "您未勾选任何记录");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $modalInstance.close(true, $scope.checkboxes.checked);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $modalInstance.close(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }]);
|
|
|
var getState = function(active) {
|
|
|
var fn = 'get';
|
|
|
switch(active) {
|
|
|
@@ -800,7 +928,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
}
|
|
|
return fn;
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 改变单据日期范围
|
|
|
*/
|