فهرست منبع

修改单个物料导入input blur和click问题

shenjj 7 سال پیش
والد
کامیت
32e610c8eb

+ 51 - 17
src/main/webapp/resources/js/vendor/controllers/forstore/single_entry.js

@@ -29,7 +29,9 @@ define(['app/app', 'jquery-uploadify'], function(app) {
         pcmpcode: false,
         spec: false,
         minDelivery: false,
-        maxDelivery: false
+        maxDelivery: false,
+        OnePrice: false,
+        minPackQty: false
       }
       for (var i = 0; i < $scope.Regul.prices.length; i++) {
         $scope.Regul.prices[i].priceInvalid = false
@@ -125,12 +127,19 @@ define(['app/app', 'jquery-uploadify'], function(app) {
      * @param name    品牌名称
      */
     $scope.RegulonBrandBlur = function(name) {
-      if (name === '') {
-        $scope.Regul.BrandList = []
-      } else {
-        $scope.Regul.pbranden = $scope.Regul.BrandList.value[0].nameEn
-        $scope.Regul.BrandList = []
-      }
+      // setTimeout(function() {
+        if (name === '') {
+          $scope.Regul.BrandList = []
+        } else {
+          $scope.Regul.pbranden = $scope.Regul.BrandList.value && $scope.Regul.BrandList.value[0].nameEn || name
+          $scope.Regul.BrandList = []
+        }
+      // }, 300)
+    }
+
+    $scope.stopMounseDown = function(e) {
+      var _e = e || window.event
+      _e.preventDefault()
     }
 
     $scope.setBrand = function(brand, index) {
@@ -199,14 +208,12 @@ define(['app/app', 'jquery-uploadify'], function(app) {
      * @param name    型号名称
      */
     $scope.RegulonCodeBlur = function(name) {
-      setTimeout(function() {
-        if (name === '') {
-          $scope.Regul.CodeList = []
-        } else {
-          $scope.Regul.pcmpcode = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].code || name
-          $scope.Regul.CodeList = []
-        }
-      }, 0)
+      if (name === '') {
+        $scope.Regul.CodeList = []
+      } else {
+        $scope.Regul.pcmpcode = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].code || name
+        $scope.Regul.CodeList = []
+      }
     }
     $scope.setCode = function(code, index) {
         $scope.Regul.pcmpcode = code
@@ -257,12 +264,13 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.setPriceMinPackAmount = function(num) {
-      if (num.indexOf('.') > -1) {
+      if (num && num.indexOf('.') > -1) {
         toaster.pop('warning', '提示', '最小包装数不能存在小数点')
         $scope.Regul.minPackQty = 1
       } else {
         $scope.Regul.minPackQty = num
       }
+      $scope.objError.minPackQty = false
     }
 
     $scope.setReserve = function(num) {
@@ -277,6 +285,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
 
     $scope.setOnePrice = function(num) {
       $scope.Regul.OnePrice = num
+      $scope.objError.OnePrice = false
     }
     // 修改规格书
     $scope.onUploadSuccess = function(data) {
@@ -524,12 +533,30 @@ define(['app/app', 'jquery-uploadify'], function(app) {
         return;
       }
 
-      if ($scope.Regul.reserve <=0) {
+      if ($scope.Regul.reserve <= 0) {
         toaster.pop('warning','提示', '库存数量必须大于等于1')
         $scope.objError.reserve = true
         return;
       }
 
+      if (/\D/.test($scope.Regul.reserve)) {
+        toaster.pop('warning','提示', '库存数量只能为正整数')
+        $scope.objError.reserve = true
+        return;
+      }
+
+      if ($scope.Regul.minPackQty !== '' && /\D/.test($scope.Regul.minPackQty)) {
+        toaster.pop('warning','提示', '最小包装数输入不正确')
+        $scope.objError.minPackQty = true
+        return;
+      }
+
+      if ($scope.Regul.OnePrice !== '' && !/^\d+(\.\d+)?$/.test($scope.Regul.OnePrice)) {
+        toaster.pop('warning','提示', '成本单价输入不正确')
+        $scope.objError.OnePrice = true
+        return;
+      }
+
       if (!$scope.Regul.minBuyQty || $scope.Regul.minBuyQty === 0) {
         toaster.pop('warning','提示', '最小起订量必须是大于0的数字')
         $scope.objError.minBuyQty = true
@@ -657,6 +684,13 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       // });
     }
 
+    // document.addEventListener('click', function() {
+    //   $scope.Regul.pcmpcode = $scope.Regul.CodeList&& $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].code || name
+    //   $scope.Regul.CodeList = []
+    //   $scope.Regul.pbranden = $scope.Regul.BrandList && $scope.Regul.BrandList.value[0].nameEn
+    //   $scope.Regul.BrandList = []
+    // }, false)
+
 
   }])
 });

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

@@ -178,16 +178,16 @@
           <div class="fl name">
             <span class="red">*</span>品牌:
           </div>
-          <!--ng-blur="RegulonBrandBlur(Regul.pbranden)"-->
+          <!---->
           <div class="fl input" style="position: relative">
             <input type="text"
                    ng-change="onBrandChange(Regul.pbranden)"
                    placeholder="请输入品牌名称"
-
+                   ng-blur="RegulonBrandBlur(Regul.pbranden)"
                    ng-model="Regul.pbranden"
                    class="form-control inputText" maxlength="25" ng-class="objError.pbranden ? 'danger' : '' "/>
             <ul class="listUl" ng-show="Regul.BrandList.value.length > 0">
-              <li ng-repeat="item in Regul.BrandList.value" ng-click="setBrand(item.nameEn)">
+              <li ng-repeat="item in Regul.BrandList.value" ng-click="setBrand(item.nameEn)" ng-mousedown="stopMounseDown($event)">
                 {{item.nameEn}}
               </li>
             </ul>
@@ -216,12 +216,12 @@
             <input type="text"
                    ng-change="onCodeChange(Regul.pcmpcode)"
                    placeholder="请输入型号"
-
+                   ng-blur="RegulonCodeBlur(Regul.pcmpcode)"
                    ng-model="Regul.pcmpcode"
                    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)">
+              <li ng-repeat="item in Regul.CodeList.value" ng-click="setCode(item.code)" ng-mousedown="stopMounseDown($event)">
                 {{item.code}}
               </li>
             </ul>
@@ -262,6 +262,7 @@
                    ng-model="Regul.minPackQty"
                    ng-blur="setPriceMinPackAmount(Regul.minPackQty)"
                    class="form-control inputText" maxlength="50"
+                   ng-class="objError.minPackQty ? 'danger' : '' "
             />
           </div>
         </div>
@@ -275,7 +276,8 @@
                    placeholder="请输入库存数量"
                    ng-model="Regul.reserve"
                    ng-blur="setReserve(Regul.reserve)"
-                   class="form-control inputText" maxlength="50"/>
+                   class="form-control inputText" maxlength="9"
+                   ng-class="objError.reserve ? 'danger' : '' "/>
           </div>
         </div>
         <div class="clearfix w50 fl list">
@@ -288,8 +290,9 @@
                    placeholder="请输入成本单价"
                    ng-model="Regul.OnePrice"
                    ng-blur="setOnePrice(Regul.OnePrice)"
-                   class="form-control inputText" maxlength="50" validata-price
+                   class="form-control inputText" maxlength="12" validata-price
                    oninput="if(value.length>11)value=value.slice(0,11)"
+                   ng-class="objError.OnePrice ? 'danger' : '' "
             />
           </div>
         </div>