@form-create/element-ui 2.5.19 → 2.5.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v2.5.19
2
+ * @form-create/element-ui v2.5.20
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -19,11 +19,9 @@
19
19
  Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]);
20
20
  }
21
21
  }
22
-
23
22
  return a;
24
23
  }, _extends.apply(this, arguments);
25
24
  }
26
-
27
25
  var normalMerge = ["attrs", "props", "domProps"],
28
26
  toArrayMerge = ["class", "style", "directives"],
29
27
  functionalMerge = ["on", "nativeOn"],
@@ -46,7 +44,6 @@
46
44
  c[b][i] = c[b][i] ? mergeFn(c[b][i], a[b][i]) : a[b][i];
47
45
  } else c[b] = a[b];
48
46
  }
49
-
50
47
  return c;
51
48
  }, {});
52
49
  },
@@ -55,7 +52,6 @@
55
52
  a && a.apply(this, arguments), b && b.apply(this, arguments);
56
53
  };
57
54
  };
58
-
59
55
  var helper = mergeJsxProps;
60
56
 
61
57
  function _typeof(obj) {
@@ -246,7 +242,6 @@
246
242
  if (!exclude || exclude.indexOf(name) === -1) {
247
243
  lst.push(slots[name]);
248
244
  }
249
-
250
245
  return lst;
251
246
  }, []);
252
247
  }
@@ -299,7 +294,6 @@
299
294
  },
300
295
  update: function update() {
301
296
  var _this = this;
302
-
303
297
  this.trueValue = this.value ? this.options().filter(function (opt) {
304
298
  return _this.value.indexOf(opt.value) !== -1;
305
299
  }).map(function (option) {
@@ -312,7 +306,6 @@
312
306
  },
313
307
  render: function render() {
314
308
  var _this2 = this;
315
-
316
309
  var h = arguments[0];
317
310
  return h("ElCheckboxGroup", helper([{}, this.formCreateInject.prop, {
318
311
  "attrs": {
@@ -323,7 +316,6 @@
323
316
  }
324
317
  }]), [this.options().map(function (opt, index) {
325
318
  var props = _objectSpread2({}, opt);
326
-
327
319
  var Type = _this2.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
328
320
  delete props.value;
329
321
  return h(Type, {
@@ -341,15 +333,12 @@
341
333
  function styleInject(css, ref) {
342
334
  if (ref === void 0) ref = {};
343
335
  var insertAt = ref.insertAt;
344
-
345
336
  if (!css || typeof document === 'undefined') {
346
337
  return;
347
338
  }
348
-
349
339
  var head = document.head || document.getElementsByTagName('head')[0];
350
340
  var style = document.createElement('style');
351
341
  style.type = 'text/css';
352
-
353
342
  if (insertAt === 'top') {
354
343
  if (head.firstChild) {
355
344
  head.insertBefore(style, head.firstChild);
@@ -359,7 +348,6 @@
359
348
  } else {
360
349
  head.appendChild(style);
361
350
  }
362
-
363
351
  if (style.styleSheet) {
364
352
  style.styleSheet.cssText = css;
365
353
  } else {
@@ -515,12 +503,10 @@
515
503
  },
516
504
  closeModel: function closeModel(close) {
517
505
  this.$emit(close ? '$close' : '$ok');
518
-
519
506
  if (this.reload) {
520
507
  this.$off('$ok');
521
508
  this.$off('$close');
522
509
  }
523
-
524
510
  this.frameVisible = false;
525
511
  },
526
512
  handleCancel: function handleCancel() {
@@ -530,12 +516,10 @@
530
516
  if (this.disabled || false === this.onOpen()) {
531
517
  return;
532
518
  }
533
-
534
519
  this.frameVisible = true;
535
520
  },
536
521
  makeInput: function makeInput() {
537
522
  var _this = this;
538
-
539
523
  var h = this.$createElement;
540
524
  var props = {
541
525
  type: 'text',
@@ -572,11 +556,9 @@
572
556
  },
573
557
  makeGroup: function makeGroup(children) {
574
558
  var h = this.$createElement;
575
-
576
559
  if (!this.maxLength || this.fileList.length < this.maxLength) {
577
560
  children.push(this.makeBtn());
578
561
  }
579
-
580
562
  return h("div", {
581
563
  "key": this.key('group')
582
564
  }, _toConsumableArray(children));
@@ -590,25 +572,20 @@
590
572
  },
591
573
  valid: function valid(f) {
592
574
  var field = this.formCreateInject.field || this.field;
593
-
594
575
  if (field && f !== field) {
595
576
  throw new Error('[frame]无效的字段值');
596
577
  }
597
578
  },
598
579
  makeIcons: function makeIcons(val, index) {
599
580
  var h = this.$createElement;
600
-
601
581
  if (this.handleIcon !== false || this.allowRemove === true) {
602
582
  var icons = [];
603
-
604
583
  if (this.type !== 'file' && this.handleIcon !== false || this.type === 'file' && this.handleIcon) {
605
584
  icons.push(this.makeHandleIcon(val, index));
606
585
  }
607
-
608
586
  if (this.allowRemove) {
609
587
  icons.push(this.makeRemoveIcon(val, index));
610
588
  }
611
-
612
589
  return h("div", {
613
590
  "class": 'fc-upload-cover',
614
591
  "key": this.key('uc')
@@ -617,7 +594,6 @@
617
594
  },
618
595
  makeHandleIcon: function makeHandleIcon(val, index) {
619
596
  var _this2 = this;
620
-
621
597
  var h = this.$createElement;
622
598
  return h("i", {
623
599
  "class": this.handleIcon === true || this.handleIcon === undefined ? 'el-icon-view' : this.handleIcon,
@@ -631,7 +607,6 @@
631
607
  },
632
608
  makeRemoveIcon: function makeRemoveIcon(val, index) {
633
609
  var _this3 = this;
634
-
635
610
  var h = this.$createElement;
636
611
  return h("i", {
637
612
  "class": "el-icon-delete",
@@ -645,7 +620,6 @@
645
620
  },
646
621
  makeFiles: function makeFiles() {
647
622
  var _this4 = this;
648
-
649
623
  var h = this.$createElement;
650
624
  return this.makeGroup(this.fileList.map(function (src, index) {
651
625
  return _this4.makeItem(index, [h("i", {
@@ -660,7 +634,6 @@
660
634
  },
661
635
  makeImages: function makeImages() {
662
636
  var _this5 = this;
663
-
664
637
  var h = this.$createElement;
665
638
  return this.makeGroup(this.fileList.map(function (src, index) {
666
639
  return _this5.makeItem(index, [h("img", {
@@ -672,7 +645,6 @@
672
645
  },
673
646
  makeBtn: function makeBtn() {
674
647
  var _this6 = this;
675
-
676
648
  var h = this.$createElement;
677
649
  return h("div", {
678
650
  "class": 'fc-upload-btn',
@@ -693,7 +665,6 @@
693
665
  if (this.disabled) {
694
666
  return;
695
667
  }
696
-
697
668
  if (false !== this.onBeforeRemove(src)) {
698
669
  this.fileList.splice(this.fileList.indexOf(src), 1);
699
670
  this.onRemove(src);
@@ -704,26 +675,21 @@
704
675
  },
705
676
  frameLoad: function frameLoad(iframe) {
706
677
  var _this7 = this;
707
-
708
678
  this.onLoad(iframe);
709
-
710
679
  try {
711
680
  if (this.helper === true) {
712
681
  iframe['form_create_helper'] = {
713
682
  api: this.formCreateInject.api,
714
683
  close: function close(field) {
715
684
  _this7.valid(field);
716
-
717
685
  _this7.closeModel();
718
686
  },
719
687
  set: function set(field, value) {
720
688
  _this7.valid(field);
721
-
722
689
  if (!_this7.disabled) _this7.$emit('input', value);
723
690
  },
724
691
  get: function get(field) {
725
692
  _this7.valid(field);
726
-
727
693
  return _this7.value;
728
694
  },
729
695
  onOk: function onOk(fn) {
@@ -740,7 +706,6 @@
740
706
  },
741
707
  makeFooter: function makeFooter() {
742
708
  var _this8 = this;
743
-
744
709
  var h = this.$createElement;
745
710
  var _this$$props = this.$props,
746
711
  okBtnText = _this$$props.okBtnText,
@@ -748,11 +713,9 @@
748
713
  closeBtn = _this$$props.closeBtn,
749
714
  okBtn = _this$$props.okBtn,
750
715
  footer = _this$$props.footer;
751
-
752
716
  if (!footer) {
753
717
  return;
754
718
  }
755
-
756
719
  return h("div", {
757
720
  "slot": "footer"
758
721
  }, [closeBtn ? h("ElButton", {
@@ -775,11 +738,9 @@
775
738
  },
776
739
  render: function render() {
777
740
  var _this9 = this;
778
-
779
741
  var h = arguments[0];
780
742
  var type = this.type;
781
743
  var node;
782
-
783
744
  if (type === 'input') {
784
745
  node = this.makeInput();
785
746
  } else if (type === 'image') {
@@ -787,7 +748,6 @@
787
748
  } else {
788
749
  node = this.makeFiles();
789
750
  }
790
-
791
751
  var _this$$props2 = this.$props,
792
752
  _this$$props2$width = _this$$props2.width,
793
753
  width = _this$$props2$width === void 0 ? '30%' : _this$$props2$width,
@@ -892,7 +852,6 @@
892
852
  },
893
853
  update: function update() {
894
854
  var _this = this;
895
-
896
855
  this.trueValue = this.options().filter(function (opt) {
897
856
  return opt.value === _this.value;
898
857
  }).reduce(function (initial, opt) {
@@ -905,7 +864,6 @@
905
864
  },
906
865
  render: function render() {
907
866
  var _this2 = this;
908
-
909
867
  var h = arguments[0];
910
868
  return h("ElRadioGroup", helper([{}, this.formCreateInject.prop, {
911
869
  "attrs": {
@@ -916,7 +874,6 @@
916
874
  }
917
875
  }]), [this.options().map(function (opt, index) {
918
876
  var props = _objectSpread2({}, opt);
919
-
920
877
  var Type = _this2.type === 'button' ? 'ElRadioButton' : 'ElRadio';
921
878
  delete props.value;
922
879
  return h(Type, {
@@ -952,11 +909,9 @@
952
909
  if (value === undefined || value === null) {
953
910
  return true;
954
911
  }
955
-
956
912
  if (Array.isArray(value) && Array.isArray(value) && !value.length) {
957
913
  return true;
958
914
  }
959
-
960
915
  return typeof value === 'string' && !value;
961
916
  }
962
917
  };
@@ -1034,18 +989,15 @@
1034
989
  if (!this.$refs.tree) return;
1035
990
  var type = this.type.toLocaleLowerCase();
1036
991
  var value;
1037
-
1038
992
  if (type === 'selected') {
1039
993
  value = this.$refs.tree.getCurrentKey();
1040
994
  } else {
1041
995
  value = this.$refs.tree.getCheckedKeys();
1042
996
  }
1043
-
1044
997
  this.$emit('input', value);
1045
998
  },
1046
999
  setValue: function setValue() {
1047
1000
  var type = this.type.toLocaleLowerCase();
1048
-
1049
1001
  if (type === 'selected') {
1050
1002
  this.$refs.tree.setCurrentKey(this.value);
1051
1003
  } else {
@@ -1055,7 +1007,6 @@
1055
1007
  },
1056
1008
  render: function render() {
1057
1009
  var _this = this;
1058
-
1059
1010
  var h = arguments[0];
1060
1011
  return h("ElTree", helper([{}, this.formCreateInject.prop, {
1061
1012
  "ref": "tree",
@@ -1084,11 +1035,9 @@
1084
1035
  uid: i
1085
1036
  };
1086
1037
  }
1087
-
1088
1038
  function getFileName(file) {
1089
1039
  return ('' + file).split('/').pop();
1090
1040
  }
1091
-
1092
1041
  var NAME$5 = 'fcUpload';
1093
1042
  var Upload = {
1094
1043
  name: NAME$5,
@@ -1138,7 +1087,6 @@
1138
1087
  if (this.formCreateInject.prop.props.showFileList === undefined) {
1139
1088
  this.formCreateInject.prop.props.showFileList = false;
1140
1089
  }
1141
-
1142
1090
  this.formCreateInject.prop.props.fileList = toArray(this.value).map(parseFile);
1143
1091
  },
1144
1092
  watch: {
@@ -1167,7 +1115,6 @@
1167
1115
  if (this.isDisabled()) {
1168
1116
  return;
1169
1117
  }
1170
-
1171
1118
  this.$refs.upload.handleRemove(file);
1172
1119
  },
1173
1120
  handleClick: function handleClick(file) {
@@ -1187,7 +1134,6 @@
1187
1134
  },
1188
1135
  makeRemoveIcon: function makeRemoveIcon(file, index) {
1189
1136
  var _this = this;
1190
-
1191
1137
  var h = this.$createElement;
1192
1138
  return h("i", {
1193
1139
  "class": "el-icon-delete",
@@ -1201,7 +1147,6 @@
1201
1147
  },
1202
1148
  makeHandleIcon: function makeHandleIcon(file, index) {
1203
1149
  var _this2 = this;
1204
-
1205
1150
  var h = this.$createElement;
1206
1151
  return h("i", {
1207
1152
  "class": this.handleIcon === true || this.handleIcon === undefined ? 'el-icon-view' : this.handleIcon,
@@ -1229,16 +1174,13 @@
1229
1174
  makeIcons: function makeIcons(file, index) {
1230
1175
  var h = this.$createElement;
1231
1176
  var icons = [];
1232
-
1233
1177
  if (this.allowRemove || this.handleIcon !== false) {
1234
1178
  if (this.uploadType !== 'file' && this.handleIcon !== false || this.uploadType === 'file' && this.handleIcon) {
1235
1179
  icons.push(this.makeHandleIcon(file, index));
1236
1180
  }
1237
-
1238
1181
  if (this.allowRemove) {
1239
1182
  icons.push(this.makeRemoveIcon(file, index));
1240
1183
  }
1241
-
1242
1184
  return h("div", {
1243
1185
  "class": 'fc-upload-cover'
1244
1186
  }, [icons]);
@@ -1246,7 +1188,6 @@
1246
1188
  },
1247
1189
  makeFiles: function makeFiles() {
1248
1190
  var _this3 = this;
1249
-
1250
1191
  var h = this.$createElement;
1251
1192
  return this.uploadList.map(function (file, index) {
1252
1193
  return _this3.$scopedSlots.fileList ? _this3.$scopedSlots.fileList({
@@ -1282,7 +1223,6 @@
1282
1223
  }).filter(function (url) {
1283
1224
  return url !== undefined;
1284
1225
  });
1285
-
1286
1226
  if (this.cacheFiles.length !== files.length) {
1287
1227
  this.cacheFiles = _toConsumableArray(files);
1288
1228
  this.$emit('input', this.limit === 1 ? files[0] || '' : files);
@@ -1294,15 +1234,12 @@
1294
1234
  },
1295
1235
  render: function render() {
1296
1236
  var h = arguments[0];
1297
-
1298
1237
  if (this.$refs.upload) {
1299
1238
  if (this.formCreateInject.prop.props.showFileList === undefined) {
1300
1239
  this.formCreateInject.prop.props.showFileList = this.$refs.upload.showFileList;
1301
1240
  }
1302
-
1303
1241
  this.formCreateInject.prop.props.fileList = this.$refs.upload.fileList;
1304
1242
  }
1305
-
1306
1243
  return h("div", {
1307
1244
  "class": '_fc-upload'
1308
1245
  }, [[this.formCreateInject.prop.props.showFileList ? [] : this.makeFiles(), this.makeUpload()], h("el-dialog", {
@@ -1325,7 +1262,6 @@
1325
1262
  },
1326
1263
  mounted: function mounted() {
1327
1264
  var _this4 = this;
1328
-
1329
1265
  this.uploadList = this.$refs.upload.uploadFiles;
1330
1266
  this.$watch(function () {
1331
1267
  return _this4.$refs.upload.uploadFiles;
@@ -1348,14 +1284,11 @@
1348
1284
  var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1349
1285
  var mode = arguments.length > 2 ? arguments[2] : undefined;
1350
1286
  var isArr = false;
1351
-
1352
1287
  for (var key in target) {
1353
1288
  if (Object.prototype.hasOwnProperty.call(target, key)) {
1354
1289
  var clone = target[key];
1355
-
1356
1290
  if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1357
1291
  var nst = origin[key] === undefined;
1358
-
1359
1292
  if (isArr) {
1360
1293
  isArr = false;
1361
1294
  nst && $set(origin, key, []);
@@ -1370,16 +1303,13 @@
1370
1303
  } else {
1371
1304
  nst && $set(origin, key, {});
1372
1305
  }
1373
-
1374
1306
  origin[key] = deepExtend(origin[key], clone, mode);
1375
1307
  } else {
1376
1308
  $set(origin, key, clone);
1377
-
1378
1309
  if (!is.Undef(clone)) {
1379
1310
  if (!is.Undef(clone.__json)) {
1380
1311
  origin[key].__json = clone.__json;
1381
1312
  }
1382
-
1383
1313
  if (!is.Undef(clone.__origin)) {
1384
1314
  origin[key].__origin = clone.__origin;
1385
1315
  }
@@ -1387,7 +1317,6 @@
1387
1317
  }
1388
1318
  }
1389
1319
  }
1390
-
1391
1320
  return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1392
1321
  return !v || !v.__ctrl;
1393
1322
  }) : origin;
@@ -1404,10 +1333,8 @@
1404
1333
  Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1405
1334
  }
1406
1335
  }
1407
-
1408
1336
  return a;
1409
1337
  };
1410
-
1411
1338
  function extend() {
1412
1339
  return _extends$1.apply(this, arguments);
1413
1340
  }
@@ -1475,18 +1402,34 @@
1475
1402
  },
1476
1403
  computed: {
1477
1404
  formRule: function formRule() {
1478
- if (this.rule) {
1479
- return Array.isArray(this.rule) ? this.rule : [this.rule];
1480
- }
1481
-
1482
1405
  if (this.rules) {
1483
1406
  return this.rules;
1484
1407
  }
1485
-
1408
+ if (this.rule) {
1409
+ return Array.isArray(this.rule) ? this.rule : [this.rule];
1410
+ }
1486
1411
  return [];
1487
1412
  }
1488
1413
  },
1489
1414
  watch: {
1415
+ formRule: {
1416
+ handler: function handler(n, o) {
1417
+ var _this = this;
1418
+ Object.keys(this.cacheRule).forEach(function (v) {
1419
+ var item = _this.cacheRule[v];
1420
+ if (n === o) {
1421
+ deepExtend(item.rule, n);
1422
+ } else {
1423
+ var val = item.$f.formData();
1424
+ item.$f.once('reload', function () {
1425
+ item.$f.setValue(val);
1426
+ });
1427
+ item.rule = deepCopy(n);
1428
+ }
1429
+ });
1430
+ },
1431
+ deep: true
1432
+ },
1490
1433
  disabled: function disabled(n) {
1491
1434
  if (this.syncDisabled) {
1492
1435
  var lst = this.cacheRule;
@@ -1497,24 +1440,20 @@
1497
1440
  },
1498
1441
  expand: function expand(n) {
1499
1442
  var d = n - this.value.length;
1500
-
1501
1443
  if (d > 0) {
1502
1444
  this.expandRule(d);
1503
1445
  }
1504
1446
  },
1505
1447
  value: function value(n) {
1506
- var _this = this;
1507
-
1448
+ var _this2 = this;
1508
1449
  n = n || [];
1509
1450
  var keys = Object.keys(this.cacheRule),
1510
1451
  total = keys.length,
1511
1452
  len = total - n.length;
1512
-
1513
1453
  if (len < 0) {
1514
1454
  for (var i = len; i < 0; i++) {
1515
1455
  this.addRule(n.length + i);
1516
1456
  }
1517
-
1518
1457
  for (var _i = 0; _i < total; _i++) {
1519
1458
  this.setValue(keys[_i], n[_i]);
1520
1459
  }
@@ -1523,12 +1462,9 @@
1523
1462
  for (var _i2 = 0; _i2 < len; _i2++) {
1524
1463
  this.removeRule(keys[total - _i2 - 1]);
1525
1464
  }
1526
-
1527
- this.subForm();
1528
1465
  }
1529
-
1530
1466
  n.forEach(function (val, i) {
1531
- _this.setValue(keys[i], n[i]);
1467
+ _this2.setValue(keys[i], n[i]);
1532
1468
  });
1533
1469
  }
1534
1470
  }
@@ -1545,23 +1481,18 @@
1545
1481
  this.$emit('change', value);
1546
1482
  },
1547
1483
  formData: function formData(key, _formData) {
1548
- var _this2 = this;
1549
-
1484
+ var _this3 = this;
1550
1485
  var cacheRule = this.cacheRule;
1551
1486
  var keys = Object.keys(cacheRule);
1552
-
1553
1487
  if (keys.filter(function (k) {
1554
1488
  return cacheRule[k].$f;
1555
1489
  }).length !== keys.length) {
1556
1490
  return;
1557
1491
  }
1558
-
1559
1492
  var value = keys.map(function (k) {
1560
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1561
- var value = _this2.field ? data[_this2.field] || null : data;
1562
-
1563
- _this2.cache(k, value);
1564
-
1493
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1494
+ var value = _this3.field ? data[_this3.field] || null : data;
1495
+ _this3.cache(k, value);
1565
1496
  return value;
1566
1497
  });
1567
1498
  this.input(value);
@@ -1569,72 +1500,53 @@
1569
1500
  setValue: function setValue(key, value) {
1570
1501
  var field = this.field,
1571
1502
  $f = this.cacheRule[key].$f;
1572
-
1573
1503
  if (field) {
1574
1504
  value = _defineProperty({}, field, this._value(value));
1575
1505
  }
1576
-
1577
1506
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1578
1507
  return;
1579
1508
  }
1580
-
1581
1509
  this.cache(key, value);
1582
1510
  $f.coverValue(value || {});
1583
1511
  },
1584
1512
  addRule: function addRule(i, emit) {
1585
- var _this3 = this;
1586
-
1513
+ var _this4 = this;
1587
1514
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1588
1515
  var options = this.options ? _objectSpread2({}, this.options) : {
1589
1516
  submitBtn: false,
1590
1517
  resetBtn: false
1591
1518
  };
1592
-
1593
1519
  if (this.defaultValue) {
1594
1520
  if (!options.formData) options.formData = {};
1595
1521
  var defVal = deepCopy(this.defaultValue);
1596
1522
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1597
1523
  }
1598
-
1599
1524
  this.$set(this.cacheRule, ++this.len, {
1600
1525
  rule: rule,
1601
1526
  options: options
1602
1527
  });
1603
-
1604
1528
  if (emit) {
1605
1529
  this.$nextTick(function () {
1606
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1530
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1607
1531
  });
1608
1532
  }
1609
1533
  },
1610
1534
  add$f: function add$f(i, key, $f) {
1611
- var _this4 = this;
1612
-
1535
+ var _this5 = this;
1613
1536
  this.cacheRule[key].$f = $f;
1614
- this.subForm();
1615
1537
  this.formData(key, $f.formData());
1616
1538
  this.$nextTick(function () {
1617
- if (_this4.syncDisabled) {
1618
- $f.disabled(_this4.disabled);
1539
+ if (_this5.syncDisabled) {
1540
+ $f.disabled(_this5.disabled);
1619
1541
  }
1620
-
1621
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1542
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1622
1543
  });
1623
1544
  },
1624
- subForm: function subForm() {
1625
- var _this5 = this;
1626
-
1627
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1628
- return _this5.cacheRule[k].$f;
1629
- }));
1630
- },
1631
1545
  removeRule: function removeRule(key, emit) {
1632
1546
  var _this6 = this;
1633
-
1634
1547
  var index = Object.keys(this.cacheRule).indexOf(key);
1635
1548
  this.$delete(this.cacheRule, key);
1636
1549
  this.$delete(this.cacheValue, key);
1637
-
1638
1550
  if (emit) {
1639
1551
  this.$nextTick(function () {
1640
1552
  return _this6.$emit('remove', index);
@@ -1645,16 +1557,13 @@
1645
1557
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1646
1558
  return;
1647
1559
  }
1648
-
1649
1560
  this.addRule(i, true);
1650
1561
  },
1651
1562
  del: function del(index, key) {
1652
1563
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1653
1564
  return;
1654
1565
  }
1655
-
1656
1566
  this.removeRule(key, true);
1657
- this.subForm();
1658
1567
  this.value.splice(index, 1);
1659
1568
  this.input(this.value);
1660
1569
  },
@@ -1671,7 +1580,6 @@
1671
1580
  },
1672
1581
  delIcon: function delIcon(index, key) {
1673
1582
  var _this7 = this;
1674
-
1675
1583
  var h = this.$createElement;
1676
1584
  return h("i", {
1677
1585
  "key": "d".concat(key),
@@ -1686,7 +1594,6 @@
1686
1594
  },
1687
1595
  makeIcon: function makeIcon(total, index, key) {
1688
1596
  var _this8 = this;
1689
-
1690
1597
  if (this.$scopedSlots.button) {
1691
1598
  return this.$scopedSlots.button({
1692
1599
  total: total,
@@ -1699,11 +1606,9 @@
1699
1606
  add: this.add
1700
1607
  });
1701
1608
  }
1702
-
1703
1609
  if (index === 0) {
1704
1610
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1705
1611
  }
1706
-
1707
1612
  if (index >= this.min) {
1708
1613
  return this.delIcon(index, key);
1709
1614
  }
@@ -1720,18 +1625,15 @@
1720
1625
  created: function created() {
1721
1626
  this.type = this.formCreateInject.form.$form();
1722
1627
  var d = (this.expand || 0) - this.value.length;
1723
-
1724
1628
  if (d > 0) {
1725
1629
  this.expandRule(d);
1726
1630
  }
1727
-
1728
1631
  for (var i = 0; i < this.value.length; i++) {
1729
1632
  this.addRule(i);
1730
1633
  }
1731
1634
  },
1732
1635
  render: function render() {
1733
1636
  var _this9 = this;
1734
-
1735
1637
  var h = arguments[0];
1736
1638
  var keys = Object.keys(this.cacheRule);
1737
1639
  var button = this.button;
@@ -1764,7 +1666,10 @@
1764
1666
  "span": button ? 20 : 24
1765
1667
  }
1766
1668
  }, [h("ElFormItem", [h(Type, helper([{
1767
- "key": key
1669
+ "key": key,
1670
+ "attrs": {
1671
+ "inFor": true
1672
+ }
1768
1673
  }, {
1769
1674
  "on": {
1770
1675
  'update:value': function updateValue(formData) {
@@ -1774,7 +1679,6 @@
1774
1679
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1775
1680
  args[_key - 1] = arguments[_key];
1776
1681
  }
1777
-
1778
1682
  return _this9.emitEvent(name, args, index, key);
1779
1683
  },
1780
1684
  input: function input($f) {
@@ -1847,11 +1751,9 @@
1847
1751
  },
1848
1752
  setValue: function setValue(value) {
1849
1753
  var str = JSON.stringify(value);
1850
-
1851
1754
  if (this.cacheValue === str) {
1852
1755
  return;
1853
1756
  }
1854
-
1855
1757
  this.cacheValue = str;
1856
1758
  this.cacheRule.$f.coverValue(value || {});
1857
1759
  },
@@ -1868,23 +1770,16 @@
1868
1770
  },
1869
1771
  add$f: function add$f($f) {
1870
1772
  var _this = this;
1871
-
1872
1773
  this.cacheRule.$f = $f;
1873
- this.subForm();
1874
1774
  this.$nextTick(function () {
1875
1775
  _this.syncDisabled && $f.disabled(_this.disabled);
1876
-
1877
1776
  _this.$emit('itemMounted', $f);
1878
1777
  });
1879
1778
  },
1880
- subForm: function subForm() {
1881
- this.formCreateInject.subForm(this.cacheRule.$f);
1882
- },
1883
1779
  emitEvent: function emitEvent(name) {
1884
1780
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1885
1781
  args[_key - 1] = arguments[_key];
1886
1782
  }
1887
-
1888
1783
  this.$emit.apply(this, [name].concat(args));
1889
1784
  }
1890
1785
  },
@@ -1917,6 +1812,17 @@
1917
1812
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub];
1918
1813
 
1919
1814
  var NAME$8 = 'FormCreate';
1815
+ var getRuleInject = function getRuleInject(vm, parent) {
1816
+ if (!vm || vm === parent) {
1817
+ return;
1818
+ }
1819
+ if (vm.formCreateInject) {
1820
+ return vm.formCreateInject;
1821
+ }
1822
+ if (vm.$parent) {
1823
+ return getRuleInject(vm.$parent, parent);
1824
+ }
1825
+ };
1920
1826
  function $FormCreate(FormCreate) {
1921
1827
  return {
1922
1828
  name: NAME$8,
@@ -1948,7 +1854,12 @@
1948
1854
  extendOption: Boolean,
1949
1855
  value: Object,
1950
1856
  api: Object,
1951
- name: String
1857
+ name: String,
1858
+ subForm: {
1859
+ type: Boolean,
1860
+ "default": true
1861
+ },
1862
+ inFor: Boolean
1952
1863
  },
1953
1864
  data: function data() {
1954
1865
  return {
@@ -1960,7 +1871,8 @@
1960
1871
  unique: 1,
1961
1872
  renderRule: _toConsumableArray(this.rule || []),
1962
1873
  ctxInject: {},
1963
- updateValue: ''
1874
+ updateValue: JSON.stringify(this.value || {}),
1875
+ isMore: !!this.inFor
1964
1876
  };
1965
1877
  },
1966
1878
  render: function render() {
@@ -1982,8 +1894,8 @@
1982
1894
  watch: {
1983
1895
  value: {
1984
1896
  handler: function handler(n) {
1985
- if (JSON.stringify(n) === this.updateValue) return;
1986
- this.$f.setValue(n);
1897
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1898
+ this.$f.setValue(n || {});
1987
1899
  },
1988
1900
  deep: true
1989
1901
  },
@@ -1996,18 +1908,15 @@
1996
1908
  },
1997
1909
  rule: function rule(n) {
1998
1910
  var _this = this;
1999
-
2000
1911
  if (n.length === this.renderRule.length && n.every(function (v) {
2001
1912
  return _this.renderRule.indexOf(v) > -1;
2002
1913
  })) return;
2003
1914
  this.formCreate.$handle.reloadRule(n);
2004
-
2005
1915
  this._renderRule();
2006
1916
  }
2007
1917
  },
2008
1918
  beforeCreate: function beforeCreate() {
2009
1919
  var _this2 = this;
2010
-
2011
1920
  var _this$$options$propsD = this.$options.propsData,
2012
1921
  rule = _this$$options$propsD.rule,
2013
1922
  option = _this$$options$propsD.option;
@@ -2016,6 +1925,50 @@
2016
1925
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
2017
1926
  });
2018
1927
  this.$emit('beforeCreate', this.formCreate.api());
1928
+ },
1929
+ created: function created() {
1930
+ var _this3 = this;
1931
+ var vm = this,
1932
+ fapi = this.formCreate.api();
1933
+ var addSubForm = function addSubForm() {
1934
+ if (vm.$pfc) {
1935
+ var inject = getRuleInject(vm, vm.$pfc);
1936
+ if (inject) {
1937
+ var sub;
1938
+ if (vm.isMore) {
1939
+ sub = toArray(inject.getSubForm());
1940
+ sub.push(fapi);
1941
+ } else {
1942
+ sub = fapi;
1943
+ }
1944
+ inject.subForm(sub);
1945
+ }
1946
+ }
1947
+ };
1948
+ var rmSubForm = function rmSubForm() {
1949
+ var inject = getRuleInject(vm, vm.$pfc);
1950
+ if (inject) {
1951
+ if (vm.isMore) {
1952
+ var sub = toArray(inject.getSubForm());
1953
+ var idx = sub.indexOf(fapi);
1954
+ if (idx > -1) {
1955
+ sub.splice(idx, 1);
1956
+ }
1957
+ } else {
1958
+ inject.subForm();
1959
+ }
1960
+ }
1961
+ };
1962
+ vm.$on('hook:beforeDestroy', function () {
1963
+ rmSubForm();
1964
+ });
1965
+ this.$watch(function () {
1966
+ return _this3.subForm;
1967
+ }, function (n) {
1968
+ n ? addSubForm() : rmSubForm();
1969
+ }, {
1970
+ immediate: true
1971
+ });
2019
1972
  }
2020
1973
  };
2021
1974
  }
@@ -2023,17 +1976,12 @@
2023
1976
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
2024
1977
  var toArrayMerge$1 = ['class', 'style', 'directives'];
2025
1978
  var functionalMerge$1 = ['on', 'nativeOn'];
2026
-
2027
1979
  var mergeProps = function mergeProps(objects) {
2028
1980
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2029
1981
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2030
-
2031
1982
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
2032
-
2033
1983
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
2034
-
2035
1984
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
2036
-
2037
1985
  var propsMerge = opt['props'] || [];
2038
1986
  return objects.reduce(function (a, b) {
2039
1987
  for (var key in b) {
@@ -2050,9 +1998,7 @@
2050
1998
  for (var event in b[key]) {
2051
1999
  if (a[key][event]) {
2052
2000
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2053
-
2054
2001
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2055
-
2056
2002
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2057
2003
  } else {
2058
2004
  a[key][event] = b[key][event];
@@ -2077,11 +2023,9 @@
2077
2023
  } else a[key] = b[key];
2078
2024
  }
2079
2025
  }
2080
-
2081
2026
  return a;
2082
2027
  }, initial);
2083
2028
  };
2084
-
2085
2029
  var mergeFn$1 = function mergeFn(fn1, fn2) {
2086
2030
  return function () {
2087
2031
  fn1 && fn1.apply(this, arguments);
@@ -2089,7 +2033,7 @@
2089
2033
  };
2090
2034
  };
2091
2035
 
2092
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2036
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
2093
2037
  var arrayAttrs = ['validate', 'children', 'control'];
2094
2038
  var normalAttrs = ['effect', 'deep'];
2095
2039
  function attrs() {
@@ -2118,30 +2062,24 @@
2118
2062
  function toJson(obj, space) {
2119
2063
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2120
2064
  if (val && val._isVue === true) return undefined;
2121
-
2122
2065
  if (_typeof(val) !== FUNCTION) {
2123
2066
  return val;
2124
2067
  }
2125
-
2126
2068
  if (val.__json) {
2127
2069
  return val.__json;
2128
2070
  }
2129
-
2130
2071
  if (val.__origin) val = val.__origin;
2131
2072
  if (val.__emit) return undefined;
2132
2073
  return PREFIX + val + SUFFIX;
2133
2074
  }, space);
2134
2075
  }
2135
-
2136
2076
  function makeFn(fn) {
2137
2077
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2138
2078
  }
2139
-
2140
2079
  function parseFn(fn, mode) {
2141
2080
  if (fn && is.String(fn) && fn.length > 4) {
2142
2081
  var v = fn.trim();
2143
2082
  var flag = false;
2144
-
2145
2083
  try {
2146
2084
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2147
2085
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2157,7 +2095,6 @@
2157
2095
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2158
2096
  flag = true;
2159
2097
  }
2160
-
2161
2098
  if (!flag) return fn;
2162
2099
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2163
2100
  val.__json = fn;
@@ -2167,7 +2104,6 @@
2167
2104
  return undefined;
2168
2105
  }
2169
2106
  }
2170
-
2171
2107
  return fn;
2172
2108
  }
2173
2109
  function parseJson(json, mode) {
@@ -2184,8 +2120,7 @@
2184
2120
  configurable: false,
2185
2121
  writable: !!writable
2186
2122
  };
2187
- } //todo 优化位置
2188
-
2123
+ }
2189
2124
  function copyRule(rule) {
2190
2125
  return copyRules([rule])[0];
2191
2126
  }
@@ -2230,7 +2165,6 @@
2230
2165
  } catch (e) {
2231
2166
  logError(e);
2232
2167
  }
2233
-
2234
2168
  return def;
2235
2169
  }
2236
2170
 
@@ -2249,11 +2183,9 @@
2249
2183
  return function (title, field, value) {
2250
2184
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2251
2185
  var maker = new Creator(name, title, field, value, props);
2252
-
2253
2186
  if (init) {
2254
2187
  if (is.Function(init)) init(maker);else maker.props(init);
2255
2188
  }
2256
-
2257
2189
  return maker;
2258
2190
  };
2259
2191
  }
@@ -2318,13 +2250,11 @@
2318
2250
  function copy(value) {
2319
2251
  return deepCopy(value);
2320
2252
  }
2321
-
2322
2253
  function Api(h) {
2323
2254
  function tidyFields(fields) {
2324
2255
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2325
2256
  return fields;
2326
2257
  }
2327
-
2328
2258
  function props(fields, key, val) {
2329
2259
  tidyFields(fields).forEach(function (field) {
2330
2260
  h.getCtxs(field).forEach(function (ctx) {
@@ -2333,7 +2263,6 @@
2333
2263
  });
2334
2264
  });
2335
2265
  }
2336
-
2337
2266
  function allSubForm() {
2338
2267
  var subs = h.subForm;
2339
2268
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2343,39 +2272,32 @@
2343
2272
  return initial;
2344
2273
  }, []);
2345
2274
  }
2346
-
2347
2275
  var api = {
2348
2276
  get config() {
2349
2277
  return h.options;
2350
2278
  },
2351
-
2352
2279
  get options() {
2353
2280
  return h.options;
2354
2281
  },
2355
-
2356
2282
  get form() {
2357
2283
  return h.form;
2358
2284
  },
2359
-
2360
2285
  get rule() {
2361
2286
  return h.rules;
2362
2287
  },
2363
-
2364
2288
  get parent() {
2365
2289
  return h.vm.$pfc && h.vm.$pfc.$f;
2366
2290
  },
2367
-
2368
2291
  get children() {
2369
2292
  return allSubForm();
2370
2293
  },
2371
-
2372
2294
  formData: function formData(fields) {
2373
2295
  return tidyFields(fields).reduce(function (initial, id) {
2374
2296
  var ctx = h.getFieldCtx(id);
2375
2297
  if (!ctx) return initial;
2376
2298
  initial[ctx.field] = copy(ctx.rule.value);
2377
2299
  return initial;
2378
- }, copy(h.appendData));
2300
+ }, h.options.appendValue ? copy(h.appendData) : {});
2379
2301
  },
2380
2302
  getValue: function getValue(field) {
2381
2303
  var ctx = h.getFieldCtx(field);
@@ -2433,7 +2355,6 @@
2433
2355
  var index = h.sort.length - 1,
2434
2356
  rules;
2435
2357
  var ctx = h.getCtx(after);
2436
-
2437
2358
  if (ctx) {
2438
2359
  if (child) {
2439
2360
  rules = ctx.rule.children;
@@ -2443,14 +2364,12 @@
2443
2364
  rules = ctx.root;
2444
2365
  }
2445
2366
  } else rules = h.rules;
2446
-
2447
2367
  rules.splice(index + 1, 0, rule);
2448
2368
  },
2449
2369
  prepend: function prepend(rule, after, child) {
2450
2370
  var index = 0,
2451
2371
  rules;
2452
2372
  var ctx = h.getCtx(after);
2453
-
2454
2373
  if (ctx) {
2455
2374
  if (child) {
2456
2375
  rules = ctx.rule.children;
@@ -2459,7 +2378,6 @@
2459
2378
  rules = ctx.root;
2460
2379
  }
2461
2380
  } else rules = h.rules;
2462
-
2463
2381
  rules.splice(index, 0, rule);
2464
2382
  },
2465
2383
  hidden: function hidden(state, fields) {
@@ -2532,18 +2450,14 @@
2532
2450
  });
2533
2451
  return;
2534
2452
  }
2535
-
2536
2453
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2537
-
2538
2454
  if (!ctxs) {
2539
2455
  return;
2540
2456
  }
2541
-
2542
2457
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2543
2458
  ctxs.forEach(function (ctx) {
2544
2459
  if (!ctx.deleted) {
2545
2460
  var subForm = h.subForm[ctx.id];
2546
-
2547
2461
  if (subForm) {
2548
2462
  if (Array.isArray(subForm)) {
2549
2463
  subForm.forEach(function (form) {
@@ -2552,9 +2466,7 @@
2552
2466
  } else if (subForm) {
2553
2467
  subForm.refresh();
2554
2468
  }
2555
- } //ctx.updateKey(true);
2556
-
2557
-
2469
+ }
2558
2470
  h.$render.clearCache(ctx);
2559
2471
  }
2560
2472
  });
@@ -2602,11 +2514,25 @@
2602
2514
  },
2603
2515
  getRule: function getRule(id, origin) {
2604
2516
  var ctx = h.getCtx(id);
2605
-
2606
2517
  if (ctx) {
2607
2518
  return origin ? ctx.origin : ctx.rule;
2608
2519
  }
2609
2520
  },
2521
+ setEffect: function setEffect(id, attr, value) {
2522
+ var ctx = h.getCtx(id);
2523
+ if (ctx && attr) {
2524
+ if (attr[0] === '$') {
2525
+ attr = attr.substr(1);
2526
+ }
2527
+ if (hasProperty(ctx.rule, '$' + attr)) {
2528
+ $set(ctx.rule, '$' + attr, value);
2529
+ }
2530
+ if (!hasProperty(ctx.rule, 'effect')) {
2531
+ ctx.rule.effect = {};
2532
+ }
2533
+ $set(ctx.rule.effect, attr, value);
2534
+ }
2535
+ },
2610
2536
  updateValidate: function updateValidate(id, validate, merge) {
2611
2537
  if (merge) {
2612
2538
  api.mergeRule(id, {
@@ -2645,7 +2571,6 @@
2645
2571
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2646
2572
  args[_key - 2] = arguments[_key];
2647
2573
  }
2648
-
2649
2574
  return invoke(function () {
2650
2575
  return api.method(id, name).apply(void 0, args);
2651
2576
  });
@@ -2655,11 +2580,9 @@
2655
2580
  },
2656
2581
  trigger: function trigger(id, event) {
2657
2582
  var el = api.el(id);
2658
-
2659
2583
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2660
2584
  args[_key2 - 2] = arguments[_key2];
2661
2585
  }
2662
-
2663
2586
  el && el.$emit.apply(el, [event].concat(args));
2664
2587
  },
2665
2588
  el: function el(id) {
@@ -2684,11 +2607,9 @@
2684
2607
  },
2685
2608
  emit: function emit(name) {
2686
2609
  var _h$vm;
2687
-
2688
2610
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2689
2611
  args[_key3 - 1] = arguments[_key3];
2690
2612
  }
2691
-
2692
2613
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2693
2614
  },
2694
2615
  helper: {
@@ -2699,7 +2620,6 @@
2699
2620
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2700
2621
  api[n] = function () {
2701
2622
  var _h$vm2;
2702
-
2703
2623
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2704
2624
  };
2705
2625
  });
@@ -2717,11 +2637,9 @@
2717
2637
  ctx.parent && this.clearCache(ctx.parent);
2718
2638
  return;
2719
2639
  }
2720
-
2721
2640
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2722
2641
  this.$handle.refresh();
2723
2642
  }
2724
-
2725
2643
  var parent = this.cache[ctx.id].parent;
2726
2644
  this.cache[ctx.id] = null;
2727
2645
  parent && this.clearCache(parent);
@@ -2778,10 +2696,8 @@
2778
2696
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2779
2697
  _data[to] = {};
2780
2698
  }
2781
-
2782
2699
  _data = _data[to];
2783
2700
  }
2784
-
2785
2701
  to = v;
2786
2702
  });
2787
2703
  _data[to] = val;
@@ -2801,7 +2717,6 @@
2801
2717
  var children = ctxs[id].rule.children;
2802
2718
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2803
2719
  }
2804
-
2805
2720
  return initial;
2806
2721
  }, {});
2807
2722
  },
@@ -2810,59 +2725,46 @@
2810
2725
  },
2811
2726
  getTypeSlot: function getTypeSlot(type) {
2812
2727
  var name = 'type-' + toLine(type);
2813
-
2814
2728
  var _fn = function _fn(vm) {
2815
2729
  if (vm) {
2816
2730
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2817
-
2818
2731
  if (slot) {
2819
2732
  return slot;
2820
2733
  }
2821
-
2822
2734
  return _fn(vm.$pfc);
2823
2735
  }
2824
2736
  };
2825
-
2826
2737
  return _fn(this.vm);
2827
2738
  },
2828
2739
  render: function render() {
2829
2740
  var _this = this;
2830
-
2831
2741
  if (!this.vm.isShow) {
2832
2742
  return;
2833
2743
  }
2834
-
2835
2744
  this.$h = this.vm.$createElement;
2836
2745
  this.$manager.beforeRender();
2837
2746
  var vn;
2838
-
2839
2747
  var make = function make() {
2840
2748
  return _this.renderList();
2841
2749
  };
2842
-
2843
2750
  make.renderSlot = function (slot) {
2844
2751
  return _this.renderList(slot);
2845
2752
  };
2846
-
2847
2753
  make.renderName = function (name) {
2848
2754
  return _this.renderId(name);
2849
2755
  };
2850
-
2851
2756
  make.renderField = function (field) {
2852
2757
  return _this.renderId(field, 'field');
2853
2758
  };
2854
-
2855
2759
  if (this.vm.$scopedSlots.container) {
2856
2760
  vn = [this.vm.$scopedSlots.container(make)];
2857
2761
  } else {
2858
2762
  vn = make();
2859
2763
  }
2860
-
2861
2764
  return this.$manager.render(vn);
2862
2765
  },
2863
2766
  renderList: function renderList(slot) {
2864
2767
  var _this2 = this;
2865
-
2866
2768
  return this.sort.map(function (id) {
2867
2769
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2868
2770
  }).filter(function (val) {
@@ -2871,7 +2773,6 @@
2871
2773
  },
2872
2774
  makeVm: function makeVm(rule) {
2873
2775
  var _this3 = this;
2874
-
2875
2776
  var vm = rule.vm;
2876
2777
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2877
2778
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2880,8 +2781,7 @@
2880
2781
  },
2881
2782
  mergeGlobal: function mergeGlobal(ctx) {
2882
2783
  var g = this.$handle.options.global;
2883
- if (!g) return; //todo 缓存配置,更新 option 更新
2884
-
2784
+ if (!g) return;
2885
2785
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2886
2786
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2887
2787
  },
@@ -2908,23 +2808,19 @@
2908
2808
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2909
2809
  });
2910
2810
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2911
-
2912
2811
  if (keys.indexOf(key) > -1) {
2913
2812
  vm.$props[key] = prop.value;
2914
2813
  }
2915
2814
  },
2916
2815
  renderTemp: function renderTemp(ctx) {
2917
2816
  var _this4 = this;
2918
-
2919
2817
  if (!_vue.compile) {
2920
2818
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2921
2819
  return [];
2922
2820
  }
2923
-
2924
2821
  var rule = ctx.prop;
2925
2822
  var id = ctx.id,
2926
2823
  key = ctx.key;
2927
-
2928
2824
  if (!this.tempList[id]) {
2929
2825
  if (!ctx.el) {
2930
2826
  ctx.el = this.makeVm(rule);
@@ -2932,7 +2828,6 @@
2932
2828
  return ctx.parser.mounted(ctx);
2933
2829
  });
2934
2830
  }
2935
-
2936
2831
  var _vm = ctx.el;
2937
2832
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2938
2833
  _this4.onInput(ctx, value);
@@ -2942,7 +2837,6 @@
2942
2837
  template: _vue.compile(rule.template)
2943
2838
  };
2944
2839
  }
2945
-
2946
2840
  var _this$tempList$id = this.tempList[id],
2947
2841
  vm = _this$tempList$id.vm,
2948
2842
  template = _this$tempList$id.template;
@@ -2966,7 +2860,6 @@
2966
2860
  },
2967
2861
  renderId: function renderId(name, type) {
2968
2862
  var _this5 = this;
2969
-
2970
2863
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2971
2864
  return ctxs ? ctxs.map(function (ctx) {
2972
2865
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2975,21 +2868,16 @@
2975
2868
  renderCtx: function renderCtx(ctx, parent) {
2976
2869
  if (ctx.type === 'hidden') return;
2977
2870
  var rule = ctx.rule;
2978
- var preview = this.options.preview || false;
2979
-
2980
2871
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2981
2872
  var vn;
2982
- var cacheFlag = true;
2873
+ var cacheFlag = rule.cache !== false;
2983
2874
  var _type = ctx.trueType;
2984
2875
  var none = !(is.Undef(rule.display) || !!rule.display);
2985
-
2986
2876
  if (_type === 'template' && !rule.template) {
2987
2877
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2988
-
2989
2878
  if (none) {
2990
2879
  this.display(vn);
2991
2880
  }
2992
-
2993
2881
  vn = this.item(ctx, vn);
2994
2882
  } else if (_type === 'fcFragment') {
2995
2883
  vn = this.renderChildren(ctx);
@@ -3001,27 +2889,24 @@
3001
2889
  this.setOptions(ctx);
3002
2890
  this.ctxProp(ctx);
3003
2891
  var prop = ctx.prop;
2892
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3004
2893
  prop.props.formCreateInject = this.injectProp(ctx);
3005
-
2894
+ var preview = prop.preview;
3006
2895
  if (prop.hidden) {
3007
2896
  this.setCache(ctx, undefined, parent);
3008
2897
  return;
3009
2898
  }
3010
-
3011
2899
  if (_type === 'template' && prop.template) {
3012
2900
  vn = this.renderTemp(ctx);
3013
2901
  cacheFlag = false;
3014
2902
  } else {
3015
2903
  var children = [];
3016
-
3017
2904
  if (ctx.parser.renderChildren) {
3018
2905
  children = ctx.parser.renderChildren(ctx);
3019
2906
  } else if (ctx.parser.loadChildren !== false) {
3020
2907
  children = this.renderChildren(ctx);
3021
2908
  }
3022
-
3023
2909
  var slot = this.getTypeSlot(ctx.type);
3024
-
3025
2910
  if (slot) {
3026
2911
  vn = slot({
3027
2912
  rule: rule,
@@ -3035,32 +2920,24 @@
3035
2920
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3036
2921
  }
3037
2922
  }
3038
-
3039
2923
  vn = this.renderSides(vn, ctx);
3040
-
3041
2924
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3042
2925
  vn = this.$manager.makeWrap(ctx, vn);
3043
2926
  }
3044
-
3045
2927
  if (none) {
3046
2928
  vn = this.display(vn);
3047
2929
  }
3048
-
3049
2930
  vn = this.item(ctx, vn);
3050
2931
  }
3051
-
3052
2932
  if (cacheFlag) {
3053
2933
  this.setCache(ctx, vn, parent);
3054
2934
  }
3055
-
3056
2935
  return vn;
3057
2936
  }
3058
-
3059
2937
  return this.getCache(ctx);
3060
2938
  },
3061
2939
  display: function display(vn) {
3062
2940
  var _this6 = this;
3063
-
3064
2941
  if (Array.isArray(vn)) {
3065
2942
  var data = [];
3066
2943
  vn.forEach(function (v) {
@@ -3083,7 +2960,6 @@
3083
2960
  display: 'none'
3084
2961
  }];
3085
2962
  }
3086
-
3087
2963
  return vn;
3088
2964
  }
3089
2965
  },
@@ -3095,7 +2971,6 @@
3095
2971
  },
3096
2972
  injectProp: function injectProp(ctx) {
3097
2973
  var _this7 = this;
3098
-
3099
2974
  if (!this.vm.ctxInject[ctx.id]) {
3100
2975
  $set(this.vm.ctxInject, ctx.id, {
3101
2976
  api: this.$handle.api,
@@ -3103,23 +2978,25 @@
3103
2978
  subForm: function subForm(_subForm) {
3104
2979
  _this7.$handle.addSubForm(ctx, _subForm);
3105
2980
  },
2981
+ getSubForm: function getSubForm() {
2982
+ return _this7.$handle.subForm[ctx.id];
2983
+ },
3106
2984
  options: [],
3107
2985
  children: [],
3108
2986
  prop: {},
3109
2987
  preview: false,
3110
2988
  field: ctx.field,
3111
- rule: ctx.rule
2989
+ rule: ctx.rule,
2990
+ input: ctx.input
3112
2991
  });
3113
2992
  }
3114
-
3115
2993
  var inject = this.vm.ctxInject[ctx.id];
3116
2994
  extend(inject, {
3117
- preview: this.options.preview || false,
2995
+ preview: ctx.prop.preview,
3118
2996
  options: ctx.prop.options,
3119
2997
  children: ctx.rule.children,
3120
2998
  prop: function () {
3121
2999
  var temp = _objectSpread2({}, ctx.prop);
3122
-
3123
3000
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3124
3001
  delete temp.model;
3125
3002
  return temp;
@@ -3129,7 +3006,6 @@
3129
3006
  },
3130
3007
  ctxProp: function ctxProp(ctx, custom) {
3131
3008
  var _this8 = this;
3132
-
3133
3009
  var ref = ctx.ref,
3134
3010
  key = ctx.key,
3135
3011
  rule = ctx.rule;
@@ -3148,7 +3024,6 @@
3148
3024
  }
3149
3025
  }
3150
3026
  }];
3151
-
3152
3027
  if (!custom && ctx.input) {
3153
3028
  ctx.prop.model = {
3154
3029
  value: this.$handle.getFormData(ctx),
@@ -3158,17 +3033,14 @@
3158
3033
  expression: "formData.".concat(ctx.id)
3159
3034
  };
3160
3035
  }
3161
-
3162
3036
  mergeProps(props, ctx.prop);
3163
3037
  return ctx.prop;
3164
3038
  },
3165
3039
  onMounted: function onMounted(ctx) {
3166
3040
  ctx.el = this.vm.$refs[ctx.ref];
3167
-
3168
3041
  if (ctx.el) {
3169
3042
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3170
3043
  }
3171
-
3172
3044
  ctx.parser.mounted(ctx);
3173
3045
  this.$handle.effect(ctx, 'mounted');
3174
3046
  },
@@ -3177,19 +3049,15 @@
3177
3049
  },
3178
3050
  renderChildren: function renderChildren(ctx) {
3179
3051
  var _this9 = this;
3180
-
3181
3052
  var children = ctx.rule.children,
3182
3053
  orgChildren = this.orgChildren[ctx.id];
3183
-
3184
3054
  var isRm = function isRm(child) {
3185
3055
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3186
3056
  };
3187
-
3188
3057
  if (!is.trueArray(children) && orgChildren) {
3189
3058
  this.$handle.deferSyncValue(function () {
3190
3059
  orgChildren.forEach(function (child) {
3191
3060
  if (!child) return;
3192
-
3193
3061
  if (isRm(child)) {
3194
3062
  _this9.$handle.rmCtx(child.__fc__);
3195
3063
  }
@@ -3198,11 +3066,9 @@
3198
3066
  this.orgChildren[ctx.id] = [];
3199
3067
  return [];
3200
3068
  }
3201
-
3202
3069
  orgChildren && this.$handle.deferSyncValue(function () {
3203
3070
  orgChildren.forEach(function (child) {
3204
3071
  if (!child) return;
3205
-
3206
3072
  if (children.indexOf(child) === -1 && isRm(child)) {
3207
3073
  _this9.$handle.rmCtx(child.__fc__);
3208
3074
  }
@@ -3211,15 +3077,12 @@
3211
3077
  return children.map(function (child) {
3212
3078
  if (!child) return;
3213
3079
  if (is.String(child)) return child;
3214
-
3215
3080
  if (child.__fc__) {
3216
3081
  return _this9.renderCtx(child.__fc__, ctx);
3217
3082
  }
3218
-
3219
3083
  if (child.type) {
3220
3084
  _this9.vm.$nextTick(function () {
3221
3085
  _this9.$handle.loadChildren(children, ctx);
3222
-
3223
3086
  _this9.$handle.refresh();
3224
3087
  });
3225
3088
  }
@@ -3227,38 +3090,33 @@
3227
3090
  },
3228
3091
  defaultRender: function defaultRender(ctx, children) {
3229
3092
  var prop = ctx.prop;
3093
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3230
3094
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3231
3095
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3232
3096
  return this.vNode.make(lower(ctx.originType), prop, children);
3233
3097
  },
3234
3098
  renderRule: function renderRule(rule, children, origin) {
3235
3099
  var _this10 = this;
3236
-
3237
3100
  if (!rule) return undefined;
3238
3101
  if (is.String(rule)) return rule;
3239
3102
  var type;
3240
-
3241
3103
  if (origin) {
3242
3104
  type = rule.type;
3243
3105
  } else {
3244
3106
  type = rule.is;
3245
-
3246
3107
  if (rule.type) {
3247
3108
  type = toCase(rule.type);
3248
3109
  var alias = this.vNode.aliasMap[type];
3249
3110
  if (alias) type = toCase(alias);
3250
3111
  }
3251
3112
  }
3252
-
3253
3113
  if (!type) return undefined;
3254
3114
  var data = [[children]];
3255
-
3256
3115
  if (is.trueArray(rule.children)) {
3257
3116
  data.push(rule.children.map(function (v) {
3258
3117
  return _this10.renderRule(v);
3259
3118
  }));
3260
3119
  }
3261
-
3262
3120
  return this.$h(type, _objectSpread2({}, rule), data);
3263
3121
  }
3264
3122
  });
@@ -3294,10 +3152,8 @@
3294
3152
  },
3295
3153
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3296
3154
  var _this = this;
3297
-
3298
3155
  Object.keys(data).forEach(function (k) {
3299
3156
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3300
-
3301
3157
  if (fn) {
3302
3158
  data[k] = fn;
3303
3159
  }
@@ -3311,7 +3167,6 @@
3311
3167
  return this.parseEventLst(rule, fn, inject, true);
3312
3168
  } else if (is.String(fn)) {
3313
3169
  var val = parseFn(fn);
3314
-
3315
3170
  if (val && fn !== val) {
3316
3171
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3317
3172
  }
@@ -3319,7 +3174,6 @@
3319
3174
  },
3320
3175
  parseEmit: function parseEmit(ctx, on) {
3321
3176
  var _this2 = this;
3322
-
3323
3177
  var event = {},
3324
3178
  rule = ctx.rule,
3325
3179
  emitPrefix = rule.emitPrefix,
@@ -3327,48 +3181,36 @@
3327
3181
  name = rule.name,
3328
3182
  inject = rule.inject;
3329
3183
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3330
-
3331
3184
  if (is.trueArray(emit)) {
3332
3185
  var emitKey = emitPrefix || field || name;
3333
-
3334
3186
  if (emitKey) {
3335
3187
  if (!on) emitKey = "native-".concat(emitKey);
3336
3188
  emit.forEach(function (eventName) {
3337
3189
  if (!eventName) return;
3338
3190
  var eventInject;
3339
-
3340
3191
  if (is.Object(eventName)) {
3341
3192
  eventInject = eventName.inject;
3342
3193
  eventName = eventName.name;
3343
3194
  }
3344
-
3345
3195
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3346
-
3347
3196
  var fn = function fn() {
3348
3197
  var _this2$vm, _this2$vm2;
3349
-
3350
3198
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3351
3199
  arg[_key] = arguments[_key];
3352
3200
  }
3353
-
3354
3201
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3355
-
3356
3202
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3357
3203
  };
3358
-
3359
3204
  fn.__emit = true;
3360
-
3361
3205
  if (!eventInject && inject === false) {
3362
3206
  event[eventName] = fn;
3363
3207
  } else {
3364
3208
  var _inject = eventInject || inject || _this2.options.injectEvent;
3365
-
3366
3209
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3367
3210
  }
3368
3211
  });
3369
3212
  }
3370
3213
  }
3371
-
3372
3214
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3373
3215
  return event;
3374
3216
  },
@@ -3390,21 +3232,16 @@
3390
3232
  if (this.watching && !this.loading) return _fn;
3391
3233
  _fn = _fn.__origin;
3392
3234
  }
3393
-
3394
3235
  var h = this;
3395
-
3396
3236
  var fn = function fn() {
3397
3237
  var data = h.getInjectData(self, _inject2);
3398
-
3399
3238
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3400
3239
  args[_key2] = arguments[_key2];
3401
3240
  }
3402
-
3403
3241
  data.args = [].concat(args);
3404
3242
  args.unshift(data);
3405
3243
  return _fn.apply(this, args);
3406
3244
  };
3407
-
3408
3245
  fn.__origin = _fn;
3409
3246
  fn.__json = _fn.__json;
3410
3247
  return fn;
@@ -3417,17 +3254,14 @@
3417
3254
  extend(Handler.prototype, {
3418
3255
  usePage: function usePage() {
3419
3256
  var _this = this;
3420
-
3421
3257
  var page = this.options.page;
3422
3258
  if (!page) return;
3423
3259
  var first = 25;
3424
3260
  var limit = getLimit(this.rules);
3425
-
3426
3261
  if (is.Object(page)) {
3427
3262
  if (page.first) first = parseInt(page.first, 10) || first;
3428
3263
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3429
3264
  }
3430
-
3431
3265
  extend(this, {
3432
3266
  first: first,
3433
3267
  limit: limit,
@@ -3440,27 +3274,21 @@
3440
3274
  },
3441
3275
  pageLoad: function pageLoad() {
3442
3276
  var _this2 = this;
3443
-
3444
3277
  var pageFn = function pageFn() {
3445
3278
  if (_this2.pageEnd) {
3446
3279
  _this2.vm.$off(EVENT, pageFn);
3447
-
3448
3280
  _this2.bus.$emit('page-end');
3449
3281
  } else {
3450
3282
  _this2.first += _this2.limit;
3451
3283
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3452
-
3453
3284
  _this2.loadRule();
3454
-
3455
3285
  _this2.refresh();
3456
3286
  }
3457
3287
  };
3458
-
3459
3288
  this.vm.$on(EVENT, pageFn);
3460
3289
  }
3461
3290
  });
3462
3291
  }
3463
-
3464
3292
  function getLimit(rules) {
3465
3293
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3466
3294
  }
@@ -3473,7 +3301,6 @@
3473
3301
  },
3474
3302
  bindNextTick: function bindNextTick(fn) {
3475
3303
  var _this = this;
3476
-
3477
3304
  this.clearNextTick();
3478
3305
  this.nextTick = setTimeout(function () {
3479
3306
  fn();
@@ -3481,7 +3308,6 @@
3481
3308
  }, 10);
3482
3309
  },
3483
3310
  render: function render() {
3484
- // console.warn('%c render', 'color:green');
3485
3311
  ++this.loadedId;
3486
3312
  if (this.vm.unique > 0) return this.$render.render();else {
3487
3313
  this.vm.unique = 1;
@@ -3496,7 +3322,6 @@
3496
3322
  __fc__: enumerable(ctx, true)
3497
3323
  });
3498
3324
  }
3499
-
3500
3325
  function RuleContext(handle, rule) {
3501
3326
  var id = uniqueId();
3502
3327
  extend(this, {
@@ -3530,7 +3355,6 @@
3530
3355
  if (!this.payload[name]) {
3531
3356
  this.payload[name] = {};
3532
3357
  }
3533
-
3534
3358
  return this.payload[name];
3535
3359
  },
3536
3360
  clearEffectData: function clearEffectData(name) {
@@ -3550,9 +3374,7 @@
3550
3374
  },
3551
3375
  initProp: function initProp() {
3552
3376
  var _this = this;
3553
-
3554
3377
  var rule = _objectSpread2({}, this.rule);
3555
-
3556
3378
  delete rule.children;
3557
3379
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3558
3380
  return _this.payload[k];
@@ -3607,31 +3429,22 @@
3607
3429
  },
3608
3430
  rm: function rm() {
3609
3431
  var _this2 = this;
3610
-
3611
3432
  var _rm = function _rm() {
3612
3433
  var index = _this2.root.indexOf(_this2.origin);
3613
-
3614
3434
  if (index > -1) {
3615
3435
  _this2.root.splice(index, 1);
3616
-
3617
3436
  _this2.$handle && _this2.$handle.refresh();
3618
3437
  }
3619
3438
  };
3620
-
3621
3439
  if (this.deleted) {
3622
3440
  _rm();
3623
-
3624
3441
  return;
3625
3442
  }
3626
-
3627
3443
  this.$handle.noWatch(function () {
3628
3444
  _this2.$handle.deferSyncValue(function () {
3629
3445
  _this2.rmCtrl();
3630
-
3631
3446
  _rm();
3632
-
3633
3447
  _this2.$handle.rmCtx(_this2);
3634
-
3635
3448
  extend(_this2, {
3636
3449
  root: []
3637
3450
  });
@@ -3659,7 +3472,6 @@
3659
3472
  extend(Handler.prototype, {
3660
3473
  nextRefresh: function nextRefresh(fn) {
3661
3474
  var _this = this;
3662
-
3663
3475
  var id = this.loadedId;
3664
3476
  this.vm.$nextTick(function () {
3665
3477
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3667,7 +3479,6 @@
3667
3479
  },
3668
3480
  parseRule: function parseRule(_rule) {
3669
3481
  var _this2 = this;
3670
-
3671
3482
  var rule = getRule(_rule);
3672
3483
  Object.defineProperties(rule, {
3673
3484
  __origin__: enumerable(_rule, true)
@@ -3679,20 +3490,16 @@
3679
3490
  if (!item) {
3680
3491
  return;
3681
3492
  }
3682
-
3683
3493
  _this2.loadFn(item, rule);
3684
3494
  });
3685
3495
  this.loadCtrl(rule);
3686
-
3687
3496
  if (rule.update) {
3688
3497
  rule.update = parseFn(rule.update);
3689
3498
  }
3690
-
3691
3499
  return rule;
3692
3500
  },
3693
3501
  loadFn: function loadFn(item, rule) {
3694
3502
  var _this3 = this;
3695
-
3696
3503
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3697
3504
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3698
3505
  });
@@ -3706,48 +3513,35 @@
3706
3513
  },
3707
3514
  syncProp: function syncProp(ctx) {
3708
3515
  var _this4 = this;
3709
-
3710
3516
  var rule = ctx.rule;
3711
3517
  is.trueArray(rule.sync) && mergeProps([{
3712
3518
  on: rule.sync.reduce(function (pre, prop) {
3713
3519
  pre["update:".concat(prop)] = function (val) {
3714
3520
  rule.props[prop] = val;
3715
-
3716
3521
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3717
3522
  };
3718
-
3719
3523
  return pre;
3720
3524
  }, {})
3721
3525
  }], ctx.computed);
3722
3526
  },
3723
3527
  loadRule: function loadRule() {
3724
3528
  var _this5 = this;
3725
-
3726
- // console.warn('%c load', 'color:blue');
3727
3529
  this.cycleLoad = false;
3728
3530
  this.loading = true;
3729
-
3730
3531
  if (this.pageEnd) {
3731
3532
  this.bus.$emit('load-start');
3732
3533
  }
3733
-
3734
3534
  this.deferSyncValue(function () {
3735
3535
  _this5._loadRule(_this5.rules);
3736
-
3737
3536
  _this5.loading = false;
3738
-
3739
3537
  if (_this5.cycleLoad && _this5.pageEnd) {
3740
3538
  return _this5.loadRule();
3741
3539
  }
3742
-
3743
3540
  if (_this5.pageEnd) {
3744
3541
  _this5.bus.$emit('load-end');
3745
3542
  }
3746
-
3747
3543
  _this5.vm._renderRule();
3748
-
3749
3544
  _this5.$render.initOrgChildren();
3750
-
3751
3545
  _this5.syncForm();
3752
3546
  });
3753
3547
  },
@@ -3755,79 +3549,60 @@
3755
3549
  this.cycleLoad = false;
3756
3550
  this.loading = true;
3757
3551
  this.bus.$emit('load-start');
3758
-
3759
3552
  this._loadRule(children, parent);
3760
-
3761
3553
  this.loading = false;
3762
-
3763
3554
  if (this.cycleLoad) {
3764
3555
  return this.loadRule();
3765
3556
  } else {
3766
3557
  this.bus.$emit('load-end');
3767
3558
  this.syncForm();
3768
3559
  }
3769
-
3770
3560
  this.$render.clearCache(parent);
3771
3561
  },
3772
3562
  _loadRule: function _loadRule(rules, parent) {
3773
3563
  var _this6 = this;
3774
-
3775
3564
  var preIndex = function preIndex(i) {
3776
3565
  var pre = rules[i - 1];
3777
-
3778
3566
  if (!pre || !pre.__fc__) {
3779
3567
  return i > 0 ? preIndex(i - 1) : -1;
3780
3568
  }
3781
-
3782
3569
  var index = _this6.sort.indexOf(pre.__fc__.id);
3783
-
3784
3570
  return index > -1 ? index : preIndex(i - 1);
3785
3571
  };
3786
-
3787
3572
  var loadChildren = function loadChildren(children, parent) {
3788
3573
  if (is.trueArray(children)) {
3789
3574
  _this6._loadRule(children, parent);
3790
3575
  }
3791
3576
  };
3792
-
3793
3577
  rules.map(function (_rule, index) {
3794
3578
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3795
3579
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3796
3580
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3797
-
3798
3581
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3799
3582
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3800
3583
  return _rule.__fc__;
3801
3584
  }
3802
-
3803
3585
  var rule = getRule(_rule);
3804
-
3805
3586
  var isRepeat = function isRepeat() {
3806
3587
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3807
3588
  };
3808
-
3809
3589
  _this6.ruleEffect(rule, 'init', {
3810
3590
  repeat: isRepeat()
3811
3591
  });
3812
-
3813
3592
  if (isRepeat()) {
3814
3593
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3815
3594
  }
3816
-
3817
3595
  var ctx;
3818
3596
  var isCopy = false;
3819
3597
  var isInit = !!_rule.__fc__;
3820
-
3821
3598
  if (isInit) {
3822
3599
  ctx = _rule.__fc__;
3823
3600
  var check = !ctx.check(_this6);
3824
-
3825
3601
  if (ctx.deleted) {
3826
3602
  if (check) {
3827
3603
  if (isCtrl(ctx)) {
3828
3604
  return;
3829
3605
  }
3830
-
3831
3606
  ctx.update(_this6);
3832
3607
  }
3833
3608
  } else {
@@ -3835,66 +3610,49 @@
3835
3610
  if (isCtrl(ctx)) {
3836
3611
  return;
3837
3612
  }
3838
-
3839
3613
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3840
3614
  ctx = null;
3841
3615
  isCopy = true;
3842
3616
  }
3843
3617
  }
3844
3618
  }
3845
-
3846
3619
  if (!ctx) {
3847
3620
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3848
-
3849
3621
  _this6.bindParser(ctx);
3850
3622
  } else {
3851
3623
  if (ctx.originType !== ctx.rule.type) {
3852
3624
  ctx.updateType();
3853
-
3854
3625
  _this6.bindParser(ctx);
3855
3626
  }
3856
-
3857
3627
  _this6.appendValue(ctx.rule);
3858
3628
  }
3859
-
3860
3629
  [false, true].forEach(function (b) {
3861
3630
  return _this6.parseEmit(ctx, b);
3862
3631
  });
3863
-
3864
3632
  _this6.syncProp(ctx);
3865
-
3866
3633
  ctx.parent = parent || null;
3867
3634
  ctx.root = rules;
3868
-
3869
3635
  _this6.setCtx(ctx);
3870
-
3871
3636
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3872
3637
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3873
-
3874
3638
  if (!parent) {
3875
3639
  var _preIndex = preIndex(index);
3876
-
3877
3640
  if (_preIndex > -1 || !index) {
3878
3641
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3879
3642
  } else {
3880
3643
  _this6.sort.push(ctx.id);
3881
3644
  }
3882
3645
  }
3883
-
3884
3646
  var r = ctx.rule;
3885
-
3886
3647
  if (!ctx.updated) {
3887
3648
  ctx.updated = true;
3888
-
3889
3649
  if (is.Function(r.update)) {
3890
3650
  _this6.bus.$once('load-end', function () {
3891
3651
  _this6.refreshUpdate(ctx, r.value);
3892
3652
  });
3893
3653
  }
3894
-
3895
3654
  _this6.effect(ctx, 'loaded');
3896
3655
  }
3897
-
3898
3656
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3899
3657
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3900
3658
  return ctx;
@@ -3905,20 +3663,16 @@
3905
3663
  },
3906
3664
  useCtrl: function useCtrl(ctx) {
3907
3665
  var _this7 = this;
3908
-
3909
3666
  var controls = getCtrl(ctx),
3910
3667
  validate = [],
3911
3668
  api = this.api;
3912
3669
  if (!controls.length) return false;
3913
-
3914
3670
  var _loop = function _loop(i) {
3915
3671
  var control = controls[i],
3916
3672
  handleFn = control.handle || function (val) {
3917
3673
  return val === control.value;
3918
3674
  };
3919
-
3920
3675
  if (!is.trueArray(control.rule)) return "continue";
3921
-
3922
3676
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3923
3677
  valid: invoke(function () {
3924
3678
  return handleFn(ctx.rule.value, api);
@@ -3926,17 +3680,13 @@
3926
3680
  ctrl: findCtrl(ctx, control.rule),
3927
3681
  isHidden: is.String(control.rule[0])
3928
3682
  });
3929
-
3930
3683
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3931
3684
  validate.push(data);
3932
3685
  };
3933
-
3934
3686
  for (var i = 0; i < controls.length; i++) {
3935
3687
  var _ret = _loop(i);
3936
-
3937
3688
  if (_ret === "continue") continue;
3938
3689
  }
3939
-
3940
3690
  if (!validate.length) return false;
3941
3691
  var flag = false;
3942
3692
  this.deferSyncValue(function () {
@@ -3948,21 +3698,17 @@
3948
3698
  append = _ref.append,
3949
3699
  child = _ref.child,
3950
3700
  ctrl = _ref.ctrl;
3951
-
3952
3701
  if (isHidden) {
3953
3702
  valid ? ctx.ctrlRule.push({
3954
3703
  __ctrl: true,
3955
3704
  children: rule,
3956
3705
  valid: valid
3957
3706
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3958
-
3959
3707
  _this7.vm.$nextTick(function () {
3960
3708
  _this7.api.hidden(!valid, rule);
3961
3709
  });
3962
-
3963
3710
  return;
3964
3711
  }
3965
-
3966
3712
  if (valid) {
3967
3713
  flag = true;
3968
3714
  var ruleCon = {
@@ -3972,9 +3718,7 @@
3972
3718
  children: rule
3973
3719
  };
3974
3720
  ctx.ctrlRule.push(ruleCon);
3975
-
3976
3721
  _this7.bus.$once('load-start', function () {
3977
- // this.cycleLoad = true;
3978
3722
  if (prepend) {
3979
3723
  api.prepend(ruleCon, prepend, child);
3980
3724
  } else if (append || child) {
@@ -3999,60 +3743,53 @@
3999
3743
  },
4000
3744
  _reloadRule: function _reloadRule(rules) {
4001
3745
  var _this8 = this;
4002
-
4003
- // console.warn('%c reload', 'color:red');
4004
3746
  if (!rules) rules = this.rules;
4005
-
4006
3747
  var ctxs = _objectSpread2({}, this.ctxs);
4007
-
4008
3748
  this.clearNextTick();
4009
3749
  this.$render.clearOrgChildren();
4010
3750
  this.initData(rules);
4011
3751
  this.fc.rules = rules;
4012
- this.bus.$once('load-end', function () {
4013
- Object.keys(ctxs).filter(function (id) {
4014
- return _this8.ctxs[id] === undefined;
4015
- }).forEach(function (id) {
4016
- return _this8.rmCtx(ctxs[id]);
3752
+ this.deferSyncValue(function () {
3753
+ _this8.bus.$once('load-end', function () {
3754
+ Object.keys(ctxs).filter(function (id) {
3755
+ return _this8.ctxs[id] === undefined;
3756
+ }).forEach(function (id) {
3757
+ return _this8.rmCtx(ctxs[id]);
3758
+ });
3759
+ _this8.$render.clearCacheAll();
4017
3760
  });
4018
-
4019
- _this8.$render.clearCacheAll();
3761
+ _this8.reloading = true;
3762
+ _this8.loadRule();
3763
+ _this8.reloading = false;
3764
+ _this8.refresh();
3765
+ _this8.vm.$emit('reload', _this8.api);
4020
3766
  });
4021
- this.reloading = true;
4022
- this.loadRule();
4023
- this.reloading = false;
4024
- this.refresh();
4025
3767
  this.bus.$off('next-tick', this.nextReload);
4026
3768
  this.bus.$once('next-tick', this.nextReload);
4027
3769
  this.vm.$emit('update', this.api);
4028
3770
  },
4029
- //todo 组件生成全部通过 alias
4030
3771
  refresh: function refresh() {
4031
3772
  this.vm._refresh();
4032
3773
  }
4033
3774
  });
4034
3775
  }
4035
-
4036
3776
  function fullRule(rule) {
4037
3777
  var def = baseRule();
4038
3778
  Object.keys(def).forEach(function (k) {
4039
- if (!hasProperty(rule, k)) rule[k] = def[k];
3779
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4040
3780
  });
4041
3781
  return rule;
4042
3782
  }
4043
-
4044
3783
  function getCtrl(ctx) {
4045
3784
  var control = ctx.rule.control || [];
4046
3785
  if (is.Object(control)) return [control];else return control;
4047
3786
  }
4048
-
4049
3787
  function findCtrl(ctx, rule) {
4050
3788
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4051
3789
  var ctrl = ctx.ctrlRule[i];
4052
3790
  if (ctrl.children === rule) return ctrl;
4053
3791
  }
4054
3792
  }
4055
-
4056
3793
  function isCtrl(ctx) {
4057
3794
  return !!ctx.rule.__ctrl;
4058
3795
  }
@@ -4063,7 +3800,6 @@
4063
3800
  if (is.Undef(ctx.cacheValue)) {
4064
3801
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4065
3802
  }
4066
-
4067
3803
  return ctx.cacheValue;
4068
3804
  },
4069
3805
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4080,7 +3816,6 @@
4080
3816
  },
4081
3817
  onInput: function onInput(ctx, value) {
4082
3818
  var val;
4083
-
4084
3819
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4085
3820
  this.setValue(ctx, val, value);
4086
3821
  }
@@ -4093,7 +3828,6 @@
4093
3828
  },
4094
3829
  validate: function validate() {
4095
3830
  var _this = this;
4096
-
4097
3831
  toEmpty(this.vm.validate);
4098
3832
  this.fields().forEach(function (id) {
4099
3833
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4104,17 +3838,14 @@
4104
3838
  },
4105
3839
  syncForm: function syncForm() {
4106
3840
  var _this2 = this;
4107
-
4108
3841
  toEmpty(this.form);
4109
3842
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4110
3843
  var ctx = _this2.getFieldCtx(field);
4111
-
4112
3844
  var handle = _this2.valueHandle(ctx);
4113
-
4114
3845
  handle.configurable = true;
4115
3846
  initial[field] = handle;
4116
3847
  return initial;
4117
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3848
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4118
3849
  initial[field] = {
4119
3850
  enumerable: true,
4120
3851
  configurable: true,
@@ -4126,12 +3857,11 @@
4126
3857
  }
4127
3858
  };
4128
3859
  return initial;
4129
- }, {})));
3860
+ }, {}) : {}));
4130
3861
  this.syncValue();
4131
3862
  },
4132
3863
  valueHandle: function valueHandle(ctx) {
4133
3864
  var _this3 = this;
4134
-
4135
3865
  return {
4136
3866
  enumerable: true,
4137
3867
  get: function get() {
@@ -4150,24 +3880,18 @@
4150
3880
  delete this.appendData[rule.field];
4151
3881
  },
4152
3882
  addSubForm: function addSubForm(ctx, subForm) {
4153
- if (ctx.input) {
4154
- this.subForm[ctx.id] = subForm;
4155
- }
3883
+ this.subForm[ctx.id] = subForm;
4156
3884
  },
4157
3885
  deferSyncValue: function deferSyncValue(fn, sync) {
4158
3886
  if (!this.deferSyncFn) {
4159
3887
  this.deferSyncFn = fn;
4160
3888
  }
4161
-
4162
3889
  if (!this.deferSyncFn.sync) {
4163
3890
  this.deferSyncFn.sync = sync;
4164
3891
  }
4165
-
4166
3892
  invoke(fn);
4167
-
4168
3893
  if (this.deferSyncFn === fn) {
4169
3894
  this.deferSyncFn = null;
4170
-
4171
3895
  if (fn.sync) {
4172
3896
  this.syncValue();
4173
3897
  }
@@ -4177,18 +3901,16 @@
4177
3901
  if (this.deferSyncFn) {
4178
3902
  return this.deferSyncFn.sync = true;
4179
3903
  }
4180
-
4181
3904
  this.vm._updateValue(_objectSpread2({}, this.form));
4182
3905
  },
4183
3906
  isChange: function isChange(ctx, value) {
4184
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3907
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4185
3908
  },
4186
3909
  isQuote: function isQuote(ctx, value) {
4187
3910
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4188
3911
  },
4189
3912
  refreshUpdate: function refreshUpdate(ctx, val) {
4190
3913
  var _this4 = this;
4191
-
4192
3914
  if (is.Function(ctx.rule.update)) {
4193
3915
  var state = invoke(function () {
4194
3916
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4208,20 +3930,16 @@
4208
3930
  this.vm.$emit('update', this.api);
4209
3931
  this.refresh();
4210
3932
  }
4211
-
4212
3933
  this.refreshUpdate(ctx, val);
4213
3934
  },
4214
3935
  appendLink: function appendLink(ctx) {
4215
3936
  var _this5 = this;
4216
-
4217
3937
  var link = ctx.rule.link;
4218
3938
  is.trueArray(link) && link.forEach(function (field) {
4219
3939
  var fn = function fn() {
4220
3940
  return _this5.refreshRule(ctx, ctx.rule.value);
4221
3941
  };
4222
-
4223
3942
  _this5.bus.$on('change-' + field, fn);
4224
-
4225
3943
  ctx.linkOn.push(function () {
4226
3944
  return _this5.bus.$off('change-' + field, fn);
4227
3945
  });
@@ -4232,11 +3950,9 @@
4232
3950
  }
4233
3951
  });
4234
3952
  }
4235
-
4236
3953
  function strFn(key, val) {
4237
3954
  return typeof val === 'function' ? '' + val : val;
4238
3955
  }
4239
-
4240
3956
  function toEmpty(obj) {
4241
3957
  Object.keys(obj).forEach(function (k) {
4242
3958
  return delete obj[k];
@@ -4256,11 +3972,12 @@
4256
3972
  return ctx.$render.defaultRender(ctx, children);
4257
3973
  },
4258
3974
  preview: function preview(children, ctx) {
4259
- return ctx.$render.defaultRender(ctx, children);
3975
+ return this.render(children, ctx);
4260
3976
  },
4261
3977
  mergeProp: function mergeProp(ctx) {}
4262
3978
  };
4263
3979
 
3980
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4264
3981
  function useContext(Handler) {
4265
3982
  extend(Handler.prototype, {
4266
3983
  getCtx: function getCtx(id) {
@@ -4271,7 +3988,6 @@
4271
3988
  },
4272
3989
  setIdCtx: function setIdCtx(ctx, key, type) {
4273
3990
  var field = "".concat(type, "Ctx");
4274
-
4275
3991
  if (!this[field][key]) {
4276
3992
  this[field][key] = [ctx];
4277
3993
  } else {
@@ -4283,11 +3999,9 @@
4283
3999
  var lst = this[field][key];
4284
4000
  if (!lst) return false;
4285
4001
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4286
-
4287
4002
  if (!lst.length) {
4288
4003
  delete this[field][key];
4289
4004
  }
4290
-
4291
4005
  return flag;
4292
4006
  },
4293
4007
  getFieldCtx: function getFieldCtx(field) {
@@ -4306,7 +4020,6 @@
4306
4020
  if (!ctx.input) return;
4307
4021
  this.setIdCtx(ctx, field, 'field');
4308
4022
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4309
-
4310
4023
  if (this.isMounted && !this.reloading) {
4311
4024
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4312
4025
  }
@@ -4327,70 +4040,51 @@
4327
4040
  if (!this.noWatchFn) {
4328
4041
  this.noWatchFn = fn;
4329
4042
  }
4330
-
4331
4043
  invoke(fn);
4332
-
4333
4044
  if (this.noWatchFn === fn) {
4334
4045
  this.noWatchFn = null;
4335
4046
  }
4336
4047
  },
4337
4048
  watchCtx: function watchCtx(ctx) {
4338
4049
  var _this = this;
4339
-
4340
4050
  var vm = this.vm;
4341
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4342
4051
  Object.keys(ctx.rule).filter(function (k) {
4343
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4052
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4344
4053
  }).forEach(function (key) {
4345
4054
  var flag = key === 'children';
4346
4055
  ctx.watch.push(vm.$watch(function () {
4347
4056
  return ctx.rule[key];
4348
4057
  }, function (n, o) {
4349
4058
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4350
-
4351
4059
  if (flag && ctx.parser.loadChildren === false) {
4352
4060
  _this.$render.clearCache(ctx);
4353
-
4354
4061
  _this.nextRefresh();
4355
-
4356
4062
  return;
4357
4063
  }
4358
-
4359
- _this.watching = true; // if (key === 'hidden')
4360
- // ctx.updateKey(true);
4361
- // else
4362
-
4064
+ _this.watching = true;
4363
4065
  if (key === 'link') {
4364
4066
  ctx.link();
4365
4067
  return;
4366
4068
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4367
4069
  _this.parseInjectEvent(ctx.rule, n || {});
4368
-
4369
4070
  if (key === 'props' && ctx.input) {
4370
4071
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4371
4072
  }
4372
4073
  } 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') {
4373
4074
  ctx.updateType();
4374
-
4375
4075
  _this.bindParser(ctx);
4376
4076
  } else if (key === 'children') {
4377
4077
  var _flag = is.trueArray(n);
4378
-
4379
4078
  _this.deferSyncValue(function () {
4380
4079
  if (n !== o) {
4381
4080
  _this.rmSub(o);
4382
-
4383
4081
  _this.$render.initOrgChildren();
4384
4082
  }
4385
-
4386
4083
  _flag && _this.loadChildren(n, ctx);
4387
-
4388
4084
  _this.vm.$emit('update', _this.api);
4389
4085
  });
4390
4086
  }
4391
-
4392
4087
  _this.$render.clearCache(ctx);
4393
-
4394
4088
  _this.watching = false;
4395
4089
  }, {
4396
4090
  deep: !flag,
@@ -4401,27 +4095,23 @@
4401
4095
  },
4402
4096
  rmSub: function rmSub(sub) {
4403
4097
  var _this2 = this;
4404
-
4405
4098
  is.trueArray(sub) && sub.forEach(function (r) {
4406
4099
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4407
4100
  });
4408
4101
  },
4409
4102
  rmCtx: function rmCtx(ctx) {
4410
4103
  var _this3 = this;
4411
-
4412
4104
  if (ctx.deleted) return;
4413
4105
  var id = ctx.id,
4414
4106
  field = ctx.field,
4415
4107
  input = ctx.input,
4416
4108
  name = ctx.name;
4417
-
4418
4109
  if (ctx.input) {
4419
4110
  Object.defineProperty(ctx.rule, 'value', {
4420
4111
  value: ctx.rule.value,
4421
4112
  writable: true
4422
4113
  });
4423
4114
  }
4424
-
4425
4115
  $del(this.ctxs, id);
4426
4116
  $del(this.$render.tempList, id);
4427
4117
  $del(this.$render.orgChildren, id);
@@ -4429,6 +4119,7 @@
4429
4119
  $del(this.formData, id);
4430
4120
  $del(this.subForm, id);
4431
4121
  $del(ctx, 'cacheValue');
4122
+ input && $del(this.form, field);
4432
4123
  input && this.rmIdCtx(ctx, field, 'field');
4433
4124
  name && this.rmIdCtx(ctx, name, 'name');
4434
4125
  this.deferSyncValue(function () {
@@ -4440,18 +4131,15 @@
4440
4131
  });
4441
4132
  }
4442
4133
  }
4443
-
4444
4134
  if (ctx.root === _this3.rules) {
4445
4135
  _this3.vm._renderRule();
4446
4136
  }
4447
4137
  }
4448
4138
  }, input);
4449
4139
  var index = this.sort.indexOf(id);
4450
-
4451
4140
  if (index > -1) {
4452
4141
  this.sort.splice(index, 1);
4453
4142
  }
4454
-
4455
4143
  this.$render.clearCache(ctx);
4456
4144
  ctx["delete"]();
4457
4145
  this.effect(ctx, 'deleted');
@@ -4466,13 +4154,10 @@
4466
4154
  extend(Handler.prototype, {
4467
4155
  mounted: function mounted() {
4468
4156
  var _this = this;
4469
-
4470
4157
  var _mounted = function _mounted() {
4471
4158
  _this.isMounted = true;
4472
-
4473
4159
  _this.lifecycle('mounted');
4474
4160
  };
4475
-
4476
4161
  if (this.pageEnd) {
4477
4162
  _mounted();
4478
4163
  } else {
@@ -4481,7 +4166,6 @@
4481
4166
  },
4482
4167
  lifecycle: function lifecycle(name) {
4483
4168
  var _this2 = this;
4484
-
4485
4169
  var fn = this.options[name];
4486
4170
  is.Function(fn) && invoke(function () {
4487
4171
  return fn(_this2.api);
@@ -4495,26 +4179,21 @@
4495
4179
  extend(Handler.prototype, {
4496
4180
  useProvider: function useProvider() {
4497
4181
  var _this = this;
4498
-
4499
4182
  var ps = this.fc.providers;
4500
4183
  Object.keys(ps).forEach(function (k) {
4501
4184
  var prop = ps[k];
4502
4185
  prop._c = getComponent(prop);
4503
-
4504
4186
  _this.onEffect(prop);
4505
-
4506
4187
  _this.providers[k] = prop;
4507
4188
  });
4508
4189
  },
4509
4190
  onEffect: function onEffect(provider) {
4510
4191
  var _this2 = this;
4511
-
4512
4192
  var used = [];
4513
4193
  (provider._c || ['*']).forEach(function (name) {
4514
4194
  var type = name === '*' ? '*' : _this2.getType(name);
4515
4195
  if (used.indexOf(type) > -1) return;
4516
4196
  used.push(type);
4517
-
4518
4197
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4519
4198
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4520
4199
  });
@@ -4523,7 +4202,6 @@
4523
4202
  },
4524
4203
  watchEffect: function watchEffect(ctx) {
4525
4204
  var _this3 = this;
4526
-
4527
4205
  var vm = this.vm;
4528
4206
  var effect = {};
4529
4207
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
@@ -4566,13 +4244,11 @@
4566
4244
  if (hasProperty(rule, '$' + name)) {
4567
4245
  return rule['$' + name];
4568
4246
  }
4569
-
4570
4247
  if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4571
4248
  return undefined;
4572
4249
  },
4573
4250
  emitEffect: function emitEffect(_ref, event, append) {
4574
4251
  var _this4 = this;
4575
-
4576
4252
  var ctx = _ref.ctx,
4577
4253
  rule = _ref.rule,
4578
4254
  input = _ref.input,
@@ -4583,15 +4259,12 @@
4583
4259
  if (k[0] === '$') {
4584
4260
  i[k.substr(1)] = rule[k];
4585
4261
  }
4586
-
4587
4262
  return i;
4588
4263
  }, _objectSpread2({}, rule.effect || {}));
4589
4264
  Object.keys(effect).forEach(function (attr) {
4590
4265
  var p = _this4.providers[attr];
4591
4266
  if (!p || p.input && !input) return;
4592
-
4593
4267
  var _type;
4594
-
4595
4268
  if (!p._c) {
4596
4269
  _type = '*';
4597
4270
  } else if (p._used.indexOf(type) > -1) {
@@ -4599,40 +4272,33 @@
4599
4272
  } else {
4600
4273
  return;
4601
4274
  }
4602
-
4603
4275
  var data = _objectSpread2({
4604
4276
  value: effect[attr],
4605
4277
  getValue: function getValue() {
4606
4278
  return _this4.getEffect(rule, attr);
4607
4279
  }
4608
4280
  }, append || {});
4609
-
4610
4281
  if (ctx) {
4611
4282
  data.getProp = function () {
4612
4283
  return ctx.effectData(attr);
4613
4284
  };
4614
-
4615
4285
  data.clearProp = function () {
4616
4286
  return ctx.clearEffectData(attr);
4617
4287
  };
4618
-
4619
4288
  data.mergeProp = function (prop) {
4620
4289
  return mergeProps([prop], data.getProp());
4621
4290
  };
4622
4291
  }
4623
-
4624
4292
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4625
4293
  });
4626
4294
  }
4627
4295
  });
4628
4296
  }
4629
-
4630
4297
  function unique(arr) {
4631
4298
  return arr.filter(function (item, index, arr) {
4632
4299
  return arr.indexOf(item, 0) === index;
4633
4300
  });
4634
4301
  }
4635
-
4636
4302
  function getComponent(p) {
4637
4303
  var c = p.components;
4638
4304
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4642,7 +4308,6 @@
4642
4308
 
4643
4309
  function Handler(fc) {
4644
4310
  var _this = this;
4645
-
4646
4311
  extend(this, {
4647
4312
  fc: fc,
4648
4313
  vm: fc.vm,
@@ -4694,9 +4359,7 @@
4694
4359
  this.useProvider();
4695
4360
  this.usePage();
4696
4361
  this.loadRule();
4697
-
4698
4362
  this.$manager.__init();
4699
-
4700
4363
  this.vm.$set(this.vm, 'formData', this.formData);
4701
4364
  }
4702
4365
  });
@@ -4709,7 +4372,6 @@
4709
4372
  useLifecycle(Handler);
4710
4373
  useEffect(Handler);
4711
4374
 
4712
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4713
4375
  function getError(action, option, xhr) {
4714
4376
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4715
4377
  var err = new Error(msg);
@@ -4717,44 +4379,34 @@
4717
4379
  err.url = action;
4718
4380
  return err;
4719
4381
  }
4720
-
4721
4382
  function getBody(xhr) {
4722
4383
  var text = xhr.responseText || xhr.response;
4723
-
4724
4384
  if (!text) {
4725
4385
  return text;
4726
4386
  }
4727
-
4728
4387
  try {
4729
4388
  return JSON.parse(text);
4730
4389
  } catch (e) {
4731
4390
  return text;
4732
4391
  }
4733
4392
  }
4734
-
4735
4393
  function fetch(option) {
4736
4394
  if (typeof XMLHttpRequest === 'undefined') {
4737
4395
  return;
4738
4396
  }
4739
-
4740
4397
  var xhr = new XMLHttpRequest();
4741
4398
  var action = option.action;
4742
-
4743
4399
  xhr.onerror = function error(e) {
4744
4400
  option.onError(e);
4745
4401
  };
4746
-
4747
4402
  xhr.onload = function onload() {
4748
4403
  if (xhr.status < 200 || xhr.status >= 300) {
4749
4404
  return option.onError(getError(action, option, xhr), getBody(xhr));
4750
4405
  }
4751
-
4752
4406
  option.onSuccess(getBody(xhr));
4753
4407
  };
4754
-
4755
4408
  xhr.open(option.method || 'get', action, true);
4756
4409
  var formData;
4757
-
4758
4410
  if (option.data) {
4759
4411
  if ((option.dataType || '').toLowerCase() !== 'json') {
4760
4412
  formData = new FormData();
@@ -4766,11 +4418,9 @@
4766
4418
  xhr.setRequestHeader('content-type', 'application/json');
4767
4419
  }
4768
4420
  }
4769
-
4770
4421
  if (option.withCredentials && 'withCredentials' in xhr) {
4771
4422
  xhr.withCredentials = true;
4772
4423
  }
4773
-
4774
4424
  var headers = option.headers || {};
4775
4425
  Object.keys(headers).forEach(function (item) {
4776
4426
  if (headers[item] !== null) {
@@ -4798,14 +4448,11 @@
4798
4448
  };
4799
4449
  return prop;
4800
4450
  }
4801
-
4802
4451
  function CreateNodeFactory() {
4803
4452
  var aliasMap = {};
4804
-
4805
4453
  function CreateNode(vm) {
4806
4454
  vm && this.setVm(vm);
4807
4455
  }
4808
-
4809
4456
  extend(CreateNode.prototype, {
4810
4457
  setVm: function setVm(vm) {
4811
4458
  this.vm = vm;
@@ -4813,7 +4460,10 @@
4813
4460
  },
4814
4461
  make: function make(tag, data, children) {
4815
4462
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4816
- var Node = this.$h(tag, parseProp(data), children || []);
4463
+ return this.makeComponent(tag, data, children);
4464
+ },
4465
+ makeComponent: function makeComponent(type, data, children) {
4466
+ var Node = this.$h(type, parseProp(data), children || []);
4817
4467
  Node.context = this.vm;
4818
4468
  return Node;
4819
4469
  },
@@ -4831,7 +4481,6 @@
4831
4481
  var v = nodes[k];
4832
4482
  [k, line, lower].forEach(function (n) {
4833
4483
  CreateNode.alias(k, v);
4834
-
4835
4484
  CreateNode.prototype[n] = function (data, children) {
4836
4485
  return this.make(v, data, children);
4837
4486
  };
@@ -4843,20 +4492,15 @@
4843
4492
  }
4844
4493
 
4845
4494
  function createManager(proto) {
4846
- var CustomManager = /*#__PURE__*/function (_Manager) {
4495
+ var CustomManager = function (_Manager) {
4847
4496
  _inherits(CustomManager, _Manager);
4848
-
4849
4497
  var _super = _createSuper(CustomManager);
4850
-
4851
4498
  function CustomManager() {
4852
4499
  _classCallCheck(this, CustomManager);
4853
-
4854
4500
  return _super.apply(this, arguments);
4855
4501
  }
4856
-
4857
4502
  return CustomManager;
4858
4503
  }(Manager);
4859
-
4860
4504
  Object.assign(CustomManager.prototype, proto);
4861
4505
  return CustomManager;
4862
4506
  }
@@ -4876,19 +4520,15 @@
4876
4520
  extend(Manager.prototype, {
4877
4521
  __init: function __init() {
4878
4522
  var _this = this;
4879
-
4880
4523
  this.$render = this.$handle.$render;
4881
-
4882
4524
  this.$r = function () {
4883
4525
  var _this$$render;
4884
-
4885
4526
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4886
4527
  };
4887
4528
  },
4888
4529
  updateKey: function updateKey() {
4889
4530
  this.key = uniqueId();
4890
4531
  },
4891
- //TODO interface
4892
4532
  init: function init() {},
4893
4533
  update: function update() {},
4894
4534
  beforeRender: function beforeRender() {},
@@ -4897,7 +4537,6 @@
4897
4537
  },
4898
4538
  mergeOptions: function mergeOptions(args, opt) {
4899
4539
  var _this2 = this;
4900
-
4901
4540
  return mergeProps(args.map(function (v) {
4902
4541
  return _this2.tidyOptions(v);
4903
4542
  }), opt, this.mergeOptionsRule);
@@ -4933,7 +4572,6 @@
4933
4572
  name: 'required',
4934
4573
  load: function load(inject, rule, api) {
4935
4574
  var val = parseVa(inject.getValue());
4936
-
4937
4575
  if (val.required === false) {
4938
4576
  inject.clearProp();
4939
4577
  } else {
@@ -4943,21 +4581,17 @@
4943
4581
  is.empty(v) ? call(validate.message) : call();
4944
4582
  }
4945
4583
  });
4946
-
4947
4584
  if (!validate.message) {
4948
4585
  validate.message = rule.title + ' is required';
4949
4586
  }
4950
-
4951
4587
  inject.getProp().validate = [validate];
4952
4588
  }
4953
-
4954
4589
  api.sync(rule);
4955
4590
  },
4956
4591
  watch: function watch() {
4957
4592
  $required.load.apply($required, arguments);
4958
4593
  }
4959
4594
  };
4960
-
4961
4595
  function parseVa(val) {
4962
4596
  if (is.Boolean(val)) {
4963
4597
  return {
@@ -4973,7 +4607,6 @@
4973
4607
  return val;
4974
4608
  }
4975
4609
  }
4976
-
4977
4610
  function parseOpt(option) {
4978
4611
  if (is.String(option)) {
4979
4612
  option = {
@@ -4981,29 +4614,21 @@
4981
4614
  to: 'options'
4982
4615
  };
4983
4616
  }
4984
-
4985
4617
  return option;
4986
4618
  }
4987
-
4988
4619
  function run(inject, rule, api) {
4989
4620
  var option = inject.value;
4990
-
4991
4621
  if (is.Function(option)) {
4992
4622
  option = option(rule, api);
4993
4623
  }
4994
-
4995
4624
  option = parseOpt(option);
4996
-
4997
4625
  if (!option || !option.action) {
4998
4626
  return false;
4999
4627
  }
5000
-
5001
4628
  if (!option.to) {
5002
4629
  option.to = 'options';
5003
4630
  }
5004
-
5005
4631
  var _onError = option.onError;
5006
-
5007
4632
  var check = function check() {
5008
4633
  if (!inject.getValue()) {
5009
4634
  inject.clearProp();
@@ -5011,7 +4636,6 @@
5011
4636
  return true;
5012
4637
  }
5013
4638
  };
5014
-
5015
4639
  var set = function set(val) {
5016
4640
  if (val === undefined) {
5017
4641
  inject.clearProp();
@@ -5020,7 +4644,6 @@
5020
4644
  deepSet(inject.getProp(), option.to, val);
5021
4645
  }
5022
4646
  };
5023
-
5024
4647
  invoke(function () {
5025
4648
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5026
4649
  onSuccess: function onSuccess(body) {
@@ -5033,7 +4656,6 @@
5033
4656
  onError: function onError(e) {
5034
4657
  set(undefined);
5035
4658
  if (check()) return;
5036
-
5037
4659
  (_onError || function (e) {
5038
4660
  return err(e.message || 'fetch fail ' + option.action);
5039
4661
  })(e, rule, api);
@@ -5042,7 +4664,6 @@
5042
4664
  });
5043
4665
  return true;
5044
4666
  }
5045
-
5046
4667
  var $provider = {
5047
4668
  fetch: $fetch,
5048
4669
  required: $required
@@ -5063,42 +4684,34 @@
5063
4684
  return is.String(v);
5064
4685
  }).join('');
5065
4686
  }
5066
-
5067
4687
  return '';
5068
4688
  }
5069
4689
  };
5070
4690
 
5071
4691
  var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
5072
-
5073
4692
  function _parseProp(name, id) {
5074
4693
  var prop;
5075
-
5076
4694
  if (arguments.length === 2) {
5077
4695
  prop = arguments[1];
5078
4696
  id = prop[name];
5079
4697
  } else {
5080
4698
  prop = arguments[2];
5081
4699
  }
5082
-
5083
4700
  return {
5084
4701
  id: id,
5085
4702
  prop: prop
5086
4703
  };
5087
4704
  }
5088
-
5089
4705
  function nameProp() {
5090
4706
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
5091
4707
  }
5092
-
5093
4708
  function _getEl(options) {
5094
4709
  if (!options || !options.el) return window.document.body;
5095
4710
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
5096
4711
  }
5097
-
5098
4712
  function mountForm(rules, option) {
5099
4713
  var $vm = new _vue({
5100
4714
  data: function data() {
5101
- //todo 外部无法修改
5102
4715
  return {
5103
4716
  rule: rules,
5104
4717
  option: option || {}
@@ -5114,7 +4727,6 @@
5114
4727
  $vm.$mount();
5115
4728
  return $vm;
5116
4729
  }
5117
-
5118
4730
  function exportAttrs(attrs) {
5119
4731
  var key = attrs.key || [];
5120
4732
  var array = attrs.array || [];
@@ -5124,18 +4736,13 @@
5124
4736
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
5125
4737
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
5126
4738
  }
5127
-
5128
4739
  var id$1 = 1;
5129
- var instance = {}; //todo 表单嵌套
5130
-
4740
+ var instance = {};
5131
4741
  function FormCreateFactory(config) {
5132
4742
  var components = _defineProperty({}, fragment.name, fragment);
5133
-
5134
4743
  var parsers = {};
5135
4744
  var directives = {};
5136
-
5137
4745
  var providers = _objectSpread2({}, $provider);
5138
-
5139
4746
  var maker = makerFactory();
5140
4747
  var globalConfig = {
5141
4748
  global: {}
@@ -5143,27 +4750,24 @@
5143
4750
  var data = {};
5144
4751
  var CreateNode = CreateNodeFactory();
5145
4752
  exportAttrs(config.attrs || {});
5146
-
5147
4753
  function getApi(name) {
5148
- return instance[name];
4754
+ var val = instance[name];
4755
+ if (Array.isArray(val)) return _toConsumableArray(val);
4756
+ return val;
5149
4757
  }
5150
-
5151
4758
  function directive() {
5152
4759
  var data = nameProp.apply(void 0, arguments);
5153
4760
  if (data.id && data.prop) directives[data.id] = data.prop;
5154
4761
  }
5155
-
5156
4762
  function register() {
5157
4763
  var data = nameProp.apply(void 0, arguments);
5158
4764
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5159
4765
  name: data.id
5160
4766
  });
5161
4767
  }
5162
-
5163
4768
  function componentAlias(alias) {
5164
4769
  CreateNode.use(alias);
5165
4770
  }
5166
-
5167
4771
  function parser() {
5168
4772
  var data = nameProp.apply(void 0, arguments);
5169
4773
  if (!data.id || !data.prop) return;
@@ -5174,13 +4778,10 @@
5174
4778
  maker[name] = creatorFactory(name);
5175
4779
  parser.maker && extend(maker, parser.maker);
5176
4780
  }
5177
-
5178
4781
  function component(id, component) {
5179
4782
  var name;
5180
-
5181
4783
  if (is.String(id)) {
5182
4784
  name = toCase(id);
5183
-
5184
4785
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5185
4786
  return $form();
5186
4787
  } else if (component === undefined) {
@@ -5190,39 +4791,29 @@
5190
4791
  name = toCase(id.name);
5191
4792
  component = id;
5192
4793
  }
5193
-
5194
4794
  if (!name || !component) return;
5195
4795
  components[name] = component;
5196
4796
  if (component.formCreateParser) parser(name, component.formCreateParser);
5197
4797
  }
5198
-
5199
4798
  function $form() {
5200
4799
  return _vue.extend($FormCreate(FormCreate));
5201
4800
  }
5202
-
5203
4801
  function $vnode() {
5204
4802
  return _vue.extend(fragment);
5205
- } //todo 检查回调函数作用域
5206
-
5207
-
4803
+ }
5208
4804
  function use(fn, opt) {
5209
4805
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5210
4806
  return this;
5211
4807
  }
5212
-
5213
4808
  function create(rules, _opt, parent) {
5214
4809
  var $vm = mountForm(rules, _opt || {});
5215
4810
  var _this = $vm.$refs.fc.formCreate;
5216
4811
  _this.$parent = parent;
5217
-
5218
4812
  _getEl(_this.options).appendChild($vm.$el);
5219
-
5220
4813
  return _this.api();
5221
4814
  }
5222
-
5223
4815
  function factory(inherit) {
5224
4816
  var _config = _objectSpread2({}, config);
5225
-
5226
4817
  if (inherit) {
5227
4818
  _config.inherit = {
5228
4819
  components: components,
@@ -5235,10 +4826,8 @@
5235
4826
  } else {
5236
4827
  delete _config.inherit;
5237
4828
  }
5238
-
5239
4829
  return FormCreateFactory(_config);
5240
4830
  }
5241
-
5242
4831
  function FormCreate(vm, rules, options) {
5243
4832
  extend(this, {
5244
4833
  id: id$1++,
@@ -5249,6 +4838,7 @@
5249
4838
  providers: providers,
5250
4839
  rules: Array.isArray(rules) ? rules : [],
5251
4840
  name: vm.$options.propsData.name,
4841
+ inFor: vm.$options.propsData.inFor,
5252
4842
  prop: {
5253
4843
  components: components,
5254
4844
  directives: directives
@@ -5256,22 +4846,25 @@
5256
4846
  CreateNode: CreateNode,
5257
4847
  bus: new _vue(),
5258
4848
  unwatch: null,
4849
+ options: options || {},
5259
4850
  extendApi: config.extendApi || function (api) {
5260
4851
  return api;
5261
4852
  }
5262
4853
  });
5263
4854
  this.init();
5264
- this.initOptions(options || {});
5265
-
4855
+ this.initOptions(this.options);
5266
4856
  if (this.name) {
5267
- instance[this.name] = this.api();
4857
+ if (this.inFor) {
4858
+ if (!instance[this.name]) instance[this.name] = [];
4859
+ instance[this.name].push(this.api());
4860
+ } else {
4861
+ instance[this.name] = this.api();
4862
+ }
5268
4863
  }
5269
4864
  }
5270
-
5271
4865
  extend(FormCreate.prototype, {
5272
4866
  init: function init() {
5273
4867
  var _this2 = this;
5274
-
5275
4868
  var vm = this.vm;
5276
4869
  var h = new Handler(this);
5277
4870
  this.$handle = h;
@@ -5283,15 +4876,12 @@
5283
4876
  return vm.$pfc.option;
5284
4877
  }, function () {
5285
4878
  _this2.initOptions(_this2.options);
5286
-
5287
4879
  vm.$f.refresh();
5288
4880
  }, {
5289
4881
  deep: true
5290
4882
  });
5291
-
5292
4883
  _this2.initOptions(_this2.options);
5293
4884
  }
5294
-
5295
4885
  _this2.created();
5296
4886
  });
5297
4887
  vm.$on('hook:mounted', function () {
@@ -5301,9 +4891,13 @@
5301
4891
  vm.destroyed = true;
5302
4892
  _this2.unwatch && _this2.unwatch();
5303
4893
  h.reloadRule([]);
5304
-
5305
4894
  if (_this2.name) {
5306
- delete instance[_this2.name];
4895
+ if (_this2.inFor) {
4896
+ var idx = instance[_this2.name].indexOf(_this2.api());
4897
+ instance[_this2.name].splice(idx, 1);
4898
+ } else {
4899
+ delete instance[_this2.name];
4900
+ }
5307
4901
  }
5308
4902
  });
5309
4903
  vm.$on('hook:updated', function () {
@@ -5321,11 +4915,9 @@
5321
4915
  submitBtn: {},
5322
4916
  resetBtn: {}
5323
4917
  }, deepCopy(globalConfig));
5324
-
5325
4918
  if (this.isSub()) {
5326
4919
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5327
4920
  }
5328
-
5329
4921
  this.updateOptions(options);
5330
4922
  },
5331
4923
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5333,12 +4925,10 @@
5333
4925
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5334
4926
  delete opt[n];
5335
4927
  });
5336
-
5337
4928
  if (opt.global) {
5338
4929
  target.global = mergeGlobal(target.global, opt.global);
5339
4930
  delete opt.global;
5340
4931
  }
5341
-
5342
4932
  this.$handle.$manager.mergeOptions([opt], target);
5343
4933
  return target;
5344
4934
  },
@@ -5360,7 +4950,6 @@
5360
4950
  this.$handle.mounted();
5361
4951
  }
5362
4952
  });
5363
-
5364
4953
  function useAttr(formCreate) {
5365
4954
  extend(formCreate, {
5366
4955
  version: config.version,
@@ -5385,15 +4974,12 @@
5385
4974
  getApi: getApi,
5386
4975
  init: function init(rules) {
5387
4976
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5388
-
5389
4977
  var $vm = mountForm(rules, _opt),
5390
4978
  _this = $vm.$refs.fc.formCreate;
5391
4979
  return {
5392
4980
  mount: function mount($el) {
5393
4981
  if ($el && is.Element($el)) _this.options.el = $el;
5394
-
5395
4982
  _getEl(_this.options).appendChild($vm.$el);
5396
-
5397
4983
  return _this.api();
5398
4984
  },
5399
4985
  remove: function remove() {
@@ -5408,7 +4994,6 @@
5408
4994
  }
5409
4995
  });
5410
4996
  }
5411
-
5412
4997
  function useStatic(formCreate) {
5413
4998
  extend(formCreate, {
5414
4999
  create: create,
@@ -5417,12 +5002,10 @@
5417
5002
  if (Vue._installedFormCreate === true) return;
5418
5003
  Vue._installedFormCreate = true;
5419
5004
  _vue = Vue;
5420
-
5421
5005
  var $formCreate = function $formCreate(rules) {
5422
5006
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5423
5007
  return create(rules, opt, this);
5424
5008
  };
5425
-
5426
5009
  useAttr($formCreate);
5427
5010
  Vue.prototype.$formCreate = $formCreate;
5428
5011
  Vue.component('FormCreate', $form());
@@ -5430,7 +5013,6 @@
5430
5013
  }
5431
5014
  });
5432
5015
  }
5433
-
5434
5016
  useAttr(create);
5435
5017
  useStatic(create);
5436
5018
  CreateNode.use({
@@ -5438,7 +5020,6 @@
5438
5020
  });
5439
5021
  parser(html);
5440
5022
  if (config.install) create.use(config);
5441
-
5442
5023
  if (config.inherit) {
5443
5024
  var inherit = config.inherit;
5444
5025
  inherit.components && extend(components, inherit.components);
@@ -5448,7 +5029,6 @@
5448
5029
  inherit.maker && extend(maker, inherit.maker);
5449
5030
  inherit.data && extend(data, inherit.data);
5450
5031
  }
5451
-
5452
5032
  return create;
5453
5033
  }
5454
5034
 
@@ -5475,7 +5055,6 @@
5475
5055
  }(),
5476
5056
  mergeProp: function mergeProp(ctx) {
5477
5057
  var props = ctx.prop.props;
5478
-
5479
5058
  if (!props.valueFormat) {
5480
5059
  props.valueFormat = DEFAULT_FORMATS[props.type] || DEFAULT_FORMATS['date'];
5481
5060
  }
@@ -5510,7 +5089,6 @@
5510
5089
  }(),
5511
5090
  mergeProp: function mergeProp(ctx) {
5512
5091
  var props = ctx.prop.props;
5513
-
5514
5092
  if (props && props.autosize && props.autosize.minRows) {
5515
5093
  props.rows = props.autosize.minRows || 2;
5516
5094
  }
@@ -5530,13 +5108,11 @@
5530
5108
  props = ctx.prop.props,
5531
5109
  min = props.min || 0,
5532
5110
  parseValue;
5533
-
5534
5111
  if (props.range === true) {
5535
5112
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5536
5113
  } else {
5537
5114
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5538
5115
  }
5539
-
5540
5116
  return parseValue;
5541
5117
  }
5542
5118
  };
@@ -5554,7 +5130,6 @@
5554
5130
  },
5555
5131
  mergeProp: function mergeProp(ctx) {
5556
5132
  var props = ctx.prop.props;
5557
-
5558
5133
  if (!props.valueFormat) {
5559
5134
  props.valueFormat = 'HH:mm:ss';
5560
5135
  }
@@ -5658,26 +5233,20 @@
5658
5233
  function isTooltip(info) {
5659
5234
  return info.type === 'tooltip';
5660
5235
  }
5661
-
5662
5236
  var upperCaseReg = /[A-Z]/;
5663
5237
  function isAttr(name, value) {
5664
5238
  return !upperCaseReg.test(name) && (is.String(value) || is.Number(value));
5665
5239
  }
5666
-
5667
5240
  function tidy(props, name) {
5668
5241
  if (!hasProperty(props, name)) return;
5669
-
5670
5242
  if (is.String(props[name])) {
5671
5243
  var _props$name;
5672
-
5673
5244
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5674
5245
  }
5675
5246
  }
5676
-
5677
5247
  function isFalse(val) {
5678
5248
  return val === false;
5679
5249
  }
5680
-
5681
5250
  function tidyBool(opt, name) {
5682
5251
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5683
5252
  opt[name] = {
@@ -5685,7 +5254,6 @@
5685
5254
  };
5686
5255
  }
5687
5256
  }
5688
-
5689
5257
  var manager = {
5690
5258
  validate: function validate(call) {
5691
5259
  this.form().validate(call);
@@ -5695,7 +5263,6 @@
5695
5263
  },
5696
5264
  clearValidateState: function clearValidateState(ctx) {
5697
5265
  var fItem = this.vm.$refs[ctx.wrapRef];
5698
-
5699
5266
  if (fItem) {
5700
5267
  fItem.validateMessage = '';
5701
5268
  fItem.validateState = '';
@@ -5772,7 +5339,6 @@
5772
5339
  if (children.length) {
5773
5340
  children.push(this.makeFormBtn());
5774
5341
  }
5775
-
5776
5342
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5777
5343
  },
5778
5344
  makeWrap: function makeWrap(ctx, children) {
@@ -5810,7 +5376,6 @@
5810
5376
  var isTip = isTooltip(infoProp);
5811
5377
  var form = this.options.form;
5812
5378
  var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
5813
-
5814
5379
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5815
5380
  var prop = {
5816
5381
  type: infoProp.type || 'popover',
@@ -5819,11 +5384,9 @@
5819
5384
  slot: 'label'
5820
5385
  };
5821
5386
  var field = 'content';
5822
-
5823
5387
  if (infoProp.info && !hasProperty(prop.props, field)) {
5824
5388
  prop.props[field] = infoProp.info;
5825
5389
  }
5826
-
5827
5390
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5828
5391
  type: 'i',
5829
5392
  slot: isTip ? 'default' : 'reference',
@@ -5831,7 +5394,6 @@
5831
5394
  key: "".concat(uni, "i")
5832
5395
  })]));
5833
5396
  }
5834
-
5835
5397
  return this.$r(mergeProps([titleProp, {
5836
5398
  props: titleProp,
5837
5399
  slot: titleProp.slot || 'label',
@@ -5861,19 +5423,15 @@
5861
5423
  },
5862
5424
  makeFormBtn: function makeFormBtn() {
5863
5425
  var vn = [];
5864
-
5865
5426
  if (!isFalse(this.options.submitBtn.show)) {
5866
5427
  vn.push(this.makeSubmitBtn());
5867
5428
  }
5868
-
5869
5429
  if (!isFalse(this.options.resetBtn.show)) {
5870
5430
  vn.push(this.makeResetBtn());
5871
5431
  }
5872
-
5873
5432
  if (!vn.length) {
5874
5433
  return;
5875
5434
  }
5876
-
5877
5435
  var item = this.$r({
5878
5436
  type: 'formItem',
5879
5437
  key: "".concat(this.key, "fb")
@@ -5888,7 +5446,6 @@
5888
5446
  },
5889
5447
  makeResetBtn: function makeResetBtn() {
5890
5448
  var _this = this;
5891
-
5892
5449
  var resetBtn = this.options.resetBtn;
5893
5450
  return this.$r({
5894
5451
  type: 'button',
@@ -5907,7 +5464,6 @@
5907
5464
  },
5908
5465
  makeSubmitBtn: function makeSubmitBtn() {
5909
5466
  var _this2 = this;
5910
-
5911
5467
  var submitBtn = this.options.submitBtn;
5912
5468
  return this.$r({
5913
5469
  type: 'button',
@@ -5932,7 +5488,6 @@
5932
5488
  useTree(maker);
5933
5489
  useUpload(maker);
5934
5490
  useFrame(maker);
5935
-
5936
5491
  function useAlias(maker) {
5937
5492
  ['group', 'tree', 'switch', 'upload', 'autoComplete', 'checkbox', 'cascader', 'colorPicker', 'datePicker', 'frame', 'inputNumber', 'radio', 'rate'].forEach(function (name) {
5938
5493
  maker[name] = creatorFactory(name);
@@ -5941,14 +5496,12 @@
5941
5496
  maker.number = maker.inputNumber;
5942
5497
  maker.color = maker.colorPicker;
5943
5498
  }
5944
-
5945
5499
  function useSelect(maker) {
5946
5500
  var select = 'select';
5947
5501
  var multiple = 'multiple';
5948
5502
  maker['selectMultiple'] = creatorFactory(select, _defineProperty({}, multiple, true));
5949
5503
  maker['selectOne'] = creatorFactory(select, _defineProperty({}, multiple, false));
5950
5504
  }
5951
-
5952
5505
  function useTree(maker) {
5953
5506
  var name = 'tree';
5954
5507
  var types = {
@@ -5962,7 +5515,6 @@
5962
5515
  return m;
5963
5516
  }, maker);
5964
5517
  }
5965
-
5966
5518
  function useUpload(maker) {
5967
5519
  var name = 'upload';
5968
5520
  var types = {
@@ -5983,7 +5535,6 @@
5983
5535
  maker.uploadImage = maker.image;
5984
5536
  maker.uploadFile = maker.file;
5985
5537
  }
5986
-
5987
5538
  function useFrame(maker) {
5988
5539
  var types = {
5989
5540
  frameInputs: ['input', 0],
@@ -6019,28 +5570,23 @@
6019
5570
  };
6020
5571
  return btn;
6021
5572
  }
6022
-
6023
5573
  function extendApi(api, h) {
6024
5574
  extend(api, {
6025
5575
  validate: function validate(callback) {
6026
5576
  var flag;
6027
5577
  var forms = api.children;
6028
5578
  var len = forms.length;
6029
-
6030
5579
  var validate = function validate() {
6031
5580
  h.$manager.validate(function () {
6032
5581
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6033
5582
  args[_key] = arguments[_key];
6034
5583
  }
6035
-
6036
5584
  if (!args[0] || !flag) {
6037
5585
  flag = args;
6038
5586
  }
6039
-
6040
5587
  callback && callback.apply(void 0, _toConsumableArray(flag));
6041
5588
  });
6042
5589
  };
6043
-
6044
5590
  var validFn = function validFn(args) {
6045
5591
  setTimeout(function () {
6046
5592
  if (!args[0]) {
@@ -6048,23 +5594,19 @@
6048
5594
  flag = args;
6049
5595
  }
6050
5596
  }
6051
-
6052
5597
  if (! --len) {
6053
5598
  validate();
6054
5599
  }
6055
5600
  });
6056
5601
  };
6057
-
6058
5602
  forms.forEach(function (form) {
6059
5603
  form.validate(function () {
6060
5604
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6061
5605
  args[_key2] = arguments[_key2];
6062
5606
  }
6063
-
6064
5607
  return validFn(args);
6065
5608
  });
6066
5609
  });
6067
-
6068
5610
  if (!len) {
6069
5611
  validate();
6070
5612
  }
@@ -6075,23 +5617,19 @@
6075
5617
  var sub = h.subForm[ctx.id];
6076
5618
  var len = 0;
6077
5619
  var flag;
6078
-
6079
5620
  var validate = function validate() {
6080
5621
  h.$manager.validateField(ctx.id, function () {
6081
5622
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
6082
5623
  args[_key3] = arguments[_key3];
6083
5624
  }
6084
-
6085
5625
  if (args[0]) {
6086
5626
  flag = args;
6087
5627
  } else if (flag) {
6088
5628
  return callback && callback('子表单验证未通过', flag[1]);
6089
5629
  }
6090
-
6091
5630
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
6092
5631
  });
6093
5632
  };
6094
-
6095
5633
  var validFn = function validFn(args) {
6096
5634
  setTimeout(function () {
6097
5635
  if (!args[0]) {
@@ -6099,31 +5637,26 @@
6099
5637
  flag = args;
6100
5638
  }
6101
5639
  }
6102
-
6103
5640
  if (! --len) {
6104
5641
  validate();
6105
5642
  }
6106
5643
  });
6107
5644
  };
6108
-
6109
5645
  sub && toArray(sub).forEach(function (form) {
6110
5646
  len++;
6111
5647
  form.validate(function () {
6112
5648
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
6113
5649
  args[_key4] = arguments[_key4];
6114
5650
  }
6115
-
6116
5651
  return validFn(args);
6117
5652
  });
6118
5653
  });
6119
-
6120
5654
  if (!len) {
6121
5655
  validate();
6122
5656
  }
6123
5657
  },
6124
5658
  clearValidateState: function clearValidateState(fields) {
6125
5659
  var _this = this;
6126
-
6127
5660
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6128
5661
  api.helper.tidyFields(fields).forEach(function (field) {
6129
5662
  if (clearSub) _this.clearSubValidateState(field);
@@ -6137,7 +5670,6 @@
6137
5670
  h.getCtxs(field).forEach(function (ctx) {
6138
5671
  var subForm = h.subForm[ctx.id];
6139
5672
  if (!subForm) return;
6140
-
6141
5673
  if (Array.isArray(subForm)) {
6142
5674
  subForm.forEach(function (form) {
6143
5675
  form.clearValidateState();
@@ -6151,14 +5683,12 @@
6151
5683
  btn: {
6152
5684
  loading: function loading() {
6153
5685
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6154
-
6155
5686
  api.submitBtnProps({
6156
5687
  loading: !!_loading
6157
5688
  });
6158
5689
  },
6159
5690
  disabled: function disabled() {
6160
5691
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6161
-
6162
5692
  api.submitBtnProps({
6163
5693
  disabled: !!_disabled
6164
5694
  });
@@ -6173,14 +5703,12 @@
6173
5703
  resetBtn: {
6174
5704
  loading: function loading() {
6175
5705
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6176
-
6177
5706
  api.resetBtnProps({
6178
5707
  loading: !!_loading2
6179
5708
  });
6180
5709
  },
6181
5710
  disabled: function disabled() {
6182
5711
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6183
-
6184
5712
  api.resetBtnProps({
6185
5713
  disabled: !!_disabled2
6186
5714
  });
@@ -6209,7 +5737,6 @@
6209
5737
  submit: function submit(successFn, failFn) {
6210
5738
  var _arguments = arguments,
6211
5739
  _this2 = this;
6212
-
6213
5740
  api.validate(function (valid) {
6214
5741
  if (valid) {
6215
5742
  var formData = api.formData();
@@ -6244,11 +5771,10 @@
6244
5771
  FormCreate.maker[name] = maker[name];
6245
5772
  });
6246
5773
  }
6247
-
6248
5774
  function elmFormCreate() {
6249
5775
  return FormCreateFactory({
6250
5776
  ui: "".concat("element-ui"),
6251
- version: "".concat("2.5.19"),
5777
+ version: "".concat("2.5.20"),
6252
5778
  manager: manager,
6253
5779
  extendApi: extendApi,
6254
5780
  install: install,
@@ -6261,15 +5787,12 @@
6261
5787
  }
6262
5788
 
6263
5789
  var FormCreate = elmFormCreate();
6264
-
6265
5790
  if (typeof window !== 'undefined') {
6266
5791
  window.formCreate = FormCreate;
6267
-
6268
5792
  if (window.Vue) {
6269
5793
  FormCreate.install(window.Vue);
6270
5794
  }
6271
5795
  }
6272
-
6273
5796
  var maker$1 = FormCreate.maker;
6274
5797
 
6275
5798
  exports.default = FormCreate;