Browse Source

修改单个物料导入,编辑一半时提示

shenjj 7 years ago
parent
commit
2e552ee1cc

+ 8 - 0
src/main/webapp/resources/js/vendor/app.js

@@ -988,6 +988,14 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
 
 			$rootScope.$on('$stateChangeStart', function (event, toState) {
 
+				if($rootScope.singleEntryInfo) {
+					if (confirm('是否放弃本次编辑?')) {
+            $rootScope.singleEntryInfo = false
+					} else {
+            event.preventDefault()
+					}
+				}
+
 				if (toState.name === 'vendor_store_apply' && $rootScope.applyStatus !== 'NONE') {
 					event.preventDefault();
 					$state.go(getToStateName());

+ 16 - 3
src/main/webapp/resources/js/vendor/controllers/forstore/single_entry.js

@@ -83,6 +83,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
 
     // 品牌change事件
     $scope.onBrandChange = function(brand, index) {
+      $rootScope.singleEntryInfo = true
       $scope.objError.pbranden = false
       if (index === undefined) {
         if (brand === '') {
@@ -118,6 +119,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.RegulKindBlur  = function() {
+      $rootScope.singleEntryInfo = true
       $scope.objError.kind = false
     }
 
@@ -127,11 +129,12 @@ define(['app/app', 'jquery-uploadify'], function(app) {
      * @param name    品牌名称
      */
     $scope.RegulonBrandBlur = function(name) {
+      $rootScope.singleEntryInfo = true
       // setTimeout(function() {
         if (name === '') {
           $scope.Regul.BrandList = []
         } else {
-          $scope.Regul.pbranden = $scope.Regul.BrandList.value && $scope.Regul.BrandList.value[0].nameEn || name
+          $scope.Regul.pbranden = $scope.Regul.BrandList && $scope.Regul.BrandList.value && $scope.Regul.BrandList.value[0].nameEn || name
           $scope.Regul.BrandList = []
         }
       // }, 300)
@@ -143,6 +146,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.setBrand = function(brand, index) {
+      $rootScope.singleEntryInfo = true
       if (index === undefined) {
         $scope.Regul.pbranden = brand
         $scope.Regul.BrandList = []
@@ -167,6 +171,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     ;
 
     $scope.onCodeChange = function(code, index) {
+      $rootScope.singleEntryInfo = true
       $scope.objError.pcmpcode = false
       if (index === undefined) {
         if (code === '') {
@@ -187,22 +192,25 @@ define(['app/app', 'jquery-uploadify'], function(app) {
      * @param name    型号名称
      */
     $scope.RegulonCodeBlur = function(name) {
+      $rootScope.singleEntryInfo = true
       if (name === '') {
         $scope.Regul.CodeList = []
       } else {
         $scope.Regul.pcmpcode = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pcmpcode || name
-        $scope.Regul.CodeList = []
         $scope.Regul.pbranden = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.pbranden
         $scope.Regul.spec = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.spec
         $scope.Regul.kind = $scope.Regul.CodeList.value && $scope.Regul.CodeList.value[0].pbranden || $scope.Regul.kind
+        $scope.Regul.CodeList = []
       }
     }
     $scope.setCode = function(code, index) {
+      $rootScope.singleEntryInfo = true
         $scope.Regul.pcmpcode = code.pcmpcode
-        $scope.Regul.CodeList = []
+
       $scope.Regul.pbranden = code.pbranden
       $scope.Regul.spec = code.spec
       $scope.Regul.kind = code.kind
+      $scope.Regul.CodeList = []
     }
 
     var countLength = function(string) {
@@ -239,6 +247,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.setPriceMinPackAmount = function(num) {
+      $rootScope.singleEntryInfo = true
       if (num && num.indexOf('.') > -1) {
         toaster.pop('warning', '提示', '最小包装数不能存在小数点')
         $scope.Regul.minPackQty = 1
@@ -249,6 +258,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.setReserve = function(num) {
+      $rootScope.singleEntryInfo = true
       if (num && num.indexOf('.') > -1) {
         toaster.pop('warning', '提示', '库存数量不能存在小数点')
         $scope.Regul.reserve = 1
@@ -259,11 +269,13 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
 
     $scope.setOnePrice = function(num) {
+      $rootScope.singleEntryInfo = true
       $scope.Regul.OnePrice = num
       $scope.objError.OnePrice = false
     }
     // 修改规格书
     $scope.onUploadSuccess = function(data) {
+      $rootScope.singleEntryInfo = true
       $scope.Regul.Regulpic = data.path;
       $scope.Regul.Ischange = true
     };
@@ -308,6 +320,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
         toaster.pop('warning', '提示', '最小包装数未编辑导致无法上架');
         return
       }
+      $rootScope.singleEntryInfo = true
       if (!$scope.Regul.breakUp && $scope.Regul.minBuyQty !== $scope.Regul.minPackQty) {
         if ($scope.Regul.minBuyQty % $scope.Regul.minPackQty !== 0) {
           $scope.Regul.minBuyQty = $scope.Regul.minPackQty

+ 2 - 2
src/main/webapp/resources/view/vendor/forstore/single_entry.html

@@ -150,8 +150,8 @@
   <div class="pro_management device">
     <div class="com_tab">
       <ul class="fl" style="width: 100%" ng-if="!isPcbStore">
-        <li ng-class="{'active': tab == 'bathOn'}"><a>导入产品</a></li>
-        <li ng-class="{'active': tab == 'single_entry'}"><a ui-sref="single_entry">单个录入</a></li>
+        <li ng-class="{'active': tab == 'bathOn'}"><a ui-sref="vendor_upload">导入产品</a></li>
+        <li ng-class="{'active': tab == 'single_entry'}"><a >单个录入</a></li>
         <!--<li ng-class="{'active': $$productOn.tab == 'bathOn'}" ng-click="toggleActive('bathOn')"><a href="">导入产品并上架</a></li>-->
         <!--<li ng-class="{'active': $$productOn.tab == 'bathOnPerson'}" ng-click="toggleActive('bathOnPerson')"><a href="">导入产品</a></li>-->
       </ul>