@form-create/element-ui 2.5.18 → 2.5.21

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