@form-create/view-design 2.5.18 → 2.5.21

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