Kaynağa Gözat

在账户设置内,添加客户分配功能,添加客户分配界面,配置js

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@2398 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
aof 10 yıl önce
ebeveyn
işleme
cbd0926295

+ 8 - 0
src/main/webapp/resources/css/index.css

@@ -2033,3 +2033,11 @@ input.ng-invalid.ng-dirty,textarea.ng-invalid.ng-dirty {
 #searchContainer  .form-group {
 	margin-bottom: 15px;
 }
+.warningLg {
+	line-height: 40px;
+    height: 40px;
+	font-family: "Microsoft YaHei", "Hiragino Sans GB";
+	font-weight: 700;
+	font-size: 17px;
+	color:red;
+}

+ 19 - 0
src/main/webapp/resources/js/common/services.js

@@ -221,6 +221,25 @@ define([ 'angular', 'toaster'], function(angular) {
 		};
 	}]).factory('AccountUser', ['$resource', function($resource) {
 		return $resource('account/user/:uu', {}, {
+			findVendor: {
+				url: 'account/user/findVendor/:uu',
+				method: 'GET',
+				isArray: true
+			},
+			findChooseVendor: {
+				url: 'account/user/removeVendor/:uu',
+				method: 'GET',
+				isArray: true
+			},
+			removeChooseVendor: {
+				url: 'account/user/removeVendor/:uu',
+				method: 'POST',
+				isArray: true
+			},
+			addVendor: {
+				url: 'account/user/addVendor/:uu',
+				method: 'POST'
+			},
 			update: {
 				method: 'PUT'
 			},

+ 179 - 3
src/main/webapp/resources/js/index/app.js

@@ -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){

+ 34 - 0
src/main/webapp/resources/tpl/index/account/add_vendor.html

@@ -0,0 +1,34 @@
+<div class="modal-header">
+	<h3 class="modal-title">
+		<i class="fa fa-user fa-fw text-default"></i>分配企业权限(添加客户)
+	</h3>
+</div>
+<div class="modal-body">
+	<div>
+		<table width="99%" class="block table table-bordered table-striped table-hover">
+		<thead>
+				<th width="40px;" style="text-align: center"><input type="checkbox" name="checkbox" ng-model="checkboxes.checked" ng-click="checkAll()"></th>
+				<th width="100px;">客户名称</th>
+				<th width="80px;">客户UU</th>
+		</thead>
+		<tbody>
+				<div style="overflow-y:scroll; width:100%;max-height:500px">			
+					<tr ng-repeat="vendor in enters">
+						<td width="40px;" style="text-align: center"><input ng-model="vendor.$selected" name="checkbox" ng-click="checkOne(vendor)" type="checkbox"></td>
+						<td width="100px;">{{vendor.myEnterprise.enName}}</td>
+						<td width="80px;">{{vendor.myEnterprise.uu}}</td>
+					</tr>
+					<div ng-if="enters.length == 0" class="warningLg">
+						此账号客户已全部被分配,请返回!
+					</div>	
+				</div>
+		<tbody>
+	</table>
+	</div>
+</div>
+<div class="modal-footer">
+	<span class="pull-left text-muted"><i
+		class="fa fa-fw fa-warning"></i>点击企业选中或取消</span>
+	<button class="btn btn-primary" ng-click="close(true)">确认并保存</button>
+	<button class="btn btn-default" ng-click="close(false)" type="button">取消</button>
+</div>

+ 34 - 0
src/main/webapp/resources/tpl/index/account/remove_vendor.html

@@ -0,0 +1,34 @@
+<div class="modal-header">
+	<h3 class="modal-title">
+		<i class="fa fa-user fa-fw text-default"></i>分配企业权限(删除客户)
+	</h3>
+</div>
+<div class="modal-body">
+	<div>
+		<table width="99%" class="block table table-bordered table-striped table-hover">
+		<thead>
+				<th width="40px;" style="text-align: center"><input type="checkbox" name="checkbox" ng-model="checkboxes.checked" ng-click="checkAll()"></th>
+				<th width="100px;">客户名称</th>
+				<th width="80px;">客户UU</th>
+		</thead>
+		<tbody>
+				<div style="overflow-y:scroll; width:100%;max-height:500px">
+					<tr ng-repeat="vendor in enters">
+						<td width="40px;" style="text-align: center"><input ng-model="vendor.$selected" name="checkbox" ng-click="checkOne(vendor)" type="checkbox"></td>
+						<td width="100px;">{{vendor.myEnterprise.enName}}</td>
+						<td width="80px;">{{vendor.myEnterprise.uu}}</td>
+					</tr>
+					<div ng-if="enters.length == 0" class="warningLg">
+						您未绑定任何客户,请返回!
+					</div>	
+				</div>
+		<tbody>
+	</table>
+	</div>
+</div>
+<div class="modal-footer">
+	<span class="pull-left text-muted"><i
+		class="fa fa-fw fa-warning"></i>点击企业选中或取消</span>
+	<button class="btn btn-primary" ng-click="close(true)">确认并删除</button>
+	<button class="btn btn-default" ng-click="close(false)" type="button">取消</button>
+</div>

+ 36 - 0
src/main/webapp/resources/tpl/index/account/user.html

@@ -58,6 +58,34 @@
 	transition: all 0s ease-in-out;
 }
 
+.row-operator2>.operator-menu3 {
+	position: absolute;
+	width: 125px;
+	height: 60;
+	line-height: 30px;
+	padding: 0 10px;
+	top: 30;
+	background-color: #333;
+	border-radius: 0 3px 3px 0;
+	opacity: 0;
+}
+
+.row-operator2>.operator-menu3 a {
+	color: #fff;
+}
+
+.row-operator2>.operator-menu3 a:hover {
+	color: #56a022;
+}
+
+.row-operator2:hover>.operator-menu3 {
+	z-index:100;
+	height: 40px;
+	opacity: .75;
+	-webkit-transition: all 0s ease-in-out;
+	-moz-transition: all 0s ease-in-out;
+	transition: all 0s ease-in-out;
+}
 </style>
 <div class="loading in" ng-class="{'in': loading}">
 	<i></i>
@@ -213,6 +241,7 @@
 						<th width="170">身份证号</th>
 						<th width="170">电话</th>
 						<th width="200">邮箱</th>
+						<th width="70">客户分配</th>
 						<th colspan="2">角色</th>
 					</tr>
 				</thead>
@@ -256,6 +285,13 @@
 						<td class="text-center" ng-bind="::u.userIdcode"></td>
 						<td class="text-center" ng-bind="::u.userTel"></td>
 						<td class="text-center" ng-bind="::u.userEmail"></td>
+						<td class="text-center row-operator2">
+							<a class="operator-trigger" href="javascript:void(0);" ng-click="addVendor(u)" style="color: green;"><i class="fa fa-plus-circle fa-lg"></i></a>
+							<ul class="list-unstyle list-inline operator-menu3">
+								<li><a ng-click="addVendor(u)"><i class="fa fa-fw fa-pencil-square-o"></i>添加</a></li>
+								<li><a ng-click="removeVendor(u)" ng-if="u.userUU != user.userUU"><i class="fa fa-fw fa-trash-o"></i>删除</a></li>
+							</ul>
+						</td>
 						<td class="user-role">
 							<div class="role-item" ng-repeat="role in u.roles"
 								title="{{role.desc}}">