|
@@ -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){
|