Browse Source

买家发布求购校验同步

yangc 8 years ago
parent
commit
eefe11e74a

+ 43 - 9
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -63,13 +63,18 @@ define(['app/app'], function (app) {
           $scope.deadDate.setMonth($scope.deadDate.getMonth() + 3);
           $scope.deadDate.setMonth($scope.deadDate.getMonth() + 3);
 
 
           $scope.checkCode = function () {
           $scope.checkCode = function () {
-            $scope.validObj.code = $scope.applyObj.code && $scope.applyObj.code
-                !== '';
+            $scope.validObj.code = $scope.applyObj.code && $scope.applyObj.code !== '';
+            if (!$scope.validObj.code) {
+              toaster.pop('error', '型号不能为空');
+            }
             return this.validObj.code;
             return this.validObj.code;
           }
           }
           $scope.checkBrand = function () {
           $scope.checkBrand = function () {
             $scope.validObj.brand = $scope.applyObj.brand
             $scope.validObj.brand = $scope.applyObj.brand
                 && $scope.applyObj.brand !== '';
                 && $scope.applyObj.brand !== '';
+            if (!$scope.validObj.brand) {
+              toaster.pop('error', '品牌不能为空');
+            }
             return $scope.validObj.brand;
             return $scope.validObj.brand;
           }
           }
           $scope.checkUnitPrice = function () {
           $scope.checkUnitPrice = function () {
@@ -97,23 +102,52 @@ define(['app/app'], function (app) {
             }
             }
           }
           }
           $scope.onAmountChange = function () {
           $scope.onAmountChange = function () {
-            if ($scope.applyObj.amount.length > 8 || !(/^[0-9]*$/).test($scope.applyObj.amount)) {
-              $scope.applyObj.amount = $scope.applyObj.amount.substring(0, $scope.applyObj.amount.length - 1)
+            if (!(/^[0-9]*$/).test($scope.applyObj.amount)) {
+              var chineseIndex = -1;
+              for (var i = 0; i < $scope.applyObj.amount.length; i++) {
+                if (!(/^[0-9]*$/).test($scope.applyObj.amount.charAt(i))) {
+                  chineseIndex = i;
+                  break;
+                }
+              }
+              $scope.applyObj.amount = cutOutString($scope.applyObj.amount, chineseIndex);
+            } else if ($scope.applyObj.amount.length > 8) {
+              $scope.applyObj.amount = cutOutString($scope.applyObj.amount, 8);
             }
             }
           }
           }
           $scope.onEncapsulationChange = function () {
           $scope.onEncapsulationChange = function () {
             if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
             if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
-              $scope.applyObj.encapsulation = $scope.applyObj.encapsulation.substring(0, $scope.applyObj.encapsulation.length - 1)
+              $scope.applyObj.encapsulation = cutOutString($scope.applyObj.encapsulation, 20);
             }
             }
           }
           }
           $scope.onCodeChange = function () {
           $scope.onCodeChange = function () {
-            if ($scope.applyObj.code && getRealLen($scope.applyObj.code) > 30) {
-              $scope.applyObj.code = $scope.applyObj.code.substring(0, $scope.applyObj.code.length - 1)
+            // $scope.applyObj.code = $scope.applyObj.code.trim();
+            if ((/[^\x00-\xff]/g).test($scope.applyObj.code)) {
+              var chineseIndex = -1;
+              for (var i = 0; i < $scope.applyObj.code.length; i++) {
+                if ((/[^\x00-\xff]/g).test($scope.applyObj.code.charAt(i))) {
+                  chineseIndex = i;
+                  break;
+                }
+              }
+              $scope.applyObj.code = cutOutString($scope.applyObj.code, chineseIndex);
+            } else if ($scope.applyObj.code && getRealLen($scope.applyObj.code) > 100) {
+              $scope.applyObj.code = cutOutString($scope.applyObj.code, 100);
             }
             }
           }
           }
           $scope.onBrandChange = function () {
           $scope.onBrandChange = function () {
-            if ($scope.applyObj.brand && getRealLen($scope.applyObj.brand) > 20) {
-              $scope.applyObj.brand = $scope.applyObj.brand.substring(0, $scope.applyObj.brand.length - 1)
+            // $scope.applyObj.brand = $scope.applyObj.brand.trim();
+            if ((/[^\x00-\xff]/g).test($scope.applyObj.brand)) {
+              var chineseIndex = -1;
+              for (var i = 0; i < $scope.applyObj.brand.length; i++) {
+                if ((/[^\x00-\xff]/g).test($scope.applyObj.brand.charAt(i))) {
+                  chineseIndex = i;
+                  break;
+                }
+              }
+              $scope.applyObj.brand = cutOutString($scope.applyObj.brand, chineseIndex);
+            } else if ($scope.applyObj.brand && getRealLen($scope.applyObj.brand) > 50) {
+              $scope.applyObj.brand = cutOutString($scope.applyObj.brand, 50);
             }
             }
           }
           }
           $scope.onProduceDateChange = function () {
           $scope.onProduceDateChange = function () {

+ 1 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/seek_purchase_ctrl.js

@@ -171,7 +171,7 @@ define(['app/app'], function (app) {
                   toaster.pop('warning', '提示', '单价必须是大于0的数字');
                   toaster.pop('warning', '提示', '单价必须是大于0的数字');
                 }
                 }
               } else if (!$scope.validOffer.minDay || !$scope.validOffer.maxDay) {
               } else if (!$scope.validOffer.minDay || !$scope.validOffer.maxDay) {
-                if (!$scope.offer.minDay || !$scope.offer.maxDay) {
+                if ((!$scope.offer.minDay && !angular.isNumber($scope.offer.minDay)) || (!$scope.offer.maxDay && !angular.isNumber($scope.offer.maxDay))) {
                   toaster.pop('warning', '提示', '交期不能为空');
                   toaster.pop('warning', '提示', '交期不能为空');
                 } else {
                 } else {
                   if ($scope.offer.minDay > 31 || $scope.offer.minDay < 1 || $scope.offer.minDay.toString().indexOf('.') !== -1
                   if ($scope.offer.minDay > 31 || $scope.offer.minDay < 1 || $scope.offer.minDay.toString().indexOf('.') !== -1

+ 2 - 2
src/main/webapp/resources/view/usercenter/forstore/seekPurchase.html

@@ -572,7 +572,7 @@
                 <p>单个发布</p>
                 <p>单个发布</p>
                 <div class="form-block">
                 <div class="form-block">
                     <span><i>*</i>型号</span>
                     <span><i>*</i>型号</span>
-                    <input type="text" class="form-group" ng-model="applyObj.code" maxlength="30" ng-class="{'error': !validObj.code}" ng-blur="checkCode()" ng-change="onCodeChange()" >
+                    <input type="text" class="form-group" ng-model="applyObj.code" ng-class="{'error': !validObj.code}" ng-blur="checkCode()" ng-change="onCodeChange()" >
                 </div>
                 </div>
                 <div class="form-block">
                 <div class="form-block">
                     <span><i>*</i>品牌</span>
                     <span><i>*</i>品牌</span>
@@ -607,7 +607,7 @@
                 </div>
                 </div>
                 <div class="form-block">
                 <div class="form-block">
                     <span>封装</span>
                     <span>封装</span>
-                    <input type="text" class="form-group" ng-model="applyObj.encapsulation"  maxlength="20" ng-change="onEncapsulationChange()">
+                    <input type="text" class="form-group" ng-model="applyObj.encapsulation" ng-change="onEncapsulationChange()">
                 </div>
                 </div>
                 <div class="form-block">
                 <div class="form-block">
                     <span>生产日期</span>
                     <span>生产日期</span>