Browse Source

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@1046 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 years ago
parent
commit
4e88fae302

+ 24 - 21
src/main/webapp/resources/js/index/app.js

@@ -260,6 +260,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 		});
 		});
 	});
 	});
 	app.controller('TruckCtrl', function($scope, $rootScope, $modal, SaleTruck){
 	app.controller('TruckCtrl', function($scope, $rootScope, $modal, SaleTruck){
+		
 		SaleTruck.query({}, function(data){
 		SaleTruck.query({}, function(data){
 			$rootScope.truck = data;
 			$rootScope.truck = data;
 			$scope.truckCount = data ? data.length : 0;
 			$scope.truckCount = data ? data.length : 0;
@@ -279,12 +280,13 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 				templateUrl: 'static/tpl/index/sale/track.html',
 				templateUrl: 'static/tpl/index/sale/track.html',
 				controller: 'TruckModalCtrl',
 				controller: 'TruckModalCtrl',
 				size: 'lg'
 				size: 'lg'
-			}).result.then(function(){
-				
+			}).result.then(function(s){
+				s && ($scope.clearAll());
 			});
 			});
 		};
 		};
 	});
 	});
-	app.controller('TruckModalCtrl', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice){
+	app.controller('TruckModalCtrl', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster){
+		$scope.saleSend = {sendItems: []};
 		SaleTruck.detail({}, function(data){
 		SaleTruck.detail({}, function(data){
 			$scope.notices = data;
 			$scope.notices = data;
 		});
 		});
@@ -298,32 +300,33 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 			$modalInstance.close();
 			$modalInstance.close();
 		};
 		};
 		$scope.send = function() {// 发货
 		$scope.send = function() {// 发货
-			$scope.saleSend.sendItems = [];
 			if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
 			if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
 				toaster.pop('error', '错误', '请输入送货单号');
 				toaster.pop('error', '错误', '请输入送货单号');
 				return;
 				return;
 			}
 			}
-			var a = 0;
-			var valid = true;
-			angular.forEach($scope.notices, function(item){
-				if(a == 0) {//第一次
-					$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.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;
+			var currency = $scope.notices[0].orderItem.order.currency,
+					custUU = $scope.notices[0].enUU,
+					payments = $scope.notices[0].orderItem.order.payments, valid = true, items = [];
+			for(var i in $scope.notices) {
+				var item = $scope.notices[i];
+				if(item.id) {
+					if(item.orderItem.order.currency != currency || item.enUU != custUU || item.orderItem.order.payments != payments) {
+						valid = false;
+						break;
+					}
+					items[i] = {noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price};
 				}
 				}
-				$scope.saleSend.sendItems[$scope.saleSend.sendItems.length] = {
-					noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price
-				};
-			});
+			}
 			if(!valid) {
 			if(!valid) {
 				toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
 				toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
 			} else {
 			} else {
-				PurcNotice.sendByBatch({}, $scope.saleSend, function(data){
+				var send = angular.extend(angular.copy($scope.saleSend), {
+					currency: currency,
+					custUU: custUU,
+					payments: payments,
+					sendItems: items
+				});
+				PurcNotice.sendByBatch({}, send, function(data){
 					toaster.pop('success', '提示', '发货成功。');
 					toaster.pop('success', '提示', '发货成功。');
 					$modalInstance.close(true);
 					$modalInstance.close(true);
 				}, function(response){
 				}, function(response){

+ 7 - 7
src/main/webapp/resources/tpl/index/sale/track.html

@@ -30,7 +30,7 @@
 			<th width="120">单价</th>
 			<th width="120">单价</th>
 			<th width="100">交货日期</th>
 			<th width="100">交货日期</th>
 			<th width="150">订单</th>
 			<th width="150">订单</th>
-			<th width="49">操作</th>
+			<th width="48">操作</th>
 			<th width="1"></th>
 			<th width="1"></th>
 		</tr>
 		</tr>
 	</table>
 	</table>
@@ -43,10 +43,10 @@
 					<div ng-bind="::notice.orderItem.product.title"></div>
 					<div ng-bind="::notice.orderItem.product.title"></div>
 					<div class="text-muted" ng-bind="::notice.orderItem.product.spec"></div>
 					<div class="text-muted" ng-bind="::notice.orderItem.product.spec"></div>
 				</td>
 				</td>
-				<td width="80">
+				<td width="80" class="text-center">
 					<div>
 					<div>
-						<span class="text-num" ng-bind="notice.qty-notice.endQty"></span>&nbsp;
-						<span ng-bind="notice.orderItem.product.unit"></span>
+						<span class="text-num" ng-bind="notice.qty-notice.endQty"></span><br>
+						<span ng-bind="::notice.orderItem.product.unit" class="text-muted"></span>
 					</div>
 					</div>
 				</td>
 				</td>
 				<td width="120"><input ng-model="notice.thisSendQty"
 				<td width="120"><input ng-model="notice.thisSendQty"
@@ -63,17 +63,17 @@
 				</td>
 				</td>
 				<td width="150">
 				<td width="150">
 					<div ng-bind="::notice.orderItem.order.code"></div>
 					<div ng-bind="::notice.orderItem.order.code"></div>
-					<div>
+					<div class="text-muted">
 						第 <span ng-bind="::notice.orderItem.number"></span> 行
 						第 <span ng-bind="::notice.orderItem.number"></span> 行
 					</div>
 					</div>
 				</td>
 				</td>
 				<td width="50" class="text-center"><a ng-click="remove($index, notice)"
 				<td width="50" class="text-center"><a ng-click="remove($index, notice)"
-					class="text-muted"><i class="fa fa-trash-o fa-2x"></i>取消</a></td>
+					class="text-muted"><i class="fa fa-trash-o fa-2x"></i><br>取消</a></td>
 			</tr>
 			</tr>
 		</table>
 		</table>
 	</div>
 	</div>
 </div>
 </div>
 <div class="modal-footer">
 <div class="modal-footer">
-	<button class="btn btn-primary" ng-click="send()" type="button">确认送货</button>
+	<button class="btn btn-primary" ng-click="send()" ng-disabled="!notices||notices.length==0" type="button">确认送货</button>
 	<button class="btn btn-default" ng-click="cancel()" type="button">取消</button>
 	<button class="btn btn-default" ng-click="cancel()" type="button">取消</button>
 </div>
 </div>