@form-create/element-ui 3.1.5 → 3.1.6

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.1.4
2
+ * @form-create/element-ui v3.1.6
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1499,6 +1499,26 @@
1499
1499
  },
1500
1500
  emits: ['update:modelValue', 'change', 'itemMounted', 'remove'],
1501
1501
  watch: {
1502
+ rule: {
1503
+ handler: function handler(n, o) {
1504
+ var _this = this;
1505
+
1506
+ Object.keys(this.cacheRule).forEach(function (v) {
1507
+ var item = _this.cacheRule[v];
1508
+
1509
+ if (n === o) {
1510
+ deepExtend(item.rule, n);
1511
+ } else {
1512
+ var val = item.$f.formData();
1513
+ item.$f.once('reloading', function () {
1514
+ item.$f.setValue(val);
1515
+ });
1516
+ item.rule = deepCopy(n);
1517
+ }
1518
+ });
1519
+ },
1520
+ deep: true
1521
+ },
1502
1522
  disabled: function disabled(n) {
1503
1523
  if (this.syncDisabled) {
1504
1524
  var lst = this.cacheRule;
@@ -1516,7 +1536,7 @@
1516
1536
  },
1517
1537
  modelValue: {
1518
1538
  handler: function handler(n) {
1519
- var _this = this;
1539
+ var _this2 = this;
1520
1540
 
1521
1541
  n = n || [];
1522
1542
  var keys = Object.keys(this.cacheRule),
@@ -1539,7 +1559,7 @@
1539
1559
  }
1540
1560
 
1541
1561
  n.forEach(function (val, i) {
1542
- _this.setValue(keys[i], n[i]);
1562
+ _this2.setValue(keys[i], n[i]);
1543
1563
  });
1544
1564
  }
1545
1565
  },
@@ -1558,7 +1578,7 @@
1558
1578
  this.$emit('change', value);
1559
1579
  },
1560
1580
  formData: function formData(key, _formData) {
1561
- var _this2 = this;
1581
+ var _this3 = this;
1562
1582
 
1563
1583
  var cacheRule = this.cacheRule;
1564
1584
  var keys = Object.keys(cacheRule);
@@ -1570,10 +1590,10 @@
1570
1590
  }
1571
1591
 
1572
1592
  var value = keys.map(function (k) {
1573
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1574
- var value = _this2.field ? data[_this2.field] || null : data;
1593
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1594
+ var value = _this3.field ? data[_this3.field] || null : data;
1575
1595
 
1576
- _this2.cache(k, value);
1596
+ _this3.cache(k, value);
1577
1597
 
1578
1598
  return value;
1579
1599
  });
@@ -1593,7 +1613,7 @@
1593
1613
  this.cache(key, value);
1594
1614
  },
1595
1615
  addRule: function addRule(i, emit) {
1596
- var _this3 = this;
1616
+ var _this4 = this;
1597
1617
 
1598
1618
  var rule = this.formCreateInject.form.copyRules(this.rule || []);
1599
1619
  var options = this.options ? _objectSpread2({}, this.options) : {
@@ -1614,25 +1634,25 @@
1614
1634
 
1615
1635
  if (emit) {
1616
1636
  vue.nextTick(function () {
1617
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1637
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1618
1638
  });
1619
1639
  }
1620
1640
  },
1621
1641
  add$f: function add$f(i, key, $f) {
1622
- var _this4 = this;
1642
+ var _this5 = this;
1623
1643
 
1624
1644
  this.cacheRule[key].$f = $f;
1625
1645
  this.formData(key, $f.formData());
1626
1646
  vue.nextTick(function () {
1627
- if (_this4.syncDisabled) {
1628
- $f.disabled(_this4.disabled);
1647
+ if (_this5.syncDisabled) {
1648
+ $f.disabled(_this5.disabled);
1629
1649
  }
1630
1650
 
1631
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1651
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1632
1652
  });
1633
1653
  },
1634
1654
  removeRule: function removeRule(key, emit) {
1635
- var _this5 = this;
1655
+ var _this6 = this;
1636
1656
 
1637
1657
  var index = Object.keys(this.cacheRule).indexOf(key);
1638
1658
  delete this.cacheRule[key];
@@ -1640,7 +1660,7 @@
1640
1660
 
1641
1661
  if (emit) {
1642
1662
  vue.nextTick(function () {
1643
- return _this5.$emit('remove', index);
1663
+ return _this6.$emit('remove', index);
1644
1664
  });
1645
1665
  }
1646
1666
  },
@@ -1673,14 +1693,14 @@
1673
1693
  });
1674
1694
  },
1675
1695
  delIcon: function delIcon(index, key) {
1676
- var _this6 = this;
1696
+ var _this7 = this;
1677
1697
 
1678
1698
  return vue.createVNode(vue.resolveComponent("ElIcon"), {
1679
1699
  "key": "d".concat(key),
1680
1700
  "class": "el-icon-remove-outline",
1681
1701
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
1682
1702
  "onClick": function onClick() {
1683
- return _this6.del(index, key);
1703
+ return _this7.del(index, key);
1684
1704
  }
1685
1705
  }, {
1686
1706
  "default": function _default() {
@@ -1689,7 +1709,7 @@
1689
1709
  });
1690
1710
  },
1691
1711
  makeIcon: function makeIcon(total, index, key) {
1692
- var _this7 = this;
1712
+ var _this8 = this;
1693
1713
 
1694
1714
  if (this.$slots.button) {
1695
1715
  return this.$slots.button({
@@ -1698,7 +1718,7 @@
1698
1718
  vm: this,
1699
1719
  key: key,
1700
1720
  del: function del() {
1701
- return _this7.del(index, key);
1721
+ return _this8.del(index, key);
1702
1722
  },
1703
1723
  add: this.add
1704
1724
  });
@@ -1733,7 +1753,7 @@
1733
1753
  }
1734
1754
  },
1735
1755
  render: function render() {
1736
- var _this8 = this;
1756
+ var _this9 = this;
1737
1757
 
1738
1758
  var keys = Object.keys(this.cacheRule);
1739
1759
  var button = this.button;
@@ -1754,9 +1774,9 @@
1754
1774
  }, [keys.map(function (key, index) {
1755
1775
  var _slot;
1756
1776
 
1757
- var _this8$cacheRule$key = _this8.cacheRule[key],
1758
- rule = _this8$cacheRule$key.rule,
1759
- options = _this8$cacheRule$key.options;
1777
+ var _this9$cacheRule$key = _this9.cacheRule[key],
1778
+ rule = _this9$cacheRule$key.rule,
1779
+ options = _this9$cacheRule$key.options;
1760
1780
  return vue.createVNode(vue.resolveComponent("ElRow"), {
1761
1781
  "align": "middle",
1762
1782
  "type": "flex",
@@ -1774,18 +1794,18 @@
1774
1794
  "key": key,
1775
1795
  "inFor": true,
1776
1796
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
1777
- return _this8.formData(key, formData);
1797
+ return _this9.formData(key, formData);
1778
1798
  },
1779
- "modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
1799
+ "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
1780
1800
  "onEmit-event": function onEmitEvent(name) {
1781
1801
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1782
1802
  args[_key - 1] = arguments[_key];
1783
1803
  }
1784
1804
 
1785
- return _this8.emitEvent(name, args, index, key);
1805
+ return _this9.emitEvent(name, args, index, key);
1786
1806
  },
1787
1807
  "onUpdate:api": function onUpdateApi($f) {
1788
- return _this8.add$f(index, key, $f);
1808
+ return _this9.add$f(index, key, $f);
1789
1809
  },
1790
1810
  "rule": rule,
1791
1811
  "option": options,
@@ -1798,7 +1818,7 @@
1798
1818
  "span": 2,
1799
1819
  "pull": 1,
1800
1820
  "push": 1
1801
- }, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
1821
+ }, _isSlot(_slot = _this9.makeIcon(keys.length, index, key)) ? _slot : {
1802
1822
  "default": function _default() {
1803
1823
  return [_slot];
1804
1824
  }
@@ -1923,7 +1943,7 @@
1923
1943
  var NAME$1 = 'FormCreate';
1924
1944
 
1925
1945
  var getRuleInject = function getRuleInject(vm, parent) {
1926
- if (vm === parent) {
1946
+ if (!vm || vm === parent) {
1927
1947
  return;
1928
1948
  }
1929
1949
 
@@ -1984,7 +2004,7 @@
1984
2004
  isShow: true,
1985
2005
  unique: 1,
1986
2006
  renderRule: _toConsumableArray(rule.value || []),
1987
- updateValue: JSON.stringify(modelValue)
2007
+ updateValue: JSON.stringify(modelValue || {})
1988
2008
  });
1989
2009
  var fc = new FormCreate(vm);
1990
2010
  var fapi = fc.api();
@@ -2156,7 +2176,7 @@
2156
2176
  };
2157
2177
  };
2158
2178
 
2159
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate'];
2179
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache'];
2160
2180
  var arrayAttrs = ['validate', 'children', 'control'];
2161
2181
  var normalAttrs = ['effect'];
2162
2182
  function attrs() {
@@ -2544,7 +2564,7 @@
2544
2564
  if (!ctx) return initial;
2545
2565
  initial[ctx.field] = copy(ctx.rule.value);
2546
2566
  return initial;
2547
- }, copy(h.appendData));
2567
+ }, {});
2548
2568
  },
2549
2569
  getValue: function getValue(field) {
2550
2570
  var ctx = h.getFieldCtx(field);
@@ -3075,7 +3095,6 @@
3075
3095
  try {
3076
3096
  if (ctx.type === 'hidden') return;
3077
3097
  var rule = ctx.rule;
3078
- var preview = this.options.preview || false;
3079
3098
 
3080
3099
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
3081
3100
  var vn;
@@ -3087,7 +3106,10 @@
3087
3106
  this.setOptions(ctx);
3088
3107
  this.ctxProp(ctx);
3089
3108
  var prop = ctx.prop;
3109
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3090
3110
  prop.props.formCreateInject = this.injectProp(ctx);
3111
+ var cacheFlag = prop.cache !== false;
3112
+ var preview = prop.preview;
3091
3113
 
3092
3114
  if (prop.hidden) {
3093
3115
  this.setCache(ctx, undefined, parent);
@@ -3145,18 +3167,18 @@
3145
3167
  _vn = _this4.display(_vn);
3146
3168
  }
3147
3169
 
3148
- _this4.setCache(ctx, function () {
3170
+ cacheFlag && _this4.setCache(ctx, function () {
3149
3171
  return _vn;
3150
3172
  }, parent);
3151
-
3152
3173
  return _vn;
3153
3174
  };
3154
3175
 
3155
3176
  this.setCache(ctx, vn, parent);
3156
- return vn;
3157
3177
  }
3158
3178
 
3159
- return this.getCache(ctx);
3179
+ return function () {
3180
+ return _this4.getCache(ctx).apply(void 0, arguments);
3181
+ };
3160
3182
  } catch (e) {
3161
3183
  console.error(e);
3162
3184
  return;
@@ -3223,7 +3245,7 @@
3223
3245
 
3224
3246
  var inject = state.ctxInject[ctx.id];
3225
3247
  extend(inject, {
3226
- preview: this.options.preview || false,
3248
+ preview: ctx.prop.preview,
3227
3249
  options: ctx.prop.options,
3228
3250
  children: ctx.loadChildrenPending()
3229
3251
  });
@@ -3301,6 +3323,7 @@
3301
3323
  },
3302
3324
  defaultRender: function defaultRender(ctx, children) {
3303
3325
  var prop = ctx.prop;
3326
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3304
3327
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3305
3328
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3306
3329
  return this.vNode.make(lower(ctx.originType), prop, children);
@@ -3775,11 +3798,7 @@
3775
3798
  this.$handle.appendLink(this);
3776
3799
  },
3777
3800
  watchTo: function watchTo() {
3778
- var _this4 = this;
3779
-
3780
- vue.nextTick(function () {
3781
- _this4.$handle && _this4.$handle.watchCtx(_this4);
3782
- });
3801
+ this.$handle.watchCtx(this);
3783
3802
  },
3784
3803
  "delete": function _delete() {
3785
3804
  var undef = void 0;
@@ -3808,15 +3827,15 @@
3808
3827
  this.ctrlRule = [];
3809
3828
  },
3810
3829
  rm: function rm() {
3811
- var _this5 = this;
3830
+ var _this4 = this;
3812
3831
 
3813
3832
  var _rm = function _rm() {
3814
- var index = _this5.root.indexOf(_this5.origin);
3833
+ var index = _this4.root.indexOf(_this4.origin);
3815
3834
 
3816
3835
  if (index > -1) {
3817
- _this5.root.splice(index, 1);
3836
+ _this4.root.splice(index, 1);
3818
3837
 
3819
- _this5.$handle && _this5.$handle.refresh();
3838
+ _this4.$handle && _this4.$handle.refresh();
3820
3839
  }
3821
3840
  };
3822
3841
 
@@ -3827,17 +3846,17 @@
3827
3846
  }
3828
3847
 
3829
3848
  this.$handle.noWatch(function () {
3830
- _this5.$handle.deferSyncValue(function () {
3831
- _this5.rmCtrl();
3849
+ _this4.$handle.deferSyncValue(function () {
3850
+ _this4.rmCtrl();
3832
3851
 
3833
3852
  _rm();
3834
3853
 
3835
- _this5.$handle.rmCtx(_this5);
3854
+ _this4.$handle.rmCtx(_this4);
3836
3855
 
3837
- extend(_this5, {
3856
+ extend(_this4, {
3838
3857
  root: []
3839
3858
  });
3840
- }, _this5.input);
3859
+ }, _this4.input);
3841
3860
  });
3842
3861
  },
3843
3862
  update: function update(handle, init) {
@@ -3941,13 +3960,13 @@
3941
3960
  return _this5.loadRule();
3942
3961
  }
3943
3962
 
3963
+ _this5.syncForm();
3964
+
3944
3965
  if (_this5.pageEnd) {
3945
3966
  _this5.bus.$emit('load-end');
3946
3967
  }
3947
3968
 
3948
3969
  _this5.vm.setupState.renderRule();
3949
-
3950
- _this5.syncForm();
3951
3970
  });
3952
3971
  },
3953
3972
  loadChildren: function loadChildren(children, parent) {
@@ -3962,8 +3981,8 @@
3962
3981
  if (this.cycleLoad) {
3963
3982
  return this.loadRule();
3964
3983
  } else {
3965
- this.bus.$emit('load-end');
3966
3984
  this.syncForm();
3985
+ this.bus.$emit('load-end');
3967
3986
  }
3968
3987
 
3969
3988
  this.$render.clearCache(parent);
@@ -4207,19 +4226,27 @@
4207
4226
  this.clearNextTick();
4208
4227
  this.initData(rules);
4209
4228
  this.fc.rules = rules;
4210
- this.bus.$once('load-end', function () {
4211
- Object.keys(ctxs).filter(function (id) {
4212
- return _this8.ctxs[id] === undefined;
4213
- }).forEach(function (id) {
4214
- return _this8.rmCtx(ctxs[id]);
4229
+ this.deferSyncValue(function () {
4230
+ _this8.bus.$once('load-end', function () {
4231
+ Object.keys(ctxs).filter(function (id) {
4232
+ return _this8.ctxs[id] === undefined;
4233
+ }).forEach(function (id) {
4234
+ return _this8.rmCtx(ctxs[id]);
4235
+ });
4236
+
4237
+ _this8.$render.clearCacheAll();
4215
4238
  });
4216
4239
 
4217
- _this8.$render.clearCacheAll();
4240
+ _this8.reloading = true;
4241
+
4242
+ _this8.loadRule();
4243
+
4244
+ _this8.reloading = false;
4245
+
4246
+ _this8.refresh();
4247
+
4248
+ _this8.bus.$emit('reloading', _this8.api);
4218
4249
  });
4219
- this.reloading = true;
4220
- this.loadRule();
4221
- this.reloading = false;
4222
- this.refresh();
4223
4250
  this.bus.$off('next-tick', this.nextReload);
4224
4251
  this.bus.$once('next-tick', this.nextReload);
4225
4252
  this.bus.$emit('update', this.api);
@@ -4285,28 +4312,14 @@
4285
4312
  syncForm: function syncForm() {
4286
4313
  var _this = this;
4287
4314
 
4315
+ var data = vue.reactive({});
4288
4316
  this.fields().reduce(function (initial, field) {
4289
4317
  var ctx = _this.getCtx(field);
4290
4318
 
4291
4319
  initial[field] = vue.toRef(ctx.rule, 'value');
4292
4320
  return initial;
4293
- }, Object.keys(this.appendData).reduce(function (initial, field) {
4294
- initial[field] = vue.customRef(function (track, trigger) {
4295
- return {
4296
- get: function get() {
4297
- track();
4298
- return _this.appendData[field];
4299
- },
4300
- set: function set(val) {
4301
- trigger();
4302
- _this.appendData[field] = val;
4303
-
4304
- _this.syncValue();
4305
- }
4306
- };
4307
- });
4308
- return initial;
4309
- }, this.form));
4321
+ }, data);
4322
+ this.form = data;
4310
4323
  this.syncValue();
4311
4324
  },
4312
4325
  appendValue: function appendValue(rule) {
@@ -4413,11 +4426,46 @@
4413
4426
  return ctx.$render.defaultRender(ctx, children);
4414
4427
  },
4415
4428
  preview: function preview(children, ctx) {
4416
- return ctx.$render.defaultRender(ctx, children);
4429
+ return this.render(children, ctx);
4417
4430
  },
4418
4431
  mergeProp: function mergeProp(ctx) {}
4419
4432
  };
4420
4433
 
4434
+ var _ = {
4435
+ sum: function sum(arr) {
4436
+ if (Array.isArray(arr)) {
4437
+ var val = 0;
4438
+ arr.map(function (v) {
4439
+ return val += v || 0;
4440
+ });
4441
+ return val;
4442
+ }
4443
+ },
4444
+ column: function column(arr, field) {
4445
+ if (Array.isArray(arr)) {
4446
+ return arr.map(function (v) {
4447
+ return v[field];
4448
+ });
4449
+ }
4450
+
4451
+ return [];
4452
+ },
4453
+ get: function get(obj, field, def) {
4454
+ var lst = field.split('.');
4455
+ var val = obj;
4456
+
4457
+ for (var i = 0; i < lst.length; i++) {
4458
+ if (hasProperty(val, lst[i])) {
4459
+ val = val[lst[i]];
4460
+ } else {
4461
+ return def === undefined ? 0 : def;
4462
+ }
4463
+ }
4464
+
4465
+ return val;
4466
+ }
4467
+ };
4468
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
4421
4469
  function useContext(Handler) {
4422
4470
  extend(Handler.prototype, {
4423
4471
  getCtx: function getCtx(id) {
@@ -4494,10 +4542,9 @@
4494
4542
  watchCtx: function watchCtx(ctx) {
4495
4543
  var _this = this;
4496
4544
 
4497
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate'];
4498
4545
  var all = attrs();
4499
4546
  all.filter(function (k) {
4500
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4547
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4501
4548
  }).forEach(function (key) {
4502
4549
  var ref = vue.toRef(ctx.rule, key);
4503
4550
  var flag = key === 'children';
@@ -4560,11 +4607,36 @@
4560
4607
  return val.value;
4561
4608
  }, function () {
4562
4609
  var formValue = ctx.parser.toFormValue(val.value, ctx);
4610
+ formValue = formValue === null ? undefined : formValue;
4563
4611
 
4564
4612
  if (_this.isChange(ctx, formValue)) {
4565
4613
  _this.setValue(ctx, val.value, formValue, true);
4566
4614
  }
4567
4615
  }));
4616
+ this.bus.$once('load-end', function () {
4617
+ var computedRef = vue.toRef(ctx.rule, 'computed');
4618
+ ctx.watch.push(vue.watch(function () {
4619
+ var computed = computedRef.value;
4620
+ if (!computed) return undefined;
4621
+ var fn;
4622
+
4623
+ if (is.Function(computed)) {
4624
+ fn = function fn() {
4625
+ return computed(_this.api.form, _this.api);
4626
+ };
4627
+ } else {
4628
+ fn = function fn() {
4629
+ return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
4630
+ };
4631
+ }
4632
+
4633
+ return invoke(fn, undefined);
4634
+ }, function (n) {
4635
+ val.value = n;
4636
+ }, {
4637
+ immediate: !!computedRef.value
4638
+ }));
4639
+ });
4568
4640
  }
4569
4641
 
4570
4642
  this.watchEffect(ctx);
@@ -4605,6 +4677,7 @@
4605
4677
  $del(this.formData, id);
4606
4678
  $del(this.subForm, id);
4607
4679
  $del(this.vm.setupState.ctxInject, id);
4680
+ input && $del(this.form, field);
4608
4681
  input && this.rmIdCtx(ctx, field, 'field');
4609
4682
  name && this.rmIdCtx(ctx, name, 'name');
4610
4683
  this.deferSyncValue(function () {
@@ -5001,6 +5074,14 @@
5001
5074
  make: function make(tag, data, children) {
5002
5075
  return makeDirective(data, this.h(tag, toProps(data), children));
5003
5076
  },
5077
+ makeComponent: function makeComponent(type, data, children) {
5078
+ try {
5079
+ return makeDirective(data, vue.createVNode(type, toProps(data), children));
5080
+ } catch (e) {
5081
+ console.error(e);
5082
+ return vue.createVNode('');
5083
+ }
5084
+ },
5004
5085
  h: function h(tag, data, children) {
5005
5086
  var isNativeTag = vue.getCurrentInstance().appContext.config.isNativeTag(tag);
5006
5087
 
@@ -5417,7 +5498,7 @@
5417
5498
  CreateNode: CreateNode,
5418
5499
  bus: new Mitt(),
5419
5500
  unwatch: null,
5420
- options: vue.ref({}),
5501
+ options: vue.ref(vm.props.option || {}),
5421
5502
  extendApi: config.extendApi || function (api) {
5422
5503
  return api;
5423
5504
  }
@@ -5461,7 +5542,7 @@
5461
5542
  });
5462
5543
  }
5463
5544
 
5464
- this.initOptions(this.vm.props.option || {});
5545
+ this.initOptions(this.options || {});
5465
5546
  this.$handle.init();
5466
5547
  },
5467
5548
  isSub: function isSub() {
@@ -6370,17 +6451,17 @@
6370
6451
  var required = {
6371
6452
  name: 'required',
6372
6453
  load: function load(inject, rule, api) {
6373
- var val = parseVa(inject.getValue());
6454
+ var val = parseVal(inject.getValue());
6374
6455
 
6375
6456
  if (val.required === false) {
6376
6457
  inject.clearProp();
6377
6458
  } else {
6378
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
6459
+ var validate = _objectSpread2({
6379
6460
  required: true,
6380
6461
  validator: function validator(_, v, call) {
6381
6462
  is.empty(v) ? call(validate.message) : call();
6382
6463
  }
6383
- });
6464
+ }, val);
6384
6465
 
6385
6466
  if (!validate.message) {
6386
6467
  validate.message = rule.title + ' is required';
@@ -6396,7 +6477,7 @@
6396
6477
  }
6397
6478
  };
6398
6479
 
6399
- function parseVa(val) {
6480
+ function parseVal(val) {
6400
6481
  if (is.Boolean(val)) {
6401
6482
  return {
6402
6483
  required: val
@@ -6405,6 +6486,10 @@
6405
6486
  return {
6406
6487
  message: val
6407
6488
  };
6489
+ } else if (is.Function(val)) {
6490
+ return {
6491
+ validator: val
6492
+ };
6408
6493
  } else if (!is.Object(val)) {
6409
6494
  return {};
6410
6495
  } else {
@@ -6435,7 +6520,7 @@
6435
6520
  function elmFormCreate() {
6436
6521
  return FormCreateFactory({
6437
6522
  ui: 'element-ui',
6438
- version: '3.1.4',
6523
+ version: '3.1.6',
6439
6524
  manager: manager,
6440
6525
  extendApi: extendApi,
6441
6526
  install: install,