Browse Source

修复型号联想词带出品牌,规格,名称等字段

shenjj 7 years ago
parent
commit
59efeb3b0d

+ 7 - 1
src/main/webapp/resources/js/common/query/material.js

@@ -126,7 +126,13 @@ define([ 'ngResource' ], function() {
             importOneMaterail: {
               url: 'trade/products/edit/one',
               method: 'POST'
-            }
+            },
+          // 根据型号联想词,获取品牌,规格,物料名称等字段
+          getSimilarComponents: {
+            url: 'trade/products/code/keyword',
+            method: 'GET',
+            isArray: true
+          }
         });
     }]);
 });

+ 10 - 35
src/main/webapp/resources/js/vendor/controllers/forstore/single_entry.js

@@ -179,27 +179,6 @@ define(['app/app', 'jquery-uploadify'], function(app) {
           return false
         }
         $scope.Regul.CodeList = getSimilarCode(code).$$state
-      } else {
-        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);
-          }
-        }
       }
     }
     /**
@@ -211,24 +190,19 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       if (name === '') {
         $scope.Regul.CodeList = []
       } else {
-        $scope.Regul.pcmpcode = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].code || name
+        $scope.Regul.pcmpcode = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pcmpcode || name
         $scope.Regul.CodeList = []
+        $scope.Regul.pbranden = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.pbranden
+        $scope.Regul.spec = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.spec
+        $scope.Regul.kind = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.kind
       }
     }
     $scope.setCode = function(code, index) {
-        $scope.Regul.pcmpcode = code
+        $scope.Regul.pcmpcode = code.pcmpcode
         $scope.Regul.CodeList = []
-    }
-
-    $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.Regul.pbranden = code.pbranden
+      $scope.Regul.spec = code.spec
+      $scope.Regul.kind = code.kind
     }
 
     var countLength = function(string) {
@@ -241,8 +215,9 @@ define(['app/app', 'jquery-uploadify'], function(app) {
      */
     function getSimilarCode(name) {
       if (name) {
-        return Search.getSimilarComponents({keyword: name}).$promise.then(
+        return Material.getSimilarComponents({keyword: name}).$promise.then(
             function (data) {
+              console.log(data)
               return data.map(function (item) {
                 return item;
               });

+ 2 - 2
src/main/webapp/resources/view/vendor/forstore/single_entry.html

@@ -221,8 +221,8 @@
                    ng-class="objError.pcmpcode ? 'danger' : '' "
                    class="form-control inputText" maxlength="100"/>
             <ul class="listUl" ng-show="Regul.CodeList.value.length > 0">
-              <li ng-repeat="item in Regul.CodeList.value" ng-click="setCode(item.code)" ng-mousedown="stopMounseDown($event)">
-                {{item.code}}
+              <li ng-repeat="item in Regul.CodeList.value" ng-click="setCode(item)" ng-mousedown="stopMounseDown($event)">
+                {{item.pcmpcode}}
               </li>
             </ul>
           </div>