Explorar o código

Merge remote-tracking branch 'origin/liusw-seekpurchase-v1.0.12.12' into liusw-seekpurchase-v1.0.12.12

liusw %!s(int64=8) %!d(string=hai) anos
pai
achega
270adc9272

+ 8 - 6
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -31,6 +31,8 @@ define(['app/app'], function (app) {
             deadline: true
           };
 
+          $scope.nowDate = new Date();
+
           $scope.checkCode = function () {
             $scope.validObj.code = $scope.applyObj.code && $scope.applyObj.code
                 !== '';
@@ -385,7 +387,7 @@ define(['app/app'], function (app) {
               newNum = parseInt(newNum);
               if (breakUp) {
                 if (newNum < buy) {
-                  // $scope.$message.error('最小起订量为' + buy)
+                  toaster.pop('error', '最小起订量为' + buy);
                   $scope.fragments[index].num = buy;
                   $scope.fragments[index].canSub = false;
                   $scope.fragments[index].canAdd = true;
@@ -404,25 +406,25 @@ define(['app/app'], function (app) {
                 }
               } else {
                 if (newNum < buy) {
-                  // $scope.$message.error('最小起订量为' + buy)
+                  toaster.pop('error', '最小起订量为' + buy);
                   $scope.fragments[index].num = buy;
                   $scope.fragments[index].canSub = false;
                   if (newNum > reserve) {
-                    // $scope.$message.error('库存不足')
+                    toaster.pop('error', '库存不足');
                     $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;
-                  // $scope.$message.error('库存不足')
+                  toaster.pop('error', '库存不足');
                   $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) {
-                    // $scope.$message.error('不支持拆包且包装量为' + pack)
+                    toaster.pop('error', '不支持拆包且包装量为' + pack);
                     // 这个直接赋值的,应该给这个值进行判断(Math.floor(newNum / pack) + 1) * pack
                     var res = (Math.floor(newNum / pack) + 1) * pack;
                     $scope.fragments[index].num = res > reserve
@@ -472,7 +474,7 @@ define(['app/app'], function (app) {
               $scope.changeNum($scope.fragments[index].num, index);
               getFragment($scope.goods[index], $scope.fragments[index]);
             } else {
-              // $scope.$message.error('请输入整数')
+              toaster.pop('error', '请输入整数');
               $scope.fragments[index].num = $scope.goods[index].minBuyQty;
             }
             $scope.onInput(index);

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

@@ -38,6 +38,88 @@ define(['app/app'], function (app) {
             $scope.seekPurchaseTableParams.reload();
           }
 
+
+          /*
+          * 输入价格校验
+          * */
+          $scope.onUnitPriceBlur = function () {
+            if (angular.isNumber($scope.offer.unitPrice)) {
+              if ($scope.offer.unitPrice < 0) {
+                 $scope.offer.unitPrice = 0;
+              }
+            } else {
+              $scope.offer.unitPrice = 0;
+            }
+          }
+
+          $scope.onUnitPriceChange = function () {
+            var price = $scope.offer.unitPrice;
+            if (angular.isNumber(price)) {
+              if (price >= 9999) {
+                $scope.offer.unitPrice = Number(price.toString().substring(0, 4));
+              } else if (price.toString().indexOf('.') > -1) {
+                var arr = price.toString().split(".");
+                if (arr[0].length > 4) {
+                  $scope.offer.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1]);
+                } else if (arr[1].length > 6) {
+                  $scope.offer.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6));
+                }
+              }
+            }
+          }
+
+          $scope.onMinDayInput = function () {
+            $scope.offer.minDay = Math.floor($scope.offer.minDay)
+            if ($scope.offer.maxDay && $scope.offer.maxDay < $scope.offer.minDay) {
+              $scope.offer.minDay = $scope.offer.maxDay;
+              toaster.pop('warning', '提示', '最短交期必须小于最长交期');
+            }
+            if ($scope.offer.minDay < 1 || $scope.offer.minDay > 31) {
+              toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
+            }
+          };
+
+          $scope.onMinDayChange = function () {
+            if (angular.isNumber($scope.offer.minDay) && $scope.offer.minDay.toString().length > 2) {
+              $scope.offer.minDay = Number($scope.offer.minDay.toString().substring(0, 2));
+            }
+          }
+
+          $scope.onMaxDayInput = function () {
+            $scope.offer.maxDay = Math.floor($scope.offer.maxDay)
+            if ($scope.offer.minDay && $scope.offer.maxDay < $scope.offer.minDay) {
+              $scope.offer.maxDay = $scope.offer.minDay;
+              toaster.pop('warning', '提示', '最短交期必须小于最长交期');
+            }
+            if ($scope.offer.maxDay < 1 || $scope.offer.maxDay > 31) {
+              toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
+            }
+          }
+
+          $scope.onMaxDayChange = function () {
+            if (angular.isNumber($scope.offer.maxDay) && $scope.offer.maxDay.toString().length > 2) {
+              $scope.offer.maxDay = Number($scope.offer.maxDay.toString().substring(0, 2));
+            }
+          }
+
+          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.onProduceDateChange = function () {
+            if ($scope.offer.produceDate && getRealLen($scope.offer.produceDate) > 12) {
+              $scope.offer.produceDate = $scope.offer.produceDate.substring(0, $scope.offer.produceDate.length - 1);
+            }
+          }
+
           // 保存报价
           $scope.saveOffer = function (seek) {
             seekPurchase.saveOffer($scope.offer, function (data) {
@@ -130,7 +212,7 @@ define(['app/app'], function (app) {
             seek.$active = flag;
             console.info(seek);
             if (flag) {
-              $scope.offer.currency = seek.currency ? "RMB" : seek.currency;
+              $scope.offer.currency = seek.currency ? seek.currency : "RMB";
               $scope.offer.spId = seek.spId;
             }
           }

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

@@ -407,7 +407,7 @@
                            ng-class="{'error': !validObj.deadline}"
                            datepicker-popup="yyyy-MM-dd"
                            is-open="condition.deadlineOpen"
-                           min-date="startDate" current-text="今天" clear-text="清除" close-text="关闭"
+                           min-date="nowDate" current-text="今天" clear-text="清除" close-text="关闭"
                            ng-click="openDatePicker($event, condition, 'deadlineOpen',3)"
                            datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
                     />
@@ -509,10 +509,10 @@
             </thead>
             <tbody ng-repeat="seek in seekListData.content">
             <tr class="default-row">
-                <td ng-bind="seek.releaseDate | date:'yyyy-MM-dd HH:mm:ss'">2012-12-12 12:12:12</td>
-                <td ng-bind="seek.brand || '-'" title="{{seek.brand}}">asdasfasdad</td>
-                <td ng-bind="seek.code || '-'" title="{{seek.code}}">asdasdad</td>
-                <td ng-bind="seek.amount || '-'">5000</td>
+                <td ng-bind="seek.releaseDate | date:'yyyy-MM-dd HH:mm:ss'"></td>
+                <td ng-bind="seek.code || '-'" title="{{seek.code}}"></td>
+                <td ng-bind="seek.brand || '-'" title="{{seek.brand}}"></td>
+                <td ng-bind="seek.amount || '-'"></td>
                 <td>
                     <span ng-class="{'red-text': seek.unitPrice && seek.unitPrice > 0}">{{seek.currency+seek.unitPrice | currencyStr}}</span>
                 </td>

+ 21 - 8
src/main/webapp/resources/view/vendor/forstore/seekPurchase.html

@@ -22,7 +22,7 @@
         margin-right: 11px;
     }
     .seek-purchase .seek-purchase-content .screen .fl select:last-child {
-        width: 72px;
+        width: 88px;
         padding-left: 6px;
     }
     .seek-purchase .seek-purchase-content .screen .sreach >span {
@@ -234,10 +234,17 @@
     .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) input {
         display: inline-block;
         width: 118px;
-        height: 26px;
+        height: 25px;
         border: 1px solid #5392f9;
     }
-    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) div {
+    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) select {
+        border: none;
+        padding-left: 3px;
+        background: url(static/img/seekPurchase/select-arrow-down.png) no-repeat;
+        background-position: 18px 9px;
+    }
+    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) div,
+    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) select {
         position: absolute;
         top: 14px;
         left: 33px;
@@ -250,7 +257,8 @@
         border-bottom-left-radius: 4px;
         border-top-left-radius: 4px;
     }
-    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) div + input {
+    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) div + input,
+    .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(2) select + input {
         padding-left: 34px;
     }
     .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(3) {
@@ -260,6 +268,7 @@
         display: inline-block;
         width: 32px;
         height: 26px;
+        padding: 6px;
     }
     .seek-purchase .seek-purchase-content >table tbody tr.say-price td >div >div:nth-child(4) {
         margin-right: 69px;
@@ -409,15 +418,19 @@
                             <div>报价</div>
                             <div>
                                 <i>*</i>单价
-                                <div ng-model="offer.currency">¥</div>
-                                <input type="text" class="form-control" ng-model="offer.unitPrice">
+                                <select ng-if="!seek.currency" ng-init="offer.currency = 'RMB'" ng-model="offer.currency">
+                                    <option value="RMB">¥</option>
+                                    <option value="USD">$</option>
+                                </select>
+                                <div ng-if="seek.currency" ng-model="offer.currency">¥</div>
+                                <input type="number" class="form-control" ng-blur="onUnitPriceBlur()" ng-change="onUnitPriceChange()" ng-model="offer.unitPrice">
                             </div>
                             <div>
                                 <i>*</i>交期&nbsp;
-                                <input type="number" class="form-control" ng-model="offer.minDay">&nbsp;-&nbsp;<input type="number" class="form-control" ng-model="offer.maxDay">&nbsp;天
+                                <input type="number" class="form-control" ng-model="offer.minDay" ng-blur="onMinDayInput()" ng-change="onMinDayChange()">&nbsp;-&nbsp;<input type="number" class="form-control" ng-model="offer.maxDay" ng-blur="onMaxDayInput()" ng-change="onMaxDayChange()">&nbsp;天
                             </div>
                             <div>
-                                生产日期&nbsp;<input type="text" class="form-control" ng-model="offer.produceDate">
+                                生产日期&nbsp;<input type="text" class="form-control" ng-model="offer.produceDate" ng-change="onProduceDateChange()">
                             </div>
                             <div>
                                 <span ng-click="setSeekActive(seek, false)">取消</span>