Browse Source

处理品牌、器件推广的Bug

suntg 7 years ago
parent
commit
f821850908

+ 20 - 12
src/main/webapp/resources/js/admin/controllers/ads/ads_brand.js

@@ -29,12 +29,16 @@ define([ 'app/app' ], function(app) {
         loadData();
 
         $scope.weight = function(brand){
-            BrandActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
-                toaster.pop('success', '处理成功', '【' + data[0].nameCn + '】' + '禁用成功');
-                loadData();
-            }, function(res){
-                toaster.pop('error', '错误', res.data);
-            })
+            if (angular.isDefined(brand.inputWeight)) {
+                BrandActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                    toaster.pop('success', '处理成功', '【' + data[0].nameCn + '】' + '禁用成功');
+                    loadData();
+                }, function(res){
+                    toaster.pop('error', '错误', res.data);
+                })
+            } else [
+                toaster.pop('warning', '请先在右侧输入权重值')
+            ]
         };
         $scope.disweight = function(brand){
             BrandActive.setSimpleInfoWeight({weight: 0}, brand, function(data){
@@ -49,12 +53,16 @@ define([ 'app/app' ], function(app) {
             })
         };
         $scope.updateweight = function(brand){
-            BrandActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
-                toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已修改推广');
-                $scope.load('weight');
-            }, function(res){
-                toaster.pop('error', '错误', res.data);
-            })
+            if (angular.isDefined(brand.inputWeight)) {
+                BrandActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                    toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已修改推广');
+                    $scope.load('weight');
+                }, function(res){
+                    toaster.pop('error', '错误', res.data);
+                })
+            } else {
+                toaster.pop('warning', '请先在右侧输入权重值')
+            }
         };
 
     }]);

+ 20 - 12
src/main/webapp/resources/js/admin/controllers/ads/ads_component.js

@@ -30,12 +30,16 @@ define([ 'app/app' ], function(app) {
         loadData();
 
         $scope.weight = function(brand){
-            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
-                toaster.pop('success', '处理成功', '【' + data[0].code + '】' + '禁用成功');
-                loadData();
-            }, function(res){
-                toaster.pop('error', '错误', res.data);
-            })
+            if (angular.isDefined(brand.inputWeight)) {
+                ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                    toaster.pop('success', '处理成功', '【' + data[0].code + '】' + '禁用成功');
+                    loadData();
+                }, function(res){
+                    toaster.pop('error', '错误', res.data);
+                })
+            } else {
+                toaster.pop('warning', '请先在右侧输入权重值');
+            }
         };
         $scope.disweight = function(brand){
             ComponentActive.setSimpleInfoWeight({weight: 0}, brand, function(data){
@@ -50,12 +54,16 @@ define([ 'app/app' ], function(app) {
             })
         };
         $scope.updateweight = function(brand){
-            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
-                toaster.pop('success', '处理成功', '【' + data.code + '】' + '已修改推广');
-                $scope.load('weight');
-            }, function(res){
-                toaster.pop('error', '错误', res.data);
-            })
+            if (angular.isDefined(brand.inputWeight)) {
+                ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                    toaster.pop('success', '处理成功', '【' + data.code + '】' + '已修改推广');
+                    $scope.load('weight');
+                }, function(res){
+                    toaster.pop('error', '错误', res.data);
+                })
+            } else {
+                toaster.pop('warning', '请先在右侧输入权重值');
+            }
         };
 
         $scope.searchComponent = function(keyword){