@form-create/iview 2.5.19 → 2.5.20

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/iview v2.5.19
2
+ * @form-create/iview v2.5.20
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -19,11 +19,9 @@
19
19
  Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]);
20
20
  }
21
21
  }
22
-
23
22
  return a;
24
23
  }, _extends.apply(this, arguments);
25
24
  }
26
-
27
25
  var normalMerge = ["attrs", "props", "domProps"],
28
26
  toArrayMerge = ["class", "style", "directives"],
29
27
  functionalMerge = ["on", "nativeOn"],
@@ -46,7 +44,6 @@
46
44
  c[b][i] = c[b][i] ? mergeFn(c[b][i], a[b][i]) : a[b][i];
47
45
  } else c[b] = a[b];
48
46
  }
49
-
50
47
  return c;
51
48
  }, {});
52
49
  },
@@ -55,7 +52,6 @@
55
52
  a && a.apply(this, arguments), b && b.apply(this, arguments);
56
53
  };
57
54
  };
58
-
59
55
  var helper = mergeJsxProps;
60
56
 
61
57
  function _typeof(obj) {
@@ -246,7 +242,6 @@
246
242
  if (!exclude || exclude.indexOf(name) === -1) {
247
243
  lst.push(slots[name]);
248
244
  }
249
-
250
245
  return lst;
251
246
  }, []);
252
247
  }
@@ -298,7 +293,6 @@
298
293
  },
299
294
  update: function update() {
300
295
  var _this = this;
301
-
302
296
  this.trueValue = this.value ? this.options().filter(function (opt) {
303
297
  return _this.value.indexOf(opt.value) !== -1;
304
298
  }).map(function (option) {
@@ -320,7 +314,6 @@
320
314
  }
321
315
  }]), [this.options().map(function (opt, index) {
322
316
  var props = _objectSpread2({}, opt);
323
-
324
317
  delete props.value;
325
318
  return h("Checkbox", {
326
319
  "props": _objectSpread2({}, props),
@@ -337,15 +330,12 @@
337
330
  function styleInject(css, ref) {
338
331
  if (ref === void 0) ref = {};
339
332
  var insertAt = ref.insertAt;
340
-
341
333
  if (!css || typeof document === 'undefined') {
342
334
  return;
343
335
  }
344
-
345
336
  var head = document.head || document.getElementsByTagName('head')[0];
346
337
  var style = document.createElement('style');
347
338
  style.type = 'text/css';
348
-
349
339
  if (insertAt === 'top') {
350
340
  if (head.firstChild) {
351
341
  head.insertBefore(style, head.firstChild);
@@ -355,7 +345,6 @@
355
345
  } else {
356
346
  head.appendChild(style);
357
347
  }
358
-
359
348
  if (style.styleSheet) {
360
349
  style.styleSheet.cssText = css;
361
350
  } else {
@@ -512,12 +501,10 @@
512
501
  },
513
502
  closeModel: function closeModel(close) {
514
503
  this.$emit(close ? '$close' : '$ok');
515
-
516
504
  if (this.reload) {
517
505
  this.$off('$ok');
518
506
  this.$off('$close');
519
507
  }
520
-
521
508
  this.frameVisible = false;
522
509
  },
523
510
  showModel: function showModel() {
@@ -526,7 +513,6 @@
526
513
  },
527
514
  makeInput: function makeInput() {
528
515
  var _this = this;
529
-
530
516
  var h = this.$createElement;
531
517
  var props = {
532
518
  type: 'text',
@@ -569,7 +555,6 @@
569
555
  },
570
556
  makeIcons: function makeIcons(val, index) {
571
557
  var h = this.$createElement;
572
-
573
558
  if (this.handleIcon !== false || this.allowRemove === true) {
574
559
  var icons = [];
575
560
  if (this.type !== 'file' && this.handleIcon !== false || this.type === 'file' && this.handleIcon) icons.push(this.makeHandleIcon(val, index));
@@ -582,7 +567,6 @@
582
567
  },
583
568
  makeHandleIcon: function makeHandleIcon(val, index) {
584
569
  var _this2 = this;
585
-
586
570
  var h = this.$createElement;
587
571
  return h("icon", helper([{}, {
588
572
  "props": {
@@ -599,7 +583,6 @@
599
583
  },
600
584
  makeRemoveIcon: function makeRemoveIcon(val, index) {
601
585
  var _this3 = this;
602
-
603
586
  var h = this.$createElement;
604
587
  return h("icon", helper([{}, {
605
588
  "props": {
@@ -616,7 +599,6 @@
616
599
  },
617
600
  makeFiles: function makeFiles() {
618
601
  var _this4 = this;
619
-
620
602
  var h = this.$createElement;
621
603
  return this.makeGroup(this.fileList.map(function (src, index) {
622
604
  return _this4.makeItem(index, [h("icon", helper([{}, {
@@ -635,7 +617,6 @@
635
617
  },
636
618
  makeImages: function makeImages() {
637
619
  var _this5 = this;
638
-
639
620
  var h = this.$createElement;
640
621
  return this.makeGroup(this.fileList.map(function (src, index) {
641
622
  return _this5.makeItem(index, [h("img", {
@@ -647,7 +628,6 @@
647
628
  },
648
629
  makeBtn: function makeBtn() {
649
630
  var _this6 = this;
650
-
651
631
  var h = this.$createElement;
652
632
  return h("div", {
653
633
  "class": 'fc-upload-btn',
@@ -669,7 +649,6 @@
669
649
  },
670
650
  handleRemove: function handleRemove(src) {
671
651
  if (this.disabled) return;
672
-
673
652
  if (false !== this.onBeforeRemove(src)) {
674
653
  this.fileList.splice(this.fileList.indexOf(src), 1);
675
654
  this.onRemove(src);
@@ -680,26 +659,21 @@
680
659
  },
681
660
  frameLoad: function frameLoad(iframe) {
682
661
  var _this7 = this;
683
-
684
662
  this.onLoad(iframe);
685
-
686
663
  try {
687
664
  if (this.helper === true) {
688
665
  iframe['form_create_helper'] = {
689
666
  api: this.formCreateInject.api,
690
667
  close: function close(field) {
691
668
  _this7.valid(field);
692
-
693
669
  _this7.closeModel();
694
670
  },
695
671
  set: function set(field, value) {
696
672
  _this7.valid(field);
697
-
698
673
  if (!_this7.disabled) _this7.$emit('input', value);
699
674
  },
700
675
  get: function get(field) {
701
676
  _this7.valid(field);
702
-
703
677
  return _this7.value;
704
678
  },
705
679
  onOk: function onOk(fn) {
@@ -716,7 +690,6 @@
716
690
  },
717
691
  makeFooter: function makeFooter() {
718
692
  var _this8 = this;
719
-
720
693
  var h = this.$createElement;
721
694
  var _this$$props = this.$props,
722
695
  okBtnText = _this$$props.okBtnText,
@@ -748,7 +721,6 @@
748
721
  },
749
722
  render: function render() {
750
723
  var _this9 = this;
751
-
752
724
  var h = arguments[0];
753
725
  var type = this.type;
754
726
  var node;
@@ -868,7 +840,6 @@
868
840
  },
869
841
  update: function update() {
870
842
  var _this = this;
871
-
872
843
  this.trueValue = this.options().filter(function (opt) {
873
844
  return opt.value === _this.value;
874
845
  }).reduce(function (initial, opt) {
@@ -890,7 +861,6 @@
890
861
  }
891
862
  }]), [this.options().map(function (opt, index) {
892
863
  var props = _objectSpread2({}, opt);
893
-
894
864
  delete props.value;
895
865
  return h("Radio", {
896
866
  "props": _objectSpread2({}, props),
@@ -925,11 +895,9 @@
925
895
  if (value === undefined || value === null) {
926
896
  return true;
927
897
  }
928
-
929
898
  if (Array.isArray(value) && Array.isArray(value) && !value.length) {
930
899
  return true;
931
900
  }
932
-
933
901
  return typeof value === 'string' && !value;
934
902
  }
935
903
  };
@@ -1007,10 +975,8 @@
1007
975
  },
1008
976
  checked: function checked(_data, value, type) {
1009
977
  var _this = this;
1010
-
1011
978
  _data.forEach(function (node) {
1012
979
  _this.$set(node, type, value.indexOf(node.id) !== -1);
1013
-
1014
980
  if (node.children !== undefined && Array.isArray(node.children)) _this.checked(node.children, value, type);
1015
981
  });
1016
982
  },
@@ -1023,13 +989,11 @@
1023
989
  render: function render() {
1024
990
  var h = arguments[0];
1025
991
  var on = {};
1026
-
1027
992
  if (this.type === 'selected') {
1028
993
  on['on-select-change'] = this.onInput;
1029
994
  } else {
1030
995
  on['on-check-change'] = this.onInput;
1031
996
  }
1032
-
1033
997
  return h("Tree", helper([{}, this.formCreateInject.prop, {
1034
998
  "ref": "tree"
1035
999
  }, {
@@ -1047,11 +1011,9 @@
1047
1011
  name: getFileName(file)
1048
1012
  };
1049
1013
  }
1050
-
1051
1014
  function getFileName(file) {
1052
1015
  return ('' + file).split('/').pop();
1053
1016
  }
1054
-
1055
1017
  var NAME$5 = 'fcUpload';
1056
1018
  function createUpload(config) {
1057
1019
  return {
@@ -1146,7 +1108,6 @@
1146
1108
  },
1147
1109
  makeRemoveIcon: function makeRemoveIcon(file, index) {
1148
1110
  var _this = this;
1149
-
1150
1111
  var h = this.$createElement;
1151
1112
  return h("icon", {
1152
1113
  "attrs": {
@@ -1162,7 +1123,6 @@
1162
1123
  },
1163
1124
  makeHandleIcon: function makeHandleIcon(file, index) {
1164
1125
  var _this2 = this;
1165
-
1166
1126
  var h = this.$createElement;
1167
1127
  return h("icon", {
1168
1128
  "attrs": {
@@ -1191,7 +1151,6 @@
1191
1151
  makeIcons: function makeIcons(file, index) {
1192
1152
  var h = this.$createElement;
1193
1153
  var icons = [];
1194
-
1195
1154
  if (this.allowRemove || this.handleIcon !== false) {
1196
1155
  if (this.uploadType !== 'file' && this.handleIcon !== false || this.uploadType === 'file' && this.handleIcon) icons.push(this.makeHandleIcon(file, index));
1197
1156
  if (this.allowRemove) icons.push(this.makeRemoveIcon(file, index));
@@ -1202,7 +1161,6 @@
1202
1161
  },
1203
1162
  makeFiles: function makeFiles() {
1204
1163
  var _this3 = this;
1205
-
1206
1164
  var h = this.$createElement;
1207
1165
  return this.uploadList.map(function (file, index) {
1208
1166
  return _this3.$scopedSlots.fileList ? _this3.$scopedSlots.fileList({
@@ -1241,7 +1199,6 @@
1241
1199
  }).filter(function (url) {
1242
1200
  return url !== undefined;
1243
1201
  });
1244
-
1245
1202
  if (this.cacheFiles.length !== files.length) {
1246
1203
  this.cacheFiles = _toConsumableArray(files);
1247
1204
  this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
@@ -1253,14 +1210,11 @@
1253
1210
  },
1254
1211
  render: function render() {
1255
1212
  var _this4 = this;
1256
-
1257
1213
  var h = arguments[0];
1258
-
1259
1214
  if (this.$refs.upload) {
1260
1215
  if (this.formCreateInject.prop.props.showUploadList === undefined) this.formCreateInject.prop.props.showUploadList = this.$refs.upload.showUploadList;
1261
1216
  this.formCreateInject.prop.props.defaultFileList = this.$refs.upload.defaultFileList;
1262
1217
  }
1263
-
1264
1218
  return h("div", {
1265
1219
  "class": "_fc-upload"
1266
1220
  }, [[this.formCreateInject.prop.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], h("Modal", {
@@ -1284,7 +1238,6 @@
1284
1238
  },
1285
1239
  mounted: function mounted() {
1286
1240
  var _this5 = this;
1287
-
1288
1241
  this.uploadList = this.$refs.upload.fileList;
1289
1242
  this.$watch(function () {
1290
1243
  return _this5.$refs.upload.fileList;
@@ -1317,14 +1270,11 @@
1317
1270
  var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1318
1271
  var mode = arguments.length > 2 ? arguments[2] : undefined;
1319
1272
  var isArr = false;
1320
-
1321
1273
  for (var key in target) {
1322
1274
  if (Object.prototype.hasOwnProperty.call(target, key)) {
1323
1275
  var clone = target[key];
1324
-
1325
1276
  if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1326
1277
  var nst = origin[key] === undefined;
1327
-
1328
1278
  if (isArr) {
1329
1279
  isArr = false;
1330
1280
  nst && $set(origin, key, []);
@@ -1339,16 +1289,13 @@
1339
1289
  } else {
1340
1290
  nst && $set(origin, key, {});
1341
1291
  }
1342
-
1343
1292
  origin[key] = deepExtend(origin[key], clone, mode);
1344
1293
  } else {
1345
1294
  $set(origin, key, clone);
1346
-
1347
1295
  if (!is.Undef(clone)) {
1348
1296
  if (!is.Undef(clone.__json)) {
1349
1297
  origin[key].__json = clone.__json;
1350
1298
  }
1351
-
1352
1299
  if (!is.Undef(clone.__origin)) {
1353
1300
  origin[key].__origin = clone.__origin;
1354
1301
  }
@@ -1356,7 +1303,6 @@
1356
1303
  }
1357
1304
  }
1358
1305
  }
1359
-
1360
1306
  return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1361
1307
  return !v || !v.__ctrl;
1362
1308
  }) : origin;
@@ -1373,10 +1319,8 @@
1373
1319
  Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1374
1320
  }
1375
1321
  }
1376
-
1377
1322
  return a;
1378
1323
  };
1379
-
1380
1324
  function extend() {
1381
1325
  return _extends$1.apply(this, arguments);
1382
1326
  }
@@ -1445,18 +1389,34 @@
1445
1389
  },
1446
1390
  computed: {
1447
1391
  formRule: function formRule() {
1448
- if (this.rule) {
1449
- return Array.isArray(this.rule) ? this.rule : [this.rule];
1450
- }
1451
-
1452
1392
  if (this.rules) {
1453
1393
  return this.rules;
1454
1394
  }
1455
-
1395
+ if (this.rule) {
1396
+ return Array.isArray(this.rule) ? this.rule : [this.rule];
1397
+ }
1456
1398
  return [];
1457
1399
  }
1458
1400
  },
1459
1401
  watch: {
1402
+ formRule: {
1403
+ handler: function handler(n, o) {
1404
+ var _this = this;
1405
+ Object.keys(this.cacheRule).forEach(function (v) {
1406
+ var item = _this.cacheRule[v];
1407
+ if (n === o) {
1408
+ deepExtend(item.rule, n);
1409
+ } else {
1410
+ var val = item.$f.formData();
1411
+ item.$f.once('reload', function () {
1412
+ item.$f.setValue(val);
1413
+ });
1414
+ item.rule = deepCopy(n);
1415
+ }
1416
+ });
1417
+ },
1418
+ deep: true
1419
+ },
1460
1420
  disabled: function disabled(n) {
1461
1421
  if (this.syncDisabled) {
1462
1422
  var lst = this.cacheRule;
@@ -1467,24 +1427,20 @@
1467
1427
  },
1468
1428
  expand: function expand(n) {
1469
1429
  var d = n - this.value.length;
1470
-
1471
1430
  if (d > 0) {
1472
1431
  this.expandRule(d);
1473
1432
  }
1474
1433
  },
1475
1434
  value: function value(n) {
1476
- var _this = this;
1477
-
1435
+ var _this2 = this;
1478
1436
  n = n || [];
1479
1437
  var keys = Object.keys(this.cacheRule),
1480
1438
  total = keys.length,
1481
1439
  len = total - n.length;
1482
-
1483
1440
  if (len < 0) {
1484
1441
  for (var i = len; i < 0; i++) {
1485
1442
  this.addRule(n.length + i);
1486
1443
  }
1487
-
1488
1444
  for (var _i = 0; _i < total; _i++) {
1489
1445
  this.setValue(keys[_i], n[_i]);
1490
1446
  }
@@ -1493,12 +1449,9 @@
1493
1449
  for (var _i2 = 0; _i2 < len; _i2++) {
1494
1450
  this.removeRule(keys[total - _i2 - 1]);
1495
1451
  }
1496
-
1497
- this.subForm();
1498
1452
  }
1499
-
1500
1453
  n.forEach(function (val, i) {
1501
- _this.setValue(keys[i], n[i]);
1454
+ _this2.setValue(keys[i], n[i]);
1502
1455
  });
1503
1456
  }
1504
1457
  }
@@ -1515,23 +1468,18 @@
1515
1468
  this.$emit('change', value);
1516
1469
  },
1517
1470
  formData: function formData(key, _formData) {
1518
- var _this2 = this;
1519
-
1471
+ var _this3 = this;
1520
1472
  var cacheRule = this.cacheRule;
1521
1473
  var keys = Object.keys(cacheRule);
1522
-
1523
1474
  if (keys.filter(function (k) {
1524
1475
  return cacheRule[k].$f;
1525
1476
  }).length !== keys.length) {
1526
1477
  return;
1527
1478
  }
1528
-
1529
1479
  var value = keys.map(function (k) {
1530
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1531
- var value = _this2.field ? data[_this2.field] || null : data;
1532
-
1533
- _this2.cache(k, value);
1534
-
1480
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1481
+ var value = _this3.field ? data[_this3.field] || null : data;
1482
+ _this3.cache(k, value);
1535
1483
  return value;
1536
1484
  });
1537
1485
  this.input(value);
@@ -1539,72 +1487,53 @@
1539
1487
  setValue: function setValue(key, value) {
1540
1488
  var field = this.field,
1541
1489
  $f = this.cacheRule[key].$f;
1542
-
1543
1490
  if (field) {
1544
1491
  value = _defineProperty({}, field, this._value(value));
1545
1492
  }
1546
-
1547
1493
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1548
1494
  return;
1549
1495
  }
1550
-
1551
1496
  this.cache(key, value);
1552
1497
  $f.coverValue(value || {});
1553
1498
  },
1554
1499
  addRule: function addRule(i, emit) {
1555
- var _this3 = this;
1556
-
1500
+ var _this4 = this;
1557
1501
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1558
1502
  var options = this.options ? _objectSpread2({}, this.options) : {
1559
1503
  submitBtn: false,
1560
1504
  resetBtn: false
1561
1505
  };
1562
-
1563
1506
  if (this.defaultValue) {
1564
1507
  if (!options.formData) options.formData = {};
1565
1508
  var defVal = deepCopy(this.defaultValue);
1566
1509
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1567
1510
  }
1568
-
1569
1511
  this.$set(this.cacheRule, ++this.len, {
1570
1512
  rule: rule,
1571
1513
  options: options
1572
1514
  });
1573
-
1574
1515
  if (emit) {
1575
1516
  this.$nextTick(function () {
1576
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1517
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1577
1518
  });
1578
1519
  }
1579
1520
  },
1580
1521
  add$f: function add$f(i, key, $f) {
1581
- var _this4 = this;
1582
-
1522
+ var _this5 = this;
1583
1523
  this.cacheRule[key].$f = $f;
1584
- this.subForm();
1585
1524
  this.formData(key, $f.formData());
1586
1525
  this.$nextTick(function () {
1587
- if (_this4.syncDisabled) {
1588
- $f.disabled(_this4.disabled);
1526
+ if (_this5.syncDisabled) {
1527
+ $f.disabled(_this5.disabled);
1589
1528
  }
1590
-
1591
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1529
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1592
1530
  });
1593
1531
  },
1594
- subForm: function subForm() {
1595
- var _this5 = this;
1596
-
1597
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1598
- return _this5.cacheRule[k].$f;
1599
- }));
1600
- },
1601
1532
  removeRule: function removeRule(key, emit) {
1602
1533
  var _this6 = this;
1603
-
1604
1534
  var index = Object.keys(this.cacheRule).indexOf(key);
1605
1535
  this.$delete(this.cacheRule, key);
1606
1536
  this.$delete(this.cacheValue, key);
1607
-
1608
1537
  if (emit) {
1609
1538
  this.$nextTick(function () {
1610
1539
  return _this6.$emit('remove', index);
@@ -1615,16 +1544,13 @@
1615
1544
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1616
1545
  return;
1617
1546
  }
1618
-
1619
1547
  this.addRule(i, true);
1620
1548
  },
1621
1549
  del: function del(index, key) {
1622
1550
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1623
1551
  return;
1624
1552
  }
1625
-
1626
1553
  this.removeRule(key, true);
1627
- this.subForm();
1628
1554
  this.value.splice(index, 1);
1629
1555
  this.input(this.value);
1630
1556
  },
@@ -1643,7 +1569,6 @@
1643
1569
  },
1644
1570
  delIcon: function delIcon(index, key) {
1645
1571
  var _this7 = this;
1646
-
1647
1572
  var h = this.$createElement;
1648
1573
  return h("Icon", {
1649
1574
  "key": "d".concat(key),
@@ -1660,7 +1585,6 @@
1660
1585
  },
1661
1586
  makeIcon: function makeIcon(total, index, key) {
1662
1587
  var _this8 = this;
1663
-
1664
1588
  if (this.$scopedSlots.button) {
1665
1589
  return this.$scopedSlots.button({
1666
1590
  total: total,
@@ -1673,11 +1597,9 @@
1673
1597
  add: this.add
1674
1598
  });
1675
1599
  }
1676
-
1677
1600
  if (index === 0) {
1678
1601
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1679
1602
  }
1680
-
1681
1603
  if (index >= this.min) {
1682
1604
  return this.delIcon(index, key);
1683
1605
  }
@@ -1694,18 +1616,15 @@
1694
1616
  created: function created() {
1695
1617
  this.type = this.formCreateInject.form.$form();
1696
1618
  var d = (this.expand || 0) - this.value.length;
1697
-
1698
1619
  if (d > 0) {
1699
1620
  this.expandRule(d);
1700
1621
  }
1701
-
1702
1622
  for (var i = 0; i < this.value.length; i++) {
1703
1623
  this.addRule(i);
1704
1624
  }
1705
1625
  },
1706
1626
  render: function render() {
1707
1627
  var _this9 = this;
1708
-
1709
1628
  var h = arguments[0];
1710
1629
  var keys = Object.keys(this.cacheRule);
1711
1630
  var button = this.button;
@@ -1740,7 +1659,10 @@
1740
1659
  "span": button ? 20 : 24
1741
1660
  }
1742
1661
  }, [h("FormItem", [h(Type, helper([{
1743
- "key": key
1662
+ "key": key,
1663
+ "attrs": {
1664
+ "inFor": true
1665
+ }
1744
1666
  }, {
1745
1667
  "on": {
1746
1668
  'update:value': function updateValue(formData) {
@@ -1750,7 +1672,6 @@
1750
1672
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1751
1673
  args[_key - 1] = arguments[_key];
1752
1674
  }
1753
-
1754
1675
  return _this9.emitEvent(name, args, index, key);
1755
1676
  },
1756
1677
  input: function input($f) {
@@ -1833,11 +1754,9 @@
1833
1754
  },
1834
1755
  setValue: function setValue(value) {
1835
1756
  var str = JSON.stringify(value);
1836
-
1837
1757
  if (this.cacheValue === str) {
1838
1758
  return;
1839
1759
  }
1840
-
1841
1760
  this.cacheValue = str;
1842
1761
  this.cacheRule.$f.coverValue(value || {});
1843
1762
  },
@@ -1854,23 +1773,16 @@
1854
1773
  },
1855
1774
  add$f: function add$f($f) {
1856
1775
  var _this = this;
1857
-
1858
1776
  this.cacheRule.$f = $f;
1859
- this.subForm();
1860
1777
  this.$nextTick(function () {
1861
1778
  _this.syncDisabled && $f.disabled(_this.disabled);
1862
-
1863
1779
  _this.$emit('itemMounted', $f);
1864
1780
  });
1865
1781
  },
1866
- subForm: function subForm() {
1867
- this.formCreateInject.subForm(this.cacheRule.$f);
1868
- },
1869
1782
  emitEvent: function emitEvent(name) {
1870
1783
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1871
1784
  args[_key - 1] = arguments[_key];
1872
1785
  }
1873
-
1874
1786
  this.$emit.apply(this, [name].concat(args));
1875
1787
  }
1876
1788
  },
@@ -1903,6 +1815,17 @@
1903
1815
  var components = [Checkbox, Radio, Select, Tree, Sub, frame, upload, group];
1904
1816
 
1905
1817
  var NAME$8 = 'FormCreate';
1818
+ var getRuleInject = function getRuleInject(vm, parent) {
1819
+ if (!vm || vm === parent) {
1820
+ return;
1821
+ }
1822
+ if (vm.formCreateInject) {
1823
+ return vm.formCreateInject;
1824
+ }
1825
+ if (vm.$parent) {
1826
+ return getRuleInject(vm.$parent, parent);
1827
+ }
1828
+ };
1906
1829
  function $FormCreate(FormCreate) {
1907
1830
  return {
1908
1831
  name: NAME$8,
@@ -1934,7 +1857,12 @@
1934
1857
  extendOption: Boolean,
1935
1858
  value: Object,
1936
1859
  api: Object,
1937
- name: String
1860
+ name: String,
1861
+ subForm: {
1862
+ type: Boolean,
1863
+ "default": true
1864
+ },
1865
+ inFor: Boolean
1938
1866
  },
1939
1867
  data: function data() {
1940
1868
  return {
@@ -1946,7 +1874,8 @@
1946
1874
  unique: 1,
1947
1875
  renderRule: _toConsumableArray(this.rule || []),
1948
1876
  ctxInject: {},
1949
- updateValue: ''
1877
+ updateValue: JSON.stringify(this.value || {}),
1878
+ isMore: !!this.inFor
1950
1879
  };
1951
1880
  },
1952
1881
  render: function render() {
@@ -1968,8 +1897,8 @@
1968
1897
  watch: {
1969
1898
  value: {
1970
1899
  handler: function handler(n) {
1971
- if (JSON.stringify(n) === this.updateValue) return;
1972
- this.$f.setValue(n);
1900
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1901
+ this.$f.setValue(n || {});
1973
1902
  },
1974
1903
  deep: true
1975
1904
  },
@@ -1982,18 +1911,15 @@
1982
1911
  },
1983
1912
  rule: function rule(n) {
1984
1913
  var _this = this;
1985
-
1986
1914
  if (n.length === this.renderRule.length && n.every(function (v) {
1987
1915
  return _this.renderRule.indexOf(v) > -1;
1988
1916
  })) return;
1989
1917
  this.formCreate.$handle.reloadRule(n);
1990
-
1991
1918
  this._renderRule();
1992
1919
  }
1993
1920
  },
1994
1921
  beforeCreate: function beforeCreate() {
1995
1922
  var _this2 = this;
1996
-
1997
1923
  var _this$$options$propsD = this.$options.propsData,
1998
1924
  rule = _this$$options$propsD.rule,
1999
1925
  option = _this$$options$propsD.option;
@@ -2002,6 +1928,50 @@
2002
1928
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
2003
1929
  });
2004
1930
  this.$emit('beforeCreate', this.formCreate.api());
1931
+ },
1932
+ created: function created() {
1933
+ var _this3 = this;
1934
+ var vm = this,
1935
+ fapi = this.formCreate.api();
1936
+ var addSubForm = function addSubForm() {
1937
+ if (vm.$pfc) {
1938
+ var inject = getRuleInject(vm, vm.$pfc);
1939
+ if (inject) {
1940
+ var sub;
1941
+ if (vm.isMore) {
1942
+ sub = toArray(inject.getSubForm());
1943
+ sub.push(fapi);
1944
+ } else {
1945
+ sub = fapi;
1946
+ }
1947
+ inject.subForm(sub);
1948
+ }
1949
+ }
1950
+ };
1951
+ var rmSubForm = function rmSubForm() {
1952
+ var inject = getRuleInject(vm, vm.$pfc);
1953
+ if (inject) {
1954
+ if (vm.isMore) {
1955
+ var sub = toArray(inject.getSubForm());
1956
+ var idx = sub.indexOf(fapi);
1957
+ if (idx > -1) {
1958
+ sub.splice(idx, 1);
1959
+ }
1960
+ } else {
1961
+ inject.subForm();
1962
+ }
1963
+ }
1964
+ };
1965
+ vm.$on('hook:beforeDestroy', function () {
1966
+ rmSubForm();
1967
+ });
1968
+ this.$watch(function () {
1969
+ return _this3.subForm;
1970
+ }, function (n) {
1971
+ n ? addSubForm() : rmSubForm();
1972
+ }, {
1973
+ immediate: true
1974
+ });
2005
1975
  }
2006
1976
  };
2007
1977
  }
@@ -2009,17 +1979,12 @@
2009
1979
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
2010
1980
  var toArrayMerge$1 = ['class', 'style', 'directives'];
2011
1981
  var functionalMerge$1 = ['on', 'nativeOn'];
2012
-
2013
1982
  var mergeProps = function mergeProps(objects) {
2014
1983
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2015
1984
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2016
-
2017
1985
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
2018
-
2019
1986
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
2020
-
2021
1987
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
2022
-
2023
1988
  var propsMerge = opt['props'] || [];
2024
1989
  return objects.reduce(function (a, b) {
2025
1990
  for (var key in b) {
@@ -2036,9 +2001,7 @@
2036
2001
  for (var event in b[key]) {
2037
2002
  if (a[key][event]) {
2038
2003
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2039
-
2040
2004
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2041
-
2042
2005
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2043
2006
  } else {
2044
2007
  a[key][event] = b[key][event];
@@ -2063,11 +2026,9 @@
2063
2026
  } else a[key] = b[key];
2064
2027
  }
2065
2028
  }
2066
-
2067
2029
  return a;
2068
2030
  }, initial);
2069
2031
  };
2070
-
2071
2032
  var mergeFn$1 = function mergeFn(fn1, fn2) {
2072
2033
  return function () {
2073
2034
  fn1 && fn1.apply(this, arguments);
@@ -2075,7 +2036,7 @@
2075
2036
  };
2076
2037
  };
2077
2038
 
2078
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2039
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
2079
2040
  var arrayAttrs = ['validate', 'children', 'control'];
2080
2041
  var normalAttrs = ['effect', 'deep'];
2081
2042
  function attrs() {
@@ -2104,30 +2065,24 @@
2104
2065
  function toJson(obj, space) {
2105
2066
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2106
2067
  if (val && val._isVue === true) return undefined;
2107
-
2108
2068
  if (_typeof(val) !== FUNCTION) {
2109
2069
  return val;
2110
2070
  }
2111
-
2112
2071
  if (val.__json) {
2113
2072
  return val.__json;
2114
2073
  }
2115
-
2116
2074
  if (val.__origin) val = val.__origin;
2117
2075
  if (val.__emit) return undefined;
2118
2076
  return PREFIX + val + SUFFIX;
2119
2077
  }, space);
2120
2078
  }
2121
-
2122
2079
  function makeFn(fn) {
2123
2080
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2124
2081
  }
2125
-
2126
2082
  function parseFn(fn, mode) {
2127
2083
  if (fn && is.String(fn) && fn.length > 4) {
2128
2084
  var v = fn.trim();
2129
2085
  var flag = false;
2130
-
2131
2086
  try {
2132
2087
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2133
2088
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2143,7 +2098,6 @@
2143
2098
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2144
2099
  flag = true;
2145
2100
  }
2146
-
2147
2101
  if (!flag) return fn;
2148
2102
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2149
2103
  val.__json = fn;
@@ -2153,7 +2107,6 @@
2153
2107
  return undefined;
2154
2108
  }
2155
2109
  }
2156
-
2157
2110
  return fn;
2158
2111
  }
2159
2112
  function parseJson(json, mode) {
@@ -2170,8 +2123,7 @@
2170
2123
  configurable: false,
2171
2124
  writable: !!writable
2172
2125
  };
2173
- } //todo 优化位置
2174
-
2126
+ }
2175
2127
  function copyRule(rule) {
2176
2128
  return copyRules([rule])[0];
2177
2129
  }
@@ -2216,7 +2168,6 @@
2216
2168
  } catch (e) {
2217
2169
  logError(e);
2218
2170
  }
2219
-
2220
2171
  return def;
2221
2172
  }
2222
2173
 
@@ -2235,11 +2186,9 @@
2235
2186
  return function (title, field, value) {
2236
2187
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2237
2188
  var maker = new Creator(name, title, field, value, props);
2238
-
2239
2189
  if (init) {
2240
2190
  if (is.Function(init)) init(maker);else maker.props(init);
2241
2191
  }
2242
-
2243
2192
  return maker;
2244
2193
  };
2245
2194
  }
@@ -2304,13 +2253,11 @@
2304
2253
  function copy(value) {
2305
2254
  return deepCopy(value);
2306
2255
  }
2307
-
2308
2256
  function Api(h) {
2309
2257
  function tidyFields(fields) {
2310
2258
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2311
2259
  return fields;
2312
2260
  }
2313
-
2314
2261
  function props(fields, key, val) {
2315
2262
  tidyFields(fields).forEach(function (field) {
2316
2263
  h.getCtxs(field).forEach(function (ctx) {
@@ -2319,7 +2266,6 @@
2319
2266
  });
2320
2267
  });
2321
2268
  }
2322
-
2323
2269
  function allSubForm() {
2324
2270
  var subs = h.subForm;
2325
2271
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2329,39 +2275,32 @@
2329
2275
  return initial;
2330
2276
  }, []);
2331
2277
  }
2332
-
2333
2278
  var api = {
2334
2279
  get config() {
2335
2280
  return h.options;
2336
2281
  },
2337
-
2338
2282
  get options() {
2339
2283
  return h.options;
2340
2284
  },
2341
-
2342
2285
  get form() {
2343
2286
  return h.form;
2344
2287
  },
2345
-
2346
2288
  get rule() {
2347
2289
  return h.rules;
2348
2290
  },
2349
-
2350
2291
  get parent() {
2351
2292
  return h.vm.$pfc && h.vm.$pfc.$f;
2352
2293
  },
2353
-
2354
2294
  get children() {
2355
2295
  return allSubForm();
2356
2296
  },
2357
-
2358
2297
  formData: function formData(fields) {
2359
2298
  return tidyFields(fields).reduce(function (initial, id) {
2360
2299
  var ctx = h.getFieldCtx(id);
2361
2300
  if (!ctx) return initial;
2362
2301
  initial[ctx.field] = copy(ctx.rule.value);
2363
2302
  return initial;
2364
- }, copy(h.appendData));
2303
+ }, h.options.appendValue ? copy(h.appendData) : {});
2365
2304
  },
2366
2305
  getValue: function getValue(field) {
2367
2306
  var ctx = h.getFieldCtx(field);
@@ -2419,7 +2358,6 @@
2419
2358
  var index = h.sort.length - 1,
2420
2359
  rules;
2421
2360
  var ctx = h.getCtx(after);
2422
-
2423
2361
  if (ctx) {
2424
2362
  if (child) {
2425
2363
  rules = ctx.rule.children;
@@ -2429,14 +2367,12 @@
2429
2367
  rules = ctx.root;
2430
2368
  }
2431
2369
  } else rules = h.rules;
2432
-
2433
2370
  rules.splice(index + 1, 0, rule);
2434
2371
  },
2435
2372
  prepend: function prepend(rule, after, child) {
2436
2373
  var index = 0,
2437
2374
  rules;
2438
2375
  var ctx = h.getCtx(after);
2439
-
2440
2376
  if (ctx) {
2441
2377
  if (child) {
2442
2378
  rules = ctx.rule.children;
@@ -2445,7 +2381,6 @@
2445
2381
  rules = ctx.root;
2446
2382
  }
2447
2383
  } else rules = h.rules;
2448
-
2449
2384
  rules.splice(index, 0, rule);
2450
2385
  },
2451
2386
  hidden: function hidden(state, fields) {
@@ -2518,18 +2453,14 @@
2518
2453
  });
2519
2454
  return;
2520
2455
  }
2521
-
2522
2456
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2523
-
2524
2457
  if (!ctxs) {
2525
2458
  return;
2526
2459
  }
2527
-
2528
2460
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2529
2461
  ctxs.forEach(function (ctx) {
2530
2462
  if (!ctx.deleted) {
2531
2463
  var subForm = h.subForm[ctx.id];
2532
-
2533
2464
  if (subForm) {
2534
2465
  if (Array.isArray(subForm)) {
2535
2466
  subForm.forEach(function (form) {
@@ -2538,9 +2469,7 @@
2538
2469
  } else if (subForm) {
2539
2470
  subForm.refresh();
2540
2471
  }
2541
- } //ctx.updateKey(true);
2542
-
2543
-
2472
+ }
2544
2473
  h.$render.clearCache(ctx);
2545
2474
  }
2546
2475
  });
@@ -2588,11 +2517,25 @@
2588
2517
  },
2589
2518
  getRule: function getRule(id, origin) {
2590
2519
  var ctx = h.getCtx(id);
2591
-
2592
2520
  if (ctx) {
2593
2521
  return origin ? ctx.origin : ctx.rule;
2594
2522
  }
2595
2523
  },
2524
+ setEffect: function setEffect(id, attr, value) {
2525
+ var ctx = h.getCtx(id);
2526
+ if (ctx && attr) {
2527
+ if (attr[0] === '$') {
2528
+ attr = attr.substr(1);
2529
+ }
2530
+ if (hasProperty(ctx.rule, '$' + attr)) {
2531
+ $set(ctx.rule, '$' + attr, value);
2532
+ }
2533
+ if (!hasProperty(ctx.rule, 'effect')) {
2534
+ ctx.rule.effect = {};
2535
+ }
2536
+ $set(ctx.rule.effect, attr, value);
2537
+ }
2538
+ },
2596
2539
  updateValidate: function updateValidate(id, validate, merge) {
2597
2540
  if (merge) {
2598
2541
  api.mergeRule(id, {
@@ -2631,7 +2574,6 @@
2631
2574
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2632
2575
  args[_key - 2] = arguments[_key];
2633
2576
  }
2634
-
2635
2577
  return invoke(function () {
2636
2578
  return api.method(id, name).apply(void 0, args);
2637
2579
  });
@@ -2641,11 +2583,9 @@
2641
2583
  },
2642
2584
  trigger: function trigger(id, event) {
2643
2585
  var el = api.el(id);
2644
-
2645
2586
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2646
2587
  args[_key2 - 2] = arguments[_key2];
2647
2588
  }
2648
-
2649
2589
  el && el.$emit.apply(el, [event].concat(args));
2650
2590
  },
2651
2591
  el: function el(id) {
@@ -2670,11 +2610,9 @@
2670
2610
  },
2671
2611
  emit: function emit(name) {
2672
2612
  var _h$vm;
2673
-
2674
2613
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2675
2614
  args[_key3 - 1] = arguments[_key3];
2676
2615
  }
2677
-
2678
2616
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2679
2617
  },
2680
2618
  helper: {
@@ -2685,7 +2623,6 @@
2685
2623
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2686
2624
  api[n] = function () {
2687
2625
  var _h$vm2;
2688
-
2689
2626
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2690
2627
  };
2691
2628
  });
@@ -2703,11 +2640,9 @@
2703
2640
  ctx.parent && this.clearCache(ctx.parent);
2704
2641
  return;
2705
2642
  }
2706
-
2707
2643
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2708
2644
  this.$handle.refresh();
2709
2645
  }
2710
-
2711
2646
  var parent = this.cache[ctx.id].parent;
2712
2647
  this.cache[ctx.id] = null;
2713
2648
  parent && this.clearCache(parent);
@@ -2764,10 +2699,8 @@
2764
2699
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2765
2700
  _data[to] = {};
2766
2701
  }
2767
-
2768
2702
  _data = _data[to];
2769
2703
  }
2770
-
2771
2704
  to = v;
2772
2705
  });
2773
2706
  _data[to] = val;
@@ -2787,7 +2720,6 @@
2787
2720
  var children = ctxs[id].rule.children;
2788
2721
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2789
2722
  }
2790
-
2791
2723
  return initial;
2792
2724
  }, {});
2793
2725
  },
@@ -2796,59 +2728,46 @@
2796
2728
  },
2797
2729
  getTypeSlot: function getTypeSlot(type) {
2798
2730
  var name = 'type-' + toLine(type);
2799
-
2800
2731
  var _fn = function _fn(vm) {
2801
2732
  if (vm) {
2802
2733
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2803
-
2804
2734
  if (slot) {
2805
2735
  return slot;
2806
2736
  }
2807
-
2808
2737
  return _fn(vm.$pfc);
2809
2738
  }
2810
2739
  };
2811
-
2812
2740
  return _fn(this.vm);
2813
2741
  },
2814
2742
  render: function render() {
2815
2743
  var _this = this;
2816
-
2817
2744
  if (!this.vm.isShow) {
2818
2745
  return;
2819
2746
  }
2820
-
2821
2747
  this.$h = this.vm.$createElement;
2822
2748
  this.$manager.beforeRender();
2823
2749
  var vn;
2824
-
2825
2750
  var make = function make() {
2826
2751
  return _this.renderList();
2827
2752
  };
2828
-
2829
2753
  make.renderSlot = function (slot) {
2830
2754
  return _this.renderList(slot);
2831
2755
  };
2832
-
2833
2756
  make.renderName = function (name) {
2834
2757
  return _this.renderId(name);
2835
2758
  };
2836
-
2837
2759
  make.renderField = function (field) {
2838
2760
  return _this.renderId(field, 'field');
2839
2761
  };
2840
-
2841
2762
  if (this.vm.$scopedSlots.container) {
2842
2763
  vn = [this.vm.$scopedSlots.container(make)];
2843
2764
  } else {
2844
2765
  vn = make();
2845
2766
  }
2846
-
2847
2767
  return this.$manager.render(vn);
2848
2768
  },
2849
2769
  renderList: function renderList(slot) {
2850
2770
  var _this2 = this;
2851
-
2852
2771
  return this.sort.map(function (id) {
2853
2772
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2854
2773
  }).filter(function (val) {
@@ -2857,7 +2776,6 @@
2857
2776
  },
2858
2777
  makeVm: function makeVm(rule) {
2859
2778
  var _this3 = this;
2860
-
2861
2779
  var vm = rule.vm;
2862
2780
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2863
2781
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2866,8 +2784,7 @@
2866
2784
  },
2867
2785
  mergeGlobal: function mergeGlobal(ctx) {
2868
2786
  var g = this.$handle.options.global;
2869
- if (!g) return; //todo 缓存配置,更新 option 更新
2870
-
2787
+ if (!g) return;
2871
2788
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2872
2789
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2873
2790
  },
@@ -2894,23 +2811,19 @@
2894
2811
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2895
2812
  });
2896
2813
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2897
-
2898
2814
  if (keys.indexOf(key) > -1) {
2899
2815
  vm.$props[key] = prop.value;
2900
2816
  }
2901
2817
  },
2902
2818
  renderTemp: function renderTemp(ctx) {
2903
2819
  var _this4 = this;
2904
-
2905
2820
  if (!_vue.compile) {
2906
2821
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2907
2822
  return [];
2908
2823
  }
2909
-
2910
2824
  var rule = ctx.prop;
2911
2825
  var id = ctx.id,
2912
2826
  key = ctx.key;
2913
-
2914
2827
  if (!this.tempList[id]) {
2915
2828
  if (!ctx.el) {
2916
2829
  ctx.el = this.makeVm(rule);
@@ -2918,7 +2831,6 @@
2918
2831
  return ctx.parser.mounted(ctx);
2919
2832
  });
2920
2833
  }
2921
-
2922
2834
  var _vm = ctx.el;
2923
2835
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2924
2836
  _this4.onInput(ctx, value);
@@ -2928,7 +2840,6 @@
2928
2840
  template: _vue.compile(rule.template)
2929
2841
  };
2930
2842
  }
2931
-
2932
2843
  var _this$tempList$id = this.tempList[id],
2933
2844
  vm = _this$tempList$id.vm,
2934
2845
  template = _this$tempList$id.template;
@@ -2952,7 +2863,6 @@
2952
2863
  },
2953
2864
  renderId: function renderId(name, type) {
2954
2865
  var _this5 = this;
2955
-
2956
2866
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2957
2867
  return ctxs ? ctxs.map(function (ctx) {
2958
2868
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2961,21 +2871,16 @@
2961
2871
  renderCtx: function renderCtx(ctx, parent) {
2962
2872
  if (ctx.type === 'hidden') return;
2963
2873
  var rule = ctx.rule;
2964
- var preview = this.options.preview || false;
2965
-
2966
2874
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2967
2875
  var vn;
2968
- var cacheFlag = true;
2876
+ var cacheFlag = rule.cache !== false;
2969
2877
  var _type = ctx.trueType;
2970
2878
  var none = !(is.Undef(rule.display) || !!rule.display);
2971
-
2972
2879
  if (_type === 'template' && !rule.template) {
2973
2880
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2974
-
2975
2881
  if (none) {
2976
2882
  this.display(vn);
2977
2883
  }
2978
-
2979
2884
  vn = this.item(ctx, vn);
2980
2885
  } else if (_type === 'fcFragment') {
2981
2886
  vn = this.renderChildren(ctx);
@@ -2987,27 +2892,24 @@
2987
2892
  this.setOptions(ctx);
2988
2893
  this.ctxProp(ctx);
2989
2894
  var prop = ctx.prop;
2895
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
2990
2896
  prop.props.formCreateInject = this.injectProp(ctx);
2991
-
2897
+ var preview = prop.preview;
2992
2898
  if (prop.hidden) {
2993
2899
  this.setCache(ctx, undefined, parent);
2994
2900
  return;
2995
2901
  }
2996
-
2997
2902
  if (_type === 'template' && prop.template) {
2998
2903
  vn = this.renderTemp(ctx);
2999
2904
  cacheFlag = false;
3000
2905
  } else {
3001
2906
  var children = [];
3002
-
3003
2907
  if (ctx.parser.renderChildren) {
3004
2908
  children = ctx.parser.renderChildren(ctx);
3005
2909
  } else if (ctx.parser.loadChildren !== false) {
3006
2910
  children = this.renderChildren(ctx);
3007
2911
  }
3008
-
3009
2912
  var slot = this.getTypeSlot(ctx.type);
3010
-
3011
2913
  if (slot) {
3012
2914
  vn = slot({
3013
2915
  rule: rule,
@@ -3021,32 +2923,24 @@
3021
2923
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3022
2924
  }
3023
2925
  }
3024
-
3025
2926
  vn = this.renderSides(vn, ctx);
3026
-
3027
2927
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3028
2928
  vn = this.$manager.makeWrap(ctx, vn);
3029
2929
  }
3030
-
3031
2930
  if (none) {
3032
2931
  vn = this.display(vn);
3033
2932
  }
3034
-
3035
2933
  vn = this.item(ctx, vn);
3036
2934
  }
3037
-
3038
2935
  if (cacheFlag) {
3039
2936
  this.setCache(ctx, vn, parent);
3040
2937
  }
3041
-
3042
2938
  return vn;
3043
2939
  }
3044
-
3045
2940
  return this.getCache(ctx);
3046
2941
  },
3047
2942
  display: function display(vn) {
3048
2943
  var _this6 = this;
3049
-
3050
2944
  if (Array.isArray(vn)) {
3051
2945
  var data = [];
3052
2946
  vn.forEach(function (v) {
@@ -3069,7 +2963,6 @@
3069
2963
  display: 'none'
3070
2964
  }];
3071
2965
  }
3072
-
3073
2966
  return vn;
3074
2967
  }
3075
2968
  },
@@ -3081,7 +2974,6 @@
3081
2974
  },
3082
2975
  injectProp: function injectProp(ctx) {
3083
2976
  var _this7 = this;
3084
-
3085
2977
  if (!this.vm.ctxInject[ctx.id]) {
3086
2978
  $set(this.vm.ctxInject, ctx.id, {
3087
2979
  api: this.$handle.api,
@@ -3089,23 +2981,25 @@
3089
2981
  subForm: function subForm(_subForm) {
3090
2982
  _this7.$handle.addSubForm(ctx, _subForm);
3091
2983
  },
2984
+ getSubForm: function getSubForm() {
2985
+ return _this7.$handle.subForm[ctx.id];
2986
+ },
3092
2987
  options: [],
3093
2988
  children: [],
3094
2989
  prop: {},
3095
2990
  preview: false,
3096
2991
  field: ctx.field,
3097
- rule: ctx.rule
2992
+ rule: ctx.rule,
2993
+ input: ctx.input
3098
2994
  });
3099
2995
  }
3100
-
3101
2996
  var inject = this.vm.ctxInject[ctx.id];
3102
2997
  extend(inject, {
3103
- preview: this.options.preview || false,
2998
+ preview: ctx.prop.preview,
3104
2999
  options: ctx.prop.options,
3105
3000
  children: ctx.rule.children,
3106
3001
  prop: function () {
3107
3002
  var temp = _objectSpread2({}, ctx.prop);
3108
-
3109
3003
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3110
3004
  delete temp.model;
3111
3005
  return temp;
@@ -3115,7 +3009,6 @@
3115
3009
  },
3116
3010
  ctxProp: function ctxProp(ctx, custom) {
3117
3011
  var _this8 = this;
3118
-
3119
3012
  var ref = ctx.ref,
3120
3013
  key = ctx.key,
3121
3014
  rule = ctx.rule;
@@ -3134,7 +3027,6 @@
3134
3027
  }
3135
3028
  }
3136
3029
  }];
3137
-
3138
3030
  if (!custom && ctx.input) {
3139
3031
  ctx.prop.model = {
3140
3032
  value: this.$handle.getFormData(ctx),
@@ -3144,17 +3036,14 @@
3144
3036
  expression: "formData.".concat(ctx.id)
3145
3037
  };
3146
3038
  }
3147
-
3148
3039
  mergeProps(props, ctx.prop);
3149
3040
  return ctx.prop;
3150
3041
  },
3151
3042
  onMounted: function onMounted(ctx) {
3152
3043
  ctx.el = this.vm.$refs[ctx.ref];
3153
-
3154
3044
  if (ctx.el) {
3155
3045
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3156
3046
  }
3157
-
3158
3047
  ctx.parser.mounted(ctx);
3159
3048
  this.$handle.effect(ctx, 'mounted');
3160
3049
  },
@@ -3163,19 +3052,15 @@
3163
3052
  },
3164
3053
  renderChildren: function renderChildren(ctx) {
3165
3054
  var _this9 = this;
3166
-
3167
3055
  var children = ctx.rule.children,
3168
3056
  orgChildren = this.orgChildren[ctx.id];
3169
-
3170
3057
  var isRm = function isRm(child) {
3171
3058
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3172
3059
  };
3173
-
3174
3060
  if (!is.trueArray(children) && orgChildren) {
3175
3061
  this.$handle.deferSyncValue(function () {
3176
3062
  orgChildren.forEach(function (child) {
3177
3063
  if (!child) return;
3178
-
3179
3064
  if (isRm(child)) {
3180
3065
  _this9.$handle.rmCtx(child.__fc__);
3181
3066
  }
@@ -3184,11 +3069,9 @@
3184
3069
  this.orgChildren[ctx.id] = [];
3185
3070
  return [];
3186
3071
  }
3187
-
3188
3072
  orgChildren && this.$handle.deferSyncValue(function () {
3189
3073
  orgChildren.forEach(function (child) {
3190
3074
  if (!child) return;
3191
-
3192
3075
  if (children.indexOf(child) === -1 && isRm(child)) {
3193
3076
  _this9.$handle.rmCtx(child.__fc__);
3194
3077
  }
@@ -3197,15 +3080,12 @@
3197
3080
  return children.map(function (child) {
3198
3081
  if (!child) return;
3199
3082
  if (is.String(child)) return child;
3200
-
3201
3083
  if (child.__fc__) {
3202
3084
  return _this9.renderCtx(child.__fc__, ctx);
3203
3085
  }
3204
-
3205
3086
  if (child.type) {
3206
3087
  _this9.vm.$nextTick(function () {
3207
3088
  _this9.$handle.loadChildren(children, ctx);
3208
-
3209
3089
  _this9.$handle.refresh();
3210
3090
  });
3211
3091
  }
@@ -3213,38 +3093,33 @@
3213
3093
  },
3214
3094
  defaultRender: function defaultRender(ctx, children) {
3215
3095
  var prop = ctx.prop;
3096
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3216
3097
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3217
3098
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3218
3099
  return this.vNode.make(lower(ctx.originType), prop, children);
3219
3100
  },
3220
3101
  renderRule: function renderRule(rule, children, origin) {
3221
3102
  var _this10 = this;
3222
-
3223
3103
  if (!rule) return undefined;
3224
3104
  if (is.String(rule)) return rule;
3225
3105
  var type;
3226
-
3227
3106
  if (origin) {
3228
3107
  type = rule.type;
3229
3108
  } else {
3230
3109
  type = rule.is;
3231
-
3232
3110
  if (rule.type) {
3233
3111
  type = toCase(rule.type);
3234
3112
  var alias = this.vNode.aliasMap[type];
3235
3113
  if (alias) type = toCase(alias);
3236
3114
  }
3237
3115
  }
3238
-
3239
3116
  if (!type) return undefined;
3240
3117
  var data = [[children]];
3241
-
3242
3118
  if (is.trueArray(rule.children)) {
3243
3119
  data.push(rule.children.map(function (v) {
3244
3120
  return _this10.renderRule(v);
3245
3121
  }));
3246
3122
  }
3247
-
3248
3123
  return this.$h(type, _objectSpread2({}, rule), data);
3249
3124
  }
3250
3125
  });
@@ -3280,10 +3155,8 @@
3280
3155
  },
3281
3156
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3282
3157
  var _this = this;
3283
-
3284
3158
  Object.keys(data).forEach(function (k) {
3285
3159
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3286
-
3287
3160
  if (fn) {
3288
3161
  data[k] = fn;
3289
3162
  }
@@ -3297,7 +3170,6 @@
3297
3170
  return this.parseEventLst(rule, fn, inject, true);
3298
3171
  } else if (is.String(fn)) {
3299
3172
  var val = parseFn(fn);
3300
-
3301
3173
  if (val && fn !== val) {
3302
3174
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3303
3175
  }
@@ -3305,7 +3177,6 @@
3305
3177
  },
3306
3178
  parseEmit: function parseEmit(ctx, on) {
3307
3179
  var _this2 = this;
3308
-
3309
3180
  var event = {},
3310
3181
  rule = ctx.rule,
3311
3182
  emitPrefix = rule.emitPrefix,
@@ -3313,48 +3184,36 @@
3313
3184
  name = rule.name,
3314
3185
  inject = rule.inject;
3315
3186
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3316
-
3317
3187
  if (is.trueArray(emit)) {
3318
3188
  var emitKey = emitPrefix || field || name;
3319
-
3320
3189
  if (emitKey) {
3321
3190
  if (!on) emitKey = "native-".concat(emitKey);
3322
3191
  emit.forEach(function (eventName) {
3323
3192
  if (!eventName) return;
3324
3193
  var eventInject;
3325
-
3326
3194
  if (is.Object(eventName)) {
3327
3195
  eventInject = eventName.inject;
3328
3196
  eventName = eventName.name;
3329
3197
  }
3330
-
3331
3198
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3332
-
3333
3199
  var fn = function fn() {
3334
3200
  var _this2$vm, _this2$vm2;
3335
-
3336
3201
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3337
3202
  arg[_key] = arguments[_key];
3338
3203
  }
3339
-
3340
3204
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3341
-
3342
3205
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3343
3206
  };
3344
-
3345
3207
  fn.__emit = true;
3346
-
3347
3208
  if (!eventInject && inject === false) {
3348
3209
  event[eventName] = fn;
3349
3210
  } else {
3350
3211
  var _inject = eventInject || inject || _this2.options.injectEvent;
3351
-
3352
3212
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3353
3213
  }
3354
3214
  });
3355
3215
  }
3356
3216
  }
3357
-
3358
3217
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3359
3218
  return event;
3360
3219
  },
@@ -3376,21 +3235,16 @@
3376
3235
  if (this.watching && !this.loading) return _fn;
3377
3236
  _fn = _fn.__origin;
3378
3237
  }
3379
-
3380
3238
  var h = this;
3381
-
3382
3239
  var fn = function fn() {
3383
3240
  var data = h.getInjectData(self, _inject2);
3384
-
3385
3241
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3386
3242
  args[_key2] = arguments[_key2];
3387
3243
  }
3388
-
3389
3244
  data.args = [].concat(args);
3390
3245
  args.unshift(data);
3391
3246
  return _fn.apply(this, args);
3392
3247
  };
3393
-
3394
3248
  fn.__origin = _fn;
3395
3249
  fn.__json = _fn.__json;
3396
3250
  return fn;
@@ -3403,17 +3257,14 @@
3403
3257
  extend(Handler.prototype, {
3404
3258
  usePage: function usePage() {
3405
3259
  var _this = this;
3406
-
3407
3260
  var page = this.options.page;
3408
3261
  if (!page) return;
3409
3262
  var first = 25;
3410
3263
  var limit = getLimit(this.rules);
3411
-
3412
3264
  if (is.Object(page)) {
3413
3265
  if (page.first) first = parseInt(page.first, 10) || first;
3414
3266
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3415
3267
  }
3416
-
3417
3268
  extend(this, {
3418
3269
  first: first,
3419
3270
  limit: limit,
@@ -3426,27 +3277,21 @@
3426
3277
  },
3427
3278
  pageLoad: function pageLoad() {
3428
3279
  var _this2 = this;
3429
-
3430
3280
  var pageFn = function pageFn() {
3431
3281
  if (_this2.pageEnd) {
3432
3282
  _this2.vm.$off(EVENT, pageFn);
3433
-
3434
3283
  _this2.bus.$emit('page-end');
3435
3284
  } else {
3436
3285
  _this2.first += _this2.limit;
3437
3286
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3438
-
3439
3287
  _this2.loadRule();
3440
-
3441
3288
  _this2.refresh();
3442
3289
  }
3443
3290
  };
3444
-
3445
3291
  this.vm.$on(EVENT, pageFn);
3446
3292
  }
3447
3293
  });
3448
3294
  }
3449
-
3450
3295
  function getLimit(rules) {
3451
3296
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3452
3297
  }
@@ -3459,7 +3304,6 @@
3459
3304
  },
3460
3305
  bindNextTick: function bindNextTick(fn) {
3461
3306
  var _this = this;
3462
-
3463
3307
  this.clearNextTick();
3464
3308
  this.nextTick = setTimeout(function () {
3465
3309
  fn();
@@ -3467,7 +3311,6 @@
3467
3311
  }, 10);
3468
3312
  },
3469
3313
  render: function render() {
3470
- // console.warn('%c render', 'color:green');
3471
3314
  ++this.loadedId;
3472
3315
  if (this.vm.unique > 0) return this.$render.render();else {
3473
3316
  this.vm.unique = 1;
@@ -3482,7 +3325,6 @@
3482
3325
  __fc__: enumerable(ctx, true)
3483
3326
  });
3484
3327
  }
3485
-
3486
3328
  function RuleContext(handle, rule) {
3487
3329
  var id = uniqueId();
3488
3330
  extend(this, {
@@ -3516,7 +3358,6 @@
3516
3358
  if (!this.payload[name]) {
3517
3359
  this.payload[name] = {};
3518
3360
  }
3519
-
3520
3361
  return this.payload[name];
3521
3362
  },
3522
3363
  clearEffectData: function clearEffectData(name) {
@@ -3536,9 +3377,7 @@
3536
3377
  },
3537
3378
  initProp: function initProp() {
3538
3379
  var _this = this;
3539
-
3540
3380
  var rule = _objectSpread2({}, this.rule);
3541
-
3542
3381
  delete rule.children;
3543
3382
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3544
3383
  return _this.payload[k];
@@ -3593,31 +3432,22 @@
3593
3432
  },
3594
3433
  rm: function rm() {
3595
3434
  var _this2 = this;
3596
-
3597
3435
  var _rm = function _rm() {
3598
3436
  var index = _this2.root.indexOf(_this2.origin);
3599
-
3600
3437
  if (index > -1) {
3601
3438
  _this2.root.splice(index, 1);
3602
-
3603
3439
  _this2.$handle && _this2.$handle.refresh();
3604
3440
  }
3605
3441
  };
3606
-
3607
3442
  if (this.deleted) {
3608
3443
  _rm();
3609
-
3610
3444
  return;
3611
3445
  }
3612
-
3613
3446
  this.$handle.noWatch(function () {
3614
3447
  _this2.$handle.deferSyncValue(function () {
3615
3448
  _this2.rmCtrl();
3616
-
3617
3449
  _rm();
3618
-
3619
3450
  _this2.$handle.rmCtx(_this2);
3620
-
3621
3451
  extend(_this2, {
3622
3452
  root: []
3623
3453
  });
@@ -3645,7 +3475,6 @@
3645
3475
  extend(Handler.prototype, {
3646
3476
  nextRefresh: function nextRefresh(fn) {
3647
3477
  var _this = this;
3648
-
3649
3478
  var id = this.loadedId;
3650
3479
  this.vm.$nextTick(function () {
3651
3480
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3653,7 +3482,6 @@
3653
3482
  },
3654
3483
  parseRule: function parseRule(_rule) {
3655
3484
  var _this2 = this;
3656
-
3657
3485
  var rule = getRule(_rule);
3658
3486
  Object.defineProperties(rule, {
3659
3487
  __origin__: enumerable(_rule, true)
@@ -3665,20 +3493,16 @@
3665
3493
  if (!item) {
3666
3494
  return;
3667
3495
  }
3668
-
3669
3496
  _this2.loadFn(item, rule);
3670
3497
  });
3671
3498
  this.loadCtrl(rule);
3672
-
3673
3499
  if (rule.update) {
3674
3500
  rule.update = parseFn(rule.update);
3675
3501
  }
3676
-
3677
3502
  return rule;
3678
3503
  },
3679
3504
  loadFn: function loadFn(item, rule) {
3680
3505
  var _this3 = this;
3681
-
3682
3506
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3683
3507
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3684
3508
  });
@@ -3692,48 +3516,35 @@
3692
3516
  },
3693
3517
  syncProp: function syncProp(ctx) {
3694
3518
  var _this4 = this;
3695
-
3696
3519
  var rule = ctx.rule;
3697
3520
  is.trueArray(rule.sync) && mergeProps([{
3698
3521
  on: rule.sync.reduce(function (pre, prop) {
3699
3522
  pre["update:".concat(prop)] = function (val) {
3700
3523
  rule.props[prop] = val;
3701
-
3702
3524
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3703
3525
  };
3704
-
3705
3526
  return pre;
3706
3527
  }, {})
3707
3528
  }], ctx.computed);
3708
3529
  },
3709
3530
  loadRule: function loadRule() {
3710
3531
  var _this5 = this;
3711
-
3712
- // console.warn('%c load', 'color:blue');
3713
3532
  this.cycleLoad = false;
3714
3533
  this.loading = true;
3715
-
3716
3534
  if (this.pageEnd) {
3717
3535
  this.bus.$emit('load-start');
3718
3536
  }
3719
-
3720
3537
  this.deferSyncValue(function () {
3721
3538
  _this5._loadRule(_this5.rules);
3722
-
3723
3539
  _this5.loading = false;
3724
-
3725
3540
  if (_this5.cycleLoad && _this5.pageEnd) {
3726
3541
  return _this5.loadRule();
3727
3542
  }
3728
-
3729
3543
  if (_this5.pageEnd) {
3730
3544
  _this5.bus.$emit('load-end');
3731
3545
  }
3732
-
3733
3546
  _this5.vm._renderRule();
3734
-
3735
3547
  _this5.$render.initOrgChildren();
3736
-
3737
3548
  _this5.syncForm();
3738
3549
  });
3739
3550
  },
@@ -3741,79 +3552,60 @@
3741
3552
  this.cycleLoad = false;
3742
3553
  this.loading = true;
3743
3554
  this.bus.$emit('load-start');
3744
-
3745
3555
  this._loadRule(children, parent);
3746
-
3747
3556
  this.loading = false;
3748
-
3749
3557
  if (this.cycleLoad) {
3750
3558
  return this.loadRule();
3751
3559
  } else {
3752
3560
  this.bus.$emit('load-end');
3753
3561
  this.syncForm();
3754
3562
  }
3755
-
3756
3563
  this.$render.clearCache(parent);
3757
3564
  },
3758
3565
  _loadRule: function _loadRule(rules, parent) {
3759
3566
  var _this6 = this;
3760
-
3761
3567
  var preIndex = function preIndex(i) {
3762
3568
  var pre = rules[i - 1];
3763
-
3764
3569
  if (!pre || !pre.__fc__) {
3765
3570
  return i > 0 ? preIndex(i - 1) : -1;
3766
3571
  }
3767
-
3768
3572
  var index = _this6.sort.indexOf(pre.__fc__.id);
3769
-
3770
3573
  return index > -1 ? index : preIndex(i - 1);
3771
3574
  };
3772
-
3773
3575
  var loadChildren = function loadChildren(children, parent) {
3774
3576
  if (is.trueArray(children)) {
3775
3577
  _this6._loadRule(children, parent);
3776
3578
  }
3777
3579
  };
3778
-
3779
3580
  rules.map(function (_rule, index) {
3780
3581
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3781
3582
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3782
3583
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3783
-
3784
3584
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3785
3585
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3786
3586
  return _rule.__fc__;
3787
3587
  }
3788
-
3789
3588
  var rule = getRule(_rule);
3790
-
3791
3589
  var isRepeat = function isRepeat() {
3792
3590
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3793
3591
  };
3794
-
3795
3592
  _this6.ruleEffect(rule, 'init', {
3796
3593
  repeat: isRepeat()
3797
3594
  });
3798
-
3799
3595
  if (isRepeat()) {
3800
3596
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3801
3597
  }
3802
-
3803
3598
  var ctx;
3804
3599
  var isCopy = false;
3805
3600
  var isInit = !!_rule.__fc__;
3806
-
3807
3601
  if (isInit) {
3808
3602
  ctx = _rule.__fc__;
3809
3603
  var check = !ctx.check(_this6);
3810
-
3811
3604
  if (ctx.deleted) {
3812
3605
  if (check) {
3813
3606
  if (isCtrl(ctx)) {
3814
3607
  return;
3815
3608
  }
3816
-
3817
3609
  ctx.update(_this6);
3818
3610
  }
3819
3611
  } else {
@@ -3821,66 +3613,49 @@
3821
3613
  if (isCtrl(ctx)) {
3822
3614
  return;
3823
3615
  }
3824
-
3825
3616
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3826
3617
  ctx = null;
3827
3618
  isCopy = true;
3828
3619
  }
3829
3620
  }
3830
3621
  }
3831
-
3832
3622
  if (!ctx) {
3833
3623
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3834
-
3835
3624
  _this6.bindParser(ctx);
3836
3625
  } else {
3837
3626
  if (ctx.originType !== ctx.rule.type) {
3838
3627
  ctx.updateType();
3839
-
3840
3628
  _this6.bindParser(ctx);
3841
3629
  }
3842
-
3843
3630
  _this6.appendValue(ctx.rule);
3844
3631
  }
3845
-
3846
3632
  [false, true].forEach(function (b) {
3847
3633
  return _this6.parseEmit(ctx, b);
3848
3634
  });
3849
-
3850
3635
  _this6.syncProp(ctx);
3851
-
3852
3636
  ctx.parent = parent || null;
3853
3637
  ctx.root = rules;
3854
-
3855
3638
  _this6.setCtx(ctx);
3856
-
3857
3639
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3858
3640
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3859
-
3860
3641
  if (!parent) {
3861
3642
  var _preIndex = preIndex(index);
3862
-
3863
3643
  if (_preIndex > -1 || !index) {
3864
3644
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3865
3645
  } else {
3866
3646
  _this6.sort.push(ctx.id);
3867
3647
  }
3868
3648
  }
3869
-
3870
3649
  var r = ctx.rule;
3871
-
3872
3650
  if (!ctx.updated) {
3873
3651
  ctx.updated = true;
3874
-
3875
3652
  if (is.Function(r.update)) {
3876
3653
  _this6.bus.$once('load-end', function () {
3877
3654
  _this6.refreshUpdate(ctx, r.value);
3878
3655
  });
3879
3656
  }
3880
-
3881
3657
  _this6.effect(ctx, 'loaded');
3882
3658
  }
3883
-
3884
3659
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3885
3660
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3886
3661
  return ctx;
@@ -3891,20 +3666,16 @@
3891
3666
  },
3892
3667
  useCtrl: function useCtrl(ctx) {
3893
3668
  var _this7 = this;
3894
-
3895
3669
  var controls = getCtrl(ctx),
3896
3670
  validate = [],
3897
3671
  api = this.api;
3898
3672
  if (!controls.length) return false;
3899
-
3900
3673
  var _loop = function _loop(i) {
3901
3674
  var control = controls[i],
3902
3675
  handleFn = control.handle || function (val) {
3903
3676
  return val === control.value;
3904
3677
  };
3905
-
3906
3678
  if (!is.trueArray(control.rule)) return "continue";
3907
-
3908
3679
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3909
3680
  valid: invoke(function () {
3910
3681
  return handleFn(ctx.rule.value, api);
@@ -3912,17 +3683,13 @@
3912
3683
  ctrl: findCtrl(ctx, control.rule),
3913
3684
  isHidden: is.String(control.rule[0])
3914
3685
  });
3915
-
3916
3686
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3917
3687
  validate.push(data);
3918
3688
  };
3919
-
3920
3689
  for (var i = 0; i < controls.length; i++) {
3921
3690
  var _ret = _loop(i);
3922
-
3923
3691
  if (_ret === "continue") continue;
3924
3692
  }
3925
-
3926
3693
  if (!validate.length) return false;
3927
3694
  var flag = false;
3928
3695
  this.deferSyncValue(function () {
@@ -3934,21 +3701,17 @@
3934
3701
  append = _ref.append,
3935
3702
  child = _ref.child,
3936
3703
  ctrl = _ref.ctrl;
3937
-
3938
3704
  if (isHidden) {
3939
3705
  valid ? ctx.ctrlRule.push({
3940
3706
  __ctrl: true,
3941
3707
  children: rule,
3942
3708
  valid: valid
3943
3709
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3944
-
3945
3710
  _this7.vm.$nextTick(function () {
3946
3711
  _this7.api.hidden(!valid, rule);
3947
3712
  });
3948
-
3949
3713
  return;
3950
3714
  }
3951
-
3952
3715
  if (valid) {
3953
3716
  flag = true;
3954
3717
  var ruleCon = {
@@ -3958,9 +3721,7 @@
3958
3721
  children: rule
3959
3722
  };
3960
3723
  ctx.ctrlRule.push(ruleCon);
3961
-
3962
3724
  _this7.bus.$once('load-start', function () {
3963
- // this.cycleLoad = true;
3964
3725
  if (prepend) {
3965
3726
  api.prepend(ruleCon, prepend, child);
3966
3727
  } else if (append || child) {
@@ -3985,60 +3746,53 @@
3985
3746
  },
3986
3747
  _reloadRule: function _reloadRule(rules) {
3987
3748
  var _this8 = this;
3988
-
3989
- // console.warn('%c reload', 'color:red');
3990
3749
  if (!rules) rules = this.rules;
3991
-
3992
3750
  var ctxs = _objectSpread2({}, this.ctxs);
3993
-
3994
3751
  this.clearNextTick();
3995
3752
  this.$render.clearOrgChildren();
3996
3753
  this.initData(rules);
3997
3754
  this.fc.rules = rules;
3998
- this.bus.$once('load-end', function () {
3999
- Object.keys(ctxs).filter(function (id) {
4000
- return _this8.ctxs[id] === undefined;
4001
- }).forEach(function (id) {
4002
- return _this8.rmCtx(ctxs[id]);
3755
+ this.deferSyncValue(function () {
3756
+ _this8.bus.$once('load-end', function () {
3757
+ Object.keys(ctxs).filter(function (id) {
3758
+ return _this8.ctxs[id] === undefined;
3759
+ }).forEach(function (id) {
3760
+ return _this8.rmCtx(ctxs[id]);
3761
+ });
3762
+ _this8.$render.clearCacheAll();
4003
3763
  });
4004
-
4005
- _this8.$render.clearCacheAll();
3764
+ _this8.reloading = true;
3765
+ _this8.loadRule();
3766
+ _this8.reloading = false;
3767
+ _this8.refresh();
3768
+ _this8.vm.$emit('reload', _this8.api);
4006
3769
  });
4007
- this.reloading = true;
4008
- this.loadRule();
4009
- this.reloading = false;
4010
- this.refresh();
4011
3770
  this.bus.$off('next-tick', this.nextReload);
4012
3771
  this.bus.$once('next-tick', this.nextReload);
4013
3772
  this.vm.$emit('update', this.api);
4014
3773
  },
4015
- //todo 组件生成全部通过 alias
4016
3774
  refresh: function refresh() {
4017
3775
  this.vm._refresh();
4018
3776
  }
4019
3777
  });
4020
3778
  }
4021
-
4022
3779
  function fullRule(rule) {
4023
3780
  var def = baseRule();
4024
3781
  Object.keys(def).forEach(function (k) {
4025
- if (!hasProperty(rule, k)) rule[k] = def[k];
3782
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4026
3783
  });
4027
3784
  return rule;
4028
3785
  }
4029
-
4030
3786
  function getCtrl(ctx) {
4031
3787
  var control = ctx.rule.control || [];
4032
3788
  if (is.Object(control)) return [control];else return control;
4033
3789
  }
4034
-
4035
3790
  function findCtrl(ctx, rule) {
4036
3791
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4037
3792
  var ctrl = ctx.ctrlRule[i];
4038
3793
  if (ctrl.children === rule) return ctrl;
4039
3794
  }
4040
3795
  }
4041
-
4042
3796
  function isCtrl(ctx) {
4043
3797
  return !!ctx.rule.__ctrl;
4044
3798
  }
@@ -4049,7 +3803,6 @@
4049
3803
  if (is.Undef(ctx.cacheValue)) {
4050
3804
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4051
3805
  }
4052
-
4053
3806
  return ctx.cacheValue;
4054
3807
  },
4055
3808
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4066,7 +3819,6 @@
4066
3819
  },
4067
3820
  onInput: function onInput(ctx, value) {
4068
3821
  var val;
4069
-
4070
3822
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4071
3823
  this.setValue(ctx, val, value);
4072
3824
  }
@@ -4079,7 +3831,6 @@
4079
3831
  },
4080
3832
  validate: function validate() {
4081
3833
  var _this = this;
4082
-
4083
3834
  toEmpty(this.vm.validate);
4084
3835
  this.fields().forEach(function (id) {
4085
3836
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4090,17 +3841,14 @@
4090
3841
  },
4091
3842
  syncForm: function syncForm() {
4092
3843
  var _this2 = this;
4093
-
4094
3844
  toEmpty(this.form);
4095
3845
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4096
3846
  var ctx = _this2.getFieldCtx(field);
4097
-
4098
3847
  var handle = _this2.valueHandle(ctx);
4099
-
4100
3848
  handle.configurable = true;
4101
3849
  initial[field] = handle;
4102
3850
  return initial;
4103
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3851
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4104
3852
  initial[field] = {
4105
3853
  enumerable: true,
4106
3854
  configurable: true,
@@ -4112,12 +3860,11 @@
4112
3860
  }
4113
3861
  };
4114
3862
  return initial;
4115
- }, {})));
3863
+ }, {}) : {}));
4116
3864
  this.syncValue();
4117
3865
  },
4118
3866
  valueHandle: function valueHandle(ctx) {
4119
3867
  var _this3 = this;
4120
-
4121
3868
  return {
4122
3869
  enumerable: true,
4123
3870
  get: function get() {
@@ -4136,24 +3883,18 @@
4136
3883
  delete this.appendData[rule.field];
4137
3884
  },
4138
3885
  addSubForm: function addSubForm(ctx, subForm) {
4139
- if (ctx.input) {
4140
- this.subForm[ctx.id] = subForm;
4141
- }
3886
+ this.subForm[ctx.id] = subForm;
4142
3887
  },
4143
3888
  deferSyncValue: function deferSyncValue(fn, sync) {
4144
3889
  if (!this.deferSyncFn) {
4145
3890
  this.deferSyncFn = fn;
4146
3891
  }
4147
-
4148
3892
  if (!this.deferSyncFn.sync) {
4149
3893
  this.deferSyncFn.sync = sync;
4150
3894
  }
4151
-
4152
3895
  invoke(fn);
4153
-
4154
3896
  if (this.deferSyncFn === fn) {
4155
3897
  this.deferSyncFn = null;
4156
-
4157
3898
  if (fn.sync) {
4158
3899
  this.syncValue();
4159
3900
  }
@@ -4163,18 +3904,16 @@
4163
3904
  if (this.deferSyncFn) {
4164
3905
  return this.deferSyncFn.sync = true;
4165
3906
  }
4166
-
4167
3907
  this.vm._updateValue(_objectSpread2({}, this.form));
4168
3908
  },
4169
3909
  isChange: function isChange(ctx, value) {
4170
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3910
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4171
3911
  },
4172
3912
  isQuote: function isQuote(ctx, value) {
4173
3913
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4174
3914
  },
4175
3915
  refreshUpdate: function refreshUpdate(ctx, val) {
4176
3916
  var _this4 = this;
4177
-
4178
3917
  if (is.Function(ctx.rule.update)) {
4179
3918
  var state = invoke(function () {
4180
3919
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4194,20 +3933,16 @@
4194
3933
  this.vm.$emit('update', this.api);
4195
3934
  this.refresh();
4196
3935
  }
4197
-
4198
3936
  this.refreshUpdate(ctx, val);
4199
3937
  },
4200
3938
  appendLink: function appendLink(ctx) {
4201
3939
  var _this5 = this;
4202
-
4203
3940
  var link = ctx.rule.link;
4204
3941
  is.trueArray(link) && link.forEach(function (field) {
4205
3942
  var fn = function fn() {
4206
3943
  return _this5.refreshRule(ctx, ctx.rule.value);
4207
3944
  };
4208
-
4209
3945
  _this5.bus.$on('change-' + field, fn);
4210
-
4211
3946
  ctx.linkOn.push(function () {
4212
3947
  return _this5.bus.$off('change-' + field, fn);
4213
3948
  });
@@ -4218,11 +3953,9 @@
4218
3953
  }
4219
3954
  });
4220
3955
  }
4221
-
4222
3956
  function strFn(key, val) {
4223
3957
  return typeof val === 'function' ? '' + val : val;
4224
3958
  }
4225
-
4226
3959
  function toEmpty(obj) {
4227
3960
  Object.keys(obj).forEach(function (k) {
4228
3961
  return delete obj[k];
@@ -4242,11 +3975,12 @@
4242
3975
  return ctx.$render.defaultRender(ctx, children);
4243
3976
  },
4244
3977
  preview: function preview(children, ctx) {
4245
- return ctx.$render.defaultRender(ctx, children);
3978
+ return this.render(children, ctx);
4246
3979
  },
4247
3980
  mergeProp: function mergeProp(ctx) {}
4248
3981
  };
4249
3982
 
3983
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4250
3984
  function useContext(Handler) {
4251
3985
  extend(Handler.prototype, {
4252
3986
  getCtx: function getCtx(id) {
@@ -4257,7 +3991,6 @@
4257
3991
  },
4258
3992
  setIdCtx: function setIdCtx(ctx, key, type) {
4259
3993
  var field = "".concat(type, "Ctx");
4260
-
4261
3994
  if (!this[field][key]) {
4262
3995
  this[field][key] = [ctx];
4263
3996
  } else {
@@ -4269,11 +4002,9 @@
4269
4002
  var lst = this[field][key];
4270
4003
  if (!lst) return false;
4271
4004
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4272
-
4273
4005
  if (!lst.length) {
4274
4006
  delete this[field][key];
4275
4007
  }
4276
-
4277
4008
  return flag;
4278
4009
  },
4279
4010
  getFieldCtx: function getFieldCtx(field) {
@@ -4292,7 +4023,6 @@
4292
4023
  if (!ctx.input) return;
4293
4024
  this.setIdCtx(ctx, field, 'field');
4294
4025
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4295
-
4296
4026
  if (this.isMounted && !this.reloading) {
4297
4027
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4298
4028
  }
@@ -4313,70 +4043,51 @@
4313
4043
  if (!this.noWatchFn) {
4314
4044
  this.noWatchFn = fn;
4315
4045
  }
4316
-
4317
4046
  invoke(fn);
4318
-
4319
4047
  if (this.noWatchFn === fn) {
4320
4048
  this.noWatchFn = null;
4321
4049
  }
4322
4050
  },
4323
4051
  watchCtx: function watchCtx(ctx) {
4324
4052
  var _this = this;
4325
-
4326
4053
  var vm = this.vm;
4327
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4328
4054
  Object.keys(ctx.rule).filter(function (k) {
4329
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4055
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4330
4056
  }).forEach(function (key) {
4331
4057
  var flag = key === 'children';
4332
4058
  ctx.watch.push(vm.$watch(function () {
4333
4059
  return ctx.rule[key];
4334
4060
  }, function (n, o) {
4335
4061
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4336
-
4337
4062
  if (flag && ctx.parser.loadChildren === false) {
4338
4063
  _this.$render.clearCache(ctx);
4339
-
4340
4064
  _this.nextRefresh();
4341
-
4342
4065
  return;
4343
4066
  }
4344
-
4345
- _this.watching = true; // if (key === 'hidden')
4346
- // ctx.updateKey(true);
4347
- // else
4348
-
4067
+ _this.watching = true;
4349
4068
  if (key === 'link') {
4350
4069
  ctx.link();
4351
4070
  return;
4352
4071
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4353
4072
  _this.parseInjectEvent(ctx.rule, n || {});
4354
-
4355
4073
  if (key === 'props' && ctx.input) {
4356
4074
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4357
4075
  }
4358
4076
  } else if (['emit', 'nativeEmit'].indexOf(key) > -1) _this.parseEmit(ctx, key === 'emit');else if (['prefix', 'suffix'].indexOf(key) > -1) n && _this.loadFn(n, ctx.rule);else if (key === 'type') {
4359
4077
  ctx.updateType();
4360
-
4361
4078
  _this.bindParser(ctx);
4362
4079
  } else if (key === 'children') {
4363
4080
  var _flag = is.trueArray(n);
4364
-
4365
4081
  _this.deferSyncValue(function () {
4366
4082
  if (n !== o) {
4367
4083
  _this.rmSub(o);
4368
-
4369
4084
  _this.$render.initOrgChildren();
4370
4085
  }
4371
-
4372
4086
  _flag && _this.loadChildren(n, ctx);
4373
-
4374
4087
  _this.vm.$emit('update', _this.api);
4375
4088
  });
4376
4089
  }
4377
-
4378
4090
  _this.$render.clearCache(ctx);
4379
-
4380
4091
  _this.watching = false;
4381
4092
  }, {
4382
4093
  deep: !flag,
@@ -4387,27 +4098,23 @@
4387
4098
  },
4388
4099
  rmSub: function rmSub(sub) {
4389
4100
  var _this2 = this;
4390
-
4391
4101
  is.trueArray(sub) && sub.forEach(function (r) {
4392
4102
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4393
4103
  });
4394
4104
  },
4395
4105
  rmCtx: function rmCtx(ctx) {
4396
4106
  var _this3 = this;
4397
-
4398
4107
  if (ctx.deleted) return;
4399
4108
  var id = ctx.id,
4400
4109
  field = ctx.field,
4401
4110
  input = ctx.input,
4402
4111
  name = ctx.name;
4403
-
4404
4112
  if (ctx.input) {
4405
4113
  Object.defineProperty(ctx.rule, 'value', {
4406
4114
  value: ctx.rule.value,
4407
4115
  writable: true
4408
4116
  });
4409
4117
  }
4410
-
4411
4118
  $del(this.ctxs, id);
4412
4119
  $del(this.$render.tempList, id);
4413
4120
  $del(this.$render.orgChildren, id);
@@ -4415,6 +4122,7 @@
4415
4122
  $del(this.formData, id);
4416
4123
  $del(this.subForm, id);
4417
4124
  $del(ctx, 'cacheValue');
4125
+ input && $del(this.form, field);
4418
4126
  input && this.rmIdCtx(ctx, field, 'field');
4419
4127
  name && this.rmIdCtx(ctx, name, 'name');
4420
4128
  this.deferSyncValue(function () {
@@ -4426,18 +4134,15 @@
4426
4134
  });
4427
4135
  }
4428
4136
  }
4429
-
4430
4137
  if (ctx.root === _this3.rules) {
4431
4138
  _this3.vm._renderRule();
4432
4139
  }
4433
4140
  }
4434
4141
  }, input);
4435
4142
  var index = this.sort.indexOf(id);
4436
-
4437
4143
  if (index > -1) {
4438
4144
  this.sort.splice(index, 1);
4439
4145
  }
4440
-
4441
4146
  this.$render.clearCache(ctx);
4442
4147
  ctx["delete"]();
4443
4148
  this.effect(ctx, 'deleted');
@@ -4452,13 +4157,10 @@
4452
4157
  extend(Handler.prototype, {
4453
4158
  mounted: function mounted() {
4454
4159
  var _this = this;
4455
-
4456
4160
  var _mounted = function _mounted() {
4457
4161
  _this.isMounted = true;
4458
-
4459
4162
  _this.lifecycle('mounted');
4460
4163
  };
4461
-
4462
4164
  if (this.pageEnd) {
4463
4165
  _mounted();
4464
4166
  } else {
@@ -4467,7 +4169,6 @@
4467
4169
  },
4468
4170
  lifecycle: function lifecycle(name) {
4469
4171
  var _this2 = this;
4470
-
4471
4172
  var fn = this.options[name];
4472
4173
  is.Function(fn) && invoke(function () {
4473
4174
  return fn(_this2.api);
@@ -4481,26 +4182,21 @@
4481
4182
  extend(Handler.prototype, {
4482
4183
  useProvider: function useProvider() {
4483
4184
  var _this = this;
4484
-
4485
4185
  var ps = this.fc.providers;
4486
4186
  Object.keys(ps).forEach(function (k) {
4487
4187
  var prop = ps[k];
4488
4188
  prop._c = getComponent(prop);
4489
-
4490
4189
  _this.onEffect(prop);
4491
-
4492
4190
  _this.providers[k] = prop;
4493
4191
  });
4494
4192
  },
4495
4193
  onEffect: function onEffect(provider) {
4496
4194
  var _this2 = this;
4497
-
4498
4195
  var used = [];
4499
4196
  (provider._c || ['*']).forEach(function (name) {
4500
4197
  var type = name === '*' ? '*' : _this2.getType(name);
4501
4198
  if (used.indexOf(type) > -1) return;
4502
4199
  used.push(type);
4503
-
4504
4200
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4505
4201
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4506
4202
  });
@@ -4509,7 +4205,6 @@
4509
4205
  },
4510
4206
  watchEffect: function watchEffect(ctx) {
4511
4207
  var _this3 = this;
4512
-
4513
4208
  var vm = this.vm;
4514
4209
  var effect = {};
4515
4210
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
@@ -4552,13 +4247,11 @@
4552
4247
  if (hasProperty(rule, '$' + name)) {
4553
4248
  return rule['$' + name];
4554
4249
  }
4555
-
4556
4250
  if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4557
4251
  return undefined;
4558
4252
  },
4559
4253
  emitEffect: function emitEffect(_ref, event, append) {
4560
4254
  var _this4 = this;
4561
-
4562
4255
  var ctx = _ref.ctx,
4563
4256
  rule = _ref.rule,
4564
4257
  input = _ref.input,
@@ -4569,15 +4262,12 @@
4569
4262
  if (k[0] === '$') {
4570
4263
  i[k.substr(1)] = rule[k];
4571
4264
  }
4572
-
4573
4265
  return i;
4574
4266
  }, _objectSpread2({}, rule.effect || {}));
4575
4267
  Object.keys(effect).forEach(function (attr) {
4576
4268
  var p = _this4.providers[attr];
4577
4269
  if (!p || p.input && !input) return;
4578
-
4579
4270
  var _type;
4580
-
4581
4271
  if (!p._c) {
4582
4272
  _type = '*';
4583
4273
  } else if (p._used.indexOf(type) > -1) {
@@ -4585,40 +4275,33 @@
4585
4275
  } else {
4586
4276
  return;
4587
4277
  }
4588
-
4589
4278
  var data = _objectSpread2({
4590
4279
  value: effect[attr],
4591
4280
  getValue: function getValue() {
4592
4281
  return _this4.getEffect(rule, attr);
4593
4282
  }
4594
4283
  }, append || {});
4595
-
4596
4284
  if (ctx) {
4597
4285
  data.getProp = function () {
4598
4286
  return ctx.effectData(attr);
4599
4287
  };
4600
-
4601
4288
  data.clearProp = function () {
4602
4289
  return ctx.clearEffectData(attr);
4603
4290
  };
4604
-
4605
4291
  data.mergeProp = function (prop) {
4606
4292
  return mergeProps([prop], data.getProp());
4607
4293
  };
4608
4294
  }
4609
-
4610
4295
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4611
4296
  });
4612
4297
  }
4613
4298
  });
4614
4299
  }
4615
-
4616
4300
  function unique(arr) {
4617
4301
  return arr.filter(function (item, index, arr) {
4618
4302
  return arr.indexOf(item, 0) === index;
4619
4303
  });
4620
4304
  }
4621
-
4622
4305
  function getComponent(p) {
4623
4306
  var c = p.components;
4624
4307
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4628,7 +4311,6 @@
4628
4311
 
4629
4312
  function Handler(fc) {
4630
4313
  var _this = this;
4631
-
4632
4314
  extend(this, {
4633
4315
  fc: fc,
4634
4316
  vm: fc.vm,
@@ -4680,9 +4362,7 @@
4680
4362
  this.useProvider();
4681
4363
  this.usePage();
4682
4364
  this.loadRule();
4683
-
4684
4365
  this.$manager.__init();
4685
-
4686
4366
  this.vm.$set(this.vm, 'formData', this.formData);
4687
4367
  }
4688
4368
  });
@@ -4695,7 +4375,6 @@
4695
4375
  useLifecycle(Handler);
4696
4376
  useEffect(Handler);
4697
4377
 
4698
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4699
4378
  function getError(action, option, xhr) {
4700
4379
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4701
4380
  var err = new Error(msg);
@@ -4703,44 +4382,34 @@
4703
4382
  err.url = action;
4704
4383
  return err;
4705
4384
  }
4706
-
4707
4385
  function getBody(xhr) {
4708
4386
  var text = xhr.responseText || xhr.response;
4709
-
4710
4387
  if (!text) {
4711
4388
  return text;
4712
4389
  }
4713
-
4714
4390
  try {
4715
4391
  return JSON.parse(text);
4716
4392
  } catch (e) {
4717
4393
  return text;
4718
4394
  }
4719
4395
  }
4720
-
4721
4396
  function fetch(option) {
4722
4397
  if (typeof XMLHttpRequest === 'undefined') {
4723
4398
  return;
4724
4399
  }
4725
-
4726
4400
  var xhr = new XMLHttpRequest();
4727
4401
  var action = option.action;
4728
-
4729
4402
  xhr.onerror = function error(e) {
4730
4403
  option.onError(e);
4731
4404
  };
4732
-
4733
4405
  xhr.onload = function onload() {
4734
4406
  if (xhr.status < 200 || xhr.status >= 300) {
4735
4407
  return option.onError(getError(action, option, xhr), getBody(xhr));
4736
4408
  }
4737
-
4738
4409
  option.onSuccess(getBody(xhr));
4739
4410
  };
4740
-
4741
4411
  xhr.open(option.method || 'get', action, true);
4742
4412
  var formData;
4743
-
4744
4413
  if (option.data) {
4745
4414
  if ((option.dataType || '').toLowerCase() !== 'json') {
4746
4415
  formData = new FormData();
@@ -4752,11 +4421,9 @@
4752
4421
  xhr.setRequestHeader('content-type', 'application/json');
4753
4422
  }
4754
4423
  }
4755
-
4756
4424
  if (option.withCredentials && 'withCredentials' in xhr) {
4757
4425
  xhr.withCredentials = true;
4758
4426
  }
4759
-
4760
4427
  var headers = option.headers || {};
4761
4428
  Object.keys(headers).forEach(function (item) {
4762
4429
  if (headers[item] !== null) {
@@ -4784,14 +4451,11 @@
4784
4451
  };
4785
4452
  return prop;
4786
4453
  }
4787
-
4788
4454
  function CreateNodeFactory() {
4789
4455
  var aliasMap = {};
4790
-
4791
4456
  function CreateNode(vm) {
4792
4457
  vm && this.setVm(vm);
4793
4458
  }
4794
-
4795
4459
  extend(CreateNode.prototype, {
4796
4460
  setVm: function setVm(vm) {
4797
4461
  this.vm = vm;
@@ -4799,7 +4463,10 @@
4799
4463
  },
4800
4464
  make: function make(tag, data, children) {
4801
4465
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4802
- var Node = this.$h(tag, parseProp(data), children || []);
4466
+ return this.makeComponent(tag, data, children);
4467
+ },
4468
+ makeComponent: function makeComponent(type, data, children) {
4469
+ var Node = this.$h(type, parseProp(data), children || []);
4803
4470
  Node.context = this.vm;
4804
4471
  return Node;
4805
4472
  },
@@ -4817,7 +4484,6 @@
4817
4484
  var v = nodes[k];
4818
4485
  [k, line, lower].forEach(function (n) {
4819
4486
  CreateNode.alias(k, v);
4820
-
4821
4487
  CreateNode.prototype[n] = function (data, children) {
4822
4488
  return this.make(v, data, children);
4823
4489
  };
@@ -4829,20 +4495,15 @@
4829
4495
  }
4830
4496
 
4831
4497
  function createManager(proto) {
4832
- var CustomManager = /*#__PURE__*/function (_Manager) {
4498
+ var CustomManager = function (_Manager) {
4833
4499
  _inherits(CustomManager, _Manager);
4834
-
4835
4500
  var _super = _createSuper(CustomManager);
4836
-
4837
4501
  function CustomManager() {
4838
4502
  _classCallCheck(this, CustomManager);
4839
-
4840
4503
  return _super.apply(this, arguments);
4841
4504
  }
4842
-
4843
4505
  return CustomManager;
4844
4506
  }(Manager);
4845
-
4846
4507
  Object.assign(CustomManager.prototype, proto);
4847
4508
  return CustomManager;
4848
4509
  }
@@ -4862,19 +4523,15 @@
4862
4523
  extend(Manager.prototype, {
4863
4524
  __init: function __init() {
4864
4525
  var _this = this;
4865
-
4866
4526
  this.$render = this.$handle.$render;
4867
-
4868
4527
  this.$r = function () {
4869
4528
  var _this$$render;
4870
-
4871
4529
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4872
4530
  };
4873
4531
  },
4874
4532
  updateKey: function updateKey() {
4875
4533
  this.key = uniqueId();
4876
4534
  },
4877
- //TODO interface
4878
4535
  init: function init() {},
4879
4536
  update: function update() {},
4880
4537
  beforeRender: function beforeRender() {},
@@ -4883,7 +4540,6 @@
4883
4540
  },
4884
4541
  mergeOptions: function mergeOptions(args, opt) {
4885
4542
  var _this2 = this;
4886
-
4887
4543
  return mergeProps(args.map(function (v) {
4888
4544
  return _this2.tidyOptions(v);
4889
4545
  }), opt, this.mergeOptionsRule);
@@ -4919,7 +4575,6 @@
4919
4575
  name: 'required',
4920
4576
  load: function load(inject, rule, api) {
4921
4577
  var val = parseVa(inject.getValue());
4922
-
4923
4578
  if (val.required === false) {
4924
4579
  inject.clearProp();
4925
4580
  } else {
@@ -4929,21 +4584,17 @@
4929
4584
  is.empty(v) ? call(validate.message) : call();
4930
4585
  }
4931
4586
  });
4932
-
4933
4587
  if (!validate.message) {
4934
4588
  validate.message = rule.title + ' is required';
4935
4589
  }
4936
-
4937
4590
  inject.getProp().validate = [validate];
4938
4591
  }
4939
-
4940
4592
  api.sync(rule);
4941
4593
  },
4942
4594
  watch: function watch() {
4943
4595
  $required.load.apply($required, arguments);
4944
4596
  }
4945
4597
  };
4946
-
4947
4598
  function parseVa(val) {
4948
4599
  if (is.Boolean(val)) {
4949
4600
  return {
@@ -4959,7 +4610,6 @@
4959
4610
  return val;
4960
4611
  }
4961
4612
  }
4962
-
4963
4613
  function parseOpt(option) {
4964
4614
  if (is.String(option)) {
4965
4615
  option = {
@@ -4967,29 +4617,21 @@
4967
4617
  to: 'options'
4968
4618
  };
4969
4619
  }
4970
-
4971
4620
  return option;
4972
4621
  }
4973
-
4974
4622
  function run(inject, rule, api) {
4975
4623
  var option = inject.value;
4976
-
4977
4624
  if (is.Function(option)) {
4978
4625
  option = option(rule, api);
4979
4626
  }
4980
-
4981
4627
  option = parseOpt(option);
4982
-
4983
4628
  if (!option || !option.action) {
4984
4629
  return false;
4985
4630
  }
4986
-
4987
4631
  if (!option.to) {
4988
4632
  option.to = 'options';
4989
4633
  }
4990
-
4991
4634
  var _onError = option.onError;
4992
-
4993
4635
  var check = function check() {
4994
4636
  if (!inject.getValue()) {
4995
4637
  inject.clearProp();
@@ -4997,7 +4639,6 @@
4997
4639
  return true;
4998
4640
  }
4999
4641
  };
5000
-
5001
4642
  var set = function set(val) {
5002
4643
  if (val === undefined) {
5003
4644
  inject.clearProp();
@@ -5006,7 +4647,6 @@
5006
4647
  deepSet(inject.getProp(), option.to, val);
5007
4648
  }
5008
4649
  };
5009
-
5010
4650
  invoke(function () {
5011
4651
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5012
4652
  onSuccess: function onSuccess(body) {
@@ -5019,7 +4659,6 @@
5019
4659
  onError: function onError(e) {
5020
4660
  set(undefined);
5021
4661
  if (check()) return;
5022
-
5023
4662
  (_onError || function (e) {
5024
4663
  return err(e.message || 'fetch fail ' + option.action);
5025
4664
  })(e, rule, api);
@@ -5028,7 +4667,6 @@
5028
4667
  });
5029
4668
  return true;
5030
4669
  }
5031
-
5032
4670
  var $provider = {
5033
4671
  fetch: $fetch,
5034
4672
  required: $required
@@ -5049,42 +4687,34 @@
5049
4687
  return is.String(v);
5050
4688
  }).join('');
5051
4689
  }
5052
-
5053
4690
  return '';
5054
4691
  }
5055
4692
  };
5056
4693
 
5057
4694
  var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
5058
-
5059
4695
  function _parseProp(name, id) {
5060
4696
  var prop;
5061
-
5062
4697
  if (arguments.length === 2) {
5063
4698
  prop = arguments[1];
5064
4699
  id = prop[name];
5065
4700
  } else {
5066
4701
  prop = arguments[2];
5067
4702
  }
5068
-
5069
4703
  return {
5070
4704
  id: id,
5071
4705
  prop: prop
5072
4706
  };
5073
4707
  }
5074
-
5075
4708
  function nameProp() {
5076
4709
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
5077
4710
  }
5078
-
5079
4711
  function _getEl(options) {
5080
4712
  if (!options || !options.el) return window.document.body;
5081
4713
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
5082
4714
  }
5083
-
5084
4715
  function mountForm(rules, option) {
5085
4716
  var $vm = new _vue({
5086
4717
  data: function data() {
5087
- //todo 外部无法修改
5088
4718
  return {
5089
4719
  rule: rules,
5090
4720
  option: option || {}
@@ -5100,7 +4730,6 @@
5100
4730
  $vm.$mount();
5101
4731
  return $vm;
5102
4732
  }
5103
-
5104
4733
  function exportAttrs(attrs) {
5105
4734
  var key = attrs.key || [];
5106
4735
  var array = attrs.array || [];
@@ -5110,18 +4739,13 @@
5110
4739
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
5111
4740
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
5112
4741
  }
5113
-
5114
4742
  var id$1 = 1;
5115
- var instance = {}; //todo 表单嵌套
5116
-
4743
+ var instance = {};
5117
4744
  function FormCreateFactory(config) {
5118
4745
  var components = _defineProperty({}, fragment.name, fragment);
5119
-
5120
4746
  var parsers = {};
5121
4747
  var directives = {};
5122
-
5123
4748
  var providers = _objectSpread2({}, $provider);
5124
-
5125
4749
  var maker = makerFactory();
5126
4750
  var globalConfig = {
5127
4751
  global: {}
@@ -5129,27 +4753,24 @@
5129
4753
  var data = {};
5130
4754
  var CreateNode = CreateNodeFactory();
5131
4755
  exportAttrs(config.attrs || {});
5132
-
5133
4756
  function getApi(name) {
5134
- return instance[name];
4757
+ var val = instance[name];
4758
+ if (Array.isArray(val)) return _toConsumableArray(val);
4759
+ return val;
5135
4760
  }
5136
-
5137
4761
  function directive() {
5138
4762
  var data = nameProp.apply(void 0, arguments);
5139
4763
  if (data.id && data.prop) directives[data.id] = data.prop;
5140
4764
  }
5141
-
5142
4765
  function register() {
5143
4766
  var data = nameProp.apply(void 0, arguments);
5144
4767
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5145
4768
  name: data.id
5146
4769
  });
5147
4770
  }
5148
-
5149
4771
  function componentAlias(alias) {
5150
4772
  CreateNode.use(alias);
5151
4773
  }
5152
-
5153
4774
  function parser() {
5154
4775
  var data = nameProp.apply(void 0, arguments);
5155
4776
  if (!data.id || !data.prop) return;
@@ -5160,13 +4781,10 @@
5160
4781
  maker[name] = creatorFactory(name);
5161
4782
  parser.maker && extend(maker, parser.maker);
5162
4783
  }
5163
-
5164
4784
  function component(id, component) {
5165
4785
  var name;
5166
-
5167
4786
  if (is.String(id)) {
5168
4787
  name = toCase(id);
5169
-
5170
4788
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5171
4789
  return $form();
5172
4790
  } else if (component === undefined) {
@@ -5176,39 +4794,29 @@
5176
4794
  name = toCase(id.name);
5177
4795
  component = id;
5178
4796
  }
5179
-
5180
4797
  if (!name || !component) return;
5181
4798
  components[name] = component;
5182
4799
  if (component.formCreateParser) parser(name, component.formCreateParser);
5183
4800
  }
5184
-
5185
4801
  function $form() {
5186
4802
  return _vue.extend($FormCreate(FormCreate));
5187
4803
  }
5188
-
5189
4804
  function $vnode() {
5190
4805
  return _vue.extend(fragment);
5191
- } //todo 检查回调函数作用域
5192
-
5193
-
4806
+ }
5194
4807
  function use(fn, opt) {
5195
4808
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5196
4809
  return this;
5197
4810
  }
5198
-
5199
4811
  function create(rules, _opt, parent) {
5200
4812
  var $vm = mountForm(rules, _opt || {});
5201
4813
  var _this = $vm.$refs.fc.formCreate;
5202
4814
  _this.$parent = parent;
5203
-
5204
4815
  _getEl(_this.options).appendChild($vm.$el);
5205
-
5206
4816
  return _this.api();
5207
4817
  }
5208
-
5209
4818
  function factory(inherit) {
5210
4819
  var _config = _objectSpread2({}, config);
5211
-
5212
4820
  if (inherit) {
5213
4821
  _config.inherit = {
5214
4822
  components: components,
@@ -5221,10 +4829,8 @@
5221
4829
  } else {
5222
4830
  delete _config.inherit;
5223
4831
  }
5224
-
5225
4832
  return FormCreateFactory(_config);
5226
4833
  }
5227
-
5228
4834
  function FormCreate(vm, rules, options) {
5229
4835
  extend(this, {
5230
4836
  id: id$1++,
@@ -5235,6 +4841,7 @@
5235
4841
  providers: providers,
5236
4842
  rules: Array.isArray(rules) ? rules : [],
5237
4843
  name: vm.$options.propsData.name,
4844
+ inFor: vm.$options.propsData.inFor,
5238
4845
  prop: {
5239
4846
  components: components,
5240
4847
  directives: directives
@@ -5242,22 +4849,25 @@
5242
4849
  CreateNode: CreateNode,
5243
4850
  bus: new _vue(),
5244
4851
  unwatch: null,
4852
+ options: options || {},
5245
4853
  extendApi: config.extendApi || function (api) {
5246
4854
  return api;
5247
4855
  }
5248
4856
  });
5249
4857
  this.init();
5250
- this.initOptions(options || {});
5251
-
4858
+ this.initOptions(this.options);
5252
4859
  if (this.name) {
5253
- instance[this.name] = this.api();
4860
+ if (this.inFor) {
4861
+ if (!instance[this.name]) instance[this.name] = [];
4862
+ instance[this.name].push(this.api());
4863
+ } else {
4864
+ instance[this.name] = this.api();
4865
+ }
5254
4866
  }
5255
4867
  }
5256
-
5257
4868
  extend(FormCreate.prototype, {
5258
4869
  init: function init() {
5259
4870
  var _this2 = this;
5260
-
5261
4871
  var vm = this.vm;
5262
4872
  var h = new Handler(this);
5263
4873
  this.$handle = h;
@@ -5269,15 +4879,12 @@
5269
4879
  return vm.$pfc.option;
5270
4880
  }, function () {
5271
4881
  _this2.initOptions(_this2.options);
5272
-
5273
4882
  vm.$f.refresh();
5274
4883
  }, {
5275
4884
  deep: true
5276
4885
  });
5277
-
5278
4886
  _this2.initOptions(_this2.options);
5279
4887
  }
5280
-
5281
4888
  _this2.created();
5282
4889
  });
5283
4890
  vm.$on('hook:mounted', function () {
@@ -5287,9 +4894,13 @@
5287
4894
  vm.destroyed = true;
5288
4895
  _this2.unwatch && _this2.unwatch();
5289
4896
  h.reloadRule([]);
5290
-
5291
4897
  if (_this2.name) {
5292
- delete instance[_this2.name];
4898
+ if (_this2.inFor) {
4899
+ var idx = instance[_this2.name].indexOf(_this2.api());
4900
+ instance[_this2.name].splice(idx, 1);
4901
+ } else {
4902
+ delete instance[_this2.name];
4903
+ }
5293
4904
  }
5294
4905
  });
5295
4906
  vm.$on('hook:updated', function () {
@@ -5307,11 +4918,9 @@
5307
4918
  submitBtn: {},
5308
4919
  resetBtn: {}
5309
4920
  }, deepCopy(globalConfig));
5310
-
5311
4921
  if (this.isSub()) {
5312
4922
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5313
4923
  }
5314
-
5315
4924
  this.updateOptions(options);
5316
4925
  },
5317
4926
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5319,12 +4928,10 @@
5319
4928
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5320
4929
  delete opt[n];
5321
4930
  });
5322
-
5323
4931
  if (opt.global) {
5324
4932
  target.global = mergeGlobal(target.global, opt.global);
5325
4933
  delete opt.global;
5326
4934
  }
5327
-
5328
4935
  this.$handle.$manager.mergeOptions([opt], target);
5329
4936
  return target;
5330
4937
  },
@@ -5346,7 +4953,6 @@
5346
4953
  this.$handle.mounted();
5347
4954
  }
5348
4955
  });
5349
-
5350
4956
  function useAttr(formCreate) {
5351
4957
  extend(formCreate, {
5352
4958
  version: config.version,
@@ -5371,15 +4977,12 @@
5371
4977
  getApi: getApi,
5372
4978
  init: function init(rules) {
5373
4979
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5374
-
5375
4980
  var $vm = mountForm(rules, _opt),
5376
4981
  _this = $vm.$refs.fc.formCreate;
5377
4982
  return {
5378
4983
  mount: function mount($el) {
5379
4984
  if ($el && is.Element($el)) _this.options.el = $el;
5380
-
5381
4985
  _getEl(_this.options).appendChild($vm.$el);
5382
-
5383
4986
  return _this.api();
5384
4987
  },
5385
4988
  remove: function remove() {
@@ -5394,7 +4997,6 @@
5394
4997
  }
5395
4998
  });
5396
4999
  }
5397
-
5398
5000
  function useStatic(formCreate) {
5399
5001
  extend(formCreate, {
5400
5002
  create: create,
@@ -5403,12 +5005,10 @@
5403
5005
  if (Vue._installedFormCreate === true) return;
5404
5006
  Vue._installedFormCreate = true;
5405
5007
  _vue = Vue;
5406
-
5407
5008
  var $formCreate = function $formCreate(rules) {
5408
5009
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5409
5010
  return create(rules, opt, this);
5410
5011
  };
5411
-
5412
5012
  useAttr($formCreate);
5413
5013
  Vue.prototype.$formCreate = $formCreate;
5414
5014
  Vue.component('FormCreate', $form());
@@ -5416,7 +5016,6 @@
5416
5016
  }
5417
5017
  });
5418
5018
  }
5419
-
5420
5019
  useAttr(create);
5421
5020
  useStatic(create);
5422
5021
  CreateNode.use({
@@ -5424,7 +5023,6 @@
5424
5023
  });
5425
5024
  parser(html);
5426
5025
  if (config.install) create.use(config);
5427
-
5428
5026
  if (config.inherit) {
5429
5027
  var inherit = config.inherit;
5430
5028
  inherit.components && extend(components, inherit.components);
@@ -5434,7 +5032,6 @@
5434
5032
  inherit.maker && extend(maker, inherit.maker);
5435
5033
  inherit.data && extend(data, inherit.data);
5436
5034
  }
5437
-
5438
5035
  return create;
5439
5036
  }
5440
5037
 
@@ -5457,7 +5054,6 @@
5457
5054
  }(),
5458
5055
  mergeProp: function mergeProp(ctx) {
5459
5056
  var props = ctx.prop.props;
5460
-
5461
5057
  if (props.startDate) {
5462
5058
  props.startDate = props.startDate && timeStampToDate(props.startDate);
5463
5059
  }
@@ -5473,12 +5069,10 @@
5473
5069
  },
5474
5070
  toValue: function toValue(formValue, ctx) {
5475
5071
  var el = ctx.el;
5476
-
5477
5072
  if (el) {
5478
5073
  this.el = el;
5479
5074
  return this._toValue(formValue, ctx);
5480
5075
  }
5481
-
5482
5076
  return formValue;
5483
5077
  },
5484
5078
  toFormValue: function toFormValue(value, ctx) {
@@ -5490,7 +5084,6 @@
5490
5084
  props = ctx.prop.props,
5491
5085
  parseValue,
5492
5086
  type = props.type || 'date';
5493
-
5494
5087
  if (['daterange', 'datetimerange'].indexOf(type) !== -1) {
5495
5088
  if (isArr) {
5496
5089
  parseValue = value.map(function (time) {
@@ -5505,7 +5098,6 @@
5505
5098
  parseValue = isArr ? value[0] || '' : value;
5506
5099
  parseValue = !parseValue ? '' : timeStampToDate(parseValue);
5507
5100
  }
5508
-
5509
5101
  return parseValue;
5510
5102
  }
5511
5103
  },
@@ -5542,7 +5134,6 @@
5542
5134
  }(),
5543
5135
  mergeProp: function mergeProp(ctx) {
5544
5136
  var props = ctx.prop.props;
5545
-
5546
5137
  if (props.autosize && props.autosize.minRows) {
5547
5138
  props.rows = props.autosize.minRows || 2;
5548
5139
  }
@@ -5562,13 +5153,11 @@
5562
5153
  props = ctx.prop.props,
5563
5154
  min = props.min || 0,
5564
5155
  parseValue;
5565
-
5566
5156
  if (props.range === true) {
5567
5157
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5568
5158
  } else {
5569
5159
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5570
5160
  }
5571
-
5572
5161
  return parseValue;
5573
5162
  }
5574
5163
  };
@@ -5678,18 +5267,14 @@
5678
5267
 
5679
5268
  function tidy(props, name) {
5680
5269
  if (!hasProperty(props, name)) return;
5681
-
5682
5270
  if (is.String(props[name])) {
5683
5271
  var _props$name;
5684
-
5685
5272
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5686
5273
  }
5687
5274
  }
5688
-
5689
5275
  function isFalse(val) {
5690
5276
  return val === false;
5691
5277
  }
5692
-
5693
5278
  function tidyBool(opt, name) {
5694
5279
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5695
5280
  opt[name] = {
@@ -5697,7 +5282,6 @@
5697
5282
  };
5698
5283
  }
5699
5284
  }
5700
-
5701
5285
  var manager = {
5702
5286
  validate: function validate(call) {
5703
5287
  this.form().validate(call);
@@ -5707,7 +5291,6 @@
5707
5291
  },
5708
5292
  clearValidateState: function clearValidateState(ctx) {
5709
5293
  var fItem = this.vm.$refs[ctx.wrapRef];
5710
-
5711
5294
  if (fItem) {
5712
5295
  fItem.validateMessage = '';
5713
5296
  fItem.validateState = '';
@@ -5781,7 +5364,6 @@
5781
5364
  if (children.length) {
5782
5365
  children.push(this.makeFormBtn());
5783
5366
  }
5784
-
5785
5367
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5786
5368
  },
5787
5369
  makeWrap: function makeWrap(ctx, children) {
@@ -5813,11 +5395,9 @@
5813
5395
  return !(!title.title && !title["native"] || isFalse(title.show));
5814
5396
  },
5815
5397
  makeInfo: function makeInfo(rule, uni) {
5816
-
5817
5398
  var titleProp = rule.title;
5818
5399
  var infoProp = rule.info;
5819
5400
  var children = [titleProp.title];
5820
-
5821
5401
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5822
5402
  var prop = {
5823
5403
  type: infoProp.type || 'poptip',
@@ -5826,11 +5406,9 @@
5826
5406
  slot: 'label'
5827
5407
  };
5828
5408
  var field = 'content';
5829
-
5830
5409
  if (infoProp.info && !hasProperty(prop.props, field)) {
5831
5410
  prop.props[field] = infoProp.info;
5832
5411
  }
5833
-
5834
5412
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5835
5413
  type: 'icon',
5836
5414
  props: {
@@ -5841,7 +5419,6 @@
5841
5419
  key: "".concat(uni, "i")
5842
5420
  })]));
5843
5421
  }
5844
-
5845
5422
  return this.$r(mergeProps([titleProp, {
5846
5423
  props: titleProp,
5847
5424
  slot: titleProp.slot || 'label',
@@ -5871,19 +5448,15 @@
5871
5448
  },
5872
5449
  makeFormBtn: function makeFormBtn() {
5873
5450
  var vn = [];
5874
-
5875
5451
  if (!isFalse(this.options.submitBtn.show)) {
5876
5452
  vn.push(this.makeSubmitBtn());
5877
5453
  }
5878
-
5879
5454
  if (!isFalse(this.options.resetBtn.show)) {
5880
5455
  vn.push(this.makeResetBtn());
5881
5456
  }
5882
-
5883
5457
  if (!vn.length) {
5884
5458
  return;
5885
5459
  }
5886
-
5887
5460
  var item = this.$r({
5888
5461
  type: 'formItem',
5889
5462
  key: "".concat(this.key, "fb")
@@ -5898,7 +5471,6 @@
5898
5471
  },
5899
5472
  makeResetBtn: function makeResetBtn() {
5900
5473
  var _this2 = this;
5901
-
5902
5474
  var resetBtn = this.options.resetBtn;
5903
5475
  this.setSize(resetBtn);
5904
5476
  return this.$r({
@@ -5919,7 +5491,6 @@
5919
5491
  },
5920
5492
  makeSubmitBtn: function makeSubmitBtn() {
5921
5493
  var _this3 = this;
5922
-
5923
5494
  var submitBtn = this.options.submitBtn;
5924
5495
  this.setSize(submitBtn);
5925
5496
  return this.$r({
@@ -5941,7 +5512,6 @@
5941
5512
 
5942
5513
  var maker = {};
5943
5514
  var names = ['upload', 'select', 'tree', 'checkbox', 'autoComplete', 'cascader', 'colorPicker', 'frame', 'inputNumber', 'radio', 'rate', 'timePicker', 'group'];
5944
-
5945
5515
  function useAlias(maker) {
5946
5516
  names.forEach(function (name) {
5947
5517
  maker[name] = creatorFactory(name);
@@ -5950,7 +5520,6 @@
5950
5520
  maker.number = maker.inputNumber;
5951
5521
  maker.color = maker.colorPicker;
5952
5522
  }
5953
-
5954
5523
  function useUpload(maker) {
5955
5524
  var name = 'upload';
5956
5525
  var types = {
@@ -5971,7 +5540,6 @@
5971
5540
  maker.uploadImage = maker.image;
5972
5541
  maker.uploadFile = maker.file;
5973
5542
  }
5974
-
5975
5543
  function useTree(maker) {
5976
5544
  var name = 'tree';
5977
5545
  var types = {
@@ -5985,7 +5553,6 @@
5985
5553
  return maker;
5986
5554
  }, maker);
5987
5555
  }
5988
-
5989
5556
  function useTimePicker(maker) {
5990
5557
  var name = 'timePicker';
5991
5558
  maker.time = creatorFactory(name, {
@@ -5995,7 +5562,6 @@
5995
5562
  type: 'timerange'
5996
5563
  });
5997
5564
  }
5998
-
5999
5565
  function useSelect(maker) {
6000
5566
  var name = 'select';
6001
5567
  maker.selectMultiple = creatorFactory(name, {
@@ -6005,7 +5571,6 @@
6005
5571
  multiple: false
6006
5572
  });
6007
5573
  }
6008
-
6009
5574
  function useFrame(maker) {
6010
5575
  var name = 'frame';
6011
5576
  var types = {
@@ -6029,7 +5594,6 @@
6029
5594
  maker.frameFile = maker.frameFiles;
6030
5595
  maker.frameImage = maker.frameImages;
6031
5596
  }
6032
-
6033
5597
  useAlias(maker);
6034
5598
  useUpload(maker);
6035
5599
  useTree(maker);
@@ -6048,28 +5612,23 @@
6048
5612
  };
6049
5613
  return btn;
6050
5614
  }
6051
-
6052
5615
  function extendApi(api, h) {
6053
5616
  extend(api, {
6054
5617
  validate: function validate(callback) {
6055
5618
  var flag;
6056
5619
  var forms = api.children;
6057
5620
  var len = forms.length;
6058
-
6059
5621
  var validate = function validate() {
6060
5622
  h.$manager.validate(function () {
6061
5623
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6062
5624
  args[_key] = arguments[_key];
6063
5625
  }
6064
-
6065
5626
  if (!args[0] || !flag) {
6066
5627
  flag = args;
6067
5628
  }
6068
-
6069
5629
  callback && callback.apply(void 0, _toConsumableArray(flag));
6070
5630
  });
6071
5631
  };
6072
-
6073
5632
  var validFn = function validFn(args) {
6074
5633
  setTimeout(function () {
6075
5634
  if (!args[0]) {
@@ -6077,23 +5636,19 @@
6077
5636
  flag = args;
6078
5637
  }
6079
5638
  }
6080
-
6081
5639
  if (! --len) {
6082
5640
  validate();
6083
5641
  }
6084
5642
  });
6085
5643
  };
6086
-
6087
5644
  forms.forEach(function (form) {
6088
5645
  form.validate(function () {
6089
5646
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6090
5647
  args[_key2] = arguments[_key2];
6091
5648
  }
6092
-
6093
5649
  return validFn(args);
6094
5650
  });
6095
5651
  });
6096
-
6097
5652
  if (!len) {
6098
5653
  validate();
6099
5654
  }
@@ -6104,23 +5659,19 @@
6104
5659
  var sub = h.subForm[ctx.id];
6105
5660
  var len = 0;
6106
5661
  var flag;
6107
-
6108
5662
  var validate = function validate() {
6109
5663
  h.$manager.validateField(ctx.id, function () {
6110
5664
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
6111
5665
  args[_key3] = arguments[_key3];
6112
5666
  }
6113
-
6114
5667
  if (args[0]) {
6115
5668
  flag = args;
6116
5669
  } else if (flag) {
6117
5670
  return callback && callback('子表单验证未通过');
6118
5671
  }
6119
-
6120
5672
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
6121
5673
  });
6122
5674
  };
6123
-
6124
5675
  var validFn = function validFn(args) {
6125
5676
  setTimeout(function () {
6126
5677
  if (!args[0]) {
@@ -6128,31 +5679,26 @@
6128
5679
  flag = args;
6129
5680
  }
6130
5681
  }
6131
-
6132
5682
  if (! --len) {
6133
5683
  validate();
6134
5684
  }
6135
5685
  });
6136
5686
  };
6137
-
6138
5687
  sub && toArray(sub).forEach(function (form) {
6139
5688
  len++;
6140
5689
  form.validate(function () {
6141
5690
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
6142
5691
  args[_key4] = arguments[_key4];
6143
5692
  }
6144
-
6145
5693
  return validFn(args);
6146
5694
  });
6147
5695
  });
6148
-
6149
5696
  if (!len) {
6150
5697
  validate();
6151
5698
  }
6152
5699
  },
6153
5700
  clearValidateState: function clearValidateState(fields) {
6154
5701
  var _this = this;
6155
-
6156
5702
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6157
5703
  api.helper.tidyFields(fields).forEach(function (field) {
6158
5704
  if (clearSub) _this.clearSubValidateState(field);
@@ -6166,7 +5712,6 @@
6166
5712
  h.getCtxs(field).forEach(function (ctx) {
6167
5713
  var subForm = h.subForm[ctx.id];
6168
5714
  if (!subForm) return;
6169
-
6170
5715
  if (Array.isArray(subForm)) {
6171
5716
  subForm.forEach(function (form) {
6172
5717
  form.clearValidateState();
@@ -6180,14 +5725,12 @@
6180
5725
  btn: {
6181
5726
  loading: function loading() {
6182
5727
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6183
-
6184
5728
  api.submitBtnProps({
6185
5729
  loading: !!_loading
6186
5730
  });
6187
5731
  },
6188
5732
  disabled: function disabled() {
6189
5733
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6190
-
6191
5734
  api.submitBtnProps({
6192
5735
  disabled: !!_disabled
6193
5736
  });
@@ -6202,14 +5745,12 @@
6202
5745
  resetBtn: {
6203
5746
  loading: function loading() {
6204
5747
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6205
-
6206
5748
  api.resetBtnProps({
6207
5749
  loading: !!_loading2
6208
5750
  });
6209
5751
  },
6210
5752
  disabled: function disabled() {
6211
5753
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6212
-
6213
5754
  api.resetBtnProps({
6214
5755
  disabled: !!_disabled2
6215
5756
  });
@@ -6238,7 +5779,6 @@
6238
5779
  submit: function submit(successFn, failFn) {
6239
5780
  var _arguments = arguments,
6240
5781
  _this2 = this;
6241
-
6242
5782
  api.validate(function (valid) {
6243
5783
  if (valid) {
6244
5784
  var formData = api.formData();
@@ -6273,11 +5813,10 @@
6273
5813
  FormCreate.maker[name] = maker[name];
6274
5814
  });
6275
5815
  }
6276
-
6277
5816
  function ivuFormCreate() {
6278
5817
  return FormCreateFactory({
6279
5818
  ui: "".concat("iview"),
6280
- version: "".concat("2.5.19"),
5819
+ version: "".concat("2.5.20"),
6281
5820
  manager: manager,
6282
5821
  install: install,
6283
5822
  extendApi: extendApi,
@@ -6290,15 +5829,12 @@
6290
5829
  }
6291
5830
 
6292
5831
  var FormCreate = ivuFormCreate();
6293
-
6294
5832
  if (typeof window !== 'undefined') {
6295
5833
  window.formCreate = FormCreate;
6296
-
6297
5834
  if (window.Vue) {
6298
5835
  FormCreate.install(window.Vue);
6299
5836
  }
6300
5837
  }
6301
-
6302
5838
  var maker$1 = FormCreate.maker;
6303
5839
 
6304
5840
  exports.default = FormCreate;