@form-create/element-ui 3.2.21 → 3.2.22
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/dist/form-create.esm.js +487 -71
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +487 -71
- package/dist/form-create.min.js +2 -2
- package/package.json +4 -4
- package/src/core/api.js +6 -4
- package/src/core/manager.js +2 -2
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.2.
|
|
2
|
+
* @form-create/element-ui v3.2.22
|
|
3
3
|
* (c) 2018-2025 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -166,6 +166,10 @@
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
function _slicedToArray(arr, i) {
|
|
170
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
function _toConsumableArray(arr) {
|
|
170
174
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
171
175
|
}
|
|
@@ -174,10 +178,44 @@
|
|
|
174
178
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
175
179
|
}
|
|
176
180
|
|
|
181
|
+
function _arrayWithHoles(arr) {
|
|
182
|
+
if (Array.isArray(arr)) return arr;
|
|
183
|
+
}
|
|
184
|
+
|
|
177
185
|
function _iterableToArray(iter) {
|
|
178
186
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
179
187
|
}
|
|
180
188
|
|
|
189
|
+
function _iterableToArrayLimit(arr, i) {
|
|
190
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
191
|
+
|
|
192
|
+
if (_i == null) return;
|
|
193
|
+
var _arr = [];
|
|
194
|
+
var _n = true;
|
|
195
|
+
var _d = false;
|
|
196
|
+
|
|
197
|
+
var _s, _e;
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
201
|
+
_arr.push(_s.value);
|
|
202
|
+
|
|
203
|
+
if (i && _arr.length === i) break;
|
|
204
|
+
}
|
|
205
|
+
} catch (err) {
|
|
206
|
+
_d = true;
|
|
207
|
+
_e = err;
|
|
208
|
+
} finally {
|
|
209
|
+
try {
|
|
210
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
211
|
+
} finally {
|
|
212
|
+
if (_d) throw _e;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return _arr;
|
|
217
|
+
}
|
|
218
|
+
|
|
181
219
|
function _unsupportedIterableToArray(o, minLen) {
|
|
182
220
|
if (!o) return;
|
|
183
221
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -199,6 +237,10 @@
|
|
|
199
237
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
200
238
|
}
|
|
201
239
|
|
|
240
|
+
function _nonIterableRest() {
|
|
241
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
242
|
+
}
|
|
243
|
+
|
|
202
244
|
function getSlot(slots, exclude) {
|
|
203
245
|
return Object.keys(slots).reduce(function (lst, name) {
|
|
204
246
|
if (!exclude || exclude.indexOf(name) === -1) {
|
|
@@ -1761,7 +1803,7 @@
|
|
|
1761
1803
|
var keys = this.sort;
|
|
1762
1804
|
|
|
1763
1805
|
if (keys.filter(function (k) {
|
|
1764
|
-
return cacheRule[k].$f;
|
|
1806
|
+
return cacheRule[k] && cacheRule[k].$f;
|
|
1765
1807
|
}).length !== keys.length) {
|
|
1766
1808
|
return;
|
|
1767
1809
|
}
|
|
@@ -1814,6 +1856,7 @@
|
|
|
1814
1856
|
rule: rule,
|
|
1815
1857
|
options: options
|
|
1816
1858
|
};
|
|
1859
|
+
this.sort = Object.keys(this.cacheRule);
|
|
1817
1860
|
|
|
1818
1861
|
if (emit) {
|
|
1819
1862
|
vue.nextTick(function () {
|
|
@@ -1835,6 +1878,7 @@
|
|
|
1835
1878
|
var index = Object.keys(this.cacheRule).indexOf(key);
|
|
1836
1879
|
delete this.cacheRule[key];
|
|
1837
1880
|
delete this.cacheValue[key];
|
|
1881
|
+
this.sort = Object.keys(this.cacheRule);
|
|
1838
1882
|
|
|
1839
1883
|
if (emit) {
|
|
1840
1884
|
vue.nextTick(function () {
|
|
@@ -1957,15 +2001,6 @@
|
|
|
1957
2001
|
}
|
|
1958
2002
|
},
|
|
1959
2003
|
created: function created() {
|
|
1960
|
-
var _this12 = this;
|
|
1961
|
-
|
|
1962
|
-
vue.watch(function () {
|
|
1963
|
-
return _objectSpread2({}, _this12.cacheRule);
|
|
1964
|
-
}, function (n) {
|
|
1965
|
-
_this12.sort = Object.keys(n);
|
|
1966
|
-
}, {
|
|
1967
|
-
immediate: true
|
|
1968
|
-
});
|
|
1969
2004
|
var d = (this.expand || 0) - this.modelValue.length;
|
|
1970
2005
|
|
|
1971
2006
|
for (var i = 0; i < this.modelValue.length; i++) {
|
|
@@ -1977,7 +2012,7 @@
|
|
|
1977
2012
|
}
|
|
1978
2013
|
},
|
|
1979
2014
|
render: function render() {
|
|
1980
|
-
var
|
|
2015
|
+
var _this12 = this;
|
|
1981
2016
|
|
|
1982
2017
|
var keys = this.sort;
|
|
1983
2018
|
var button = this.button;
|
|
@@ -1991,10 +2026,10 @@
|
|
|
1991
2026
|
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
|
|
1992
2027
|
"onClick": this.add
|
|
1993
2028
|
}, null) : keys.map(function (key, index) {
|
|
1994
|
-
var
|
|
1995
|
-
rule =
|
|
1996
|
-
options =
|
|
1997
|
-
var btn = button && !disabled ?
|
|
2029
|
+
var _this12$cacheRule$key = _this12.cacheRule[key],
|
|
2030
|
+
rule = _this12$cacheRule$key.rule,
|
|
2031
|
+
options = _this12$cacheRule$key.options;
|
|
2032
|
+
var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
|
|
1998
2033
|
return vue.createVNode("div", {
|
|
1999
2034
|
"class": "_fc-group-container",
|
|
2000
2035
|
"key": key
|
|
@@ -2003,20 +2038,20 @@
|
|
|
2003
2038
|
}, {
|
|
2004
2039
|
disabled: disabled,
|
|
2005
2040
|
'onUpdate:modelValue': function onUpdateModelValue(formData) {
|
|
2006
|
-
return
|
|
2041
|
+
return _this12.formData(key, formData);
|
|
2007
2042
|
},
|
|
2008
2043
|
'onEmit-event': function onEmitEvent(name) {
|
|
2009
2044
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2010
2045
|
args[_key - 1] = arguments[_key];
|
|
2011
2046
|
}
|
|
2012
2047
|
|
|
2013
|
-
return
|
|
2048
|
+
return _this12.emitEvent(name, args, index, key);
|
|
2014
2049
|
},
|
|
2015
2050
|
'onUpdate:api': function onUpdateApi($f) {
|
|
2016
|
-
return
|
|
2051
|
+
return _this12.add$f(index, key, $f);
|
|
2017
2052
|
},
|
|
2018
2053
|
inFor: true,
|
|
2019
|
-
modelValue:
|
|
2054
|
+
modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
|
|
2020
2055
|
rule: rule,
|
|
2021
2056
|
option: options,
|
|
2022
2057
|
extendOption: true
|
|
@@ -3234,6 +3269,10 @@
|
|
|
3234
3269
|
return undefined;
|
|
3235
3270
|
},
|
|
3236
3271
|
|
|
3272
|
+
get formulas() {
|
|
3273
|
+
return _objectSpread2({}, h.fc.formulas);
|
|
3274
|
+
},
|
|
3275
|
+
|
|
3237
3276
|
formData: function formData(fields) {
|
|
3238
3277
|
if (fields == null || typeof fields === 'boolean') {
|
|
3239
3278
|
var data = {};
|
|
@@ -3664,10 +3703,13 @@
|
|
|
3664
3703
|
}
|
|
3665
3704
|
}
|
|
3666
3705
|
},
|
|
3667
|
-
getChildrenFormData: function getChildrenFormData(id) {
|
|
3706
|
+
getChildrenFormData: function getChildrenFormData(id, flag) {
|
|
3668
3707
|
var rules = api.getChildrenRuleList(id);
|
|
3669
3708
|
return rules.reduce(function (formData, rule) {
|
|
3670
|
-
|
|
3709
|
+
if (rule.ignore !== true || flag === true) {
|
|
3710
|
+
formData[rule.field] = copy(rule.value);
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3671
3713
|
return formData;
|
|
3672
3714
|
}, {});
|
|
3673
3715
|
},
|
|
@@ -3760,7 +3802,7 @@
|
|
|
3760
3802
|
});
|
|
3761
3803
|
reject(e);
|
|
3762
3804
|
});
|
|
3763
|
-
});
|
|
3805
|
+
})["catch"](function (e) {});
|
|
3764
3806
|
});
|
|
3765
3807
|
},
|
|
3766
3808
|
watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
|
|
@@ -3785,7 +3827,7 @@
|
|
|
3785
3827
|
});
|
|
3786
3828
|
error && error(e);
|
|
3787
3829
|
});
|
|
3788
|
-
});
|
|
3830
|
+
})["catch"](function (e) {});
|
|
3789
3831
|
}, opt.wait == null ? 1000 : opt.wait);
|
|
3790
3832
|
},
|
|
3791
3833
|
getData: function getData(id, def) {
|
|
@@ -5946,19 +5988,25 @@
|
|
|
5946
5988
|
return info;
|
|
5947
5989
|
});
|
|
5948
5990
|
ctx.refRule['__$validate'] = vue.computed(function () {
|
|
5991
|
+
var t = function t(msg) {
|
|
5992
|
+
var match = msg.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
|
|
5993
|
+
|
|
5994
|
+
if (match) {
|
|
5995
|
+
var _ctx$refRule, _ctx$refRule$__$title;
|
|
5996
|
+
|
|
5997
|
+
return _this.api.t(match[1], {
|
|
5998
|
+
title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : (_ctx$refRule$__$title = _ctx$refRule.__$title) === null || _ctx$refRule$__$title === void 0 ? void 0 : _ctx$refRule$__$title.value
|
|
5999
|
+
});
|
|
6000
|
+
}
|
|
6001
|
+
|
|
6002
|
+
return msg;
|
|
6003
|
+
};
|
|
6004
|
+
|
|
5949
6005
|
return toArray(ctx.rule.validate).map(function (item) {
|
|
5950
6006
|
var temp = _objectSpread2({}, item);
|
|
5951
6007
|
|
|
5952
6008
|
if (temp.message) {
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
if (match) {
|
|
5956
|
-
var _ctx$refRule, _ctx$refRule$__$title;
|
|
5957
|
-
|
|
5958
|
-
temp.message = _this.api.t(match[1], {
|
|
5959
|
-
title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : (_ctx$refRule$__$title = _ctx$refRule.__$title) === null || _ctx$refRule$__$title === void 0 ? void 0 : _ctx$refRule$__$title.value
|
|
5960
|
-
});
|
|
5961
|
-
}
|
|
6009
|
+
temp.message = t(temp.message);
|
|
5962
6010
|
}
|
|
5963
6011
|
|
|
5964
6012
|
if (is.Function(temp.validator)) {
|
|
@@ -5979,8 +6027,19 @@
|
|
|
5979
6027
|
api: that.$handle.api
|
|
5980
6028
|
}].concat(args));
|
|
5981
6029
|
};
|
|
6030
|
+
}
|
|
6031
|
+
|
|
6032
|
+
if (temp.adapter) {
|
|
6033
|
+
if (_typeof(temp.error) === 'object') {
|
|
6034
|
+
var msg = _objectSpread2({}, temp.error);
|
|
5982
6035
|
|
|
5983
|
-
|
|
6036
|
+
Object.keys(msg).forEach(function (key) {
|
|
6037
|
+
msg[key] = t(msg[key]);
|
|
6038
|
+
});
|
|
6039
|
+
temp.error = msg;
|
|
6040
|
+
}
|
|
6041
|
+
|
|
6042
|
+
return _this.adapterValidate(temp, ctx);
|
|
5984
6043
|
}
|
|
5985
6044
|
|
|
5986
6045
|
return temp;
|
|
@@ -6052,9 +6111,282 @@
|
|
|
6052
6111
|
});
|
|
6053
6112
|
this.watchEffect(ctx);
|
|
6054
6113
|
},
|
|
6055
|
-
|
|
6114
|
+
adapterValidate: function adapterValidate(validate, ctx) {
|
|
6056
6115
|
var _this2 = this;
|
|
6057
6116
|
|
|
6117
|
+
var validator = function validator(value, callback) {
|
|
6118
|
+
var before = validate.beforeValidate && invoke(function () {
|
|
6119
|
+
return validate.beforeValidate({
|
|
6120
|
+
value: value,
|
|
6121
|
+
api: _this2.api,
|
|
6122
|
+
validate: validate,
|
|
6123
|
+
rule: ctx.rule
|
|
6124
|
+
});
|
|
6125
|
+
});
|
|
6126
|
+
|
|
6127
|
+
if (before === false) {
|
|
6128
|
+
callback();
|
|
6129
|
+
} else {
|
|
6130
|
+
var key = _this2.validator(value, validate);
|
|
6131
|
+
|
|
6132
|
+
if (!key) {
|
|
6133
|
+
if (validate.validator) {
|
|
6134
|
+
var res = validate.validator && invoke(function () {
|
|
6135
|
+
return validate.validator(value, callback);
|
|
6136
|
+
});
|
|
6137
|
+
|
|
6138
|
+
if (res && is.Function(res.then)) {
|
|
6139
|
+
res.then(function () {
|
|
6140
|
+
return callback();
|
|
6141
|
+
})["catch"](function (e) {
|
|
6142
|
+
return callback(e);
|
|
6143
|
+
});
|
|
6144
|
+
}
|
|
6145
|
+
} else {
|
|
6146
|
+
callback();
|
|
6147
|
+
}
|
|
6148
|
+
} else {
|
|
6149
|
+
var message = '';
|
|
6150
|
+
|
|
6151
|
+
if (_typeof(validate.error) === 'object') {
|
|
6152
|
+
message = validate.error[key] || validate.error["default"];
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6155
|
+
if (!message && typeof validate.message === 'string') {
|
|
6156
|
+
message = validate.message;
|
|
6157
|
+
}
|
|
6158
|
+
|
|
6159
|
+
if (!message) {
|
|
6160
|
+
message = _this2.getValidateMessage(ctx, {
|
|
6161
|
+
key: key,
|
|
6162
|
+
rule: validate[key]
|
|
6163
|
+
});
|
|
6164
|
+
}
|
|
6165
|
+
|
|
6166
|
+
callback(message);
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
};
|
|
6170
|
+
|
|
6171
|
+
return this.$manager.adapterValidate({
|
|
6172
|
+
required: validate.required,
|
|
6173
|
+
message: validate.message,
|
|
6174
|
+
target: validate.trigger
|
|
6175
|
+
}, validator);
|
|
6176
|
+
},
|
|
6177
|
+
getValidateMessage: function getValidateMessage(ctx, invalid) {
|
|
6178
|
+
var _ctx$refRule2, _ctx$refRule2$__$titl, _this$api$t;
|
|
6179
|
+
|
|
6180
|
+
var formatRule = Array.isArray(invalid.rule) ? invalid.rule.join(',') : '' + invalid.rule;
|
|
6181
|
+
return this.api.t(invalid.key === 'required' ? invalid.key : 'validate.' + invalid.key, (_this$api$t = {}, _defineProperty(_this$api$t, invalid.key, formatRule), _defineProperty(_this$api$t, "title", (_ctx$refRule2 = ctx.refRule) === null || _ctx$refRule2 === void 0 ? void 0 : (_ctx$refRule2$__$titl = _ctx$refRule2.__$title) === null || _ctx$refRule2$__$titl === void 0 ? void 0 : _ctx$refRule2$__$titl.value), _this$api$t));
|
|
6182
|
+
},
|
|
6183
|
+
validator: function validator(value, validate) {
|
|
6184
|
+
var isEmpty = is.empty(value);
|
|
6185
|
+
|
|
6186
|
+
if (isEmpty) {
|
|
6187
|
+
if (validate.required) {
|
|
6188
|
+
return 'required';
|
|
6189
|
+
}
|
|
6190
|
+
|
|
6191
|
+
return;
|
|
6192
|
+
}
|
|
6193
|
+
|
|
6194
|
+
var _loop = function _loop() {
|
|
6195
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
6196
|
+
key = _Object$entries$_i[0],
|
|
6197
|
+
rule = _Object$entries$_i[1];
|
|
6198
|
+
|
|
6199
|
+
switch (key) {
|
|
6200
|
+
case 'len':
|
|
6201
|
+
case 'maxLen':
|
|
6202
|
+
case 'minLen':
|
|
6203
|
+
var check = function check(val) {
|
|
6204
|
+
if (key === 'len') {
|
|
6205
|
+
return val === rule;
|
|
6206
|
+
} else if (key === 'maxLen') {
|
|
6207
|
+
return val <= rule;
|
|
6208
|
+
} else {
|
|
6209
|
+
return val >= rule;
|
|
6210
|
+
}
|
|
6211
|
+
};
|
|
6212
|
+
|
|
6213
|
+
if (Array.isArray(value)) {
|
|
6214
|
+
if (!check(value.length)) {
|
|
6215
|
+
return {
|
|
6216
|
+
v: key
|
|
6217
|
+
};
|
|
6218
|
+
}
|
|
6219
|
+
} else if (_typeof(value) === 'object') {
|
|
6220
|
+
return {
|
|
6221
|
+
v: key
|
|
6222
|
+
};
|
|
6223
|
+
} else if (!check(('' + value).length)) {
|
|
6224
|
+
return {
|
|
6225
|
+
v: key
|
|
6226
|
+
};
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6229
|
+
break;
|
|
6230
|
+
|
|
6231
|
+
case 'pattern':
|
|
6232
|
+
var reg = typeof rule === 'string' ? new RegExp(rule) : rule;
|
|
6233
|
+
|
|
6234
|
+
if (!reg.test('' + value)) {
|
|
6235
|
+
return {
|
|
6236
|
+
v: key
|
|
6237
|
+
};
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6240
|
+
break;
|
|
6241
|
+
|
|
6242
|
+
case 'uppercase':
|
|
6243
|
+
if (rule && (typeof value !== 'string' || !/^[A-Z]*$/.test(value))) {
|
|
6244
|
+
return {
|
|
6245
|
+
v: key
|
|
6246
|
+
};
|
|
6247
|
+
}
|
|
6248
|
+
|
|
6249
|
+
break;
|
|
6250
|
+
|
|
6251
|
+
case 'lowercase':
|
|
6252
|
+
if (rule && (typeof value !== 'string' || !/^[a-z]*$/.test(value))) {
|
|
6253
|
+
return {
|
|
6254
|
+
v: key
|
|
6255
|
+
};
|
|
6256
|
+
}
|
|
6257
|
+
|
|
6258
|
+
break;
|
|
6259
|
+
|
|
6260
|
+
case 'min':
|
|
6261
|
+
case 'max':
|
|
6262
|
+
case 'positive':
|
|
6263
|
+
case 'negative':
|
|
6264
|
+
case 'integer':
|
|
6265
|
+
case 'number':
|
|
6266
|
+
var num = Number(value);
|
|
6267
|
+
|
|
6268
|
+
if (Number.isNaN(num)) {
|
|
6269
|
+
return {
|
|
6270
|
+
v: key
|
|
6271
|
+
};
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
if (key === 'min' && num < rule) {
|
|
6275
|
+
return {
|
|
6276
|
+
v: key
|
|
6277
|
+
};
|
|
6278
|
+
}
|
|
6279
|
+
|
|
6280
|
+
if (key === 'max' && num > rule) {
|
|
6281
|
+
return {
|
|
6282
|
+
v: key
|
|
6283
|
+
};
|
|
6284
|
+
}
|
|
6285
|
+
|
|
6286
|
+
if (key === 'positive' && num <= 0) {
|
|
6287
|
+
return {
|
|
6288
|
+
v: key
|
|
6289
|
+
};
|
|
6290
|
+
}
|
|
6291
|
+
|
|
6292
|
+
if (key === 'negative' && num >= 0) {
|
|
6293
|
+
return {
|
|
6294
|
+
v: key
|
|
6295
|
+
};
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
if (key === 'integer' && !Number.isInteger(num)) {
|
|
6299
|
+
return {
|
|
6300
|
+
v: key
|
|
6301
|
+
};
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
break;
|
|
6305
|
+
|
|
6306
|
+
case 'equal':
|
|
6307
|
+
if (value !== rule) {
|
|
6308
|
+
return {
|
|
6309
|
+
v: key
|
|
6310
|
+
};
|
|
6311
|
+
}
|
|
6312
|
+
|
|
6313
|
+
break;
|
|
6314
|
+
|
|
6315
|
+
case 'enum':
|
|
6316
|
+
if (Array.isArray(rule) && !rule.includes(value)) {
|
|
6317
|
+
return {
|
|
6318
|
+
v: key
|
|
6319
|
+
};
|
|
6320
|
+
}
|
|
6321
|
+
|
|
6322
|
+
break;
|
|
6323
|
+
|
|
6324
|
+
case 'hasKeys':
|
|
6325
|
+
if (_typeof(value) !== 'object' || Array.isArray(rule) && rule.some(function (key) {
|
|
6326
|
+
return !(key in value);
|
|
6327
|
+
})) {
|
|
6328
|
+
return {
|
|
6329
|
+
v: key
|
|
6330
|
+
};
|
|
6331
|
+
}
|
|
6332
|
+
|
|
6333
|
+
break;
|
|
6334
|
+
|
|
6335
|
+
case 'email':
|
|
6336
|
+
var regexEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
6337
|
+
|
|
6338
|
+
if (!regexEmail.test('' + value)) {
|
|
6339
|
+
return {
|
|
6340
|
+
v: key
|
|
6341
|
+
};
|
|
6342
|
+
}
|
|
6343
|
+
|
|
6344
|
+
break;
|
|
6345
|
+
|
|
6346
|
+
case 'url':
|
|
6347
|
+
var regexUrl = new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", 'i');
|
|
6348
|
+
|
|
6349
|
+
if (!regexUrl.test('' + value)) {
|
|
6350
|
+
return {
|
|
6351
|
+
v: key
|
|
6352
|
+
};
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6355
|
+
break;
|
|
6356
|
+
|
|
6357
|
+
case 'ip':
|
|
6358
|
+
var regexIp = /^(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})(\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})){3}$/;
|
|
6359
|
+
|
|
6360
|
+
if (!regexIp.test('' + value)) {
|
|
6361
|
+
return {
|
|
6362
|
+
v: key
|
|
6363
|
+
};
|
|
6364
|
+
}
|
|
6365
|
+
|
|
6366
|
+
break;
|
|
6367
|
+
|
|
6368
|
+
case 'phone':
|
|
6369
|
+
var regexPhone = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
|
|
6370
|
+
|
|
6371
|
+
if (!regexPhone.test('' + value)) {
|
|
6372
|
+
return {
|
|
6373
|
+
v: key
|
|
6374
|
+
};
|
|
6375
|
+
}
|
|
6376
|
+
|
|
6377
|
+
break;
|
|
6378
|
+
}
|
|
6379
|
+
};
|
|
6380
|
+
|
|
6381
|
+
for (var _i = 0, _Object$entries = Object.entries(validate); _i < _Object$entries.length; _i++) {
|
|
6382
|
+
var _ret = _loop();
|
|
6383
|
+
|
|
6384
|
+
if (_typeof(_ret) === "object") return _ret.v;
|
|
6385
|
+
}
|
|
6386
|
+
},
|
|
6387
|
+
compute: function compute(ctx, item) {
|
|
6388
|
+
var _this3 = this;
|
|
6389
|
+
|
|
6058
6390
|
var fn;
|
|
6059
6391
|
|
|
6060
6392
|
if (_typeof(item) === 'object') {
|
|
@@ -6073,13 +6405,13 @@
|
|
|
6073
6405
|
var or = item.mode === 'OR';
|
|
6074
6406
|
var valid = true;
|
|
6075
6407
|
|
|
6076
|
-
var
|
|
6408
|
+
var _loop2 = function _loop2(i) {
|
|
6077
6409
|
var one = item.group[i];
|
|
6078
6410
|
var flag = void 0;
|
|
6079
6411
|
var field = null;
|
|
6080
6412
|
|
|
6081
6413
|
if (one.variable) {
|
|
6082
|
-
field = JSON.stringify(
|
|
6414
|
+
field = JSON.stringify(_this3.fc.getLoadData(one.variable) || '');
|
|
6083
6415
|
} else if (one.field) {
|
|
6084
6416
|
field = convertFieldToConditions(one.field || '');
|
|
6085
6417
|
} else if (!one.mode) {
|
|
@@ -6100,11 +6432,11 @@
|
|
|
6100
6432
|
flag = false;
|
|
6101
6433
|
} else if (is.Function(one.handler)) {
|
|
6102
6434
|
flag = invoke(function () {
|
|
6103
|
-
return one.handler(
|
|
6435
|
+
return one.handler(_this3.api, ctx.rule);
|
|
6104
6436
|
});
|
|
6105
6437
|
} else {
|
|
6106
6438
|
flag = invoke(function () {
|
|
6107
|
-
return new Function('$condition', '$val', '$form', '$scope', '$group', '$rule', "with($form){with($scope){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}}")).call(
|
|
6439
|
+
return new Function('$condition', '$val', '$form', '$scope', '$group', '$rule', "with($form){with($scope){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}}")).call(_this3.api.form, condition, one.value, _this3.api.top.form, _this3.api.top === _this3.api.scope ? {} : _this3.api.scope.form, group ? _this3.subRuleData[group.id] || {} : {}, ctx.rule);
|
|
6108
6440
|
});
|
|
6109
6441
|
}
|
|
6110
6442
|
|
|
@@ -6120,9 +6452,9 @@
|
|
|
6120
6452
|
};
|
|
6121
6453
|
|
|
6122
6454
|
for (var i = 0; i < item.group.length; i++) {
|
|
6123
|
-
var
|
|
6455
|
+
var _ret2 = _loop2(i);
|
|
6124
6456
|
|
|
6125
|
-
if (_typeof(
|
|
6457
|
+
if (_typeof(_ret2) === "object") return _ret2.v;
|
|
6126
6458
|
}
|
|
6127
6459
|
|
|
6128
6460
|
return or ? false : valid;
|
|
@@ -6133,27 +6465,27 @@
|
|
|
6133
6465
|
|
|
6134
6466
|
if (item.linkage) {
|
|
6135
6467
|
return val ? invoke(function () {
|
|
6136
|
-
return
|
|
6468
|
+
return _this3.computeValue(item.linkage, ctx, group);
|
|
6137
6469
|
}, undefined) : oldValueTag;
|
|
6138
6470
|
}
|
|
6139
6471
|
|
|
6140
6472
|
return val;
|
|
6141
6473
|
} else if (is.Function(item)) {
|
|
6142
6474
|
fn = function fn() {
|
|
6143
|
-
return item(
|
|
6475
|
+
return item(_this3.api.form, _this3.api);
|
|
6144
6476
|
};
|
|
6145
6477
|
} else {
|
|
6146
6478
|
var _group = ctx.getParentGroup();
|
|
6147
6479
|
|
|
6148
6480
|
fn = function fn() {
|
|
6149
|
-
return
|
|
6481
|
+
return _this3.computeValue(item, ctx, _group);
|
|
6150
6482
|
};
|
|
6151
6483
|
}
|
|
6152
6484
|
|
|
6153
6485
|
return invoke(fn, undefined);
|
|
6154
6486
|
},
|
|
6155
6487
|
computeValue: function computeValue(str, ctx, group) {
|
|
6156
|
-
var
|
|
6488
|
+
var _this4 = this;
|
|
6157
6489
|
|
|
6158
6490
|
var that = this;
|
|
6159
6491
|
var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
|
|
@@ -6175,35 +6507,35 @@
|
|
|
6175
6507
|
return obj;
|
|
6176
6508
|
}, {});
|
|
6177
6509
|
return invoke(function () {
|
|
6178
|
-
return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(
|
|
6510
|
+
return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this4.api.form, formulas, _this4.api.top.form, _this4.api.top === _this4.api.scope ? {} : _this4.api.scope.form, group ? _this4.subRuleData[group.id] || {} : {}, ctx.rule, _this4.api);
|
|
6179
6511
|
}, undefined);
|
|
6180
6512
|
},
|
|
6181
6513
|
updateChildren: function updateChildren(ctx, n, o) {
|
|
6182
|
-
var
|
|
6514
|
+
var _this5 = this;
|
|
6183
6515
|
|
|
6184
6516
|
this.deferSyncValue(function () {
|
|
6185
6517
|
o && o.forEach(function (child) {
|
|
6186
6518
|
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
|
|
6187
|
-
|
|
6519
|
+
_this5.rmCtx(child.__fc__);
|
|
6188
6520
|
}
|
|
6189
6521
|
});
|
|
6190
6522
|
|
|
6191
6523
|
if (is.trueArray(n)) {
|
|
6192
|
-
|
|
6524
|
+
_this5.loadChildren(n, ctx);
|
|
6193
6525
|
|
|
6194
|
-
|
|
6526
|
+
_this5.bus.$emit('update', _this5.api);
|
|
6195
6527
|
}
|
|
6196
6528
|
});
|
|
6197
6529
|
},
|
|
6198
6530
|
rmSub: function rmSub(sub) {
|
|
6199
|
-
var
|
|
6531
|
+
var _this6 = this;
|
|
6200
6532
|
|
|
6201
6533
|
is.trueArray(sub) && sub.forEach(function (r) {
|
|
6202
|
-
r && r.__fc__ &&
|
|
6534
|
+
r && r.__fc__ && _this6.rmCtx(r.__fc__);
|
|
6203
6535
|
});
|
|
6204
6536
|
},
|
|
6205
6537
|
rmCtx: function rmCtx(ctx) {
|
|
6206
|
-
var
|
|
6538
|
+
var _this7 = this;
|
|
6207
6539
|
|
|
6208
6540
|
if (ctx.deleted) return;
|
|
6209
6541
|
var id = ctx.id,
|
|
@@ -6232,19 +6564,19 @@
|
|
|
6232
6564
|
}
|
|
6233
6565
|
|
|
6234
6566
|
this.deferSyncValue(function () {
|
|
6235
|
-
if (!
|
|
6567
|
+
if (!_this7.reloading) {
|
|
6236
6568
|
if (ctx.parser.loadChildren !== false) {
|
|
6237
6569
|
var children = ctx.getPending('children', ctx.rule.children);
|
|
6238
6570
|
|
|
6239
6571
|
if (is.trueArray(children)) {
|
|
6240
6572
|
children.forEach(function (h) {
|
|
6241
|
-
return h.__fc__ &&
|
|
6573
|
+
return h.__fc__ && _this7.rmCtx(h.__fc__);
|
|
6242
6574
|
});
|
|
6243
6575
|
}
|
|
6244
6576
|
}
|
|
6245
6577
|
|
|
6246
|
-
if (ctx.root ===
|
|
6247
|
-
|
|
6578
|
+
if (ctx.root === _this7.rules) {
|
|
6579
|
+
_this7.vm.setupState.renderRule();
|
|
6248
6580
|
}
|
|
6249
6581
|
}
|
|
6250
6582
|
}, input);
|
|
@@ -6617,7 +6949,26 @@
|
|
|
6617
6949
|
}
|
|
6618
6950
|
}).then(function () {
|
|
6619
6951
|
return _this3.globalBeforeFetch(opt);
|
|
6620
|
-
})
|
|
6952
|
+
});
|
|
6953
|
+
},
|
|
6954
|
+
beforeSubmit: function beforeSubmit(formData) {
|
|
6955
|
+
var _this4 = this;
|
|
6956
|
+
|
|
6957
|
+
return new Promise(function (resolve, reject) {
|
|
6958
|
+
var res = _this4.options.beforeSubmit && invoke(function () {
|
|
6959
|
+
return _this4.options.beforeSubmit(formData, {
|
|
6960
|
+
api: _this4.api
|
|
6961
|
+
});
|
|
6962
|
+
});
|
|
6963
|
+
|
|
6964
|
+
if (res && is.Function(res.then)) {
|
|
6965
|
+
res.then(resolve)["catch"](reject);
|
|
6966
|
+
} else if (res === false) {
|
|
6967
|
+
reject();
|
|
6968
|
+
} else {
|
|
6969
|
+
resolve();
|
|
6970
|
+
}
|
|
6971
|
+
});
|
|
6621
6972
|
}
|
|
6622
6973
|
});
|
|
6623
6974
|
useInject(Handler);
|
|
@@ -6772,6 +7123,13 @@
|
|
|
6772
7123
|
form: function form() {
|
|
6773
7124
|
return this.vm.refs[this.ref];
|
|
6774
7125
|
},
|
|
7126
|
+
adapterValidate: function adapterValidate(validate, validator) {
|
|
7127
|
+
validate.validator = function (rule, value, callback) {
|
|
7128
|
+
return validator(value, callback);
|
|
7129
|
+
};
|
|
7130
|
+
|
|
7131
|
+
return validate;
|
|
7132
|
+
},
|
|
6775
7133
|
getSlot: function getSlot(name) {
|
|
6776
7134
|
var _fn = function _fn(vm) {
|
|
6777
7135
|
if (vm) {
|
|
@@ -7132,7 +7490,7 @@
|
|
|
7132
7490
|
api: api
|
|
7133
7491
|
});
|
|
7134
7492
|
});
|
|
7135
|
-
});
|
|
7493
|
+
})["catch"](function (e) {});
|
|
7136
7494
|
}, option.wait || 600));
|
|
7137
7495
|
}
|
|
7138
7496
|
|
|
@@ -7266,6 +7624,57 @@
|
|
|
7266
7624
|
return baseDriver(getSessionStorage, name);
|
|
7267
7625
|
}
|
|
7268
7626
|
|
|
7627
|
+
var baseLanguage = {
|
|
7628
|
+
en: {
|
|
7629
|
+
required: '{title} is required',
|
|
7630
|
+
validate: {
|
|
7631
|
+
url: '{title} is not a valid url',
|
|
7632
|
+
email: '{title} is not a valid email',
|
|
7633
|
+
ip: '{title} {title} is not a valid ip',
|
|
7634
|
+
phone: '{title} {title} is not a valid phone',
|
|
7635
|
+
pattern: '{title} does not match pattern {pattern}',
|
|
7636
|
+
uppercase: '{title} must be all uppercase',
|
|
7637
|
+
lowercase: '{title} must be all lowercased',
|
|
7638
|
+
positive: '{title} is not a positive number',
|
|
7639
|
+
negative: '{title} is not a negative number',
|
|
7640
|
+
equal: '{title} is not equal to {equal}',
|
|
7641
|
+
min: '{title} cannot be less than {min}',
|
|
7642
|
+
max: '{title} cannot be greater than {max}',
|
|
7643
|
+
"enum": '{title} must be one of {enum}',
|
|
7644
|
+
hasKeys: '{title} does not contain required fields {hasKeys}',
|
|
7645
|
+
minLen: '{title} must be at least {minLen}',
|
|
7646
|
+
maxLen: '{title} cannot be longer than {maxLen}',
|
|
7647
|
+
len: '{title} must be exactly {len}',
|
|
7648
|
+
integer: '{title} is not an integer',
|
|
7649
|
+
number: '{title} is not an number'
|
|
7650
|
+
}
|
|
7651
|
+
},
|
|
7652
|
+
'zh-cn': {
|
|
7653
|
+
required: '{title}不能为空',
|
|
7654
|
+
validate: {
|
|
7655
|
+
url: '{title}不是有效的 url 地址',
|
|
7656
|
+
email: '{title}不是有效的邮箱地址',
|
|
7657
|
+
ip: '{title}不是有效的 IP 地址',
|
|
7658
|
+
phone: '{title}不是正确的手机号',
|
|
7659
|
+
pattern: '{title}必须匹配 {pattern}',
|
|
7660
|
+
uppercase: '{title}必须全大写',
|
|
7661
|
+
lowercase: '{title}必须全小写',
|
|
7662
|
+
positive: '{title}不是正数',
|
|
7663
|
+
negative: '{title}不是负数',
|
|
7664
|
+
equal: '{title}必须等于 {equal}',
|
|
7665
|
+
min: '{title}必须大于等于 {min}',
|
|
7666
|
+
max: '{title}必须小于等于 {max}',
|
|
7667
|
+
"enum": '{title}必须是 {enum} 之一',
|
|
7668
|
+
hasKeys: '{title}必须包含 {hasKeys} 字段',
|
|
7669
|
+
minLen: '{title}长度必须大于 {minLen}',
|
|
7670
|
+
maxLen: '{title}长度必须小于 {maxLen}',
|
|
7671
|
+
len: '{title}长度必须为 {len}',
|
|
7672
|
+
integer: '{title}必须为整数',
|
|
7673
|
+
number: '{title}必须为数字'
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
};
|
|
7677
|
+
|
|
7269
7678
|
function parseProp(name, id) {
|
|
7270
7679
|
var prop;
|
|
7271
7680
|
|
|
@@ -7789,7 +8198,11 @@
|
|
|
7789
8198
|
|
|
7790
8199
|
var _locale = this.getLocale();
|
|
7791
8200
|
|
|
7792
|
-
value = deepGet(language[_locale], id);
|
|
8201
|
+
value = deepGet(language[_locale] || {}, id);
|
|
8202
|
+
|
|
8203
|
+
if (value == null) {
|
|
8204
|
+
value = deepGet(baseLanguage[_locale] || {}, id);
|
|
8205
|
+
}
|
|
7793
8206
|
}
|
|
7794
8207
|
|
|
7795
8208
|
return value;
|
|
@@ -8466,7 +8879,6 @@
|
|
|
8466
8879
|
e.preventDefault();
|
|
8467
8880
|
}
|
|
8468
8881
|
},
|
|
8469
|
-
"class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : ''],
|
|
8470
8882
|
style: form.style,
|
|
8471
8883
|
type: 'form'
|
|
8472
8884
|
};
|
|
@@ -8475,9 +8887,11 @@
|
|
|
8475
8887
|
var key = this.key,
|
|
8476
8888
|
ref = this.ref,
|
|
8477
8889
|
$handle = this.$handle;
|
|
8890
|
+
var form = this.options.form;
|
|
8478
8891
|
extend(this.rule, {
|
|
8479
8892
|
key: key,
|
|
8480
|
-
ref: ref
|
|
8893
|
+
ref: ref,
|
|
8894
|
+
"class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : '']
|
|
8481
8895
|
});
|
|
8482
8896
|
extend(this.rule.props, {
|
|
8483
8897
|
model: $handle.formData
|
|
@@ -8942,14 +9356,16 @@
|
|
|
8942
9356
|
var promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
|
|
8943
9357
|
promise.then(function () {
|
|
8944
9358
|
var formData = api.formData();
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
9359
|
+
h.beforeSubmit(formData).then(function () {
|
|
9360
|
+
is.Function(successFn) && invoke(function () {
|
|
9361
|
+
return successFn(formData, api);
|
|
9362
|
+
});
|
|
9363
|
+
is.Function(h.options.onSubmit) && invoke(function () {
|
|
9364
|
+
return h.options.onSubmit(formData, api);
|
|
9365
|
+
});
|
|
9366
|
+
h.vm.emit('submit', formData, api);
|
|
9367
|
+
resolve(formData);
|
|
9368
|
+
})["catch"](function (e) {});
|
|
8953
9369
|
})["catch"](function () {
|
|
8954
9370
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8955
9371
|
args[_key] = arguments[_key];
|
|
@@ -9056,7 +9472,7 @@
|
|
|
9056
9472
|
function elmFormCreate() {
|
|
9057
9473
|
return FormCreateFactory({
|
|
9058
9474
|
ui: 'element-ui',
|
|
9059
|
-
version: '3.2.
|
|
9475
|
+
version: '3.2.22',
|
|
9060
9476
|
manager: manager,
|
|
9061
9477
|
extendApi: extendApi,
|
|
9062
9478
|
install: install,
|