|
|
@@ -2901,23 +2901,37 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
code: 0,
|
|
|
brand: 0
|
|
|
};
|
|
|
- if (!productReplaceList[i].ptrCmpcode) {
|
|
|
- $scope.errorObj[i].code = 1;
|
|
|
- }
|
|
|
- if (!productReplaceList[i].ptrBranden) {
|
|
|
- $scope.errorObj[i].brand = 1;
|
|
|
+
|
|
|
+ if (!productReplaceList[i].ptrCmpcode && !productReplaceList[i].ptrBranden) {
|
|
|
+ // 都为空的情况下
|
|
|
+ $scope.errorObj[i].code = 0;
|
|
|
+ $scope.errorObj[i].brand = 0;
|
|
|
+ productReplaceList[i]['index'] = 1
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (!productReplaceList[i].ptrCmpcode) {
|
|
|
+ $scope.errorObj[i].code = 1;
|
|
|
+ }
|
|
|
+ else if (!productReplaceList[i].ptrBranden) {
|
|
|
+ $scope.errorObj[i].brand = 1;
|
|
|
+ }
|
|
|
+ productReplaceList[i].detno = i + 1;
|
|
|
}
|
|
|
- productReplaceList[i].detno = i + 1;
|
|
|
+
|
|
|
+
|
|
|
if ($scope.errorObj[i].code == 1 || $scope.errorObj[i].brand == 1) {
|
|
|
toaster.pop('error', '请填完整信息');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- if ($scope.resultDatalistArray[$scope.replaceMaterialId]) {
|
|
|
- $scope.resultDatalistArray[$scope.replaceMaterialId].arr = productReplaceList
|
|
|
- $scope.resultDatalistArray[$scope.replaceMaterialId].headlength = productReplaceList.length
|
|
|
- }
|
|
|
- var _productReplaceList = $scope.resultDatalistArray[$scope.replaceMaterialId].arr
|
|
|
+
|
|
|
+ var _productReplaceList = productReplaceList.filter(function(item, index) {
|
|
|
+ return !item['index']
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(_productReplaceList)
|
|
|
+
|
|
|
+
|
|
|
//提交
|
|
|
Material.setProductReplacesByPerson({
|
|
|
productId: $scope.replaceMaterialId
|
|
|
@@ -2940,15 +2954,15 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
$scope.editCmp = material.pcmpcode;
|
|
|
$scope.editBrand = material.pbranden;
|
|
|
$scope._material = material;
|
|
|
- if ($scope.resultDatalistArray[material.id]) {
|
|
|
- getChangeList($scope.resultDatalistArray[material.id].arr, material)
|
|
|
- } else {
|
|
|
- Material.getGoodsListByProductId({
|
|
|
- id: material.id
|
|
|
- }, function(data) {
|
|
|
- getChangeList(data, material)
|
|
|
- })
|
|
|
- }
|
|
|
+ // if ($scope.resultDatalistArray[material.id]) {
|
|
|
+ // getChangeList($scope.resultDatalistArray[material.id].arr, material)
|
|
|
+ // } else {
|
|
|
+ Material.getGoodsListByProductId({
|
|
|
+ id: material.id
|
|
|
+ }, function(data) {
|
|
|
+ getChangeList(data, material)
|
|
|
+ })
|
|
|
+ // }
|
|
|
} else {
|
|
|
$scope.errorObj = [{
|
|
|
code: 0,
|
|
|
@@ -3067,15 +3081,33 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
toaster.pop('error', '请填完整信息');
|
|
|
return
|
|
|
}
|
|
|
- } else if (type === 'sub' && $scope.replaceMaterialList.length > 1 && $scope.linearLength > 1) {
|
|
|
+ } else if (type === 'sub' && $scope.replaceMaterialList.length > 0 && $scope.linearLength > 0) {
|
|
|
+ var _productId = $scope.replaceMaterialList[0].productId
|
|
|
$scope.linearLength--;
|
|
|
$scope.replaceMaterialList.splice(index, 1);
|
|
|
$scope.errorObj.splice(index, 1);
|
|
|
$scope.isInCodeList.splice(index, 1);
|
|
|
$scope.isInBrandList.splice(index, 1);
|
|
|
+
|
|
|
+ if($scope.linearLength === 0) {
|
|
|
+ $scope.replaceMaterialList.splice(0, 0, {
|
|
|
+ ptrCmpcode: '',
|
|
|
+ ptrBranden: '',
|
|
|
+ showSimilarCodeList: false,
|
|
|
+ showSimilarBrandList: false,
|
|
|
+ editable: true,
|
|
|
+ productId: _productId
|
|
|
+ })
|
|
|
+ $scope.errorObj.splice(0, 0, {
|
|
|
+ code: 0,
|
|
|
+ brand: 0
|
|
|
+ });
|
|
|
+ $scope.linearLength++
|
|
|
+ console.log($scope.replaceMaterialList)
|
|
|
+ }
|
|
|
}
|
|
|
- $scope.resultDatalistArray[$scope._material.id].arr = $scope.replaceMaterialList
|
|
|
- $scope.resultDatalistArray[$scope._material.id].headlength = $scope.linearLength
|
|
|
+ // $scope.resultDatalistArray[$scope._material.id].arr = $scope.replaceMaterialList
|
|
|
+ // $scope.resultDatalistArray[$scope._material.id].headlength = $scope.linearLength
|
|
|
}
|
|
|
|
|
|
$scope.onCodeChange = function(code, index) {
|
|
|
@@ -3199,19 +3231,19 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
$scope.lookCmp = material.pcmpcode;
|
|
|
$scope.lookBrand = material.pbranden;
|
|
|
|
|
|
- if ($scope.resultDatalistArray[material.id]) {
|
|
|
- $scope.resultDatalist = $scope.resultDatalistArray[material.id].arr
|
|
|
- console.log($scope.resultDatalist)
|
|
|
- $scope.linearLength = $scope.resultDatalistArray[material.id].headlength
|
|
|
- } else {
|
|
|
- Material.getGoodsListByProductId({
|
|
|
- id: material.id
|
|
|
- }, function(data) {
|
|
|
- $scope.resultDatalistArray[material.id] = normalChangeArr(data)
|
|
|
- $scope.resultDatalist = $scope.resultDatalistArray[material.id].arr
|
|
|
- $scope.linearLength = $scope.resultDatalistArray[material.id].headlength
|
|
|
- })
|
|
|
- }
|
|
|
+ // if ($scope.resultDatalistArray[material.id]) {
|
|
|
+ // $scope.resultDatalist = $scope.resultDatalistArray[material.id].arr
|
|
|
+ // console.log($scope.resultDatalist)
|
|
|
+ // $scope.linearLength = $scope.resultDatalistArray[material.id].headlength
|
|
|
+ // } else {
|
|
|
+ Material.getGoodsListByProductId({
|
|
|
+ id: material.id
|
|
|
+ }, function(data) {
|
|
|
+ $scope.resultDatalistArray[material.id] = normalChangeArr(data)
|
|
|
+ $scope.resultDatalist = $scope.resultDatalistArray[material.id].arr
|
|
|
+ $scope.linearLength = $scope.resultDatalistArray[material.id].headlength
|
|
|
+ })
|
|
|
+ // }
|
|
|
}
|
|
|
//编辑按钮
|
|
|
$scope.updateIndex = function() {
|