Browse Source

批量发货

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@738 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
suntg 11 years ago
parent
commit
5d39fcdd47
1 changed files with 124 additions and 2 deletions
  1. 124 2
      src/main/webapp/resources/js/index/app.js

+ 124 - 2
src/main/webapp/resources/js/index/app.js

@@ -790,7 +790,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 			}
 			}
 		};
 		};
 	});
 	});
-	app.controller('SaleNoticeCtrl', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis){
+	app.controller('SaleNoticeCtrl', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $modal){
 		$scope.active = 'todo';
 		$scope.active = 'todo';
 		$scope.dateZoneText = '一个月内';
 		$scope.dateZoneText = '一个月内';
 		$scope.condition = {dateZone: 1};
 		$scope.condition = {dateZone: 1};
@@ -848,7 +848,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 				$scope.loading = true;
 				$scope.loading = true;
 				PurcNotice.save({id: notice.id}, send, function(){
 				PurcNotice.save({id: notice.id}, send, function(){
 					$scope.loading = false;
 					$scope.loading = false;
-					toaster.pop('info', '提示', '发货成功');
+					toaster.pop('success', '提示', '发货成功');
 					$scope.tableParams.reload();
 					$scope.tableParams.reload();
 				}, function(response){
 				}, function(response){
 					$scope.loading = false;
 					$scope.loading = false;
@@ -856,7 +856,129 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 				});
 				});
 			}
 			}
 		};
 		};
+		
+		$scope.checkboxes = {
+			checked : false
+		};
+
+		// 点击勾选全部的复选框
+		$scope.checkAll = function(){
+			angular.forEach($scope.tableParams.data, function(item) {
+				item.$selected = $scope.checkboxes.checked;
+			});
+		};
+		
+		// 点击其中一个明细的复选框
+		$scope.checkOne = function(order){
+			var result = true;
+			angular.forEach($scope.tableParams.data, function(item) {
+				if(item.$selected != true){
+					result = false;
+					return;
+				}
+			});
+			$scope.checkboxes.checked = result;
+		};
+		
+		$scope.sendByBatch = function(){
+			var modalInstance = $modal.open({
+				animation: true,
+				templateUrl: 'sendByBatch.html',
+				controller: 'SaleNoticeSendByBatchCtrl',
+				size: 'lg',
+				resolve: {
+					selectedNotices: function(){return $scope.tableParams.data;}
+				}
+			});
+			
+			modalInstance.result.then(function(){
+				$scope.tableParams.reload();
+			}, function(){
+				
+			});
+		};
+		
+		$scope.getSends = function(notice){
+			if( ! notice.sends){
+				PurcNotice.getSends({id: notice.id}, function(data){
+					notice.sends = data;
+				}, function(response){
+					
+				});
+			}
+		};
+		
+		
 	});
 	});
+	
+	app.controller('SaleNoticeSendByBatchCtrl', function($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster){
+		$scope.notices = selectedNotices;
+		$scope.currency = Symbol.currency;//将币别转化为对应的符号
+		$scope.saleSend = {
+			code: '',
+			payments: '',
+			currency: '',
+			custUU: '',
+			custUserUU: '',
+			remark: '平台批量发货',
+			sendItems: []
+			
+		};
+		
+		var getSelectedNotice = function(){
+			var selected = [];
+			angualr.forEach(selectedNotices, function(item){
+				if(item.$selected) {
+					
+				}
+			});
+		};
+		
+		//确认送货
+		$scope.sendByBatch = function () {
+			$scope.saleSend.sendItems = [];
+			if($scope.saleSend.code == '') {//送货单号为空
+				toaster.pop('error', '错误', '请输入送货单号');
+				return;
+			}
+			var a = 0;
+			var valid = true;
+			angular.forEach(selectedNotices, function(item){
+				if(item.$selected) {
+					if(a == 0) {//第一次
+						$scope.saleSend.custUserUU = item.orderItem.order.userUU;
+						$scope.saleSend.currency = item.orderItem.order.currency;
+						$scope.saleSend.custUU = item.enUU;
+						$scope.saleSend.payments = item.orderItem.order.payments;
+						a = 1;
+					} else {//其他
+						if($scope.saleSend.custUserUU != item.orderItem.order.userUU) valid = false;
+						if($scope.saleSend.currency != item.orderItem.order.currency) valid = false;
+						if($scope.saleSend.custUU != item.enUU) valid = false;
+						if($scope.saleSend.payments != item.orderItem.order.payments) valid = false;
+					}
+					$scope.saleSend.sendItems[$scope.saleSend.sendItems.length] = {
+						noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price
+					};
+				}
+			});
+			if(!valid) {
+				toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
+			} else {
+				PurcNotice.sendByBatch({}, $scope.saleSend, function(data){
+					toaster.pop('success', '提示', '批量发货成功。');
+					$modalInstance.close('success');
+				}, function(response){
+					toaster.pop('error', '错误', response.data);
+				});
+			}
+  		};
+
+  		$scope.cancel = function () {
+    		$modalInstance.dismiss();
+  		};
+	});
+	
 	/**
 	/**
 	 * 发货单
 	 * 发货单
 	 */
 	 */