|
|
@@ -1,6 +1,6 @@
|
|
|
define([ 'app/app' ], function(app) {
|
|
|
'use strict';
|
|
|
- app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams) {
|
|
|
+ app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal) {
|
|
|
$rootScope.active = 'vendor_material';
|
|
|
|
|
|
$scope.tab = 'material';
|
|
|
@@ -1018,6 +1018,169 @@ define([ 'app/app' ], function(app) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ $scope.getSimilarBrands = function(keyword) {
|
|
|
+ if (keyword) {
|
|
|
+ return Search.getSimilarBrands({keyword : keyword}).$promise.then(function(data) {
|
|
|
+ return data.map(function(item) {
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取器件联想词
|
|
|
+ $scope.getSimilarCmps = function(code) {
|
|
|
+ if (code) {
|
|
|
+ return Search.getSimilarComponents({keyword : code}).$promise.then(function(data) {
|
|
|
+ return data.map(function(item) {
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取末级类目联想词
|
|
|
+ $scope.getSimilarKinds = function(name) {
|
|
|
+ if (name) {
|
|
|
+ return Search.getSimilarLeafKinds({keyword: name}).$promise.then(function(data) {
|
|
|
+ return data.map(function(item) {
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 选择类目
|
|
|
+ $scope.selectKind = function() {
|
|
|
+ $modal.open({
|
|
|
+ animation: true,
|
|
|
+ size: 'lg',
|
|
|
+ templateUrl: 'static/view/prod/product_kindChoose_modal.html',
|
|
|
+ controller: 'KindChooseCtrl',
|
|
|
+ resolve: {
|
|
|
+ actives: function() {
|
|
|
+ return $scope.actives;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).result.then(function(data){
|
|
|
+ $scope.activesString = data.actives[data.actives.length - 1].nameCn;;
|
|
|
+ }, function(){
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.attachName = '';
|
|
|
+ //上传规格书
|
|
|
+ $scope.onAttachInput = function (event) {
|
|
|
+ console.log(event.target.files[0]);
|
|
|
+ $scope.attachName = event.target.files[0].name;
|
|
|
+ console.log($scope.attachName);
|
|
|
+ }
|
|
|
+ $scope.deleteAttach = function () {
|
|
|
+ $scope.attachName = '';
|
|
|
+ }
|
|
|
+
|
|
|
}]);
|
|
|
|
|
|
+ //类目选择模态框
|
|
|
+ app.register.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function($scope, KindAPI, actives, toaster, $modalInstance) {
|
|
|
+ $scope.actives = actives;
|
|
|
+ $scope.kinds = [[], [], [], []];
|
|
|
+ // 获取子类目
|
|
|
+ var getChildren = function(pid, deep) {
|
|
|
+ KindAPI.getChildren({parentId: pid}, function(data) {
|
|
|
+ $scope.kinds[deep] = data;
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '获取子类目失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 改变节点选中状态
|
|
|
+ var changeStatus = function(item, deep) {
|
|
|
+ var actives = [], level = 0;
|
|
|
+ angular.forEach($scope.kinds, function(ks, i) {
|
|
|
+ if(i > deep) {
|
|
|
+ $scope.kinds[i] = [];
|
|
|
+ } else {
|
|
|
+ angular.forEach(ks, function(k, j) {
|
|
|
+ if(i == deep) {
|
|
|
+ if(k.id == item.id) {
|
|
|
+ $scope.kinds[i][j].$active = true;
|
|
|
+ actives.push(k);
|
|
|
+ } else {
|
|
|
+ k.$active = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(k.$active) {
|
|
|
+ actives.push(k);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 选择的节点
|
|
|
+ $scope.actives = actives;
|
|
|
+ $scope.active = item;
|
|
|
+ // 当前可操作的层级
|
|
|
+ if(deep < 3) {
|
|
|
+ $scope.activeDeep = deep + 1;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 节点点击后获取子类目,节点被选中
|
|
|
+ $scope.onItemClick = function(item, deep) {
|
|
|
+ changeStatus(item, deep);
|
|
|
+ if (!item.isLeaf) {
|
|
|
+ getChildren(item.id, deep + 1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 重新加载数据
|
|
|
+ function reload(deep) {
|
|
|
+ var pid;
|
|
|
+ if(deep) {
|
|
|
+ pid = $scope.actives[deep - 1].id;
|
|
|
+ } else {
|
|
|
+ pid = 0;
|
|
|
+ deep = 0;
|
|
|
+ }
|
|
|
+ getChildren(pid, deep);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始加载数据,获取第一层的类目
|
|
|
+ if($scope.actives) {
|
|
|
+ angular.forEach($scope.actives, function(v, k) {
|
|
|
+ KindAPI.getChildren({parentId: v.parentid}, function(data) {
|
|
|
+ $scope.kinds[k] = data;
|
|
|
+ angular.forEach($scope.kinds[k], function(kind, i){
|
|
|
+ if(kind.id == v.id) {
|
|
|
+ $scope.kinds[k][i].$active = true;
|
|
|
+ $scope.actives[k] = $scope.kinds[k][i];
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '获取子类目失败', response.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ $scope.cancel = function() {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 确认选择
|
|
|
+ $scope.check = function() {
|
|
|
+ var a = {
|
|
|
+ active: $scope.active,
|
|
|
+ actives: $scope.actives
|
|
|
+ };
|
|
|
+ $modalInstance.close(a);
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+
|
|
|
});
|