yangc 8 лет назад
Родитель
Сommit
2b35baa558

+ 20 - 17
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialPersonCtrl.js

@@ -2522,23 +2522,6 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		]
 		$scope.setReplies = function (type, index) {
 			if (type === 'add' && $scope.replaceMaterialList.length < 10) {
-                for (var i = 0; i < $scope.replaceMaterialList.length; i ++) {
-                        $scope.errorObj[i] = {code : 0, brand : 0};
-						$scope.isInCodeList[i] = false;
-						$scope.isInBrandList[i] = false;
-                        if (!$scope.replaceMaterialList[i].ptrCmpcode) {
-                            $scope.errorObj[i].code = 1;
-                        }
-                        if (!$scope.replaceMaterialList[i].ptrBranden) {
-                            $scope.errorObj[i].brand = 1;
-                        }
-					if ($scope.replaceMaterialList[i].ptrBranden && $scope.replaceMaterialList[i].ptrCmpcode) {
-                        $scope.canAdd = true;
-					} else {
-                        $scope.canAdd = false;
-                        break;
-					}
-                };
 				if ($scope.canAdd) {
 					$scope.replaceMaterialList.splice(index + 1, 0, {
 						ptrCmpcode: '',
@@ -2547,11 +2530,31 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 						showSimilarBrandList: false,
 						productId: $scope.replaceMaterialList[0].productId
 					})
+					for (var i = 0; i < $scope.replaceMaterialList.length; i ++) {
+						$scope.errorObj[i] = {code : 0, brand : 0};
+						$scope.isInCodeList[i] = false;
+						$scope.isInBrandList[i] = false;
+						if (!$scope.replaceMaterialList[i].ptrCmpcode) {
+							$scope.errorObj[i].code = 1;
+						}
+						if (!$scope.replaceMaterialList[i].ptrBranden) {
+							$scope.errorObj[i].brand = 1;
+						}
+						if ($scope.replaceMaterialList[i].ptrBranden && $scope.replaceMaterialList[i].ptrCmpcode) {
+							$scope.canAdd = true;
+						} else {
+							$scope.canAdd = false;
+							break;
+						}
+					};
 				} else {
 					toaster.pop('error', '请填完整信息');
 				}
 			} else if (type === 'sub' && $scope.replaceMaterialList.length > 1) {
 				$scope.replaceMaterialList.splice(index, 1);
+				$scope.errorObj.splice(index, 1);
+				$scope.isInCodeList.splice(index, 1);
+				$scope.isInBrandList.splice(index, 1);
 			}
 		}