Browse Source

替代料bug修改

yangc 8 years ago
parent
commit
39be8b175d

+ 74 - 13
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialPersonCtrl.js

@@ -2505,15 +2505,15 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		]
 		$scope.setReplies = function (type, index) {
 			if (type === 'add' && $scope.replaceMaterialList.length < 10) {
-                for (var index = 0 ;index < $scope.replaceMaterialList.length ; index ++) {
-                        $scope.errorObj[index] = {code : 0, brand : 0};
-                        if (!$scope.replaceMaterialList[index].ptrCmpcode) {
-                            $scope.errorObj[index].code = 1;
+                for (var i = 0; i < $scope.replaceMaterialList.length; i ++) {
+                        $scope.errorObj[i] = {code : 0, brand : 0};
+                        if (!$scope.replaceMaterialList[i].ptrCmpcode) {
+                            $scope.errorObj[i].code = 1;
                         }
-                        if (!$scope.replaceMaterialList[index].ptrBranden) {
-                            $scope.errorObj[index].brand = 1;
+                        if (!$scope.replaceMaterialList[i].ptrBranden) {
+                            $scope.errorObj[i].brand = 1;
                         }
-					if ($scope.replaceMaterialList[index].ptrBranden && $scope.replaceMaterialList[index].ptrCmpcode) {
+					if ($scope.replaceMaterialList[i].ptrBranden && $scope.replaceMaterialList[i].ptrCmpcode) {
                         $scope.canAdd = true;
 					} else {
                         $scope.canAdd = false;
@@ -2536,6 +2536,28 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			}
 		}
 
+		var getRealLen = function (str) {
+			var len = 0;
+			for (var i = 0; i < str.length; i++) {
+				if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
+					len += 2;
+				} else {
+					len++;
+				}
+			}
+			return len;
+		};
+
+		var cutOutString = function (str, length) {
+			for (var i = 1; i <= str.length; i++) {
+				if (getRealLen(str.substr(0, i)) > length){
+					str = str.substr(0, i-1);
+					break;
+				}
+			}
+			return str;
+		};
+
 		// $scope.showSimilarCodeList = false;
 		$scope.isInCodeList = true;
 		// $scope.showSimilarBrandList = false;
@@ -2582,17 +2604,45 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			$scope.isInBrandList = flag;
 		}
 		$scope.onCodeChange = function (code, index) {
-			if (!code) {
-				$scope.setShowSimilarCodeList(false, index);
+			if ((/[^\x00-\xff]/g).test(code)) {
+				var chineseIndex = -1;
+				for (var i = 0; i < code.length; i++) {
+					if ((/[^\x00-\xff]/g).test(code.charAt(i))) {
+						chineseIndex = i;
+						break;
+					}
+				}
+				$scope.replaceMaterialList[index].ptrCmpcode = cutOutString(code, chineseIndex);
+			} else if (code && getRealLen(code) > 100) {
+				$scope.replaceMaterialList[index].ptrCmpcode = cutOutString(code, 100);
 			} else {
-				$scope.getSimilarCode(code, index);
+				if (!code) {
+					$scope.setShowSimilarCodeList(false, index);
+				} else {
+					$scope.getSimilarCode(code, index);
+				}
 			}
 		}
 		$scope.onBrandChange = function (brand, index) {
-			if (!brand) {
-				$scope.setShowSimilarBrandList(false, index);
+			if ((/[^\x00-\xff]/g).test(brand)) {
+				var chineseIndex = -1;
+				for (var i = 0; i < brand.length; i++) {
+					if ((/[^\x00-\xff]/g).test(brand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(brand.charAt(i))) {
+						chineseIndex = i;
+						break;
+					}
+				}
+				if (chineseIndex > -1) {
+					$scope.replaceMaterialList[index].ptrBranden = brand.substring(0, chineseIndex);
+				}
+			} else if (brand && getRealLen(brand) > 50) {
+				$scope.replaceMaterialList[index].ptrBranden = cutOutString(brand, 50);
 			} else {
-				$scope.getSimilarBrand(brand, index);
+				if (!brand) {
+					$scope.setShowSimilarBrandList(false, index);
+				} else {
+					$scope.getSimilarBrand(brand, index);
+				}
 			}
 		}
 		$scope.onCodeBlur = function (index) {
@@ -2722,6 +2772,17 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			};
 			$modalInstance.close(a);
 		};
+		var getRealLen = function (str) {
+			var len = 0;
+			for (var i = 0; i < str.length; i++) {
+				if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
+					len += 2;
+				} else {
+					len++;
+				}
+			}
+			return len;
+		}
 	}]);
 
 

+ 10 - 6
src/main/webapp/resources/view/vendor/forstore/vendor_material_person.html

@@ -109,6 +109,10 @@
 	.public-tab.table>tbody>tr>td{
 		border-top: none;
 		border-bottom: #e8e8e8 1px solid;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		white-space: nowrap;
+		padding: 0 10px;
 	}
 	.public-tab.table>tbody>tr>td a{
 		margin: 0;
@@ -125,14 +129,14 @@
 	.public-tab.table>tbody>tr>td span{
 		margin: 0;
 	}
-	.public-tab.table>tbody>tr>td span.brand-type{
+	/*.public-tab.table>tbody>tr>td span.brand-type{
 		display: inline-block;
 		margin: 0;
-		width: 80%;
+		width: 180px;
 		overflow: hidden;
 		text-overflow: ellipsis;
 		white-space: nowrap;
-	}
+	}*/
 	.public-tab.table>tbody>tr>td span:hover span {
 		color: #fff;
 		background: #5078cb;
@@ -1562,7 +1566,7 @@
 	.edit-replace-box {
 		position: fixed;
 		width: 510px;
-		top: 12%;
+		top: 10%;
 		left: 33%;
 		/*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
 		/*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
@@ -2249,8 +2253,8 @@
 								<div class="replace-list">
 									<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>
+										<span title="{{replace.ptrCmpcode}}">型号:{{replace.ptrCmpcode}}</span>
+										<span title="{{replace.ptrBranden}}">品牌:{{replace.ptrBranden}}</span>
 									</div>
 									<div ng-if="(material.productReplaceList.length < 4 && material.productReplaceList.length % 2 !== 0) || (material.productReplaceList.length > 4 && material.showMoreReplace && material.productReplaceList.length % 2 !== 0)" class="replace-item"></div>
 								</div>