Pārlūkot izejas kodu

买家求购修改

yangc 8 gadi atpakaļ
vecāks
revīzija
e5d243231c

+ 8 - 0
src/main/webapp/resources/js/usercenter/app.js

@@ -727,5 +727,13 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
 			}
 		}
 	});
+
+	// 币别filter
+	app.filter('currencyStr', function () {
+		return function (str) {
+			return str ? str.startsWith('RMB') ? '¥' + str.substring(3, str.length) : '$' + str.substring(3, str.length) : '-';
+		}
+	});
+
 	return app;
 });

+ 171 - 2
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -47,7 +47,10 @@ define(['app/app'], function(app) {
       });
 
       // 搜索
-      $scope.onSearch = function(){
+      $scope.onSearch = function(searchStatus){
+        if (searchStatus) {
+          $scope.searchStatus = searchStatus;
+        }
         $scope.seekPurchaseTableParams.reload();
       }
 
@@ -64,6 +67,7 @@ define(['app/app'], function(app) {
           } else if (status == 1) {
             seekPurchase.getMallGoodsList({spId: seek.spId}, function(data) {
                 $scope.goods = data;
+                initFragments();
             });
           }
           seek.$status = status;
@@ -74,7 +78,7 @@ define(['app/app'], function(app) {
       // 获取报价列表 getSeekPurchaseOfferPageInfo 参数:分页参数,spId
 
 
-      $scope.condition = {endDateOpen:false, startDateOpen: false};
+      $scope.condition = {endDateOpen:false, startDateOpen: false, deadlineOpen: false};
       // 打开日期选择框
       $scope.openDatePicker = function ($event, item, openParam,status) {
         if (status != null) {
@@ -147,5 +151,170 @@ define(['app/app'], function(app) {
       $scope.getHours = function (timeStamp) {
         return Math.floor((timeStamp / (1000 * 60 * 60)) % 24);
       }
+
+      /*
+      * input 校验
+      * */
+      $scope.fragments = [];
+      function initFragment (commodity) {
+        if (!commodity) {
+          return {};
+        }
+        var fragment = {};
+        var prices = commodity.prices[0];
+        fragment.num = commodity.minBuyQty;
+        fragment.prices = prices;
+
+        if (commodity.currencyName !== 'USD') {
+          fragment.currency = 'RMB';
+        } else {
+          fragment.currency = 'USD';
+        }
+
+        if (fragment.currency !== 'USD') {
+          fragment.price = prices.rMBPrice;
+        } else {
+          fragment.price = prices.uSDPrice;
+        }
+        fragment.canAdd = true;
+        fragment.canSub = false;
+        return fragment;
+      }
+      function initFragments() {
+        angular.forEach($scope.goods, function (item) {
+          $scope.fragments.push(initFragment(item));
+        })
+      }
+      function getFragment (commodity, fragment) {
+        // 判断是否小于第一分段的起订量
+        if (commodity.prices[0].start > fragment.num) {
+          fragment.num = commodity.prices[0].start;
+        }
+        // 获取分段的信息
+        var prices = commodity.prices;
+        for (var i = 0; i < prices.length; i++) {
+          if (fragment.num <= prices[i].end) {
+            fragment.prices = prices[i];
+            break;
+          }
+        }
+      }
+      $scope.onInput = function (index) {
+        var prices = $scope.goods[index].prices;
+        if (prices && prices.length) {
+          for (var i = 0; i < prices.length; i++) {
+            if ($scope.fragments[index].num >= prices[i].start && $scope.fragments[index].num <= prices[i].end) {
+              $scope.fragments[index].price = $scope.fragments[index].currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice;
+              break;
+            }
+          }
+        }
+      }
+      $scope.changeNum = function (newNum, index) {
+        var pack = $scope.goods[index].perQty || $scope.goods[index].minPackQty;
+        var buy = $scope.goods[index].minBuyQty;
+        var reserve = $scope.goods[index].reserve;
+        var breakUp = $scope.goods[index].breakUp;
+        if (!newNum) {
+          $scope.fragments[index].num = buy;
+        } else {
+          newNum = parseInt(newNum);
+          if (breakUp) {
+            if (newNum < buy) {
+              // $scope.$message.error('最小起订量为' + buy)
+              $scope.fragments[index].num = buy;
+              $scope.fragments[index].canSub = false;
+              $scope.fragments[index].canAdd = true;
+            } else if (newNum > reserve) {
+              // $scope.$message.error('库存不足')
+              $scope.fragments[index].num = reserve;
+              $scope.fragments[index].canAdd = false;
+              $scope.fragments[index].canSub = true;
+            } else {
+              $scope.fragments[index].canSub = true;
+              $scope.fragments[index].canAdd = true;
+              $scope.fragments[index].num = newNum;
+              newNum === buy && ($scope.fragments[index].canSub = false);
+              newNum === reserve && ($scope.fragments[index].canAdd = false);
+            }
+          } else {
+            if (newNum < buy) {
+              // $scope.$message.error('最小起订量为' + buy)
+              $scope.fragments[index].num = buy;
+              $scope.fragments[index].canSub = false;
+              if (newNum > reserve) {
+                // $scope.$message.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('库存不足')
+              $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)
+                // 这个直接赋值的,应该给这个值进行判断(Math.floor(newNum / pack) + 1) * pack
+                var res = (Math.floor(newNum / pack) + 1) * pack;
+                $scope.fragments[index].num = res > reserve ? Math.floor(newNum / pack) * pack : res;
+              } else {
+                $scope.fragments[index].num = newNum;
+              }
+              newNum === buy && ($scope.fragments[index].canSub = false);
+              newNum === reserve && ($scope.fragments[index].canAdd = false);
+            }
+          }
+        }
+      }
+      $scope.subNum = function (index) {
+        if ($scope.fragments[index].canSub) {
+          var pack = $scope.goods[index].perQty || $scope.goods[index].minPackQty;
+          var newNum = 0;
+          if ($scope.goods[index].breakUp) {
+            newNum = $scope.fragments[index].num - 1;
+          } else {
+            newNum = $scope.fragments[index].num - pack;
+          }
+          $scope.changeNum(newNum, index)
+          getFragment($scope.goods[index], $scope.fragments[index]);
+          $scope.onInput(index);
+        }
+      }
+      $scope.addNum = function (index) {
+        if ($scope.fragments[index].canAdd) {
+          var pack = $scope.goods[index].perQty || $scope.goods[index].minPackQty;
+          var newNum = 0;
+          if ($scope.goods[index].breakUp) {
+            newNum = $scope.fragments[index].num + 1;
+          } else {
+            newNum = $scope.fragments[index].num + pack;
+          }
+          $scope.changeNum(newNum, index)
+          getFragment($scope.goods[index], $scope.fragments[index]);
+          $scope.onInput(index);
+        }
+      }
+      $scope.inputNum = function (index) {
+        if ((/^[\d]*$/).test($scope.fragments[index].num)) {
+          $scope.changeNum($scope.fragments[index].num, index);
+          getFragment($scope.goods[index], $scope.fragments[index]);
+        } else {
+          // $scope.$message.error('请输入整数')
+          $scope.fragments[index].num = $scope.goods[index].minBuyQty;
+        }
+      }
+
+      $scope.showUseFlag = false;
+      $scope.setShowUseFlag = function (flag, of) {
+        if (flag) {
+          $scope.currentOffer = of;
+        }
+        $scope.showUseFlag = flag;
+      }
+
     }]);
 });

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

@@ -146,6 +146,9 @@
     .seek-purchase .seek-purchase-content .screen .sreach .date input.form-control{
         padding: 6px 6px;
     }
+    .seek-purchase .seek-purchase-content .publish-purchase .fl .form-block .btn-default{
+        border: none;
+    }
     /*搜索时间筛选 end*/
     .seek-purchase .seek-purchase-content >table {
         width: 1000px;
@@ -168,7 +171,7 @@
         color: #333;
         padding-left: 6px;
         font-size: 14px;
-        background: url('static/img/seekPurchase/select-arrow-down.png') no-repeat #fff right !important;
+        background: url('static/img/seekPurchase/select-arrow-down.png') no-repeat #fff 49px 10px !important;
     }
     .seek-purchase .seek-purchase-content >table >tbody >tr.default-row {
         border-bottom: 1px solid #dae5fd;
@@ -216,8 +219,10 @@
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr:nth-child(even) {
         background: #fce8df;
     }
-    .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number {
+    .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number >div {
         position: relative;
+        width: 100px;
+        margin: 0 auto;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number input {
         width: 80px;
@@ -237,11 +242,11 @@
         cursor: pointer;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number span:first-child {
-        top: 12px;
+        top: 13px;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.input-number span:last-child {
-        top: 12px;
-        right: 38px;
+        top: 13px;
+        right: 10px;
     }
     .seek-purchase .seek-purchase-content >table >tbody tr.expand-row table tbody tr td.operate a {
         color: #5078cb;
@@ -319,9 +324,9 @@
         overflow-y: auto;
     }
     /*提示框样式 start*/
-    .seek-purchase .com-del-box {
+    /*.seek-purchase .com-del-box {
         display: none;
-    }
+    }*/
     .seek-purchase .com-del-box .title {
         background-color: #4290f7;
     }
@@ -361,6 +366,14 @@
         padding-right: 15px;
         margin: 20px 0 12px 0;
     }
+    .seek-purchase table {
+        table-layout: fixed;
+    }
+    .seek-purchase table tbody tr td {
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+    }
 </style>
 <div class="user_right fr seek-purchase">
     <!--求购询价-->
@@ -385,11 +398,20 @@
                 </div>
                 <div class="form-block">
                     <span><i>*</i>截止日期</span>
-                    <input type="text" class="form-group"  ng-model="seek.deadline">
+                    <input type="text" ng-model="seek.deadline"
+                           readonly
+                           class="form-control select-adder" placeholder="截止日期"
+                           datepicker-popup="yyyy-MM-dd"
+                           is-open="condition.deadlineOpen"
+                           min-date="startDate" current-text="今天" clear-text="清除" close-text="关闭"
+                           ng-click="openDatePicker($event, condition, 'deadlineOpen',3)"
+                           datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
+                           "
+                    />
                 </div>
                 <div class="form-block">
                     <span>采购数量</span>
-                    <input type="text" class="form-group"  ng-model="seek.amount">
+                    <input type="number" class="form-group"  ng-model="seek.amount">
                 </div>
                 <div class="form-block single-price">
                     <span>单价预算</span>
@@ -397,7 +419,7 @@
                         <option value="RMB">¥</option>
                         <option value="USD">$</option>
                     </select>
-                    <input type="text" class="form-group" ng-model="seek.unitPrice">
+                    <input type="number" class="form-group" ng-model="seek.unitPrice">
                 </div>
                 <div class="form-block">
                     <span>封装</span>
@@ -469,7 +491,7 @@
                 <th width="99">生产日期</th>
                 <th width="76">截止时间</th>
                 <th width="81">
-                    <select class="select-adder" ng-model="searchStatus" ng-change="onSearch()">
+                    <select class="select-adder" ng-model="searchStatus" ng-change="onSearch(searchStatus)">
                         <option value="0">全部</option>
                         <option value="200">待报价</option>
                         <option value="201">已报价</option>
@@ -482,12 +504,14 @@
             <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">asdasfasdad</td>
-                <td ng-bind="seek.code">asdasdad</td>
-                <td ng-bind="seek.amount">5000</td>
-                <td><span class="red-text" ng-bind="seek.currency+seek.unitPrice">$5.569</span></td>
-                <td ng-bind="seek.encapsulation">盘装</td>
-                <td ng-bind="seek.produceDate">2012-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>
+                    <span ng-class="{'red-text': seek.unitPrice && seek.unitPrice > 0}">{{seek.currency+seek.unitPrice | currencyStr}}</span>
+                </td>
+                <td ng-bind="seek.encapsulation || '-'">盘装</td>
+                <td ng-bind="seek.produceDate || '-'">2012-12-12</td>
                 <td>剩余&nbsp;<span class="red-text">8</span>&nbsp;天</td>
                 <td ng-switch="seek.status">
                     <span ng-switch-when="200" style="color:red;">待报价</span>
@@ -511,12 +535,12 @@
                                 <thead>
                                 <tr>
                                     <th width="68">全选</th>
-                                    <th width="103">卖家</th>
-                                    <th width="126">交期(天)</th>
+                                    <th width="146">卖家</th>
+                                    <th width="83">交期(天)</th>
                                     <th width="104">单价</th>
                                     <th width="137">生产日期</th>
                                     <th width="111">库存</th>
-                                    <th width="164">购买数量</th>
+                                    <th width="144">购买数量</th>
                                     <th width="186">操作</th>
                                 </tr>
                                 </thead>
@@ -524,14 +548,20 @@
                             <div class="seek-list">
                                 <table>
                                     <tbody>
-                                    <tr ng-repeat="go in goods">
+                                    <tr ng-repeat="go in goods track by $index">
                                         <td width="68"><input type="checkbox"></td>
-                                        <td width="103" ng-bind="go.enterpriseName">哈哈哈</td>
-                                        <td width="126" class="red-text" ng-bind="go.minDelivery+'-'+go.maxDelivery">4-6</td>
-                                        <td width="104" class="red-text" ng-bind="go.currencyName">$123</td>
+                                        <td width="146" ng-bind="go.enterpriseName">哈哈哈</td>
+                                        <td width="83" class="red-text" ng-bind="go.minDelivery+'-'+go.maxDelivery">4-6{{fragments[i].price}}</td>
+                                        <td width="104" class="red-text">{{go.currencyName + fragments[$index].price | currencyStr}}</td>
                                         <td width="137" ng-bind="go.produceDate">2012-12-12</td>
                                         <td width="111" ng-bind="go.reserve">21412</td>
-                                        <td width="164" class="input-number"><span>-</span><input type="number" ng-bind="go.minBuyQty"><span>+</span></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)" ng-input="onInput($index)">
+                                                <span ng-click="addNum($index)">+</span>
+                                            </div>
+                                        </td>
                                         <td width="186" class="operate">
                                             <a>联系卖家 <img src="static/img/seekPurchase/link-buyer.png" alt=""></a>
                                             <span>立即购买</span>
@@ -552,8 +582,8 @@
                                 <thead>
                                 <tr>
                                     <th width="173">卖家</th>
-                                    <th width="196">交期(天)</th>
-                                    <th width="196">单价</th>
+                                    <th width="186">交期(天)</th>
+                                    <th width="186">单价</th>
                                     <th width="212">生产日期</th>
                                     <th width="221">操作</th>
                                 </tr>
@@ -564,12 +594,12 @@
                                     <tbody>
                                     <tr ng-repeat="of in offer">
                                         <td width="173" ng-bind="(of.enterprise).enName"></td>
-                                        <td width="196" class="red-text" ng-bind="of.minDay+'-'+of.maxDay">4-6</td>
-                                        <td width="196"><span ng-bind="of.currency+of.unitPrice">$9.86</span></td>
+                                        <td width="186" class="red-text" ng-bind="of.minDay+'-'+of.maxDay">4-6</td>
+                                        <td width="186"><span ng-bind="of.currency+of.unitPrice">$9.86</span></td>
                                         <td width="212" ng-bind="of.produceDate | date: 'yyyy-MM-dd'"></td>
                                         <td width="221" class="operate">
                                             <a href = "of.user.usertTel">联系卖家 <img src="static/img/seekPurchase/link-buyer.png" alt=""></a>
-                                            <span>采纳报价</span>
+                                            <span ng-click="setShowUseFlag(true, of)">采纳报价</span>
                                         </td>
                                     </tr>
                                     </tbody>
@@ -591,16 +621,16 @@
             </tbody>
         </table>
     </div>
-    <div class="com-del-box">
+    <div class="com-del-box" ng-show="showUseFlag">
         <div class="title">
-            <i></i>
+            <i ng-click="setShowUseFlag(false)"></i>
         </div>
         <div class="content">
             <p><i class="fa fa-exclamation-circle"></i>是否要采纳此报价?</p>
             <div class="remind-line"><i class="red-text">*</i>点击【确认】后默认终止该求购</div>
-            <div class="input-line"><i class="red-text">*</i>采购数量&nbsp;<input type="text" placeholder="请输入采购数量" class="form-control"></div>
+            <div class="input-line"><i class="red-text">*</i>采购数量&nbsp;<input type="number" placeholder="请输入采购数量" class="form-control"></div>
             <div class="btn-line">
-                <a>取消</a>
+                <a ng-click="setShowUseFlag(false)">取消</a>
                 <a>确认</a>
             </div>
         </div>