Просмотр исходного кода

处理配送规则相应的Bug

hulh 8 лет назад
Родитель
Сommit
66ab7cbd50

+ 29 - 21
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_deliveryRule_ctrl.js

@@ -382,7 +382,8 @@ define([ 'app/app' ], function(app) {
                 return false;
             }
             if ($scope.modifyRule.fareType == 1){
-                if (!$scope.modifyRule.uniformPrice){
+                if (typeof($scope.modifyRule.uniformPrice) == 'undefined' ||
+                    typeof($scope.modifyRule.uniformPrice) == 'string'){
                     toaster.pop('error', "请输入统一规定运费");
                     return false;
                 }
@@ -472,30 +473,32 @@ define([ 'app/app' ], function(app) {
             $scope.modifyRule.fareType = t;
         };
 
+        var convertArray = function (array) {
+            var resultArray = angular.copy(array);
+            angular.forEach(array, function (item, index) {
+                if (item.mainland && !item.province){
+                    resultArray.splice(index, 1);
+                    angular.forEach($scope.tree.$data, function (v) {
+                        if (v.label == item.mainland){
+                            angular.forEach(v.items, function (p) {
+                                var object = {
+                                    province : p.label
+                                };
+                                resultArray.push(object);
+                            })
+                        }
+                    });
+                }
+            });
+            return resultArray;
+        };
+
         $scope.chooseBox = false;
         $scope.cancel = function () {
             $scope.resetData($scope.tree.$data);
             if ($scope.mapArray.length > 0){
-                var resultArray = [];
-                angular.forEach($scope.mapArray, function (item) {
-                    if (item.mainland && !item.province){
-                        angular.forEach($scope.tree.$data, function (v) {
-                            if (v.label == item.mainland){
-                                angular.forEach(v.items, function (p) {
-                                    var object = {
-                                        province : p.label
-                                    };
-                                    resultArray.push(object);
-                                })
-                            }
-                        })
-                    }
-                });
-                if (resultArray.length == 0){
-                    $scope.tree.newInitData($scope.mapArray);
-                }else {
-                    $scope.tree.newInitData(resultArray);
-                }
+                var resultArray = convertArray($scope.mapArray);
+                $scope.tree.newInitData(resultArray);
             }
             $scope.chooseBox = false;
         };
@@ -533,6 +536,11 @@ define([ 'app/app' ], function(app) {
 
         $scope.deleteMapItem = function (index) {
             $scope.mapArray.splice(index, 1);
+            $scope.resetData($scope.tree.$data);
+            if ($scope.mapArray.length > 0){
+                var resultArray = convertArray($scope.mapArray);
+                $scope.tree.newInitData(resultArray);
+            }
         };
 
         /**

+ 1 - 1
src/main/webapp/resources/view/vendor/forstore/vendor_delivery_rule.html

@@ -457,7 +457,7 @@
 						<div class="no-edit" style="margin-top: 6px; position: relative;">适用范围内统一运费
 							<em ng-bind="currencySymbol"></em>
 							<div ng-bind="modifyRule.uniformPrice" style="width: 80px;overflow: hidden;float: left;
-    position: absolute;top: 0;left: 133px;"></div>
+    position: absolute;top: 0;left: 133px; white-space: nowrap;"></div>
 						</div>
 					</div>
 				</div>