Browse Source

解决合并配送规则需求的冲突

hulh 8 years ago
parent
commit
3efa35c0ed

+ 45 - 50
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_index_ctrl.js

@@ -4,7 +4,7 @@
  */
 define(['app/app', 'calendar'], function(app) {
     'use strict';
-    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter','$modal', function($scope, toaster, VendorService, $rootScope, News, $filter,$modal) {
+    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', '$modal', 'DistributionRule', '$q', function($scope, toaster, VendorService, $rootScope, News, $filter, $modal, DistributionRule, $q) {
         $rootScope.active = 'index';
         $scope.userInfo = $rootScope.userInfo;
         //个人账户
@@ -41,37 +41,6 @@ define(['app/app', 'calendar'], function(app) {
         //
         // });
 
-      //安全设置提醒框
-      $scope.openHomeCenterModel = function() {
-        var modalInstance = $modal.open({
-          animation: true,
-          templateUrl: $rootScope.rootPath + '/static/view/usercenter/modal/homeCenter_modal.html',
-          controller:'homeModalCtrl'
-        });
-        modalInstance.result.then(function(){
-        }, function(){
-        });
-      }
-
-      //安全级别
-      if(!($scope.userInfo.pwdEnable && $scope.userInfo.haveUserQuestion && ($scope.userInfo.userEmail==null?false:true))){
-        $scope.openHomeCenterModel();
-      }
-
-    }]);
-
-  app.register.controller('homeModalCtrl', ['$scope',  '$modalInstance', 'toaster', '$http', 'ShippingAddress','$state', function($scope, $modalInstance, toaster, $http, ShippingAddress,$state){
-    console.info($scope.userInfo);
-    $scope.goLink = function(op){
-      $state.go('vendor_account_management',{op:op});
-      $modalInstance.dismiss('cancel');
-    }
-
-    $scope.cancel = function (){
-      $modalInstance.dismiss('cancel');
-    }
-  }]);
-
         var initRuleCount = function () {
             return DistributionRule.findCountOfActiveRule({},{},function (data) {
                 if (data.success){
@@ -81,29 +50,55 @@ define(['app/app', 'calendar'], function(app) {
                 toaster.pop("error", error.data);
             })
         };
-        initRuleCount();
 
-        $q.all([initRuleCount().$promise]).then(function (data) {
-            if (data){
-                if ($scope.needShowTip){
-                    $modal.open({
-                        animation: true,
-                        templateUrl: 'static/view/common/modal/delivery_rule_modal.html',
-                        controller: 'rule_tip_ctrl',
-                        resolve : {
-                            type : function() {
-                                return 'center';
-                            },
-                            tipModal : function() {
-                                return true;
+        //安全设置提醒框
+        $scope.openHomeCenterModel = function() {
+            var modalInstance = $modal.open({
+              animation: true,
+              templateUrl: $rootScope.rootPath + '/static/view/usercenter/modal/homeCenter_modal.html',
+              controller:'homeModalCtrl'
+            });
+            modalInstance.result.then(function(){
+            }, function(){
+            });
+        }
+
+        //安全级别
+        if(!($scope.userInfo.pwdEnable && $scope.userInfo.haveUserQuestion && ($scope.userInfo.userEmail==null?false:true))){
+            $scope.openHomeCenterModel();
+        } else {
+            $q.all([initRuleCount().$promise]).then(function (data) {
+                if (data){
+                    if ($scope.needShowTip){
+                        $modal.open({
+                            animation: true,
+                            templateUrl: 'static/view/common/modal/delivery_rule_modal.html',
+                            controller: 'rule_tip_ctrl',
+                            resolve : {
+                                type : function() {
+                                    return 'center';
+                                },
+                                tipModal : function() {
+                                    return true;
+                                }
                             }
-                        }
-                    });
+                        });
+                    }
                 }
-            }
-        });
+            });
+        }
 
     }]);
 
+    app.register.controller('homeModalCtrl', ['$scope',  '$modalInstance', 'toaster', '$http', 'ShippingAddress','$state', function($scope, $modalInstance, toaster, $http, ShippingAddress,$state){
+        console.info($scope.userInfo);
+        $scope.goLink = function(op) {
+            $state.go('vendor_account_management',{op:op});
+            $modalInstance.dismiss('cancel');
+        }
 
+        $scope.cancel = function () {
+            $modalInstance.dismiss('cancel');
+        }
+    }]);
 });

+ 7 - 18
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -4,7 +4,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		$rootScope.active = 'vendor_material';
 		document.title = '卖家产品库-优软商城';
 		$scope.tab = 'material';
-		$scope.standard_tab = $stateParams.standardParam?$stateParams.standardParam:'standard';
+		$scope.standard_tab = $stateParams.standardParam ? $stateParams.standardParam : 'standard';
 		$scope.choosedIds = [];
 		$scope.deleteDiv = false;
 
@@ -539,23 +539,6 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		function publishGoods(product) {
 			if (!validateGoods($scope.goods)) return ;
 
-			$scope.goods.breakUp = 1 === $scope.goods.breakUp;
-			$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
-			if (product.sourceApp == 'ERP') {
-				if ($scope.goods.erpReserve < $scope.goods.b2cReserve + $scope.goods.reserve) {
-					toaster.pop('error', '本次上架数量和已上架数量之和不可超过ERP空闲库存数量');
-					return;
-				}
-			}
-			Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
-				if (result.success) {
-					toaster.pop('success', '商品上架成功');
-					closeShelArea(product);
-				} else {
-					toaster.pop('error', result.message);
-				}
-			}, function (error) {
-				toaster.pop('error', error.data);
 			$q.all([initRuleCount().$promise]).then(function (data) {
 				if (data){
 					if ($scope.needShowTip){
@@ -575,6 +558,12 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 					}
 					$scope.goods.breakUp = 1 === $scope.goods.breakUp;
 					$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
+					if (product.sourceApp == 'ERP') {
+						if ($scope.goods.erpReserve < $scope.goods.b2cReserve + $scope.goods.reserve) {
+							toaster.pop('error', '本次上架数量和已上架数量之和不可超过ERP空闲库存数量');
+							return;
+						}
+					}
 					Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
 						if (result.success) {
 							toaster.pop('success', '商品上架成功');

+ 2 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js

@@ -265,7 +265,8 @@ define([ 'app/app' ], function(app) {
 						});
 						return ;
 					}
-					toaster.pop("success", "提示", "发布成功 :" + data.data + "条");
+					// toaster.pop("success", "提示", "发布成功 :" + data.data + "条");
+					toaster.pop("success", "提示", "发布成功");
 					$scope.relTableParams.page(1);
 					$scope.relTableParams.reload();
 					$scope.result.success = 0;//设置成0,让前端用户不能点击