@form-create/element-ui 2.5.19 → 2.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v2.5.19
2
+ * @form-create/element-ui v2.5.22
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,40 @@
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 (item.$f) {
1419
+ var val = item.$f.formData();
1420
+ if (n === o) {
1421
+ item.$f.deferSyncValue(function () {
1422
+ deepExtend(item.rule, n);
1423
+ item.$f.setValue(val);
1424
+ }, true);
1425
+ } else {
1426
+ var _val = item.$f.formData();
1427
+ item.$f.once('reloading', function () {
1428
+ item.$f.setValue(_val);
1429
+ });
1430
+ item.rule = deepCopy(n);
1431
+ }
1432
+ }
1433
+ });
1434
+ },
1435
+ deep: true
1436
+ },
1490
1437
  disabled: function disabled(n) {
1491
1438
  if (this.syncDisabled) {
1492
1439
  var lst = this.cacheRule;
@@ -1497,24 +1444,20 @@
1497
1444
  },
1498
1445
  expand: function expand(n) {
1499
1446
  var d = n - this.value.length;
1500
-
1501
1447
  if (d > 0) {
1502
1448
  this.expandRule(d);
1503
1449
  }
1504
1450
  },
1505
1451
  value: function value(n) {
1506
- var _this = this;
1507
-
1452
+ var _this2 = this;
1508
1453
  n = n || [];
1509
1454
  var keys = Object.keys(this.cacheRule),
1510
1455
  total = keys.length,
1511
1456
  len = total - n.length;
1512
-
1513
1457
  if (len < 0) {
1514
1458
  for (var i = len; i < 0; i++) {
1515
1459
  this.addRule(n.length + i);
1516
1460
  }
1517
-
1518
1461
  for (var _i = 0; _i < total; _i++) {
1519
1462
  this.setValue(keys[_i], n[_i]);
1520
1463
  }
@@ -1523,12 +1466,9 @@
1523
1466
  for (var _i2 = 0; _i2 < len; _i2++) {
1524
1467
  this.removeRule(keys[total - _i2 - 1]);
1525
1468
  }
1526
-
1527
- this.subForm();
1528
1469
  }
1529
-
1530
1470
  n.forEach(function (val, i) {
1531
- _this.setValue(keys[i], n[i]);
1471
+ _this2.setValue(keys[i], n[i]);
1532
1472
  });
1533
1473
  }
1534
1474
  }
@@ -1545,23 +1485,18 @@
1545
1485
  this.$emit('change', value);
1546
1486
  },
1547
1487
  formData: function formData(key, _formData) {
1548
- var _this2 = this;
1549
-
1488
+ var _this3 = this;
1550
1489
  var cacheRule = this.cacheRule;
1551
1490
  var keys = Object.keys(cacheRule);
1552
-
1553
1491
  if (keys.filter(function (k) {
1554
1492
  return cacheRule[k].$f;
1555
1493
  }).length !== keys.length) {
1556
1494
  return;
1557
1495
  }
1558
-
1559
1496
  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
-
1497
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1498
+ var value = _this3.field ? data[_this3.field] || null : data;
1499
+ _this3.cache(k, value);
1565
1500
  return value;
1566
1501
  });
1567
1502
  this.input(value);
@@ -1569,72 +1504,53 @@
1569
1504
  setValue: function setValue(key, value) {
1570
1505
  var field = this.field,
1571
1506
  $f = this.cacheRule[key].$f;
1572
-
1573
1507
  if (field) {
1574
1508
  value = _defineProperty({}, field, this._value(value));
1575
1509
  }
1576
-
1577
1510
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1578
1511
  return;
1579
1512
  }
1580
-
1581
1513
  this.cache(key, value);
1582
1514
  $f.coverValue(value || {});
1583
1515
  },
1584
1516
  addRule: function addRule(i, emit) {
1585
- var _this3 = this;
1586
-
1517
+ var _this4 = this;
1587
1518
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1588
1519
  var options = this.options ? _objectSpread2({}, this.options) : {
1589
1520
  submitBtn: false,
1590
1521
  resetBtn: false
1591
1522
  };
1592
-
1593
1523
  if (this.defaultValue) {
1594
1524
  if (!options.formData) options.formData = {};
1595
1525
  var defVal = deepCopy(this.defaultValue);
1596
1526
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1597
1527
  }
1598
-
1599
1528
  this.$set(this.cacheRule, ++this.len, {
1600
1529
  rule: rule,
1601
1530
  options: options
1602
1531
  });
1603
-
1604
1532
  if (emit) {
1605
1533
  this.$nextTick(function () {
1606
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1534
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1607
1535
  });
1608
1536
  }
1609
1537
  },
1610
1538
  add$f: function add$f(i, key, $f) {
1611
- var _this4 = this;
1612
-
1539
+ var _this5 = this;
1613
1540
  this.cacheRule[key].$f = $f;
1614
- this.subForm();
1615
1541
  this.formData(key, $f.formData());
1616
1542
  this.$nextTick(function () {
1617
- if (_this4.syncDisabled) {
1618
- $f.disabled(_this4.disabled);
1543
+ if (_this5.syncDisabled) {
1544
+ $f.disabled(_this5.disabled);
1619
1545
  }
1620
-
1621
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1546
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1622
1547
  });
1623
1548
  },
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
1549
  removeRule: function removeRule(key, emit) {
1632
1550
  var _this6 = this;
1633
-
1634
1551
  var index = Object.keys(this.cacheRule).indexOf(key);
1635
1552
  this.$delete(this.cacheRule, key);
1636
1553
  this.$delete(this.cacheValue, key);
1637
-
1638
1554
  if (emit) {
1639
1555
  this.$nextTick(function () {
1640
1556
  return _this6.$emit('remove', index);
@@ -1645,16 +1561,13 @@
1645
1561
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1646
1562
  return;
1647
1563
  }
1648
-
1649
1564
  this.addRule(i, true);
1650
1565
  },
1651
1566
  del: function del(index, key) {
1652
1567
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1653
1568
  return;
1654
1569
  }
1655
-
1656
1570
  this.removeRule(key, true);
1657
- this.subForm();
1658
1571
  this.value.splice(index, 1);
1659
1572
  this.input(this.value);
1660
1573
  },
@@ -1671,7 +1584,6 @@
1671
1584
  },
1672
1585
  delIcon: function delIcon(index, key) {
1673
1586
  var _this7 = this;
1674
-
1675
1587
  var h = this.$createElement;
1676
1588
  return h("i", {
1677
1589
  "key": "d".concat(key),
@@ -1686,7 +1598,6 @@
1686
1598
  },
1687
1599
  makeIcon: function makeIcon(total, index, key) {
1688
1600
  var _this8 = this;
1689
-
1690
1601
  if (this.$scopedSlots.button) {
1691
1602
  return this.$scopedSlots.button({
1692
1603
  total: total,
@@ -1699,11 +1610,9 @@
1699
1610
  add: this.add
1700
1611
  });
1701
1612
  }
1702
-
1703
1613
  if (index === 0) {
1704
1614
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1705
1615
  }
1706
-
1707
1616
  if (index >= this.min) {
1708
1617
  return this.delIcon(index, key);
1709
1618
  }
@@ -1720,18 +1629,15 @@
1720
1629
  created: function created() {
1721
1630
  this.type = this.formCreateInject.form.$form();
1722
1631
  var d = (this.expand || 0) - this.value.length;
1723
-
1724
1632
  if (d > 0) {
1725
1633
  this.expandRule(d);
1726
1634
  }
1727
-
1728
1635
  for (var i = 0; i < this.value.length; i++) {
1729
1636
  this.addRule(i);
1730
1637
  }
1731
1638
  },
1732
1639
  render: function render() {
1733
1640
  var _this9 = this;
1734
-
1735
1641
  var h = arguments[0];
1736
1642
  var keys = Object.keys(this.cacheRule);
1737
1643
  var button = this.button;
@@ -1764,7 +1670,10 @@
1764
1670
  "span": button ? 20 : 24
1765
1671
  }
1766
1672
  }, [h("ElFormItem", [h(Type, helper([{
1767
- "key": key
1673
+ "key": key,
1674
+ "attrs": {
1675
+ "inFor": true
1676
+ }
1768
1677
  }, {
1769
1678
  "on": {
1770
1679
  'update:value': function updateValue(formData) {
@@ -1774,7 +1683,6 @@
1774
1683
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1775
1684
  args[_key - 1] = arguments[_key];
1776
1685
  }
1777
-
1778
1686
  return _this9.emitEvent(name, args, index, key);
1779
1687
  },
1780
1688
  input: function input($f) {
@@ -1847,11 +1755,9 @@
1847
1755
  },
1848
1756
  setValue: function setValue(value) {
1849
1757
  var str = JSON.stringify(value);
1850
-
1851
1758
  if (this.cacheValue === str) {
1852
1759
  return;
1853
1760
  }
1854
-
1855
1761
  this.cacheValue = str;
1856
1762
  this.cacheRule.$f.coverValue(value || {});
1857
1763
  },
@@ -1868,23 +1774,16 @@
1868
1774
  },
1869
1775
  add$f: function add$f($f) {
1870
1776
  var _this = this;
1871
-
1872
1777
  this.cacheRule.$f = $f;
1873
- this.subForm();
1874
1778
  this.$nextTick(function () {
1875
1779
  _this.syncDisabled && $f.disabled(_this.disabled);
1876
-
1877
1780
  _this.$emit('itemMounted', $f);
1878
1781
  });
1879
1782
  },
1880
- subForm: function subForm() {
1881
- this.formCreateInject.subForm(this.cacheRule.$f);
1882
- },
1883
1783
  emitEvent: function emitEvent(name) {
1884
1784
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1885
1785
  args[_key - 1] = arguments[_key];
1886
1786
  }
1887
-
1888
1787
  this.$emit.apply(this, [name].concat(args));
1889
1788
  }
1890
1789
  },
@@ -1917,6 +1816,17 @@
1917
1816
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub];
1918
1817
 
1919
1818
  var NAME$8 = 'FormCreate';
1819
+ var getRuleInject = function getRuleInject(vm, parent) {
1820
+ if (!vm || vm === parent) {
1821
+ return;
1822
+ }
1823
+ if (vm.formCreateInject) {
1824
+ return vm.formCreateInject;
1825
+ }
1826
+ if (vm.$parent) {
1827
+ return getRuleInject(vm.$parent, parent);
1828
+ }
1829
+ };
1920
1830
  function $FormCreate(FormCreate) {
1921
1831
  return {
1922
1832
  name: NAME$8,
@@ -1948,7 +1858,12 @@
1948
1858
  extendOption: Boolean,
1949
1859
  value: Object,
1950
1860
  api: Object,
1951
- name: String
1861
+ name: String,
1862
+ subForm: {
1863
+ type: Boolean,
1864
+ "default": true
1865
+ },
1866
+ inFor: Boolean
1952
1867
  },
1953
1868
  data: function data() {
1954
1869
  return {
@@ -1960,7 +1875,8 @@
1960
1875
  unique: 1,
1961
1876
  renderRule: _toConsumableArray(this.rule || []),
1962
1877
  ctxInject: {},
1963
- updateValue: ''
1878
+ updateValue: JSON.stringify(this.value || {}),
1879
+ isMore: !!this.inFor
1964
1880
  };
1965
1881
  },
1966
1882
  render: function render() {
@@ -1982,8 +1898,8 @@
1982
1898
  watch: {
1983
1899
  value: {
1984
1900
  handler: function handler(n) {
1985
- if (JSON.stringify(n) === this.updateValue) return;
1986
- this.$f.setValue(n);
1901
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1902
+ this.$f.setValue(n || {});
1987
1903
  },
1988
1904
  deep: true
1989
1905
  },
@@ -1996,18 +1912,15 @@
1996
1912
  },
1997
1913
  rule: function rule(n) {
1998
1914
  var _this = this;
1999
-
2000
1915
  if (n.length === this.renderRule.length && n.every(function (v) {
2001
1916
  return _this.renderRule.indexOf(v) > -1;
2002
1917
  })) return;
2003
1918
  this.formCreate.$handle.reloadRule(n);
2004
-
2005
1919
  this._renderRule();
2006
1920
  }
2007
1921
  },
2008
1922
  beforeCreate: function beforeCreate() {
2009
1923
  var _this2 = this;
2010
-
2011
1924
  var _this$$options$propsD = this.$options.propsData,
2012
1925
  rule = _this$$options$propsD.rule,
2013
1926
  option = _this$$options$propsD.option;
@@ -2016,6 +1929,50 @@
2016
1929
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
2017
1930
  });
2018
1931
  this.$emit('beforeCreate', this.formCreate.api());
1932
+ },
1933
+ created: function created() {
1934
+ var _this3 = this;
1935
+ var vm = this,
1936
+ fapi = this.formCreate.api();
1937
+ var addSubForm = function addSubForm() {
1938
+ if (vm.$pfc) {
1939
+ var inject = getRuleInject(vm, vm.$pfc);
1940
+ if (inject) {
1941
+ var sub;
1942
+ if (vm.isMore) {
1943
+ sub = toArray(inject.getSubForm());
1944
+ sub.push(fapi);
1945
+ } else {
1946
+ sub = fapi;
1947
+ }
1948
+ inject.subForm(sub);
1949
+ }
1950
+ }
1951
+ };
1952
+ var rmSubForm = function rmSubForm() {
1953
+ var inject = getRuleInject(vm, vm.$pfc);
1954
+ if (inject) {
1955
+ if (vm.isMore) {
1956
+ var sub = toArray(inject.getSubForm());
1957
+ var idx = sub.indexOf(fapi);
1958
+ if (idx > -1) {
1959
+ sub.splice(idx, 1);
1960
+ }
1961
+ } else {
1962
+ inject.subForm();
1963
+ }
1964
+ }
1965
+ };
1966
+ vm.$on('hook:beforeDestroy', function () {
1967
+ rmSubForm();
1968
+ });
1969
+ this.$watch(function () {
1970
+ return _this3.subForm;
1971
+ }, function (n) {
1972
+ n ? addSubForm() : rmSubForm();
1973
+ }, {
1974
+ immediate: true
1975
+ });
2019
1976
  }
2020
1977
  };
2021
1978
  }
@@ -2023,17 +1980,12 @@
2023
1980
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
2024
1981
  var toArrayMerge$1 = ['class', 'style', 'directives'];
2025
1982
  var functionalMerge$1 = ['on', 'nativeOn'];
2026
-
2027
1983
  var mergeProps = function mergeProps(objects) {
2028
1984
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2029
1985
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2030
-
2031
1986
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
2032
-
2033
1987
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
2034
-
2035
1988
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
2036
-
2037
1989
  var propsMerge = opt['props'] || [];
2038
1990
  return objects.reduce(function (a, b) {
2039
1991
  for (var key in b) {
@@ -2050,9 +2002,7 @@
2050
2002
  for (var event in b[key]) {
2051
2003
  if (a[key][event]) {
2052
2004
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2053
-
2054
2005
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2055
-
2056
2006
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2057
2007
  } else {
2058
2008
  a[key][event] = b[key][event];
@@ -2077,11 +2027,9 @@
2077
2027
  } else a[key] = b[key];
2078
2028
  }
2079
2029
  }
2080
-
2081
2030
  return a;
2082
2031
  }, initial);
2083
2032
  };
2084
-
2085
2033
  var mergeFn$1 = function mergeFn(fn1, fn2) {
2086
2034
  return function () {
2087
2035
  fn1 && fn1.apply(this, arguments);
@@ -2089,7 +2037,7 @@
2089
2037
  };
2090
2038
  };
2091
2039
 
2092
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2040
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
2093
2041
  var arrayAttrs = ['validate', 'children', 'control'];
2094
2042
  var normalAttrs = ['effect', 'deep'];
2095
2043
  function attrs() {
@@ -2118,30 +2066,24 @@
2118
2066
  function toJson(obj, space) {
2119
2067
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2120
2068
  if (val && val._isVue === true) return undefined;
2121
-
2122
2069
  if (_typeof(val) !== FUNCTION) {
2123
2070
  return val;
2124
2071
  }
2125
-
2126
2072
  if (val.__json) {
2127
2073
  return val.__json;
2128
2074
  }
2129
-
2130
2075
  if (val.__origin) val = val.__origin;
2131
2076
  if (val.__emit) return undefined;
2132
2077
  return PREFIX + val + SUFFIX;
2133
2078
  }, space);
2134
2079
  }
2135
-
2136
2080
  function makeFn(fn) {
2137
2081
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2138
2082
  }
2139
-
2140
2083
  function parseFn(fn, mode) {
2141
2084
  if (fn && is.String(fn) && fn.length > 4) {
2142
2085
  var v = fn.trim();
2143
2086
  var flag = false;
2144
-
2145
2087
  try {
2146
2088
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2147
2089
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2157,7 +2099,6 @@
2157
2099
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2158
2100
  flag = true;
2159
2101
  }
2160
-
2161
2102
  if (!flag) return fn;
2162
2103
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2163
2104
  val.__json = fn;
@@ -2167,7 +2108,6 @@
2167
2108
  return undefined;
2168
2109
  }
2169
2110
  }
2170
-
2171
2111
  return fn;
2172
2112
  }
2173
2113
  function parseJson(json, mode) {
@@ -2184,8 +2124,7 @@
2184
2124
  configurable: false,
2185
2125
  writable: !!writable
2186
2126
  };
2187
- } //todo 优化位置
2188
-
2127
+ }
2189
2128
  function copyRule(rule) {
2190
2129
  return copyRules([rule])[0];
2191
2130
  }
@@ -2230,7 +2169,6 @@
2230
2169
  } catch (e) {
2231
2170
  logError(e);
2232
2171
  }
2233
-
2234
2172
  return def;
2235
2173
  }
2236
2174
 
@@ -2249,11 +2187,9 @@
2249
2187
  return function (title, field, value) {
2250
2188
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2251
2189
  var maker = new Creator(name, title, field, value, props);
2252
-
2253
2190
  if (init) {
2254
2191
  if (is.Function(init)) init(maker);else maker.props(init);
2255
2192
  }
2256
-
2257
2193
  return maker;
2258
2194
  };
2259
2195
  }
@@ -2318,13 +2254,11 @@
2318
2254
  function copy(value) {
2319
2255
  return deepCopy(value);
2320
2256
  }
2321
-
2322
2257
  function Api(h) {
2323
2258
  function tidyFields(fields) {
2324
2259
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2325
2260
  return fields;
2326
2261
  }
2327
-
2328
2262
  function props(fields, key, val) {
2329
2263
  tidyFields(fields).forEach(function (field) {
2330
2264
  h.getCtxs(field).forEach(function (ctx) {
@@ -2333,7 +2267,6 @@
2333
2267
  });
2334
2268
  });
2335
2269
  }
2336
-
2337
2270
  function allSubForm() {
2338
2271
  var subs = h.subForm;
2339
2272
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2343,39 +2276,32 @@
2343
2276
  return initial;
2344
2277
  }, []);
2345
2278
  }
2346
-
2347
2279
  var api = {
2348
2280
  get config() {
2349
2281
  return h.options;
2350
2282
  },
2351
-
2352
2283
  get options() {
2353
2284
  return h.options;
2354
2285
  },
2355
-
2356
2286
  get form() {
2357
2287
  return h.form;
2358
2288
  },
2359
-
2360
2289
  get rule() {
2361
2290
  return h.rules;
2362
2291
  },
2363
-
2364
2292
  get parent() {
2365
2293
  return h.vm.$pfc && h.vm.$pfc.$f;
2366
2294
  },
2367
-
2368
2295
  get children() {
2369
2296
  return allSubForm();
2370
2297
  },
2371
-
2372
2298
  formData: function formData(fields) {
2373
2299
  return tidyFields(fields).reduce(function (initial, id) {
2374
2300
  var ctx = h.getFieldCtx(id);
2375
2301
  if (!ctx) return initial;
2376
2302
  initial[ctx.field] = copy(ctx.rule.value);
2377
2303
  return initial;
2378
- }, copy(h.appendData));
2304
+ }, h.options.appendValue ? copy(h.appendData) : {});
2379
2305
  },
2380
2306
  getValue: function getValue(field) {
2381
2307
  var ctx = h.getFieldCtx(field);
@@ -2433,7 +2359,6 @@
2433
2359
  var index = h.sort.length - 1,
2434
2360
  rules;
2435
2361
  var ctx = h.getCtx(after);
2436
-
2437
2362
  if (ctx) {
2438
2363
  if (child) {
2439
2364
  rules = ctx.rule.children;
@@ -2443,14 +2368,12 @@
2443
2368
  rules = ctx.root;
2444
2369
  }
2445
2370
  } else rules = h.rules;
2446
-
2447
2371
  rules.splice(index + 1, 0, rule);
2448
2372
  },
2449
2373
  prepend: function prepend(rule, after, child) {
2450
2374
  var index = 0,
2451
2375
  rules;
2452
2376
  var ctx = h.getCtx(after);
2453
-
2454
2377
  if (ctx) {
2455
2378
  if (child) {
2456
2379
  rules = ctx.rule.children;
@@ -2459,7 +2382,6 @@
2459
2382
  rules = ctx.root;
2460
2383
  }
2461
2384
  } else rules = h.rules;
2462
-
2463
2385
  rules.splice(index, 0, rule);
2464
2386
  },
2465
2387
  hidden: function hidden(state, fields) {
@@ -2532,18 +2454,14 @@
2532
2454
  });
2533
2455
  return;
2534
2456
  }
2535
-
2536
2457
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2537
-
2538
2458
  if (!ctxs) {
2539
2459
  return;
2540
2460
  }
2541
-
2542
2461
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2543
2462
  ctxs.forEach(function (ctx) {
2544
2463
  if (!ctx.deleted) {
2545
2464
  var subForm = h.subForm[ctx.id];
2546
-
2547
2465
  if (subForm) {
2548
2466
  if (Array.isArray(subForm)) {
2549
2467
  subForm.forEach(function (form) {
@@ -2552,9 +2470,7 @@
2552
2470
  } else if (subForm) {
2553
2471
  subForm.refresh();
2554
2472
  }
2555
- } //ctx.updateKey(true);
2556
-
2557
-
2473
+ }
2558
2474
  h.$render.clearCache(ctx);
2559
2475
  }
2560
2476
  });
@@ -2602,11 +2518,25 @@
2602
2518
  },
2603
2519
  getRule: function getRule(id, origin) {
2604
2520
  var ctx = h.getCtx(id);
2605
-
2606
2521
  if (ctx) {
2607
2522
  return origin ? ctx.origin : ctx.rule;
2608
2523
  }
2609
2524
  },
2525
+ setEffect: function setEffect(id, attr, value) {
2526
+ var ctx = h.getCtx(id);
2527
+ if (ctx && attr) {
2528
+ if (attr[0] === '$') {
2529
+ attr = attr.substr(1);
2530
+ }
2531
+ if (hasProperty(ctx.rule, '$' + attr)) {
2532
+ $set(ctx.rule, '$' + attr, value);
2533
+ }
2534
+ if (!hasProperty(ctx.rule, 'effect')) {
2535
+ ctx.rule.effect = {};
2536
+ }
2537
+ $set(ctx.rule.effect, attr, value);
2538
+ }
2539
+ },
2610
2540
  updateValidate: function updateValidate(id, validate, merge) {
2611
2541
  if (merge) {
2612
2542
  api.mergeRule(id, {
@@ -2645,7 +2575,6 @@
2645
2575
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2646
2576
  args[_key - 2] = arguments[_key];
2647
2577
  }
2648
-
2649
2578
  return invoke(function () {
2650
2579
  return api.method(id, name).apply(void 0, args);
2651
2580
  });
@@ -2655,11 +2584,9 @@
2655
2584
  },
2656
2585
  trigger: function trigger(id, event) {
2657
2586
  var el = api.el(id);
2658
-
2659
2587
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2660
2588
  args[_key2 - 2] = arguments[_key2];
2661
2589
  }
2662
-
2663
2590
  el && el.$emit.apply(el, [event].concat(args));
2664
2591
  },
2665
2592
  el: function el(id) {
@@ -2684,13 +2611,14 @@
2684
2611
  },
2685
2612
  emit: function emit(name) {
2686
2613
  var _h$vm;
2687
-
2688
2614
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2689
2615
  args[_key3 - 1] = arguments[_key3];
2690
2616
  }
2691
-
2692
2617
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2693
2618
  },
2619
+ deferSyncValue: function deferSyncValue(fn, sync) {
2620
+ h.deferSyncValue(fn, sync);
2621
+ },
2694
2622
  helper: {
2695
2623
  tidyFields: tidyFields,
2696
2624
  props: props
@@ -2699,7 +2627,6 @@
2699
2627
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2700
2628
  api[n] = function () {
2701
2629
  var _h$vm2;
2702
-
2703
2630
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2704
2631
  };
2705
2632
  });
@@ -2717,11 +2644,9 @@
2717
2644
  ctx.parent && this.clearCache(ctx.parent);
2718
2645
  return;
2719
2646
  }
2720
-
2721
2647
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2722
2648
  this.$handle.refresh();
2723
2649
  }
2724
-
2725
2650
  var parent = this.cache[ctx.id].parent;
2726
2651
  this.cache[ctx.id] = null;
2727
2652
  parent && this.clearCache(parent);
@@ -2778,10 +2703,8 @@
2778
2703
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2779
2704
  _data[to] = {};
2780
2705
  }
2781
-
2782
2706
  _data = _data[to];
2783
2707
  }
2784
-
2785
2708
  to = v;
2786
2709
  });
2787
2710
  _data[to] = val;
@@ -2801,7 +2724,6 @@
2801
2724
  var children = ctxs[id].rule.children;
2802
2725
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2803
2726
  }
2804
-
2805
2727
  return initial;
2806
2728
  }, {});
2807
2729
  },
@@ -2810,59 +2732,46 @@
2810
2732
  },
2811
2733
  getTypeSlot: function getTypeSlot(type) {
2812
2734
  var name = 'type-' + toLine(type);
2813
-
2814
2735
  var _fn = function _fn(vm) {
2815
2736
  if (vm) {
2816
2737
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2817
-
2818
2738
  if (slot) {
2819
2739
  return slot;
2820
2740
  }
2821
-
2822
2741
  return _fn(vm.$pfc);
2823
2742
  }
2824
2743
  };
2825
-
2826
2744
  return _fn(this.vm);
2827
2745
  },
2828
2746
  render: function render() {
2829
2747
  var _this = this;
2830
-
2831
2748
  if (!this.vm.isShow) {
2832
2749
  return;
2833
2750
  }
2834
-
2835
2751
  this.$h = this.vm.$createElement;
2836
2752
  this.$manager.beforeRender();
2837
2753
  var vn;
2838
-
2839
2754
  var make = function make() {
2840
2755
  return _this.renderList();
2841
2756
  };
2842
-
2843
2757
  make.renderSlot = function (slot) {
2844
2758
  return _this.renderList(slot);
2845
2759
  };
2846
-
2847
2760
  make.renderName = function (name) {
2848
2761
  return _this.renderId(name);
2849
2762
  };
2850
-
2851
2763
  make.renderField = function (field) {
2852
2764
  return _this.renderId(field, 'field');
2853
2765
  };
2854
-
2855
2766
  if (this.vm.$scopedSlots.container) {
2856
2767
  vn = [this.vm.$scopedSlots.container(make)];
2857
2768
  } else {
2858
2769
  vn = make();
2859
2770
  }
2860
-
2861
2771
  return this.$manager.render(vn);
2862
2772
  },
2863
2773
  renderList: function renderList(slot) {
2864
2774
  var _this2 = this;
2865
-
2866
2775
  return this.sort.map(function (id) {
2867
2776
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2868
2777
  }).filter(function (val) {
@@ -2871,7 +2780,6 @@
2871
2780
  },
2872
2781
  makeVm: function makeVm(rule) {
2873
2782
  var _this3 = this;
2874
-
2875
2783
  var vm = rule.vm;
2876
2784
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2877
2785
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2880,8 +2788,7 @@
2880
2788
  },
2881
2789
  mergeGlobal: function mergeGlobal(ctx) {
2882
2790
  var g = this.$handle.options.global;
2883
- if (!g) return; //todo 缓存配置,更新 option 更新
2884
-
2791
+ if (!g) return;
2885
2792
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2886
2793
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2887
2794
  },
@@ -2908,23 +2815,19 @@
2908
2815
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2909
2816
  });
2910
2817
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2911
-
2912
2818
  if (keys.indexOf(key) > -1) {
2913
2819
  vm.$props[key] = prop.value;
2914
2820
  }
2915
2821
  },
2916
2822
  renderTemp: function renderTemp(ctx) {
2917
2823
  var _this4 = this;
2918
-
2919
2824
  if (!_vue.compile) {
2920
2825
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2921
2826
  return [];
2922
2827
  }
2923
-
2924
2828
  var rule = ctx.prop;
2925
2829
  var id = ctx.id,
2926
2830
  key = ctx.key;
2927
-
2928
2831
  if (!this.tempList[id]) {
2929
2832
  if (!ctx.el) {
2930
2833
  ctx.el = this.makeVm(rule);
@@ -2932,7 +2835,6 @@
2932
2835
  return ctx.parser.mounted(ctx);
2933
2836
  });
2934
2837
  }
2935
-
2936
2838
  var _vm = ctx.el;
2937
2839
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2938
2840
  _this4.onInput(ctx, value);
@@ -2942,7 +2844,6 @@
2942
2844
  template: _vue.compile(rule.template)
2943
2845
  };
2944
2846
  }
2945
-
2946
2847
  var _this$tempList$id = this.tempList[id],
2947
2848
  vm = _this$tempList$id.vm,
2948
2849
  template = _this$tempList$id.template;
@@ -2966,7 +2867,6 @@
2966
2867
  },
2967
2868
  renderId: function renderId(name, type) {
2968
2869
  var _this5 = this;
2969
-
2970
2870
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2971
2871
  return ctxs ? ctxs.map(function (ctx) {
2972
2872
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2975,21 +2875,16 @@
2975
2875
  renderCtx: function renderCtx(ctx, parent) {
2976
2876
  if (ctx.type === 'hidden') return;
2977
2877
  var rule = ctx.rule;
2978
- var preview = this.options.preview || false;
2979
-
2980
2878
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2981
2879
  var vn;
2982
- var cacheFlag = true;
2880
+ var cacheFlag = rule.cache !== false;
2983
2881
  var _type = ctx.trueType;
2984
2882
  var none = !(is.Undef(rule.display) || !!rule.display);
2985
-
2986
2883
  if (_type === 'template' && !rule.template) {
2987
2884
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2988
-
2989
2885
  if (none) {
2990
2886
  this.display(vn);
2991
2887
  }
2992
-
2993
2888
  vn = this.item(ctx, vn);
2994
2889
  } else if (_type === 'fcFragment') {
2995
2890
  vn = this.renderChildren(ctx);
@@ -3001,27 +2896,24 @@
3001
2896
  this.setOptions(ctx);
3002
2897
  this.ctxProp(ctx);
3003
2898
  var prop = ctx.prop;
2899
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3004
2900
  prop.props.formCreateInject = this.injectProp(ctx);
3005
-
2901
+ var preview = prop.preview;
3006
2902
  if (prop.hidden) {
3007
2903
  this.setCache(ctx, undefined, parent);
3008
2904
  return;
3009
2905
  }
3010
-
3011
2906
  if (_type === 'template' && prop.template) {
3012
2907
  vn = this.renderTemp(ctx);
3013
2908
  cacheFlag = false;
3014
2909
  } else {
3015
2910
  var children = [];
3016
-
3017
2911
  if (ctx.parser.renderChildren) {
3018
2912
  children = ctx.parser.renderChildren(ctx);
3019
2913
  } else if (ctx.parser.loadChildren !== false) {
3020
2914
  children = this.renderChildren(ctx);
3021
2915
  }
3022
-
3023
2916
  var slot = this.getTypeSlot(ctx.type);
3024
-
3025
2917
  if (slot) {
3026
2918
  vn = slot({
3027
2919
  rule: rule,
@@ -3035,32 +2927,24 @@
3035
2927
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3036
2928
  }
3037
2929
  }
3038
-
3039
2930
  vn = this.renderSides(vn, ctx);
3040
-
3041
2931
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3042
2932
  vn = this.$manager.makeWrap(ctx, vn);
3043
2933
  }
3044
-
3045
2934
  if (none) {
3046
2935
  vn = this.display(vn);
3047
2936
  }
3048
-
3049
2937
  vn = this.item(ctx, vn);
3050
2938
  }
3051
-
3052
2939
  if (cacheFlag) {
3053
2940
  this.setCache(ctx, vn, parent);
3054
2941
  }
3055
-
3056
2942
  return vn;
3057
2943
  }
3058
-
3059
2944
  return this.getCache(ctx);
3060
2945
  },
3061
2946
  display: function display(vn) {
3062
2947
  var _this6 = this;
3063
-
3064
2948
  if (Array.isArray(vn)) {
3065
2949
  var data = [];
3066
2950
  vn.forEach(function (v) {
@@ -3078,12 +2962,13 @@
3078
2962
  vn.data.style.push({
3079
2963
  display: 'none'
3080
2964
  });
2965
+ } else if (is.String(vn.data.style)) {
2966
+ vn.data.style += ';display:none;';
3081
2967
  } else {
3082
2968
  vn.data.style = [vn.data.style, {
3083
2969
  display: 'none'
3084
2970
  }];
3085
2971
  }
3086
-
3087
2972
  return vn;
3088
2973
  }
3089
2974
  },
@@ -3095,7 +2980,6 @@
3095
2980
  },
3096
2981
  injectProp: function injectProp(ctx) {
3097
2982
  var _this7 = this;
3098
-
3099
2983
  if (!this.vm.ctxInject[ctx.id]) {
3100
2984
  $set(this.vm.ctxInject, ctx.id, {
3101
2985
  api: this.$handle.api,
@@ -3103,23 +2987,25 @@
3103
2987
  subForm: function subForm(_subForm) {
3104
2988
  _this7.$handle.addSubForm(ctx, _subForm);
3105
2989
  },
2990
+ getSubForm: function getSubForm() {
2991
+ return _this7.$handle.subForm[ctx.id];
2992
+ },
3106
2993
  options: [],
3107
2994
  children: [],
3108
2995
  prop: {},
3109
2996
  preview: false,
3110
2997
  field: ctx.field,
3111
- rule: ctx.rule
2998
+ rule: ctx.rule,
2999
+ input: ctx.input
3112
3000
  });
3113
3001
  }
3114
-
3115
3002
  var inject = this.vm.ctxInject[ctx.id];
3116
3003
  extend(inject, {
3117
- preview: this.options.preview || false,
3004
+ preview: ctx.prop.preview,
3118
3005
  options: ctx.prop.options,
3119
3006
  children: ctx.rule.children,
3120
3007
  prop: function () {
3121
3008
  var temp = _objectSpread2({}, ctx.prop);
3122
-
3123
3009
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3124
3010
  delete temp.model;
3125
3011
  return temp;
@@ -3129,7 +3015,6 @@
3129
3015
  },
3130
3016
  ctxProp: function ctxProp(ctx, custom) {
3131
3017
  var _this8 = this;
3132
-
3133
3018
  var ref = ctx.ref,
3134
3019
  key = ctx.key,
3135
3020
  rule = ctx.rule;
@@ -3148,7 +3033,6 @@
3148
3033
  }
3149
3034
  }
3150
3035
  }];
3151
-
3152
3036
  if (!custom && ctx.input) {
3153
3037
  ctx.prop.model = {
3154
3038
  value: this.$handle.getFormData(ctx),
@@ -3158,17 +3042,14 @@
3158
3042
  expression: "formData.".concat(ctx.id)
3159
3043
  };
3160
3044
  }
3161
-
3162
3045
  mergeProps(props, ctx.prop);
3163
3046
  return ctx.prop;
3164
3047
  },
3165
3048
  onMounted: function onMounted(ctx) {
3166
3049
  ctx.el = this.vm.$refs[ctx.ref];
3167
-
3168
3050
  if (ctx.el) {
3169
3051
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3170
3052
  }
3171
-
3172
3053
  ctx.parser.mounted(ctx);
3173
3054
  this.$handle.effect(ctx, 'mounted');
3174
3055
  },
@@ -3177,19 +3058,15 @@
3177
3058
  },
3178
3059
  renderChildren: function renderChildren(ctx) {
3179
3060
  var _this9 = this;
3180
-
3181
3061
  var children = ctx.rule.children,
3182
3062
  orgChildren = this.orgChildren[ctx.id];
3183
-
3184
3063
  var isRm = function isRm(child) {
3185
3064
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3186
3065
  };
3187
-
3188
3066
  if (!is.trueArray(children) && orgChildren) {
3189
3067
  this.$handle.deferSyncValue(function () {
3190
3068
  orgChildren.forEach(function (child) {
3191
3069
  if (!child) return;
3192
-
3193
3070
  if (isRm(child)) {
3194
3071
  _this9.$handle.rmCtx(child.__fc__);
3195
3072
  }
@@ -3198,11 +3075,9 @@
3198
3075
  this.orgChildren[ctx.id] = [];
3199
3076
  return [];
3200
3077
  }
3201
-
3202
3078
  orgChildren && this.$handle.deferSyncValue(function () {
3203
3079
  orgChildren.forEach(function (child) {
3204
3080
  if (!child) return;
3205
-
3206
3081
  if (children.indexOf(child) === -1 && isRm(child)) {
3207
3082
  _this9.$handle.rmCtx(child.__fc__);
3208
3083
  }
@@ -3211,15 +3086,12 @@
3211
3086
  return children.map(function (child) {
3212
3087
  if (!child) return;
3213
3088
  if (is.String(child)) return child;
3214
-
3215
3089
  if (child.__fc__) {
3216
3090
  return _this9.renderCtx(child.__fc__, ctx);
3217
3091
  }
3218
-
3219
3092
  if (child.type) {
3220
3093
  _this9.vm.$nextTick(function () {
3221
3094
  _this9.$handle.loadChildren(children, ctx);
3222
-
3223
3095
  _this9.$handle.refresh();
3224
3096
  });
3225
3097
  }
@@ -3227,38 +3099,33 @@
3227
3099
  },
3228
3100
  defaultRender: function defaultRender(ctx, children) {
3229
3101
  var prop = ctx.prop;
3102
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3230
3103
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3231
3104
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3232
3105
  return this.vNode.make(lower(ctx.originType), prop, children);
3233
3106
  },
3234
3107
  renderRule: function renderRule(rule, children, origin) {
3235
3108
  var _this10 = this;
3236
-
3237
3109
  if (!rule) return undefined;
3238
3110
  if (is.String(rule)) return rule;
3239
3111
  var type;
3240
-
3241
3112
  if (origin) {
3242
3113
  type = rule.type;
3243
3114
  } else {
3244
3115
  type = rule.is;
3245
-
3246
3116
  if (rule.type) {
3247
3117
  type = toCase(rule.type);
3248
3118
  var alias = this.vNode.aliasMap[type];
3249
3119
  if (alias) type = toCase(alias);
3250
3120
  }
3251
3121
  }
3252
-
3253
3122
  if (!type) return undefined;
3254
3123
  var data = [[children]];
3255
-
3256
3124
  if (is.trueArray(rule.children)) {
3257
3125
  data.push(rule.children.map(function (v) {
3258
3126
  return _this10.renderRule(v);
3259
3127
  }));
3260
3128
  }
3261
-
3262
3129
  return this.$h(type, _objectSpread2({}, rule), data);
3263
3130
  }
3264
3131
  });
@@ -3294,10 +3161,8 @@
3294
3161
  },
3295
3162
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3296
3163
  var _this = this;
3297
-
3298
3164
  Object.keys(data).forEach(function (k) {
3299
3165
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3300
-
3301
3166
  if (fn) {
3302
3167
  data[k] = fn;
3303
3168
  }
@@ -3311,7 +3176,6 @@
3311
3176
  return this.parseEventLst(rule, fn, inject, true);
3312
3177
  } else if (is.String(fn)) {
3313
3178
  var val = parseFn(fn);
3314
-
3315
3179
  if (val && fn !== val) {
3316
3180
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3317
3181
  }
@@ -3319,7 +3183,6 @@
3319
3183
  },
3320
3184
  parseEmit: function parseEmit(ctx, on) {
3321
3185
  var _this2 = this;
3322
-
3323
3186
  var event = {},
3324
3187
  rule = ctx.rule,
3325
3188
  emitPrefix = rule.emitPrefix,
@@ -3327,48 +3190,36 @@
3327
3190
  name = rule.name,
3328
3191
  inject = rule.inject;
3329
3192
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3330
-
3331
3193
  if (is.trueArray(emit)) {
3332
3194
  var emitKey = emitPrefix || field || name;
3333
-
3334
3195
  if (emitKey) {
3335
3196
  if (!on) emitKey = "native-".concat(emitKey);
3336
3197
  emit.forEach(function (eventName) {
3337
3198
  if (!eventName) return;
3338
3199
  var eventInject;
3339
-
3340
3200
  if (is.Object(eventName)) {
3341
3201
  eventInject = eventName.inject;
3342
3202
  eventName = eventName.name;
3343
3203
  }
3344
-
3345
3204
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3346
-
3347
3205
  var fn = function fn() {
3348
3206
  var _this2$vm, _this2$vm2;
3349
-
3350
3207
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3351
3208
  arg[_key] = arguments[_key];
3352
3209
  }
3353
-
3354
3210
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3355
-
3356
3211
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3357
3212
  };
3358
-
3359
3213
  fn.__emit = true;
3360
-
3361
3214
  if (!eventInject && inject === false) {
3362
3215
  event[eventName] = fn;
3363
3216
  } else {
3364
3217
  var _inject = eventInject || inject || _this2.options.injectEvent;
3365
-
3366
3218
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3367
3219
  }
3368
3220
  });
3369
3221
  }
3370
3222
  }
3371
-
3372
3223
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3373
3224
  return event;
3374
3225
  },
@@ -3390,21 +3241,16 @@
3390
3241
  if (this.watching && !this.loading) return _fn;
3391
3242
  _fn = _fn.__origin;
3392
3243
  }
3393
-
3394
3244
  var h = this;
3395
-
3396
3245
  var fn = function fn() {
3397
3246
  var data = h.getInjectData(self, _inject2);
3398
-
3399
3247
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3400
3248
  args[_key2] = arguments[_key2];
3401
3249
  }
3402
-
3403
3250
  data.args = [].concat(args);
3404
3251
  args.unshift(data);
3405
3252
  return _fn.apply(this, args);
3406
3253
  };
3407
-
3408
3254
  fn.__origin = _fn;
3409
3255
  fn.__json = _fn.__json;
3410
3256
  return fn;
@@ -3417,17 +3263,14 @@
3417
3263
  extend(Handler.prototype, {
3418
3264
  usePage: function usePage() {
3419
3265
  var _this = this;
3420
-
3421
3266
  var page = this.options.page;
3422
3267
  if (!page) return;
3423
3268
  var first = 25;
3424
3269
  var limit = getLimit(this.rules);
3425
-
3426
3270
  if (is.Object(page)) {
3427
3271
  if (page.first) first = parseInt(page.first, 10) || first;
3428
3272
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3429
3273
  }
3430
-
3431
3274
  extend(this, {
3432
3275
  first: first,
3433
3276
  limit: limit,
@@ -3440,27 +3283,21 @@
3440
3283
  },
3441
3284
  pageLoad: function pageLoad() {
3442
3285
  var _this2 = this;
3443
-
3444
3286
  var pageFn = function pageFn() {
3445
3287
  if (_this2.pageEnd) {
3446
3288
  _this2.vm.$off(EVENT, pageFn);
3447
-
3448
3289
  _this2.bus.$emit('page-end');
3449
3290
  } else {
3450
3291
  _this2.first += _this2.limit;
3451
3292
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3452
-
3453
3293
  _this2.loadRule();
3454
-
3455
3294
  _this2.refresh();
3456
3295
  }
3457
3296
  };
3458
-
3459
3297
  this.vm.$on(EVENT, pageFn);
3460
3298
  }
3461
3299
  });
3462
3300
  }
3463
-
3464
3301
  function getLimit(rules) {
3465
3302
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3466
3303
  }
@@ -3473,7 +3310,6 @@
3473
3310
  },
3474
3311
  bindNextTick: function bindNextTick(fn) {
3475
3312
  var _this = this;
3476
-
3477
3313
  this.clearNextTick();
3478
3314
  this.nextTick = setTimeout(function () {
3479
3315
  fn();
@@ -3481,7 +3317,6 @@
3481
3317
  }, 10);
3482
3318
  },
3483
3319
  render: function render() {
3484
- // console.warn('%c render', 'color:green');
3485
3320
  ++this.loadedId;
3486
3321
  if (this.vm.unique > 0) return this.$render.render();else {
3487
3322
  this.vm.unique = 1;
@@ -3496,7 +3331,6 @@
3496
3331
  __fc__: enumerable(ctx, true)
3497
3332
  });
3498
3333
  }
3499
-
3500
3334
  function RuleContext(handle, rule) {
3501
3335
  var id = uniqueId();
3502
3336
  extend(this, {
@@ -3530,7 +3364,6 @@
3530
3364
  if (!this.payload[name]) {
3531
3365
  this.payload[name] = {};
3532
3366
  }
3533
-
3534
3367
  return this.payload[name];
3535
3368
  },
3536
3369
  clearEffectData: function clearEffectData(name) {
@@ -3550,9 +3383,7 @@
3550
3383
  },
3551
3384
  initProp: function initProp() {
3552
3385
  var _this = this;
3553
-
3554
3386
  var rule = _objectSpread2({}, this.rule);
3555
-
3556
3387
  delete rule.children;
3557
3388
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3558
3389
  return _this.payload[k];
@@ -3607,31 +3438,22 @@
3607
3438
  },
3608
3439
  rm: function rm() {
3609
3440
  var _this2 = this;
3610
-
3611
3441
  var _rm = function _rm() {
3612
3442
  var index = _this2.root.indexOf(_this2.origin);
3613
-
3614
3443
  if (index > -1) {
3615
3444
  _this2.root.splice(index, 1);
3616
-
3617
3445
  _this2.$handle && _this2.$handle.refresh();
3618
3446
  }
3619
3447
  };
3620
-
3621
3448
  if (this.deleted) {
3622
3449
  _rm();
3623
-
3624
3450
  return;
3625
3451
  }
3626
-
3627
3452
  this.$handle.noWatch(function () {
3628
3453
  _this2.$handle.deferSyncValue(function () {
3629
3454
  _this2.rmCtrl();
3630
-
3631
3455
  _rm();
3632
-
3633
3456
  _this2.$handle.rmCtx(_this2);
3634
-
3635
3457
  extend(_this2, {
3636
3458
  root: []
3637
3459
  });
@@ -3659,7 +3481,6 @@
3659
3481
  extend(Handler.prototype, {
3660
3482
  nextRefresh: function nextRefresh(fn) {
3661
3483
  var _this = this;
3662
-
3663
3484
  var id = this.loadedId;
3664
3485
  this.vm.$nextTick(function () {
3665
3486
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3667,7 +3488,6 @@
3667
3488
  },
3668
3489
  parseRule: function parseRule(_rule) {
3669
3490
  var _this2 = this;
3670
-
3671
3491
  var rule = getRule(_rule);
3672
3492
  Object.defineProperties(rule, {
3673
3493
  __origin__: enumerable(_rule, true)
@@ -3679,20 +3499,16 @@
3679
3499
  if (!item) {
3680
3500
  return;
3681
3501
  }
3682
-
3683
3502
  _this2.loadFn(item, rule);
3684
3503
  });
3685
3504
  this.loadCtrl(rule);
3686
-
3687
3505
  if (rule.update) {
3688
3506
  rule.update = parseFn(rule.update);
3689
3507
  }
3690
-
3691
3508
  return rule;
3692
3509
  },
3693
3510
  loadFn: function loadFn(item, rule) {
3694
3511
  var _this3 = this;
3695
-
3696
3512
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3697
3513
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3698
3514
  });
@@ -3706,48 +3522,35 @@
3706
3522
  },
3707
3523
  syncProp: function syncProp(ctx) {
3708
3524
  var _this4 = this;
3709
-
3710
3525
  var rule = ctx.rule;
3711
3526
  is.trueArray(rule.sync) && mergeProps([{
3712
3527
  on: rule.sync.reduce(function (pre, prop) {
3713
3528
  pre["update:".concat(prop)] = function (val) {
3714
3529
  rule.props[prop] = val;
3715
-
3716
3530
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3717
3531
  };
3718
-
3719
3532
  return pre;
3720
3533
  }, {})
3721
3534
  }], ctx.computed);
3722
3535
  },
3723
3536
  loadRule: function loadRule() {
3724
3537
  var _this5 = this;
3725
-
3726
- // console.warn('%c load', 'color:blue');
3727
3538
  this.cycleLoad = false;
3728
3539
  this.loading = true;
3729
-
3730
3540
  if (this.pageEnd) {
3731
3541
  this.bus.$emit('load-start');
3732
3542
  }
3733
-
3734
3543
  this.deferSyncValue(function () {
3735
3544
  _this5._loadRule(_this5.rules);
3736
-
3737
3545
  _this5.loading = false;
3738
-
3739
3546
  if (_this5.cycleLoad && _this5.pageEnd) {
3740
3547
  return _this5.loadRule();
3741
3548
  }
3742
-
3743
3549
  if (_this5.pageEnd) {
3744
3550
  _this5.bus.$emit('load-end');
3745
3551
  }
3746
-
3747
3552
  _this5.vm._renderRule();
3748
-
3749
3553
  _this5.$render.initOrgChildren();
3750
-
3751
3554
  _this5.syncForm();
3752
3555
  });
3753
3556
  },
@@ -3755,79 +3558,60 @@
3755
3558
  this.cycleLoad = false;
3756
3559
  this.loading = true;
3757
3560
  this.bus.$emit('load-start');
3758
-
3759
3561
  this._loadRule(children, parent);
3760
-
3761
3562
  this.loading = false;
3762
-
3763
3563
  if (this.cycleLoad) {
3764
3564
  return this.loadRule();
3765
3565
  } else {
3766
3566
  this.bus.$emit('load-end');
3767
3567
  this.syncForm();
3768
3568
  }
3769
-
3770
3569
  this.$render.clearCache(parent);
3771
3570
  },
3772
3571
  _loadRule: function _loadRule(rules, parent) {
3773
3572
  var _this6 = this;
3774
-
3775
3573
  var preIndex = function preIndex(i) {
3776
3574
  var pre = rules[i - 1];
3777
-
3778
3575
  if (!pre || !pre.__fc__) {
3779
3576
  return i > 0 ? preIndex(i - 1) : -1;
3780
3577
  }
3781
-
3782
3578
  var index = _this6.sort.indexOf(pre.__fc__.id);
3783
-
3784
3579
  return index > -1 ? index : preIndex(i - 1);
3785
3580
  };
3786
-
3787
3581
  var loadChildren = function loadChildren(children, parent) {
3788
3582
  if (is.trueArray(children)) {
3789
3583
  _this6._loadRule(children, parent);
3790
3584
  }
3791
3585
  };
3792
-
3793
3586
  rules.map(function (_rule, index) {
3794
3587
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3795
3588
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3796
3589
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3797
-
3798
3590
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3799
3591
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3800
3592
  return _rule.__fc__;
3801
3593
  }
3802
-
3803
3594
  var rule = getRule(_rule);
3804
-
3805
3595
  var isRepeat = function isRepeat() {
3806
3596
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3807
3597
  };
3808
-
3809
3598
  _this6.ruleEffect(rule, 'init', {
3810
3599
  repeat: isRepeat()
3811
3600
  });
3812
-
3813
3601
  if (isRepeat()) {
3814
3602
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3815
3603
  }
3816
-
3817
3604
  var ctx;
3818
3605
  var isCopy = false;
3819
3606
  var isInit = !!_rule.__fc__;
3820
-
3821
3607
  if (isInit) {
3822
3608
  ctx = _rule.__fc__;
3823
3609
  var check = !ctx.check(_this6);
3824
-
3825
3610
  if (ctx.deleted) {
3826
3611
  if (check) {
3827
3612
  if (isCtrl(ctx)) {
3828
3613
  return;
3829
3614
  }
3830
-
3831
3615
  ctx.update(_this6);
3832
3616
  }
3833
3617
  } else {
@@ -3835,66 +3619,49 @@
3835
3619
  if (isCtrl(ctx)) {
3836
3620
  return;
3837
3621
  }
3838
-
3839
3622
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3840
3623
  ctx = null;
3841
3624
  isCopy = true;
3842
3625
  }
3843
3626
  }
3844
3627
  }
3845
-
3846
3628
  if (!ctx) {
3847
3629
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3848
-
3849
3630
  _this6.bindParser(ctx);
3850
3631
  } else {
3851
3632
  if (ctx.originType !== ctx.rule.type) {
3852
3633
  ctx.updateType();
3853
-
3854
3634
  _this6.bindParser(ctx);
3855
3635
  }
3856
-
3857
3636
  _this6.appendValue(ctx.rule);
3858
3637
  }
3859
-
3860
3638
  [false, true].forEach(function (b) {
3861
3639
  return _this6.parseEmit(ctx, b);
3862
3640
  });
3863
-
3864
3641
  _this6.syncProp(ctx);
3865
-
3866
3642
  ctx.parent = parent || null;
3867
3643
  ctx.root = rules;
3868
-
3869
3644
  _this6.setCtx(ctx);
3870
-
3871
3645
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3872
3646
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3873
-
3874
3647
  if (!parent) {
3875
3648
  var _preIndex = preIndex(index);
3876
-
3877
3649
  if (_preIndex > -1 || !index) {
3878
3650
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3879
3651
  } else {
3880
3652
  _this6.sort.push(ctx.id);
3881
3653
  }
3882
3654
  }
3883
-
3884
3655
  var r = ctx.rule;
3885
-
3886
3656
  if (!ctx.updated) {
3887
3657
  ctx.updated = true;
3888
-
3889
3658
  if (is.Function(r.update)) {
3890
3659
  _this6.bus.$once('load-end', function () {
3891
3660
  _this6.refreshUpdate(ctx, r.value);
3892
3661
  });
3893
3662
  }
3894
-
3895
3663
  _this6.effect(ctx, 'loaded');
3896
3664
  }
3897
-
3898
3665
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3899
3666
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3900
3667
  return ctx;
@@ -3905,20 +3672,16 @@
3905
3672
  },
3906
3673
  useCtrl: function useCtrl(ctx) {
3907
3674
  var _this7 = this;
3908
-
3909
3675
  var controls = getCtrl(ctx),
3910
3676
  validate = [],
3911
3677
  api = this.api;
3912
3678
  if (!controls.length) return false;
3913
-
3914
3679
  var _loop = function _loop(i) {
3915
3680
  var control = controls[i],
3916
3681
  handleFn = control.handle || function (val) {
3917
3682
  return val === control.value;
3918
3683
  };
3919
-
3920
3684
  if (!is.trueArray(control.rule)) return "continue";
3921
-
3922
3685
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3923
3686
  valid: invoke(function () {
3924
3687
  return handleFn(ctx.rule.value, api);
@@ -3926,17 +3689,13 @@
3926
3689
  ctrl: findCtrl(ctx, control.rule),
3927
3690
  isHidden: is.String(control.rule[0])
3928
3691
  });
3929
-
3930
3692
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3931
3693
  validate.push(data);
3932
3694
  };
3933
-
3934
3695
  for (var i = 0; i < controls.length; i++) {
3935
3696
  var _ret = _loop(i);
3936
-
3937
3697
  if (_ret === "continue") continue;
3938
3698
  }
3939
-
3940
3699
  if (!validate.length) return false;
3941
3700
  var flag = false;
3942
3701
  this.deferSyncValue(function () {
@@ -3948,21 +3707,17 @@
3948
3707
  append = _ref.append,
3949
3708
  child = _ref.child,
3950
3709
  ctrl = _ref.ctrl;
3951
-
3952
3710
  if (isHidden) {
3953
3711
  valid ? ctx.ctrlRule.push({
3954
3712
  __ctrl: true,
3955
3713
  children: rule,
3956
3714
  valid: valid
3957
3715
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3958
-
3959
3716
  _this7.vm.$nextTick(function () {
3960
3717
  _this7.api.hidden(!valid, rule);
3961
3718
  });
3962
-
3963
3719
  return;
3964
3720
  }
3965
-
3966
3721
  if (valid) {
3967
3722
  flag = true;
3968
3723
  var ruleCon = {
@@ -3972,9 +3727,7 @@
3972
3727
  children: rule
3973
3728
  };
3974
3729
  ctx.ctrlRule.push(ruleCon);
3975
-
3976
3730
  _this7.bus.$once('load-start', function () {
3977
- // this.cycleLoad = true;
3978
3731
  if (prepend) {
3979
3732
  api.prepend(ruleCon, prepend, child);
3980
3733
  } else if (append || child) {
@@ -3999,60 +3752,53 @@
3999
3752
  },
4000
3753
  _reloadRule: function _reloadRule(rules) {
4001
3754
  var _this8 = this;
4002
-
4003
- // console.warn('%c reload', 'color:red');
4004
3755
  if (!rules) rules = this.rules;
4005
-
4006
3756
  var ctxs = _objectSpread2({}, this.ctxs);
4007
-
4008
3757
  this.clearNextTick();
4009
3758
  this.$render.clearOrgChildren();
4010
3759
  this.initData(rules);
4011
3760
  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]);
3761
+ this.deferSyncValue(function () {
3762
+ _this8.bus.$once('load-end', function () {
3763
+ Object.keys(ctxs).filter(function (id) {
3764
+ return _this8.ctxs[id] === undefined;
3765
+ }).forEach(function (id) {
3766
+ return _this8.rmCtx(ctxs[id]);
3767
+ });
3768
+ _this8.$render.clearCacheAll();
4017
3769
  });
4018
-
4019
- _this8.$render.clearCacheAll();
3770
+ _this8.reloading = true;
3771
+ _this8.loadRule();
3772
+ _this8.reloading = false;
3773
+ _this8.refresh();
3774
+ _this8.vm.$emit('reloading', _this8.api);
4020
3775
  });
4021
- this.reloading = true;
4022
- this.loadRule();
4023
- this.reloading = false;
4024
- this.refresh();
4025
3776
  this.bus.$off('next-tick', this.nextReload);
4026
3777
  this.bus.$once('next-tick', this.nextReload);
4027
3778
  this.vm.$emit('update', this.api);
4028
3779
  },
4029
- //todo 组件生成全部通过 alias
4030
3780
  refresh: function refresh() {
4031
3781
  this.vm._refresh();
4032
3782
  }
4033
3783
  });
4034
3784
  }
4035
-
4036
3785
  function fullRule(rule) {
4037
3786
  var def = baseRule();
4038
3787
  Object.keys(def).forEach(function (k) {
4039
- if (!hasProperty(rule, k)) rule[k] = def[k];
3788
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4040
3789
  });
4041
3790
  return rule;
4042
3791
  }
4043
-
4044
3792
  function getCtrl(ctx) {
4045
3793
  var control = ctx.rule.control || [];
4046
3794
  if (is.Object(control)) return [control];else return control;
4047
3795
  }
4048
-
4049
3796
  function findCtrl(ctx, rule) {
4050
3797
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4051
3798
  var ctrl = ctx.ctrlRule[i];
4052
3799
  if (ctrl.children === rule) return ctrl;
4053
3800
  }
4054
3801
  }
4055
-
4056
3802
  function isCtrl(ctx) {
4057
3803
  return !!ctx.rule.__ctrl;
4058
3804
  }
@@ -4063,7 +3809,6 @@
4063
3809
  if (is.Undef(ctx.cacheValue)) {
4064
3810
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4065
3811
  }
4066
-
4067
3812
  return ctx.cacheValue;
4068
3813
  },
4069
3814
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4080,7 +3825,6 @@
4080
3825
  },
4081
3826
  onInput: function onInput(ctx, value) {
4082
3827
  var val;
4083
-
4084
3828
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4085
3829
  this.setValue(ctx, val, value);
4086
3830
  }
@@ -4093,7 +3837,6 @@
4093
3837
  },
4094
3838
  validate: function validate() {
4095
3839
  var _this = this;
4096
-
4097
3840
  toEmpty(this.vm.validate);
4098
3841
  this.fields().forEach(function (id) {
4099
3842
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4104,17 +3847,14 @@
4104
3847
  },
4105
3848
  syncForm: function syncForm() {
4106
3849
  var _this2 = this;
4107
-
4108
3850
  toEmpty(this.form);
4109
3851
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4110
3852
  var ctx = _this2.getFieldCtx(field);
4111
-
4112
3853
  var handle = _this2.valueHandle(ctx);
4113
-
4114
3854
  handle.configurable = true;
4115
3855
  initial[field] = handle;
4116
3856
  return initial;
4117
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3857
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4118
3858
  initial[field] = {
4119
3859
  enumerable: true,
4120
3860
  configurable: true,
@@ -4126,12 +3866,11 @@
4126
3866
  }
4127
3867
  };
4128
3868
  return initial;
4129
- }, {})));
3869
+ }, {}) : {}));
4130
3870
  this.syncValue();
4131
3871
  },
4132
3872
  valueHandle: function valueHandle(ctx) {
4133
3873
  var _this3 = this;
4134
-
4135
3874
  return {
4136
3875
  enumerable: true,
4137
3876
  get: function get() {
@@ -4150,24 +3889,18 @@
4150
3889
  delete this.appendData[rule.field];
4151
3890
  },
4152
3891
  addSubForm: function addSubForm(ctx, subForm) {
4153
- if (ctx.input) {
4154
- this.subForm[ctx.id] = subForm;
4155
- }
3892
+ this.subForm[ctx.id] = subForm;
4156
3893
  },
4157
3894
  deferSyncValue: function deferSyncValue(fn, sync) {
4158
3895
  if (!this.deferSyncFn) {
4159
3896
  this.deferSyncFn = fn;
4160
3897
  }
4161
-
4162
3898
  if (!this.deferSyncFn.sync) {
4163
3899
  this.deferSyncFn.sync = sync;
4164
3900
  }
4165
-
4166
3901
  invoke(fn);
4167
-
4168
3902
  if (this.deferSyncFn === fn) {
4169
3903
  this.deferSyncFn = null;
4170
-
4171
3904
  if (fn.sync) {
4172
3905
  this.syncValue();
4173
3906
  }
@@ -4177,18 +3910,16 @@
4177
3910
  if (this.deferSyncFn) {
4178
3911
  return this.deferSyncFn.sync = true;
4179
3912
  }
4180
-
4181
3913
  this.vm._updateValue(_objectSpread2({}, this.form));
4182
3914
  },
4183
3915
  isChange: function isChange(ctx, value) {
4184
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3916
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4185
3917
  },
4186
3918
  isQuote: function isQuote(ctx, value) {
4187
3919
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4188
3920
  },
4189
3921
  refreshUpdate: function refreshUpdate(ctx, val) {
4190
3922
  var _this4 = this;
4191
-
4192
3923
  if (is.Function(ctx.rule.update)) {
4193
3924
  var state = invoke(function () {
4194
3925
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4208,20 +3939,16 @@
4208
3939
  this.vm.$emit('update', this.api);
4209
3940
  this.refresh();
4210
3941
  }
4211
-
4212
3942
  this.refreshUpdate(ctx, val);
4213
3943
  },
4214
3944
  appendLink: function appendLink(ctx) {
4215
3945
  var _this5 = this;
4216
-
4217
3946
  var link = ctx.rule.link;
4218
3947
  is.trueArray(link) && link.forEach(function (field) {
4219
3948
  var fn = function fn() {
4220
3949
  return _this5.refreshRule(ctx, ctx.rule.value);
4221
3950
  };
4222
-
4223
3951
  _this5.bus.$on('change-' + field, fn);
4224
-
4225
3952
  ctx.linkOn.push(function () {
4226
3953
  return _this5.bus.$off('change-' + field, fn);
4227
3954
  });
@@ -4232,11 +3959,9 @@
4232
3959
  }
4233
3960
  });
4234
3961
  }
4235
-
4236
3962
  function strFn(key, val) {
4237
3963
  return typeof val === 'function' ? '' + val : val;
4238
3964
  }
4239
-
4240
3965
  function toEmpty(obj) {
4241
3966
  Object.keys(obj).forEach(function (k) {
4242
3967
  return delete obj[k];
@@ -4256,11 +3981,12 @@
4256
3981
  return ctx.$render.defaultRender(ctx, children);
4257
3982
  },
4258
3983
  preview: function preview(children, ctx) {
4259
- return ctx.$render.defaultRender(ctx, children);
3984
+ return this.render(children, ctx);
4260
3985
  },
4261
3986
  mergeProp: function mergeProp(ctx) {}
4262
3987
  };
4263
3988
 
3989
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4264
3990
  function useContext(Handler) {
4265
3991
  extend(Handler.prototype, {
4266
3992
  getCtx: function getCtx(id) {
@@ -4271,7 +3997,6 @@
4271
3997
  },
4272
3998
  setIdCtx: function setIdCtx(ctx, key, type) {
4273
3999
  var field = "".concat(type, "Ctx");
4274
-
4275
4000
  if (!this[field][key]) {
4276
4001
  this[field][key] = [ctx];
4277
4002
  } else {
@@ -4283,11 +4008,9 @@
4283
4008
  var lst = this[field][key];
4284
4009
  if (!lst) return false;
4285
4010
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4286
-
4287
4011
  if (!lst.length) {
4288
4012
  delete this[field][key];
4289
4013
  }
4290
-
4291
4014
  return flag;
4292
4015
  },
4293
4016
  getFieldCtx: function getFieldCtx(field) {
@@ -4306,7 +4029,6 @@
4306
4029
  if (!ctx.input) return;
4307
4030
  this.setIdCtx(ctx, field, 'field');
4308
4031
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4309
-
4310
4032
  if (this.isMounted && !this.reloading) {
4311
4033
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4312
4034
  }
@@ -4327,70 +4049,51 @@
4327
4049
  if (!this.noWatchFn) {
4328
4050
  this.noWatchFn = fn;
4329
4051
  }
4330
-
4331
4052
  invoke(fn);
4332
-
4333
4053
  if (this.noWatchFn === fn) {
4334
4054
  this.noWatchFn = null;
4335
4055
  }
4336
4056
  },
4337
4057
  watchCtx: function watchCtx(ctx) {
4338
4058
  var _this = this;
4339
-
4340
4059
  var vm = this.vm;
4341
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4342
4060
  Object.keys(ctx.rule).filter(function (k) {
4343
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4061
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4344
4062
  }).forEach(function (key) {
4345
4063
  var flag = key === 'children';
4346
4064
  ctx.watch.push(vm.$watch(function () {
4347
4065
  return ctx.rule[key];
4348
4066
  }, function (n, o) {
4349
4067
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4350
-
4351
4068
  if (flag && ctx.parser.loadChildren === false) {
4352
4069
  _this.$render.clearCache(ctx);
4353
-
4354
4070
  _this.nextRefresh();
4355
-
4356
4071
  return;
4357
4072
  }
4358
-
4359
- _this.watching = true; // if (key === 'hidden')
4360
- // ctx.updateKey(true);
4361
- // else
4362
-
4073
+ _this.watching = true;
4363
4074
  if (key === 'link') {
4364
4075
  ctx.link();
4365
4076
  return;
4366
4077
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4367
4078
  _this.parseInjectEvent(ctx.rule, n || {});
4368
-
4369
4079
  if (key === 'props' && ctx.input) {
4370
4080
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4371
4081
  }
4372
4082
  } 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
4083
  ctx.updateType();
4374
-
4375
4084
  _this.bindParser(ctx);
4376
4085
  } else if (key === 'children') {
4377
4086
  var _flag = is.trueArray(n);
4378
-
4379
4087
  _this.deferSyncValue(function () {
4380
4088
  if (n !== o) {
4381
4089
  _this.rmSub(o);
4382
-
4383
4090
  _this.$render.initOrgChildren();
4384
4091
  }
4385
-
4386
4092
  _flag && _this.loadChildren(n, ctx);
4387
-
4388
4093
  _this.vm.$emit('update', _this.api);
4389
4094
  });
4390
4095
  }
4391
-
4392
4096
  _this.$render.clearCache(ctx);
4393
-
4394
4097
  _this.watching = false;
4395
4098
  }, {
4396
4099
  deep: !flag,
@@ -4401,27 +4104,23 @@
4401
4104
  },
4402
4105
  rmSub: function rmSub(sub) {
4403
4106
  var _this2 = this;
4404
-
4405
4107
  is.trueArray(sub) && sub.forEach(function (r) {
4406
4108
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4407
4109
  });
4408
4110
  },
4409
4111
  rmCtx: function rmCtx(ctx) {
4410
4112
  var _this3 = this;
4411
-
4412
4113
  if (ctx.deleted) return;
4413
4114
  var id = ctx.id,
4414
4115
  field = ctx.field,
4415
4116
  input = ctx.input,
4416
4117
  name = ctx.name;
4417
-
4418
4118
  if (ctx.input) {
4419
4119
  Object.defineProperty(ctx.rule, 'value', {
4420
4120
  value: ctx.rule.value,
4421
4121
  writable: true
4422
4122
  });
4423
4123
  }
4424
-
4425
4124
  $del(this.ctxs, id);
4426
4125
  $del(this.$render.tempList, id);
4427
4126
  $del(this.$render.orgChildren, id);
@@ -4429,6 +4128,7 @@
4429
4128
  $del(this.formData, id);
4430
4129
  $del(this.subForm, id);
4431
4130
  $del(ctx, 'cacheValue');
4131
+ input && $del(this.form, field);
4432
4132
  input && this.rmIdCtx(ctx, field, 'field');
4433
4133
  name && this.rmIdCtx(ctx, name, 'name');
4434
4134
  this.deferSyncValue(function () {
@@ -4440,18 +4140,15 @@
4440
4140
  });
4441
4141
  }
4442
4142
  }
4443
-
4444
4143
  if (ctx.root === _this3.rules) {
4445
4144
  _this3.vm._renderRule();
4446
4145
  }
4447
4146
  }
4448
4147
  }, input);
4449
4148
  var index = this.sort.indexOf(id);
4450
-
4451
4149
  if (index > -1) {
4452
4150
  this.sort.splice(index, 1);
4453
4151
  }
4454
-
4455
4152
  this.$render.clearCache(ctx);
4456
4153
  ctx["delete"]();
4457
4154
  this.effect(ctx, 'deleted');
@@ -4466,13 +4163,10 @@
4466
4163
  extend(Handler.prototype, {
4467
4164
  mounted: function mounted() {
4468
4165
  var _this = this;
4469
-
4470
4166
  var _mounted = function _mounted() {
4471
4167
  _this.isMounted = true;
4472
-
4473
4168
  _this.lifecycle('mounted');
4474
4169
  };
4475
-
4476
4170
  if (this.pageEnd) {
4477
4171
  _mounted();
4478
4172
  } else {
@@ -4481,7 +4175,6 @@
4481
4175
  },
4482
4176
  lifecycle: function lifecycle(name) {
4483
4177
  var _this2 = this;
4484
-
4485
4178
  var fn = this.options[name];
4486
4179
  is.Function(fn) && invoke(function () {
4487
4180
  return fn(_this2.api);
@@ -4495,26 +4188,21 @@
4495
4188
  extend(Handler.prototype, {
4496
4189
  useProvider: function useProvider() {
4497
4190
  var _this = this;
4498
-
4499
4191
  var ps = this.fc.providers;
4500
4192
  Object.keys(ps).forEach(function (k) {
4501
4193
  var prop = ps[k];
4502
4194
  prop._c = getComponent(prop);
4503
-
4504
4195
  _this.onEffect(prop);
4505
-
4506
4196
  _this.providers[k] = prop;
4507
4197
  });
4508
4198
  },
4509
4199
  onEffect: function onEffect(provider) {
4510
4200
  var _this2 = this;
4511
-
4512
4201
  var used = [];
4513
4202
  (provider._c || ['*']).forEach(function (name) {
4514
4203
  var type = name === '*' ? '*' : _this2.getType(name);
4515
4204
  if (used.indexOf(type) > -1) return;
4516
4205
  used.push(type);
4517
-
4518
4206
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4519
4207
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4520
4208
  });
@@ -4523,7 +4211,6 @@
4523
4211
  },
4524
4212
  watchEffect: function watchEffect(ctx) {
4525
4213
  var _this3 = this;
4526
-
4527
4214
  var vm = this.vm;
4528
4215
  var effect = {};
4529
4216
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
@@ -4566,13 +4253,11 @@
4566
4253
  if (hasProperty(rule, '$' + name)) {
4567
4254
  return rule['$' + name];
4568
4255
  }
4569
-
4570
4256
  if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4571
4257
  return undefined;
4572
4258
  },
4573
4259
  emitEffect: function emitEffect(_ref, event, append) {
4574
4260
  var _this4 = this;
4575
-
4576
4261
  var ctx = _ref.ctx,
4577
4262
  rule = _ref.rule,
4578
4263
  input = _ref.input,
@@ -4583,15 +4268,12 @@
4583
4268
  if (k[0] === '$') {
4584
4269
  i[k.substr(1)] = rule[k];
4585
4270
  }
4586
-
4587
4271
  return i;
4588
4272
  }, _objectSpread2({}, rule.effect || {}));
4589
4273
  Object.keys(effect).forEach(function (attr) {
4590
4274
  var p = _this4.providers[attr];
4591
4275
  if (!p || p.input && !input) return;
4592
-
4593
4276
  var _type;
4594
-
4595
4277
  if (!p._c) {
4596
4278
  _type = '*';
4597
4279
  } else if (p._used.indexOf(type) > -1) {
@@ -4599,40 +4281,33 @@
4599
4281
  } else {
4600
4282
  return;
4601
4283
  }
4602
-
4603
4284
  var data = _objectSpread2({
4604
4285
  value: effect[attr],
4605
4286
  getValue: function getValue() {
4606
4287
  return _this4.getEffect(rule, attr);
4607
4288
  }
4608
4289
  }, append || {});
4609
-
4610
4290
  if (ctx) {
4611
4291
  data.getProp = function () {
4612
4292
  return ctx.effectData(attr);
4613
4293
  };
4614
-
4615
4294
  data.clearProp = function () {
4616
4295
  return ctx.clearEffectData(attr);
4617
4296
  };
4618
-
4619
4297
  data.mergeProp = function (prop) {
4620
4298
  return mergeProps([prop], data.getProp());
4621
4299
  };
4622
4300
  }
4623
-
4624
4301
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4625
4302
  });
4626
4303
  }
4627
4304
  });
4628
4305
  }
4629
-
4630
4306
  function unique(arr) {
4631
4307
  return arr.filter(function (item, index, arr) {
4632
4308
  return arr.indexOf(item, 0) === index;
4633
4309
  });
4634
4310
  }
4635
-
4636
4311
  function getComponent(p) {
4637
4312
  var c = p.components;
4638
4313
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4642,7 +4317,6 @@
4642
4317
 
4643
4318
  function Handler(fc) {
4644
4319
  var _this = this;
4645
-
4646
4320
  extend(this, {
4647
4321
  fc: fc,
4648
4322
  vm: fc.vm,
@@ -4694,9 +4368,7 @@
4694
4368
  this.useProvider();
4695
4369
  this.usePage();
4696
4370
  this.loadRule();
4697
-
4698
4371
  this.$manager.__init();
4699
-
4700
4372
  this.vm.$set(this.vm, 'formData', this.formData);
4701
4373
  }
4702
4374
  });
@@ -4709,7 +4381,6 @@
4709
4381
  useLifecycle(Handler);
4710
4382
  useEffect(Handler);
4711
4383
 
4712
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4713
4384
  function getError(action, option, xhr) {
4714
4385
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4715
4386
  var err = new Error(msg);
@@ -4717,44 +4388,34 @@
4717
4388
  err.url = action;
4718
4389
  return err;
4719
4390
  }
4720
-
4721
4391
  function getBody(xhr) {
4722
4392
  var text = xhr.responseText || xhr.response;
4723
-
4724
4393
  if (!text) {
4725
4394
  return text;
4726
4395
  }
4727
-
4728
4396
  try {
4729
4397
  return JSON.parse(text);
4730
4398
  } catch (e) {
4731
4399
  return text;
4732
4400
  }
4733
4401
  }
4734
-
4735
4402
  function fetch(option) {
4736
4403
  if (typeof XMLHttpRequest === 'undefined') {
4737
4404
  return;
4738
4405
  }
4739
-
4740
4406
  var xhr = new XMLHttpRequest();
4741
4407
  var action = option.action;
4742
-
4743
4408
  xhr.onerror = function error(e) {
4744
4409
  option.onError(e);
4745
4410
  };
4746
-
4747
4411
  xhr.onload = function onload() {
4748
4412
  if (xhr.status < 200 || xhr.status >= 300) {
4749
4413
  return option.onError(getError(action, option, xhr), getBody(xhr));
4750
4414
  }
4751
-
4752
4415
  option.onSuccess(getBody(xhr));
4753
4416
  };
4754
-
4755
4417
  xhr.open(option.method || 'get', action, true);
4756
4418
  var formData;
4757
-
4758
4419
  if (option.data) {
4759
4420
  if ((option.dataType || '').toLowerCase() !== 'json') {
4760
4421
  formData = new FormData();
@@ -4766,11 +4427,9 @@
4766
4427
  xhr.setRequestHeader('content-type', 'application/json');
4767
4428
  }
4768
4429
  }
4769
-
4770
4430
  if (option.withCredentials && 'withCredentials' in xhr) {
4771
4431
  xhr.withCredentials = true;
4772
4432
  }
4773
-
4774
4433
  var headers = option.headers || {};
4775
4434
  Object.keys(headers).forEach(function (item) {
4776
4435
  if (headers[item] !== null) {
@@ -4798,14 +4457,11 @@
4798
4457
  };
4799
4458
  return prop;
4800
4459
  }
4801
-
4802
4460
  function CreateNodeFactory() {
4803
4461
  var aliasMap = {};
4804
-
4805
4462
  function CreateNode(vm) {
4806
4463
  vm && this.setVm(vm);
4807
4464
  }
4808
-
4809
4465
  extend(CreateNode.prototype, {
4810
4466
  setVm: function setVm(vm) {
4811
4467
  this.vm = vm;
@@ -4813,7 +4469,10 @@
4813
4469
  },
4814
4470
  make: function make(tag, data, children) {
4815
4471
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4816
- var Node = this.$h(tag, parseProp(data), children || []);
4472
+ return this.makeComponent(tag, data, children);
4473
+ },
4474
+ makeComponent: function makeComponent(type, data, children) {
4475
+ var Node = this.$h(type, parseProp(data), children || []);
4817
4476
  Node.context = this.vm;
4818
4477
  return Node;
4819
4478
  },
@@ -4831,7 +4490,6 @@
4831
4490
  var v = nodes[k];
4832
4491
  [k, line, lower].forEach(function (n) {
4833
4492
  CreateNode.alias(k, v);
4834
-
4835
4493
  CreateNode.prototype[n] = function (data, children) {
4836
4494
  return this.make(v, data, children);
4837
4495
  };
@@ -4843,20 +4501,15 @@
4843
4501
  }
4844
4502
 
4845
4503
  function createManager(proto) {
4846
- var CustomManager = /*#__PURE__*/function (_Manager) {
4504
+ var CustomManager = function (_Manager) {
4847
4505
  _inherits(CustomManager, _Manager);
4848
-
4849
4506
  var _super = _createSuper(CustomManager);
4850
-
4851
4507
  function CustomManager() {
4852
4508
  _classCallCheck(this, CustomManager);
4853
-
4854
4509
  return _super.apply(this, arguments);
4855
4510
  }
4856
-
4857
4511
  return CustomManager;
4858
4512
  }(Manager);
4859
-
4860
4513
  Object.assign(CustomManager.prototype, proto);
4861
4514
  return CustomManager;
4862
4515
  }
@@ -4876,19 +4529,15 @@
4876
4529
  extend(Manager.prototype, {
4877
4530
  __init: function __init() {
4878
4531
  var _this = this;
4879
-
4880
4532
  this.$render = this.$handle.$render;
4881
-
4882
4533
  this.$r = function () {
4883
4534
  var _this$$render;
4884
-
4885
4535
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4886
4536
  };
4887
4537
  },
4888
4538
  updateKey: function updateKey() {
4889
4539
  this.key = uniqueId();
4890
4540
  },
4891
- //TODO interface
4892
4541
  init: function init() {},
4893
4542
  update: function update() {},
4894
4543
  beforeRender: function beforeRender() {},
@@ -4897,7 +4546,6 @@
4897
4546
  },
4898
4547
  mergeOptions: function mergeOptions(args, opt) {
4899
4548
  var _this2 = this;
4900
-
4901
4549
  return mergeProps(args.map(function (v) {
4902
4550
  return _this2.tidyOptions(v);
4903
4551
  }), opt, this.mergeOptionsRule);
@@ -4932,33 +4580,28 @@
4932
4580
  var $required = {
4933
4581
  name: 'required',
4934
4582
  load: function load(inject, rule, api) {
4935
- var val = parseVa(inject.getValue());
4936
-
4583
+ var val = parseVal(inject.getValue());
4937
4584
  if (val.required === false) {
4938
4585
  inject.clearProp();
4939
4586
  } else {
4940
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
4587
+ var validate = _objectSpread2({
4941
4588
  required: true,
4942
4589
  validator: function validator(_, v, call) {
4943
4590
  is.empty(v) ? call(validate.message) : call();
4944
4591
  }
4945
- });
4946
-
4592
+ }, val);
4947
4593
  if (!validate.message) {
4948
4594
  validate.message = rule.title + ' is required';
4949
4595
  }
4950
-
4951
4596
  inject.getProp().validate = [validate];
4952
4597
  }
4953
-
4954
4598
  api.sync(rule);
4955
4599
  },
4956
4600
  watch: function watch() {
4957
4601
  $required.load.apply($required, arguments);
4958
4602
  }
4959
4603
  };
4960
-
4961
- function parseVa(val) {
4604
+ function parseVal(val) {
4962
4605
  if (is.Boolean(val)) {
4963
4606
  return {
4964
4607
  required: val
@@ -4967,13 +4610,16 @@
4967
4610
  return {
4968
4611
  message: val
4969
4612
  };
4613
+ } else if (is.Function(val)) {
4614
+ return {
4615
+ validator: val
4616
+ };
4970
4617
  } else if (!is.Object(val)) {
4971
4618
  return {};
4972
4619
  } else {
4973
4620
  return val;
4974
4621
  }
4975
4622
  }
4976
-
4977
4623
  function parseOpt(option) {
4978
4624
  if (is.String(option)) {
4979
4625
  option = {
@@ -4981,29 +4627,21 @@
4981
4627
  to: 'options'
4982
4628
  };
4983
4629
  }
4984
-
4985
4630
  return option;
4986
4631
  }
4987
-
4988
4632
  function run(inject, rule, api) {
4989
4633
  var option = inject.value;
4990
-
4991
4634
  if (is.Function(option)) {
4992
4635
  option = option(rule, api);
4993
4636
  }
4994
-
4995
4637
  option = parseOpt(option);
4996
-
4997
4638
  if (!option || !option.action) {
4998
4639
  return false;
4999
4640
  }
5000
-
5001
4641
  if (!option.to) {
5002
4642
  option.to = 'options';
5003
4643
  }
5004
-
5005
4644
  var _onError = option.onError;
5006
-
5007
4645
  var check = function check() {
5008
4646
  if (!inject.getValue()) {
5009
4647
  inject.clearProp();
@@ -5011,7 +4649,6 @@
5011
4649
  return true;
5012
4650
  }
5013
4651
  };
5014
-
5015
4652
  var set = function set(val) {
5016
4653
  if (val === undefined) {
5017
4654
  inject.clearProp();
@@ -5020,7 +4657,6 @@
5020
4657
  deepSet(inject.getProp(), option.to, val);
5021
4658
  }
5022
4659
  };
5023
-
5024
4660
  invoke(function () {
5025
4661
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5026
4662
  onSuccess: function onSuccess(body) {
@@ -5033,7 +4669,6 @@
5033
4669
  onError: function onError(e) {
5034
4670
  set(undefined);
5035
4671
  if (check()) return;
5036
-
5037
4672
  (_onError || function (e) {
5038
4673
  return err(e.message || 'fetch fail ' + option.action);
5039
4674
  })(e, rule, api);
@@ -5042,7 +4677,6 @@
5042
4677
  });
5043
4678
  return true;
5044
4679
  }
5045
-
5046
4680
  var $provider = {
5047
4681
  fetch: $fetch,
5048
4682
  required: $required
@@ -5063,42 +4697,34 @@
5063
4697
  return is.String(v);
5064
4698
  }).join('');
5065
4699
  }
5066
-
5067
4700
  return '';
5068
4701
  }
5069
4702
  };
5070
4703
 
5071
4704
  var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
5072
-
5073
4705
  function _parseProp(name, id) {
5074
4706
  var prop;
5075
-
5076
4707
  if (arguments.length === 2) {
5077
4708
  prop = arguments[1];
5078
4709
  id = prop[name];
5079
4710
  } else {
5080
4711
  prop = arguments[2];
5081
4712
  }
5082
-
5083
4713
  return {
5084
4714
  id: id,
5085
4715
  prop: prop
5086
4716
  };
5087
4717
  }
5088
-
5089
4718
  function nameProp() {
5090
4719
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
5091
4720
  }
5092
-
5093
4721
  function _getEl(options) {
5094
4722
  if (!options || !options.el) return window.document.body;
5095
4723
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
5096
4724
  }
5097
-
5098
4725
  function mountForm(rules, option) {
5099
4726
  var $vm = new _vue({
5100
4727
  data: function data() {
5101
- //todo 外部无法修改
5102
4728
  return {
5103
4729
  rule: rules,
5104
4730
  option: option || {}
@@ -5114,7 +4740,6 @@
5114
4740
  $vm.$mount();
5115
4741
  return $vm;
5116
4742
  }
5117
-
5118
4743
  function exportAttrs(attrs) {
5119
4744
  var key = attrs.key || [];
5120
4745
  var array = attrs.array || [];
@@ -5124,18 +4749,13 @@
5124
4749
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
5125
4750
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
5126
4751
  }
5127
-
5128
4752
  var id$1 = 1;
5129
- var instance = {}; //todo 表单嵌套
5130
-
4753
+ var instance = {};
5131
4754
  function FormCreateFactory(config) {
5132
4755
  var components = _defineProperty({}, fragment.name, fragment);
5133
-
5134
4756
  var parsers = {};
5135
4757
  var directives = {};
5136
-
5137
4758
  var providers = _objectSpread2({}, $provider);
5138
-
5139
4759
  var maker = makerFactory();
5140
4760
  var globalConfig = {
5141
4761
  global: {}
@@ -5143,27 +4763,24 @@
5143
4763
  var data = {};
5144
4764
  var CreateNode = CreateNodeFactory();
5145
4765
  exportAttrs(config.attrs || {});
5146
-
5147
4766
  function getApi(name) {
5148
- return instance[name];
4767
+ var val = instance[name];
4768
+ if (Array.isArray(val)) return _toConsumableArray(val);
4769
+ return val;
5149
4770
  }
5150
-
5151
4771
  function directive() {
5152
4772
  var data = nameProp.apply(void 0, arguments);
5153
4773
  if (data.id && data.prop) directives[data.id] = data.prop;
5154
4774
  }
5155
-
5156
4775
  function register() {
5157
4776
  var data = nameProp.apply(void 0, arguments);
5158
4777
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5159
4778
  name: data.id
5160
4779
  });
5161
4780
  }
5162
-
5163
4781
  function componentAlias(alias) {
5164
4782
  CreateNode.use(alias);
5165
4783
  }
5166
-
5167
4784
  function parser() {
5168
4785
  var data = nameProp.apply(void 0, arguments);
5169
4786
  if (!data.id || !data.prop) return;
@@ -5174,13 +4791,10 @@
5174
4791
  maker[name] = creatorFactory(name);
5175
4792
  parser.maker && extend(maker, parser.maker);
5176
4793
  }
5177
-
5178
4794
  function component(id, component) {
5179
4795
  var name;
5180
-
5181
4796
  if (is.String(id)) {
5182
4797
  name = toCase(id);
5183
-
5184
4798
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5185
4799
  return $form();
5186
4800
  } else if (component === undefined) {
@@ -5190,39 +4804,29 @@
5190
4804
  name = toCase(id.name);
5191
4805
  component = id;
5192
4806
  }
5193
-
5194
4807
  if (!name || !component) return;
5195
4808
  components[name] = component;
5196
4809
  if (component.formCreateParser) parser(name, component.formCreateParser);
5197
4810
  }
5198
-
5199
4811
  function $form() {
5200
4812
  return _vue.extend($FormCreate(FormCreate));
5201
4813
  }
5202
-
5203
4814
  function $vnode() {
5204
4815
  return _vue.extend(fragment);
5205
- } //todo 检查回调函数作用域
5206
-
5207
-
4816
+ }
5208
4817
  function use(fn, opt) {
5209
4818
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5210
4819
  return this;
5211
4820
  }
5212
-
5213
4821
  function create(rules, _opt, parent) {
5214
4822
  var $vm = mountForm(rules, _opt || {});
5215
4823
  var _this = $vm.$refs.fc.formCreate;
5216
4824
  _this.$parent = parent;
5217
-
5218
4825
  _getEl(_this.options).appendChild($vm.$el);
5219
-
5220
4826
  return _this.api();
5221
4827
  }
5222
-
5223
4828
  function factory(inherit) {
5224
4829
  var _config = _objectSpread2({}, config);
5225
-
5226
4830
  if (inherit) {
5227
4831
  _config.inherit = {
5228
4832
  components: components,
@@ -5235,10 +4839,8 @@
5235
4839
  } else {
5236
4840
  delete _config.inherit;
5237
4841
  }
5238
-
5239
4842
  return FormCreateFactory(_config);
5240
4843
  }
5241
-
5242
4844
  function FormCreate(vm, rules, options) {
5243
4845
  extend(this, {
5244
4846
  id: id$1++,
@@ -5249,6 +4851,7 @@
5249
4851
  providers: providers,
5250
4852
  rules: Array.isArray(rules) ? rules : [],
5251
4853
  name: vm.$options.propsData.name,
4854
+ inFor: vm.$options.propsData.inFor,
5252
4855
  prop: {
5253
4856
  components: components,
5254
4857
  directives: directives
@@ -5256,22 +4859,25 @@
5256
4859
  CreateNode: CreateNode,
5257
4860
  bus: new _vue(),
5258
4861
  unwatch: null,
4862
+ options: options || {},
5259
4863
  extendApi: config.extendApi || function (api) {
5260
4864
  return api;
5261
4865
  }
5262
4866
  });
5263
4867
  this.init();
5264
- this.initOptions(options || {});
5265
-
4868
+ this.initOptions(this.options);
5266
4869
  if (this.name) {
5267
- instance[this.name] = this.api();
4870
+ if (this.inFor) {
4871
+ if (!instance[this.name]) instance[this.name] = [];
4872
+ instance[this.name].push(this.api());
4873
+ } else {
4874
+ instance[this.name] = this.api();
4875
+ }
5268
4876
  }
5269
4877
  }
5270
-
5271
4878
  extend(FormCreate.prototype, {
5272
4879
  init: function init() {
5273
4880
  var _this2 = this;
5274
-
5275
4881
  var vm = this.vm;
5276
4882
  var h = new Handler(this);
5277
4883
  this.$handle = h;
@@ -5283,15 +4889,12 @@
5283
4889
  return vm.$pfc.option;
5284
4890
  }, function () {
5285
4891
  _this2.initOptions(_this2.options);
5286
-
5287
4892
  vm.$f.refresh();
5288
4893
  }, {
5289
4894
  deep: true
5290
4895
  });
5291
-
5292
4896
  _this2.initOptions(_this2.options);
5293
4897
  }
5294
-
5295
4898
  _this2.created();
5296
4899
  });
5297
4900
  vm.$on('hook:mounted', function () {
@@ -5301,9 +4904,13 @@
5301
4904
  vm.destroyed = true;
5302
4905
  _this2.unwatch && _this2.unwatch();
5303
4906
  h.reloadRule([]);
5304
-
5305
4907
  if (_this2.name) {
5306
- delete instance[_this2.name];
4908
+ if (_this2.inFor) {
4909
+ var idx = instance[_this2.name].indexOf(_this2.api());
4910
+ instance[_this2.name].splice(idx, 1);
4911
+ } else {
4912
+ delete instance[_this2.name];
4913
+ }
5307
4914
  }
5308
4915
  });
5309
4916
  vm.$on('hook:updated', function () {
@@ -5321,11 +4928,9 @@
5321
4928
  submitBtn: {},
5322
4929
  resetBtn: {}
5323
4930
  }, deepCopy(globalConfig));
5324
-
5325
4931
  if (this.isSub()) {
5326
4932
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5327
4933
  }
5328
-
5329
4934
  this.updateOptions(options);
5330
4935
  },
5331
4936
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5333,12 +4938,10 @@
5333
4938
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5334
4939
  delete opt[n];
5335
4940
  });
5336
-
5337
4941
  if (opt.global) {
5338
4942
  target.global = mergeGlobal(target.global, opt.global);
5339
4943
  delete opt.global;
5340
4944
  }
5341
-
5342
4945
  this.$handle.$manager.mergeOptions([opt], target);
5343
4946
  return target;
5344
4947
  },
@@ -5360,7 +4963,6 @@
5360
4963
  this.$handle.mounted();
5361
4964
  }
5362
4965
  });
5363
-
5364
4966
  function useAttr(formCreate) {
5365
4967
  extend(formCreate, {
5366
4968
  version: config.version,
@@ -5385,15 +4987,12 @@
5385
4987
  getApi: getApi,
5386
4988
  init: function init(rules) {
5387
4989
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5388
-
5389
4990
  var $vm = mountForm(rules, _opt),
5390
4991
  _this = $vm.$refs.fc.formCreate;
5391
4992
  return {
5392
4993
  mount: function mount($el) {
5393
4994
  if ($el && is.Element($el)) _this.options.el = $el;
5394
-
5395
4995
  _getEl(_this.options).appendChild($vm.$el);
5396
-
5397
4996
  return _this.api();
5398
4997
  },
5399
4998
  remove: function remove() {
@@ -5408,7 +5007,6 @@
5408
5007
  }
5409
5008
  });
5410
5009
  }
5411
-
5412
5010
  function useStatic(formCreate) {
5413
5011
  extend(formCreate, {
5414
5012
  create: create,
@@ -5417,12 +5015,10 @@
5417
5015
  if (Vue._installedFormCreate === true) return;
5418
5016
  Vue._installedFormCreate = true;
5419
5017
  _vue = Vue;
5420
-
5421
5018
  var $formCreate = function $formCreate(rules) {
5422
5019
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5423
5020
  return create(rules, opt, this);
5424
5021
  };
5425
-
5426
5022
  useAttr($formCreate);
5427
5023
  Vue.prototype.$formCreate = $formCreate;
5428
5024
  Vue.component('FormCreate', $form());
@@ -5430,7 +5026,6 @@
5430
5026
  }
5431
5027
  });
5432
5028
  }
5433
-
5434
5029
  useAttr(create);
5435
5030
  useStatic(create);
5436
5031
  CreateNode.use({
@@ -5438,7 +5033,6 @@
5438
5033
  });
5439
5034
  parser(html);
5440
5035
  if (config.install) create.use(config);
5441
-
5442
5036
  if (config.inherit) {
5443
5037
  var inherit = config.inherit;
5444
5038
  inherit.components && extend(components, inherit.components);
@@ -5448,7 +5042,6 @@
5448
5042
  inherit.maker && extend(maker, inherit.maker);
5449
5043
  inherit.data && extend(data, inherit.data);
5450
5044
  }
5451
-
5452
5045
  return create;
5453
5046
  }
5454
5047
 
@@ -5475,7 +5068,6 @@
5475
5068
  }(),
5476
5069
  mergeProp: function mergeProp(ctx) {
5477
5070
  var props = ctx.prop.props;
5478
-
5479
5071
  if (!props.valueFormat) {
5480
5072
  props.valueFormat = DEFAULT_FORMATS[props.type] || DEFAULT_FORMATS['date'];
5481
5073
  }
@@ -5510,7 +5102,6 @@
5510
5102
  }(),
5511
5103
  mergeProp: function mergeProp(ctx) {
5512
5104
  var props = ctx.prop.props;
5513
-
5514
5105
  if (props && props.autosize && props.autosize.minRows) {
5515
5106
  props.rows = props.autosize.minRows || 2;
5516
5107
  }
@@ -5530,13 +5121,11 @@
5530
5121
  props = ctx.prop.props,
5531
5122
  min = props.min || 0,
5532
5123
  parseValue;
5533
-
5534
5124
  if (props.range === true) {
5535
5125
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5536
5126
  } else {
5537
5127
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5538
5128
  }
5539
-
5540
5129
  return parseValue;
5541
5130
  }
5542
5131
  };
@@ -5554,7 +5143,6 @@
5554
5143
  },
5555
5144
  mergeProp: function mergeProp(ctx) {
5556
5145
  var props = ctx.prop.props;
5557
-
5558
5146
  if (!props.valueFormat) {
5559
5147
  props.valueFormat = 'HH:mm:ss';
5560
5148
  }
@@ -5658,26 +5246,20 @@
5658
5246
  function isTooltip(info) {
5659
5247
  return info.type === 'tooltip';
5660
5248
  }
5661
-
5662
5249
  var upperCaseReg = /[A-Z]/;
5663
5250
  function isAttr(name, value) {
5664
5251
  return !upperCaseReg.test(name) && (is.String(value) || is.Number(value));
5665
5252
  }
5666
-
5667
5253
  function tidy(props, name) {
5668
5254
  if (!hasProperty(props, name)) return;
5669
-
5670
5255
  if (is.String(props[name])) {
5671
5256
  var _props$name;
5672
-
5673
5257
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5674
5258
  }
5675
5259
  }
5676
-
5677
5260
  function isFalse(val) {
5678
5261
  return val === false;
5679
5262
  }
5680
-
5681
5263
  function tidyBool(opt, name) {
5682
5264
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5683
5265
  opt[name] = {
@@ -5685,7 +5267,6 @@
5685
5267
  };
5686
5268
  }
5687
5269
  }
5688
-
5689
5270
  var manager = {
5690
5271
  validate: function validate(call) {
5691
5272
  this.form().validate(call);
@@ -5695,7 +5276,6 @@
5695
5276
  },
5696
5277
  clearValidateState: function clearValidateState(ctx) {
5697
5278
  var fItem = this.vm.$refs[ctx.wrapRef];
5698
-
5699
5279
  if (fItem) {
5700
5280
  fItem.validateMessage = '';
5701
5281
  fItem.validateState = '';
@@ -5772,7 +5352,6 @@
5772
5352
  if (children.length) {
5773
5353
  children.push(this.makeFormBtn());
5774
5354
  }
5775
-
5776
5355
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5777
5356
  },
5778
5357
  makeWrap: function makeWrap(ctx, children) {
@@ -5810,7 +5389,6 @@
5810
5389
  var isTip = isTooltip(infoProp);
5811
5390
  var form = this.options.form;
5812
5391
  var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
5813
-
5814
5392
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5815
5393
  var prop = {
5816
5394
  type: infoProp.type || 'popover',
@@ -5819,11 +5397,9 @@
5819
5397
  slot: 'label'
5820
5398
  };
5821
5399
  var field = 'content';
5822
-
5823
5400
  if (infoProp.info && !hasProperty(prop.props, field)) {
5824
5401
  prop.props[field] = infoProp.info;
5825
5402
  }
5826
-
5827
5403
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5828
5404
  type: 'i',
5829
5405
  slot: isTip ? 'default' : 'reference',
@@ -5831,7 +5407,6 @@
5831
5407
  key: "".concat(uni, "i")
5832
5408
  })]));
5833
5409
  }
5834
-
5835
5410
  return this.$r(mergeProps([titleProp, {
5836
5411
  props: titleProp,
5837
5412
  slot: titleProp.slot || 'label',
@@ -5861,19 +5436,15 @@
5861
5436
  },
5862
5437
  makeFormBtn: function makeFormBtn() {
5863
5438
  var vn = [];
5864
-
5865
5439
  if (!isFalse(this.options.submitBtn.show)) {
5866
5440
  vn.push(this.makeSubmitBtn());
5867
5441
  }
5868
-
5869
5442
  if (!isFalse(this.options.resetBtn.show)) {
5870
5443
  vn.push(this.makeResetBtn());
5871
5444
  }
5872
-
5873
5445
  if (!vn.length) {
5874
5446
  return;
5875
5447
  }
5876
-
5877
5448
  var item = this.$r({
5878
5449
  type: 'formItem',
5879
5450
  key: "".concat(this.key, "fb")
@@ -5888,7 +5459,6 @@
5888
5459
  },
5889
5460
  makeResetBtn: function makeResetBtn() {
5890
5461
  var _this = this;
5891
-
5892
5462
  var resetBtn = this.options.resetBtn;
5893
5463
  return this.$r({
5894
5464
  type: 'button',
@@ -5907,7 +5477,6 @@
5907
5477
  },
5908
5478
  makeSubmitBtn: function makeSubmitBtn() {
5909
5479
  var _this2 = this;
5910
-
5911
5480
  var submitBtn = this.options.submitBtn;
5912
5481
  return this.$r({
5913
5482
  type: 'button',
@@ -5932,7 +5501,6 @@
5932
5501
  useTree(maker);
5933
5502
  useUpload(maker);
5934
5503
  useFrame(maker);
5935
-
5936
5504
  function useAlias(maker) {
5937
5505
  ['group', 'tree', 'switch', 'upload', 'autoComplete', 'checkbox', 'cascader', 'colorPicker', 'datePicker', 'frame', 'inputNumber', 'radio', 'rate'].forEach(function (name) {
5938
5506
  maker[name] = creatorFactory(name);
@@ -5941,14 +5509,12 @@
5941
5509
  maker.number = maker.inputNumber;
5942
5510
  maker.color = maker.colorPicker;
5943
5511
  }
5944
-
5945
5512
  function useSelect(maker) {
5946
5513
  var select = 'select';
5947
5514
  var multiple = 'multiple';
5948
5515
  maker['selectMultiple'] = creatorFactory(select, _defineProperty({}, multiple, true));
5949
5516
  maker['selectOne'] = creatorFactory(select, _defineProperty({}, multiple, false));
5950
5517
  }
5951
-
5952
5518
  function useTree(maker) {
5953
5519
  var name = 'tree';
5954
5520
  var types = {
@@ -5962,7 +5528,6 @@
5962
5528
  return m;
5963
5529
  }, maker);
5964
5530
  }
5965
-
5966
5531
  function useUpload(maker) {
5967
5532
  var name = 'upload';
5968
5533
  var types = {
@@ -5983,7 +5548,6 @@
5983
5548
  maker.uploadImage = maker.image;
5984
5549
  maker.uploadFile = maker.file;
5985
5550
  }
5986
-
5987
5551
  function useFrame(maker) {
5988
5552
  var types = {
5989
5553
  frameInputs: ['input', 0],
@@ -6019,28 +5583,23 @@
6019
5583
  };
6020
5584
  return btn;
6021
5585
  }
6022
-
6023
5586
  function extendApi(api, h) {
6024
5587
  extend(api, {
6025
5588
  validate: function validate(callback) {
6026
5589
  var flag;
6027
5590
  var forms = api.children;
6028
5591
  var len = forms.length;
6029
-
6030
5592
  var validate = function validate() {
6031
5593
  h.$manager.validate(function () {
6032
5594
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6033
5595
  args[_key] = arguments[_key];
6034
5596
  }
6035
-
6036
5597
  if (!args[0] || !flag) {
6037
5598
  flag = args;
6038
5599
  }
6039
-
6040
5600
  callback && callback.apply(void 0, _toConsumableArray(flag));
6041
5601
  });
6042
5602
  };
6043
-
6044
5603
  var validFn = function validFn(args) {
6045
5604
  setTimeout(function () {
6046
5605
  if (!args[0]) {
@@ -6048,23 +5607,19 @@
6048
5607
  flag = args;
6049
5608
  }
6050
5609
  }
6051
-
6052
5610
  if (! --len) {
6053
5611
  validate();
6054
5612
  }
6055
5613
  });
6056
5614
  };
6057
-
6058
5615
  forms.forEach(function (form) {
6059
5616
  form.validate(function () {
6060
5617
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6061
5618
  args[_key2] = arguments[_key2];
6062
5619
  }
6063
-
6064
5620
  return validFn(args);
6065
5621
  });
6066
5622
  });
6067
-
6068
5623
  if (!len) {
6069
5624
  validate();
6070
5625
  }
@@ -6075,23 +5630,19 @@
6075
5630
  var sub = h.subForm[ctx.id];
6076
5631
  var len = 0;
6077
5632
  var flag;
6078
-
6079
5633
  var validate = function validate() {
6080
5634
  h.$manager.validateField(ctx.id, function () {
6081
5635
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
6082
5636
  args[_key3] = arguments[_key3];
6083
5637
  }
6084
-
6085
5638
  if (args[0]) {
6086
5639
  flag = args;
6087
5640
  } else if (flag) {
6088
5641
  return callback && callback('子表单验证未通过', flag[1]);
6089
5642
  }
6090
-
6091
5643
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
6092
5644
  });
6093
5645
  };
6094
-
6095
5646
  var validFn = function validFn(args) {
6096
5647
  setTimeout(function () {
6097
5648
  if (!args[0]) {
@@ -6099,31 +5650,26 @@
6099
5650
  flag = args;
6100
5651
  }
6101
5652
  }
6102
-
6103
5653
  if (! --len) {
6104
5654
  validate();
6105
5655
  }
6106
5656
  });
6107
5657
  };
6108
-
6109
5658
  sub && toArray(sub).forEach(function (form) {
6110
5659
  len++;
6111
5660
  form.validate(function () {
6112
5661
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
6113
5662
  args[_key4] = arguments[_key4];
6114
5663
  }
6115
-
6116
5664
  return validFn(args);
6117
5665
  });
6118
5666
  });
6119
-
6120
5667
  if (!len) {
6121
5668
  validate();
6122
5669
  }
6123
5670
  },
6124
5671
  clearValidateState: function clearValidateState(fields) {
6125
5672
  var _this = this;
6126
-
6127
5673
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6128
5674
  api.helper.tidyFields(fields).forEach(function (field) {
6129
5675
  if (clearSub) _this.clearSubValidateState(field);
@@ -6137,7 +5683,6 @@
6137
5683
  h.getCtxs(field).forEach(function (ctx) {
6138
5684
  var subForm = h.subForm[ctx.id];
6139
5685
  if (!subForm) return;
6140
-
6141
5686
  if (Array.isArray(subForm)) {
6142
5687
  subForm.forEach(function (form) {
6143
5688
  form.clearValidateState();
@@ -6151,14 +5696,12 @@
6151
5696
  btn: {
6152
5697
  loading: function loading() {
6153
5698
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6154
-
6155
5699
  api.submitBtnProps({
6156
5700
  loading: !!_loading
6157
5701
  });
6158
5702
  },
6159
5703
  disabled: function disabled() {
6160
5704
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6161
-
6162
5705
  api.submitBtnProps({
6163
5706
  disabled: !!_disabled
6164
5707
  });
@@ -6173,14 +5716,12 @@
6173
5716
  resetBtn: {
6174
5717
  loading: function loading() {
6175
5718
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6176
-
6177
5719
  api.resetBtnProps({
6178
5720
  loading: !!_loading2
6179
5721
  });
6180
5722
  },
6181
5723
  disabled: function disabled() {
6182
5724
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6183
-
6184
5725
  api.resetBtnProps({
6185
5726
  disabled: !!_disabled2
6186
5727
  });
@@ -6209,7 +5750,6 @@
6209
5750
  submit: function submit(successFn, failFn) {
6210
5751
  var _arguments = arguments,
6211
5752
  _this2 = this;
6212
-
6213
5753
  api.validate(function (valid) {
6214
5754
  if (valid) {
6215
5755
  var formData = api.formData();
@@ -6244,11 +5784,10 @@
6244
5784
  FormCreate.maker[name] = maker[name];
6245
5785
  });
6246
5786
  }
6247
-
6248
5787
  function elmFormCreate() {
6249
5788
  return FormCreateFactory({
6250
5789
  ui: "".concat("element-ui"),
6251
- version: "".concat("2.5.19"),
5790
+ version: "".concat("2.5.22"),
6252
5791
  manager: manager,
6253
5792
  extendApi: extendApi,
6254
5793
  install: install,
@@ -6261,15 +5800,12 @@
6261
5800
  }
6262
5801
 
6263
5802
  var FormCreate = elmFormCreate();
6264
-
6265
5803
  if (typeof window !== 'undefined') {
6266
5804
  window.formCreate = FormCreate;
6267
-
6268
5805
  if (window.Vue) {
6269
5806
  FormCreate.install(window.Vue);
6270
5807
  }
6271
5808
  }
6272
-
6273
5809
  var maker$1 = FormCreate.maker;
6274
5810
 
6275
5811
  exports.default = FormCreate;