Преглед изворни кода

针对公共询价报价操作时,增加分段报价校验:1、分段数必须递增,不符合会给出提示;2、分段数据未填写给出提示

hejq пре 8 година
родитељ
комит
1cb7966be3
1 измењених фајлова са 63 додато и 25 уклоњено
  1. 63 25
      src/main/webapp/resources/js/index/app.js

+ 63 - 25
src/main/webapp/resources/js/index/app.js

@@ -5583,14 +5583,27 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         // 增加一列分段报价
         $scope.addStep = function (inquiryItem) {
-            $scope.replyPrices.push(true);
-            if (inquiryItem.replies.length >= 5) {
-                toaster.pop('warning', '提示', '最多支持5个分段!');
-            } else {
-                inquiryItem.replies.push({});
-                if (inquiryItem.replies.length != 1) {
-                    $scope.replyPrices.push(true);
-                    $scope.replylapQtys.push(true);
+            var check = true;
+            angular.forEach(inquiryItem.replies, function(reply) {
+                if (reply.lapQty == null) {
+                    toaster.pop('error', '提示', '存在未填写分段数量的分段,请先填写分段数量');
+                    check = false;
+                }
+                if (check && reply.price == null) {
+                    toaster.pop('error', '提示', '存在未填写价格的分段,请先填写价格');
+                    check = false;
+                }
+            });
+            if (check) {
+                $scope.replyPrices.push(true);
+                if (inquiryItem.replies.length >= 5) {
+                    toaster.pop('warning', '提示', '最多支持5个分段!');
+                } else {
+                    inquiryItem.replies.push({});
+                    if (inquiryItem.replies.length != 1) {
+                        $scope.replyPrices.push(true);
+                        $scope.replylapQtys.push(true);
+                    }
                 }
             }
         };
@@ -5609,26 +5622,51 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         // 保存报价信息
         $scope.save = function(inquiryItem, method) {
-            var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
-            $upload.upload({
-                url: 'pubInquiry/turnToQuotation',
-                file: file,
-                method: 'POST',
-                data: {
-                    item: inquiryItem,
-                    method: method
+            var replies = [];
+            // 判断分段数是否合法
+            var valid = true;
+            var validLapQty = 0;
+            angular.forEach(inquiryItem.replies, function (r, i) {
+                if ((i > 0 ? r.lapQty : 1) || r.price) {
+                    replies.push(r);
                 }
-            }).success(function (data) {
-                if (data.item) {
-                    item = data.item;
+                // 直接比较是字符串比较,需要先转换再比较  2017年9月7日 15:05:51
+                if (i > 0 && parseInt(r.lapQty) <= parseInt(inquiryItem.replies[i - 1].lapQty) || r.lapQty == null) {
+                    valid = false;
+                    validLapQty = r.lapQty;
                 }
-                $scope.loading = false;
-                toaster.pop('info', '提示', '报价成功');
-                $modalInstance.close();
-            }).error(function (data) {
-                $scope.loading = false;
-                toaster.pop('error', '附件上传失败');
             });
+            inquiryItem.replies = replies;
+            $scope.loading = true;
+            if (!valid) {
+                if (validLapQty) {
+                    toaster.pop('error', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
+                } else {
+                    toaster.pop('error', '提示', '分段数量不合法,不能保存!');
+                }
+            } else {
+                alert('success');
+                /*var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
+                $upload.upload({
+                    url: 'pubInquiry/turnToQuotation',
+                    file: file,
+                    method: 'POST',
+                    data: {
+                        item: inquiryItem,
+                        method: method
+                    }
+                }).success(function (data) {
+                    if (data.item) {
+                        item = data.item;
+                    }
+                    $scope.loading = false;
+                    toaster.pop('info', '提示', '报价成功');
+                    $modalInstance.close();
+                }).error(function (data) {
+                    $scope.loading = false;
+                    toaster.pop('error', '附件上传失败');
+                });*/
+            }
         }
 
         $scope.previewShow = false;