Browse Source

【生成对账单方法优化,防止事务不一致】

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@4492 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
aof 10 years ago
parent
commit
e3698dbf39
1 changed files with 16 additions and 33 deletions
  1. 16 33
      src/main/webapp/resources/js/index/app.js

+ 16 - 33
src/main/webapp/resources/js/index/app.js

@@ -3806,12 +3806,12 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 		$scope.ifShow = true;
 		var loadData = function(){
 			FaApCheck.get({id:$stateParams.id},function(data){
-			$scope.data = data;
-			if($scope.data.status){
-				
-			}else{
-				$scope.ifShow = true;
-			}
+				$scope.data = data;
+				if($scope.data.status){
+					
+				}else{
+					$scope.ifShow = true;
+				}
 			})
 		}
 		
@@ -3842,21 +3842,18 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 		
 		//删除应收对账单的同时更新来源表已转数	
 		var updateYCheckQty = function(){
-		var sourceInfos = [];		
-
+			var sourceInfos = [];		
 			angular.forEach($scope.data.items, function(item){
 				$scope.sourceInfo = {
 						sourceId: '',
 						sourceTable: '',
 						newYCheckQty: ''
 					};	
-				
 				$scope.sourceInfo.sourceId = item.sourceId;
 				$scope.sourceInfo.sourceTable = item.sourceTable;
 				$scope.sourceInfo.newYCheckQty = item.oldYCheckQty;	
 				sourceInfos.push($scope.sourceInfo);
 			});
-			
 			FaApCheck.update({}, sourceInfos, function(){
 					
 			},function(response){
@@ -3880,7 +3877,6 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 
 		//作废应收对账单	
 		$scope.cancelApCheck = function(check) {
-			
 			FaApCheck.cancel({id:check.id},function(data){
 				$scope.checkResult = false;
 				if(data.result) {
@@ -3905,13 +3901,12 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 		$scope.loading = true;
 		$scope.getData = function(){
 		    FaApCheck.getAll(function(data){
-			$scope.data = data;
-			angular.forEach($scope.data, function(item) {
-					item:{
-						$selected:true;
-					}
-				});
-				
+				$scope.data = data;
+				angular.forEach($scope.data, function(item) {
+						item:{
+							$selected:true;
+						}
+					});
 				$scope.loading = false;
 			});
 
@@ -4168,17 +4163,6 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 			}
 		});
 			
-			
-		//修改来源表已转数
-		var updateYCheckQty = function(){
-			FaApCheck.update({}, sourceInfos, function(){
-
-			}),function(response){
-				$scope.loading = false;
-	  			toaster.pop('error', '更新已转数失败', response.data);
-			}
-		};
-			
 		//保存生成的应收对账单
 		$scope.saveApCheck = function(){
 			FaApCheck.saveApCheck({}, $scope.apCheck, function(data){
@@ -4186,16 +4170,15 @@ app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams'
 				toaster.pop('success', '成功', '生成应收对账成功');
 				$state.go('fa.apCheck_detail', {id: data.id}, {reload:true});					
 			}, function(response){
-				$scope.loading = false;
-				toaster.pop('error', '失败', '生成应收对账失败', response.data);
+				toaster.pop('error', '失败', '生成对账失败,请刷新界面');
 			})
 		};
 			
 		//如果是同一家客户,生成对账单的同时,关闭模态框
 		if($scope.sameCust && $scope.validQty) {
-			updateYCheckQty();
 			$scope.saveApCheck();
-			}
+		}
+		
 		}
 	}]);