@cloudbase/weda-ui-mp 3.10.2 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/form/form/wd-form.wxss +2 -0
- package/components/form-field-behavior/form-field-behavior.js +16 -1
- package/components/form-field-behavior/validator.js +6 -2
- package/components/navLayout/index.wxss +5 -1
- package/components/wd-form/index.js +1 -1
- package/components/wd-form/wd-form.wxss +2 -0
- package/components/wd-form-item/wd-form-item.wxss +2 -0
- package/components/wd-form-item-obj/wd-form-item.wxss +2 -0
- package/components/wd-input/inner-input/wd-input.wxss +2 -0
- package/components/wd-progress/wd-progress.wxss +2 -0
- package/components/wd-rating/wd-rating.wxss +2 -0
- package/components/wd-switch/wd-switch.wxss +2 -0
- package/components/wd-tag-select/wd-tag-select.wxss +2 -0
- package/package.json +1 -1
- package/utils/enum.js +5 -1
- package/utils/error.js +4 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { validType } from './validator';
|
|
2
2
|
import equal from '../../utils/deepEqual';
|
|
3
|
+
import { errorHandler } from '../../utils/error';
|
|
4
|
+
|
|
3
5
|
import { autorun, untracked } from 'mobx';
|
|
4
6
|
import {
|
|
5
7
|
convertStatus,
|
|
@@ -40,6 +42,10 @@ export default Behavior({
|
|
|
40
42
|
type: Boolean,
|
|
41
43
|
value: true,
|
|
42
44
|
},
|
|
45
|
+
label: {
|
|
46
|
+
type: String,
|
|
47
|
+
value: '标题',
|
|
48
|
+
},
|
|
43
49
|
requiredMsg: {
|
|
44
50
|
type: String,
|
|
45
51
|
value: '该项为必填项',
|
|
@@ -93,7 +99,7 @@ export default Behavior({
|
|
|
93
99
|
setHidden() {
|
|
94
100
|
that.setVisible(false);
|
|
95
101
|
},
|
|
96
|
-
async handleValidate() {
|
|
102
|
+
async handleValidate(throwError = true) {
|
|
97
103
|
let finalValue = that.data.value;
|
|
98
104
|
const {
|
|
99
105
|
required,
|
|
@@ -101,6 +107,7 @@ export default Behavior({
|
|
|
101
107
|
requiredMsg,
|
|
102
108
|
privateRules,
|
|
103
109
|
selfDefineRules,
|
|
110
|
+
label,
|
|
104
111
|
} = that.data;
|
|
105
112
|
const _rules = [].concat(rules, privateRules, selfDefineRules);
|
|
106
113
|
if (!required && !_rules.length) return;
|
|
@@ -189,6 +196,14 @@ export default Behavior({
|
|
|
189
196
|
validateState: 'error',
|
|
190
197
|
validateErrorMsg: errorArr[0].message,
|
|
191
198
|
});
|
|
199
|
+
if (throwError) {
|
|
200
|
+
const { compError } = errorHandler({
|
|
201
|
+
code: 'VALIDATE_ERROR',
|
|
202
|
+
error: errorArr,
|
|
203
|
+
message: `【${label}】${errorArr[0]?.message}`,
|
|
204
|
+
});
|
|
205
|
+
throw compError;
|
|
206
|
+
}
|
|
192
207
|
} else {
|
|
193
208
|
// console.log("校验成功>>>>>>>")
|
|
194
209
|
that.setData({
|
|
@@ -13,9 +13,10 @@ const pattern = {
|
|
|
13
13
|
userName: /^[\da-zA-Z\u2E80-\uFE4F \s]{2,}$/,
|
|
14
14
|
carId:
|
|
15
15
|
/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
|
|
16
|
-
mobile:
|
|
16
|
+
mobile: /^1[3-9]\d{9}$/,
|
|
17
|
+
tel: /(^(0\d{2,3}-)?|^\(\d{3}\)?|^(400|800)-?)(\d{3,8})(-\d{1,4})?$/,
|
|
18
|
+
internationalTel:
|
|
17
19
|
/^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
|
|
18
|
-
tel: /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
|
|
19
20
|
address: /^[\da-zA-Z\u2E80-\uFE4F \s-]{4,400}$/,
|
|
20
21
|
date: /((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/,
|
|
21
22
|
numVcode: /^[0-9]{4,8}$/,
|
|
@@ -67,6 +68,9 @@ export const validType = {
|
|
|
67
68
|
tel(value) {
|
|
68
69
|
return pattern.tel.test(String(value).trim());
|
|
69
70
|
},
|
|
71
|
+
internationalTel(value) {
|
|
72
|
+
return pattern.internationalTel.test(String(value).trim());
|
|
73
|
+
},
|
|
70
74
|
// 邮箱检测
|
|
71
75
|
email(value) {
|
|
72
76
|
return typeof value === 'string' && pattern.email.test(value.trim());
|
|
@@ -110,7 +110,11 @@
|
|
|
110
110
|
width: 100%;
|
|
111
111
|
height: 100%;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
.weda-grid-navigation__icon {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
}
|
|
114
118
|
.weda-grid-navigation .weda-grid-navigation__col .weda-grid-navigation__text {
|
|
115
119
|
font-size: 0.85714em;
|
|
116
120
|
line-height: 1.42857em;
|
package/package.json
CHANGED
package/utils/enum.js
CHANGED
|
@@ -709,13 +709,17 @@ export const WD_INPUT_RULES = [
|
|
|
709
709
|
value: 'cn',
|
|
710
710
|
},
|
|
711
711
|
{
|
|
712
|
-
label: '
|
|
712
|
+
label: '大陆手机号',
|
|
713
713
|
value: 'mobile',
|
|
714
714
|
},
|
|
715
715
|
{
|
|
716
716
|
label: '固定电话',
|
|
717
717
|
value: 'tel',
|
|
718
718
|
},
|
|
719
|
+
{
|
|
720
|
+
label: '通用电话(国内及境外手机号、电话)',
|
|
721
|
+
value: 'internationalTel',
|
|
722
|
+
},
|
|
719
723
|
{
|
|
720
724
|
label: '网址',
|
|
721
725
|
value: 'url',
|
package/utils/error.js
CHANGED
|
@@ -11,12 +11,14 @@ export class WdCompError extends Error {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const errorHandler = ({ id = '', code, error }) => {
|
|
14
|
+
export const errorHandler = ({ id = '', code, error, message = '' }) => {
|
|
15
15
|
const comErrorInfo = {
|
|
16
16
|
code,
|
|
17
17
|
requestId: error?.requestId,
|
|
18
18
|
original: error,
|
|
19
|
-
message:
|
|
19
|
+
message:
|
|
20
|
+
message ||
|
|
21
|
+
`[组件${id}:${code}]${error?.message || error?.errMsg || code}`,
|
|
20
22
|
};
|
|
21
23
|
const compError = new WdCompError(comErrorInfo.message, comErrorInfo);
|
|
22
24
|
console.error(`${comErrorInfo.code}:`, comErrorInfo);
|