@cloudbase/weda-ui-mp 3.18.4 → 3.18.5
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.
|
@@ -97,9 +97,23 @@ export default Behavior({
|
|
|
97
97
|
},
|
|
98
98
|
async handleValidate(throwError = true) {
|
|
99
99
|
let finalValue = that.data.value;
|
|
100
|
+
const validPromise = [];
|
|
101
|
+
if (that.data?.formsItemMap && Object.values(that.data?.formsItemMap)?.length) {
|
|
102
|
+
Object.values(that.data?.formsItemMap).forEach((field) => {
|
|
103
|
+
field?.forEach((item) => {
|
|
104
|
+
if (item.handleValidate) {
|
|
105
|
+
const validate = item.handleValidate(false);
|
|
106
|
+
if (validate) {
|
|
107
|
+
validPromise.push(validate);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
const { required, rules, requiredMsg, privateRules, selfDefineRules, label } = that.data;
|
|
101
115
|
const _rules = [].concat(rules, privateRules, selfDefineRules);
|
|
102
|
-
if (!required && !_rules.length) return;
|
|
116
|
+
if (!required && !_rules.length && !validPromise.length) return;
|
|
103
117
|
if (finalValue) {
|
|
104
118
|
if (typeof finalValue === 'string') {
|
|
105
119
|
if (finalValue.trim) {
|
|
@@ -110,7 +124,6 @@ export default Behavior({
|
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
const validPromise = [];
|
|
114
127
|
if (required) {
|
|
115
128
|
if (!validType.required(finalValue)) {
|
|
116
129
|
validPromise.push(Promise.resolve({ format: 'required', message: requiredMsg }));
|
|
@@ -171,10 +184,12 @@ export default Behavior({
|
|
|
171
184
|
}
|
|
172
185
|
}
|
|
173
186
|
}
|
|
174
|
-
const errorArr = await Promise.all(validPromise).then((arr) => {
|
|
175
|
-
return arr
|
|
187
|
+
const errorArr = await Promise.all(validPromise?.flat()).then((arr) => {
|
|
188
|
+
return arr
|
|
189
|
+
?.filter((item) => item !== void 0)
|
|
190
|
+
?.filter((i) => (Array.isArray(i) ? i.length > 0 : i))
|
|
191
|
+
?.map((i) => ({ ...i, label }));
|
|
176
192
|
});
|
|
177
|
-
|
|
178
193
|
if (errorArr.length > 0) {
|
|
179
194
|
that.setData({
|
|
180
195
|
validateState: 'error',
|
|
@@ -125,11 +125,9 @@ Component({
|
|
|
125
125
|
position,
|
|
126
126
|
isMaskShow,
|
|
127
127
|
defaultMaskShow,
|
|
128
|
-
isBdShow
|
|
128
|
+
isBdShow,
|
|
129
129
|
) {
|
|
130
|
-
const defaultWidth = { center: 'calc(100% - 4.57rem)', bottom: '100%' }[
|
|
131
|
-
position
|
|
132
|
-
];
|
|
130
|
+
const defaultWidth = { center: 'calc(100% - 4.57rem)', bottom: '100%' }[position];
|
|
133
131
|
const styleShow = `width: ${defaultWidth};` + style;
|
|
134
132
|
const styleMain = style?.match(/(display:).*?(;)/g)?.join('');
|
|
135
133
|
|
|
@@ -153,8 +151,7 @@ Component({
|
|
|
153
151
|
'weda-modal-new': true,
|
|
154
152
|
[`${WD_PREFIX}-modal-bd`]: true,
|
|
155
153
|
[`${WD_PREFIX}-modal-bd__toggle`]: isBdShow,
|
|
156
|
-
[`${WD_PREFIX}-modal-bd__box`]:
|
|
157
|
-
!defaultMaskShow && position === 'center',
|
|
154
|
+
[`${WD_PREFIX}-modal-bd__box`]: !defaultMaskShow && position === 'center',
|
|
158
155
|
});
|
|
159
156
|
|
|
160
157
|
this.setData({
|
|
@@ -165,17 +162,12 @@ Component({
|
|
|
165
162
|
modalBdClasses,
|
|
166
163
|
});
|
|
167
164
|
},
|
|
168
|
-
defaultShow: function (defaultShow) {
|
|
169
|
-
this.dealShow(defaultShow);
|
|
170
|
-
},
|
|
171
165
|
'isBdShow,openInfo,closeInfo': function () {
|
|
172
166
|
this.updateWidgetAPI();
|
|
173
167
|
},
|
|
174
168
|
template: function (template) {
|
|
175
169
|
const modalFtClasses = classNames({
|
|
176
|
-
[`${WD_PREFIX}-modal-bd__ft-text-btn`]: ['confirm', 'notice'].includes(
|
|
177
|
-
template
|
|
178
|
-
),
|
|
170
|
+
[`${WD_PREFIX}-modal-bd__ft-text-btn`]: ['confirm', 'notice'].includes(template),
|
|
179
171
|
[`${WD_PREFIX}-modal-bd__ft-text-btn--vertical`]: template === 'notice',
|
|
180
172
|
});
|
|
181
173
|
this.setData({ modalFtClasses });
|