yangc 8 years ago
parent
commit
c687588d6a

+ 81 - 7
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialPersonCtrl.js

@@ -1024,8 +1024,12 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		};
 
 		$scope.setProductReplacesByPerson = function (productReplaceList) {
+			for (var i = 0; i < productReplaceList.length; i++) {
+				productReplaceList[i].detno = i + 1;
+			}
 			Material.setProductReplacesByPerson(productReplaceList , function (data) {
-
+				loadDataReload();
+				$scope.setActiveIndex(-1);
             }, function (response) {
             })
         }
@@ -2473,16 +2477,21 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 
 		$scope.replaceMaterialList = [
 			{
-				brand: '',
-				code: ''
+				ptrBranden: '',
+				ptrCmpcode: '',
+				showSimilarCodeList: false,
+				showSimilarBrandList: false
 			}
 		]
 		$scope.setReplies = function (type, index) {
-			if (type === 'add' && $scope.replaceMaterialList.length < 5) {
-				if ($scope.replaceMaterialList[index].brand && $scope.replaceMaterialList[index].code) {
+			if (type === 'add' && $scope.replaceMaterialList.length < 10) {
+				if ($scope.replaceMaterialList[index].ptrBranden && $scope.replaceMaterialList[index].ptrCmpcode) {
 					$scope.replaceMaterialList.splice(index + 1, 0, {
-						code: '',
-						brand: ''
+						ptrCmpcode: '',
+						ptrBranden: '',
+						showSimilarCodeList: false,
+						showSimilarBrandList: false,
+						productId: $scope.replaceMaterialList[0].productId
 					})
 				} else {
 					toaster.pop('error', '请填完整信息');
@@ -2492,6 +2501,71 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			}
 		}
 
+		// $scope.showSimilarCodeList = false;
+		$scope.isInCodeList = true;
+		// $scope.showSimilarBrandList = false;
+		$scope.isInBrandList = true;
+
+		$scope.getSimilarCode = function (keyword, index) {
+			if (keyword) {
+				Search.getSimilarComponents({keyword : keyword}, function (data) {
+					$scope.similarCode = data || [];
+					$scope.setShowSimilarCodeList(data && data.length, index);
+				}, function (error) {
+					toaster.pop('error', '系统错误');
+				})
+			}
+		}
+		$scope.getSimilarBrand = function (keyword, index) {
+			if (keyword) {
+				Search.getSimilarBrands({keyword : keyword}, function (data) {
+					$scope.similarBrand = data || [];
+					$scope.setShowSimilarBrandList(data && data.length, index);
+				}, function (error) {
+					toaster.pop('error', '系统错误');
+				})
+			}
+		}
+		$scope.setShowSimilarCodeList = function (flag, index) {
+			$scope.replaceMaterialList[index].showSimilarCodeList = flag;
+		}
+		$scope.setShowSimilarBrandList = function (flag, index) {
+			$scope.replaceMaterialList[index].showSimilarBrandList = flag;
+		}
+		$scope.setIsInCodeList = function (flag) {
+			$scope.isInCodeList = flag;
+		}
+		$scope.setIsInBrandList = function (flag) {
+			$scope.isInBrandList = flag;
+		}
+		$scope.onCodeChange = function (code, index) {
+			if (!code) {
+				$scope.setShowSimilarCodeList(false, index);
+			} else {
+				$scope.getSimilarCode(code, index);
+			}
+		}
+		$scope.onBrandChange = function (brand, index) {
+			if (!brand) {
+				$scope.setShowSimilarBrandList(false, index);
+			} else {
+				$scope.getSimilarBrand(brand, index);
+			}
+		}
+		$scope.onCodeBlur = function (index) {
+			$scope.setShowSimilarCodeList($scope.isInCodeList, index);
+		}
+		$scope.onBrandBlur = function (index) {
+			$scope.setShowSimilarBrandList($scope.isInBrandList, index);
+		}
+		$scope.setCode = function (index, code) {
+			$scope.replaceMaterialList[index].ptrCmpcode = code;
+			$scope.setShowSimilarCodeList(false, index);
+		}
+		$scope.setBrand = function (index, brand) {
+			$scope.replaceMaterialList[index].ptrBranden = brand;
+			$scope.setShowSimilarBrandList(false, index);
+		}
 	}]);
 
 	//类目选择模态框

+ 50 - 14
src/main/webapp/resources/view/vendor/forstore/vendor_material_person.html

@@ -1599,6 +1599,7 @@
 	}
 	.edit-replace-box .content .content-line {
 		margin: 0 0 14px 0;
+		position: relative;
 	}
 	.edit-replace-box .content .content-line p {
 		margin-left: 16px;
@@ -1677,6 +1678,38 @@
 		margin-left: 15px;
 		background: #acabab;
 	}
+
+	.edit-replace-box .content .content-line .form-item ul.similar-list {
+		position: absolute;
+		top: 27px;
+		left: 89px;
+		background: #fff;
+		border: 1px solid #b5b5b5;
+		z-index: 1;
+		max-height: 120px;
+		overflow-y: auto;
+		overflow-x: hidden;
+		border-radius: 3px;
+		width: 141px;
+		font-size: 14px;
+	}
+	.edit-replace-box .content .content-line .form-item.form-right ul.similar-list {
+		width: 140px;
+		left: 59px;
+	}
+	.edit-replace-box .content .content-line .form-item ul.similar-list li {
+		height: 30px;
+		line-height: 30px;
+		cursor: pointer;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		white-space: nowrap;
+		padding: 0 5px;
+	}
+	.edit-replace-box .content .content-line .form-item ul.similar-list li:hover {
+		background: #5078cb;
+		color: #fff;
+	}
 </style>
 <div class="user_right fr">
 	<!--货品管理-->
@@ -1763,8 +1796,8 @@
 							<span ng-show="isBatch"><input type="checkbox" ng-checked="material.isChoosed"  ng-click="chooseOne(material)"  id="{{$index+1}}"/><label for="{{$index+1}}"></label><br/></span>
 							<span
 									ng-show="!isBatch" ng-bind="(param.page - 1) * 10 + $index + 1"></span>
-							<img ng-if="!material.uuid" src="static/img/store/common/nonstandard.png" alt="" class="standard"/>
-							<img ng-if="material.uuid" src="static/img/store/common/standard.png" alt="" class="standard"/>
+							<img ng-if="material.standard == 0" src="static/img/store/common/nonstandard.png" alt="" class="standard"/>
+							<img ng-if="material.standard != 0" src="static/img/store/common/standard.png" alt="" class="standard"/>
 						</td>
 						<td>
 							<span ng-if="material.kind" ng-bind="material.kind" title="{{material.kind}}"></span>
@@ -2135,19 +2168,19 @@
 							</div>
 						</td>
 					</tr>
-					<tr class="replace-row">
+					<tr class="replace-row" ng-if="material.productReplaceList.length > 0">
 						<td colspan="6">
 							<div>
 								<p>可替代型号:</p>
 								<div class="replace-list">
-									<div class="replace-item" ng-repeat="replace in material.productReplaceList track by replace.detno" ng-if="material.showMoreReplace || (!material.showMoreReplace && replace.detno < 5) ">
+									<div class="replace-item" ng-repeat="replace in material.productReplaceList" ng-if="material.showMoreReplace || (!material.showMoreReplace && replace.detno < 5) ">
 										<i>{{replace.detno}}</i>
 										<span>型号:{{replace.ptrCmpcode}}</span>
 										<span>品牌:{{replace.ptrBranden}}</span>
 									</div>
 								</div>
 								<div class="expand-operate">
-									<a href="" ng-click="material.showMoreReplace = !material.showMoreReplace">查看更多</a>
+									<a href="" ng-click="material.showMoreReplace = !material.showMoreReplace" ng-if="material.productReplaceList.length > 4">{{!material.showMoreReplace?'查看更多':'收起'}}</a>
 								</div>
 							</div>
 						</td>
@@ -2387,19 +2420,22 @@
 			<div class="content-line">
 				<p>可替代型号:</p>
 			</div>
-			<div class="content-line" ng-repeat="mate in replaceMaterialList track by $index">
+			<div class="content-line" ng-repeat="(key, mate) in replaceMaterialList">
 				<div class="form-item form-left">
-					<span><i>{{mate.detno}}</i>型号:</span>
-					<input type="text" class="form-control" ng-model="mate.ptrCmpcode" placeholder="请输入型号名称">
-					<!--<ul class="similar-list" ng-show="showSimilarCodeList" ng-mouseenter="isInCodeList = true;" ng-mouseleave="isInCodeList = false;">-->
-					<!--<li ng-repeat="sCode in similarCode" ng-bind="sCode.code" title="{{sCode.code}}"></li>-->
-					<!--</ul>-->
+					<span><i>{{key + 1}}</i>型号:</span>
+					<input type="text" class="form-control" ng-model="mate.ptrCmpcode" ng-change="onCodeChange(mate.ptrCmpcode, key)" ng-blur="onCodeBlur(key)" placeholder="请输入型号名称">
+                    <ul class="similar-list" ng-show="mate.showSimilarCodeList" ng-mouseenter="setIsInCodeList(true)" ng-mouseleave="setIsInCodeList(false)">
+                        <li ng-repeat="sCode in similarCode" ng-bind="sCode.code" title="{{sCode.code}}" ng-click="setCode(key, sCode.code)"></li>
+                    </ul>
 				</div>
 				<div class="form-item form-right">
 					<span>品牌:</span>
-					<input type="text" class="form-control" ng-model="mate.ptrBranden" placeholder="请输入品牌名称">
-					<i class="fa fa-minus-circle" ng-if="replaceMaterialList.length > 1" ng-click="setReplies('sub', $index)"></i>
-					<i class="fa fa-plus-circle" ng-if="replaceMaterialList.length < 10" ng-click="setReplies('add', $index)"></i>
+					<input type="text" class="form-control" ng-model="mate.ptrBranden" ng-change="onBrandChange(mate.ptrBranden, key)" ng-blur="onBrandBlur(key)" placeholder="请输入品牌名称">
+                    <ul class="similar-list" ng-show="mate.showSimilarBrandList" ng-mouseenter="setIsInBrandList(true)" ng-mouseleave="setIsInBrandList(false)">
+                        <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" ng-click="setReplies('sub', key)"></i>
+					<i class="fa fa-plus-circle" ng-if="replaceMaterialList.length < 10" ng-click="setReplies('add', key)"></i>
 				</div>
 			</div>
 		</div>