Browse Source

客户资料分配转移

yangc 8 years ago
parent
commit
c3b78b6fd0

+ 54 - 0
src/main/webapp/resources/css/b2bCommon.css

@@ -117,4 +117,58 @@
     padding-bottom: 18px;
     border-top: 1px solid #e3e3e3;
     text-align: center;
+}
+
+.b2b-operate-modal .form-group {
+    font-size: 0;
+}
+.b2b-operate-modal .form-group >div {
+    padding: 0 30px;
+}
+.b2b-operate-modal .form-group input {
+    width: 354px;
+    height: 34px;
+    border: 1px solid #ccc;
+    font-size: 12px;
+    display: inline-block;
+}
+.b2b-operate-modal .form-group .input-group-addon {
+    width: 76px;
+    height: 34px;
+    display: inline-block;
+    line-height: 34px;
+    padding: 0;
+    background: #5078cb;
+    color: #fff;
+    font-size: 14px;
+}
+.b2b-operate-modal #user-lists {
+    padding: 0 30px;
+}
+.b2b-operate-modal #user-lists table thead tr {
+    height: 34px;
+    line-height: 34px;
+    padding: 0;
+    background: #89aefa;
+}
+.b2b-operate-modal #user-lists table thead tr th {
+    color: #fff;
+    font-weight: normal;
+    font-size: 14px;
+    text-align: center;
+}
+.b2b-operate-modal #user-lists table tbody tr {
+    height: 40px;
+    line-height: 40px;
+    text-align: center;
+    border-left: 1px solid #ecf0fb;
+    border-right: 1px solid #ecf0fb;
+    border-bottom: 1px solid #ecf0fb;
+}
+.b2b-operate-modal #user-lists table tbody tr:hover {
+    background: #f9fafd;
+}
+.b2b-operate-modal #user-lists table tbody tr td {
+    font-size: 14px;
+    border: none;
 }

+ 84 - 0
src/main/webapp/resources/js/common/controllers/commonCtrls.js

@@ -1934,7 +1934,91 @@ define([ 'app/app' ], function(app) {
 			$modalInstance.dismiss('cancel');
 		}
 	}]);
+	/*
+	 * b2b新增分配人员
+	 * */
+	app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function ($scope, $modalInstance, customer, AccountUser, toaster) {
+		$scope.checkboxes = {
+			checked: false
+		};
+		$scope.loading = true;
+		$scope.distribute = [];
+		AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
+			$scope.userinfos = data;
+			var distribute = [];
+			angular.forEach($scope.userinfos, function (user, index) {
+				if (user.distribute) {
+					distribute.push({num: index});
+				}
+			});
+			$scope.distribute = distribute;
+			$scope.havedone = angular.copy($scope.distribute);
+			$scope.loading = false;
+		})
+
+		var checkStatus = function (userinfos) {
+			var distribute = [];
+			angular.forEach(userinfos, function (user, index) {
+				if (user.distribute) {
+					distribute.push({num: index});
+				}
+			});
+			$scope.distribute = distribute;
+			$scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
+		}
+		$scope.isChanged = false;
+		$scope.isChangedAll = false;
+		$scope.changes = [];
+		// 点击勾选全部的复选框
+		$scope.checkAll = function () {
+			angular.forEach($scope.userinfos, function (item, index) {
+				item.distribute = $scope.checkboxes.checked;
+			});
+			checkStatus($scope.userinfos);
+		};
+
+		// 点击其中一个明细的复选框
+		$scope.checkOne = function () {
+			var result = true;
+			angular.forEach($scope.userinfos, function (item) {
+				if (item.distribute != true) {
+					result = false;
+					return;
+				}
+			});
+			$scope.checkboxes.checked = result;
+			checkStatus($scope.userinfos);
+		};
+		$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 getOriginalData = function(data) {
 		var result = {};
 		if(data&&data.length) {

+ 148 - 2
src/main/webapp/resources/js/vendor/controllers/b2b/sale/saleCustomerCtrl.js

@@ -65,7 +65,7 @@ define(['app/app'], function (app) {
                 if ($scope.enabled || customer.enTransfer) {
                     var modalInstance = $modal.open({
                         animation: true,
-                        templateUrl: 'static/tpl/index/account/add_userInfo.html',
+                        templateUrl: 'static/view/vendor/b2b/modal/add_userInfo.html',
                         controller: 'AddUserInfoCtrl',
                         resolve: {
                             customer: function () {
@@ -102,7 +102,7 @@ define(['app/app'], function (app) {
                 if ($scope.enabled || customer.enDistribute) {
                     var modalInstance = $modal.open({
                         animation: true,
-                        templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
+                        templateUrl: 'static/view/vendor/b2b/modal/transfer_userInfo.html',
                         controller: 'TransferUserInfoCtrl',
                         resolve: {
                             customer: function () {
@@ -193,4 +193,150 @@ define(['app/app'], function (app) {
             });
         }
     }]);
+    // 转移权限
+    app.register.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
+        AuthenticationService.getAuthentication().success(function (data) {
+            $scope.loading = false;
+            $scope.thisUser = data;
+        });
+        $scope.checkboxes = {
+            checked: false
+        };
+        $scope.loading = true;
+        $scope.transfer = [];
+        AccountUser.findUsers({uu: customer.myEnterprise.uu}, {}, function (data) {
+            $scope.userinfos = data;
+            var transfer = [];
+            angular.forEach($scope.userinfos, function (user, index) {
+                // 当前用户是被管理员转移权限时,转移的是被管理员转移的权限。
+                if ($scope.thisUser.userUU === user.userUU && user.transfer) {
+                    $scope.thisUser.transfer = true;
+                }
+            });
+            angular.forEach($scope.userinfos, function (user, index) {
+                if ($scope.thisUser.sys || $scope.thisUser.transfer) {
+                    if (user.transfer) {
+                        transfer.push({num: index});
+                        user.checked = true;
+                    }
+                } else {
+                    if (user.distribute) {
+                        transfer.push({num: index});
+                        user.checked = true;
+                    }
+                }
+            });
+            $scope.transfer = transfer;
+            $scope.havedone = angular.copy($scope.transfer);
+            $scope.loading = false;
+        });
+
+        var checkStatus = function (userinfos) {
+            var transfer = [];
+            angular.forEach(userinfos, function (user, index) {
+                if ($scope.thisUser.sys || $scope.thisUser.transfer) {
+                    if (user.transfer) {
+                        transfer.push({num: index});
+                    }
+                } else {
+                    if (user.distribute) {
+                        transfer.push({num: index});
+                    }
+                }
+            });
+            $scope.transfer = transfer;
+            $scope.isChanged = !angular.equals($scope.havedone, $scope.transfer);
+        };
+        $scope.isChanged = false;
+        $scope.isChangedAll = false;
+        $scope.changes = [];
+        // 点击其中一个明细的复选框
+        $scope.checkOne = function (user) {
+            $scope.changes = [];
+            if ($scope.thisUser.sys) { // 管理员操作
+                user.$checked = !user.$checked;
+                angular.forEach($scope.userinfos, function (userInfo) {
+                    if ($scope.thisUser.userUU === user.userUU && user.transfer) {
+                        $scope.thisUser.transfer = true;
+                    }
+                    if (user.userUU !== userInfo.userUU) {
+                        userInfo.transfer = false;
+                    }
+                });
+            } else if ($scope.thisUser.transfer) { // 被管理员转移权限的非管理员操作
+                user.$checked = !user.$checked;
+                angular.forEach($scope.userinfos, function (userInfo) {
+                    if (user.userUU !== userInfo.userUU) {
+                        userInfo.transfer = false;
+                    } else {
+                        userInfo.transfer = true;
+                    }
+                });
+            } else { // 被分配客户的用户
+                user.$checked = !user.$checked;
+                angular.forEach($scope.userinfos, function (userInfo) {
+                    if (user.userUU !== userInfo.userUU) {
+                        userInfo.distribute = false;
+                    } else {
+                        userInfo.distribute = true;
+                    }
+                });
+            }
+            checkStatus($scope.userinfos);
+        };
+        $scope.close = function (save) {
+            var chooseResult = [];
+            if (save) {
+                if (customer.myEnterprise.uu) {
+                    // 当前用户是管理员时
+                    if ($scope.thisUser.sys) {
+                        angular.forEach($scope.userinfos, function (item, i) {
+                            chooseResult.push(item);
+                        });
+                        if (chooseResult.length > 0) {
+                            $scope.loading = true;
+                            AccountUser.transferUserToVendor({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 {
+                        // 非管理员转移自己的权限时
+                        angular.forEach($scope.userinfos, function (item, i) {
+                            if (item.transfer && item.userUU !== $scope.thisUser.userUU) {
+                                $scope.target = item;
+                            }
+                        });
+                        if (!$scope.target) {
+                            toaster.pop('error', '保存失败', "您未选择权限转移对象");
+                        } else {
+                            $scope.loading = true;
+                            AccountUser.transferMyDistribute({custUU: customer.myEnterprise.uu, userUU: $scope.target.userUU}, {} ,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 {
+                    $modalInstance.close(true, $scope.checkboxes.checked);
+                }
+            } else {
+                $modalInstance.close(false);
+            }
+        };
+
+    }]);
+
 });

+ 0 - 85
src/main/webapp/resources/js/vendor/controllers/b2b/sale/saleCustomerDetailCtrl.js

@@ -211,89 +211,4 @@ define(['app/app'], function (app) {
             $modalInstance.dismiss();
         }
     }]);
-    /*
-    * 新增分配人员
-    * */
-    app.register.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function ($scope, $modalInstance, customer, AccountUser, toaster) {
-        $scope.checkboxes = {
-            checked: false
-        };
-        $scope.loading = true;
-        $scope.distribute = [];
-        AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
-            $scope.userinfos = data;
-            var distribute = [];
-            angular.forEach($scope.userinfos, function (user, index) {
-                if (user.distribute) {
-                    distribute.push({num: index});
-                }
-            });
-            $scope.distribute = distribute;
-            $scope.havedone = angular.copy($scope.distribute);
-            $scope.loading = false;
-        })
-
-        var checkStatus = function (userinfos) {
-            var distribute = [];
-            angular.forEach(userinfos, function (user, index) {
-                if (user.distribute) {
-                    distribute.push({num: index});
-                }
-            });
-            $scope.distribute = distribute;
-            $scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
-        }
-        $scope.isChanged = false;
-        $scope.isChangedAll = false;
-        $scope.changes = [];
-        // 点击勾选全部的复选框
-        $scope.checkAll = function () {
-            angular.forEach($scope.userinfos, function (item, index) {
-                item.distribute = $scope.checkboxes.checked;
-            });
-            checkStatus($scope.userinfos);
-        };
-
-        // 点击其中一个明细的复选框
-        $scope.checkOne = function () {
-            var result = true;
-            angular.forEach($scope.userinfos, function (item) {
-                if (item.distribute != true) {
-                    result = false;
-                    return;
-                }
-            });
-            $scope.checkboxes.checked = result;
-            checkStatus($scope.userinfos);
-        };
-        $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);
-            }
-        };
-
-    }]);
 });

+ 1 - 51
src/main/webapp/resources/view/vendor/b2b/modal/add_userInfo.html

@@ -17,58 +17,8 @@
 			max-height: 400px;
 		}
 	}
-	.add-user-modal .form-group {
-		font-size: 0;
-	}
-	.add-user-modal .form-group >div {
-		padding: 0 30px;
-	}
-	.add-user-modal .form-group input {
-		width: 354px;
-		height: 34px;
-		border: 1px solid #ccc;
-		font-size: 12px;
-		display: inline-block;
-	}
-	.add-user-modal .form-group .input-group-addon {
-		width: 76px;
-		height: 34px;
-		display: inline-block;
-		line-height: 34px;
-		padding: 0;
-		background: #5078cb;
-		color: #fff;
-		font-size: 14px;
-	}
-	.add-user-modal #user-lists {
-		padding: 0 30px;
-	}
-	.add-user-modal #user-lists table thead tr {
-		height: 34px;
-		line-height: 34px;
-		padding: 0;
-		background: #89aefa;
-	}
-	.add-user-modal #user-lists table thead tr th {
-		color: #fff;
-		font-weight: normal;
-		font-size: 14px;
-		text-align: center;
-	}
-	.add-user-modal #user-lists table tbody tr {
-		height: 40px;
-		line-height: 40px;
-		text-align: center;
-		border-left: 1px solid #ecf0fb;
-		border-right: 1px solid #ecf0fb;
-		border-bottom: 1px solid #ecf0fb;
-	}
-	.add-user-modal #user-lists table tbody tr td {
-		font-size: 14px;
-		border: none;
-	}
 </style>
-<div class="b2b-com-modal add-user-modal">
+<div class="b2b-com-modal b2b-operate-modal">
 	<p class="title">
 		客户分配 <i class="fa fa-close" ng-click="close(false)"></i>
 	</p>

+ 78 - 0
src/main/webapp/resources/view/vendor/b2b/modal/transfer_userInfo.html

@@ -0,0 +1,78 @@
+<style>
+	.modal-content {
+		width: 492px;
+	}
+	#user-lists{
+		max-height: 600px;
+		overflow-x: hidden;
+		overflow-y: scroll;
+	}
+	@media screen and (max-width: 1366px){
+		#user-lists{
+			max-height: 368px;
+		}
+	}
+	@media screen and (max-width: 1600px){
+		#user-lists{
+			max-height: 400px;
+		}
+	}
+</style>
+<div class="b2b-com-modal b2b-operate-modal">
+	<p class="title">
+		权限转移 <i class="fa fa-close" ng-click="close(false)"></i>
+	</p>
+	<div class="form-group" id="window-search" style="height: 36px; margin-bottom: 0; margin-top: 16px;padding-bottom: 45px;border-bottom: 1px solid #e3e3e3;">
+		<div class="col-sm-12">
+			<input type="text" class="form-control input-sm" required="" placeholder="输入用户名关键词搜索" autofocus="" ng-model="keyword" ng-search="onSearch(keyword)" />
+			<a class="btn input-group-addon" ng-click="onSearch()">搜索</a>
+		</div>
+	</div>
+	<div class="modal-body" id="user-lists">
+		<table class="table">
+			<thead>
+			<th width="80px;">用户UU</th>
+			<th width="100px;">用户名称</th>
+			<th width="40px;"></th>
+			</thead>
+			<tbody ng-if="thisUser.sys">
+			<!-- 当前用户是管理员时 -->
+			<tr ng-repeat="user in userinfos| filter: keyword" style="overflow-y:scroll; width:100%;max-height:500px" ng-if="!user.sys">
+				<td width="80px;">{{user.userUU}}</td>
+				<td width="100px;">{{user.userName}}</td>
+				<td width="40px;" style="text-align: center"><input ng-model="user.transfer" name="checkbox" ng-click="checkOne(user)" ng-checked="user.checked" type="checkbox" title="选择"></td>
+			</tr>
+			</tbody>
+			<tbody ng-if="!thisUser.sys && thisUser.transfer">
+			<!-- 当前用户是被管理员转移权限时 -->
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="!user.sys">
+				<td width="80px;">{{user.userUU}}</td>
+				<td width="100px;">{{user.userName}}</td>
+				<td width="40px;" style="text-align: center">
+					<label class="com-check-box">
+						<input ng-model="user.transfer" id="{{'user1' + $index}}" name="checkbox" ng-click="checkOne(user)" ng-checked="user.checked" type="checkbox" title="选择">
+						<label for="{{'user1' + $index}}"></label>
+					</label>
+				</td>
+			</tr>
+			</tbody>
+			<tbody ng-if="!thisUser.sys && !thisUser.transfer">
+			<!-- 当前用户是非管理员,但有查看权限时 -->
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" ng-if="!user.distribute && !user.sys">
+				<td width="80px;">{{user.userUU}}</td>
+				<td width="100px;">{{user.userName}}</td>
+				<td width="40px;" style="text-align: center">
+					<label class="com-check-box">
+						<input ng-model="user.distribute" id="{{'user2' + $index}}" name="distribute" ng-click="checkOne(user)" ng-checked="user.checked" type="checkbox" title="选择">
+						<label for="{{'user2' + $index}}"></label>
+					</label>
+				</td>
+			</tr>
+			</tbody>
+		</table>
+	</div>
+	<div class="operate">
+		<button class="b2b-btn b2b-btn-submit" ng-click="close(true)" ng-disabled="!isChanged">确认</button>
+		<button class="b2b-btn b2b-btn-cancel" ng-click="close(false)" type="button">取消</button>
+	</div>
+</div>