瀏覽代碼

客户资料-转移

yangc 8 年之前
父節點
當前提交
828e1205e7

+ 116 - 0
src/main/webapp/resources/js/common/b2bServices.js

@@ -690,5 +690,121 @@ define([ 'angular', 'common/services', 'common/utils', 'big'], function(angular,
         .factory('B2bCustomer', ['$resource', 'BaseService', function($resource, BaseService){
             var b2bPath = BaseService.getB2bUrl();
             return $resource(b2bPath + 'vendor/customer/info/search', {}, {});
+        }])
+        .factory('B2bAuthenticationService', ['$http', 'SessionService', 'BaseService', 'SerializerUtil', function($http, SessionService, BaseService, SerializerUtil) {
+            var cacheSession = function() {
+                SessionService.set('authenticated', true);
+            };
+            var uncacheSession = function() {
+                SessionService.unset('authenticated');
+            };
+            var rootPath = BaseService.getB2bUrl();
+            return {
+                root: function() {
+                    return rootPath;
+                },
+                logout: function() {
+                    var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
+                    if(keys) {
+                        for(var i = keys.length; i--;)
+                            document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString()
+                    }
+                    var config = {
+                        cache: false,
+                        headers: {
+                            'Cache-Control': 'no-cache',
+                            'Pragma': 'no-cache',
+                        },
+                        ifModified :true ,
+                    };
+                    var logout = $http.get(rootPath + "/logout", config);
+                    var refresh = function(data) {
+                        var pathName = document.location.pathname;
+                        var index = pathName.substr(1).indexOf("/");// platform-b2c/logout/proxy
+                        var result = pathName.substr(0,index);
+                        var uri = pathName.substr(13,index+1000) + document.location.hash;
+                        if (result == '/platform-b2b') {
+                            var contextPath = ''
+                            data.content = contextPath + uri;
+                        }
+                        if (data.content) {
+                            if (data.content == window.location.href) {
+                                window.location.reload();
+                            } else {
+                                window.location.href = data.content;
+                            }
+                        }
+                    }
+                    logout.success(uncacheSession);
+                    logout.success(function(data) {
+                        if (data.url) {
+                            $.ajax({
+                                url: data.url,
+                                type: "get",
+                                cache: false,
+                                dataType: "jsonp",
+                                jsonp: "callback",
+                                jsonpCallback: "successCallback",
+                                success: function (response) {
+                                    console.log(response);
+                                    refresh(data);
+                                },
+                                error: function (response) {
+                                    console.log(response);
+                                    refresh(data);
+                                }
+                            });
+                        } else {
+                            refresh(data);
+                        }
+                    });
+                    return logout;
+                },
+                redirectSignin: function() {
+                    $http.get(rootPath + '/login/page').success(function(data) {
+                        if (data.content) {
+                            window.location.href = data.content;
+                        } else {
+                            toaster.pop('error', '系统错误');
+                        }
+                    }).error(function() {
+                        toaster.pop('error', '系统错误');
+                    });
+                },
+                redirectRegister: function() {
+                    // 获取跳转注册的url
+                    $http.get(rootPath + '/register/page', {
+                        params: {
+                            returnUrl: window.location.href
+                        }
+                    }).success(function(data) {
+                        if (data.content) {
+                            window.location.href = data.content;
+                        } else {
+                            alert('系统错误');
+                        }
+                    }).error(function() {
+                        alert('系统错误');
+                    });
+                },
+                isAuthed: function() {
+                    return SessionService.get('authenticated');
+                },
+                getAuthentication: function() {
+                    var request = $http.get(rootPath + '/authentication', {cache: true});
+                    request.success(function(data) {
+                        if (data) {
+                            cacheSession();
+                        } else {
+                            uncacheSession();
+                        }
+                    });
+                    request.error(uncacheSession);
+                    return request;
+                },
+                reSignin: function(enUU) {
+                    return $http.get(rootPath + '/authentication/' + enUU);
+                }
+            };
         }]);
 });

+ 8 - 4
src/main/webapp/resources/js/vendor/controllers/b2b/sale/saleCustomerCtrl.js

@@ -194,7 +194,7 @@ define(['app/app'], function (app) {
         }
     }]);
     // 转移权限
-    app.register.controller('TransferUserInfoCtrl', ['$scope', '$rootScope', '$modalInstance', 'customer', 'B2bAccountUser', 'toaster', 'AuthenticationService', function ($scope, $rootScope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
+    app.register.controller('TransferUserInfoCtrl', ['$scope', '$rootScope', '$modalInstance', 'customer', 'B2bAccountUser', 'toaster', 'B2bAuthenticationService', function ($scope, $rootScope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
         AuthenticationService.getAuthentication().success(function (data) {
             $scope.loading = false;
             $scope.thisUser = data;
@@ -239,7 +239,7 @@ define(['app/app'], function (app) {
                         transfer.push({num: index});
                     }
                 } else {
-                    if (user.distribute) {
+                    if (user.transfer) {
                         transfer.push({num: index});
                     }
                 }
@@ -276,9 +276,13 @@ define(['app/app'], function (app) {
                 user.$checked = !user.$checked;
                 angular.forEach($scope.userinfos, function (userInfo) {
                     if (user.userUU !== userInfo.userUU) {
-                        userInfo.distribute = false;
+                        // userInfo.distribute = false;
+                        userInfo.checked = false;
+                        userInfo.transfer = false;
                     } else {
-                        userInfo.distribute = true;
+                        // userInfo.distribute = true;
+                        userInfo.checked = true;
+                        userInfo.transfer = true;
                     }
                 });
             }

+ 8 - 3
src/main/webapp/resources/view/vendor/b2b/modal/transfer_userInfo.html

@@ -37,10 +37,15 @@
 			</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">
+			<tr ng-repeat="user in userinfos| filter: keyword track by $index" 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>
+				<td width="40px;" style="text-align: center">
+					<label class="com-check-box">
+						<input ng-model="user.transfer" id="{{'user' + $index}}" name="checkbox" ng-click="checkOne(user)" ng-checked="user.checked" type="checkbox" title="选择">
+						<label for="{{'user' + $index}}"></label>
+					</label>
+				</td>
 			</tr>
 			</tbody>
 			<tbody ng-if="!thisUser.sys && thisUser.transfer">
@@ -63,7 +68,7 @@
 				<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="选择">
+						<input id="{{'user2' + $index}}" name="distribute" ng-click="checkOne(user)" ng-checked="user.checked" type="checkbox" title="选择">
 						<label for="{{'user2' + $index}}"></label>
 					</label>
 				</td>