yangc 8 лет назад
Родитель
Сommit
8fc033db40

+ 68 - 10
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -31,6 +31,18 @@ define(['app/app'], function (app) {
             deadline: true
           };
 
+          var getRealLen = function (str) {
+            var len = 0;
+            for (var i = 0; i < str.length; i++) {
+              if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
+                len += 2;
+              } else {
+                len++;
+              }
+            }
+            return len;
+          }
+
           $scope.nowDate = new Date();
 
           $scope.deadDate = new Date();
@@ -47,11 +59,46 @@ define(['app/app'], function (app) {
             return $scope.validObj.brand;
           }
           $scope.checkUnitPrice = function () {
-            $scope.validObj.unitPrice = $scope.applyObj.unitPrice === '' ? true
+            $scope.validObj.unitPrice = ($scope.applyObj.unitPrice === '' || !$scope.applyObj.unitPrice ) ? true
                 : $scope.applyObj.unitPrice > 0 && $scope.applyObj.unitPrice
                 < 100000000;
             return $scope.validObj.unitPrice;
           }
+          $scope.onUnitPriceInput = function () {
+            var price = $scope.applyObj.unitPrice;
+            if (angular.isNumber(price)) {
+              if (price >= 9999) {
+                $scope.applyObj.unitPrice = Number(price.toString().substring(0, 4));
+              } else if (price.toString().indexOf('.') > -1) {
+                var arr = price.toString().split(".");
+                if (arr[0].length > 4) {
+                  $scope.applyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1]);
+                } else if (arr[1].length > 6) {
+                  $scope.applyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6));
+                }
+              }
+            }
+          }
+          $scope.onEncapsulationChange = function () {
+            if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
+              $scope.applyObj.encapsulation = $scope.applyObj.encapsulation.substring(0, $scope.applyObj.encapsulation.length - 1)
+            }
+          }
+          $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.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.onProduceDateChange = function () {
+            if ($scope.sayPriceObj.produceDate && getRealLen($scope.sayPriceObj.produceDate) > 12) {
+              $scope.sayPriceObj.produceDate = $scope.sayPriceObj.produceDate.substring(0, $scope.sayPriceObj.produceDate.length - 1)
+            }
+          }
           $scope.checkAmount = function () {
             $scope.validObj.amount = $scope.applyObj.amount === '' ? true
                 : $scope.applyObj.amount > 0 && $scope.applyObj.amount
@@ -87,7 +134,15 @@ define(['app/app'], function (app) {
                     toaster.pop('error', res.data);
                   });
             } else {
-              toaster.pop('error', '请输入正确的信息');
+              if (!$scope.validObj.code) {
+                toaster.pop('error', '型号不能为空');
+              } else if (!$scope.validObj.brand) {
+                toaster.pop('error', '品牌不能为空');
+              } else if (!$scope.validObj.deadline) {
+                toaster.pop('error', '截止日期不能为空');
+              } else if (!$scope.validObj.amount || !$scope.validObj.unitPrice) {
+                toaster.pop('error', '请输入正确的数值');
+              }
             }
           }
 
@@ -398,12 +453,12 @@ define(['app/app'], function (app) {
               newNum = parseInt(newNum);
               if (breakUp) {
                 if (newNum < buy) {
-                  toaster.pop('error', '最小起订量为' + buy);
+                  toaster.pop('info', '提示', '最小起订量为' + buy);
                   $scope.fragments[index].num = buy;
                   $scope.fragments[index].canSub = false;
                   $scope.fragments[index].canAdd = true;
                 } else if (newNum > reserve) {
-                  // $scope.$message.error('库存不足')
+                  toaster.pop('info', '提示', '库存不足');
                   $scope.fragments[index].num = reserve;
                   $scope.fragments[index].canAdd = false;
                   $scope.fragments[index].canSub = true;
@@ -417,26 +472,25 @@ define(['app/app'], function (app) {
                 }
               } else {
                 if (newNum < buy) {
-                  toaster.pop('error', '最小起订量为' + buy);
+                  toaster.pop('info', '提示', '最小起订量为' + buy);
                   $scope.fragments[index].num = buy;
                   $scope.fragments[index].canSub = false;
                   if (newNum > reserve) {
-                    toaster.pop('error', '库存不足');
+                    toaster.pop('info', '提示', '库存不足');
                     $scope.fragments[index].num = reserve - (reserve % pack);
                     $scope.fragments[index].canAdd = false;
                   }
                 } else if (newNum > reserve) {
                   $scope.fragments[index].canSub = true;
                   $scope.fragments[index].canAdd = false;
-                  toaster.pop('error', '库存不足');
+                  toaster.pop('info', '提示', '库存不足');
                   $scope.fragments[index].num = reserve - (reserve % pack);
                 } else {
                   $scope.fragments[index].canSub = true;
                   $scope.fragments[index].canAdd = true;
                   var remainder = newNum % pack;
                   if (remainder !== 0) {
-                    toaster.pop('error', '不支持拆包且包装量为' + pack);
-                    // 这个直接赋值的,应该给这个值进行判断(Math.floor(newNum / pack) + 1) * pack
+                    toaster.pop('info', '提示', '不支持拆包且包装量为' + pack);
                     var res = (Math.floor(newNum / pack) + 1) * pack;
                     $scope.fragments[index].num = res > reserve
                         ? Math.floor(newNum / pack) * pack : res;
@@ -463,6 +517,8 @@ define(['app/app'], function (app) {
               $scope.changeNum(newNum, index)
               getFragment($scope.goods[index], $scope.fragments[index]);
               $scope.onInput(index);
+            } else {
+              toaster.pop('info', '提示', '该商品最少购买' + $scope.goods[index].minBuyQty + '件');
             }
           }
           $scope.addNum = function (index) {
@@ -478,6 +534,8 @@ define(['app/app'], function (app) {
               $scope.changeNum(newNum, index)
               getFragment($scope.goods[index], $scope.fragments[index]);
               $scope.onInput(index);
+            } else {
+              toaster.pop('info', '提示', '库存不足');
             }
           }
           $scope.inputNum = function (index) {
@@ -485,7 +543,7 @@ define(['app/app'], function (app) {
               $scope.changeNum($scope.fragments[index].num, index);
               getFragment($scope.goods[index], $scope.fragments[index]);
             } else {
-              toaster.pop('error', '请输入整数');
+              toaster.pop('info', '提示', '请输入整数');
               $scope.fragments[index].num = $scope.goods[index].minBuyQty;
             }
             $scope.onInput(index);

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

@@ -118,15 +118,15 @@ define(['app/app'], function (app) {
           }
 
           var getRealLen = function (str) {
-            var len = 0
+            var len = 0;
             for (var i = 0; i < str.length; i++) {
               if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
-                len += 2
+                len += 2;
               } else {
-                len++
+                len++;
               }
             }
-            return len
+            return len;
           }
 
           $scope.onProduceDateChange = function () {

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

@@ -57,6 +57,7 @@
         height: 24px;
         background: url('static/img/seekPurchase/currency-arrow-down.png') no-repeat;
         background-position: 14px -1px;
+        padding: 0 3px;
     }
     .seek-purchase select {
         opacity: 1;
@@ -264,11 +265,15 @@
         position: absolute;
         cursor: pointer;
     }
+    .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number span.not-allowed {
+        cursor: not-allowed;
+        background: #e8e8e8;
+    }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number span:first-child {
-        top: 13px;
+        top: 12px;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number span:last-child {
-        top: 13px;
+        top: 12px;
         right: 10px;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.operate a {
@@ -413,11 +418,11 @@
                 <p>单个发布</p>
                 <div class="form-block">
                     <span><i>*</i>型号</span>
-                    <input type="text" class="form-group" ng-model="applyObj.code" maxlength="30" ng-class="{'error': !validObj.code}" ng-blur="checkCode()" >
+                    <input type="text" class="form-group" ng-model="applyObj.code" maxlength="30" ng-class="{'error': !validObj.code}" ng-blur="checkCode()" ng-change="onCodeChange()" >
                 </div>
                 <div class="form-block">
                     <span><i>*</i>品牌</span>
-                    <input type="text" class="form-group" ng-class="{'error': !validObj.brand}" maxlength="20" ng-model="applyObj.brand" ng-blur="checkBrand()">
+                    <input type="text" class="form-group" ng-class="{'error': !validObj.brand}" maxlength="20" ng-model="applyObj.brand" ng-blur="checkBrand()" ng-change="onBrandChange()">
                 </div>
                 <div class="form-block">
                     <span><i>*</i>截止日期</span>
@@ -431,11 +436,12 @@
                            current-text="今天" clear-text="清除" close-text="关闭"
                            ng-click="openDatePicker($event, condition, 'deadlineOpen',3)"
                            datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
+                           ng-change="checkDeadline()"
                     />
                 </div>
                 <div class="form-block">
                     <span>采购数量</span>
-                    <input type="number" class="form-group" ng-class="{'error': !validObj.amount}" ng-model="applyObj.amount" ng-blur="checkAmount" ng-change="onAmountInput()" >
+                    <input type="number" class="form-group" ng-class="{'error': !validObj.amount}" ng-model="applyObj.amount" ng-blur="checkAmount()" >
                 </div>
                 <div class="form-block single-price">
                     <span>单价预算</span>
@@ -447,11 +453,11 @@
                 </div>
                 <div class="form-block">
                     <span>封装</span>
-                    <input type="text" class="form-group" ng-model="applyObj.encapsulation"  maxlength="20">
+                    <input type="text" class="form-group" ng-model="applyObj.encapsulation"  maxlength="20" ng-change="onEncapsulationChange()">
                 </div>
                 <div class="form-block">
                     <span>生产日期</span>
-                    <input type="text" class="form-group" ng-model="applyObj.produceDate">
+                    <input type="text" class="form-group" ng-model="applyObj.produceDate" ng-change="onProduceDateChange()">
                 </div>
                 <a href="javascript:void(0)" ng-click="release()">发布求购</a>
             </div>
@@ -592,9 +598,9 @@
                                         <td width="111" ng-bind="go.reserve">21412</td>
                                         <td width="142" class="input-number">
                                             <div>
-                                                <span ng-click="subNum($index)">-</span>
-                                                <input type="number" ng-model="fragments[$index].num" ng-change="inputNum($index)">
-                                                <span ng-click="addNum($index)">+</span>
+                                                <span ng-click="subNum($index)" ng-class="{'not-allowed': !fragments[$index].canSub}">-</span>
+                                                <input type="number" ng-model="fragments[$index].num" ng-blur="inputNum($index)">
+                                                <span ng-click="addNum($index)" ng-class="{'not-allowed': !fragments[$index].canAdd}">+</span>
                                             </div>
                                         </td>
                                         <td width="186" class="operate">

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

@@ -20,7 +20,7 @@
     .disabled {
         cursor: not-allowed;
     }
-    #toast-container {
+    /*#toast-container {
         top: 36px;
     }
     #toast-container > .toast-info {
@@ -28,7 +28,7 @@
         font-size: 14px;
         font-weight: normal;
         width: auto;
-    }
+    }*/
 </style>
 <body>
     <div id="left-nav-fragment" ng-controller="leftNavCtrl">

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

@@ -24,12 +24,12 @@
 	/*#toast-container {
 		top: 36px;
 	}*/
-	#toast-container > .toast-info {
+	/*#toast-container > .toast-info {
 		background-color: #d88f2c;
 		font-size: 14px;
 		font-weight: normal;
 		width: auto;
-	}
+	}*/
 	.user_content .user_left ul li span {
 		width: 100%;
 		display: inline-block;