Browse Source

Merge remote-tracking branch 'origin/feature-201826-wangcz' into feature-201826-wangcz

dongbw 7 years ago
parent
commit
92ffeb26e2

+ 1 - 4
src/main/java/com/uas/platform/b2c/trade/seek/controller/SeekPurchaseBomController.java

@@ -24,10 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Page;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
 import java.io.IOException;

+ 20 - 0
src/main/webapp/resources/js/common/query/seekPurchase.js

@@ -80,6 +80,26 @@ define([ 'ngResource' ], function() {
             getBomListDetail: {
                 url: 'seek/bom/detail',
                 method: 'GET'
+            },
+            // 保存bom编辑
+            saveBomEdit: {
+                url: 'seek/bom/edit',
+                method: 'POST'
+            },
+            // 删除BOM信息
+            deleteBom: {
+                url: 'seek/bom/delete',
+                method: 'DELETE'
+            },
+            // 选中的物料询价BOM
+            confirmBomSeekSelected: {
+                url: 'seek/confirmBom/selected',
+                method: 'POST'
+            },
+            // 整个BOM发布询价
+            confirmBomSeekAll: {
+                url: 'seek/confirmBom',
+                method: 'POST'
             }
 		});
 }])

+ 1 - 1
src/main/webapp/resources/js/usercenter/app.js

@@ -427,7 +427,7 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
 			controller : 'downPaymentCtrl',
 			controllerUrl : 'app/controllers/forstore/buyer_down_payment_ctrl'
 		})).state('buyerSeekPurchase', angularAMD.route({
-			url: '/seekPurchase?type',
+			url: '/seekPurchase?type&bomTab',
 			templateUrl: 'static/view/usercenter/forstore/seekPurchase.html',
 			controller: 'seekPurchaseCtrl',
 			controllerUrl: 'app/controllers/forstore/seek_purchase_ctrl'

+ 173 - 8
src/main/webapp/resources/js/usercenter/controllers/forstore/bomListDetailCtrl.js

@@ -5,25 +5,190 @@ define(['app/app'], function(app) {
     'use strict';
     app.register.controller('bomListDetailCtrl', ['$scope', '$rootScope', 'ngTableParams', 'BaseService', 'toaster', 'Authority', '$stateParams', 'seekPurchase', function($scope, $rootScope, ngTableParams, BaseService, toaster, Authority, $stateParams, seekPurchase) {
         document.title = '我的求购-优软商城';
-        // 是否编辑物料中
+        // 获取数据
+        var loadData = function () {
+            seekPurchase.getBomListDetail({bomId: $stateParams.id}, function (data) {
+                $scope.bomData = data;
+                if ($scope.bomData.seekPurchaseByBatchs) {
+                    angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                        item.$checked = false;
+                    });
+                }
+            }, function (err) {
+                toaster.pop('error', err);
+            })
+        }
+        loadData();
+        // 是否编辑BOM
         $scope.editBom = false;
         // 是否编辑询价
         $scope.editSeek = false;
         // bom数据
         $scope.bomData = {};
+        // 求购参数
+        $scope.seekObj = {
+            // 截止时间
+            endTime: '',
+            // 采购套数
+            count: ''
+        }
+        // 是否打开时间选择框
+        $scope.endTimeOpen = {
+            open: false
+        };
+        // 是否全选
+        $scope.checkAll = false;
+        // 初始化是否全选
+        $scope.initCheckAll = function () {
+            var checkAll = true;
+            if ($scope.bomData.seekPurchaseByBatchs) {
+                angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                    if (!item.$checked) {
+                        checkAll = false;
+                    }
+                });
+            } else {
+                checkAll = false;
+            }
+            $scope.checkAll = checkAll;
+        }
+        // 点击全选
+        $scope.onCheckAllCheck = function () {
+            angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                item.$checked = $scope.checkAll;
+            });
+        }
+        $scope.setAllCheck = function (flag) {
+            $scope.checkAll = flag;
+            $scope.onCheckAllCheck();
+        }
 
+        // 取消/确认
+        $scope.sure = function (flag) {
+            if (flag) {
+                if ($scope.editBom) {
+                    // 保存BOM
+                    seekPurchase.saveBomEdit({}, $scope.tmpEditBom, function (data) {
+                        if (data.success) {
+                            toaster.pop('success', '保存成功');
+                            loadData();
+                            $scope.setEditBom(false);
+                        } else {
+                            toaster.pop('error', data.message);
+                        }
+                    }, function (err) {
+                        toaster.pop(err);
+                    })
+                } else {
+                    if (!$scope.seekObj.count) {
+                        toaster.pop('error', '请输入采购数量');
+                    } else if (!$scope.seekObj.endTime) {
+                        toaster.pop('error', '请输入截止时间');
+                    } else {
+                        if (!$scope.checkAll) {
+                            // 有无选中的
+                            var checkedItems = [];
+                            angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                                if (item.$checked) {
+                                    checkedItems.push(item.id)
+                                }
+                            });
+                            if (checkedItems.length == 0) {
+                                toaster.pop('error', '请选择发布的物料');
+                            } else {
+                                seekPurchase.confirmBomSeekSelected({
+                                    detailIds: checkedItems.join(','),
+                                    endTime: $scope.seekObj.endTime,
+                                    count: $scope.seekObj.count
+                                }, null, function (data) {
+                                    if (data.success) {
+                                        toaster.pop('success', '发布成功');
+                                        $scope.setEditSeek(false);
+                                    } else {
+                                        toaster.pop('error', data.message);
+                                    }
+                                }, function (err) {
+                                    toaster.pop('error', err);
+                                })
+                            }
+                        } else {
+                            seekPurchase.confirmBomSeekAll({
+                                bomId: $scope.bomData.id,
+                                endTime: $scope.seekObj.endTime,
+                                count: $scope.seekObj.count
+                            }, null, function (data) {
+                                if (data.success) {
+                                    toaster.pop('success', '发布成功');
+                                    $scope.setEditSeek(false);
+                                } else {
+                                    toaster.pop('error', data.message);
+                                }
+                            }, function (err) {
+                                toaster.pop('error', err);
+                            })
+                        }
+                    }
+                }
+            } else {
+                if ($scope.editBom) {
+                    // 取消BOM编辑
+                    $scope.setEditBom(false);
+                } else {
+                    // 取消发布求购
+                    $scope.setEditSeek(false);
+                }
+            }
+        }
+
+        // 设置是否编辑BOM
         $scope.setEditBom = function (editBom) {
+            if (editBom && $scope.editSeek) {
+                toaster.pop('info', '请先保存求购信息');
+                return;
+            }
+            // 编辑中临时数据
+            $scope.tmpEditBom = angular.copy($scope.bomData);
+            // 最少选中一个
+            var unlessCheckOne = false;
+            angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                if (item.$checked) {
+                    unlessCheckOne = true;
+                }
+            });
+            if (!unlessCheckOne) {
+                $scope.setAllCheck(true);
+            }
+            if (!editBom) {
+                $scope.setAllCheck(false);
+            }
             $scope.editBom = editBom;
         }
-
+        // 设置是否编辑询价
         $scope.setEditSeek = function (editSeek) {
+            if (editSeek && $scope.editBom) {
+                toaster.pop('info', '请先保存BOM修改');
+                return;
+            }
+            if ($scope.editSeek) {
+                $scope.endTime = '';
+                $scope.count = '';
+            }
+            if (!editSeek) {
+                $scope.setAllCheck(false);
+            }
             $scope.editSeek = editSeek;
         }
-
-        seekPurchase.getBomListDetail({bomId: $stateParams.id}, function (data) {
-            $scope.bomData = data;
-        }, function (err) {
-            toaster.pop('error', err);
-        })
+        // 打开日期选择框
+        $scope.openDatePicker = function ($event) {
+            $event.preventDefault();
+            $event.stopPropagation();
+            $scope.endTimeOpen.open = !$scope.endTimeOpen.open;
+        };
+        $scope.changeEndTime = function () {
+            if ($scope.seekObj.endTime) {
+                // 转换为23:59:59时间戳
+                $scope.seekObj.endTime = $scope.seekObj.endTime.getTime() + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000;
+            }
+        }
     }]);
 });

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

@@ -171,8 +171,12 @@ define(['app/app', 'clipboard', 'QRCode'], function (app, clipboard, QRCode) {
 
           seekPurchase.getSeekUrl({}, function(data) {
             $scope.seekUrl = data.url;
-            //   var seekUrl = 'http://10.1.51.82:24002';
-            /*$scope.tab = 'waitOffer';*/
+              if ($scope.activeType === 'bomManage') {
+                  if ($stateParams.bomTab) {
+                      $scope.bomTab = $stateParams.bomTab;
+                  }
+                  $scope.toogleBomTab($scope.bomTab);
+              }
             $scope.toogleTab = function (tab) {
               $scope.vendorType = 'self'
                 $scope.tab = tab;

+ 1 - 1
src/main/webapp/resources/view/usercenter/forstore/bomDetail.html

@@ -554,7 +554,7 @@
     <!--求购询价-->
     <div class="seek-purchase-content">
         <div class="BOM-header">
-            <a href="user#/seekPurchase?type=bomManage">&lt;返回BOM列表</a>
+            <a href="user#/seekPurchase?type=bomManage&bomTab=seekRecord">&lt;返回BOM列表</a>
             <div>
                 <div class="BOM-name-area" ng-show="!isEditName">
                     <span ng-bind="bomInfo.remark"></span>

+ 51 - 35
src/main/webapp/resources/view/usercenter/forstore/bomListDetail.html

@@ -46,7 +46,7 @@
         padding: 5px 30px;
         line-height: 50px;
     }
-    .bom-list-detail .bom-info .info-list li {
+    .bom-list-detail .bom-info .info-list .info-list-item {
         font-size: 14px;
         width: 33%;
         overflow: hidden;
@@ -61,20 +61,20 @@
     .bom-list-detail .bom-info .info-list.seek .spec {
         width: 33%;
     }
-    .bom-list-detail .bom-info .info-list li b {
+    .bom-list-detail .bom-info .info-list .info-list-item b {
         font-weight: bold;
     }
-    .bom-list-detail .bom-info .info-list li .bom-input {
+    .bom-list-detail .bom-info .info-list .info-list-item .bom-input {
         height: 30px;
         border-radius: 2px;
         border: 1px solid #dadada;
         padding: 0 10px;
         font-size: 14px;
     }
-    .bom-list-detail .bom-info .info-list li:nth-child(1) input {
+    .bom-list-detail .bom-info .info-list .info-list-item:nth-child(1) input {
         width: 218px;
     }
-    .bom-list-detail .bom-info .info-list li:nth-child(4) input {
+    .bom-list-detail .bom-info .info-list .info-list-item:nth-child(4) input {
         width: 253px;
     }
     .bom-list-detail .bom-info .info-list .expand {
@@ -85,6 +85,14 @@
     }
     .bom-list-detail .bom-info .info-list .date input {
         width: 146px;
+        display: inline-block;
+        cursor: pointer;
+    }
+    .bom-list-detail .bom-info .info-list .date .btn-default{
+        border: none;
+    }
+    .bom-list-detail .bom-info .info-list .date > ul {
+        line-height: normal;
     }
     .bom-list-detail .bom-list-table {
         width: 100%;
@@ -166,39 +174,47 @@
     }
 </style>
 <div class="user_right fr bom-list-detail">
-    <a class="back" href="user#/seekPurchase?type=bomManage">&lt;返回BOM列表</a>
+    <a class="back" href="user#/seekPurchase?type=bomManage&bomTab=bomList">&lt;返回BOM列表</a>
     <div class="operate">
         操作:
-        <button class="operate-btn" ng-click="setEditSeek(!editSeek)">发布求购</button>
-        <button class="operate-btn" ng-click="setEditBom(!editBom)">编辑BOM</button>
+        <button class="operate-btn" ng-click="setEditSeek(true)">发布求购</button>
+        <button class="operate-btn" ng-click="setEditBom(true)">编辑BOM</button>
         <button class="operate-btn">删除物料</button>
         <button class="operate-btn">删除本BOM</button>
-        <div class="fr">
-            <button class="sure-btn">确认</button>
-            <button class="sure-btn cancel-btn">取消</button>
+        <div class="fr" ng-show="editBom || editSeek">
+            <button class="sure-btn" ng-click="sure(true)">确认</button>
+            <button class="sure-btn cancel-btn" ng-click="sure(false)">取消</button>
         </div>
     </div>
     <div class="bom-info">
         <ul class="list-inline info-list" ng-class="{'seek': editSeek}">
-            <li>
+            <li class="info-list-item">
                 <b>BOM名称:
                     <span ng-show="!editBom" ng-bind="bomData.name"></span>
-                    <input class="bom-input" ng-show="editBom" type="text">
+                    <input class="bom-input" ng-show="editBom" ng-model="tmpEditBom.name" type="text">
                 </b>
             </li>
-            <li><b>本单共<span class="remind" ng-bind="bomData.amount || 0"></span>个产品</b></li>
-            <li>创建时间:{{bomData.releaseDate | date:'yyyy-MM-dd HH:mm:ss'}}</li>
-            <li class="spec">规格:
+            <li class="info-list-item"><b>本单共<span class="remind" ng-bind="bomData.amount || 0"></span>个产品</b></li>
+            <li class="info-list-item">创建时间:{{bomData.releaseDate | date:'yyyy-MM-dd HH:mm:ss'}}</li>
+            <li class="spec info-list-item">规格:
                 <span ng-show="!editBom" ng-bind="bomData.spec || '-'"></span>
-                <input class="bom-input" ng-show="editBom" type="text">
+                <input class="bom-input" ng-show="editBom" ng-model="tmpEditBom.spec" type="text">
             </li>
-            <li class="expand amount" ng-if="editSeek">
+            <li class="expand amount info-list-item" ng-if="editSeek">
                 <i class="must">*</i>采购数量(套):
-                <input class="bom-input" type="text">
+                <input class="bom-input" type="text" ng-model="seekObj.count">
             </li>
-            <li class="expand date" ng-if="editSeek">
+            <li class="info-list-item expand date" ng-if="editSeek">
                 <i class="must">*</i>截止时间:
-                <input class="bom-input" type="text">
+                <input type="text" ng-model="seekObj.endTime"
+                       class="bom-input select-adder" placeholder="截止时间"
+                       datepicker-popup="yyyy-MM-dd"
+                       is-open="endTimeOpen.open"
+                       min-date="startDate" current-text="今天" clear-text="清除" close-text="关闭"
+                       ng-click="openDatePicker($event)"
+                       datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
+                       ng-change="changeEndTime()"
+                />
             </li>
         </ul>
     </div>
@@ -207,7 +223,7 @@
             <tr>
                 <th>
                     <label class="com-check-box">
-                        <input type="checkbox" id="checkAll">
+                        <input type="checkbox" id="checkAll" ng-click="onCheckAllCheck()" ng-model="checkAll">
                         <label for="checkAll"></label>
                         <span class="check-all">全选</span>
                     </label>
@@ -218,11 +234,11 @@
             </tr>
         </thead>
         <tbody>
-            <tr>
+            <tr ng-repeat="detail in bomData.seekPurchaseByBatchs track by $index">
                 <td>
                     <label class="com-check-box">
-                        <input type="checkbox" id="1">
-                        <label for="1"></label>
+                        <input type="checkbox" id="{{$index}}" ng-click="initCheckAll()" ng-model="detail.$checked">
+                        <label for="{{$index}}"></label>
                     </label>
                 </td>
                 <td class="base-info">
@@ -231,8 +247,8 @@
                             <i class="must">*</i>品牌:
                         </div>
                         <div class="inline-block">
-                            <span ng-show="!editBom">123123123123</span>
-                            <input ng-show="editBom" ng-shw="editBom" type="text">
+                            <span ng-show="!editBom || !detail.$checked" ng-bind="detail.brand || '-'"></span>
+                            <input ng-show="editBom && detail.$checked"  ng-model="tmpEditBom.seekPurchaseByBatchs[$index].brand" type="text">
                         </div>
                     </div>
                     <div class="content-line">
@@ -240,8 +256,8 @@
                             <i class="must">*</i>物料名称:
                         </div>
                         <div class="inline-block">
-                            <span ng-show="!editBom">123123123123</span>
-                            <input ng-show="editBom" type="text">
+                            <span ng-show="!editBom || !detail.$checked" ng-bind="detail.kind || '-'"></span>
+                            <input ng-show="editBom && detail.$checked" ng-model="tmpEditBom.seekPurchaseByBatchs[$index].kind" type="text">
                         </div>
                     </div>
                 </td>
@@ -251,8 +267,8 @@
                             <i class="must">*</i>型号:
                         </div>
                         <div class="inline-block">
-                            <span ng-show="!editBom">123123123123</span>
-                            <input ng-show="editBom" type="text">
+                            <span ng-show="!editBom || !detail.$checked" ng-bind="detail.code || '-'"></span>
+                            <input ng-show="editBom && detail.$checked" ng-model="tmpEditBom.seekPurchaseByBatchs[$index].code" type="text">
                         </div>
                     </div>
                     <div class="content-line">
@@ -260,8 +276,8 @@
                             <i class="must">*</i>规格:
                         </div>
                         <div class="inline-block">
-                            <span ng-show="!editBom">123123123123</span>
-                            <input ng-show="editBom" type="text">
+                            <span ng-show="!editBom || !detail.$checked" ng-bind="detail.spec || '-'"></span>
+                            <input ng-show="editBom && detail.$checked" ng-model="tmpEditBom.seekPurchaseByBatchs[$index].spec" type="text">
                         </div>
                     </div>
                 </td>
@@ -271,8 +287,8 @@
                             单位用量:
                         </div>
                         <div class="inline-block">
-                            <span ng-show="!editBom">123123123123</span>
-                            <input ng-show="editBom" type="text">
+                            <span ng-show="!editBom || !detail.$checked" ng-bind="detail.amount || '-'"></span>
+                            <input ng-show="editBom && detail.$checked" ng-model="tmpEditBom.seekPurchaseByBatchs[$index].amount" type="text">
                         </div>
                     </div>
                 </td>