Browse Source

客户分配点击问题处理

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@9779 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 8 years ago
parent
commit
9100acf669

+ 17 - 29
src/main/webapp/resources/js/index/app.js

@@ -2025,7 +2025,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	}]);
 	
 	app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
-	    $scope.isChanged = false;
 		$scope.checkboxes = {
 				checked : false
 			};
@@ -2034,18 +2033,32 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			$scope.userinfos = data;
 			$scope.loading = false;
 		})
-
+		
+		$scope.isChanged = false;
 		$scope.changes = [];
-		var changed = {status: false, index: null};
 		// 点击勾选全部的复选框
 		$scope.checkAll = function() {
-			angular.forEach($scope.userinfos, function(item) {
+			angular.forEach($scope.userinfos, function(item, value) {
 				item.distribute = $scope.checkboxes.checked;
 			});
 		};
 		
 		// 点击其中一个明细的复选框
 		$scope.checkOne = function(vendor, isChanged, index){
+			if(isChanged) {
+				angular.forEach($scope.changes, function(item, value) {
+					if(item.num == index) {
+						$scope.changes.splice(value, 1);
+					}
+				}) ;
+			} else {
+				$scope.changes.push({num: index});
+			}
+			if($scope.changes.length != 0) {
+				$scope.isChanged = true;
+			} else {
+				$scope.isChanged = false;
+			}
 			var result = true;
 			angular.forEach($scope.userinfos, function(item) {
 				if(item.distribute != true){
@@ -2054,31 +2067,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				}
 			});
 			$scope.checkboxes.checked = result;
-			if($scope.changes.length == 0) {
-				changed = {
-						status: !isChanged,
-						index: index
-				}
-				$scope.changes.push(changed);
-				 $scope.isChanged = !isChanged;
-			} else {
-				angular.forEach($scope.changes, function(changed) {
-					if(changed.index = index) {
-						changed.status = !isChanged;
-					}
-				});
-			}
-			angular.forEach($scope.changes, function(changed) {
-				if(changed.index != index) {
-					if(changed.status) {
-						$scope.isChanged = true;
-					}
-					console.log($scope.isChanged);
-					if(!$scope.isChanged) {
-						$scope.isChanged = !isChanged;
-					}
-				}
-			});
 		};
 		$scope.close = function(save) {
 			var chooseResult = [];

+ 1 - 1
src/main/webapp/resources/tpl/index/account/add_userInfo.html

@@ -32,7 +32,7 @@
 		<thead>
 			<th width="80px;">用户UU</th>
 			<th width="100px;">用户名称</th>
-			<th width="40px;" style="text-align: center"><input type="checkbox" name="checkbox" ng-model="checkboxes.checked" ng-click="checkAll()"></th>
+			<th width="40px;" style="text-align: center"><input type="checkbox" name="checkbox" ng-model="checkboxes.checked" ng-click="checkAll();isChanged = !isChanged" ng-show="false"></th>
 		</thead>
 		<tbody>
 				<div style="overflow-y:scroll; width:100%;max-height:500px">