@form-create/element-ui 3.2.21 → 3.2.23

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.23
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 _this13 = this;
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 _this13$cacheRule$key = _this13.cacheRule[key],
1995
- rule = _this13$cacheRule$key.rule,
1996
- options = _this13$cacheRule$key.options;
1997
- var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
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 _this13.formData(key, formData);
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 _this13.emitEvent(name, args, index, key);
2048
+ return _this12.emitEvent(name, args, index, key);
2014
2049
  },
2015
2050
  'onUpdate:api': function onUpdateApi($f) {
2016
- return _this13.add$f(index, key, $f);
2051
+ return _this12.add$f(index, key, $f);
2017
2052
  },
2018
2053
  inFor: true,
2019
- modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
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
@@ -2322,7 +2357,7 @@
2322
2357
  v.__inject = true;
2323
2358
  return v;
2324
2359
  } else if (v.indexOf('$FNX:') === 0) {
2325
- v = makeFn('function($inject){' + v.substring(5) + '}');
2360
+ v = makeFn('function($inject){\n' + v.substring(5) + '\n}');
2326
2361
  v.__json = fn;
2327
2362
  v.__inject = true;
2328
2363
  return v;
@@ -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
- formData[rule.field] = copy(rule.value);
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
- var match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
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);
6035
+
6036
+ Object.keys(msg).forEach(function (key) {
6037
+ msg[key] = t(msg[key]);
6038
+ });
6039
+ temp.error = msg;
6040
+ }
5982
6041
 
5983
- return temp;
6042
+ return _this.adapterValidate(temp, ctx);
5984
6043
  }
5985
6044
 
5986
6045
  return temp;
@@ -6014,7 +6073,6 @@
6014
6073
  }
6015
6074
 
6016
6075
  Object.keys(computedRule).forEach(function (k) {
6017
- var oldValue = undefined;
6018
6076
  var computedValue = vue.computed(function () {
6019
6077
  var item = computedRule[k];
6020
6078
  if (!item) return undefined;
@@ -6022,7 +6080,7 @@
6022
6080
  var value = _this.compute(ctx, item);
6023
6081
 
6024
6082
  if (item.linkage && value === oldValueTag) {
6025
- return oldValue;
6083
+ return oldValueTag;
6026
6084
  }
6027
6085
 
6028
6086
  return value;
@@ -6043,18 +6101,307 @@
6043
6101
  }
6044
6102
 
6045
6103
  ctx.watch.push(vue.watch(computedValue, function (n) {
6046
- oldValue = n;
6104
+ if (n === oldValueTag) {
6105
+ return;
6106
+ }
6107
+
6047
6108
  setTimeout(function () {
6048
6109
  callback(n);
6049
6110
  });
6111
+ }, {
6112
+ deep: true
6050
6113
  }));
6051
6114
  });
6052
6115
  });
6053
6116
  this.watchEffect(ctx);
6054
6117
  },
6055
- compute: function compute(ctx, item) {
6118
+ adapterValidate: function adapterValidate(validate, ctx) {
6056
6119
  var _this2 = this;
6057
6120
 
6121
+ var validator = function validator(value, callback) {
6122
+ var before = validate.beforeValidate && invoke(function () {
6123
+ return validate.beforeValidate({
6124
+ value: value,
6125
+ api: _this2.api,
6126
+ validate: validate,
6127
+ rule: ctx.rule
6128
+ });
6129
+ });
6130
+
6131
+ if (before === false) {
6132
+ callback();
6133
+ } else {
6134
+ var key = _this2.validator(ctx, value, validate);
6135
+
6136
+ if (!key) {
6137
+ if (validate.validator) {
6138
+ var res = validate.validator && invoke(function () {
6139
+ return validate.validator(value, callback);
6140
+ });
6141
+
6142
+ if (res && is.Function(res.then)) {
6143
+ res.then(function () {
6144
+ return callback();
6145
+ })["catch"](function (e) {
6146
+ return callback(e);
6147
+ });
6148
+ }
6149
+ } else {
6150
+ callback();
6151
+ }
6152
+ } else {
6153
+ var message = '';
6154
+
6155
+ if (_typeof(validate.error) === 'object') {
6156
+ message = validate.error[key] || validate.error["default"];
6157
+ }
6158
+
6159
+ if (!message && typeof validate.message === 'string') {
6160
+ message = validate.message;
6161
+ }
6162
+
6163
+ if (!message) {
6164
+ message = _this2.getValidateMessage(ctx, {
6165
+ key: key,
6166
+ rule: validate[key]
6167
+ });
6168
+ }
6169
+
6170
+ callback(message);
6171
+ }
6172
+ }
6173
+ };
6174
+
6175
+ return this.$manager.adapterValidate({
6176
+ required: validate.required,
6177
+ message: validate.message,
6178
+ target: validate.trigger
6179
+ }, validator);
6180
+ },
6181
+ getValidateMessage: function getValidateMessage(ctx, invalid) {
6182
+ var _ctx$refRule2, _ctx$refRule2$__$titl, _this$api$t;
6183
+
6184
+ var formatRule = Array.isArray(invalid.rule) ? invalid.rule.join(',') : '' + invalid.rule;
6185
+ 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));
6186
+ },
6187
+ validator: function validator(ctx, value, validate) {
6188
+ var _this3 = this;
6189
+
6190
+ var isEmpty = is.empty(value);
6191
+
6192
+ if (isEmpty) {
6193
+ if (validate.required) {
6194
+ return 'required';
6195
+ }
6196
+
6197
+ return;
6198
+ }
6199
+
6200
+ var _loop = function _loop() {
6201
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
6202
+ key = _Object$entries$_i[0],
6203
+ rule = _Object$entries$_i[1];
6204
+
6205
+ switch (key) {
6206
+ case 'len':
6207
+ case 'maxLen':
6208
+ case 'minLen':
6209
+ var check = function check(val) {
6210
+ if (key === 'len') {
6211
+ return val === rule;
6212
+ } else if (key === 'maxLen') {
6213
+ return val <= rule;
6214
+ } else {
6215
+ return val >= rule;
6216
+ }
6217
+ };
6218
+
6219
+ if (Array.isArray(value)) {
6220
+ if (!check(value.length)) {
6221
+ return {
6222
+ v: key
6223
+ };
6224
+ }
6225
+ } else if (_typeof(value) === 'object') {
6226
+ return {
6227
+ v: key
6228
+ };
6229
+ } else if (!check(('' + value).length)) {
6230
+ return {
6231
+ v: key
6232
+ };
6233
+ }
6234
+
6235
+ break;
6236
+
6237
+ case 'pattern':
6238
+ var reg = typeof rule === 'string' ? new RegExp(rule) : rule;
6239
+
6240
+ if (!reg.test('' + value)) {
6241
+ return {
6242
+ v: key
6243
+ };
6244
+ }
6245
+
6246
+ break;
6247
+
6248
+ case 'uppercase':
6249
+ if (rule && (typeof value !== 'string' || !/^[A-Z]*$/.test(value))) {
6250
+ return {
6251
+ v: key
6252
+ };
6253
+ }
6254
+
6255
+ break;
6256
+
6257
+ case 'lowercase':
6258
+ if (rule && (typeof value !== 'string' || !/^[a-z]*$/.test(value))) {
6259
+ return {
6260
+ v: key
6261
+ };
6262
+ }
6263
+
6264
+ break;
6265
+
6266
+ case 'min':
6267
+ case 'max':
6268
+ case 'positive':
6269
+ case 'negative':
6270
+ case 'integer':
6271
+ case 'number':
6272
+ var num = Number(value);
6273
+
6274
+ if (Number.isNaN(num)) {
6275
+ return {
6276
+ v: key
6277
+ };
6278
+ }
6279
+
6280
+ if (key === 'min' && num < rule) {
6281
+ return {
6282
+ v: key
6283
+ };
6284
+ }
6285
+
6286
+ if (key === 'max' && num > rule) {
6287
+ return {
6288
+ v: key
6289
+ };
6290
+ }
6291
+
6292
+ if (key === 'positive' && num <= 0) {
6293
+ return {
6294
+ v: key
6295
+ };
6296
+ }
6297
+
6298
+ if (key === 'negative' && num >= 0) {
6299
+ return {
6300
+ v: key
6301
+ };
6302
+ }
6303
+
6304
+ if (key === 'integer' && !Number.isInteger(num)) {
6305
+ return {
6306
+ v: key
6307
+ };
6308
+ }
6309
+
6310
+ break;
6311
+
6312
+ case 'equal':
6313
+ if (value !== rule) {
6314
+ return {
6315
+ v: key
6316
+ };
6317
+ }
6318
+
6319
+ break;
6320
+
6321
+ case 'enum':
6322
+ if (Array.isArray(rule) && !rule.includes(value)) {
6323
+ return {
6324
+ v: key
6325
+ };
6326
+ }
6327
+
6328
+ break;
6329
+
6330
+ case 'hasKeys':
6331
+ if (_typeof(value) !== 'object' || Array.isArray(rule) && rule.some(function (key) {
6332
+ return !(key in value);
6333
+ })) {
6334
+ return {
6335
+ v: key
6336
+ };
6337
+ }
6338
+
6339
+ break;
6340
+
6341
+ case 'email':
6342
+ 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,}))$/;
6343
+
6344
+ if (!regexEmail.test('' + value)) {
6345
+ return {
6346
+ v: key
6347
+ };
6348
+ }
6349
+
6350
+ break;
6351
+
6352
+ case 'url':
6353
+ 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');
6354
+
6355
+ if (!regexUrl.test('' + value)) {
6356
+ return {
6357
+ v: key
6358
+ };
6359
+ }
6360
+
6361
+ break;
6362
+
6363
+ case 'ip':
6364
+ 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}$/;
6365
+
6366
+ if (!regexIp.test('' + value)) {
6367
+ return {
6368
+ v: key
6369
+ };
6370
+ }
6371
+
6372
+ break;
6373
+
6374
+ case 'phone':
6375
+ var regexPhone = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
6376
+
6377
+ if (!regexPhone.test('' + value)) {
6378
+ return {
6379
+ v: key
6380
+ };
6381
+ }
6382
+
6383
+ break;
6384
+
6385
+ case 'computed':
6386
+ if (!_this3.compute(ctx, rule)) {
6387
+ return {
6388
+ v: key
6389
+ };
6390
+ }
6391
+
6392
+ break;
6393
+ }
6394
+ };
6395
+
6396
+ for (var _i = 0, _Object$entries = Object.entries(validate); _i < _Object$entries.length; _i++) {
6397
+ var _ret = _loop();
6398
+
6399
+ if (_typeof(_ret) === "object") return _ret.v;
6400
+ }
6401
+ },
6402
+ compute: function compute(ctx, item) {
6403
+ var _this4 = this;
6404
+
6058
6405
  var fn;
6059
6406
 
6060
6407
  if (_typeof(item) === 'object') {
@@ -6073,13 +6420,13 @@
6073
6420
  var or = item.mode === 'OR';
6074
6421
  var valid = true;
6075
6422
 
6076
- var _loop = function _loop(i) {
6423
+ var _loop2 = function _loop2(i) {
6077
6424
  var one = item.group[i];
6078
6425
  var flag = void 0;
6079
6426
  var field = null;
6080
6427
 
6081
6428
  if (one.variable) {
6082
- field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
6429
+ field = JSON.stringify(_this4.fc.getLoadData(one.variable) || '');
6083
6430
  } else if (one.field) {
6084
6431
  field = convertFieldToConditions(one.field || '');
6085
6432
  } else if (!one.mode) {
@@ -6100,11 +6447,11 @@
6100
6447
  flag = false;
6101
6448
  } else if (is.Function(one.handler)) {
6102
6449
  flag = invoke(function () {
6103
- return one.handler(_this2.api, ctx.rule);
6450
+ return one.handler(_this4.api, ctx.rule);
6104
6451
  });
6105
6452
  } else {
6106
6453
  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(_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);
6454
+ 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(_this4.api.form, condition, one.value, _this4.api.top.form, _this4.api.top === _this4.api.scope ? {} : _this4.api.scope.form, group ? _this4.subRuleData[group.id] || {} : {}, ctx.rule);
6108
6455
  });
6109
6456
  }
6110
6457
 
@@ -6120,9 +6467,9 @@
6120
6467
  };
6121
6468
 
6122
6469
  for (var i = 0; i < item.group.length; i++) {
6123
- var _ret = _loop(i);
6470
+ var _ret2 = _loop2(i);
6124
6471
 
6125
- if (_typeof(_ret) === "object") return _ret.v;
6472
+ if (_typeof(_ret2) === "object") return _ret2.v;
6126
6473
  }
6127
6474
 
6128
6475
  return or ? false : valid;
@@ -6133,27 +6480,27 @@
6133
6480
 
6134
6481
  if (item.linkage) {
6135
6482
  return val ? invoke(function () {
6136
- return _this2.computeValue(item.linkage, ctx, group);
6483
+ return _this4.computeValue(item.linkage, ctx, group);
6137
6484
  }, undefined) : oldValueTag;
6138
6485
  }
6139
6486
 
6140
6487
  return val;
6141
6488
  } else if (is.Function(item)) {
6142
6489
  fn = function fn() {
6143
- return item(_this2.api.form, _this2.api);
6490
+ return item(_this4.api.form, _this4.api);
6144
6491
  };
6145
6492
  } else {
6146
6493
  var _group = ctx.getParentGroup();
6147
6494
 
6148
6495
  fn = function fn() {
6149
- return _this2.computeValue(item, ctx, _group);
6496
+ return _this4.computeValue(item, ctx, _group);
6150
6497
  };
6151
6498
  }
6152
6499
 
6153
6500
  return invoke(fn, undefined);
6154
6501
  },
6155
6502
  computeValue: function computeValue(str, ctx, group) {
6156
- var _this3 = this;
6503
+ var _this5 = this;
6157
6504
 
6158
6505
  var that = this;
6159
6506
  var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
@@ -6175,35 +6522,35 @@
6175
6522
  return obj;
6176
6523
  }, {});
6177
6524
  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(_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);
6525
+ return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this5.api.form, formulas, _this5.api.top.form, _this5.api.top === _this5.api.scope ? {} : _this5.api.scope.form, group ? _this5.subRuleData[group.id] || {} : {}, ctx.rule, _this5.api);
6179
6526
  }, undefined);
6180
6527
  },
6181
6528
  updateChildren: function updateChildren(ctx, n, o) {
6182
- var _this4 = this;
6529
+ var _this6 = this;
6183
6530
 
6184
6531
  this.deferSyncValue(function () {
6185
6532
  o && o.forEach(function (child) {
6186
6533
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
6187
- _this4.rmCtx(child.__fc__);
6534
+ _this6.rmCtx(child.__fc__);
6188
6535
  }
6189
6536
  });
6190
6537
 
6191
6538
  if (is.trueArray(n)) {
6192
- _this4.loadChildren(n, ctx);
6539
+ _this6.loadChildren(n, ctx);
6193
6540
 
6194
- _this4.bus.$emit('update', _this4.api);
6541
+ _this6.bus.$emit('update', _this6.api);
6195
6542
  }
6196
6543
  });
6197
6544
  },
6198
6545
  rmSub: function rmSub(sub) {
6199
- var _this5 = this;
6546
+ var _this7 = this;
6200
6547
 
6201
6548
  is.trueArray(sub) && sub.forEach(function (r) {
6202
- r && r.__fc__ && _this5.rmCtx(r.__fc__);
6549
+ r && r.__fc__ && _this7.rmCtx(r.__fc__);
6203
6550
  });
6204
6551
  },
6205
6552
  rmCtx: function rmCtx(ctx) {
6206
- var _this6 = this;
6553
+ var _this8 = this;
6207
6554
 
6208
6555
  if (ctx.deleted) return;
6209
6556
  var id = ctx.id,
@@ -6232,19 +6579,19 @@
6232
6579
  }
6233
6580
 
6234
6581
  this.deferSyncValue(function () {
6235
- if (!_this6.reloading) {
6582
+ if (!_this8.reloading) {
6236
6583
  if (ctx.parser.loadChildren !== false) {
6237
6584
  var children = ctx.getPending('children', ctx.rule.children);
6238
6585
 
6239
6586
  if (is.trueArray(children)) {
6240
6587
  children.forEach(function (h) {
6241
- return h.__fc__ && _this6.rmCtx(h.__fc__);
6588
+ return h.__fc__ && _this8.rmCtx(h.__fc__);
6242
6589
  });
6243
6590
  }
6244
6591
  }
6245
6592
 
6246
- if (ctx.root === _this6.rules) {
6247
- _this6.vm.setupState.renderRule();
6593
+ if (ctx.root === _this8.rules) {
6594
+ _this8.vm.setupState.renderRule();
6248
6595
  }
6249
6596
  }
6250
6597
  }, input);
@@ -6617,7 +6964,26 @@
6617
6964
  }
6618
6965
  }).then(function () {
6619
6966
  return _this3.globalBeforeFetch(opt);
6620
- })["catch"](function () {});
6967
+ });
6968
+ },
6969
+ beforeSubmit: function beforeSubmit(formData) {
6970
+ var _this4 = this;
6971
+
6972
+ return new Promise(function (resolve, reject) {
6973
+ var res = _this4.options.beforeSubmit && invoke(function () {
6974
+ return _this4.options.beforeSubmit(formData, {
6975
+ api: _this4.api
6976
+ });
6977
+ });
6978
+
6979
+ if (res && is.Function(res.then)) {
6980
+ res.then(resolve)["catch"](reject);
6981
+ } else if (res === false) {
6982
+ reject();
6983
+ } else {
6984
+ resolve();
6985
+ }
6986
+ });
6621
6987
  }
6622
6988
  });
6623
6989
  useInject(Handler);
@@ -6772,6 +7138,13 @@
6772
7138
  form: function form() {
6773
7139
  return this.vm.refs[this.ref];
6774
7140
  },
7141
+ adapterValidate: function adapterValidate(validate, validator) {
7142
+ validate.validator = function (rule, value, callback) {
7143
+ return validator(value, callback);
7144
+ };
7145
+
7146
+ return validate;
7147
+ },
6775
7148
  getSlot: function getSlot(name) {
6776
7149
  var _fn = function _fn(vm) {
6777
7150
  if (vm) {
@@ -6829,14 +7202,30 @@
6829
7202
  attrs.forEach(function (attr) {
6830
7203
  if (attr && (attr.attr || attr.template)) {
6831
7204
  var fn = function fn(get) {
7205
+ var group;
7206
+
7207
+ if (rule && rule.__fc__) {
7208
+ group = rule.__fc__.getParentGroup();
7209
+ }
7210
+
6832
7211
  var value;
6833
7212
 
6834
7213
  if (attr.template) {
6835
- value = fc.$handle.loadStrVar(attr.template, get);
7214
+ value = fc.$handle.loadStrVar(attr.template, get, group ? {
7215
+ rule: rule,
7216
+ value: fc.$handle.subRuleData[group.id] || {}
7217
+ } : null);
6836
7218
  } else if (attr.handler && is.Function(attr.handler)) {
6837
7219
  value = attr.handler(get, rule, api);
6838
7220
  } else {
6839
- value = get(attr.attr, attr["default"]);
7221
+ value = fc.$handle.loadStrVar("{{".concat(attr.attr, "}}"), get, group ? {
7222
+ rule: rule,
7223
+ value: fc.$handle.subRuleData[group.id] || {}
7224
+ } : null);
7225
+ }
7226
+
7227
+ if ((value == null || value === '') && attr["default"] != null) {
7228
+ value = attr["default"];
6840
7229
  }
6841
7230
 
6842
7231
  if (attr.copy !== false) {
@@ -7132,7 +7521,7 @@
7132
7521
  api: api
7133
7522
  });
7134
7523
  });
7135
- });
7524
+ })["catch"](function (e) {});
7136
7525
  }, option.wait || 600));
7137
7526
  }
7138
7527
 
@@ -7266,6 +7655,57 @@
7266
7655
  return baseDriver(getSessionStorage, name);
7267
7656
  }
7268
7657
 
7658
+ var baseLanguage = {
7659
+ en: {
7660
+ required: '{title} is required',
7661
+ validate: {
7662
+ url: '{title} is not a valid url',
7663
+ email: '{title} is not a valid email',
7664
+ ip: '{title} {title} is not a valid ip',
7665
+ phone: '{title} {title} is not a valid phone',
7666
+ pattern: '{title} does not match pattern {pattern}',
7667
+ uppercase: '{title} must be all uppercase',
7668
+ lowercase: '{title} must be all lowercased',
7669
+ positive: '{title} is not a positive number',
7670
+ negative: '{title} is not a negative number',
7671
+ equal: '{title} is not equal to {equal}',
7672
+ min: '{title} cannot be less than {min}',
7673
+ max: '{title} cannot be greater than {max}',
7674
+ "enum": '{title} must be one of {enum}',
7675
+ hasKeys: '{title} does not contain required fields {hasKeys}',
7676
+ minLen: '{title} must be at least {minLen}',
7677
+ maxLen: '{title} cannot be longer than {maxLen}',
7678
+ len: '{title} must be exactly {len}',
7679
+ integer: '{title} is not an integer',
7680
+ number: '{title} is not an number'
7681
+ }
7682
+ },
7683
+ 'zh-cn': {
7684
+ required: '{title}不能为空',
7685
+ validate: {
7686
+ url: '{title}不是有效的 url 地址',
7687
+ email: '{title}不是有效的邮箱地址',
7688
+ ip: '{title}不是有效的 IP 地址',
7689
+ phone: '{title}不是正确的手机号',
7690
+ pattern: '{title}必须匹配 {pattern}',
7691
+ uppercase: '{title}必须全大写',
7692
+ lowercase: '{title}必须全小写',
7693
+ positive: '{title}不是正数',
7694
+ negative: '{title}不是负数',
7695
+ equal: '{title}必须等于 {equal}',
7696
+ min: '{title}必须大于等于 {min}',
7697
+ max: '{title}必须小于等于 {max}',
7698
+ "enum": '{title}必须是 {enum} 之一',
7699
+ hasKeys: '{title}必须包含 {hasKeys} 字段',
7700
+ minLen: '{title}长度必须大于 {minLen}',
7701
+ maxLen: '{title}长度必须小于 {maxLen}',
7702
+ len: '{title}长度必须为 {len}',
7703
+ integer: '{title}必须为整数',
7704
+ number: '{title}必须为数字'
7705
+ }
7706
+ }
7707
+ };
7708
+
7269
7709
  function parseProp(name, id) {
7270
7710
  var prop;
7271
7711
 
@@ -7789,7 +8229,11 @@
7789
8229
 
7790
8230
  var _locale = this.getLocale();
7791
8231
 
7792
- value = deepGet(language[_locale], id);
8232
+ value = deepGet(language[_locale] || {}, id);
8233
+
8234
+ if (value == null) {
8235
+ value = deepGet(baseLanguage[_locale] || {}, id);
8236
+ }
7793
8237
  }
7794
8238
 
7795
8239
  return value;
@@ -8466,7 +8910,6 @@
8466
8910
  e.preventDefault();
8467
8911
  }
8468
8912
  },
8469
- "class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : ''],
8470
8913
  style: form.style,
8471
8914
  type: 'form'
8472
8915
  };
@@ -8475,9 +8918,11 @@
8475
8918
  var key = this.key,
8476
8919
  ref = this.ref,
8477
8920
  $handle = this.$handle;
8921
+ var form = this.options.form;
8478
8922
  extend(this.rule, {
8479
8923
  key: key,
8480
- ref: ref
8924
+ ref: ref,
8925
+ "class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : '']
8481
8926
  });
8482
8927
  extend(this.rule.props, {
8483
8928
  model: $handle.formData
@@ -8942,14 +9387,16 @@
8942
9387
  var promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
8943
9388
  promise.then(function () {
8944
9389
  var formData = api.formData();
8945
- is.Function(successFn) && invoke(function () {
8946
- return successFn(formData, api);
8947
- });
8948
- is.Function(h.options.onSubmit) && invoke(function () {
8949
- return h.options.onSubmit(formData, api);
8950
- });
8951
- h.vm.emit('submit', formData, api);
8952
- resolve(formData);
9390
+ h.beforeSubmit(formData).then(function () {
9391
+ is.Function(successFn) && invoke(function () {
9392
+ return successFn(formData, api);
9393
+ });
9394
+ is.Function(h.options.onSubmit) && invoke(function () {
9395
+ return h.options.onSubmit(formData, api);
9396
+ });
9397
+ h.vm.emit('submit', formData, api);
9398
+ resolve(formData);
9399
+ })["catch"](function (e) {});
8953
9400
  })["catch"](function () {
8954
9401
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8955
9402
  args[_key] = arguments[_key];
@@ -9056,7 +9503,7 @@
9056
9503
  function elmFormCreate() {
9057
9504
  return FormCreateFactory({
9058
9505
  ui: 'element-ui',
9059
- version: '3.2.21',
9506
+ version: '3.2.23',
9060
9507
  manager: manager,
9061
9508
  extendApi: extendApi,
9062
9509
  install: install,