@form-create/element-ui 2.5.31 → 2.5.33

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 v2.5.31
2
+ * @form-create/element-ui v2.5.33
3
3
  * (c) 2018-2023 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -312,6 +312,7 @@
312
312
  value: this.trueValue
313
313
  }
314
314
  }, {
315
+ "ref": "el",
315
316
  "on": {
316
317
  "input": this.onInput
317
318
  }
@@ -325,6 +326,9 @@
325
326
  "key": Type + index + '-' + opt.value
326
327
  }]));
327
328
  }), getSlot(this.$slots)]);
329
+ },
330
+ mounted: function mounted() {
331
+ this.$emit('fc.el', this.$refs.el);
328
332
  }
329
333
  };
330
334
 
@@ -866,7 +870,9 @@
866
870
  render: function render() {
867
871
  var _this2 = this;
868
872
  var h = arguments[0];
869
- return h("ElRadioGroup", helper([{}, this.formCreateInject.prop, {}, {
873
+ return h("ElRadioGroup", helper([{}, this.formCreateInject.prop, {
874
+ "ref": "el"
875
+ }, {
870
876
  "props": {
871
877
  value: this.trueValue
872
878
  }
@@ -884,6 +890,9 @@
884
890
  "key": Type + index + '-' + opt.value
885
891
  }]));
886
892
  }), getSlot(this.$slots)]);
893
+ },
894
+ mounted: function mounted() {
895
+ this.$emit('fc.el', this.$refs.el);
887
896
  }
888
897
  };
889
898
 
@@ -938,8 +947,7 @@
938
947
  }
939
948
  },
940
949
  render: function render(h, ctx) {
941
- var options = ctx.props.formCreateInject.options;
942
- return h("ElSelect", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
950
+ var makeOption = function makeOption(props, index) {
943
951
  var slot = props.slot;
944
952
  return h("ElOption", helper([{}, {
945
953
  "props": props
@@ -948,7 +956,26 @@
948
956
  }]), [slot ? h("template", {
949
957
  "slot": props.slotName || 'default'
950
958
  }, [is.Function(slot) ? props.slot(h) : slot]) : null]);
959
+ };
960
+ var makeOptionGroup = function makeOptionGroup(props, index) {
961
+ return h("ElOptionGroup", {
962
+ "attrs": {
963
+ "label": props.label
964
+ },
965
+ "key": '' + index + '-' + props.label
966
+ }, [is.trueArray(props.options) && props.options.map(function (v, index) {
967
+ return makeOption(v, index);
968
+ })]);
969
+ };
970
+ var options = ctx.props.formCreateInject.options;
971
+ return h("ElSelect", helper([{}, ctx.data, {
972
+ "ref": "el"
973
+ }]), [(Array.isArray(options) ? options : []).map(function (props, index) {
974
+ return hasProperty(props || '', 'options') ? makeOptionGroup(props, index) : makeOption(props, index);
951
975
  }), ctx.children]);
976
+ },
977
+ mounted: function mounted() {
978
+ this.$emit('fc.el', this.$refs.el);
952
979
  }
953
980
  };
954
981
 
@@ -1026,6 +1053,7 @@
1026
1053
  },
1027
1054
  mounted: function mounted() {
1028
1055
  this.setValue();
1056
+ this.$emit('fc.el', this.$refs.tree);
1029
1057
  }
1030
1058
  };
1031
1059
 
@@ -1207,12 +1235,12 @@
1207
1235
  makeUpload: function makeUpload() {
1208
1236
  var h = this.$createElement;
1209
1237
  var isShow = !this.limit || this.limit > this.uploadList.length;
1210
- return h("ElUpload", helper([{}, this.formCreateInject.prop, {
1211
- "ref": "upload",
1212
- "style": {
1238
+ return h("ElUpload", helper([{}, this.formCreateInject.prop, {}, {
1239
+ style: {
1213
1240
  display: 'inline-block'
1214
1241
  },
1215
- "key": this.key('upload')
1242
+ key: this.key('upload'),
1243
+ ref: 'upload'
1216
1244
  }]), [isShow ? h("template", {
1217
1245
  "slot": "default"
1218
1246
  }, [this.$slots["default"] || h("div", {
@@ -1275,6 +1303,7 @@
1275
1303
  }, {
1276
1304
  deep: true
1277
1305
  });
1306
+ this.$emit('fc.el', this.$refs.upload);
1278
1307
  }
1279
1308
  };
1280
1309
 
@@ -1344,6 +1373,9 @@
1344
1373
  return _extends$1.apply(this, arguments);
1345
1374
  }
1346
1375
 
1376
+ var css_248z$2 = "._fc-group{\n display: flex;\n min-height: 42px;\n justify-content: center;\n flex-direction: column;\n}\n\n._fc-group-disabled ._fc-group-btn, ._fc-group-disabled ._fc-group-add{\n cursor: not-allowed;\n}\n\n._fc-group-handle {\n display: flex;\n flex-direction: row;\n position: absolute;\n bottom: -15px;\n right: 30px;\n border-radius: 15px;\n border: 1px dashed #d9d9d9;\n padding: 3px 8px;\n background-color: #ffffff;\n}\n\n._fc-group-btn{\n cursor: pointer;\n}\n\n._fc-group-idx {\n position: absolute;\n bottom: -15px;\n left: 10px;\n width: 30px;\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #eee;\n border-radius: 15px;\n font-weight: 700;\n}\n\n._fc-group-handle ._fc-group-btn + ._fc-group-btn {\n margin-left: 7px;\n}\n\n._fc-group-container{\n position: relative;\n display: flex;\n flex-direction: column;\n border: 1px dashed #d9d9d9;\n padding: 20px;\n margin: 5px;\n border-radius: 5px;\n margin-bottom: 25px;\n padding-bottom: 25px;\n}\n\n._fc-group-arrow {\n position: relative;\n width: 20px;\n height: 20px;\n}\n\n._fc-group-arrow::before {\n content: \"\";\n position: absolute;\n top: 8px;\n left: 5px;\n width: 9px;\n height: 9px;\n border-left: 2px solid #999;\n border-top: 2px solid #999;\n}\n._fc-group-arrow::before {\n transform: rotate(45deg);\n}\n\n._fc-group-arrow._fc-group-down {\n transform: rotate(180deg);\n}\n\n._fc-group-plus-minus {\n width: 20px;\n height: 20px;\n position: relative;\n cursor: pointer;\n}\n\n._fc-group-plus-minus::before,\n._fc-group-plus-minus::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n width: 60%;\n height: 2px;\n background-color: #409eff;\n transform: translate(-50%, -50%);\n}\n\n._fc-group-plus-minus::before {\n transform: translate(-50%, -50%) rotate(90deg);\n}\n\n._fc-group-plus-minus._fc-group-minus::before {\n display: none;\n}\n._fc-group-plus-minus._fc-group-minus::after {\n background-color: #f56c6c;\n}\n\n\n._fc-group-add{\n cursor: pointer;\n width: 25px;\n height: 25px;\n border: 1px solid rgb(64 158 255 / 50%);\n border-radius: 15px;\n}\n\n._fc-group-add._fc-group-plus-minus::before, ._fc-group-add._fc-group-plus-minus::after {\n width: 50%;\n}\n\n";
1377
+ styleInject(css_248z$2);
1378
+
1347
1379
  var NAME$6 = 'fcGroup';
1348
1380
  var Group = {
1349
1381
  name: NAME$6,
@@ -1375,6 +1407,10 @@
1375
1407
  return [];
1376
1408
  }
1377
1409
  },
1410
+ sortBtn: {
1411
+ type: Boolean,
1412
+ "default": true
1413
+ },
1378
1414
  defaultValue: Object,
1379
1415
  disabled: {
1380
1416
  type: Boolean,
@@ -1384,10 +1420,6 @@
1384
1420
  type: Boolean,
1385
1421
  "default": true
1386
1422
  },
1387
- fontSize: {
1388
- type: Number,
1389
- "default": 28
1390
- },
1391
1423
  onBeforeRemove: {
1392
1424
  type: Function,
1393
1425
  "default": function _default() {}
@@ -1395,13 +1427,15 @@
1395
1427
  onBeforeAdd: {
1396
1428
  type: Function,
1397
1429
  "default": function _default() {}
1398
- }
1430
+ },
1431
+ parse: Function
1399
1432
  },
1400
1433
  data: function data() {
1401
1434
  return {
1402
1435
  len: 0,
1403
1436
  cacheRule: {},
1404
1437
  cacheValue: {},
1438
+ sort: [],
1405
1439
  type: undefined
1406
1440
  };
1407
1441
  },
@@ -1417,6 +1451,12 @@
1417
1451
  }
1418
1452
  },
1419
1453
  watch: {
1454
+ cacheRule: {
1455
+ handler: function handler(n) {
1456
+ this.sort = Object.keys(n);
1457
+ },
1458
+ immediate: true
1459
+ },
1420
1460
  formRule: {
1421
1461
  handler: function handler(n, o) {
1422
1462
  var _this = this;
@@ -1455,10 +1495,10 @@
1455
1495
  this.expandRule(d);
1456
1496
  }
1457
1497
  },
1458
- value: function value(n) {
1498
+ value: function value(n, o) {
1459
1499
  var _this2 = this;
1460
1500
  n = n || [];
1461
- var keys = Object.keys(this.cacheRule),
1501
+ var keys = this.sort,
1462
1502
  total = keys.length,
1463
1503
  len = total - n.length;
1464
1504
  if (len < 0) {
@@ -1494,7 +1534,7 @@
1494
1534
  formData: function formData(key, _formData) {
1495
1535
  var _this3 = this;
1496
1536
  var cacheRule = this.cacheRule;
1497
- var keys = Object.keys(cacheRule);
1537
+ var keys = this.sort;
1498
1538
  if (keys.filter(function (k) {
1499
1539
  return cacheRule[k].$f;
1500
1540
  }).length !== keys.length) {
@@ -1518,7 +1558,7 @@
1518
1558
  return;
1519
1559
  }
1520
1560
  this.cache(key, value);
1521
- $f.coverValue(value || {});
1561
+ $f && $f.coverValue(value || {});
1522
1562
  },
1523
1563
  addRule: function addRule(i, emit) {
1524
1564
  var _this4 = this;
@@ -1532,6 +1572,11 @@
1532
1572
  var defVal = deepCopy(this.defaultValue);
1533
1573
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1534
1574
  }
1575
+ this.parse && this.parse({
1576
+ rule: rule,
1577
+ options: options,
1578
+ index: this.sort.length
1579
+ });
1535
1580
  this.$set(this.cacheRule, ++this.len, {
1536
1581
  rule: rule,
1537
1582
  options: options
@@ -1545,7 +1590,6 @@
1545
1590
  add$f: function add$f(i, key, $f) {
1546
1591
  var _this5 = this;
1547
1592
  this.cacheRule[key].$f = $f;
1548
- this.formData(key, $f.formData());
1549
1593
  this.$nextTick(function () {
1550
1594
  if (_this5.syncDisabled) {
1551
1595
  $f.disabled(_this5.disabled);
@@ -1575,15 +1619,14 @@
1575
1619
  return;
1576
1620
  }
1577
1621
  this.removeRule(key, true);
1578
- this.value.splice(index, 1);
1579
- this.input(this.value);
1622
+ var value = _toConsumableArray(this.value);
1623
+ value.splice(index, 1);
1624
+ this.input(value);
1580
1625
  },
1581
1626
  addIcon: function addIcon(key) {
1582
1627
  var h = this.$createElement;
1583
- return h("i", {
1584
- "key": "a".concat(key),
1585
- "class": "el-icon-circle-plus-outline",
1586
- "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
1628
+ return h("div", {
1629
+ "class": "_fc-group-btn _fc-group-plus-minus",
1587
1630
  "on": {
1588
1631
  "click": this.add
1589
1632
  }
@@ -1592,10 +1635,8 @@
1592
1635
  delIcon: function delIcon(index, key) {
1593
1636
  var _this7 = this;
1594
1637
  var h = this.$createElement;
1595
- return h("i", {
1596
- "key": "d".concat(key),
1597
- "class": "el-icon-remove-outline",
1598
- "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
1638
+ return h("div", {
1639
+ "class": "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
1599
1640
  "on": {
1600
1641
  "click": function click() {
1601
1642
  return _this7.del(index, key);
@@ -1603,8 +1644,38 @@
1603
1644
  }
1604
1645
  });
1605
1646
  },
1606
- makeIcon: function makeIcon(total, index, key) {
1647
+ sortUpIcon: function sortUpIcon(index) {
1607
1648
  var _this8 = this;
1649
+ var h = this.$createElement;
1650
+ return h("div", {
1651
+ "class": "_fc-group-btn _fc-group-arrow _fc-group-up",
1652
+ "on": {
1653
+ "click": function click() {
1654
+ return _this8.changeSort(index, -1);
1655
+ }
1656
+ }
1657
+ });
1658
+ },
1659
+ sortDownIcon: function sortDownIcon(index) {
1660
+ var _this9 = this;
1661
+ var h = this.$createElement;
1662
+ return h("div", {
1663
+ "class": "_fc-group-btn _fc-group-arrow _fc-group-down",
1664
+ "on": {
1665
+ "click": function click() {
1666
+ return _this9.changeSort(index, 1);
1667
+ }
1668
+ }
1669
+ });
1670
+ },
1671
+ changeSort: function changeSort(index, sort) {
1672
+ var a = this.sort[index];
1673
+ this.$set(this.sort, index, this.sort[index + sort]);
1674
+ this.sort[index + sort] = a;
1675
+ this.formData(0);
1676
+ },
1677
+ makeIcon: function makeIcon(total, index, key) {
1678
+ var _this10 = this;
1608
1679
  if (this.$scopedSlots.button) {
1609
1680
  return this.$scopedSlots.button({
1610
1681
  total: total,
@@ -1612,17 +1683,25 @@
1612
1683
  vm: this,
1613
1684
  key: key,
1614
1685
  del: function del() {
1615
- return _this8.del(index, key);
1686
+ return _this10.del(index, key);
1616
1687
  },
1617
1688
  add: this.add
1618
1689
  });
1619
1690
  }
1620
- if (index === 0) {
1621
- return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1691
+ var btn = [];
1692
+ if ((!this.max || total < this.max) && total === index + 1) {
1693
+ btn.push(this.addIcon(key));
1622
1694
  }
1623
1695
  if (total > this.min) {
1624
- return this.delIcon(index, key);
1696
+ btn.push(this.delIcon(index, key));
1697
+ }
1698
+ if (this.sortBtn && index) {
1699
+ btn.push(this.sortUpIcon(index));
1625
1700
  }
1701
+ if (this.sortBtn && index !== total - 1) {
1702
+ btn.push(this.sortDownIcon(index));
1703
+ }
1704
+ return btn;
1626
1705
  },
1627
1706
  emitEvent: function emitEvent(name, args, index, key) {
1628
1707
  this.$emit.apply(this, [name].concat(_toConsumableArray(args), [this.cacheRule[key].$f, index]));
@@ -1644,71 +1723,64 @@
1644
1723
  }
1645
1724
  },
1646
1725
  render: function render() {
1647
- var _this9 = this;
1726
+ var _this11 = this;
1648
1727
  var h = arguments[0];
1649
- var keys = Object.keys(this.cacheRule);
1728
+ var keys = this.sort;
1650
1729
  var button = this.button;
1651
1730
  var Type = this.type;
1652
- return keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1731
+ var disabled = this.disabled;
1732
+ var children = keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1653
1733
  vm: this,
1654
1734
  add: this.add
1655
- }) : h("i", {
1735
+ }) : h("div", {
1656
1736
  "key": 'a_def',
1657
- "class": "el-icon-circle-plus-outline",
1658
- "style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
1737
+ "class": "_fc-group-plus-minus _fc-group-add",
1659
1738
  "on": {
1660
1739
  "click": this.add
1661
1740
  }
1662
- }) : h("div", {
1663
- "key": 'con'
1664
- }, [keys.map(function (key, index) {
1665
- var _this9$cacheRule$key = _this9.cacheRule[key],
1666
- rule = _this9$cacheRule$key.rule,
1667
- options = _this9$cacheRule$key.options;
1668
- return h("ElRow", {
1669
- "attrs": {
1670
- "align": "middle",
1671
- "type": "flex"
1672
- },
1673
- "key": key,
1674
- "style": "border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"
1675
- }, [h("ElCol", {
1676
- "attrs": {
1677
- "span": button ? 20 : 24
1678
- }
1741
+ }) : keys.map(function (key, index) {
1742
+ var _this11$cacheRule$key = _this11.cacheRule[key],
1743
+ rule = _this11$cacheRule$key.rule,
1744
+ options = _this11$cacheRule$key.options;
1745
+ var btn = button && !disabled ? _this11.makeIcon(keys.length, index, key) : [];
1746
+ return h("div", {
1747
+ "class": "_fc-group-container",
1748
+ "key": key
1679
1749
  }, [h(Type, helper([{
1680
1750
  "key": key
1681
1751
  }, {
1682
1752
  "on": {
1683
1753
  'update:value': function updateValue(formData) {
1684
- return _this9.formData(key, formData);
1754
+ return _this11.formData(key, formData);
1685
1755
  },
1686
1756
  'emit-event': function emitEvent(name) {
1687
1757
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1688
1758
  args[_key - 1] = arguments[_key];
1689
1759
  }
1690
- return _this9.emitEvent(name, args, index, key);
1760
+ return _this11.emitEvent(name, args, index, key);
1691
1761
  },
1692
1762
  input: function input($f) {
1693
- return _this9.add$f(index, key, $f);
1763
+ return _this11.add$f(index, key, $f);
1694
1764
  }
1695
1765
  }
1696
1766
  }, {}, {
1697
1767
  "props": {
1698
- value: _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.value[index])) : _this9.value[index],
1768
+ inFor: true,
1769
+ value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
1699
1770
  rule: rule,
1700
1771
  option: options,
1701
- extendOption: true,
1702
- inFor: true
1703
- }
1704
- }]))]), button ? h("ElCol", helper([{}, {
1705
- "props": {
1706
- span: 2,
1707
- pull: 1,
1708
- push: 1
1772
+ extendOption: true
1709
1773
  }
1710
- }]), [_this9.makeIcon(keys.length, index, key)]) : null]);
1711
- })]);
1774
+ }])), h("div", {
1775
+ "class": "_fc-group-idx"
1776
+ }, [index + 1]), btn.length ? h("div", {
1777
+ "class": "_fc-group-handle"
1778
+ }, [btn]) : null]);
1779
+ });
1780
+ return h("div", {
1781
+ "key": 'con',
1782
+ "class": '_fc-group ' + (disabled ? '_fc-group-disabled' : '')
1783
+ }, [children]);
1712
1784
  }
1713
1785
  };
1714
1786
 
@@ -2614,7 +2686,7 @@
2614
2686
  },
2615
2687
  el: function el(id) {
2616
2688
  var ctx = h.getCtx(id);
2617
- if (ctx) return ctx.el || h.vm.$refs[ctx.ref];
2689
+ if (ctx) return ctx.exportEl || ctx.el || h.vm.$refs[ctx.ref];
2618
2690
  },
2619
2691
  closeModal: function closeModal(id) {
2620
2692
  var el = api.el(id);
@@ -3068,6 +3140,12 @@
3068
3140
  },
3069
3141
  'fc.sub-form': function fcSubForm(subForm) {
3070
3142
  _this8.$handle.addSubForm(ctx, subForm);
3143
+ },
3144
+ 'fc.el': function fcEl(el) {
3145
+ ctx.exportEl = el;
3146
+ if (el) {
3147
+ (el.$el || el).__rule__ = ctx.rule;
3148
+ }
3071
3149
  }
3072
3150
  }
3073
3151
  }];
@@ -3389,6 +3467,7 @@
3389
3467
  payload: {},
3390
3468
  input: !!rule.field,
3391
3469
  el: undefined,
3470
+ exportEl: undefined,
3392
3471
  defaultValue: rule.field ? deepCopy(defaultValue) : undefined,
3393
3472
  field: rule.field || undefined
3394
3473
  });
@@ -3511,7 +3590,8 @@
3511
3590
  vm: handle.vm,
3512
3591
  trueType: handle.getType(this.originType),
3513
3592
  vNode: handle.$render.vNode,
3514
- updated: false
3593
+ updated: false,
3594
+ cacheValue: this.rule.value
3515
3595
  });
3516
3596
  !init && this.unwatch();
3517
3597
  this.watchTo();
@@ -3754,6 +3834,7 @@
3754
3834
  ctx.root = rules;
3755
3835
  _this6.setCtx(ctx);
3756
3836
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3837
+ _this6.effect(ctx, 'created');
3757
3838
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3758
3839
  if (!parent) {
3759
3840
  var _preIndex = preIndex(index);
@@ -4439,6 +4520,7 @@
4439
4520
  data.mergeProp = function (prop) {
4440
4521
  return mergeRule(data.getProp(), [prop]);
4441
4522
  };
4523
+ data.id = ctx.id;
4442
4524
  }
4443
4525
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4444
4526
  });
@@ -4452,9 +4534,12 @@
4452
4534
  }
4453
4535
  function getComponent(p) {
4454
4536
  var c = p.components;
4455
- if (Array.isArray(c)) return unique(c.filter(function (v) {
4456
- return v !== '*';
4457
- }));else if (is.String(c)) return [c];else return false;
4537
+ if (Array.isArray(c)) {
4538
+ var arr = unique(c.filter(function (v) {
4539
+ return v !== '*';
4540
+ }));
4541
+ return arr.length ? arr : false;
4542
+ } else if (is.String(c)) return [c];else return false;
4458
4543
  }
4459
4544
 
4460
4545
  function Handler(fc) {
@@ -4707,6 +4792,52 @@
4707
4792
  render: function render(children) {}
4708
4793
  });
4709
4794
 
4795
+ var loadData = function loadData(fc) {
4796
+ var loadData = {
4797
+ name: 'loadData',
4798
+ _fn: [],
4799
+ created: function created(inject, rule, api) {
4800
+ this.deleted(inject);
4801
+ var attrs = toArray(inject.getValue());
4802
+ var events = [];
4803
+ attrs.forEach(function (attr) {
4804
+ if (attr) {
4805
+ var on = function on() {
4806
+ if (attr.watch !== false) {
4807
+ fc.bus.$off('p.loadData.' + attr.attr, on);
4808
+ fc.bus.$once('p.loadData.' + attr.attr, on);
4809
+ }
4810
+ var value = undefined;
4811
+ if (attr.attr) {
4812
+ value = fc.loadData[attr.attr] || attr["default"];
4813
+ if (attr.copy) {
4814
+ value = deepCopy(value);
4815
+ }
4816
+ }
4817
+ deepSet(inject.getProp(), attr.to || 'options', value);
4818
+ api.sync(rule);
4819
+ };
4820
+ events.push(function () {
4821
+ return fc.bus.$off('p.loadData.' + attr.attr, on);
4822
+ });
4823
+ on();
4824
+ }
4825
+ });
4826
+ this._fn[inject.id] = events;
4827
+ },
4828
+ deleted: function deleted(inject) {
4829
+ if (this._fn[inject.id]) {
4830
+ this._fn[inject.id].forEach(function (un) {
4831
+ un();
4832
+ });
4833
+ delete this._fn[inject.id];
4834
+ }
4835
+ inject.clearProp();
4836
+ }
4837
+ };
4838
+ loadData.watch = loadData.created;
4839
+ return loadData;
4840
+ };
4710
4841
  var componentValidate = {
4711
4842
  name: 'componentValidate',
4712
4843
  load: function load(attr, rule, api) {
@@ -4748,12 +4879,21 @@
4748
4879
  }
4749
4880
  function run(inject, rule, api) {
4750
4881
  var option = inject.value;
4882
+ var set = function set(val) {
4883
+ if (val === undefined) {
4884
+ inject.clearProp();
4885
+ api.sync(rule);
4886
+ } else {
4887
+ deepSet(inject.getProp(), option.to || 'options', val);
4888
+ }
4889
+ };
4751
4890
  if (is.Function(option)) {
4752
4891
  option = option(rule, api);
4753
4892
  }
4754
4893
  option = parseOpt(option);
4755
4894
  if (!option || !option.action) {
4756
- return false;
4895
+ set(undefined);
4896
+ return;
4757
4897
  }
4758
4898
  if (!option.to) {
4759
4899
  option.to = 'options';
@@ -4766,52 +4906,66 @@
4766
4906
  return true;
4767
4907
  }
4768
4908
  };
4769
- var set = function set(val) {
4770
- if (val === undefined) {
4771
- inject.clearProp();
4909
+ var config = _objectSpread2(_objectSpread2({
4910
+ headers: {}
4911
+ }, option), {}, {
4912
+ onSuccess: function onSuccess(body, flag) {
4913
+ if (check()) return;
4914
+ var fn = function fn(v) {
4915
+ return flag ? v : v.data;
4916
+ };
4917
+ if (is.Function(option.parse)) {
4918
+ fn = option.parse;
4919
+ } else if (option.parse && is.String(option.parse)) {
4920
+ fn = function fn(v) {
4921
+ option.parse.split('.').forEach(function (k) {
4922
+ if (v) {
4923
+ v = v[k];
4924
+ }
4925
+ });
4926
+ return v;
4927
+ };
4928
+ }
4929
+ set(fn(body, rule, api));
4772
4930
  api.sync(rule);
4773
- } else {
4774
- deepSet(inject.getProp(), option.to, val);
4931
+ },
4932
+ onError: function onError(e) {
4933
+ set(undefined);
4934
+ if (check()) return;
4935
+ (_onError || function (e) {
4936
+ return err(e.message || 'fetch fail ' + option.action);
4937
+ })(e, rule, api);
4775
4938
  }
4776
- };
4939
+ });
4940
+ fc.options.beforeFetch && invoke(function () {
4941
+ return fc.options.beforeFetch(config, {
4942
+ rule: rule,
4943
+ api: api
4944
+ });
4945
+ });
4946
+ if (is.Function(option.action)) {
4947
+ option.action(rule, api).then(function (val) {
4948
+ config.onSuccess(val, true);
4949
+ })["catch"](function (e) {
4950
+ config.onError(e);
4951
+ });
4952
+ return;
4953
+ }
4777
4954
  invoke(function () {
4778
- return fc.create.fetch(_objectSpread2(_objectSpread2({}, option), {}, {
4779
- onSuccess: function onSuccess(body) {
4780
- if (check()) return;
4781
- var fn = function fn(v) {
4782
- return v.data;
4783
- };
4784
- if (is.Function(option.parse)) {
4785
- fn = option.parse;
4786
- }
4787
- set(fn(body, rule, api));
4788
- api.sync(rule);
4789
- },
4790
- onError: function onError(e) {
4791
- set(undefined);
4792
- if (check()) return;
4793
- (_onError || function (e) {
4794
- return err(e.message || 'fetch fail ' + option.action);
4795
- })(e, rule, api);
4796
- }
4797
- }), {
4955
+ return fc.create.fetch(config, {
4798
4956
  inject: inject,
4799
4957
  rule: rule,
4800
4958
  api: api
4801
4959
  });
4802
4960
  });
4803
- return true;
4804
4961
  }
4805
4962
  return {
4806
4963
  name: 'fetch',
4807
4964
  loaded: function loaded() {
4808
4965
  run.apply(void 0, arguments);
4809
4966
  },
4810
- watch: function watch(inject, rule, api) {
4811
- if (!run(inject, rule, api)) {
4812
- inject.clearProp();
4813
- api.sync(rule);
4814
- }
4967
+ watch: function watch() {
4968
+ run.apply(void 0, arguments);
4815
4969
  }
4816
4970
  };
4817
4971
  };
@@ -4865,6 +5019,7 @@
4865
5019
  }
4866
5020
  var $provider = {
4867
5021
  fetch: fetch$1,
5022
+ loadData: loadData,
4868
5023
  required: $required,
4869
5024
  componentValidate: componentValidate
4870
5025
  };
@@ -4947,13 +5102,18 @@
4947
5102
  var globalConfig = {
4948
5103
  global: {}
4949
5104
  };
4950
- var data = {};
5105
+ var loadData = {};
4951
5106
  var CreateNode = CreateNodeFactory();
4952
5107
  exportAttrs(config.attrs || {});
4953
5108
  function getApi(name) {
4954
5109
  var val = instance[name];
4955
- if (Array.isArray(val)) return _toConsumableArray(val);
4956
- return val;
5110
+ if (Array.isArray(val)) {
5111
+ return val.map(function (v) {
5112
+ return v.api();
5113
+ });
5114
+ } else if (val) {
5115
+ return val.api();
5116
+ }
4957
5117
  }
4958
5118
  function directive() {
4959
5119
  var data = nameProp.apply(void 0, arguments);
@@ -4995,6 +5155,22 @@
4995
5155
  components[name] = component;
4996
5156
  if (component.formCreateParser) parser(name, component.formCreateParser);
4997
5157
  }
5158
+ function _emitData(id) {
5159
+ Object.keys(instance).forEach(function (v) {
5160
+ var apis = Array.isArray(instance[v]) ? instance[v] : [instance[v]];
5161
+ apis.forEach(function (that) {
5162
+ that.bus.$emit('p.loadData.' + id);
5163
+ });
5164
+ });
5165
+ }
5166
+ function setData(id, data) {
5167
+ loadData[id] = data;
5168
+ _emitData(id);
5169
+ }
5170
+ function removeData(id) {
5171
+ delete loadData[id];
5172
+ _emitData(id);
5173
+ }
4998
5174
  function $form() {
4999
5175
  return _vue.extend($FormCreate(FormCreate));
5000
5176
  }
@@ -5021,7 +5197,7 @@
5021
5197
  directives: directives,
5022
5198
  providers: providers,
5023
5199
  maker: maker,
5024
- data: data
5200
+ loadData: loadData
5025
5201
  };
5026
5202
  } else {
5027
5203
  delete _config.inherit;
@@ -5037,12 +5213,13 @@
5037
5213
  parsers: parsers,
5038
5214
  providers: providers,
5039
5215
  rules: Array.isArray(rules) ? rules : [],
5040
- name: vm.$options.propsData.name,
5216
+ name: vm.$options.propsData.name || uniqueId(),
5041
5217
  inFor: vm.$options.propsData.inFor,
5042
5218
  prop: {
5043
5219
  components: components,
5044
5220
  directives: directives
5045
5221
  },
5222
+ loadData: loadData,
5046
5223
  CreateNode: CreateNode,
5047
5224
  bus: new _vue(),
5048
5225
  unwatch: null,
@@ -5056,9 +5233,9 @@
5056
5233
  if (this.name) {
5057
5234
  if (this.inFor) {
5058
5235
  if (!instance[this.name]) instance[this.name] = [];
5059
- instance[this.name].push(this.api());
5236
+ instance[this.name].push(this);
5060
5237
  } else {
5061
- instance[this.name] = this.api();
5238
+ instance[this.name] = this;
5062
5239
  }
5063
5240
  }
5064
5241
  }
@@ -5093,8 +5270,11 @@
5093
5270
  h.reloadRule([]);
5094
5271
  if (_this2.name) {
5095
5272
  if (_this2.inFor) {
5096
- var idx = instance[_this2.name].indexOf(_this2.api());
5273
+ var idx = instance[_this2.name].indexOf(_this2);
5097
5274
  instance[_this2.name].splice(idx, 1);
5275
+ if (!instance[_this2.name].length) {
5276
+ delete instance[_this2.name];
5277
+ }
5098
5278
  } else {
5099
5279
  delete instance[_this2.name];
5100
5280
  }
@@ -5154,7 +5334,8 @@
5154
5334
  extend(formCreate, {
5155
5335
  version: config.version,
5156
5336
  ui: config.ui,
5157
- data: data,
5337
+ setData: setData,
5338
+ removeData: removeData,
5158
5339
  maker: maker,
5159
5340
  component: component,
5160
5341
  directive: directive,
@@ -5227,7 +5408,7 @@
5227
5408
  inherit.directives && extend(directives, inherit.directives);
5228
5409
  inherit.providers && extend(providers, inherit.providers);
5229
5410
  inherit.maker && extend(maker, inherit.maker);
5230
- inherit.data && extend(data, inherit.data);
5411
+ inherit.loadData && extend(loadData, inherit.loadData);
5231
5412
  }
5232
5413
  return create;
5233
5414
  }
@@ -5775,8 +5956,8 @@
5775
5956
  return maker;
5776
5957
  }
5777
5958
 
5778
- var css_248z$2 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n";
5779
- styleInject(css_248z$2);
5959
+ var css_248z$3 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n";
5960
+ styleInject(css_248z$3);
5780
5961
 
5781
5962
  function tidyBtnProp(btn, def) {
5782
5963
  if (is.Boolean(btn)) btn = {
@@ -5788,6 +5969,14 @@
5788
5969
  }
5789
5970
  function extendApi(api, h) {
5790
5971
  extend(api, {
5972
+ formEl: function formEl() {
5973
+ return h.$manager.form();
5974
+ },
5975
+ wrapEl: function wrapEl(id) {
5976
+ var ctx = h.getFieldCtx(id);
5977
+ if (!ctx) return;
5978
+ return h.vm.$refs[ctx.wrapRef];
5979
+ },
5791
5980
  validate: function validate(callback) {
5792
5981
  return new Promise(function (resolve, reject) {
5793
5982
  var forms = api.children;
@@ -5950,7 +6139,7 @@
5950
6139
  function elmFormCreate() {
5951
6140
  return FormCreateFactory({
5952
6141
  ui: "".concat("element-ui"),
5953
- version: "".concat("2.5.31"),
6142
+ version: "".concat("2.5.33"),
5954
6143
  manager: manager,
5955
6144
  extendApi: extendApi,
5956
6145
  install: install,