Parcourir la source

暂时去掉填写锁库存之后与可用库存的验证

huxz il y a 8 ans
Parent
commit
5ed5a2a694

+ 117 - 47
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_standard_putOn_ctrl.js

@@ -276,10 +276,11 @@ define(['app/app'], function (app) {
                 toaster.pop('warning', '提示', '锁库数必须是大于等于0');
                 return ;
             }
-            if(Number(standard.repositoryQty) < Number(standard.editLockQty)) {
+            // TODO 去掉库存和总库存的验证
+           /* if(Number(standard.repositoryQty) < Number(standard.editLockQty)) {
                 toaster.pop('warning', '提示', '锁库数大于了总库存数');
                 standard.editLockQty = null;
-            }
+            }*/
             standard.lockQty = !standard.lockQty ? 0 : standard.lockQty;
             standard.editLockQty =!standard.editLockQty ? 0 : standard.editLockQty;
             standard.onSaleQty = !standard.onSaleQty ? 0 : standard.onSaleQty;
@@ -287,8 +288,9 @@ define(['app/app'], function (app) {
             var onSale = Number(standard.onSaleQty) + Number(standard.availableOnSale);
             var minus = Number(standard.editLockQty)  - Number(standard.lockQty);
             if(minus > onSale) {
-                toaster.pop('warning', '提示', '新增锁库数不能超过可用库存');
-                standard.editLockQty = onSale + standard.lockQty;
+                // TODO 去掉库存量的处理
+                // toaster.pop('warning', '提示', '新增锁库数不能超过可用库存');
+                // standard.editLockQty = onSale + standard.lockQty;
                 standard.editAvailableOnSale = 0;
                 standard.editOnSaleQty = 0;
             }else {
@@ -309,71 +311,139 @@ define(['app/app'], function (app) {
          * @param index
          */
         $scope.putOn = function (standard, index) {
-            //验证库存信息
-            if(!$scope.checkGoodsInfo(standard)) {
-                return ;
+
+			//验证库存信息
+			if(!$scope.checkGoodsInfo(standard)) {
+				return ;
+			}
+
+            // 如果没有开启店铺,第一次寄售时则弹出寄售协议
+            if (!$scope.$$putOn.isSelfStore) {
+				ConsignmentAgreementRecord.findRecordOfUser({}, {}, function (record) {
+					if (!record.id) {
+						// 弹出寄售协议弹窗
+						$modal.open({
+							templateUrl : 'static/view/vendor/modal/confirm_consignment_agreement.html',
+							controller : 'ConfirmConsignmentAgreement'
+						}).result.then(function(){
+							productStandardPutOnInfoPutOn(standard, index);
+							// toaster.pop('success', '操作成功');
+						}, function(){
+							toaster.pop('success', '请签订寄售协议');
+						});
+					} else {
+						productStandardPutOnInfoPutOn(standard, index);
+                    }
+				}, function (error) {
+					console.log(error);
+					toaster.pop('error', '系统异常,请联系管理员寻求帮助');
+				});
+            } else {
+				productStandardPutOnInfoPutOn(standard, index);
             }
-            StandardPutOnAdminService.productStandardPutOnInfoPutOn(null, standard, function(data){
-                if(data.code == 1) {
-                    toaster.pop('success', '上架成功');
-                    $scope.standarPutOnTable.data.splice(index, 1, data.data);
-                }else {
-                    toaster.pop('warning', '失败', data.message);
-                }
-            }, function(response){
-                toaster.pop('error', '修改失败', response.data);
-            });
         };
 
+        function productStandardPutOnInfoPutOn(standard, index) {
+
+			StandardPutOnAdminService.productStandardPutOnInfoPutOn(null, standard, function(data){
+				if(data.code == 1) {
+					toaster.pop('success', '上架成功');
+					$scope.standarPutOnTable.data.splice(index, 1, data.data);
+				}else {
+					toaster.pop('warning', '失败', data.message);
+				}
+			}, function(response){
+				toaster.pop('error', '修改失败', response.data);
+			});
+		}
+
         /**
          * 用户更新库存信息
          * @param standard
          * @param index
          */
         $scope.updateInfo = function (standard, index) {
-            //验证库存信息
-            if(!$scope.checkGoodsInfo(standard)) {
-                return ;
-            }
-            StandardPutOnAdminService.updateProductStandardPutOnInfo(null, standard, function(data){
-                if(data.code == 1) {
-                    toaster.pop('success', '标准上架信息更新成功');
-                    $scope.standarPutOnTable.data.splice(index, 1, data.data);
-                }else {
-                    toaster.pop('warning', '失败', data.message);
-                }
-            }, function(response){
-                toaster.pop('error', '修改失败', response.data);
-            });
-        };
-
-        /**
-         * 改变销售方式
-         */
-        $scope.changeSale = function (standard) {
-            standard.editIsSelfSale = standard.editSelfSaleNum == 1;
-
-            if (!standard.editIsSelfSale) {
+			//验证库存信息
+			if(!$scope.checkGoodsInfo(standard)) {
+			    console.log('AVSSC');
+				return ;
+			}
+
+			// 如果没有开启店铺,第一次寄售时则弹出寄售协议
+			if (!$scope.$$putOn.isSelfStore) {
 				ConsignmentAgreementRecord.findRecordOfUser({}, {}, function (record) {
-				    if (!record.id) {
-				        // 弹出寄售协议弹窗
+					if (!record.id) {
+						// 弹出寄售协议弹窗
 						$modal.open({
 							templateUrl : 'static/view/vendor/modal/confirm_consignment_agreement.html',
 							controller : 'ConfirmConsignmentAgreement'
 						}).result.then(function(){
-							toaster.pop('success', '操作成功');
+							updateProductStandardPutOnInfo(standard, index);
+							// toaster.pop('success', '操作成功');
 						}, function(){
-							standard.editSelfSaleNum = 1;
-							standard.editIsSelfSale = standard.editSelfSaleNum === 1;
+							toaster.pop('success', '请签订寄售协议');
 						});
+					} else {
+						updateProductStandardPutOnInfo(standard, index);
                     }
 				}, function (error) {
-                    console.log(error);
-                    toaster.pop('error', '系统异常,请联系管理员寻求帮助');
+					console.log(error);
+					toaster.pop('error', '系统异常,请联系管理员寻求帮助');
 				});
+			} else {
+				updateProductStandardPutOnInfo(standard, index);
+			}
+        };
+
+        function updateProductStandardPutOnInfo(standard, index) {
+			StandardPutOnAdminService.updateProductStandardPutOnInfo(null, standard, function(data){
+				if(data.code == 1) {
+					toaster.pop('success', '标准上架信息更新成功');
+					$scope.standarPutOnTable.data.splice(index, 1, data.data);
+				}else {
+					toaster.pop('warning', '失败', data.message);
+				}
+			}, function(response){
+				toaster.pop('error', '修改失败', response.data);
+			});
+		}
+
+        /**
+         * 改变销售方式
+         */
+        $scope.changeSale = function (standard) {
+            standard.editIsSelfSale = standard.editSelfSaleNum == 1;
+
+            if (!standard.editIsSelfSale) {
+				checkAndShowConsignmentAgreement(standard);
             }
         };
 
+		/**
+         * 检查是否签订寄售协议,否则弹出寄售协议弹框
+         *
+		 * @param standard  标准产品信息
+		 */
+		function checkAndShowConsignmentAgreement(standard) {
+			ConsignmentAgreementRecord.findRecordOfUser({}, {}, function (record) {
+				if (!record.id) {
+					// 弹出寄售协议弹窗
+					$modal.open({
+						templateUrl : 'static/view/vendor/modal/confirm_consignment_agreement.html',
+						controller : 'ConfirmConsignmentAgreement'
+					}).result.then(function(){
+						toaster.pop('success', '操作成功');
+					}, function(){
+						standard.editSelfSaleNum = 1;
+						standard.editIsSelfSale = standard.editSelfSaleNum === 1;
+					});
+				}
+			}, function (error) {
+				console.log(error);
+				toaster.pop('error', '系统异常,请联系管理员寻求帮助');
+			});
+		}
+
         /**
          * 搜索的方法
          */