Browse Source

新增企业产品库 物料编辑与查看

shenjj 8 years ago
parent
commit
df4f8e59c4

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

@@ -8,7 +8,19 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
 		return this.length > 0 ? this[this.length - 1] : null;
 	};
 
-	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'installmentServices','common.query.product', 'ui.tour', 'seekPurchaseServices', 'UASBatchPutOnPropertyModule']);
+	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'installmentServices','common.query.product', 'ui.tour', 'seekPurchaseServices', 'UASBatchPutOnPropertyModule'])
+  .directive('onFinishRender', function ($timeout) {
+    return {
+      restrict: 'A',
+      link: function (scope, element, attr) {
+        if (scope.$last === true) {
+          $timeout(function () {
+            scope.$emit('ngRepeatFinished');
+          });
+        }
+      }
+    }
+  })
 	//初始化,启动时载入app
 	app.init = function() {
 		angularAMD.bootstrap(app);

+ 71 - 22
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -3143,6 +3143,26 @@ define(['app/app', 'jquery-uploadify'], function(app) {
         }];
         $scope.isInCodeList = [false];
         $scope.isInBrandList = [false];
+      } else if ($scope.linearLength == 0) {
+        $scope.replaceMaterialList.splice(0, 0, {
+          ptrCmpcode: '',
+          ptrBranden: '',
+          showSimilarCodeList: false,
+          showSimilarBrandList: false,
+          editable: true,
+          productId: $scope.replaceMaterialList[0].productId
+        })
+        $scope.errorObj.splice(0, 0, {
+          code: 0,
+          brand: 0
+        });
+        $scope.isInCodeList.splice(0, 0, false);
+        $scope.isInBrandList.splice(0, 0, false);
+        $scope.linearLength++;
+
+        if ($scope.replaceMaterialList.length > 5) {
+          $scope.ngLastFinished = true
+        }
       }
     }
 
@@ -3198,11 +3218,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
           $scope.isInCodeList.splice(index + 1, 0, false);
           $scope.isInBrandList.splice(index + 1, 0, false);
           $scope.linearLength++;
-
-          if ($scope.replaceMaterialList.length > 5) {
-            var el = angular.element('.edit-replace-box .content2')
-            el.scrollTop(el.scrollTop() + 42)
-          }
+          $scope.ngLastFinished = true
         } else {
           toaster.pop('error', '请填完整信息');
           return
@@ -3341,6 +3357,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
 
       if ($scope.resultDatalistArray[material.id]) {
         $scope.resultDatalist = $scope.resultDatalistArray[material.id].arr
+        console.log($scope.resultDatalist)
         $scope.linearLength = $scope.resultDatalistArray[material.id].headlength
       } else {
         Material.getGoodsListByProductId({
@@ -3358,25 +3375,17 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       $scope.setShowActive = -1;
     }
     // 计算下拉的ul 位置
+    $scope.ulEl = null
+    $scope.ultype = ''
+    $scope.inputEl = null
+    $scope.inputkey = null
     $scope.onFocus = function($event, index, type, key) {
-      var el = angular.element('.'+index);
+      $scope.ulEl = angular.element('.'+index);
+      $scope.ultype = type
+      $scope.inputEl = $event
       key+=1
-      var X;
-      var Y;
-      var _scrollTop = angular.element('.edit-replace-box .content2').scrollTop()
-      if(type == 'brand') {
-        var _t  = angular.element('.com-modal-wrap').height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
-        Y = _t - _scrollTop
-        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + angular.element('.edit-replace-box').width() / 2 +  $event.currentTarget.offsetLeft + 20
-      }else {
-        var _t  = angular.element('.com-modal-wrap').height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
-        Y = _t - _scrollTop
-        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + $event.currentTarget.offsetLeft + 23
-      }
-      el.css({
-        left: X,
-        top: Y
-      })
+      $scope.inputkey = key
+      caleUllist($scope.inputEl,$scope.ultype,$scope.inputkey,$scope.ulEl)
     }
     // 针对当前人员权限重组list
     var normalChangeArr = function(arr) {
@@ -3398,6 +3407,46 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       }
     }
 
+    angular.element(window).resize(function() {
+      if(!$scope.inputEl){ return false}
+      caleUllist($scope.inputEl,$scope.ultype,$scope.inputkey,$scope.ulEl)
+    })
+
+    function caleUllist($event,type,key,el){
+      var _scrollTop = angular.element('.edit-replace-box .content2').scrollTop()
+      var Y, X;
+      if(type == 'brand') {
+        var _t  = angular.element(window).height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
+        Y = _t - _scrollTop
+        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + $event.currentTarget.offsetLeft - 11
+        el.css({
+          right: X,
+          top: Y
+        })
+      }else {
+        var _t = angular.element(window).height() * 0.2
+            + angular.element('.edit-replace-box .title').height()
+            + angular.element(
+                '.edit-replace-box .content .content-line')[key].offsetTop
+            + 28
+        Y = _t - _scrollTop
+        X = (angular.element('body').width() - angular.element(
+            '.edit-replace-box').width()) / 2
+            + $event.currentTarget.offsetLeft
+        el.css({
+          left: X,
+          top: Y
+        })
+      }
+    }
+
+    $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
+      if ($scope.replaceMaterialList.length > 5 && $scope.ngLastFinished == true) {
+        var el = angular.element('.edit-replace-box .content2')
+        el.scrollTop(el.scrollTop() + 42)
+        $scope.ngLastFinished = false
+      }
+    })
   }
   ]);
 

+ 75 - 33
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialPersonCtrl.js

@@ -2513,6 +2513,26 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
           $scope.linearLength = 1
           $scope.isInCodeList = [false];
           $scope.isInBrandList = [false];
+        } else if ($scope.linearLength == 0) {
+          $scope.replaceMaterialList.splice(0, 0, {
+            ptrCmpcode: '',
+            ptrBranden: '',
+            showSimilarCodeList: false,
+            showSimilarBrandList: false,
+            editable: true,
+            productId: $scope.replaceMaterialList[0].productId
+          })
+          $scope.errorObj.splice(0, 0, {
+            code: 0,
+            brand: 0
+          });
+          $scope.isInCodeList.splice(0, 0, false);
+          $scope.isInBrandList.splice(0, 0, false);
+          $scope.linearLength++;
+
+          if ($scope.replaceMaterialList.length > 5) {
+            $scope.ngLastFinished = true
+          }
         }
       } else {
         $scope.errorObj = [{
@@ -2569,14 +2589,11 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
           $scope.isInCodeList.splice(index + 1, 0, false);
           $scope.isInBrandList.splice(index + 1, 0, false);
           $scope.linearLength++;
-          if ($scope.replaceMaterialList.length > 5) {
-            var el = angular.element('.edit-replace-box .content')
-            el.scrollTop(el.scrollTop() + 42)
-          }
+          $scope.ngLastFinished = true
         } else {
           toaster.pop('error', '请填完整信息');
         }
-      } else if (type === 'sub' && $scope.replaceMaterialList.length > 0) {
+      } else if (type === 'sub' && $scope.replaceMaterialList.length > 1) {
         $scope.linearLength--;
         $scope.replaceMaterialList.splice(index, 1);
         $scope.errorObj.splice(index, 1);
@@ -2712,45 +2729,31 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
       $scope.replaceMaterialList[index].ptrBranden = brand;
       $scope.setShowSimilarBrandList(false, index);
     }
+
     // 计算下拉的ul 位置
+    $scope.ulEl = null
+    $scope.ultype = ''
+    $scope.inputEl = null
+    $scope.inputkey = null
     $scope.onFocus = function($event, index, type, key) {
-      var el = angular.element('.'+index);
+      $scope.ulEl = angular.element('.'+index);
+      $scope.ultype = type
+      $scope.inputEl = $event
       key+=1
-      var X;
-      var Y;
-      var _scrollTop = angular.element('.edit-replace-box .content').scrollTop()
-      if(type == 'brand') {
-        var _t  = angular.element('.com-modal-wrap').height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
-        Y = _t - _scrollTop
-        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + angular.element('.edit-replace-box').width() / 2 +  $event.currentTarget.offsetLeft + 20
-      }else {
-        var _t  = angular.element('.com-modal-wrap').height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
-        Y = _t - _scrollTop
-        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + $event.currentTarget.offsetLeft + 23
-      }
-      el.css({
-        left: X,
-        top: Y
-      })
+      $scope.inputkey = key
+      caleUllist($scope.inputEl,$scope.ultype,$scope.inputkey,$scope.ulEl)
     }
-    // $scope.resetSimilar = function (index, type) {
-    // 	for (var i = 0; i < $scope.replaceMaterialList.length; i++) {
-    // 		if (index != i) {
-    // 			$scope.replaceMaterialList[i].showSimilarCodeList = false;
-    // 			$scope.replaceMaterialList[i].showSimilarBrandList = false;
-    // 		}
-    // 	}
-    // }
     // 针对当前人员权限重组list
     var normalChangeArr = function(arr) {
+      $scope.ShowReminfo = false
       var _arr = arr.slice()
       var _headArr = [];
       var _lastArr = [];
       _arr.forEach(function(obj, index){
         if (!obj.editable) {
           _lastArr.push(obj)
-        } else {
           $scope.ShowReminfo = true
+        } else {
           _headArr.push(obj)
         }
       })
@@ -2760,8 +2763,47 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
       }
     }
 
+    angular.element(window).resize(function() {
+      if(!$scope.inputEl){ return false}
+      caleUllist($scope.inputEl,$scope.ultype,$scope.inputkey,$scope.ulEl)
+    })
 
-  }]);
+    function caleUllist($event,type,key,el){
+      var _scrollTop = angular.element('.edit-replace-box .content').scrollTop()
+      var Y, X;
+      if(type == 'brand') {
+        var _t  = angular.element(window).height() * 0.2 + angular.element('.edit-replace-box .title').height() + angular.element('.edit-replace-box .content .content-line')[key].offsetTop + 28
+        Y = _t - _scrollTop
+        X = (angular.element('body').width() - angular.element('.edit-replace-box').width()) / 2 + $event.currentTarget.offsetLeft - 11
+        el.css({
+          right: X,
+          top: Y
+        })
+      }else {
+        var _t = angular.element(window).height() * 0.2
+            + angular.element('.edit-replace-box .title').height()
+            + angular.element(
+                '.edit-replace-box .content .content-line')[key].offsetTop
+            + 28
+        Y = _t - _scrollTop
+        X = (angular.element('body').width() - angular.element(
+            '.edit-replace-box').width()) / 2
+            + $event.currentTarget.offsetLeft
+        el.css({
+          left: X,
+          top: Y
+        })
+      }
+    }
+
+    $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
+      if ($scope.replaceMaterialList.length > 5 && $scope.ngLastFinished == true) {
+        var el = angular.element('.edit-replace-box .content')
+        el.scrollTop(el.scrollTop() + 42)
+        $scope.ngLastFinished = false
+      }
+    })
+  }])
 
   //类目选择模态框
   app.register.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function($scope, KindAPI, actives, toaster, $modalInstance) {
@@ -2969,4 +3011,4 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
       }
     };
   }]);
-});
+})

+ 8 - 7
src/main/webapp/resources/view/vendor/forstore/vendor_material.html

@@ -1606,7 +1606,8 @@
 		position: fixed;
 		width: 510px;
 		top: 20%;
-		left: 33%;
+		left: 50%;
+		margin-left: -255px;
 		/*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
 		/*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
 		/*box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
@@ -1758,7 +1759,7 @@
 	}
 	.edit-replace-box .content .content-line .form-item.form-right ul.similar-list {
 		width: 140px;
-		left: 65px;
+		/*left: 65px;*/
 	}
 	.edit-replace-box .content .content-line .form-item ul.similar-list li {
 		height: 30px;
@@ -2473,8 +2474,8 @@
         <div class="line"></div>
       </div>
       <ul ng-if="resultDatalist.length > 0">
-        <li ng-repeat="list in resultDatalist">
-          <div class="sort">{{$index+1}}</div>
+        <li ng-repeat="list in resultDatalist" ng-if="list.userUU">
+          <div class="sort">{{list.detno}}</div>
           <div class="text">{{list.ptrCmpcode}}</div>
           <div class="text">{{list.ptrBranden}}</div>
         </li>
@@ -2498,7 +2499,7 @@
 			<div class="content-line">
 				<p>可替代型号:</p>
 			</div>
-			<div class="content-line" ng-repeat="(key, mate) in replaceMaterialList">
+			<div class="content-line" ng-repeat="(key, mate) in replaceMaterialList" on-finish-render="ngRepeatFinished">
 				<div class="form-item form-left">
 					<span><i>{{key + 1}}</i><em>*</em>型号:</span>
 					<input type="text" class="form-control" ng-readonly="mate.editable == false" ng-model="mate.ptrCmpcode" ng-focus="onFocus($event, 'similar-list1_'+ key, 'code', key)" ng-change="onCodeChange(mate.ptrCmpcode, key, $event)" ng-blur="onCodeBlur(key)" ng-class="{'error': errorObj[key].code == 1}" placeholder="请输入型号名称">
@@ -2512,14 +2513,14 @@
 					<ul class="similar-list" ng-class="'similar-list2_'+ key" ng-show="mate.showSimilarBrandList && similarBrand.length > 0 && mate.ptrBranden" ng-mouseenter="setIsInBrandList(true, key)" ng-mouseleave="setIsInBrandList(false, key)">
 						<li ng-repeat="sBrand in similarBrand" ng-bind="sBrand.nameEn" title="{{sBrand.nameEn}}" ng-click="setBrand(key, sBrand.nameEn)"></li>
 					</ul>
-					<i class="fa fa-minus-circle" ng-if="replaceMaterialList.length > 1 && mate.editable != false" ng-click="setReplies('sub', key)"></i>
+					<i class="fa fa-minus-circle" ng-if="replaceMaterialList.length >= 1 && mate.editable != false" ng-click="setReplies('sub', key)"></i>
 					<i class="fa fa-plus-circle" ng-if="key == linearLength - 1 && mate.editable != false" ng-click="setReplies('add', key)"></i>
 				</div>
 			</div>
 		</div>
 
 		<div class="operate">
-			<div class="reminfo" ng-if="ShowReminfo">
+			<div class="reminfo">
 				<a>*</a>您无权编辑和删除的替代型号,请联系贵公司管理员进行处理。
 			</div>
 			<span ng-click="setProductReplacesByPerson(replaceMaterialList)">确定</span>

+ 8 - 7
src/main/webapp/resources/view/vendor/forstore/vendor_material_person.html

@@ -1500,7 +1500,7 @@
 		width: 884px;
 	}
 	.replace-row td > div > div .replace-item {
-		display: inline-block;
+		/*display: inline-block;*/
 		width: 50%;
 		text-align: left;
 		background: #f6fbfe;
@@ -1509,7 +1509,7 @@
 	}
 	.replace-row td > div > .Scrollactive {
 		height: 160px;
-		overflow-y: scroll;
+		overflow-y: auto;
 	}
 	.replace-row td > div > div .replace-item:nth-child(2n-1) {
 		border-right: 1px solid #dde9fc;
@@ -1542,7 +1542,8 @@
 		position: fixed;
 		width: 510px;
 		top: 20%;
-		left: 33%;
+		left: 50%;
+		margin-left: -255px;
 		/*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
 		/*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
 		/*box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
@@ -1688,7 +1689,7 @@
 	}
 	.edit-replace-box .content .content-line .form-item.form-right ul.similar-list {
 		width: 140px;
-		left: 65px;
+		/*left: 65px;*/
 	}
 	.edit-replace-box .content .content-line .form-item ul.similar-list li {
 		height: 30px;
@@ -1729,7 +1730,7 @@
 		line-height: 15px;
 		text-decoration: none;
 		position: relative;
-		top: -3px;
+		top: -4px;
 		z-index: 1;
 	}
 	.open-more a i{
@@ -2493,7 +2494,7 @@
 			<div class="content-line">
 				<p>可替代型号:</p>
 			</div>
-			<div class="content-line" ng-repeat="(key, mate) in replaceMaterialList">
+			<div class="content-line" ng-repeat="(key, mate) in replaceMaterialList" on-finish-render="ngRepeatFinished">
 				<div class="form-item form-left">
 					<span><i>{{key + 1}}</i><em>*</em>型号:</span>
 					<input type="text"  ng-readonly="mate.editable == false"  class="form-control" ng-model="mate.ptrCmpcode" ng-focus="onFocus($event, 'similar-list3_'+ key, 'code', key)" ng-change="onCodeChange(mate.ptrCmpcode, key)" ng-blur="onCodeBlur(key)" ng-class="{'error': errorObj[key].code == 1}" placeholder="请输入型号名称">
@@ -2507,7 +2508,7 @@
                     <ul class="similar-list" ng-class="'similar-list4_'+ key" ng-show="mate.showSimilarBrandList && similarBrand.length > 0 && mate.ptrBranden" ng-mouseenter="setIsInBrandList(true, key)" ng-mouseleave="setIsInBrandList(false, key)">
                         <li ng-repeat="sBrand in similarBrand" ng-bind="sBrand.nameEn" title="{{sBrand.nameEn}}" ng-click="setBrand(key, sBrand.nameEn)"></li>
                     </ul>
-					<i class="fa fa-minus-circle" ng-if="replaceMaterialList.length > 1 && mate.editable != false" ng-click="setReplies('sub', key)"></i>
+					<i class="fa fa-minus-circle" ng-if="replaceMaterialList.length >= 1 && mate.editable != false" ng-click="setReplies('sub', key)"></i>
 					<i class="fa fa-plus-circle" ng-if="key == linearLength - 1 && mate.editable != false" ng-click="setReplies('add', key)"></i>
 				</div>
 			</div>