Explorar el Código

替代料bug修改

yangc hace 8 años
padre
commit
96ad09d5b4

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

@@ -2520,8 +2520,26 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 				showSimilarBrandList: false
 				showSimilarBrandList: false
 			}
 			}
 		]
 		]
+		$scope.canAdd = true;
 		$scope.setReplies = function (type, index) {
 		$scope.setReplies = function (type, index) {
 			if (type === 'add' && $scope.replaceMaterialList.length < 10) {
 			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) {
 				if ($scope.canAdd) {
 					$scope.replaceMaterialList.splice(index + 1, 0, {
 					$scope.replaceMaterialList.splice(index + 1, 0, {
 						ptrCmpcode: '',
 						ptrCmpcode: '',
@@ -2530,23 +2548,12 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 						showSimilarBrandList: false,
 						showSimilarBrandList: false,
 						productId: $scope.replaceMaterialList[0].productId
 						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;
-						}
-					};
+					$scope.errorObj.splice(index + 1, 0, {
+						code: 0,
+						brand: 0
+					});
+					$scope.isInCodeList.splice(index + 1, 0, false);
+					$scope.isInBrandList.splice(index + 1, 0, false);
 				} else {
 				} else {
 					toaster.pop('error', '请填完整信息');
 					toaster.pop('error', '请填完整信息');
 				}
 				}