|
|
@@ -258,70 +258,87 @@ define([ 'app/app' ], function(app) {
|
|
|
|
|
|
// 搜索框Ctrl
|
|
|
app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', function($scope, $http, $rootScope, SessionService) {
|
|
|
- $scope.searchType = 'original';// 搜索类型
|
|
|
- $scope.searchType = {
|
|
|
- original: false,
|
|
|
- inaction: false,
|
|
|
- proffing: false,
|
|
|
- brand: false,
|
|
|
- isCmp: function() {
|
|
|
- var me = this;
|
|
|
- return me.original || me.inaction || me.proffing;
|
|
|
- }
|
|
|
- };
|
|
|
- if(SessionService.get('brand')) {
|
|
|
- $scope.searchType.brand = true;
|
|
|
- }
|
|
|
+ // $scope.searchType = {
|
|
|
+ // original: false,
|
|
|
+ // inaction: false,
|
|
|
+ // proffing: false,
|
|
|
+ // brand: false,
|
|
|
+ // isCmp: function() {
|
|
|
+ // var me = this;
|
|
|
+ // return me.original || me.inaction || me.proffing;
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // 默认搜索类型
|
|
|
+ $scope.searchType = 'component';
|
|
|
|
|
|
- var componentSearchType = SessionService.get('component');
|
|
|
- if(componentSearchType) {
|
|
|
- $scope.searchType = angular.fromJson(componentSearchType);
|
|
|
- $scope.searchType.isCmp = function() {
|
|
|
- var me = this;
|
|
|
- return me.original || me.inaction || me.proffing;
|
|
|
- }
|
|
|
- }
|
|
|
+ // 选搜索类型
|
|
|
+ $scope.setTypeClick = function (type) {
|
|
|
+ $scope.searchType = type
|
|
|
+ $scope.search()
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索
|
|
|
+ $scope.search = function() {
|
|
|
+ if($scope.keyword) {
|
|
|
+ SessionService.set('brand', true);
|
|
|
+ SessionService.unset('component');
|
|
|
+ window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=' + $scope.searchType;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- // 点击搜索库存、样品、呆滞
|
|
|
- $scope.cmpTypeClick = function() {
|
|
|
- if($scope.searchType.isCmp()) {
|
|
|
- $scope.searchType.brand = false;
|
|
|
- }
|
|
|
- };
|
|
|
+ // if(SessionService.get('brand')) {
|
|
|
+ // $scope.searchType.brand = true;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // var componentSearchType = SessionService.get('component');
|
|
|
+ // if(componentSearchType) {
|
|
|
+ // $scope.searchType = angular.fromJson(componentSearchType);
|
|
|
+ // $scope.searchType.isCmp = function() {
|
|
|
+ // var me = this;
|
|
|
+ // return me.original || me.inaction || me.proffing;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 点击搜索库存、样品、呆滞
|
|
|
+ // $scope.cmpTypeClick = function() {
|
|
|
+ // if($scope.searchType.isCmp()) {
|
|
|
+ // $scope.searchType.brand = false;
|
|
|
+ // }
|
|
|
+ // };
|
|
|
|
|
|
// 点击搜索品牌
|
|
|
- $scope.brandTypeClick = function() {
|
|
|
- if($scope.searchType.brand) {
|
|
|
- $scope.searchType.original = false;
|
|
|
- $scope.searchType.inaction = false;
|
|
|
- $scope.searchType.proffing = false;
|
|
|
- }
|
|
|
- };
|
|
|
+ // $scope.brandTypeClick = function() {
|
|
|
+ // if($scope.searchType.brand) {
|
|
|
+ // $scope.searchType.original = false;
|
|
|
+ // $scope.searchType.inaction = false;
|
|
|
+ // $scope.searchType.proffing = false;
|
|
|
+ // }
|
|
|
+ // };
|
|
|
|
|
|
// 选搜索类型
|
|
|
- $scope.setSearchType = function(t) {
|
|
|
- $scope.searchType = t;
|
|
|
- };
|
|
|
+ // $scope.setSearchType = function(t) {
|
|
|
+ // $scope.searchType = t;
|
|
|
+ // };
|
|
|
|
|
|
// 搜索
|
|
|
- $scope.search = function() {
|
|
|
- if($scope.keyword) {
|
|
|
- if($scope.searchType.brand) {
|
|
|
- SessionService.set('brand', true);
|
|
|
- SessionService.unset('component');
|
|
|
- window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=brand';
|
|
|
- }else if($scope.searchType.isCmp()){
|
|
|
- SessionService.set('component', angular.toJson($scope.searchType));
|
|
|
- SessionService.unset('brand');
|
|
|
- window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=component';
|
|
|
- }else {
|
|
|
- SessionService.unset('component');
|
|
|
- SessionService.unset('brand');
|
|
|
- window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=all';
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- };
|
|
|
+ // $scope.search = function() {
|
|
|
+ // if($scope.keyword) {
|
|
|
+ // if($scope.searchType === 'brand') {
|
|
|
+ // SessionService.set('brand', true);
|
|
|
+ // SessionService.unset('component');
|
|
|
+ // window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=brand';
|
|
|
+ // }else if($scope.searchType.isCmp()){
|
|
|
+ // SessionService.set('component', angular.toJson($scope.searchType));
|
|
|
+ // SessionService.unset('brand');
|
|
|
+ // window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=component';
|
|
|
+ // }else {
|
|
|
+ // SessionService.unset('component');
|
|
|
+ // SessionService.unset('brand');
|
|
|
+ // window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=all';
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // };
|
|
|
|
|
|
// 搜索框获得焦点,显示联想框
|
|
|
$scope.onFocus = function() {
|
|
|
@@ -356,17 +373,19 @@ define([ 'app/app' ], function(app) {
|
|
|
$scope.onChange = function() {
|
|
|
if ($scope.keyword) {
|
|
|
var params = {
|
|
|
- keyword: $scope.keyword
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ type: $scope.searchType
|
|
|
};
|
|
|
- if($rootScope.userInfo) {
|
|
|
- params.userUU = $rootScope.userInfo.userUU;
|
|
|
- }
|
|
|
+ // if($rootScope.userInfo) {
|
|
|
+ // params.userUU = $rootScope.userInfo.userUU;
|
|
|
+ // }
|
|
|
$http.get('search/similarKeywords', {
|
|
|
params : params
|
|
|
}).success(function(data){
|
|
|
$scope.associates = data;// 联想词数组
|
|
|
+ console.log('1', data)
|
|
|
}).error(function(response) {
|
|
|
-
|
|
|
+ console.log(response)
|
|
|
});
|
|
|
} else {
|
|
|
$scope.associates = [];// 联想词数组
|