fanxw 5 lat temu
rodzic
commit
a4f58cb45d

+ 37 - 22
src/main/resources/static/app/basic/tank/controller/TankCtrl.js

@@ -89,29 +89,44 @@ angular.module('app.basic')
89 89
     }
90 90
 
91 91
     // 油罐编码最多只能输入数字
92
-    $scope.checkUp = function(key) {
93
-    	var text;
94
-    	var a;
95
-    	var reg = /^\d$/g;
96
-    	if (key == "ygbm") {
97
-    		text = $scope.tank.storagetankCode;
98
-    		if (text != null && text != "") {
99
-    			a = text.substring(text.length - 1, text.length);
100
-    			if (!reg.test(a)) {
101
-    				$scope.tank.storagetankCode = text.replace(a, "");
102
-    			}
103
-    		}
104
-    	}
105
-    	
106
-//    	var text = $scope.tank.storagetankCode;
107
-//    	if (text != null && text != "") {
108
-//    		var a = text.substring(text.length - 1, text.length);
109
-//	    	var reg = /^\d$/g;
110
-//	    	if (!reg.test(a)) {
111
-//	    		$scope.tank.storagetankCode = text.replace(a, "");
112
-//	    	}
92
+//    $scope.checkUp = function(key) {
93
+//    	var text;
94
+//    	var a;
95
+//    	var reg = /^\d{3}/;
96
+//    	if (key == "ygbm") {
97
+//    		text = $scope.tank.storagetankCode;
98
+//    		if (text != null && text != "") {
99
+//    			a = text.substring(text.length - 1, text.length);
100
+//    			if (!reg.test(a)) {
101
+//    				$scope.tank.storagetankCode = text.replace(a, "");
102
+//    			}
103
+//    		}
113 104
 //    	}
114
-    }
105
+//
106
+//    }
107
+    
108
+    $.validator.addMethod("validTankCode",function(value,element, params) {
109
+    	if(value == 0){
110
+    		return this.optional(element); 
111
+    	}else{
112
+    		var text;
113
+        	//var a;
114
+        	var reg = /^YG+\d{3}/;
115
+        	//if (key == "ygbm") {
116
+        		text = $scope.tank.storagetankCode;
117
+        		if (text != null && text != "") {
118
+        			//a = text.substring(text.length - 1, text.length);
119
+        			if (!reg.test(text)) {
120
+        				return this.optional(element) || false;
121
+        				//$scope.tank.storagetankCode = text.replace(a, "");
122
+        			}
123
+        		} else {
124
+        			return this.optional(element) || false;
125
+        		}
126
+        	//}
127
+    		return this.optional(element) || true;
128
+    	}
129
+    }, "请输入正确的编码格式,如:YG001!");
115 130
     
116 131
     $.validator.addMethod("validThan0",function(value,element, params) {
117 132
     	if(value == 0){

+ 2 - 4
src/main/resources/static/app/basic/tank/view/tank-edit.html

@@ -41,10 +41,8 @@
41 41
                                             <th>
42 42
                                                 <label class="input">
43 43
                                                 <!-- ng-keyup="checkUp('ygbm')" -->
44
-                                                    <input type="text" maxlength="3" ng-model="tank.storagetankCode" name="storagetankCode"
45
-                                                            required ng-readonly="isNotEdit"
46
-                                                           oninput="if(value.length>3) value=value.slice(0,3)" 
47
-                                                           onkeyup="this.value= this.value.match(/\d{0,3}/) ? this.value.match(/\d{0,3}/)[0] : ''" />
44
+                                                    <input type="text" maxlength="5" ng-model="tank.storagetankCode" name="storagetankCode"
45
+                                                            required ng-readonly="isNotEdit" validTankCode=true />
48 46
                                                 </label>
49 47
                                             </th>
50 48
                                             <th>

Plik diff jest za duży
+ 628 - 613
src/main/resources/static/build/app.js