Browse Source

处理验证问题

wangcz 7 years ago
parent
commit
c964dbb8f5

+ 69 - 22
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_storageCtrl.js

@@ -11,16 +11,6 @@ define([ 'app/app' ], function(app) {
         $scope.countData = 10;
         $scope.userInfo = $rootScope.userInfo || {};
 
-
-        /**
-         * 最大出入库数
-         * @type {number}
-         */
-        $scope.maxReserve = 999999999;
-        //数字的正则表达式
-        var intPattern = /^[1-9]+$/;
-        $scope.isInt = /^[0-9]*[1-9][0-9]*$/;
-
         // 更多操作数据和记录
         $scope.handleLink = [
             {name: '查看入库记录', tab: 'inBound', id: 0},
@@ -30,7 +20,6 @@ define([ 'app/app' ], function(app) {
             {name: '其它出库', tab: 'outBound', id: 1},
             {name: '销售出库', tab: 'outBound', id: 2}];
         $scope.handleItem = $stateParams.storage_tab ? 1 : ($scope.storage_tab === 'inBound'? $scope.handleLink[0].id : $scope.handleLink[3].id);
-        // $scope.handleItem = 2;
 
         // 销售方式数据
         $scope.boundType = {
@@ -148,6 +137,7 @@ define([ 'app/app' ], function(app) {
             $scope.storage_tab = type;
             $scope.type = $scope.storage_tab === 'inBound'? 'INBOUND' : 'OUTBOUND';
             getLoadStorageData();
+            initOtherData();
         };
 
         // 操作类型切换
@@ -156,6 +146,7 @@ define([ 'app/app' ], function(app) {
             if(type !== 1) {
                 getLoadStorageData();
             }
+            initOtherData();
             clearRecordParams();
         };
         // 销售方式筛选
@@ -292,10 +283,40 @@ define([ 'app/app' ], function(app) {
             })
         };
 
+        // 点击外面清除弹窗
+        $scope.clearOtherData = function() {
+            angular.forEach($scope.otherData, function(val) {
+                val.show = false;
+                if(!val.id){
+                    val.pbranden = '';
+                    val.key = '';
+                    val.kind = '';
+                    val.spec = '';
+                    val.qty = '';
+                    val.price = '';
+                }
+            })
+        }
+
         $scope.onChange = function (type) {
+            angular.forEach($scope.otherData, function(val) {
+                val.show = false;
+            })
             type.show = true;
             Goods.getKeywordToProductId({keyword: type.key}, function(data) {
-                $scope.listData = data
+                if(data.length <= 0) {
+                    toaster.pop('info', '提示', '该型号不存在你的产品库中!');
+                    type.pbranden = '';
+                    type.key = '';
+                    type.kind = '';
+                    type.spec = '';
+                    type.qty = '';
+                    type.price = '';
+                    $scope.listData = [];
+                    type.show = false;
+                } else {
+                    $scope.listData = data
+                }
             }, function (res) {
                 $scope.listData = [];
                 type.show = false;
@@ -309,6 +330,8 @@ define([ 'app/app' ], function(app) {
             type.kind = key.kind;
             type.spec = key.spec;
             type.id = key.id;
+            type.qty = key.erpReserve;
+            type.price = key.price;
         };
 
         $scope.addOneTable = function (type) {
@@ -495,21 +518,45 @@ define([ 'app/app' ], function(app) {
         };
 
         //数量进行验证
-        $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;
+        $scope.onAmountChange = function (item, val, type, key, deg) {
+            if (deg) {
+                if (angular.isNumber(Number(val))) {
+                    if (val >= 10000) {
+                        item[type] = Number(val.toString().substring(0, key));
+                    } else if (val.toString().indexOf('.') > -1) {
+                        var arr = val.toString().split(".");
+                        if (arr[0].length > key) {
+                            item[type] = Number(arr[0].substring(0, key) + '.' + arr[1]);
+                        } else if (arr[1].length > deg) {
+                            item[type] = Number(arr[0] + '.' + arr[1].substring(0, deg));
+                        }
                     }
+                } else {
+                    item[type] = ''
+                }
+            } else {
+                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);
                 }
-                item[type] = cutOutString(val, chineseIndex);
-            } else if (val.length > key) {
-                item[type] = cutOutString(val, key);
             }
         };
 
+        $scope.checkAmount = function (item, val, type) {
+            $scope.validObj.amount = $scope.applyObj.amount === '' ? true
+                : $scope.applyObj.amount > 0 && $scope.applyObj.amount
+                < 1000000000;
+            return $scope.validObj.amount;
+        }
+
         $scope.outBlurSendCount = function(details, val) {
             var newShipQty = details.shipQty ? details.shipQty : 0
             if (val > details.number - newShipQty) {

+ 13 - 14
src/main/webapp/resources/view/vendor/forstore/vendor_storage.html

@@ -1138,8 +1138,11 @@
         -webkit-border-radius: 5px !important;
         border-radius: 5px !important;
     }
+    .wanted_list em.red_color{
+        color:#f00;
+    }
 </style>
-<div class="user_right fr" ng-click="">
+<div class="user_right fr" ng-click="clearOtherData()">
     <!--货品管理-->
     <div class="pro_management device">
         <div class="com_tab">
@@ -1234,7 +1237,7 @@
                     <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 !== 0">类型</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'">
@@ -1261,7 +1264,7 @@
                     <td ng-bind="item.affiliatedEnterprise || '-'">深圳有陵县什么 翁一搂的</td>
                     <td ng-bind="boundType[item.opertatorType]">腌肉入库</td>
                     <td ng-bind="item.operaterUserName">张三</td>
-                    <td ng-bind="item.createTime | date : 'yyyy-MM-dd: hh:mm:ss'">2018-12-12 12:!@:</td>
+                    <td ng-bind="item.createTime | date : 'yyyy-MM-dd: HH:mm:ss'">2018-12-12</td>
                     <td><span class="btn-toggle" ng-show="item.seleted" ng-click="item.seleted = !item.seleted">收起 <i class="fa fa-angle-up"></i></span><span ng-click="unfoldClick(storageList,item)" class="btn-toggle" ng-show="!item.seleted">展开 <i class="fa fa-angle-down"></i></span></td>
                 </tr>
                 <tr ng-show="item.seleted">
@@ -1307,13 +1310,12 @@
                 <tr style="background:#f5f5f5;">
                     <td>系统自动生成</td>
                     <td><input type="text" class="form-control" ng-model="othenParam.enName"></td>
-                    <td ng-bind="storage_tab === 'inBound' ? '其它入库' : '其它出库'">其它入库</td>
                     <td ng-bind="userInfo.userName">张三</td>
                     <td ng-bind="newDate">2018-12-12</td>
                     <td><a class="btn-click" ng-click="otherAddClick()">确认</a><a class="btn-click" ng-click="otherAddClick('clear')">取消</a></td>
                 </tr>
                 <tr>
-                    <td colspan="6">
+                    <td colspan="5">
                         <table class="wanted-sub-tab table">
                             <caption>
                                 明细列表:
@@ -1321,11 +1323,11 @@
                             <thead>
                             <tr>
                                 <th width="60">序号</th>
-                                <th width="110">*型号</th>
+                                <th width="110"><em class="red_color">*</em>型号</th>
                                 <th width="130">品牌</th>
                                 <th>物料名称</th>
                                 <th width="210">规格</th>
-                                <th width="130">{{storage_tab === 'inBound' ? '*入库数' : '*出库数'}}(PCS)</th>
+                                <th width="130"><em class="red_color">*</em>{{storage_tab === 'inBound' ? '入库数' : '出库数'}}(PCS)</th>
                                 <th width="130">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                             </tr>
                             </thead>
@@ -1335,7 +1337,7 @@
                                 <td>
                                     <span ng-if="!item.newId" ng-bind="item.pcmpcode || '-'" title="{{item.pcmpcode}}"></span>
                                     <div class="down-form" ng-if="item.newId">
-                                        <input type="text" class="form-control" ng-model="item.key" ng-change="onChange(item)">
+                                        <input type="text" class="form-control" ng-model="item.key" ng-change="onChange(item, index)">
                                         <div ng-show="item.show" class="down-key" ng-mouseenter="item.show = true">
                                             <ul class="list-unstyled">
                                                 <li ng-repeat="list in listData" ng-click="addProductId(list, item)">
@@ -1344,9 +1346,6 @@
                                                     <span ng-bind="list.kind || '-'" title="{{list.kind}}"></span>
                                                     <span ng-bind="list.spec || '-'" title="{{list.spec}}"></span>
                                                 </li>
-                                                <li ng-if="listData.length <= 0">
-                                                    <div>没的找到与“{{item.key}}”产品信息</div>
-                                                </li>
                                             </ul>
                                         </div>
                                     </div>
@@ -1354,8 +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" 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>
+                                <td><input type="text" class="form-control" ng-model="item.qty" ng-change="onAmountChange(item, item.qty, 'qty', 9)"></td>
+                                <td><input type="text" class="form-control" ng-model="item.price" ng-change="onAmountChange(item, item.price, 'price', 4, 6)"></td>
                             </tr>
                             <tr>
                                 <td colspan="7">
@@ -1435,7 +1434,7 @@
                                     <th width="180">规格</th>
                                     <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="100"><em class="red_color">*</em>{{storage_tab === 'inBound' ? '入库数' : '出库数'}}(PCS)</th>
                                     <th width="80">单价({{currency === 'RMB' ? '¥' : '$'}})</th>
                                 </tr>
                                 </thead>