@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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.21
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.
@@ -162,6 +162,10 @@ function _createSuper(Derived) {
162
162
  };
163
163
  }
164
164
 
165
+ function _slicedToArray(arr, i) {
166
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
167
+ }
168
+
165
169
  function _toConsumableArray(arr) {
166
170
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
167
171
  }
@@ -170,10 +174,44 @@ function _arrayWithoutHoles(arr) {
170
174
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
171
175
  }
172
176
 
177
+ function _arrayWithHoles(arr) {
178
+ if (Array.isArray(arr)) return arr;
179
+ }
180
+
173
181
  function _iterableToArray(iter) {
174
182
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
175
183
  }
176
184
 
185
+ function _iterableToArrayLimit(arr, i) {
186
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
187
+
188
+ if (_i == null) return;
189
+ var _arr = [];
190
+ var _n = true;
191
+ var _d = false;
192
+
193
+ var _s, _e;
194
+
195
+ try {
196
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
197
+ _arr.push(_s.value);
198
+
199
+ if (i && _arr.length === i) break;
200
+ }
201
+ } catch (err) {
202
+ _d = true;
203
+ _e = err;
204
+ } finally {
205
+ try {
206
+ if (!_n && _i["return"] != null) _i["return"]();
207
+ } finally {
208
+ if (_d) throw _e;
209
+ }
210
+ }
211
+
212
+ return _arr;
213
+ }
214
+
177
215
  function _unsupportedIterableToArray(o, minLen) {
178
216
  if (!o) return;
179
217
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -195,6 +233,10 @@ function _nonIterableSpread() {
195
233
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
196
234
  }
197
235
 
236
+ function _nonIterableRest() {
237
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
238
+ }
239
+
198
240
  function getSlot(slots, exclude) {
199
241
  return Object.keys(slots).reduce(function (lst, name) {
200
242
  if (!exclude || exclude.indexOf(name) === -1) {
@@ -1757,7 +1799,7 @@ var Group = defineComponent({
1757
1799
  var keys = this.sort;
1758
1800
 
1759
1801
  if (keys.filter(function (k) {
1760
- return cacheRule[k].$f;
1802
+ return cacheRule[k] && cacheRule[k].$f;
1761
1803
  }).length !== keys.length) {
1762
1804
  return;
1763
1805
  }
@@ -1810,6 +1852,7 @@ var Group = defineComponent({
1810
1852
  rule: rule,
1811
1853
  options: options
1812
1854
  };
1855
+ this.sort = Object.keys(this.cacheRule);
1813
1856
 
1814
1857
  if (emit) {
1815
1858
  nextTick(function () {
@@ -1831,6 +1874,7 @@ var Group = defineComponent({
1831
1874
  var index = Object.keys(this.cacheRule).indexOf(key);
1832
1875
  delete this.cacheRule[key];
1833
1876
  delete this.cacheValue[key];
1877
+ this.sort = Object.keys(this.cacheRule);
1834
1878
 
1835
1879
  if (emit) {
1836
1880
  nextTick(function () {
@@ -1953,15 +1997,6 @@ var Group = defineComponent({
1953
1997
  }
1954
1998
  },
1955
1999
  created: function created() {
1956
- var _this12 = this;
1957
-
1958
- watch(function () {
1959
- return _objectSpread2({}, _this12.cacheRule);
1960
- }, function (n) {
1961
- _this12.sort = Object.keys(n);
1962
- }, {
1963
- immediate: true
1964
- });
1965
2000
  var d = (this.expand || 0) - this.modelValue.length;
1966
2001
 
1967
2002
  for (var i = 0; i < this.modelValue.length; i++) {
@@ -1973,7 +2008,7 @@ var Group = defineComponent({
1973
2008
  }
1974
2009
  },
1975
2010
  render: function render() {
1976
- var _this13 = this;
2011
+ var _this12 = this;
1977
2012
 
1978
2013
  var keys = this.sort;
1979
2014
  var button = this.button;
@@ -1987,10 +2022,10 @@ var Group = defineComponent({
1987
2022
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
1988
2023
  "onClick": this.add
1989
2024
  }, null) : keys.map(function (key, index) {
1990
- var _this13$cacheRule$key = _this13.cacheRule[key],
1991
- rule = _this13$cacheRule$key.rule,
1992
- options = _this13$cacheRule$key.options;
1993
- var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
2025
+ var _this12$cacheRule$key = _this12.cacheRule[key],
2026
+ rule = _this12$cacheRule$key.rule,
2027
+ options = _this12$cacheRule$key.options;
2028
+ var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
1994
2029
  return createVNode("div", {
1995
2030
  "class": "_fc-group-container",
1996
2031
  "key": key
@@ -1999,20 +2034,20 @@ var Group = defineComponent({
1999
2034
  }, {
2000
2035
  disabled: disabled,
2001
2036
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
2002
- return _this13.formData(key, formData);
2037
+ return _this12.formData(key, formData);
2003
2038
  },
2004
2039
  'onEmit-event': function onEmitEvent(name) {
2005
2040
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2006
2041
  args[_key - 1] = arguments[_key];
2007
2042
  }
2008
2043
 
2009
- return _this13.emitEvent(name, args, index, key);
2044
+ return _this12.emitEvent(name, args, index, key);
2010
2045
  },
2011
2046
  'onUpdate:api': function onUpdateApi($f) {
2012
- return _this13.add$f(index, key, $f);
2047
+ return _this12.add$f(index, key, $f);
2013
2048
  },
2014
2049
  inFor: true,
2015
- modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
2050
+ modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
2016
2051
  rule: rule,
2017
2052
  option: options,
2018
2053
  extendOption: true
@@ -3230,6 +3265,10 @@ function Api(h) {
3230
3265
  return undefined;
3231
3266
  },
3232
3267
 
3268
+ get formulas() {
3269
+ return _objectSpread2({}, h.fc.formulas);
3270
+ },
3271
+
3233
3272
  formData: function formData(fields) {
3234
3273
  if (fields == null || typeof fields === 'boolean') {
3235
3274
  var data = {};
@@ -3660,10 +3699,13 @@ function Api(h) {
3660
3699
  }
3661
3700
  }
3662
3701
  },
3663
- getChildrenFormData: function getChildrenFormData(id) {
3702
+ getChildrenFormData: function getChildrenFormData(id, flag) {
3664
3703
  var rules = api.getChildrenRuleList(id);
3665
3704
  return rules.reduce(function (formData, rule) {
3666
- formData[rule.field] = copy(rule.value);
3705
+ if (rule.ignore !== true || flag === true) {
3706
+ formData[rule.field] = copy(rule.value);
3707
+ }
3708
+
3667
3709
  return formData;
3668
3710
  }, {});
3669
3711
  },
@@ -3756,7 +3798,7 @@ function Api(h) {
3756
3798
  });
3757
3799
  reject(e);
3758
3800
  });
3759
- });
3801
+ })["catch"](function (e) {});
3760
3802
  });
3761
3803
  },
3762
3804
  watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
@@ -3781,7 +3823,7 @@ function Api(h) {
3781
3823
  });
3782
3824
  error && error(e);
3783
3825
  });
3784
- });
3826
+ })["catch"](function (e) {});
3785
3827
  }, opt.wait == null ? 1000 : opt.wait);
3786
3828
  },
3787
3829
  getData: function getData(id, def) {
@@ -5942,19 +5984,25 @@ function useContext(Handler) {
5942
5984
  return info;
5943
5985
  });
5944
5986
  ctx.refRule['__$validate'] = computed(function () {
5987
+ var t = function t(msg) {
5988
+ var match = msg.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5989
+
5990
+ if (match) {
5991
+ var _ctx$refRule, _ctx$refRule$__$title;
5992
+
5993
+ return _this.api.t(match[1], {
5994
+ 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
5995
+ });
5996
+ }
5997
+
5998
+ return msg;
5999
+ };
6000
+
5945
6001
  return toArray(ctx.rule.validate).map(function (item) {
5946
6002
  var temp = _objectSpread2({}, item);
5947
6003
 
5948
6004
  if (temp.message) {
5949
- var match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5950
-
5951
- if (match) {
5952
- var _ctx$refRule, _ctx$refRule$__$title;
5953
-
5954
- temp.message = _this.api.t(match[1], {
5955
- 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
5956
- });
5957
- }
6005
+ temp.message = t(temp.message);
5958
6006
  }
5959
6007
 
5960
6008
  if (is.Function(temp.validator)) {
@@ -5975,8 +6023,19 @@ function useContext(Handler) {
5975
6023
  api: that.$handle.api
5976
6024
  }].concat(args));
5977
6025
  };
6026
+ }
6027
+
6028
+ if (temp.adapter) {
6029
+ if (_typeof(temp.error) === 'object') {
6030
+ var msg = _objectSpread2({}, temp.error);
5978
6031
 
5979
- return temp;
6032
+ Object.keys(msg).forEach(function (key) {
6033
+ msg[key] = t(msg[key]);
6034
+ });
6035
+ temp.error = msg;
6036
+ }
6037
+
6038
+ return _this.adapterValidate(temp, ctx);
5980
6039
  }
5981
6040
 
5982
6041
  return temp;
@@ -6048,9 +6107,282 @@ function useContext(Handler) {
6048
6107
  });
6049
6108
  this.watchEffect(ctx);
6050
6109
  },
6051
- compute: function compute(ctx, item) {
6110
+ adapterValidate: function adapterValidate(validate, ctx) {
6052
6111
  var _this2 = this;
6053
6112
 
6113
+ var validator = function validator(value, callback) {
6114
+ var before = validate.beforeValidate && invoke(function () {
6115
+ return validate.beforeValidate({
6116
+ value: value,
6117
+ api: _this2.api,
6118
+ validate: validate,
6119
+ rule: ctx.rule
6120
+ });
6121
+ });
6122
+
6123
+ if (before === false) {
6124
+ callback();
6125
+ } else {
6126
+ var key = _this2.validator(value, validate);
6127
+
6128
+ if (!key) {
6129
+ if (validate.validator) {
6130
+ var res = validate.validator && invoke(function () {
6131
+ return validate.validator(value, callback);
6132
+ });
6133
+
6134
+ if (res && is.Function(res.then)) {
6135
+ res.then(function () {
6136
+ return callback();
6137
+ })["catch"](function (e) {
6138
+ return callback(e);
6139
+ });
6140
+ }
6141
+ } else {
6142
+ callback();
6143
+ }
6144
+ } else {
6145
+ var message = '';
6146
+
6147
+ if (_typeof(validate.error) === 'object') {
6148
+ message = validate.error[key] || validate.error["default"];
6149
+ }
6150
+
6151
+ if (!message && typeof validate.message === 'string') {
6152
+ message = validate.message;
6153
+ }
6154
+
6155
+ if (!message) {
6156
+ message = _this2.getValidateMessage(ctx, {
6157
+ key: key,
6158
+ rule: validate[key]
6159
+ });
6160
+ }
6161
+
6162
+ callback(message);
6163
+ }
6164
+ }
6165
+ };
6166
+
6167
+ return this.$manager.adapterValidate({
6168
+ required: validate.required,
6169
+ message: validate.message,
6170
+ target: validate.trigger
6171
+ }, validator);
6172
+ },
6173
+ getValidateMessage: function getValidateMessage(ctx, invalid) {
6174
+ var _ctx$refRule2, _ctx$refRule2$__$titl, _this$api$t;
6175
+
6176
+ var formatRule = Array.isArray(invalid.rule) ? invalid.rule.join(',') : '' + invalid.rule;
6177
+ 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));
6178
+ },
6179
+ validator: function validator(value, validate) {
6180
+ var isEmpty = is.empty(value);
6181
+
6182
+ if (isEmpty) {
6183
+ if (validate.required) {
6184
+ return 'required';
6185
+ }
6186
+
6187
+ return;
6188
+ }
6189
+
6190
+ var _loop = function _loop() {
6191
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
6192
+ key = _Object$entries$_i[0],
6193
+ rule = _Object$entries$_i[1];
6194
+
6195
+ switch (key) {
6196
+ case 'len':
6197
+ case 'maxLen':
6198
+ case 'minLen':
6199
+ var check = function check(val) {
6200
+ if (key === 'len') {
6201
+ return val === rule;
6202
+ } else if (key === 'maxLen') {
6203
+ return val <= rule;
6204
+ } else {
6205
+ return val >= rule;
6206
+ }
6207
+ };
6208
+
6209
+ if (Array.isArray(value)) {
6210
+ if (!check(value.length)) {
6211
+ return {
6212
+ v: key
6213
+ };
6214
+ }
6215
+ } else if (_typeof(value) === 'object') {
6216
+ return {
6217
+ v: key
6218
+ };
6219
+ } else if (!check(('' + value).length)) {
6220
+ return {
6221
+ v: key
6222
+ };
6223
+ }
6224
+
6225
+ break;
6226
+
6227
+ case 'pattern':
6228
+ var reg = typeof rule === 'string' ? new RegExp(rule) : rule;
6229
+
6230
+ if (!reg.test('' + value)) {
6231
+ return {
6232
+ v: key
6233
+ };
6234
+ }
6235
+
6236
+ break;
6237
+
6238
+ case 'uppercase':
6239
+ if (rule && (typeof value !== 'string' || !/^[A-Z]*$/.test(value))) {
6240
+ return {
6241
+ v: key
6242
+ };
6243
+ }
6244
+
6245
+ break;
6246
+
6247
+ case 'lowercase':
6248
+ if (rule && (typeof value !== 'string' || !/^[a-z]*$/.test(value))) {
6249
+ return {
6250
+ v: key
6251
+ };
6252
+ }
6253
+
6254
+ break;
6255
+
6256
+ case 'min':
6257
+ case 'max':
6258
+ case 'positive':
6259
+ case 'negative':
6260
+ case 'integer':
6261
+ case 'number':
6262
+ var num = Number(value);
6263
+
6264
+ if (Number.isNaN(num)) {
6265
+ return {
6266
+ v: key
6267
+ };
6268
+ }
6269
+
6270
+ if (key === 'min' && num < rule) {
6271
+ return {
6272
+ v: key
6273
+ };
6274
+ }
6275
+
6276
+ if (key === 'max' && num > rule) {
6277
+ return {
6278
+ v: key
6279
+ };
6280
+ }
6281
+
6282
+ if (key === 'positive' && num <= 0) {
6283
+ return {
6284
+ v: key
6285
+ };
6286
+ }
6287
+
6288
+ if (key === 'negative' && num >= 0) {
6289
+ return {
6290
+ v: key
6291
+ };
6292
+ }
6293
+
6294
+ if (key === 'integer' && !Number.isInteger(num)) {
6295
+ return {
6296
+ v: key
6297
+ };
6298
+ }
6299
+
6300
+ break;
6301
+
6302
+ case 'equal':
6303
+ if (value !== rule) {
6304
+ return {
6305
+ v: key
6306
+ };
6307
+ }
6308
+
6309
+ break;
6310
+
6311
+ case 'enum':
6312
+ if (Array.isArray(rule) && !rule.includes(value)) {
6313
+ return {
6314
+ v: key
6315
+ };
6316
+ }
6317
+
6318
+ break;
6319
+
6320
+ case 'hasKeys':
6321
+ if (_typeof(value) !== 'object' || Array.isArray(rule) && rule.some(function (key) {
6322
+ return !(key in value);
6323
+ })) {
6324
+ return {
6325
+ v: key
6326
+ };
6327
+ }
6328
+
6329
+ break;
6330
+
6331
+ case 'email':
6332
+ 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,}))$/;
6333
+
6334
+ if (!regexEmail.test('' + value)) {
6335
+ return {
6336
+ v: key
6337
+ };
6338
+ }
6339
+
6340
+ break;
6341
+
6342
+ case 'url':
6343
+ 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');
6344
+
6345
+ if (!regexUrl.test('' + value)) {
6346
+ return {
6347
+ v: key
6348
+ };
6349
+ }
6350
+
6351
+ break;
6352
+
6353
+ case 'ip':
6354
+ 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}$/;
6355
+
6356
+ if (!regexIp.test('' + value)) {
6357
+ return {
6358
+ v: key
6359
+ };
6360
+ }
6361
+
6362
+ break;
6363
+
6364
+ case 'phone':
6365
+ var regexPhone = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
6366
+
6367
+ if (!regexPhone.test('' + value)) {
6368
+ return {
6369
+ v: key
6370
+ };
6371
+ }
6372
+
6373
+ break;
6374
+ }
6375
+ };
6376
+
6377
+ for (var _i = 0, _Object$entries = Object.entries(validate); _i < _Object$entries.length; _i++) {
6378
+ var _ret = _loop();
6379
+
6380
+ if (_typeof(_ret) === "object") return _ret.v;
6381
+ }
6382
+ },
6383
+ compute: function compute(ctx, item) {
6384
+ var _this3 = this;
6385
+
6054
6386
  var fn;
6055
6387
 
6056
6388
  if (_typeof(item) === 'object') {
@@ -6069,13 +6401,13 @@ function useContext(Handler) {
6069
6401
  var or = item.mode === 'OR';
6070
6402
  var valid = true;
6071
6403
 
6072
- var _loop = function _loop(i) {
6404
+ var _loop2 = function _loop2(i) {
6073
6405
  var one = item.group[i];
6074
6406
  var flag = void 0;
6075
6407
  var field = null;
6076
6408
 
6077
6409
  if (one.variable) {
6078
- field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
6410
+ field = JSON.stringify(_this3.fc.getLoadData(one.variable) || '');
6079
6411
  } else if (one.field) {
6080
6412
  field = convertFieldToConditions(one.field || '');
6081
6413
  } else if (!one.mode) {
@@ -6096,11 +6428,11 @@ function useContext(Handler) {
6096
6428
  flag = false;
6097
6429
  } else if (is.Function(one.handler)) {
6098
6430
  flag = invoke(function () {
6099
- return one.handler(_this2.api, ctx.rule);
6431
+ return one.handler(_this3.api, ctx.rule);
6100
6432
  });
6101
6433
  } else {
6102
6434
  flag = invoke(function () {
6103
- 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(_this2.api.form, condition, one.value, _this2.api.top.form, _this2.api.top === _this2.api.scope ? {} : _this2.api.scope.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
6435
+ 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);
6104
6436
  });
6105
6437
  }
6106
6438
 
@@ -6116,9 +6448,9 @@ function useContext(Handler) {
6116
6448
  };
6117
6449
 
6118
6450
  for (var i = 0; i < item.group.length; i++) {
6119
- var _ret = _loop(i);
6451
+ var _ret2 = _loop2(i);
6120
6452
 
6121
- if (_typeof(_ret) === "object") return _ret.v;
6453
+ if (_typeof(_ret2) === "object") return _ret2.v;
6122
6454
  }
6123
6455
 
6124
6456
  return or ? false : valid;
@@ -6129,27 +6461,27 @@ function useContext(Handler) {
6129
6461
 
6130
6462
  if (item.linkage) {
6131
6463
  return val ? invoke(function () {
6132
- return _this2.computeValue(item.linkage, ctx, group);
6464
+ return _this3.computeValue(item.linkage, ctx, group);
6133
6465
  }, undefined) : oldValueTag;
6134
6466
  }
6135
6467
 
6136
6468
  return val;
6137
6469
  } else if (is.Function(item)) {
6138
6470
  fn = function fn() {
6139
- return item(_this2.api.form, _this2.api);
6471
+ return item(_this3.api.form, _this3.api);
6140
6472
  };
6141
6473
  } else {
6142
6474
  var _group = ctx.getParentGroup();
6143
6475
 
6144
6476
  fn = function fn() {
6145
- return _this2.computeValue(item, ctx, _group);
6477
+ return _this3.computeValue(item, ctx, _group);
6146
6478
  };
6147
6479
  }
6148
6480
 
6149
6481
  return invoke(fn, undefined);
6150
6482
  },
6151
6483
  computeValue: function computeValue(str, ctx, group) {
6152
- var _this3 = this;
6484
+ var _this4 = this;
6153
6485
 
6154
6486
  var that = this;
6155
6487
  var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
@@ -6171,35 +6503,35 @@ function useContext(Handler) {
6171
6503
  return obj;
6172
6504
  }, {});
6173
6505
  return invoke(function () {
6174
- return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this3.api.form, formulas, _this3.api.top.form, _this3.api.top === _this3.api.scope ? {} : _this3.api.scope.form, group ? _this3.subRuleData[group.id] || {} : {}, ctx.rule, _this3.api);
6506
+ 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);
6175
6507
  }, undefined);
6176
6508
  },
6177
6509
  updateChildren: function updateChildren(ctx, n, o) {
6178
- var _this4 = this;
6510
+ var _this5 = this;
6179
6511
 
6180
6512
  this.deferSyncValue(function () {
6181
6513
  o && o.forEach(function (child) {
6182
6514
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
6183
- _this4.rmCtx(child.__fc__);
6515
+ _this5.rmCtx(child.__fc__);
6184
6516
  }
6185
6517
  });
6186
6518
 
6187
6519
  if (is.trueArray(n)) {
6188
- _this4.loadChildren(n, ctx);
6520
+ _this5.loadChildren(n, ctx);
6189
6521
 
6190
- _this4.bus.$emit('update', _this4.api);
6522
+ _this5.bus.$emit('update', _this5.api);
6191
6523
  }
6192
6524
  });
6193
6525
  },
6194
6526
  rmSub: function rmSub(sub) {
6195
- var _this5 = this;
6527
+ var _this6 = this;
6196
6528
 
6197
6529
  is.trueArray(sub) && sub.forEach(function (r) {
6198
- r && r.__fc__ && _this5.rmCtx(r.__fc__);
6530
+ r && r.__fc__ && _this6.rmCtx(r.__fc__);
6199
6531
  });
6200
6532
  },
6201
6533
  rmCtx: function rmCtx(ctx) {
6202
- var _this6 = this;
6534
+ var _this7 = this;
6203
6535
 
6204
6536
  if (ctx.deleted) return;
6205
6537
  var id = ctx.id,
@@ -6228,19 +6560,19 @@ function useContext(Handler) {
6228
6560
  }
6229
6561
 
6230
6562
  this.deferSyncValue(function () {
6231
- if (!_this6.reloading) {
6563
+ if (!_this7.reloading) {
6232
6564
  if (ctx.parser.loadChildren !== false) {
6233
6565
  var children = ctx.getPending('children', ctx.rule.children);
6234
6566
 
6235
6567
  if (is.trueArray(children)) {
6236
6568
  children.forEach(function (h) {
6237
- return h.__fc__ && _this6.rmCtx(h.__fc__);
6569
+ return h.__fc__ && _this7.rmCtx(h.__fc__);
6238
6570
  });
6239
6571
  }
6240
6572
  }
6241
6573
 
6242
- if (ctx.root === _this6.rules) {
6243
- _this6.vm.setupState.renderRule();
6574
+ if (ctx.root === _this7.rules) {
6575
+ _this7.vm.setupState.renderRule();
6244
6576
  }
6245
6577
  }
6246
6578
  }, input);
@@ -6613,7 +6945,26 @@ extend(Handler.prototype, {
6613
6945
  }
6614
6946
  }).then(function () {
6615
6947
  return _this3.globalBeforeFetch(opt);
6616
- })["catch"](function () {});
6948
+ });
6949
+ },
6950
+ beforeSubmit: function beforeSubmit(formData) {
6951
+ var _this4 = this;
6952
+
6953
+ return new Promise(function (resolve, reject) {
6954
+ var res = _this4.options.beforeSubmit && invoke(function () {
6955
+ return _this4.options.beforeSubmit(formData, {
6956
+ api: _this4.api
6957
+ });
6958
+ });
6959
+
6960
+ if (res && is.Function(res.then)) {
6961
+ res.then(resolve)["catch"](reject);
6962
+ } else if (res === false) {
6963
+ reject();
6964
+ } else {
6965
+ resolve();
6966
+ }
6967
+ });
6617
6968
  }
6618
6969
  });
6619
6970
  useInject(Handler);
@@ -6768,6 +7119,13 @@ extend(Manager.prototype, {
6768
7119
  form: function form() {
6769
7120
  return this.vm.refs[this.ref];
6770
7121
  },
7122
+ adapterValidate: function adapterValidate(validate, validator) {
7123
+ validate.validator = function (rule, value, callback) {
7124
+ return validator(value, callback);
7125
+ };
7126
+
7127
+ return validate;
7128
+ },
6771
7129
  getSlot: function getSlot(name) {
6772
7130
  var _fn = function _fn(vm) {
6773
7131
  if (vm) {
@@ -7128,7 +7486,7 @@ var fetch = function fetch(fc) {
7128
7486
  api: api
7129
7487
  });
7130
7488
  });
7131
- });
7489
+ })["catch"](function (e) {});
7132
7490
  }, option.wait || 600));
7133
7491
  }
7134
7492
 
@@ -7262,6 +7620,57 @@ function sessionStorageDriver(name) {
7262
7620
  return baseDriver(getSessionStorage, name);
7263
7621
  }
7264
7622
 
7623
+ var baseLanguage = {
7624
+ en: {
7625
+ required: '{title} is required',
7626
+ validate: {
7627
+ url: '{title} is not a valid url',
7628
+ email: '{title} is not a valid email',
7629
+ ip: '{title} {title} is not a valid ip',
7630
+ phone: '{title} {title} is not a valid phone',
7631
+ pattern: '{title} does not match pattern {pattern}',
7632
+ uppercase: '{title} must be all uppercase',
7633
+ lowercase: '{title} must be all lowercased',
7634
+ positive: '{title} is not a positive number',
7635
+ negative: '{title} is not a negative number',
7636
+ equal: '{title} is not equal to {equal}',
7637
+ min: '{title} cannot be less than {min}',
7638
+ max: '{title} cannot be greater than {max}',
7639
+ "enum": '{title} must be one of {enum}',
7640
+ hasKeys: '{title} does not contain required fields {hasKeys}',
7641
+ minLen: '{title} must be at least {minLen}',
7642
+ maxLen: '{title} cannot be longer than {maxLen}',
7643
+ len: '{title} must be exactly {len}',
7644
+ integer: '{title} is not an integer',
7645
+ number: '{title} is not an number'
7646
+ }
7647
+ },
7648
+ 'zh-cn': {
7649
+ required: '{title}不能为空',
7650
+ validate: {
7651
+ url: '{title}不是有效的 url 地址',
7652
+ email: '{title}不是有效的邮箱地址',
7653
+ ip: '{title}不是有效的 IP 地址',
7654
+ phone: '{title}不是正确的手机号',
7655
+ pattern: '{title}必须匹配 {pattern}',
7656
+ uppercase: '{title}必须全大写',
7657
+ lowercase: '{title}必须全小写',
7658
+ positive: '{title}不是正数',
7659
+ negative: '{title}不是负数',
7660
+ equal: '{title}必须等于 {equal}',
7661
+ min: '{title}必须大于等于 {min}',
7662
+ max: '{title}必须小于等于 {max}',
7663
+ "enum": '{title}必须是 {enum} 之一',
7664
+ hasKeys: '{title}必须包含 {hasKeys} 字段',
7665
+ minLen: '{title}长度必须大于 {minLen}',
7666
+ maxLen: '{title}长度必须小于 {maxLen}',
7667
+ len: '{title}长度必须为 {len}',
7668
+ integer: '{title}必须为整数',
7669
+ number: '{title}必须为数字'
7670
+ }
7671
+ }
7672
+ };
7673
+
7265
7674
  function parseProp(name, id) {
7266
7675
  var prop;
7267
7676
 
@@ -7785,7 +8194,11 @@ function FormCreateFactory(config) {
7785
8194
 
7786
8195
  var _locale = this.getLocale();
7787
8196
 
7788
- value = deepGet(language[_locale], id);
8197
+ value = deepGet(language[_locale] || {}, id);
8198
+
8199
+ if (value == null) {
8200
+ value = deepGet(baseLanguage[_locale] || {}, id);
8201
+ }
7789
8202
  }
7790
8203
 
7791
8204
  return value;
@@ -8462,7 +8875,6 @@ var manager = {
8462
8875
  e.preventDefault();
8463
8876
  }
8464
8877
  },
8465
- "class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : ''],
8466
8878
  style: form.style,
8467
8879
  type: 'form'
8468
8880
  };
@@ -8471,9 +8883,11 @@ var manager = {
8471
8883
  var key = this.key,
8472
8884
  ref = this.ref,
8473
8885
  $handle = this.$handle;
8886
+ var form = this.options.form;
8474
8887
  extend(this.rule, {
8475
8888
  key: key,
8476
- ref: ref
8889
+ ref: ref,
8890
+ "class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : '']
8477
8891
  });
8478
8892
  extend(this.rule.props, {
8479
8893
  model: $handle.formData
@@ -8938,14 +9352,16 @@ function extendApi(api, h) {
8938
9352
  var promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
8939
9353
  promise.then(function () {
8940
9354
  var formData = api.formData();
8941
- is.Function(successFn) && invoke(function () {
8942
- return successFn(formData, api);
8943
- });
8944
- is.Function(h.options.onSubmit) && invoke(function () {
8945
- return h.options.onSubmit(formData, api);
8946
- });
8947
- h.vm.emit('submit', formData, api);
8948
- resolve(formData);
9355
+ h.beforeSubmit(formData).then(function () {
9356
+ is.Function(successFn) && invoke(function () {
9357
+ return successFn(formData, api);
9358
+ });
9359
+ is.Function(h.options.onSubmit) && invoke(function () {
9360
+ return h.options.onSubmit(formData, api);
9361
+ });
9362
+ h.vm.emit('submit', formData, api);
9363
+ resolve(formData);
9364
+ })["catch"](function (e) {});
8949
9365
  })["catch"](function () {
8950
9366
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8951
9367
  args[_key] = arguments[_key];
@@ -9052,7 +9468,7 @@ function install(FormCreate) {
9052
9468
  function elmFormCreate() {
9053
9469
  return FormCreateFactory({
9054
9470
  ui: 'element-ui',
9055
- version: '3.2.21',
9471
+ version: '3.2.22',
9056
9472
  manager: manager,
9057
9473
  extendApi: extendApi,
9058
9474
  install: install,