|
|
@@ -43,7 +43,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
id : 'DESC'
|
|
|
},
|
|
|
isStandard : true,
|
|
|
- type : "nStandard"
|
|
|
+ type : "all"
|
|
|
};
|
|
|
|
|
|
$scope.goods = { editBreakUp: false, editSelfSale: 2, editPrices: [{}] };
|
|
|
@@ -270,22 +270,21 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
// 确认删除
|
|
|
$scope.confirmDelete = function (ids) {
|
|
|
if ($scope.isChoosedAll) {
|
|
|
- if ($scope.standard_tab == 'standard') {
|
|
|
+
|
|
|
Material.deleteStandardAll(null, null, function (data) {
|
|
|
$scope.deleteDiv = false;
|
|
|
- loadDataReload();
|
|
|
- if (data.code != 1) {
|
|
|
- toaster.pop('error', data.message);
|
|
|
- } else {
|
|
|
- toaster.pop('success', data.message);
|
|
|
- }
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', '批量删除信息失败');
|
|
|
- });
|
|
|
- } else {
|
|
|
- Material.deleteUnstandardAll(null, null, function (data) {
|
|
|
- $scope.deleteDiv = false;
|
|
|
- loadDataReload();
|
|
|
+ Material.deleteUnstandardAll(null, null, function (data) {
|
|
|
+ $scope.deleteDiv = false;
|
|
|
+ loadDataReload();
|
|
|
+ if (data.code != 1) {
|
|
|
+ toaster.pop('error', data.message);
|
|
|
+ } else {
|
|
|
+ toaster.pop('success', data.message);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '批量删除信息失败');
|
|
|
+ });
|
|
|
+
|
|
|
if (data.code != 1) {
|
|
|
toaster.pop('error', data.message);
|
|
|
} else {
|
|
|
@@ -294,7 +293,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}, function (response) {
|
|
|
toaster.pop('error', '批量删除信息失败');
|
|
|
});
|
|
|
- }
|
|
|
+
|
|
|
} else {
|
|
|
var ids = $scope.choosedIds.join(',');
|
|
|
Material.deleteBatch({ids: ids, isPerson: 1}, function (data) {
|
|
|
@@ -1001,6 +1000,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
updateTagCount();
|
|
|
angular.forEach($scope.currenctMaterial, function (material, index) {
|
|
|
material.isChoosed = false;
|
|
|
+ material.showMoreReplace = false;
|
|
|
material.submitProduct = {
|
|
|
brand: {},
|
|
|
commponent: {},
|
|
|
@@ -1021,6 +1021,31 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
|
|
|
})
|
|
|
};
|
|
|
+ $scope.errorObj = [];
|
|
|
+ $scope.setProductReplacesByPerson = function (productReplaceList) {
|
|
|
+ for (var i = 0; i < productReplaceList.length; i++) {
|
|
|
+ $scope.errorObj[i] = {code : 0, brand : 0};
|
|
|
+ if (!productReplaceList[i].ptrCmpcode) {
|
|
|
+ $scope.errorObj[i].code = 1;
|
|
|
+ }
|
|
|
+ if (!productReplaceList[i].ptrBranden) {
|
|
|
+ $scope.errorObj[i].brand = 1;
|
|
|
+ }
|
|
|
+ productReplaceList[i].detno = i + 1;
|
|
|
+ }
|
|
|
+ console.log($scope.errorObj);
|
|
|
+ for (var i = 0; i < productReplaceList.length; i++) {
|
|
|
+ if ($scope.errorObj[i].code == 1 || $scope.errorObj[i].brand == 1) {
|
|
|
+ toaster.pop('error', '请填完整信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Material.setProductReplacesByPerson(productReplaceList , function (data) {
|
|
|
+ loadDataReload();
|
|
|
+ $scope.setActiveIndex(-1);
|
|
|
+ }, function (response) {
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
$scope.onSearch = function () {
|
|
|
loadDataReload();
|
|
|
@@ -1033,11 +1058,11 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
|
|
|
var init = function () {
|
|
|
$scope.param.keyword = '';
|
|
|
- if ($scope.standard_tab == 'standard') {
|
|
|
- $scope.param.type = "standard";
|
|
|
- } else if ($scope.standard_tab == 'unstandard') {
|
|
|
- $scope.param.type = "nStandard";
|
|
|
- }
|
|
|
+ // if ($scope.standard_tab == 'standard') {
|
|
|
+ // $scope.param.type = "standard";
|
|
|
+ // } else if ($scope.standard_tab == 'unstandard') {
|
|
|
+ // $scope.param.type = "nStandard";
|
|
|
+ // }
|
|
|
$scope.isBatch = false;
|
|
|
$scope.param.count = 10;
|
|
|
};
|
|
|
@@ -2449,6 +2474,232 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
$scope.attachNameInfo = '';
|
|
|
};
|
|
|
|
|
|
+ $scope.activeIndex = -1;
|
|
|
+
|
|
|
+ $scope.setActiveIndex = function (index,material) {
|
|
|
+ $scope.errorObj = [];
|
|
|
+ $scope.isInCodeList = [];
|
|
|
+ $scope.isInBrandList = [];
|
|
|
+ $scope.activeIndex = index;
|
|
|
+ if (material) {
|
|
|
+ $scope.editCmp = material.pcmpcode;
|
|
|
+ $scope.editBrand = material.pbranden;
|
|
|
+ $scope.replaceMaterialList = angular.copy(material.productReplaceList);
|
|
|
+ for (var i = 0; i < $scope.replaceMaterialList.length; i++) {
|
|
|
+ $scope.errorObj.push({
|
|
|
+ code: 0,
|
|
|
+ brand: 0
|
|
|
+ });
|
|
|
+ $scope.isInCodeList.push(false);
|
|
|
+ $scope.isInBrandList.push(false);
|
|
|
+ }
|
|
|
+ if ($scope.replaceMaterialList.length == 0) {
|
|
|
+ $scope.replaceMaterialList = [{detno : 1, productId : material.id}];
|
|
|
+ $scope.errorObj = [{
|
|
|
+ code: 0,
|
|
|
+ brand: 0
|
|
|
+ }];
|
|
|
+ $scope.isInCodeList = [false];
|
|
|
+ $scope.isInBrandList = [false];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $scope.errorObj = [{
|
|
|
+ code: 0,
|
|
|
+ brand: 0
|
|
|
+ }];
|
|
|
+ $scope.isInCodeList = [false];
|
|
|
+ $scope.isInBrandList = [false];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.replaceMaterialList = [
|
|
|
+ {
|
|
|
+ ptrBranden: '',
|
|
|
+ ptrCmpcode: '',
|
|
|
+ showSimilarCodeList: false,
|
|
|
+ showSimilarBrandList: false
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ $scope.canAdd = true;
|
|
|
+ $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: '',
|
|
|
+ ptrBranden: '',
|
|
|
+ showSimilarCodeList: false,
|
|
|
+ showSimilarBrandList: false,
|
|
|
+ productId: $scope.replaceMaterialList[0].productId
|
|
|
+ })
|
|
|
+ $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 {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var getRealLen = function (str) {
|
|
|
+ var len = 0;
|
|
|
+ for (var i = 0; i < str.length; i++) {
|
|
|
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
|
+ len += 2;
|
|
|
+ } else {
|
|
|
+ len++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return len;
|
|
|
+ };
|
|
|
+
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (getRealLen(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
+
|
|
|
+ // $scope.showSimilarCodeList = false;
|
|
|
+ // $scope.isInCodeList = true;
|
|
|
+ // $scope.showSimilarBrandList = false;
|
|
|
+ // $scope.isInBrandList = true;
|
|
|
+
|
|
|
+ $scope.getSimilarCode = function (keyword, index) {
|
|
|
+ if (keyword) {
|
|
|
+ Search.getSimilarComponents({keyword : keyword}, function (data) {
|
|
|
+ $scope.similarCode = data || [];
|
|
|
+ $scope.setShowSimilarCodeList(data && data.length, index);
|
|
|
+ }, function (error) {
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.getSimilarBrand = function (keyword, index) {
|
|
|
+ if (keyword) {
|
|
|
+ Search.getSimilarBrands({keyword : keyword}, function (data) {
|
|
|
+ $scope.similarBrand = data || [];
|
|
|
+ $scope.setShowSimilarBrandList(data && data.length, index);
|
|
|
+ }, function (error) {
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.setShowSimilarCodeList = function (flag, index) {
|
|
|
+ if (!$scope.replaceMaterialList[index].ptrCmpcode || !$scope.similarCode || !$scope.similarCode.length) {
|
|
|
+ $scope.replaceMaterialList[index].showSimilarCodeList = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.replaceMaterialList[index].showSimilarCodeList = flag;
|
|
|
+ }
|
|
|
+ $scope.setShowSimilarBrandList = function (flag, index) {
|
|
|
+ if (!$scope.replaceMaterialList[index].ptrBranden || !$scope.similarBrand || !$scope.similarBrand.length) {
|
|
|
+ $scope.replaceMaterialList[index].showSimilarBrandList = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.replaceMaterialList[index].showSimilarBrandList = flag;
|
|
|
+ }
|
|
|
+ $scope.setIsInCodeList = function (flag, index) {
|
|
|
+ $scope.isInCodeList[index] = flag;
|
|
|
+ }
|
|
|
+ $scope.setIsInBrandList = function (flag, index) {
|
|
|
+ $scope.isInBrandList[index] = flag;
|
|
|
+ }
|
|
|
+ $scope.onCodeChange = function (code, index) {
|
|
|
+ if ((/[^\x00-\xff]/g).test(code)) {
|
|
|
+ var chineseIndex = -1;
|
|
|
+ for (var i = 0; i < code.length; i++) {
|
|
|
+ if ((/[^\x00-\xff]/g).test(code.charAt(i))) {
|
|
|
+ chineseIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.replaceMaterialList[index].ptrCmpcode = cutOutString(code, chineseIndex);
|
|
|
+ } else if (code && getRealLen(code) > 100) {
|
|
|
+ $scope.replaceMaterialList[index].ptrCmpcode = cutOutString(code, 100);
|
|
|
+ } else {
|
|
|
+ if (!code) {
|
|
|
+ $scope.setShowSimilarCodeList(false, index);
|
|
|
+ } else {
|
|
|
+ $scope.getSimilarCode(code, index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onBrandChange = function (brand, index) {
|
|
|
+ if ((/[^\x00-\xff]/g).test(brand)) {
|
|
|
+ var chineseIndex = -1;
|
|
|
+ for (var i = 0; i < brand.length; i++) {
|
|
|
+ if ((/[^\x00-\xff]/g).test(brand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(brand.charAt(i))) {
|
|
|
+ chineseIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chineseIndex > -1) {
|
|
|
+ $scope.replaceMaterialList[index].ptrBranden = brand.substring(0, chineseIndex);
|
|
|
+ }
|
|
|
+ } else if (brand && getRealLen(brand) > 50) {
|
|
|
+ $scope.replaceMaterialList[index].ptrBranden = cutOutString(brand, 50);
|
|
|
+ } else {
|
|
|
+ if (!brand) {
|
|
|
+ $scope.setShowSimilarBrandList(false, index);
|
|
|
+ } else {
|
|
|
+ $scope.getSimilarBrand(brand, index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onCodeBlur = function (index) {
|
|
|
+ if ($scope.replaceMaterialList[index].ptrCmpcode) {
|
|
|
+ $scope.errorObj[index].code = 0;
|
|
|
+ }
|
|
|
+ $scope.setShowSimilarCodeList($scope.isInCodeList[index], index);
|
|
|
+ }
|
|
|
+ $scope.onBrandBlur = function (index) {
|
|
|
+ if ($scope.replaceMaterialList[index].ptrBranden) {
|
|
|
+ $scope.errorObj[index].brand = 0;
|
|
|
+ }
|
|
|
+ $scope.setShowSimilarBrandList($scope.isInBrandList[index], index);
|
|
|
+ }
|
|
|
+ $scope.setCode = function (index, code) {
|
|
|
+ $scope.replaceMaterialList[index].ptrCmpcode = code;
|
|
|
+ $scope.setShowSimilarCodeList(false, index);
|
|
|
+ }
|
|
|
+ $scope.setBrand = function (index, brand) {
|
|
|
+ $scope.replaceMaterialList[index].ptrBranden = brand;
|
|
|
+ $scope.setShowSimilarBrandList(false, index);
|
|
|
+ }
|
|
|
+ // $scope.resetSimilar = function (index, type) {
|
|
|
+ // for (var i = 0; i < $scope.replaceMaterialList.length; i++) {
|
|
|
+ // if (index != i) {
|
|
|
+ // $scope.replaceMaterialList[i].showSimilarCodeList = false;
|
|
|
+ // $scope.replaceMaterialList[i].showSimilarBrandList = false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}]);
|
|
|
|
|
|
//类目选择模态框
|
|
|
@@ -2548,6 +2799,17 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
};
|
|
|
$modalInstance.close(a);
|
|
|
};
|
|
|
+ var getRealLen = function (str) {
|
|
|
+ var len = 0;
|
|
|
+ for (var i = 0; i < str.length; i++) {
|
|
|
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
|
+ len += 2;
|
|
|
+ } else {
|
|
|
+ len++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return len;
|
|
|
+ }
|
|
|
}]);
|
|
|
|
|
|
|
|
|
@@ -2563,31 +2825,27 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
$scope.confirmDelete = function () {
|
|
|
if(deleteMaterial) {
|
|
|
if(selectAll) {
|
|
|
- if(standard_tab == 'standard') {
|
|
|
+
|
|
|
Material.deleteStandardAll({isPerson: 1}, function (data) {
|
|
|
if(data.code != 1) {
|
|
|
toaster.pop('error','错误' ,data.message);
|
|
|
}else {
|
|
|
- toaster.pop('success', '删除成功');
|
|
|
- $scope.deleteModal = false;
|
|
|
- $modalInstance.close(data);
|
|
|
- }
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', '错误', response.data);
|
|
|
- });
|
|
|
- }else {
|
|
|
- Material.deleteUnstandardAll({isPerson: 1}, function (data) {
|
|
|
- if(data.code != 1) {
|
|
|
- toaster.pop('error', '错误', data.message);
|
|
|
- }else {
|
|
|
- toaster.pop('success', '删除成功');
|
|
|
- $scope.deleteModal = false;
|
|
|
- $modalInstance.close(data);
|
|
|
+ Material.deleteUnstandardAll({isPerson: 1}, function (data) {
|
|
|
+ if(data.code != 1) {
|
|
|
+ toaster.pop('error', '错误', data.message);
|
|
|
+ }else {
|
|
|
+ toaster.pop('success', '删除成功');
|
|
|
+ $scope.deleteModal = false;
|
|
|
+ $modalInstance.close(data);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ });
|
|
|
}
|
|
|
}, function (response) {
|
|
|
toaster.pop('error', '错误', response.data);
|
|
|
});
|
|
|
- }
|
|
|
+
|
|
|
}else {
|
|
|
if(!$scope.ids || $scope.ids.length == 0) {
|
|
|
toaster.pop('warning', '提示','请选择要删除的信息');
|