Browse Source

处理验证问题,和BOM新增接口

wangcz 7 years ago
parent
commit
9117f98d57

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

@@ -110,6 +110,11 @@ define([ 'ngResource' ], function() {
             deleteBom: {
                 url: 'seek/bom/delete',
                 method: 'DELETE'
+            },
+            // 新增物料信息
+            addEaterialObj: {
+                url: 'seek/bom/detail/add',
+                method: 'POST'
             }
 		});
 }])

+ 62 - 10
src/main/webapp/resources/js/usercenter/controllers/forstore/bomListDetailCtrl.js

@@ -49,6 +49,9 @@ define(['app/app'], function(app) {
         $scope.editBom = false;
         // 是否编辑询价
         $scope.editSeek = false;
+        // 是否新增物料
+        $scope.addNew = false;
+        $scope.newMateriel = [];
         // bom数据
         $scope.bomData = {};
         // 求购参数
@@ -124,7 +127,7 @@ define(['app/app'], function(app) {
                     }, function (err) {
                         toaster.pop('error', err.data);
                     })
-                } else {
+                } else if($scope.editSeek){
                     if (!$scope.seekObj.count) {
                         toaster.pop('error', '请输入采购数量');
                     } else if (!$scope.seekObj.endTime) {
@@ -168,14 +171,40 @@ define(['app/app'], function(app) {
                             })
                         }
                     }
+                } else {
+                    // 批量验证
+                    for (var i = 0; i < $scope.newMateriel.length; i++) {
+                        if (!$scope.checkAllProduct($scope.newMateriel[i])) {
+                            return;
+                        }
+                    }
+                    angular.forEach($scope.newMateriel, function(val){
+                        val.bomId = $scope.bomData.id
+                    })
+                    seekPurchase.addEaterialObj(null, $scope.newMateriel, function (data) {
+                        if (data.success) {
+                            toaster.pop('success', '新增物料成功');
+                            $scope.addNewMateriel(false);
+                            loadData();
+                            $scope.newMateriel = []
+                        } else {
+                            toaster.pop('error', data.message);
+                        }
+                    }, function (err) {
+                        toaster.pop('error', err.data);
+                    })
                 }
             } else {
                 if ($scope.editBom) {
                     // 取消BOM编辑
                     $scope.setEditBom(false);
-                } else {
+                } else if($scope.editSeek){
                     // 取消发布求购
                     $scope.setEditSeek(false);
+                } else {
+                    // 取消新增物料
+                    $scope.addNewMateriel(false);
+                    $scope.newMateriel = [];
                 }
             }
         }
@@ -186,6 +215,10 @@ define(['app/app'], function(app) {
                 toaster.pop('info', '请先保存求购信息');
                 return;
             }
+            if (editBom && $scope.addNew) {
+                toaster.pop('info', '请先保存新增物料');
+                return;
+            }
             // 编辑中临时数据
             $scope.tmpEditBom = angular.copy($scope.bomData);
             // 最少选中一个
@@ -209,6 +242,10 @@ define(['app/app'], function(app) {
                 toaster.pop('info', '请先保存BOM修改');
                 return;
             }
+            if (editSeek && $scope.addNew) {
+                toaster.pop('info', '请先保存新增物料');
+                return;
+            }
             if ($scope.editSeek) {
                 $scope.seekObj.endTime = '';
                 $scope.seekObj.count = '';
@@ -218,7 +255,29 @@ define(['app/app'], function(app) {
                 $scope.setAllCheck(false);
             }
             $scope.editSeek = editSeek;
-        }
+        };
+
+        // 新增单条物料信息
+        $scope.addNewMateriel = function (addNew) {
+            if (addNew && $scope.editSeek) {
+                toaster.pop('info', '请先保存求购信息');
+                return;
+            }
+            if (addNew && $scope.editBom) {
+                toaster.pop('info', '请先保存BOM修改');
+                return;
+            }
+            $scope.newMateriel.push({
+                brand: '',
+                kind: '',
+                code: '',
+                spec: '',
+                amount: 0
+            });
+            $scope.setAllCheck(false);
+            $scope.addNew = addNew;
+        };
+
         // 打开日期选择框
         $scope.openDatePicker = function ($event) {
             $event.preventDefault();
@@ -279,13 +338,6 @@ define(['app/app'], function(app) {
             })
         };
 
-        // 新增单条物料信息
-        $scope.addNewBom = function () {
-            $scope.bomData.seekPurchaseByBatchs.unshift({});
-            $scope.setEditBom(true);
-            $scope.onCheckAllCheck();
-        };
-
         // 删除BOM提示框
         $scope.showDeleteBomBox = false;
         $scope.setShowDeleteBomBox = function (flag) {

+ 70 - 25
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_storageCtrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app' ], function(app) {
     'use strict';
-    app.register.controller('vendor_storageCtrl', ['$scope', '$rootScope', '$stateParams', 'BaseService', 'Goods', 'KdnLogistics', '$modal', 'toaster', 'Loading', 'AuthenticationService', '$q', '$upload', '$http', 'ngTableParams', 'InvoiceFPurchase', 'ShippingAddress', function ($scope, $rootScope, $stateParams, BaseService, Goods, KdnLogistics, $modal, toaster, Loading, AuthenticationService, $q, $upload, $http, ngTableParams, InvoiceFPurchase, ShippingAddress) {
+    app.register.controller('vendor_storageCtrl', ['$scope', '$rootScope', '$stateParams', 'BaseService', 'Goods', 'KdnLogistics', '$modal', 'toaster', 'Loading', 'AuthenticationService', '$q', '$upload', '$http', 'ngTableParams', 'InvoiceFPurchase', 'ShippingAddress', 'Enterprise', function ($scope, $rootScope, $stateParams, BaseService, Goods, KdnLogistics, $modal, toaster, Loading, AuthenticationService, $q, $upload, $http, ngTableParams, InvoiceFPurchase, ShippingAddress, Enterprise) {
         $rootScope.active = 'vendor_storage';
         $scope.keyword = '';
         $scope.type = '';
@@ -9,11 +9,17 @@ define([ 'app/app' ], function(app) {
         document.title = '卖家出入库-优软商城';
         $scope.storage_tab = $stateParams.storage_tab? $stateParams.storage_tab : 'inBound';
         $scope.countData = 10;
-        $scope.userInfo = $rootScope.userInfo || {}
-        console.log($stateParams)
+        $scope.userInfo = $rootScope.userInfo || {};
 
+
+        /**
+         * 最大出入库数
+         * @type {number}
+         */
+        $scope.maxReserve = 999999999;
         //数字的正则表达式
         var intPattern = /^[1-9]+$/;
+        $scope.isInt = /^[0-9]*[1-9][0-9]*$/;
 
         // 更多操作数据和记录
         $scope.handleLink = [
@@ -67,6 +73,27 @@ define([ 'app/app' ], function(app) {
             return new Date(_formatDate(date, 'yyyy-MM-dd')).getTime() - 8 * 60 * 60 * 1000
         };
 
+        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;
+        }
+        var cutOutString = function (str, length) {
+            for (var i = 1; i <= str.length; i++) {
+                if (getRealLen(str.substr(0, i)) > length){
+                    str = str.substr(0, i-1);
+                    break;
+                }
+            }
+            return str;
+        };
+
         // 清空数据初始化数据
         var clearRecordParams = function () {
             $scope.dateArea = 'oneMonth'
@@ -80,6 +107,18 @@ define([ 'app/app' ], function(app) {
         };
         clearRecordParams();
 
+        //获取币别信息
+        Enterprise.getCurrencyByRegisterAddress(null, function (data) {
+            if(data.code === 1) {
+                $scope.currency = data.data;
+            }else {
+                toaster.pop('info', '提示', '您公司的注册地址为空,无法确定币别,系统默认为人民币');
+                $scope.currency = 'RMB';
+            }
+        }, function (response) {
+            toaster.pop('info', '提示', '获取不到公司的币别信息');
+        });
+
         // 其它出入库默认数据
         $scope.othenParam = {
             enName: '',
@@ -211,7 +250,6 @@ define([ 'app/app' ], function(app) {
                 total: 0,
                 getData: function ($defer, params) {
                     var param = BaseService.parseParams(params.url())
-                    console.log($scope.keyword, 'keyword')
                     if($scope.keyword){
                         param.keyword = $scope.keyword
                     }
@@ -292,17 +330,22 @@ define([ 'app/app' ], function(app) {
                 return false
             }
             $scope.othenParam.detail = [];
-            console.log($scope.otherData)
-            if(!$scope.othenParam.enName) {
-                toaster.pop('error', '请填写' + ($scope.storage_tab === 'inBound' ? '卖家名称' : '买家名称'));
-                return false
-            }
+            var flag = false;
             angular.forEach($scope.otherData, function(val) {
                 if(val.id) {
-                    $scope.othenParam.detail.push({productId: val.id, qty: 323, price: 4234})
+                    if(val.qty && val.price) {
+                        $scope.othenParam.detail.push({productId: val.id, qty: Number(val.qty), price: Number(val.price)});
+                        flag = true;
+                    }else {
+                        flag = false;
+                    }
                 }
             })
-            Goods.saveOtherProductData({storage_tab: $scope.storage_tab, enName: $scope.othenParam.enName}, $scope.othenParam.detail, function(data) {
+            if(!flag) {
+                toaster.pop('info', '提示', '请正确填写下面的信息内容!');
+                return;
+            }
+            Goods.saveOtherProductData({storage_tab: $scope.storage_tab, enName: $scope.othenParam.enName ? $scope.othenParam.enName : null}, $scope.othenParam.detail, function(data) {
                 if(data.code === 1) {
                     toaster.pop('success', '申请成功!');
                     initOtherData();
@@ -452,7 +495,22 @@ define([ 'app/app' ], function(app) {
         };
 
         //数量进行验证
-        $scope.ChangeSendCount = function(details, val) {
+        $scope.onAmountChange = function (item, val, type, key) {
+            if (!(/^[0-9]*$/).test(val)) {
+                var chineseIndex = -1;
+                for (var i = 0; i < val.length; i++) {
+                    if (!(/^[0-9]*$/).test(val.charAt(i))) {
+                        chineseIndex = i;
+                        break;
+                    }
+                }
+                item[type] = cutOutString(val, chineseIndex);
+            } else if (val.length > key) {
+                item[type] = cutOutString(val, key);
+            }
+        };
+
+        $scope.outBlurSendCount = function(details, val) {
             var newShipQty = details.shipQty ? details.shipQty : 0
             if (val > details.number - newShipQty) {
                 toaster.pop('warning', '提示', '本次发货数量不能大于已剩数量')
@@ -552,18 +610,6 @@ define([ 'app/app' ], function(app) {
                 toaster.pop('info', '获取定单的信息' + response);
             });
         };
-
-          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;
-          }
     }]);
 
     // 设置物流公司
@@ -687,7 +733,6 @@ define([ 'app/app' ], function(app) {
 
         $scope.onKeyDown = function () {
             var dom = document.getElementById("ulContent");
-            // console.log(dom.scrollTop);
             if ($scope.showDownFrame && $scope.matchData){
                 if(event.keyCode == 40) { //监听到按下键
                     $scope.selectIndex ++;

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

@@ -202,6 +202,9 @@
         padding: 0 10px;
         text-align: center;
     }
+    .com-check-box{
+        cursor:pointer;
+    }
 </style>
 <div class="user_right fr bom-list-detail">
     <a class="back" href="user#/seekPurchase?type=bomManage&bomTab=bomList">&lt;返回BOM列表</a>
@@ -211,8 +214,8 @@
         <button class="operate-btn" ng-click="setEditBom(true)">编辑BOM</button>
         <button class="operate-btn" ng-click="deleteProduct()">删除物料</button>
         <button class="operate-btn" ng-click="deleteBom()">删除本BOM</button>
-        <button class="operate-btn" ng-click="addNewBom()">新增物料</button>
-        <div class="fr" ng-show="editBom || editSeek">
+        <button class="operate-btn" ng-click="addNewMateriel(true)">新增物料</button>
+        <div class="fr" ng-show="editBom || editSeek || addNew">
             <button class="sure-btn" ng-click="sure(true)">确认</button>
             <button class="sure-btn cancel-btn" ng-click="sure(false)">取消</button>
         </div>
@@ -266,6 +269,85 @@
             </tr>
         </thead>
         <tbody>
+            <tr ng-if="addNew" ng-repeat="(key, item) in newMateriel">
+                <td>
+                    <label class="com-check-box" ng-click="newMateriel.splice(key, 1);" ng-if="key !== 0">
+                        <span class="fa fa-close"></span>
+                    </label>
+                </td>
+                <td class="base-info">
+                    <div class="content-line">
+                        <div class="inline-block title">
+                            <i class="must">*</i>品牌:
+                        </div>
+                        <div class="inline-block" ng-class="{'similar-wrap': item.showSimilarBrandList}" title="{{item.brand}}">
+                            <input ng-model="item.brand"
+                                   ng-change="onBrandChange(item)"
+                                   ng-blur="checkBrand(item)"
+                                   type="text">
+                            <ul class="similar-list"
+                                ng-show="item.showSimilarBrandList"
+                                ng-mouseenter="item.isInBrandList = true;"
+                                ng-mouseleave="item.isInBrandList = false">
+                                <li ng-repeat="sBrand in similarBrand" ng-bind="sBrand.nameEn" title="{{sBrand.nameEn}}" ng-click="setBrand(item, sBrand.nameEn)"></li>
+                            </ul>
+                        </div>
+                    </div>
+                    <div class="content-line">
+                        <div class="inline-block title">
+                            <i class="must">*</i>物料名称:
+                        </div>
+                        <div class="inline-block" title="{{item.kind}}">
+                            <input ng-model="item.kind"
+                                   ng-change="onKindChange(item)"
+                                   ng-blur="checkKind(item)"
+                                   type="text">
+                        </div>
+                    </div>
+                </td>
+                <td class="base-info">
+                    <div class="content-line">
+                        <div class="inline-block title">
+                            <i class="must">*</i>型号:
+                        </div>
+                        <div class="inline-block" ng-class="{'similar-wrap': item.showSimilarCodeList}" title="{{item.code}}">
+                            <input ng-model="item.code"
+                                   ng-change="onCodeChange(item)"
+                                   ng-blur="checkCode(item)"
+                                   type="text">
+                            <ul class="similar-list"
+                                ng-show="item.showSimilarCodeList"
+                                ng-mouseenter="item.isInCodeList = true;"
+                                ng-mouseleave="item.isInCodeList = false">
+                                <li ng-repeat="sCode in similarCode" ng-bind="sCode.code" title="{{sCode.code}}" ng-click="setCode(item, sCode.code)"></li>
+                            </ul>
+                        </div>
+                    </div>
+                    <div class="content-line">
+                        <div class="inline-block title">
+                            规格:
+                        </div>
+                        <div class="inline-block" title="{{item.spec}}">
+                            <input ng-model="item.spec"
+                                   ng-change="onSpecChange(item)"
+                                   ng-blur="checkSpec(item)"
+                                   type="text">
+                        </div>
+                    </div>
+                </td>
+                <td class="base-info pcs-line">
+                    <div class="content-line">
+                        <div class="inline-block title">
+                            单位用量:
+                        </div>
+                        <div class="inline-block" title="{{item.amount}}">
+                            <input ng-model="item.amount"
+                                   ng-change="onAmountChange(item)"
+                                   type="text">
+                        </div>
+                    </div>
+                </td>
+            </tr>
             <tr ng-repeat="detail in bomData.seekPurchaseByBatchs track by $index">
                 <td>
                     <label class="com-check-box">

+ 25 - 23
src/main/webapp/resources/view/vendor/forstore/vendor_storage.html

@@ -937,7 +937,7 @@
         white-space: nowrap;
     }
     .wanted_list .wanted-tab tbody>tr>td{
-        padding:0;
+        padding:0 5px;
         line-height: 50px;
         height:50px;
         vertical-align: middle;
@@ -1184,20 +1184,6 @@
                     <label for="autoMonth"></label>
                     自定义
                 </label>
-                <div class="search fr check">
-                    <input type="text" class="form-control" ng-model="keyword" ng-search="onSearch(keyword)" placeholder="{{storage_tab =='outBound' ? '订单号/买家名称' : '发货单/卖家名称'}}"/>
-                    <button ng-click="onSearch(keyword)" style="float: left;">搜索</button>
-                </div>
-            </div>
-            <div class="radio-block">
-                更多操作:
-                <ul class="radio-btn list-inline">
-                    <li ng-repeat="item in handleLink"
-                        ng-bind="item.name"
-                        ng-class="{'active': handleItem === item.id}"
-                        ng-if="item.tab === storage_tab"
-                        ng-click="toggleType(item.id)"></li>
-                </ul>
                 <div class="radio-date" ng-show="dateArea === 'autoMonth'">
                     <div class="data-input">
                         <input id="start" type="text" ng-model="startDate" readonly="readonly"
@@ -1225,6 +1211,20 @@
                     </div>
                 </div>
             </div>
+            <div class="radio-block">
+                更多操作:
+                <ul class="radio-btn list-inline">
+                    <li ng-repeat="item in handleLink"
+                        ng-bind="item.name"
+                        ng-class="{'active': handleItem === item.id}"
+                        ng-if="item.tab === storage_tab"
+                        ng-click="toggleType(item.id)"></li>
+                </ul>
+                <div class="search fr check" ng-if="handleItem !== 1">
+                    <input type="text" class="form-control" ng-model="keyword" ng-search="onSearch(keyword)" placeholder="{{storage_tab =='outBound' ? '订单号/买家名称' : '发货单/卖家名称'}}"/>
+                    <button ng-click="onSearch(keyword)" style="float: left;">搜索</button>
+                </div>
+            </div>
         </div>
 
         <div class="wanted_list">
@@ -1280,7 +1280,7 @@
                                     <th>物料名称</th>
                                     <th width="210">规格</th>
                                     <th width="130">{{storage_tab === 'inBound' ? '入库数' : '出库数'}}(PCS)</th>
-                                    <th width="130">单价(¥)</th>
+                                    <th width="130">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                                 </tr>
                                 </thead>
                             </table>
@@ -1326,7 +1326,7 @@
                                 <th>物料名称</th>
                                 <th width="210">规格</th>
                                 <th width="130">{{storage_tab === 'inBound' ? '*入库数' : '*出库数'}}(PCS)</th>
-                                <th width="130">单价(¥)</th>
+                                <th width="130">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                             </tr>
                             </thead>
                             <tbody>
@@ -1354,8 +1354,8 @@
                                 <td><span ng-bind="item.pbranden || '-'" title="{{item.pbranden}}"></span></td>
                                 <td><span ng-bind="item.kind || '-'" title="{{item.kind}}"></span></td>
                                 <td><span ng-bind="item.spec || '-'" title="{{item.spec}}"></span></td>
-                                <td><input type="text" ng-pattern="/^[1-9]\d*$/" class="form-control" ng-model="item.qty"></td>
-                                <td><input type="text" ng-pattern="/^((\d)|(\d+\.?\d+))$/" class="form-control" ng-model="item.price"></td>
+                                <td><input type="text" ng-pattern="/^[1-9]\d*$/" class="form-control" ng-model="item.qty" ng-change="onAmountChange(item, item.qty, 'qty', 9)" ng-blur=""></td>
+                                <td><input type="text" ng-pattern="/^((\d)|(\d+\.?\d+))$/" class="form-control" ng-model="item.price" ng-change="onAmountChange(item, item.price, 'price', 4)" ng-blur=""></td>
                             </tr>
                             <tr>
                                 <td colspan="7">
@@ -1385,6 +1385,7 @@
                 <tr ng-if="item.seleted && storage_tab === 'outBound'">
                     <td colspan="7" style="background:#f5f5f5;">
                         <div class="logistics-info">
+                            <span style="margin-right:150px;">所属订单:<span ng-bind="item.associateOrderid || '-'"></span></span>
                             <span>物流公司 :&nbsp;</span>
                             <span class="input-ul">
                                 <input id="logistics-input" type="text" class="form-control select-adder" ng-focus="getItemFocus()"
@@ -1398,7 +1399,7 @@
                                   <a ng-click="addDistributor()">+&nbsp;新增配送商</a>
                                 </div>
                               </span>
-                            <span>物流单号 :&nbsp;</span>
+                            <span style="margin-left:100px;">物流单号 :&nbsp;</span>
                             <span style="margin-right: 20px; width: 160px;">
                             <form name="myForm" style="display:inline-block;width:140px;">
                               <!--ng-pattern="/^[A-Za-z0-9]+$/"-->
@@ -1412,9 +1413,10 @@
                 <tr ng-if="item.seleted && storage_tab === 'inBound' && item.logistics">
                     <td colspan="7" style="background:#f5f5f5;">
                         <div class="logistics-info">
+                            <span style="margin-right:150px;">所属订单:<span ng-bind="item.associateOrderid || '-'"></span></span>
                             <span>物流公司 :&nbsp;</span>
                             <span class="input-ul" ng-bind="item.logistics.companyName"></span>
-                            <span>物流单号 :&nbsp;</span>
+                            <span style="margin-left:100px;">物流单号 :&nbsp;</span>
                             <span style="margin-right: 20px;" ng-bind="item.logistics.number">
                             </span>
                         </div>
@@ -1434,7 +1436,7 @@
                                     <th width="100" ng-if="storage_tab === 'outBound'">应出库(PCS)</th>
                                     <th width="100" ng-if="storage_tab === 'outBound'">已出库(PCS)</th>
                                     <th width="100">{{storage_tab === 'inBound' ? '*入库数' : '*出库数'}}(PCS)</th>
-                                    <th width="80">单价(¥)</th>
+                                    <th width="80">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                                 </tr>
                                 </thead>
                             </table>
@@ -1464,7 +1466,7 @@
                                     <td width="100" ng-if="storage_tab === 'outBound'"><span ng-bind="list.shipQty || '-'" title="{{list.shipQty}}"></span></td>
                                     <td width="100">
                                         <span ng-if="list.number === list.shipQty">-</span>
-                                        <input type="text" ng-pattern="/^[1-9]\d*$/" ng-model="list.sendCount" ng-blur="ontChangeSendCount(list, list.sendCount)" ng-if="list.number !== list.shipQty" class="form-control">
+                                        <input type="text" ng-pattern="/^[1-9]\d*$/" ng-model="list.sendCount" ng-change="onAmountChange(list, list.sendCount, 'sendCount', 9)" ng-blur="outBlurSendCount(list, list.sendCount)" ng-if="list.number !== list.shipQty" class="form-control">
                                     </td>
                                     <td width="80"><span ng-bind="list.price || '-'" title="{{list.price}}"></span></td>
                                 </tr>