|
|
@@ -1,13 +1,12 @@
|
|
|
define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
'use strict';
|
|
|
- app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI) {
|
|
|
+ app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI) {
|
|
|
$rootScope.active = 'vendor_material';
|
|
|
|
|
|
$scope.tab = 'material';
|
|
|
$scope.standard_tab = $stateParams.standardParam?$stateParams.standardParam:'standard';
|
|
|
$scope.choosedIds = [];
|
|
|
$scope.deleteDiv = false;
|
|
|
- $scope.submitProduct = {};
|
|
|
|
|
|
$scope.param = {
|
|
|
page : 1,
|
|
|
@@ -481,6 +480,11 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
$scope.currenctMaterial = data.content;
|
|
|
angular.forEach($scope.currenctMaterial, function (material, index) {
|
|
|
material.isChoosed = false;
|
|
|
+ material.submitProduct = {
|
|
|
+ brand: {},
|
|
|
+ commponent: {},
|
|
|
+ kind: {}
|
|
|
+ }
|
|
|
//第一个自动展开
|
|
|
if (index == 0 && $stateParams.standardParam && ($stateParams.standardParam =='standard' || $stateParams.standardParam =='unstandard')) {
|
|
|
material.selected = true;
|
|
|
@@ -516,8 +520,6 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
function publishGoods(product) {
|
|
|
if (!validateGoods($scope.goods)) return ;
|
|
|
|
|
|
- console.log('product', product);
|
|
|
- console.log($scope.goods);
|
|
|
$scope.goods.breakUp = 1 === $scope.goods.breakUp;
|
|
|
$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
|
|
|
Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
|
|
|
@@ -532,6 +534,17 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ // 保存物料详细信息
|
|
|
+ $scope.saveDetail = function(material) {
|
|
|
+ console.log('product',$scope.goods);
|
|
|
+ console.log(material);
|
|
|
+ Material.saveDetail({productId: material.id}, $scope.goods, function (data) {
|
|
|
+ toaster.pop('success', '保存成功');
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', response.data);
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* 验证商品信息
|
|
|
*
|
|
|
@@ -1063,8 +1076,12 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
};
|
|
|
|
|
|
// 选择品牌
|
|
|
- $scope.onAssociateClickBrand = function (brand) {
|
|
|
- $scope.submitProduct.brand = brand
|
|
|
+ $scope.onAssociateClickBrand = function (material, brand) {
|
|
|
+ BrandActiveAPI.getBrand({uuid: brand.uuid}, {} , function (data) {
|
|
|
+ material.submitProduct.brand = data;
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', response.data);
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
// 获取器件联想词
|
|
|
@@ -1078,7 +1095,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
};
|
|
|
// 选择器件
|
|
|
- $scope.onAssociateClickCmp = function (cmp) {
|
|
|
+ $scope.onAssociateClickCmp = function (material, cmp) {
|
|
|
$scope.submitProduct.component = cmp;
|
|
|
ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
|
|
|
var component = data;
|
|
|
@@ -1098,7 +1115,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $scope.onAssociateClickKind = function (kind) {
|
|
|
+ $scope.onAssociateClickKind = function (material, kind) {
|
|
|
$scope.submitProduct.kind = kind;
|
|
|
};
|
|
|
|
|
|
@@ -1122,40 +1139,57 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
};
|
|
|
|
|
|
// 提交申请
|
|
|
- $scope.submit = function () {
|
|
|
- if (typeof $scope.submitProduct.brand == 'undefined' || $scope.submitProduct.brand.nameEn == null) {
|
|
|
+ $scope.submit = function (material) {
|
|
|
+ if (typeof material.submitProduct.brand == 'undefined' || material.submitProduct.brand.nameEn == null) {
|
|
|
toaster.pop('warning', '请填写品牌英文名');
|
|
|
return;
|
|
|
}
|
|
|
- if (typeof $scope.submitProduct.component == 'undefined' || $scope.submitProduct.component.code == null) {
|
|
|
- toaster.pop('warning', '请填写原厂型号');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (typeof $scope.submitProduct.website == 'undefined' || $scope.submitProduct.website == null) {
|
|
|
+ if (typeof material.submitProduct.brand.url == 'undefined' || material.submitProduct.brand.url == null) {
|
|
|
toaster.pop('warning', '请填写品牌官网');
|
|
|
return;
|
|
|
}
|
|
|
- if (typeof $scope.submitProduct.kind == 'undefined' || $scope.submitProduct.kind.id == null) {
|
|
|
- toaster.pop('warning', '请填写或选择商城已有类目');
|
|
|
- return;
|
|
|
- }
|
|
|
- if ($scope.attachName == '') {
|
|
|
- toaster.pop('warning', '请填上传规格书');
|
|
|
- return;
|
|
|
+ if (!material.pbranduuid) { // 品牌申请
|
|
|
+ if (typeof material.submitProduct.brand.brief == 'undefined' || material.submitProduct.brand.brief == null) {
|
|
|
+ toaster.pop('warning', '请填写品牌简介');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (typeof material.submitProduct.brand.series == 'undefined' || material.submitProduct.brand.series == null) {
|
|
|
+ toaster.pop('warning', '请填写主要产品');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BrandSubmit.unstandardSubmit({}, material.submitProduct, function (data) {
|
|
|
+
|
|
|
+ }, function (response) {
|
|
|
+
|
|
|
+ })
|
|
|
} else {
|
|
|
- $scope.submitProduct.attach = $scope.attachName;
|
|
|
- }
|
|
|
+ toaster.pop('enter component submit');
|
|
|
+ if (typeof material.submitProduct.component == 'undefined' || material.submitProduct.component.code == null) {
|
|
|
+ toaster.pop('warning', '请填写原厂型号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- Material.submitProduct({}, $scope.submitProduct, function (data) {
|
|
|
- if (data.data == '已存在此器件') {
|
|
|
- toaster.pop('info', '已存在此器件');
|
|
|
+ if (typeof material.submitProduct.kind == 'undefined' || material.submitProduct.kind.id == null) {
|
|
|
+ toaster.pop('warning', '请填写或选择商城已有类目');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.attachName == '') {
|
|
|
+ toaster.pop('warning', '请填上传规格书');
|
|
|
+ return;
|
|
|
} else {
|
|
|
- toaster.pop('info', data.data);
|
|
|
+ material.submitProduct.attach = $scope.attachName;
|
|
|
}
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', response.data);
|
|
|
- })
|
|
|
|
|
|
+ Material.submitProduct({}, material.submitProduct, function (data) {
|
|
|
+ if (data.data == '已存在此器件') {
|
|
|
+ toaster.pop('info', '已存在此器件');
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', data.data);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
$scope.attachNameInfo = '';
|