|
|
@@ -35,6 +35,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
"right-view" : {
|
|
|
templateUrl : "static/tpl/index/sale/right.html"
|
|
|
}
|
|
|
+ },
|
|
|
+ controller: function($scope) {
|
|
|
+ $scope.truck = [];
|
|
|
}
|
|
|
}).state('sale.index', {
|
|
|
url : "",
|
|
|
@@ -256,11 +259,78 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.todo = data;
|
|
|
});
|
|
|
});
|
|
|
- app.controller('TruckCtrl', function($scope, $rootScope, SaleTruck){
|
|
|
+ app.controller('TruckCtrl', function($scope, $rootScope, $modal, SaleTruck){
|
|
|
SaleTruck.query({}, function(data){
|
|
|
$rootScope.truck = data;
|
|
|
$scope.truckCount = data ? data.length : 0;
|
|
|
});
|
|
|
+ $scope.$watch(function(){
|
|
|
+ return $rootScope.truck;
|
|
|
+ }, function(data) {
|
|
|
+ $scope.truckCount = data ? data.length : 0;
|
|
|
+ }, true);
|
|
|
+ $scope.clearAll = function() {
|
|
|
+ SaleTruck.remove({}, function(){
|
|
|
+ $rootScope.truck = [];
|
|
|
+ });
|
|
|
+ };
|
|
|
+ $scope.openTrack = function() {
|
|
|
+ $modal.open({
|
|
|
+ templateUrl: 'static/tpl/index/sale/track.html',
|
|
|
+ controller: 'TruckModalCtrl',
|
|
|
+ size: 'lg'
|
|
|
+ }).result.then(function(){
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+ });
|
|
|
+ app.controller('TruckModalCtrl', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice){
|
|
|
+ SaleTruck.detail({}, function(data){
|
|
|
+ $scope.notices = data;
|
|
|
+ });
|
|
|
+ $scope.remove = function(index, notice) {
|
|
|
+ SaleTruck.remove({noticeId: notice.id}, function(data){
|
|
|
+ $rootScope.truck = data;
|
|
|
+ $scope.notices.splice(index, 1);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ $scope.cancel = function() {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ $scope.send = function() {// 发货
|
|
|
+ $scope.saleSend.sendItems = [];
|
|
|
+ if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
|
|
|
+ toaster.pop('error', '错误', '请输入送货单号');
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ $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(true);
|
|
|
+ }, function(response){
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
});
|
|
|
app.controller('PersonalSaleStatCtrl', function($scope, SaleStat) {
|
|
|
SaleStat.cust({}, function(data){
|
|
|
@@ -1202,23 +1272,27 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
var truck = $rootScope.truck;
|
|
|
if(!truck) {
|
|
|
SaleTruck.query({}, function(data){
|
|
|
- truck = $rootScope.truck = data;
|
|
|
+ $rootScope.truck = data;
|
|
|
});
|
|
|
}
|
|
|
$scope.isInTruck = function(noticeId) {
|
|
|
return truck.indexOf(noticeId) > -1;
|
|
|
};
|
|
|
- $scope.addtoTruck = function(noticeId) {
|
|
|
- SaleTruck.save({noticeId: noticeId}, {}, function(){
|
|
|
-
|
|
|
+ $scope.addtoTruck = function(notice) {
|
|
|
+ SaleTruck.save({noticeId: notice.id}, {}, function(data){
|
|
|
+ $rootScope.truck = data;
|
|
|
});
|
|
|
};
|
|
|
- $scope.delFromTruck = function(noticeId) {
|
|
|
- SaleTruck.remove({}, {noticeId: noticeId}, function(){
|
|
|
-
|
|
|
+ $scope.delFromTruck = function(notice) {
|
|
|
+ SaleTruck.remove({noticeId: notice.id}, {}, function(data){
|
|
|
+ $rootScope.truck = data;
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+ $scope.$watch(function(){
|
|
|
+ return $rootScope.truck;
|
|
|
+ }, function(data) {
|
|
|
+ truck = $rootScope.truck;
|
|
|
+ }, true);
|
|
|
});
|
|
|
app.controller('SaleNoticeSendByBatchCtrl', function($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster){
|
|
|
$scope.notices = angular.copy(selectedNotices);
|