Elements-SY

modify

...@@ -442,18 +442,6 @@ export default { ...@@ -442,18 +442,6 @@ export default {
442 unbind: function (el) { 442 unbind: function (el) {
443 el.removeEventListener("input", el.handler); 443 el.removeEventListener("input", el.handler);
444 }, 444 },
445 - /*
446 - -7 +7
447 - 0~7
448 - 或者 空
449 - 不能输入小数点
450 - Math.abs(-7);
451 - 不能输入和选择未来日期,
452 - 不能输入和选择历史日期,
453 - 选择时间范围,
454 - 只能输入四位正整数,不能够有小数点,
455 - 只能输入四位正整数保留3位小数,
456 - */
457 }, 445 },
458 }, 446 },
459 filters: { 447 filters: {
...@@ -575,6 +563,10 @@ export default { ...@@ -575,6 +563,10 @@ export default {
575 }, 563 },
576 // input失焦事件 564 // input失焦事件
577 inputBlur(name) { 565 inputBlur(name) {
566 + let coin = {
567 + minCNYCustomVal: "CNY",
568 + minSUDCustomVal: "USD",
569 + };
578 if (name == "minWeight") { 570 if (name == "minWeight") {
579 this.validateMaxWeight("maxWeight"); 571 this.validateMaxWeight("maxWeight");
580 this.validateMinWeight(name); 572 this.validateMinWeight(name);
...@@ -592,18 +584,10 @@ export default { ...@@ -592,18 +584,10 @@ export default {
592 this.validateMaxPieces(name); 584 this.validateMaxPieces(name);
593 } 585 }
594 if (name == "minCNYCustomVal" || name == "minSUDCustomVal") { 586 if (name == "minCNYCustomVal" || name == "minSUDCustomVal") {
595 - let coin = {
596 - minCNYCustomVal: "CNY",
597 - minSUDCustomVal: "USD",
598 - };
599 this.validateMaxCustomVal(coin[name]); 587 this.validateMaxCustomVal(coin[name]);
600 this.validateMinCustomVal(coin[name]); 588 this.validateMinCustomVal(coin[name]);
601 } 589 }
602 if (name == "maxCNYCustomVal" || name == "maxSUDCustomVal") { 590 if (name == "maxCNYCustomVal" || name == "maxSUDCustomVal") {
603 - let coin = {
604 - maxCNYCustomVal: "CNY",
605 - maxSUDCustomVal: "USD",
606 - };
607 this.validateMinCustomVal(coin[name]); 591 this.validateMinCustomVal(coin[name]);
608 this.validateMaxCustomVal(coin[name]); 592 this.validateMaxCustomVal(coin[name]);
609 } 593 }
......
...@@ -137,73 +137,29 @@ export default { ...@@ -137,73 +137,29 @@ export default {
137 validateMinPieces(name) { 137 validateMinPieces(name) {
138 // 校验输入的规则(只能输入正整数) 138 // 校验输入的规则(只能输入正整数)
139 if (/^\d+$/.test(Number(this.queryForm[name]))) { 139 if (/^\d+$/.test(Number(this.queryForm[name]))) {
140 - /*
141 - 【表单校验分析步骤】如下:
142 - 1、校验合规数字(只能输入正整数);
143 - 2、校验一种所有的表单域都为空的情况下 & 所有表单域都不为空的情况下;
144 - 3、所有表单域都为空的情况下最好办,直接返回false;
145 - 4、所有表单都不为空的情况下:这种情况就是做自定义校验;
146 - 5、自定义校验符合规则的返回true否则返回false;
147 - 提示:在做校验数字规则一定要注意无理数(E & e);
148 -
149 -
150 -
151 - :rule="{
152 - el: '.el' || document.querySelector(el), // 获取元素
153 - rule: [], // 规则
154 - value: scope.row, // 校验的值
155 - message: '', // 提示语
156 - style: {}, // 设置提示语文字
157 - hoverMessage: false, // 是否通过鼠标hover时提示Error
158 - required: true,
159 - trigger: 'blur',
160 - }"
161 - 通常情况下表单校验都是单列校验,也就是说每个表单域的校验都是独立的而不受其他表单域的校验的牵涉;
162 - 但是有些情况下,我们的表单校验可能有多列并行校验,比如说重量区间,最大重量和最小重量两个表单域,
163 - 最大重量不能小于最小重量。
164 -
165 - 提交表单的时候获取布尔值或者每一个表单校验的
166 - 单列校验或者多列(并行)校验,
167 -
168 - 使用自定义指令做表单校验:
169 - 当校验不合规则时,一种是插入节点给文本提示的同时让input文本框变成红色的;
170 - 一种是让文本框变成红色的同时鼠标hover的时候弹出悬浮框提示;
171 - 当提交表单的时候不合规则的表单域全部红色描边,并且报错文本提示语
172 -
173 - 提交表单的时候
174 -
175 - */
176 -
177 if (this.queryForm[name] && this.queryForm.maxNumOfPieces) { 140 if (this.queryForm[name] && this.queryForm.maxNumOfPieces) {
178 - // 左区间大于右区间
179 if ( 141 if (
180 Number(this.queryForm[name]) > Number(this.queryForm.maxNumOfPieces) 142 Number(this.queryForm[name]) > Number(this.queryForm.maxNumOfPieces)
181 ) { 143 ) {
182 this.$refs.minNumOfPieces.innerHTML = ""; 144 this.$refs.minNumOfPieces.innerHTML = "";
183 this.$refs.minNumOfPieces.innerHTML = "最少件数不得大于最多件数"; 145 this.$refs.minNumOfPieces.innerHTML = "最少件数不得大于最多件数";
184 } else if ( 146 } else if (
185 - Number(this.queryForm[name]) == null && 147 + Number(this.queryForm[name]) < 1 ||
186 - Number(this.queryForm.maxNumOfPieces) == null 148 + Number(this.queryForm.maxNumOfPieces) < 1
187 - ) {
188 - this.$refs.minNumOfPieces.innerHTML = "";
189 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为空";
190 - } else if (
191 - Number(this.queryForm[name]) == 0 &&
192 - Number(this.queryForm.maxNumOfPieces) == 0
193 ) { 149 ) {
194 this.$refs.minNumOfPieces.innerHTML = ""; 150 this.$refs.minNumOfPieces.innerHTML = "";
195 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为0"; 151 + this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能小于1";
196 } else { 152 } else {
197 this.$refs.minNumOfPieces.innerHTML = ""; 153 this.$refs.minNumOfPieces.innerHTML = "";
198 return true; 154 return true;
199 } 155 }
200 - } // 不能为空,不能等于0,不能大于指定的数 156 + } else if (
201 - else if (Number(this.queryForm[name]) == null) { 157 + this.queryForm[name] !== null &&
202 - this.$refs.minNumOfPieces.innerHTML = ""; 158 + this.queryForm[name] !== ""
203 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为空"; 159 + ) {
204 - } else if (Number(this.queryForm[name]) == 0) { 160 + if (Number(this.queryForm[name]) < 1) {
205 this.$refs.minNumOfPieces.innerHTML = ""; 161 this.$refs.minNumOfPieces.innerHTML = "";
206 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为0"; 162 + this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能小于1";
207 } else if (Number(this.queryForm[name]) > 100) { 163 } else if (Number(this.queryForm[name]) > 100) {
208 this.$refs.minNumOfPieces.innerHTML = ""; 164 this.$refs.minNumOfPieces.innerHTML = "";
209 this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能大于100"; 165 this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能大于100";
...@@ -213,6 +169,9 @@ export default { ...@@ -213,6 +169,9 @@ export default {
213 } 169 }
214 } else { 170 } else {
215 this.$refs.minNumOfPieces.innerHTML = ""; 171 this.$refs.minNumOfPieces.innerHTML = "";
172 + }
173 + } else {
174 + this.$refs.minNumOfPieces.innerHTML = "";
216 this.$refs.minNumOfPieces.innerHTML = "请输入有效件数"; 175 this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
217 return false; 176 return false;
218 } 177 }
...@@ -221,35 +180,30 @@ export default { ...@@ -221,35 +180,30 @@ export default {
221 validateMaxPieces(name) { 180 validateMaxPieces(name) {
222 // 校验输入的规则(只能输入正整数) 181 // 校验输入的规则(只能输入正整数)
223 if (/^\d+$/.test(Number(this.queryForm[name]))) { 182 if (/^\d+$/.test(Number(this.queryForm[name]))) {
224 - if (this.queryForm[name] && this.queryForm.maxNumOfPieces) { 183 + if (this.queryForm[name] && this.queryForm.minNumOfPieces) {
225 if ( 184 if (
226 Number(this.queryForm[name]) < Number(this.queryForm.minNumOfPieces) 185 Number(this.queryForm[name]) < Number(this.queryForm.minNumOfPieces)
227 ) { 186 ) {
228 this.$refs.minNumOfPieces.innerHTML = ""; 187 this.$refs.minNumOfPieces.innerHTML = "";
229 this.$refs.minNumOfPieces.innerHTML = "最大件数不得小于最少件数"; 188 this.$refs.minNumOfPieces.innerHTML = "最大件数不得小于最少件数";
230 } else if ( 189 } else if (
231 - Number(this.queryForm[name]) == null && 190 + Number(this.queryForm[name]) < 1 ||
232 - Number(this.queryForm.minNumOfPieces) == null 191 + Number(this.queryForm.minNumOfPieces) < 1
233 - ) {
234 - this.$refs.minNumOfPieces.innerHTML = "";
235 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为空";
236 - } else if (
237 - Number(this.queryForm[name]) == 0 &&
238 - Number(this.queryForm.minNumOfPieces) == 0
239 ) { 192 ) {
240 this.$refs.minNumOfPieces.innerHTML = ""; 193 this.$refs.minNumOfPieces.innerHTML = "";
241 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为0"; 194 + this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能小于1";
242 return false; 195 return false;
243 } else { 196 } else {
244 this.$refs.minNumOfPieces.innerHTML = ""; 197 this.$refs.minNumOfPieces.innerHTML = "";
245 return true; 198 return true;
246 } 199 }
247 - } else if (Number(this.queryForm[name]) == null) { 200 + } else if (
248 - this.$refs.minNumOfPieces.innerHTML = ""; 201 + this.queryForm[name] !== null &&
249 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为空"; 202 + this.queryForm[name] !== ""
250 - } else if (Number(this.queryForm[name]) == 0) { 203 + ) {
204 + if (Number(this.queryForm[name]) < 1) {
251 this.$refs.minNumOfPieces.innerHTML = ""; 205 this.$refs.minNumOfPieces.innerHTML = "";
252 - this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能为0"; 206 + this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能小于1";
253 } else if (Number(this.queryForm[name]) > 100) { 207 } else if (Number(this.queryForm[name]) > 100) {
254 this.$refs.minNumOfPieces.innerHTML = ""; 208 this.$refs.minNumOfPieces.innerHTML = "";
255 this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能大于100"; 209 this.$refs.minNumOfPieces.innerHTML = "最少件数和最多件数不能大于100";
...@@ -259,7 +213,10 @@ export default { ...@@ -259,7 +213,10 @@ export default {
259 } 213 }
260 } else { 214 } else {
261 this.$refs.minNumOfPieces.innerHTML = ""; 215 this.$refs.minNumOfPieces.innerHTML = "";
262 - this.$refs.maxNumOfPieces.innerHTML = "请输入有效件数"; 216 + }
217 + } else {
218 + this.$refs.minNumOfPieces.innerHTML = "";
219 + this.$refs.minNumOfPieces.innerHTML = "请输入有效件数";
263 return false; 220 return false;
264 } 221 }
265 }, 222 },
......