|
|
@@ -3703,7 +3703,6 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
|
|
|
$scope.getData = function(){
|
|
|
$scope.data = FaApCheck.getAll(function(data){
|
|
|
$scope.data = data;
|
|
|
- console.log($scope.data);
|
|
|
angular.forEach($scope.data, function(item) {
|
|
|
item:{
|
|
|
$selected:true;
|
|
|
@@ -3746,7 +3745,6 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
|
|
|
$scope.condition.uuorname = $scope.suuorname;
|
|
|
$scope.condition.dateFrom = ($scope.sdateFrom || 0);
|
|
|
$scope.condition.dateTo = ($scope.sdateTo || 0);
|
|
|
- console.log($scope.condition.dateTo);
|
|
|
$scope.condition.venduuorname = $scope.vuuorname;
|
|
|
}
|
|
|
|
|
|
@@ -3762,7 +3760,6 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
|
|
|
$scope.checkAll = function(){
|
|
|
$scope.totalMoney = 0;
|
|
|
$scope.filteredData = $filter('filter')($scope.data,$scope.condition.uuorname,$scope.condition.venduuorname);
|
|
|
- console.log($scope.filteredData);
|
|
|
var uuorname = $scope.suuorname;
|
|
|
var dateFrom = $scope.sdateFrom;
|
|
|
var dateTo = $scope.sdateTo;
|
|
|
@@ -4324,6 +4321,185 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+ // 为用户分配角色(删除企业)
|
|
|
+ $scope.removeVendor = function(user) {
|
|
|
+ var resultRole = true;
|
|
|
+ angular.forEach(user.roles,function(role){
|
|
|
+ if(role.issys == 1) {
|
|
|
+ toaster.pop('error', '提示', '管理员无需分配客户');
|
|
|
+ resultRole = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(resultRole) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/remove_vendor.html',
|
|
|
+ controller: 'RemoveVendorCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function() {
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 为用户分配角色(添加企业)
|
|
|
+ $scope.addVendor = function(user) {
|
|
|
+ var resultRole = true;
|
|
|
+ angular.forEach(user.roles,function(role){
|
|
|
+ if(role.issys == 1) {
|
|
|
+ toaster.pop('error', '提示', '管理员无需分配客户');
|
|
|
+ resultRole = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(resultRole) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/add_vendor.html',
|
|
|
+ controller: 'AddVendorCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function() {
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(changed, checked){
|
|
|
+ if(changed) {
|
|
|
+ if(checked)
|
|
|
+ $scope.newUser.roles = checked;
|
|
|
+ else
|
|
|
+ loadUsers();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.controller('RemoveVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
|
|
|
+ $scope.checkboxes = {
|
|
|
+ checked : false
|
|
|
+ };
|
|
|
+ $scope.loading = true;
|
|
|
+ AccountUser.findChooseVendor({uu : user.userUU},function(data) {
|
|
|
+ $scope.enters = data;
|
|
|
+ $scope.loading = false;
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ item:{
|
|
|
+ $selected:true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ // 点击勾选全部的复选框
|
|
|
+ $scope.checkAll = function() {
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ item.$selected = $scope.checkboxes.checked;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 点击其中一个明细的复选框
|
|
|
+ $scope.checkOne = function(vendor){
|
|
|
+ var result = true;
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ if(item.$selected != true){
|
|
|
+ result = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.checkboxes.checked = result;
|
|
|
+ };
|
|
|
+ $scope.close = function(save) {
|
|
|
+ var chooseResult = [];
|
|
|
+ if(save) {
|
|
|
+ if(user.userUU) {
|
|
|
+ angular.forEach($scope.enters, function(item, i) {
|
|
|
+ if(item.$selected) {
|
|
|
+ chooseResult.push(item.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(chooseResult.length > 0) {
|
|
|
+ $scope.loading = true;
|
|
|
+ AccountUser.removeChooseVendor({uu : user.userUU }, 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);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+ app.controller('AddVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
|
|
|
+ $scope.checkboxes = {
|
|
|
+ checked : false
|
|
|
+ };
|
|
|
+ $scope.loading = true;
|
|
|
+ AccountUser.findVendor({uu : user.userUU},function(data) {
|
|
|
+ $scope.enters = data;
|
|
|
+ $scope.loading = false;
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ item:{
|
|
|
+ $selected:true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ // 点击勾选全部的复选框
|
|
|
+ $scope.checkAll = function() {
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ item.$selected = $scope.checkboxes.checked;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 点击其中一个明细的复选框
|
|
|
+ $scope.checkOne = function(vendor){
|
|
|
+ var result = true;
|
|
|
+ angular.forEach($scope.enters, function(item) {
|
|
|
+ if(item.$selected != true){
|
|
|
+ result = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.checkboxes.checked = result;
|
|
|
+ };
|
|
|
+ $scope.close = function(save) {
|
|
|
+ var chooseResult = [];
|
|
|
+ if(save) {
|
|
|
+ if(user.userUU) {
|
|
|
+ angular.forEach($scope.enters, function(item, i) {
|
|
|
+ if(item.$selected) {
|
|
|
+ chooseResult.push(item.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(chooseResult.length > 0) {
|
|
|
+ $scope.loading = true;
|
|
|
+ AccountUser.addVendor({uu : user.userUU }, 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);
|
|
|
+ }
|
|
|
+ };
|
|
|
}]);
|
|
|
|
|
|
app.controller('UserRoleCtrl', ['$scope', '$modalInstance', 'user', 'AccountRole', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountRole, AccountUser, toaster){
|