Explorar o código

处理出入库数据验证

wangcz %!s(int64=7) %!d(string=hai) anos
pai
achega
01e1867064

+ 27 - 9
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_storageCtrl.js

@@ -300,6 +300,16 @@ define([ 'app/app' ], function(app) {
             })
         }
 
+        $scope.chickAmountBlur = function (item, num) {
+            if($scope.storage_tab === 'outBound') {
+                if(num === 0) {
+                    toaster.pop('info', '提示', '该型号在产品库中库存数量为0,不能出库!');
+                } else if(item.erpReserve && (num > item.erpReserve)) {
+                    toaster.pop('info', '提示', '出库量数量不能大于库存数!');
+                }
+            }
+        }
+
         $scope.onChange = function (type) {
             angular.forEach($scope.otherData, function(val) {
                 val.show = false;
@@ -332,8 +342,11 @@ define([ 'app/app' ], function(app) {
             type.kind = key.kind;
             type.spec = key.spec;
             type.id = key.id;
-            type.qty = key.erpReserve;
+            type.qty = ($scope.storage_tab === 'outBound' ? key.erpReserve : '');
             type.price = key.price;
+            if((!type.erpReserve || type.erpReserve === 0) && $scope.storage_tab === 'outBound'){
+                toaster.pop('info', '提示', '该型号在产品库中库存数量为0,不能出库!');
+            }
         };
 
         $scope.addOneTable = function (type) {
@@ -355,19 +368,24 @@ define([ 'app/app' ], function(app) {
                 return false
             }
             $scope.othenParam.detail = [];
-            var flag = false;
+            var flag = 0;
             angular.forEach($scope.otherData, function(val) {
                 if(val.id) {
-                    if(val.qty && val.price) {
+                    if(!val.erpReserve || val.erpReserve === 0 && $scope.storage_tab === 'outBound'){
+                        flag = 1
+                    } else if(val.erpReserve < val.qty) {
+                        flag = 2
+                    } else 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;
                     }
                 }
             })
-            if(!flag) {
-                toaster.pop('info', '提示', '请正确填写下面的信息内容!');
+            if(flag === 1) {
+                toaster.pop('info', '提示', '产品库中库存数量为0将不能出库!');
+                return;
+            }
+            if(flag === 2) {
+                toaster.pop('info', '提示', '出库量数量不能大于库存数!');
                 return;
             }
             Goods.saveOtherProductData({storage_tab: $scope.storage_tab, enName: $scope.othenParam.enName ? $scope.othenParam.enName : null}, $scope.othenParam.detail, function(data) {
@@ -599,7 +617,7 @@ define([ 'app/app' ], function(app) {
                     var _id = data.purchaseDetails[i].id
                     _obj.push({
                         id: _id,
-                        qty: data.purchaseDetails[i].sendCount
+                        qty: Number(data.purchaseDetails[i].sendCount)
                     })
                 }
             }

+ 8 - 9
src/main/webapp/resources/view/vendor/forstore/vendor_storage.html

@@ -1237,7 +1237,6 @@
                     <th width="120" ng-bind="storage_tab === 'inBound' ? '入库单号' : '出库单号'"></th>
                     <th width="180" ng-bind="storage_tab === 'inBound' ? '发货单' : '订单号'" ng-if="handleItem === 2"></th>
                     <th width="180" ng-bind="storage_tab === 'inBound' ? '卖家名称' : '买家名称'"></th>
-                    <th class="filter" width="110" ng-if="handleItem == 2">类型</th>
                     <th class="filter" width="110" ng-if="handleItem === 0">
                         <a ng-bind="selfSupport">全部类型</a> <i class="fa fa-angle-down fa-angle-up"></i>
                         <div class="hover-show" ng-if="storage_tab === 'inBound'">
@@ -1251,7 +1250,7 @@
                             <a ng-click="changeSupportType('SELL_OUTBOUND')" ng-bind="boundType.SELL_OUTBOUND">销售出库</a>
                         </div>
                     </th>
-                    <th width="90">录入人</th>
+                    <th width="90" ng-if="handleItem !== 2">录入人</th>
                     <th width="170">录入日期</th>
                     <th width="170" class="padding0">操作</th>
                 </tr>
@@ -1326,7 +1325,8 @@
                                 <th width="110"><em class="red_color">*</em>型号</th>
                                 <th width="130">品牌</th>
                                 <th>物料名称</th>
-                                <th width="210">规格</th>
+                                <th width="180">规格</th>
+                                <th width="130">库存数(PCS)</th>
                                 <th width="130"><em class="red_color">*</em>{{storage_tab === 'inBound' ? '入库数' : '出库数'}}(PCS)</th>
                                 <th width="130">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                             </tr>
@@ -1353,7 +1353,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" class="form-control" ng-model="item.qty" ng-change="onAmountChange(item, item.qty, 'qty', 9)"></td>
+                                <td><span ng-bind="item.erpReserve || '-'" title="{{item.erpReserve}}"></span></td>
+                                <td><input type="text" class="form-control" ng-model="item.qty" ng-change="onAmountChange(item, item.qty, 'qty', 9)" ng-blur="chickAmountBlur(item, item.qty)"></td>
                                 <td><input type="text" class="form-control" ng-model="item.price" ng-change="onAmountChange(item, item.price, 'price', 4, 6)"></td>
                             </tr>
                             <tr>
@@ -1376,14 +1377,12 @@
                     <td ng-if="storage_tab === 'outBound'"><span ng-bind="item.purchaseid || '-'" title="{{item.purchaseid}}"></span></td>
                     <td ng-if="storage_tab === 'inBound'"><span ng-bind="item.invoiceid || '-'" title="{{item.invoiceid}}"></span></td>
                     <td><span ng-bind="item.buyentername || item.buyerentername || item.buyername" title="{{item.buyentername || item.buyerentername || item.buyername}}"></span></td>
-                    <td ng-bind="storage_tab === 'outBound' ? '销售出库' : '采购入库'">腌肉入库</td>
-                    <td><span ng-bind="item.sellername" title="{{item.sellername}}"></span></td>
                     <td ng-bind="item.createtime | date: 'yyyy-MM-dd'"></td>
                     <td ng-if="!item.seleted"><a class="btn-click" ng-click="item.seleted = !item.seleted;unfoldClick(storageList, item)" ng-bind="storage_tab === 'inBound' ? '收货入库' : '发货出库'"></a></td>
                     <td ng-if="item.seleted"><a class="btn-click" ng-click="saveOtherCheck(item, storage_tab)">确定</a><a class="btn-click" ng-click="item.seleted = !item.seleted">取消</a></td>
                 </tr>
                 <tr ng-if="item.seleted && storage_tab === 'outBound'">
-                    <td colspan="7" style="background:#f5f5f5;">
+                    <td colspan="5" style="background:#f5f5f5;">
                         <div class="logistics-info">
                             <span style="margin-right:150px;">所属订单:<span ng-bind="item.associateOrderid || '-'"></span></span>
                             <span>物流公司 :&nbsp;</span>
@@ -1411,7 +1410,7 @@
                     </td>
                 </tr>
                 <tr ng-if="item.seleted && storage_tab === 'inBound' && item.logistics">
-                    <td colspan="7" style="background:#f5f5f5;">
+                    <td colspan="5" style="background:#f5f5f5;">
                         <div class="logistics-info">
                             <span style="margin-right:150px;">所属订单:<span ng-bind="item.associateOrderid || item.orid || '-'"></span></span>
                             <span>物流公司 :&nbsp;</span>
@@ -1423,7 +1422,7 @@
                     </td>
                 </tr>
                 <tr ng-show="item.seleted">
-                    <td colspan="7">
+                    <td colspan="5">
                         <div class="sub-table-head">
                             <table class="wanted-sub-tab table">
                                 <thead>