@form-create/element-ui 2.5.30 → 2.5.32

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.30
2
+ * @form-create/element-ui v2.5.32
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
 
@@ -939,7 +948,9 @@
939
948
  },
940
949
  render: function render(h, ctx) {
941
950
  var options = ctx.props.formCreateInject.options;
942
- return h("ElSelect", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
951
+ return h("ElSelect", helper([{}, ctx.data, {
952
+ "ref": "el"
953
+ }]), [(Array.isArray(options) ? options : []).map(function (props, index) {
943
954
  var slot = props.slot;
944
955
  return h("ElOption", helper([{}, {
945
956
  "props": props
@@ -949,6 +960,9 @@
949
960
  "slot": props.slotName || 'default'
950
961
  }, [is.Function(slot) ? props.slot(h) : slot]) : null]);
951
962
  }), ctx.children]);
963
+ },
964
+ mounted: function mounted() {
965
+ this.$emit('fc.el', this.$refs.el);
952
966
  }
953
967
  };
954
968
 
@@ -1026,6 +1040,7 @@
1026
1040
  },
1027
1041
  mounted: function mounted() {
1028
1042
  this.setValue();
1043
+ this.$emit('fc.el', this.$refs.tree);
1029
1044
  }
1030
1045
  };
1031
1046
 
@@ -1207,12 +1222,12 @@
1207
1222
  makeUpload: function makeUpload() {
1208
1223
  var h = this.$createElement;
1209
1224
  var isShow = !this.limit || this.limit > this.uploadList.length;
1210
- return h("ElUpload", helper([{}, this.formCreateInject.prop, {
1211
- "ref": "upload",
1212
- "style": {
1225
+ return h("ElUpload", helper([{}, this.formCreateInject.prop, {}, {
1226
+ style: {
1213
1227
  display: 'inline-block'
1214
1228
  },
1215
- "key": this.key('upload')
1229
+ key: this.key('upload'),
1230
+ ref: 'upload'
1216
1231
  }]), [isShow ? h("template", {
1217
1232
  "slot": "default"
1218
1233
  }, [this.$slots["default"] || h("div", {
@@ -1275,6 +1290,7 @@
1275
1290
  }, {
1276
1291
  deep: true
1277
1292
  });
1293
+ this.$emit('fc.el', this.$refs.upload);
1278
1294
  }
1279
1295
  };
1280
1296
 
@@ -1344,6 +1360,9 @@
1344
1360
  return _extends$1.apply(this, arguments);
1345
1361
  }
1346
1362
 
1363
+ 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";
1364
+ styleInject(css_248z$2);
1365
+
1347
1366
  var NAME$6 = 'fcGroup';
1348
1367
  var Group = {
1349
1368
  name: NAME$6,
@@ -1375,6 +1394,10 @@
1375
1394
  return [];
1376
1395
  }
1377
1396
  },
1397
+ sortBtn: {
1398
+ type: Boolean,
1399
+ "default": true
1400
+ },
1378
1401
  defaultValue: Object,
1379
1402
  disabled: {
1380
1403
  type: Boolean,
@@ -1384,10 +1407,6 @@
1384
1407
  type: Boolean,
1385
1408
  "default": true
1386
1409
  },
1387
- fontSize: {
1388
- type: Number,
1389
- "default": 28
1390
- },
1391
1410
  onBeforeRemove: {
1392
1411
  type: Function,
1393
1412
  "default": function _default() {}
@@ -1395,13 +1414,15 @@
1395
1414
  onBeforeAdd: {
1396
1415
  type: Function,
1397
1416
  "default": function _default() {}
1398
- }
1417
+ },
1418
+ parse: Function
1399
1419
  },
1400
1420
  data: function data() {
1401
1421
  return {
1402
1422
  len: 0,
1403
1423
  cacheRule: {},
1404
1424
  cacheValue: {},
1425
+ sort: [],
1405
1426
  type: undefined
1406
1427
  };
1407
1428
  },
@@ -1417,6 +1438,12 @@
1417
1438
  }
1418
1439
  },
1419
1440
  watch: {
1441
+ cacheRule: {
1442
+ handler: function handler(n) {
1443
+ this.sort = Object.keys(n);
1444
+ },
1445
+ immediate: true
1446
+ },
1420
1447
  formRule: {
1421
1448
  handler: function handler(n, o) {
1422
1449
  var _this = this;
@@ -1455,10 +1482,10 @@
1455
1482
  this.expandRule(d);
1456
1483
  }
1457
1484
  },
1458
- value: function value(n) {
1485
+ value: function value(n, o) {
1459
1486
  var _this2 = this;
1460
1487
  n = n || [];
1461
- var keys = Object.keys(this.cacheRule),
1488
+ var keys = this.sort,
1462
1489
  total = keys.length,
1463
1490
  len = total - n.length;
1464
1491
  if (len < 0) {
@@ -1477,6 +1504,9 @@
1477
1504
  n.forEach(function (val, i) {
1478
1505
  _this2.setValue(keys[i], n[i]);
1479
1506
  });
1507
+ if (o.length && !n.length) {
1508
+ this.input([]);
1509
+ }
1480
1510
  }
1481
1511
  }
1482
1512
  },
@@ -1494,7 +1524,7 @@
1494
1524
  formData: function formData(key, _formData) {
1495
1525
  var _this3 = this;
1496
1526
  var cacheRule = this.cacheRule;
1497
- var keys = Object.keys(cacheRule);
1527
+ var keys = this.sort;
1498
1528
  if (keys.filter(function (k) {
1499
1529
  return cacheRule[k].$f;
1500
1530
  }).length !== keys.length) {
@@ -1532,6 +1562,11 @@
1532
1562
  var defVal = deepCopy(this.defaultValue);
1533
1563
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1534
1564
  }
1565
+ this.parse && this.parse({
1566
+ rule: rule,
1567
+ options: options,
1568
+ index: this.sort.length
1569
+ });
1535
1570
  this.$set(this.cacheRule, ++this.len, {
1536
1571
  rule: rule,
1537
1572
  options: options
@@ -1545,7 +1580,6 @@
1545
1580
  add$f: function add$f(i, key, $f) {
1546
1581
  var _this5 = this;
1547
1582
  this.cacheRule[key].$f = $f;
1548
- this.formData(key, $f.formData());
1549
1583
  this.$nextTick(function () {
1550
1584
  if (_this5.syncDisabled) {
1551
1585
  $f.disabled(_this5.disabled);
@@ -1575,15 +1609,14 @@
1575
1609
  return;
1576
1610
  }
1577
1611
  this.removeRule(key, true);
1578
- this.value.splice(index, 1);
1579
- this.input(this.value);
1612
+ var value = _toConsumableArray(this.value);
1613
+ value.splice(index, 1);
1614
+ this.input(value);
1580
1615
  },
1581
1616
  addIcon: function addIcon(key) {
1582
1617
  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', ";"),
1618
+ return h("div", {
1619
+ "class": "_fc-group-btn _fc-group-plus-minus",
1587
1620
  "on": {
1588
1621
  "click": this.add
1589
1622
  }
@@ -1592,10 +1625,8 @@
1592
1625
  delIcon: function delIcon(index, key) {
1593
1626
  var _this7 = this;
1594
1627
  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', ";"),
1628
+ return h("div", {
1629
+ "class": "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
1599
1630
  "on": {
1600
1631
  "click": function click() {
1601
1632
  return _this7.del(index, key);
@@ -1603,8 +1634,38 @@
1603
1634
  }
1604
1635
  });
1605
1636
  },
1606
- makeIcon: function makeIcon(total, index, key) {
1637
+ sortUpIcon: function sortUpIcon(index) {
1607
1638
  var _this8 = this;
1639
+ var h = this.$createElement;
1640
+ return h("div", {
1641
+ "class": "_fc-group-btn _fc-group-arrow _fc-group-up",
1642
+ "on": {
1643
+ "click": function click() {
1644
+ return _this8.changeSort(index, -1);
1645
+ }
1646
+ }
1647
+ });
1648
+ },
1649
+ sortDownIcon: function sortDownIcon(index) {
1650
+ var _this9 = this;
1651
+ var h = this.$createElement;
1652
+ return h("div", {
1653
+ "class": "_fc-group-btn _fc-group-arrow _fc-group-down",
1654
+ "on": {
1655
+ "click": function click() {
1656
+ return _this9.changeSort(index, 1);
1657
+ }
1658
+ }
1659
+ });
1660
+ },
1661
+ changeSort: function changeSort(index, sort) {
1662
+ var a = this.sort[index];
1663
+ this.$set(this.sort, index, this.sort[index + sort]);
1664
+ this.sort[index + sort] = a;
1665
+ this.formData(0);
1666
+ },
1667
+ makeIcon: function makeIcon(total, index, key) {
1668
+ var _this10 = this;
1608
1669
  if (this.$scopedSlots.button) {
1609
1670
  return this.$scopedSlots.button({
1610
1671
  total: total,
@@ -1612,17 +1673,25 @@
1612
1673
  vm: this,
1613
1674
  key: key,
1614
1675
  del: function del() {
1615
- return _this8.del(index, key);
1676
+ return _this10.del(index, key);
1616
1677
  },
1617
1678
  add: this.add
1618
1679
  });
1619
1680
  }
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];
1681
+ var btn = [];
1682
+ if ((!this.max || total < this.max) && total === index + 1) {
1683
+ btn.push(this.addIcon(key));
1622
1684
  }
1623
1685
  if (total > this.min) {
1624
- return this.delIcon(index, key);
1686
+ btn.push(this.delIcon(index, key));
1687
+ }
1688
+ if (this.sortBtn && index) {
1689
+ btn.push(this.sortUpIcon(index));
1690
+ }
1691
+ if (this.sortBtn && index !== total - 1) {
1692
+ btn.push(this.sortDownIcon(index));
1625
1693
  }
1694
+ return btn;
1626
1695
  },
1627
1696
  emitEvent: function emitEvent(name, args, index, key) {
1628
1697
  this.$emit.apply(this, [name].concat(_toConsumableArray(args), [this.cacheRule[key].$f, index]));
@@ -1644,71 +1713,64 @@
1644
1713
  }
1645
1714
  },
1646
1715
  render: function render() {
1647
- var _this9 = this;
1716
+ var _this11 = this;
1648
1717
  var h = arguments[0];
1649
- var keys = Object.keys(this.cacheRule);
1718
+ var keys = this.sort;
1650
1719
  var button = this.button;
1651
1720
  var Type = this.type;
1652
- return keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1721
+ var disabled = this.disabled;
1722
+ var children = keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1653
1723
  vm: this,
1654
1724
  add: this.add
1655
- }) : h("i", {
1725
+ }) : h("div", {
1656
1726
  "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', ";"),
1727
+ "class": "_fc-group-plus-minus _fc-group-add",
1659
1728
  "on": {
1660
1729
  "click": this.add
1661
1730
  }
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
- }
1731
+ }) : keys.map(function (key, index) {
1732
+ var _this11$cacheRule$key = _this11.cacheRule[key],
1733
+ rule = _this11$cacheRule$key.rule,
1734
+ options = _this11$cacheRule$key.options;
1735
+ var btn = button && !disabled ? _this11.makeIcon(keys.length, index, key) : [];
1736
+ return h("div", {
1737
+ "class": "_fc-group-container",
1738
+ "key": key
1679
1739
  }, [h(Type, helper([{
1680
1740
  "key": key
1681
1741
  }, {
1682
1742
  "on": {
1683
1743
  'update:value': function updateValue(formData) {
1684
- return _this9.formData(key, formData);
1744
+ return _this11.formData(key, formData);
1685
1745
  },
1686
1746
  'emit-event': function emitEvent(name) {
1687
1747
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1688
1748
  args[_key - 1] = arguments[_key];
1689
1749
  }
1690
- return _this9.emitEvent(name, args, index, key);
1750
+ return _this11.emitEvent(name, args, index, key);
1691
1751
  },
1692
1752
  input: function input($f) {
1693
- return _this9.add$f(index, key, $f);
1753
+ return _this11.add$f(index, key, $f);
1694
1754
  }
1695
1755
  }
1696
1756
  }, {}, {
1697
1757
  "props": {
1698
- value: _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.value[index])) : _this9.value[index],
1758
+ inFor: true,
1759
+ value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
1699
1760
  rule: rule,
1700
1761
  option: options,
1701
- extendOption: true,
1702
- inFor: true
1762
+ extendOption: true
1703
1763
  }
1704
- }]))]), button ? h("ElCol", helper([{}, {
1705
- "props": {
1706
- span: 2,
1707
- pull: 1,
1708
- push: 1
1709
- }
1710
- }]), [_this9.makeIcon(keys.length, index, key)]) : null]);
1711
- })]);
1764
+ }])), h("div", {
1765
+ "class": "_fc-group-idx"
1766
+ }, [index + 1]), btn.length ? h("div", {
1767
+ "class": "_fc-group-handle"
1768
+ }, [btn]) : null]);
1769
+ });
1770
+ return h("div", {
1771
+ "key": 'con',
1772
+ "class": '_fc-group ' + (disabled ? '_fc-group-disabled' : '')
1773
+ }, [children]);
1712
1774
  }
1713
1775
  };
1714
1776
 
@@ -2083,7 +2145,7 @@
2083
2145
  }, space);
2084
2146
  }
2085
2147
  function makeFn(fn) {
2086
- return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2148
+ return new Function('return ' + fn)();
2087
2149
  }
2088
2150
  function parseFn(fn, mode) {
2089
2151
  if (fn && is.String(fn) && fn.length > 4) {
@@ -2614,7 +2676,7 @@
2614
2676
  },
2615
2677
  el: function el(id) {
2616
2678
  var ctx = h.getCtx(id);
2617
- if (ctx) return ctx.el || h.vm.$refs[ctx.ref];
2679
+ if (ctx) return ctx.exportEl || ctx.el || h.vm.$refs[ctx.ref];
2618
2680
  },
2619
2681
  closeModal: function closeModal(id) {
2620
2682
  var el = api.el(id);
@@ -3068,6 +3130,12 @@
3068
3130
  },
3069
3131
  'fc.sub-form': function fcSubForm(subForm) {
3070
3132
  _this8.$handle.addSubForm(ctx, subForm);
3133
+ },
3134
+ 'fc.el': function fcEl(el) {
3135
+ ctx.exportEl = el;
3136
+ if (el) {
3137
+ (el.$el || el).__rule__ = ctx.rule;
3138
+ }
3071
3139
  }
3072
3140
  }
3073
3141
  }];
@@ -3389,6 +3457,7 @@
3389
3457
  payload: {},
3390
3458
  input: !!rule.field,
3391
3459
  el: undefined,
3460
+ exportEl: undefined,
3392
3461
  defaultValue: rule.field ? deepCopy(defaultValue) : undefined,
3393
3462
  field: rule.field || undefined
3394
3463
  });
@@ -4783,6 +4852,15 @@
4783
4852
  };
4784
4853
  if (is.Function(option.parse)) {
4785
4854
  fn = option.parse;
4855
+ } else if (option.parse && is.String(option.parse)) {
4856
+ fn = function fn(v) {
4857
+ option.parse.split('.').forEach(function (k) {
4858
+ if (v) {
4859
+ v = v[k];
4860
+ }
4861
+ });
4862
+ return v;
4863
+ };
4786
4864
  }
4787
4865
  set(fn(body, rule, api));
4788
4866
  api.sync(rule);
@@ -5775,8 +5853,8 @@
5775
5853
  return maker;
5776
5854
  }
5777
5855
 
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);
5856
+ 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";
5857
+ styleInject(css_248z$3);
5780
5858
 
5781
5859
  function tidyBtnProp(btn, def) {
5782
5860
  if (is.Boolean(btn)) btn = {
@@ -5788,6 +5866,14 @@
5788
5866
  }
5789
5867
  function extendApi(api, h) {
5790
5868
  extend(api, {
5869
+ formEl: function formEl() {
5870
+ return h.$manager.form();
5871
+ },
5872
+ wrapEl: function wrapEl(id) {
5873
+ var ctx = h.getFieldCtx(id);
5874
+ if (!ctx) return;
5875
+ return h.vm.$refs[ctx.wrapRef];
5876
+ },
5791
5877
  validate: function validate(callback) {
5792
5878
  return new Promise(function (resolve, reject) {
5793
5879
  var forms = api.children;
@@ -5950,7 +6036,7 @@
5950
6036
  function elmFormCreate() {
5951
6037
  return FormCreateFactory({
5952
6038
  ui: "".concat("element-ui"),
5953
- version: "".concat("2.5.30"),
6039
+ version: "".concat("2.5.32"),
5954
6040
  manager: manager,
5955
6041
  extendApi: extendApi,
5956
6042
  install: install,