Przeglądaj źródła

处理全局搜索联想词

Administrator 7 lat temu
rodzic
commit
5546b8ac1e

+ 13 - 3
src/main/webapp/resources/js/index/app.js

@@ -24357,11 +24357,21 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         // 默认搜索类型
         $scope.searchType = 'component';
+        $scope.placeholderSearch = '请输入型号';
 
         // 选搜索类型
         $scope.setTypeClick = function (type) {
-            $scope.searchType = type
-            $scope.search()
+            $scope.keyword = '';
+            $scope.searchType = type;
+            if (type === 'kind') {
+                $scope.placeholderSearch = '请输入物料名称';
+            } else if (type === 'store') {
+                $scope.placeholderSearch = '请输入卖家名称';
+            } else if (type === 'brand') {
+                $scope.placeholderSearch = '请输入品牌';
+            } else {
+                $scope.placeholderSearch = '请输入型号';
+            }
         };
 
         // 搜索
@@ -24415,7 +24425,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     $http.get(data.url + '/search/similarKeywords', {
                         params : params
                     }).success(function(data){
-                        $scope.associates = data;// 联想词数组
+                        $scope.associates = data.result;// 联想词数组
                     }).error(function(response) {
                         console.log(response)
                     });

+ 12 - 5
src/main/webapp/resources/tpl/index/common/header.html

@@ -84,6 +84,9 @@
 		padding: 0 15px;
 		line-height: 30px;
 		text-align: left;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		white-space: nowrap;
 	}
 	#header .mall-cart{
 		width:140px;
@@ -161,20 +164,24 @@
 				<div class="input-group">
 					<div class="type">
 						<span class="type-item" ng-class="{'active': searchType === 'component'}" ng-click="setTypeClick('component')">型号</span>
-						<span class="type-item" ng-class="{'active': searchType === 'product'}" ng-click="setTypeClick('product')">物料名称</span>
+						<span class="type-item" ng-class="{'active': searchType === 'kind'}" ng-click="setTypeClick('kind')">物料名称</span>
 						<span class="type-item" ng-class="{'active': searchType === 'store'}" ng-click="setTypeClick('store')">卖家</span>
 						<span class="type-item" ng-class="{'active': searchType === 'brand'}" ng-click="setTypeClick('brand')">品牌</span>
 					</div>
 					<input ng-model="keyword" ng-change="onChange()" type="text" class="form-control"
-						   placeholder="型号/物料名称/品牌" ng-search="search()" ng-focus="onFocus()"
+						   placeholder="{{placeholderSearch}}" ng-search="search()" ng-focus="onFocus()"
 						   ng-blur="onBlur()" ng-keyup="onKeyup()"/>
 					<span class="input-group-btn" ng-click="search()">
                         <button class="btn btn-default" type="button">搜索</button>
                     </span>
-					<ul class="association" ng-show="associate || associateEnter" ng-mouseenter="onAssociateEnter()"
+					<ul class="association" ng-show="keyword && (associate || associateEnter)" ng-mouseenter="onAssociateEnter()"
 						ng-mouseleave="onAssociateLeave()">
-						<li ng-repeat="as in associates" ng-bind="as" ng-class="{'active': $index==selectIndex}"
-							ng-click="onAssociateClick(as)"></li>
+						<li ng-repeat="as in associates" ng-bind="as.code" ng-class="{'active': $index==selectIndex}"
+							ng-click="onAssociateClick(as.code)"></li>
+						<li ng-repeat="as in associates" ng-bind="as.nameCn" ng-class="{'active': $index==selectIndex}"
+							ng-click="onAssociateClick(as.nameCn)"></li>
+						<li ng-repeat="as in associates" ng-bind="as.name" ng-class="{'active': $index==selectIndex}"
+							ng-click="onAssociateClick(as.name)"></li>
 					</ul>
 				</div>
 				<div class="active-search">