Browse Source

出入库数据接口

wangcz 7 years ago
parent
commit
067c61cc22

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

@@ -538,7 +538,7 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
             controller : 'vendor_onSaleCtrl'
         })).state('vendor_storage', angularAMD.route({
             title : '出入库',
-            url : '/vendor_storage',
+            url : '/vendor_storage?storage_tab&ids',
             templateUrl : 'static/view/vendor/forstore/vendor_storage.html',
             controllerUrl : "app/controllers/forstore/vendor_storageCtrl",
             controller : 'vendor_storageCtrl'

+ 106 - 16
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_storageCtrl.js

@@ -1,15 +1,19 @@
 define([ 'app/app' ], function(app) {
     'use strict';
-    app.register.controller('vendor_storageCtrl', ['$scope', '$rootScope', 'BaseService', 'Goods', 'KdnLogistics', '$modal', 'toaster', 'Loading', 'AuthenticationService', '$q', '$upload', '$http', 'ngTableParams',function ($scope, $rootScope, BaseService, Goods, KdnLogistics, $modal, toaster, Loading, AuthenticationService, $q, $upload, $http, ngTableParams) {
+    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) {
         $rootScope.active = 'vendor_storage';
         $scope.keyword = '';
         $scope.type = '';
         $scope.tab = 'storage';
         $scope.isInt = /^[0-9]*[1-9][0-9]*$/;
         document.title = '卖家出入库-优软商城';
-        $scope.storage_tab = 'outBound';
+        $scope.storage_tab = $stateParams.storage_tab? $stateParams.storage_tab : 'inBound';
         $scope.countData = 10;
         $scope.userInfo = $rootScope.userInfo || {}
+        console.log($stateParams)
+
+        //数字的正则表达式
+        var intPattern = /^[1-9]+$/;
 
         // 更多操作数据和记录
         $scope.handleLink = [
@@ -19,8 +23,8 @@ define([ 'app/app' ], function(app) {
             {name: '查看出库记录', tab: 'outBound', id: 0},
             {name: '其它出库', tab: 'outBound', id: 1},
             {name: '销售出库', tab: 'outBound', id: 2}];
-        // $scope.handleItem = $scope.storage_tab === 'inBound'? $scope.handleLink[0].id : $scope.handleLink[3].id;
-        $scope.handleItem = 2;
+        $scope.handleItem = $stateParams.storage_tab ? 1 : ($scope.storage_tab === 'inBound'? $scope.handleLink[0].id : $scope.handleLink[3].id);
+        // $scope.handleItem = 2;
 
         $scope.lockData = [
             {id: 1,seleted: false, maiName: '324134', selfSupport: '腌肉入库', uuid: '张三1', date: 340325435434535, content: [{code: 'w324', code1: '342', code2: '2144'},{code: 'w324', code1: '342', code2: '2144'},{code: 'w324', code1: '342', code2: '2144'},{code: 'w324', code1: '342', code2: '2144'}]},
@@ -207,13 +211,13 @@ 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
                     }
                     if($scope.storage_tab === 'outBound' && $scope.handleItem === 2) {
                         param.sorting = {"createtime":"DESC"};
                         param.status = '502-406';
-                        param.storeType = 'mall';
                         param.startMils = $scope.startDate ? $scope.startDate.getTime() : null;
                         param.endMils = $scope.endDate ? $scope.endDate.getTime() : null;
                     } else {
@@ -221,21 +225,23 @@ define([ 'app/app' ], function(app) {
                         param.fromDate = $scope.startDate ? $scope.startDate.getTime() : null;
                         param.toDate = $scope.endDate ? $scope.endDate.getTime() : null;
                     }
-                    Goods[getUrl()](param, function(data) {
-                        $scope.storageList = data.content
-                        console.log(data.content, ';data')
-                        params.total(data.totalElements);
-                        $defer.resolve(data.content);
-                    }, function(err) {
-                        toaster.pop('error', '获取信息失败')
-                    })
+                    if ($scope.handleItem !== 1) {
+                        Goods[getUrl()](param, function(data) {
+                            $scope.storageList = data.content
+                            params.total(data.totalElements);
+                            $defer.resolve(data.content);
+                        }, function(err) {
+                            toaster.pop('error', '获取信息失败')
+                        })
+                    }
                 }
             })
         };
         getLoadStorageData();
 
         // 搜索功能
-        $scope.onSearch = function () {
+        $scope.onSearch = function (type) {
+            $scope.keyword = type;
             getLoadStorageData();
         };
 
@@ -299,10 +305,31 @@ define([ 'app/app' ], function(app) {
                 }
             })
             Goods.saveOtherProductData({storage_tab: $scope.storage_tab, enName: $scope.othenParam.enName}, $scope.othenParam.detail, function(data) {
-                console.log(data)
+                if(data.code === 1) {
+                    toaster.pop('success', '申请成功!');
+                    initOtherData();
+                }
             })
         };
 
+
+        //加载发货地址
+        var loadAddrs = function() {
+            ShippingAddress.getListEnterprise({ship : false}, function(data) {
+                $scope.addresss = data;
+                $scope.total = $scope.addresss.length;
+                $scope.jsonSdAddress = {};
+                if($scope.addresss.length > 0) {
+                    $scope.jsonSdAddress = $scope.addresss[0];
+                    $scope.jsonSdAddress.area = $scope.jsonSdAddress.area.replace(/,/g,' ');
+                }
+            }, function(res) {
+                toaster.pop('error', '错误', res.data);
+            });
+        };
+
+        loadAddrs();
+
         // 获取物流公司信息
         $scope.initData = function () {
             Goods.findAllSelected({},function (data) {
@@ -329,9 +356,9 @@ define([ 'app/app' ], function(app) {
             })
         };
         $scope.findAllKdnList();
+
         $scope.logistics = {};
         $scope.showText = function (data) {
-            console.log(data, 'data')
             $scope.logistics.companyName = data.companyName;
             $scope.companyObject = data;
             $scope.showCompanyName = false;
@@ -424,6 +451,69 @@ define([ 'app/app' ], function(app) {
             });
         };
 
+        //数量进行验证
+        $scope.ChangeSendCount = function(details, val) {
+            var newShipQty = details.shipQty ? details.shipQty : 0
+            if (val > details.number - newShipQty) {
+                toaster.pop('warning', '提示', '本次发货数量不能大于已剩数量')
+                val = details.number - newShipQty
+            }
+            details.sendCount = val
+        };
+
+        // 销售出库确认发货
+        $scope.saveOtherCheck = function (data) {
+            console.log(data, 'data')
+            if(!$scope.jsonSdAddress || angular.equals({}, $scope.jsonSdAddress)) {
+                toaster.pop("info", "提示", "发货地址不能为空,请前往物流管理新增发货地址");
+                return ;
+            }
+            var sendInfo = {};
+            sendInfo.sendType = data.sendType;
+            if ($scope.logistics.companyName && $scope.logistics.number){
+                sendInfo.logisticsInfo = {};
+                sendInfo.logisticsInfo.companyName = $scope.logistics.companyName;
+                sendInfo.logisticsInfo.number = $scope.logistics.number;
+            }
+            var HasCount = false
+            var _obj = []
+            for (var i = 0; i < data.purchaseDetails.length; i++) {
+                if (Math.abs(data.purchaseDetails[i].sendCount) > 0) {
+                    HasCount = true
+                    var _id = data.purchaseDetails[i].id
+                    _obj.push({
+                        id: _id,
+                        qty: data.purchaseDetails[i].sendCount
+                    })
+                }
+            }
+            if (!HasCount) {
+                toaster.pop("info", "提示", "最少填写一个发货数量");
+                return ;
+            }
+            sendInfo.map = _obj
+            sendInfo.jsonSdAddress = angular.toJson($scope.jsonSdAddress);
+            InvoiceFPurchase.saveInvoiceFPurchase({id : data.id}, sendInfo, function(res) {
+
+                // TODO 这边要停5秒钟之后,在跳转到出货单管理界面
+                /*var fromPage = window.sessionStorage.getItem("orderAdmin");
+                 if(fromPage == "invoiceProofing") {
+                 $state.go('invoiceProofing');
+                 }else {
+                 $state.go('invoice');
+                 }*/
+                // TODO huxz 跳转到订单管理页面
+                if (res.success) {
+                    toaster.pop("success", "信息", "发货成功");
+                    $state.go('vendor_order');
+                } else {
+                    toaster.pop("error", res.message);
+                }
+            }, function(response) {
+                toaster.pop('error', '错误', response.data);
+            });
+        };
+
 
         //获取登录的信息
         var getAuthentication = function () {

+ 26 - 12
src/main/webapp/resources/view/vendor/forstore/vendor_storage.html

@@ -1154,17 +1154,17 @@
                 <label class="com-check-radio">
                     <input type="radio" id="oneMonth" name="date" ng-click="setFilters('dateArea', 'oneMonth')" ng-checked="dateArea == 'oneMonth'">
                     <label for="oneMonth"></label>
-                    一个月
+                    30天
                 </label>
                 <label class="com-check-radio">
                     <input type="radio" id="threeMonth" name="date" ng-click="setFilters('dateArea', 'threeMonth')" ng-checked="dateArea == 'threeMonth'">
                     <label for="threeMonth"></label>
-                    三个月
+                    60天
                 </label>
                 <label class="com-check-radio">
                     <input type="radio" id="sixMonth" name="date" ng-click="setFilters('dateArea', 'sixMonth')" ng-checked="dateArea == 'sixMonth'">
                     <label for="sixMonth"></label>
-                    六个月
+                    180天
                 </label>
                 <label class="com-check-radio">
                     <input type="radio" id="autoMonth" name="date" ng-click="setFilters('dateArea', 'autoMonth')" ng-checked="dateArea == 'autoMonth'">
@@ -1172,8 +1172,8 @@
                     自定义
                 </label>
                 <div class="search fr check">
-                    <input type="text" class="form-control" ng-model="keyword" ng-search="onSearch()" placeholder="发货单/卖家"/>
-                    <button ng-click="onSearch()" style="float: left;">搜索</button>
+                    <input type="text" class="form-control" ng-model="keyword" ng-search="onSearch(keyword)" placeholder="发货单/卖家"/>
+                    <button ng-click="onSearch(keyword)" style="float: left;">搜索</button>
                 </div>
             </div>
             <div class="radio-block">
@@ -1337,8 +1337,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"></td>
-                                <td><input type="text" class="form-control" ng-model="item.price"></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>
                             </tr>
                             <tr>
                                 <td colspan="7">
@@ -1363,7 +1363,7 @@
                     <td ng-bind="item.buyentername || item.buyername">张三</td>
                     <td ng-bind="item.createtime | date: 'yyyy-MM-dd'">2018-12-12</td>
                     <td ng-if="!item.seleted"><a class="btn-click" ng-click="item.seleted = !item.seleted;unfoldClick(storageList, item)" ng-bind="storage_tab === 'inPut' ? '收货入库' : '发货出库'"></a></td>
-                    <td ng-if="item.seleted"><a class="btn-click">确定</a><a class="btn-click">取消</a></td>
+                    <td ng-if="item.seleted"><a class="btn-click" ng-click="saveOtherCheck(item)">确定</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;">
@@ -1413,15 +1413,18 @@
                         </div>
                         <div style="max-height:300px;overflow-y: auto;">
                             <table class="wanted-sub-tab table">
-                                <tr ng-repeat="(index, list) in item.purchaseDetails">
-                                    <td width="60" ng-bind="index + 1"></td>
+                                <tr ng-repeat="list in item.purchaseDetails">
+                                    <td width="60" ng-bind="$index + 1"></td>
                                     <td width="150"><span ng-bind="list.batchCode || '-'" title="{{list.batchCode}}"></span></td>
                                     <td width="110"><span ng-bind="list.brName || '-'" title="{{list.brName}}"></span></td>
                                     <td><span ng-bind="list.kiName || '-'" title="{{list.kiName}}"></span></td>
                                     <td width="180"><span ng-bind="list.spec || '-'" title="{{list.spec}}"></span></td>
                                     <td width="100" ng-if="storage_tab === 'outBound'"><span ng-bind="list.number || '-'" title="{{list.number}}"></span></td>
                                     <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-if="list.number !== list.shipQty" class="form-control"></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="ChangeSendCount(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>
                             </table>
@@ -1430,6 +1433,15 @@
                 </tr>
                 </tbody>
             </table>
+            <div class="empty" ng-if="handleItem !== 1 && (!storageList || storageList.length == 0)">
+                <p class="empty-img">
+                    <img src="static/img/all/empty-cart.png">
+                </p>
+                <div class="empty-info">
+                    <p class="grey"> 暂无相关记录 </p>
+                    <!--<a href="vendor#/vendor_upload?type=company"><i></i>马上去上传</a>-->
+                </div>
+            </div>
         </div>
     </div>
 </div>
@@ -1523,7 +1535,9 @@
         display:inline-flex;
         justify-content:center;
         align-items: center;
-        height:360px;
+        height: 265px;
+        margin-top: -20px;
+        background: #fff;
     }
     .wanted_list .empty-info{
         line-height: 28px;