@form-create/element-ui 2.5.17 → 2.5.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v2.5.17
2
+ * @form-create/element-ui v2.5.20
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -19,11 +19,9 @@
19
19
  Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]);
20
20
  }
21
21
  }
22
-
23
22
  return a;
24
23
  }, _extends.apply(this, arguments);
25
24
  }
26
-
27
25
  var normalMerge = ["attrs", "props", "domProps"],
28
26
  toArrayMerge = ["class", "style", "directives"],
29
27
  functionalMerge = ["on", "nativeOn"],
@@ -46,7 +44,6 @@
46
44
  c[b][i] = c[b][i] ? mergeFn(c[b][i], a[b][i]) : a[b][i];
47
45
  } else c[b] = a[b];
48
46
  }
49
-
50
47
  return c;
51
48
  }, {});
52
49
  },
@@ -55,7 +52,6 @@
55
52
  a && a.apply(this, arguments), b && b.apply(this, arguments);
56
53
  };
57
54
  };
58
-
59
55
  var helper = mergeJsxProps;
60
56
 
61
57
  function _typeof(obj) {
@@ -246,7 +242,6 @@
246
242
  if (!exclude || exclude.indexOf(name) === -1) {
247
243
  lst.push(slots[name]);
248
244
  }
249
-
250
245
  return lst;
251
246
  }, []);
252
247
  }
@@ -299,7 +294,6 @@
299
294
  },
300
295
  update: function update() {
301
296
  var _this = this;
302
-
303
297
  this.trueValue = this.value ? this.options().filter(function (opt) {
304
298
  return _this.value.indexOf(opt.value) !== -1;
305
299
  }).map(function (option) {
@@ -312,7 +306,6 @@
312
306
  },
313
307
  render: function render() {
314
308
  var _this2 = this;
315
-
316
309
  var h = arguments[0];
317
310
  return h("ElCheckboxGroup", helper([{}, this.formCreateInject.prop, {
318
311
  "attrs": {
@@ -323,7 +316,6 @@
323
316
  }
324
317
  }]), [this.options().map(function (opt, index) {
325
318
  var props = _objectSpread2({}, opt);
326
-
327
319
  var Type = _this2.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
328
320
  delete props.value;
329
321
  return h(Type, {
@@ -341,15 +333,12 @@
341
333
  function styleInject(css, ref) {
342
334
  if (ref === void 0) ref = {};
343
335
  var insertAt = ref.insertAt;
344
-
345
336
  if (!css || typeof document === 'undefined') {
346
337
  return;
347
338
  }
348
-
349
339
  var head = document.head || document.getElementsByTagName('head')[0];
350
340
  var style = document.createElement('style');
351
341
  style.type = 'text/css';
352
-
353
342
  if (insertAt === 'top') {
354
343
  if (head.firstChild) {
355
344
  head.insertBefore(style, head.firstChild);
@@ -359,7 +348,6 @@
359
348
  } else {
360
349
  head.appendChild(style);
361
350
  }
362
-
363
351
  if (style.styleSheet) {
364
352
  style.styleSheet.cssText = css;
365
353
  } else {
@@ -515,12 +503,10 @@
515
503
  },
516
504
  closeModel: function closeModel(close) {
517
505
  this.$emit(close ? '$close' : '$ok');
518
-
519
506
  if (this.reload) {
520
507
  this.$off('$ok');
521
508
  this.$off('$close');
522
509
  }
523
-
524
510
  this.frameVisible = false;
525
511
  },
526
512
  handleCancel: function handleCancel() {
@@ -530,12 +516,10 @@
530
516
  if (this.disabled || false === this.onOpen()) {
531
517
  return;
532
518
  }
533
-
534
519
  this.frameVisible = true;
535
520
  },
536
521
  makeInput: function makeInput() {
537
522
  var _this = this;
538
-
539
523
  var h = this.$createElement;
540
524
  var props = {
541
525
  type: 'text',
@@ -572,11 +556,9 @@
572
556
  },
573
557
  makeGroup: function makeGroup(children) {
574
558
  var h = this.$createElement;
575
-
576
559
  if (!this.maxLength || this.fileList.length < this.maxLength) {
577
560
  children.push(this.makeBtn());
578
561
  }
579
-
580
562
  return h("div", {
581
563
  "key": this.key('group')
582
564
  }, _toConsumableArray(children));
@@ -590,25 +572,20 @@
590
572
  },
591
573
  valid: function valid(f) {
592
574
  var field = this.formCreateInject.field || this.field;
593
-
594
575
  if (field && f !== field) {
595
576
  throw new Error('[frame]无效的字段值');
596
577
  }
597
578
  },
598
579
  makeIcons: function makeIcons(val, index) {
599
580
  var h = this.$createElement;
600
-
601
581
  if (this.handleIcon !== false || this.allowRemove === true) {
602
582
  var icons = [];
603
-
604
583
  if (this.type !== 'file' && this.handleIcon !== false || this.type === 'file' && this.handleIcon) {
605
584
  icons.push(this.makeHandleIcon(val, index));
606
585
  }
607
-
608
586
  if (this.allowRemove) {
609
587
  icons.push(this.makeRemoveIcon(val, index));
610
588
  }
611
-
612
589
  return h("div", {
613
590
  "class": 'fc-upload-cover',
614
591
  "key": this.key('uc')
@@ -617,7 +594,6 @@
617
594
  },
618
595
  makeHandleIcon: function makeHandleIcon(val, index) {
619
596
  var _this2 = this;
620
-
621
597
  var h = this.$createElement;
622
598
  return h("i", {
623
599
  "class": this.handleIcon === true || this.handleIcon === undefined ? 'el-icon-view' : this.handleIcon,
@@ -631,7 +607,6 @@
631
607
  },
632
608
  makeRemoveIcon: function makeRemoveIcon(val, index) {
633
609
  var _this3 = this;
634
-
635
610
  var h = this.$createElement;
636
611
  return h("i", {
637
612
  "class": "el-icon-delete",
@@ -645,7 +620,6 @@
645
620
  },
646
621
  makeFiles: function makeFiles() {
647
622
  var _this4 = this;
648
-
649
623
  var h = this.$createElement;
650
624
  return this.makeGroup(this.fileList.map(function (src, index) {
651
625
  return _this4.makeItem(index, [h("i", {
@@ -660,7 +634,6 @@
660
634
  },
661
635
  makeImages: function makeImages() {
662
636
  var _this5 = this;
663
-
664
637
  var h = this.$createElement;
665
638
  return this.makeGroup(this.fileList.map(function (src, index) {
666
639
  return _this5.makeItem(index, [h("img", {
@@ -672,7 +645,6 @@
672
645
  },
673
646
  makeBtn: function makeBtn() {
674
647
  var _this6 = this;
675
-
676
648
  var h = this.$createElement;
677
649
  return h("div", {
678
650
  "class": 'fc-upload-btn',
@@ -693,7 +665,6 @@
693
665
  if (this.disabled) {
694
666
  return;
695
667
  }
696
-
697
668
  if (false !== this.onBeforeRemove(src)) {
698
669
  this.fileList.splice(this.fileList.indexOf(src), 1);
699
670
  this.onRemove(src);
@@ -704,25 +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'] = {
682
+ api: this.formCreateInject.api,
713
683
  close: function close(field) {
714
684
  _this7.valid(field);
715
-
716
685
  _this7.closeModel();
717
686
  },
718
687
  set: function set(field, value) {
719
688
  _this7.valid(field);
720
-
721
689
  if (!_this7.disabled) _this7.$emit('input', value);
722
690
  },
723
691
  get: function get(field) {
724
692
  _this7.valid(field);
725
-
726
693
  return _this7.value;
727
694
  },
728
695
  onOk: function onOk(fn) {
@@ -739,7 +706,6 @@
739
706
  },
740
707
  makeFooter: function makeFooter() {
741
708
  var _this8 = this;
742
-
743
709
  var h = this.$createElement;
744
710
  var _this$$props = this.$props,
745
711
  okBtnText = _this$$props.okBtnText,
@@ -747,11 +713,9 @@
747
713
  closeBtn = _this$$props.closeBtn,
748
714
  okBtn = _this$$props.okBtn,
749
715
  footer = _this$$props.footer;
750
-
751
716
  if (!footer) {
752
717
  return;
753
718
  }
754
-
755
719
  return h("div", {
756
720
  "slot": "footer"
757
721
  }, [closeBtn ? h("ElButton", {
@@ -774,11 +738,9 @@
774
738
  },
775
739
  render: function render() {
776
740
  var _this9 = this;
777
-
778
741
  var h = arguments[0];
779
742
  var type = this.type;
780
743
  var node;
781
-
782
744
  if (type === 'input') {
783
745
  node = this.makeInput();
784
746
  } else if (type === 'image') {
@@ -786,7 +748,6 @@
786
748
  } else {
787
749
  node = this.makeFiles();
788
750
  }
789
-
790
751
  var _this$$props2 = this.$props,
791
752
  _this$$props2$width = _this$$props2.width,
792
753
  width = _this$$props2$width === void 0 ? '30%' : _this$$props2$width,
@@ -812,21 +773,18 @@
812
773
  "close": this.handleCancel
813
774
  }
814
775
  }, [h("img", {
776
+ "style": "width: 100%",
815
777
  "attrs": {
816
- "alt": "example",
817
778
  "src": this.previewImage
818
- },
819
- "style": "width: 100%"
779
+ }
820
780
  })]), h("el-dialog", helper([{
821
781
  "attrs": {
822
782
  "appendToBody": true
823
783
  }
824
- }, {
825
- "props": _objectSpread2({
826
- width: width,
827
- title: title
828
- }, this.modal)
829
- }, {
784
+ }, _objectSpread2({
785
+ width: width,
786
+ title: title
787
+ }, this.modal), {
830
788
  "attrs": {
831
789
  "visible": this.frameVisible
832
790
  },
@@ -894,7 +852,6 @@
894
852
  },
895
853
  update: function update() {
896
854
  var _this = this;
897
-
898
855
  this.trueValue = this.options().filter(function (opt) {
899
856
  return opt.value === _this.value;
900
857
  }).reduce(function (initial, opt) {
@@ -907,7 +864,6 @@
907
864
  },
908
865
  render: function render() {
909
866
  var _this2 = this;
910
-
911
867
  var h = arguments[0];
912
868
  return h("ElRadioGroup", helper([{}, this.formCreateInject.prop, {
913
869
  "attrs": {
@@ -918,7 +874,6 @@
918
874
  }
919
875
  }]), [this.options().map(function (opt, index) {
920
876
  var props = _objectSpread2({}, opt);
921
-
922
877
  var Type = _this2.type === 'button' ? 'ElRadioButton' : 'ElRadio';
923
878
  delete props.value;
924
879
  return h(Type, {
@@ -941,9 +896,26 @@
941
896
  },
942
897
  trueArray: function trueArray(data) {
943
898
  return Array.isArray(data) && data.length > 0;
899
+ },
900
+ Function: function Function(v) {
901
+ var type = this.getType(v);
902
+ return type === 'Function' || type === 'AsyncFunction';
903
+ },
904
+ getType: function getType(v) {
905
+ var str = Object.prototype.toString.call(v);
906
+ return /^\[object (.*)\]$/.exec(str)[1];
907
+ },
908
+ empty: function empty(value) {
909
+ if (value === undefined || value === null) {
910
+ return true;
911
+ }
912
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
913
+ return true;
914
+ }
915
+ return typeof value === 'string' && !value;
944
916
  }
945
917
  };
946
- ['Date', 'Object', 'Function', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
918
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
947
919
  is[t] = function (arg) {
948
920
  return is.type(arg, t);
949
921
  };
@@ -1017,18 +989,15 @@
1017
989
  if (!this.$refs.tree) return;
1018
990
  var type = this.type.toLocaleLowerCase();
1019
991
  var value;
1020
-
1021
992
  if (type === 'selected') {
1022
993
  value = this.$refs.tree.getCurrentKey();
1023
994
  } else {
1024
995
  value = this.$refs.tree.getCheckedKeys();
1025
996
  }
1026
-
1027
997
  this.$emit('input', value);
1028
998
  },
1029
999
  setValue: function setValue() {
1030
1000
  var type = this.type.toLocaleLowerCase();
1031
-
1032
1001
  if (type === 'selected') {
1033
1002
  this.$refs.tree.setCurrentKey(this.value);
1034
1003
  } else {
@@ -1038,7 +1007,6 @@
1038
1007
  },
1039
1008
  render: function render() {
1040
1009
  var _this = this;
1041
-
1042
1010
  var h = arguments[0];
1043
1011
  return h("ElTree", helper([{}, this.formCreateInject.prop, {
1044
1012
  "ref": "tree",
@@ -1067,11 +1035,9 @@
1067
1035
  uid: i
1068
1036
  };
1069
1037
  }
1070
-
1071
1038
  function getFileName(file) {
1072
1039
  return ('' + file).split('/').pop();
1073
1040
  }
1074
-
1075
1041
  var NAME$5 = 'fcUpload';
1076
1042
  var Upload = {
1077
1043
  name: NAME$5,
@@ -1121,7 +1087,6 @@
1121
1087
  if (this.formCreateInject.prop.props.showFileList === undefined) {
1122
1088
  this.formCreateInject.prop.props.showFileList = false;
1123
1089
  }
1124
-
1125
1090
  this.formCreateInject.prop.props.fileList = toArray(this.value).map(parseFile);
1126
1091
  },
1127
1092
  watch: {
@@ -1150,7 +1115,6 @@
1150
1115
  if (this.isDisabled()) {
1151
1116
  return;
1152
1117
  }
1153
-
1154
1118
  this.$refs.upload.handleRemove(file);
1155
1119
  },
1156
1120
  handleClick: function handleClick(file) {
@@ -1170,7 +1134,6 @@
1170
1134
  },
1171
1135
  makeRemoveIcon: function makeRemoveIcon(file, index) {
1172
1136
  var _this = this;
1173
-
1174
1137
  var h = this.$createElement;
1175
1138
  return h("i", {
1176
1139
  "class": "el-icon-delete",
@@ -1184,7 +1147,6 @@
1184
1147
  },
1185
1148
  makeHandleIcon: function makeHandleIcon(file, index) {
1186
1149
  var _this2 = this;
1187
-
1188
1150
  var h = this.$createElement;
1189
1151
  return h("i", {
1190
1152
  "class": this.handleIcon === true || this.handleIcon === undefined ? 'el-icon-view' : this.handleIcon,
@@ -1212,16 +1174,13 @@
1212
1174
  makeIcons: function makeIcons(file, index) {
1213
1175
  var h = this.$createElement;
1214
1176
  var icons = [];
1215
-
1216
1177
  if (this.allowRemove || this.handleIcon !== false) {
1217
1178
  if (this.uploadType !== 'file' && this.handleIcon !== false || this.uploadType === 'file' && this.handleIcon) {
1218
1179
  icons.push(this.makeHandleIcon(file, index));
1219
1180
  }
1220
-
1221
1181
  if (this.allowRemove) {
1222
1182
  icons.push(this.makeRemoveIcon(file, index));
1223
1183
  }
1224
-
1225
1184
  return h("div", {
1226
1185
  "class": 'fc-upload-cover'
1227
1186
  }, [icons]);
@@ -1229,7 +1188,6 @@
1229
1188
  },
1230
1189
  makeFiles: function makeFiles() {
1231
1190
  var _this3 = this;
1232
-
1233
1191
  var h = this.$createElement;
1234
1192
  return this.uploadList.map(function (file, index) {
1235
1193
  return _this3.$scopedSlots.fileList ? _this3.$scopedSlots.fileList({
@@ -1265,7 +1223,6 @@
1265
1223
  }).filter(function (url) {
1266
1224
  return url !== undefined;
1267
1225
  });
1268
-
1269
1226
  if (this.cacheFiles.length !== files.length) {
1270
1227
  this.cacheFiles = _toConsumableArray(files);
1271
1228
  this.$emit('input', this.limit === 1 ? files[0] || '' : files);
@@ -1277,15 +1234,12 @@
1277
1234
  },
1278
1235
  render: function render() {
1279
1236
  var h = arguments[0];
1280
-
1281
1237
  if (this.$refs.upload) {
1282
1238
  if (this.formCreateInject.prop.props.showFileList === undefined) {
1283
1239
  this.formCreateInject.prop.props.showFileList = this.$refs.upload.showFileList;
1284
1240
  }
1285
-
1286
1241
  this.formCreateInject.prop.props.fileList = this.$refs.upload.fileList;
1287
1242
  }
1288
-
1289
1243
  return h("div", {
1290
1244
  "class": '_fc-upload'
1291
1245
  }, [[this.formCreateInject.prop.props.showFileList ? [] : this.makeFiles(), this.makeUpload()], h("el-dialog", {
@@ -1308,7 +1262,6 @@
1308
1262
  },
1309
1263
  mounted: function mounted() {
1310
1264
  var _this4 = this;
1311
-
1312
1265
  this.uploadList = this.$refs.upload.uploadFiles;
1313
1266
  this.$watch(function () {
1314
1267
  return _this4.$refs.upload.uploadFiles;
@@ -1320,6 +1273,72 @@
1320
1273
  }
1321
1274
  };
1322
1275
 
1276
+ function $set(target, field, value) {
1277
+ Vue.set(target, field, value);
1278
+ }
1279
+ function $del(target, field) {
1280
+ Vue["delete"](target, field);
1281
+ }
1282
+
1283
+ function deepExtend(origin) {
1284
+ var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1285
+ var mode = arguments.length > 2 ? arguments[2] : undefined;
1286
+ var isArr = false;
1287
+ for (var key in target) {
1288
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
1289
+ var clone = target[key];
1290
+ if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1291
+ var nst = origin[key] === undefined;
1292
+ if (isArr) {
1293
+ isArr = false;
1294
+ nst && $set(origin, key, []);
1295
+ } else if (clone._clone && mode !== undefined) {
1296
+ if (mode) {
1297
+ clone = clone.getRule();
1298
+ nst && $set(origin, key, {});
1299
+ } else {
1300
+ $set(origin, key, clone._clone());
1301
+ continue;
1302
+ }
1303
+ } else {
1304
+ nst && $set(origin, key, {});
1305
+ }
1306
+ origin[key] = deepExtend(origin[key], clone, mode);
1307
+ } else {
1308
+ $set(origin, key, clone);
1309
+ if (!is.Undef(clone)) {
1310
+ if (!is.Undef(clone.__json)) {
1311
+ origin[key].__json = clone.__json;
1312
+ }
1313
+ if (!is.Undef(clone.__origin)) {
1314
+ origin[key].__origin = clone.__origin;
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ }
1320
+ return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1321
+ return !v || !v.__ctrl;
1322
+ }) : origin;
1323
+ }
1324
+ function deepCopy(value) {
1325
+ return deepExtend({}, {
1326
+ value: value
1327
+ }).value;
1328
+ }
1329
+
1330
+ var _extends$1 = Object.assign || function (a) {
1331
+ for (var b, c = 1; c < arguments.length; c++) {
1332
+ for (var d in b = arguments[c], b) {
1333
+ Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1334
+ }
1335
+ }
1336
+ return a;
1337
+ };
1338
+ function extend() {
1339
+ return _extends$1.apply(this, arguments);
1340
+ }
1341
+
1323
1342
  var NAME$6 = 'fcGroup';
1324
1343
  var Group = {
1325
1344
  name: NAME$6,
@@ -1351,6 +1370,7 @@
1351
1370
  return [];
1352
1371
  }
1353
1372
  },
1373
+ defaultValue: Object,
1354
1374
  disabled: {
1355
1375
  type: Boolean,
1356
1376
  "default": false
@@ -1382,18 +1402,34 @@
1382
1402
  },
1383
1403
  computed: {
1384
1404
  formRule: function formRule() {
1385
- if (this.rule) {
1386
- return Array.isArray(this.rule) ? this.rule : [this.rule];
1387
- }
1388
-
1389
1405
  if (this.rules) {
1390
1406
  return this.rules;
1391
1407
  }
1392
-
1408
+ if (this.rule) {
1409
+ return Array.isArray(this.rule) ? this.rule : [this.rule];
1410
+ }
1393
1411
  return [];
1394
1412
  }
1395
1413
  },
1396
1414
  watch: {
1415
+ formRule: {
1416
+ handler: function handler(n, o) {
1417
+ var _this = this;
1418
+ Object.keys(this.cacheRule).forEach(function (v) {
1419
+ var item = _this.cacheRule[v];
1420
+ if (n === o) {
1421
+ deepExtend(item.rule, n);
1422
+ } else {
1423
+ var val = item.$f.formData();
1424
+ item.$f.once('reload', function () {
1425
+ item.$f.setValue(val);
1426
+ });
1427
+ item.rule = deepCopy(n);
1428
+ }
1429
+ });
1430
+ },
1431
+ deep: true
1432
+ },
1397
1433
  disabled: function disabled(n) {
1398
1434
  if (this.syncDisabled) {
1399
1435
  var lst = this.cacheRule;
@@ -1404,24 +1440,20 @@
1404
1440
  },
1405
1441
  expand: function expand(n) {
1406
1442
  var d = n - this.value.length;
1407
-
1408
1443
  if (d > 0) {
1409
1444
  this.expandRule(d);
1410
1445
  }
1411
1446
  },
1412
1447
  value: function value(n) {
1413
- var _this = this;
1414
-
1448
+ var _this2 = this;
1415
1449
  n = n || [];
1416
1450
  var keys = Object.keys(this.cacheRule),
1417
1451
  total = keys.length,
1418
1452
  len = total - n.length;
1419
-
1420
1453
  if (len < 0) {
1421
1454
  for (var i = len; i < 0; i++) {
1422
1455
  this.addRule(n.length + i);
1423
1456
  }
1424
-
1425
1457
  for (var _i = 0; _i < total; _i++) {
1426
1458
  this.setValue(keys[_i], n[_i]);
1427
1459
  }
@@ -1430,12 +1462,9 @@
1430
1462
  for (var _i2 = 0; _i2 < len; _i2++) {
1431
1463
  this.removeRule(keys[total - _i2 - 1]);
1432
1464
  }
1433
-
1434
- this.subForm();
1435
1465
  }
1436
-
1437
1466
  n.forEach(function (val, i) {
1438
- _this.setValue(keys[i], n[i]);
1467
+ _this2.setValue(keys[i], n[i]);
1439
1468
  });
1440
1469
  }
1441
1470
  }
@@ -1452,23 +1481,18 @@
1452
1481
  this.$emit('change', value);
1453
1482
  },
1454
1483
  formData: function formData(key, _formData) {
1455
- var _this2 = this;
1456
-
1484
+ var _this3 = this;
1457
1485
  var cacheRule = this.cacheRule;
1458
1486
  var keys = Object.keys(cacheRule);
1459
-
1460
1487
  if (keys.filter(function (k) {
1461
1488
  return cacheRule[k].$f;
1462
1489
  }).length !== keys.length) {
1463
1490
  return;
1464
1491
  }
1465
-
1466
1492
  var value = keys.map(function (k) {
1467
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1468
- var value = _this2.field ? data[_this2.field] || null : data;
1469
-
1470
- _this2.cache(k, value);
1471
-
1493
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1494
+ var value = _this3.field ? data[_this3.field] || null : data;
1495
+ _this3.cache(k, value);
1472
1496
  return value;
1473
1497
  });
1474
1498
  this.input(value);
@@ -1476,65 +1500,53 @@
1476
1500
  setValue: function setValue(key, value) {
1477
1501
  var field = this.field,
1478
1502
  $f = this.cacheRule[key].$f;
1479
-
1480
1503
  if (field) {
1481
1504
  value = _defineProperty({}, field, this._value(value));
1482
1505
  }
1483
-
1484
1506
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1485
1507
  return;
1486
1508
  }
1487
-
1488
1509
  this.cache(key, value);
1489
1510
  $f.coverValue(value || {});
1490
1511
  },
1491
1512
  addRule: function addRule(i, emit) {
1492
- var _this3 = this;
1493
-
1513
+ var _this4 = this;
1494
1514
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1495
1515
  var options = this.options ? _objectSpread2({}, this.options) : {
1496
1516
  submitBtn: false,
1497
1517
  resetBtn: false
1498
1518
  };
1499
- options.formData = this.field ? _defineProperty({}, this.field, this._value(this.value[i])) : this.value[i] || {};
1519
+ if (this.defaultValue) {
1520
+ if (!options.formData) options.formData = {};
1521
+ var defVal = deepCopy(this.defaultValue);
1522
+ extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1523
+ }
1500
1524
  this.$set(this.cacheRule, ++this.len, {
1501
1525
  rule: rule,
1502
1526
  options: options
1503
1527
  });
1504
-
1505
1528
  if (emit) {
1506
1529
  this.$nextTick(function () {
1507
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1530
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1508
1531
  });
1509
1532
  }
1510
1533
  },
1511
1534
  add$f: function add$f(i, key, $f) {
1512
- var _this4 = this;
1513
-
1535
+ var _this5 = this;
1514
1536
  this.cacheRule[key].$f = $f;
1515
- this.subForm();
1537
+ this.formData(key, $f.formData());
1516
1538
  this.$nextTick(function () {
1517
- if (_this4.syncDisabled) {
1518
- $f.disabled(_this4.disabled);
1539
+ if (_this5.syncDisabled) {
1540
+ $f.disabled(_this5.disabled);
1519
1541
  }
1520
-
1521
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1542
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1522
1543
  });
1523
1544
  },
1524
- subForm: function subForm() {
1525
- var _this5 = this;
1526
-
1527
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1528
- return _this5.cacheRule[k].$f;
1529
- }));
1530
- },
1531
1545
  removeRule: function removeRule(key, emit) {
1532
1546
  var _this6 = this;
1533
-
1534
1547
  var index = Object.keys(this.cacheRule).indexOf(key);
1535
1548
  this.$delete(this.cacheRule, key);
1536
1549
  this.$delete(this.cacheValue, key);
1537
-
1538
1550
  if (emit) {
1539
1551
  this.$nextTick(function () {
1540
1552
  return _this6.$emit('remove', index);
@@ -1545,16 +1557,13 @@
1545
1557
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1546
1558
  return;
1547
1559
  }
1548
-
1549
1560
  this.addRule(i, true);
1550
1561
  },
1551
1562
  del: function del(index, key) {
1552
1563
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1553
1564
  return;
1554
1565
  }
1555
-
1556
1566
  this.removeRule(key, true);
1557
- this.subForm();
1558
1567
  this.value.splice(index, 1);
1559
1568
  this.input(this.value);
1560
1569
  },
@@ -1571,7 +1580,6 @@
1571
1580
  },
1572
1581
  delIcon: function delIcon(index, key) {
1573
1582
  var _this7 = this;
1574
-
1575
1583
  var h = this.$createElement;
1576
1584
  return h("i", {
1577
1585
  "key": "d".concat(key),
@@ -1586,7 +1594,6 @@
1586
1594
  },
1587
1595
  makeIcon: function makeIcon(total, index, key) {
1588
1596
  var _this8 = this;
1589
-
1590
1597
  if (this.$scopedSlots.button) {
1591
1598
  return this.$scopedSlots.button({
1592
1599
  total: total,
@@ -1599,11 +1606,9 @@
1599
1606
  add: this.add
1600
1607
  });
1601
1608
  }
1602
-
1603
1609
  if (index === 0) {
1604
1610
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1605
1611
  }
1606
-
1607
1612
  if (index >= this.min) {
1608
1613
  return this.delIcon(index, key);
1609
1614
  }
@@ -1620,18 +1625,15 @@
1620
1625
  created: function created() {
1621
1626
  this.type = this.formCreateInject.form.$form();
1622
1627
  var d = (this.expand || 0) - this.value.length;
1623
-
1624
1628
  if (d > 0) {
1625
1629
  this.expandRule(d);
1626
1630
  }
1627
-
1628
1631
  for (var i = 0; i < this.value.length; i++) {
1629
1632
  this.addRule(i);
1630
1633
  }
1631
1634
  },
1632
1635
  render: function render() {
1633
1636
  var _this9 = this;
1634
-
1635
1637
  var h = arguments[0];
1636
1638
  var keys = Object.keys(this.cacheRule);
1637
1639
  var button = this.button;
@@ -1664,7 +1666,10 @@
1664
1666
  "span": button ? 20 : 24
1665
1667
  }
1666
1668
  }, [h("ElFormItem", [h(Type, helper([{
1667
- "key": key
1669
+ "key": key,
1670
+ "attrs": {
1671
+ "inFor": true
1672
+ }
1668
1673
  }, {
1669
1674
  "on": {
1670
1675
  'update:value': function updateValue(formData) {
@@ -1674,7 +1679,6 @@
1674
1679
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1675
1680
  args[_key - 1] = arguments[_key];
1676
1681
  }
1677
-
1678
1682
  return _this9.emitEvent(name, args, index, key);
1679
1683
  },
1680
1684
  input: function input($f) {
@@ -1683,6 +1687,7 @@
1683
1687
  }
1684
1688
  }, {
1685
1689
  "attrs": {
1690
+ "value": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.value[index])) : _this9.value[index],
1686
1691
  "rule": rule,
1687
1692
  "option": options,
1688
1693
  "extendOption": true
@@ -1746,11 +1751,9 @@
1746
1751
  },
1747
1752
  setValue: function setValue(value) {
1748
1753
  var str = JSON.stringify(value);
1749
-
1750
1754
  if (this.cacheValue === str) {
1751
1755
  return;
1752
1756
  }
1753
-
1754
1757
  this.cacheValue = str;
1755
1758
  this.cacheRule.$f.coverValue(value || {});
1756
1759
  },
@@ -1767,23 +1770,16 @@
1767
1770
  },
1768
1771
  add$f: function add$f($f) {
1769
1772
  var _this = this;
1770
-
1771
1773
  this.cacheRule.$f = $f;
1772
- this.subForm();
1773
1774
  this.$nextTick(function () {
1774
1775
  _this.syncDisabled && $f.disabled(_this.disabled);
1775
-
1776
1776
  _this.$emit('itemMounted', $f);
1777
1777
  });
1778
1778
  },
1779
- subForm: function subForm() {
1780
- this.formCreateInject.subForm(this.cacheRule.$f);
1781
- },
1782
1779
  emitEvent: function emitEvent(name) {
1783
1780
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1784
1781
  args[_key - 1] = arguments[_key];
1785
1782
  }
1786
-
1787
1783
  this.$emit.apply(this, [name].concat(args));
1788
1784
  }
1789
1785
  },
@@ -1815,28 +1811,18 @@
1815
1811
 
1816
1812
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub];
1817
1813
 
1818
- function $set(target, field, value) {
1819
- Vue.set(target, field, value);
1820
- }
1821
- function $del(target, field) {
1822
- Vue["delete"](target, field);
1823
- }
1824
-
1825
- var _extends$1 = Object.assign || function (a) {
1826
- for (var b, c = 1; c < arguments.length; c++) {
1827
- for (var d in b = arguments[c], b) {
1828
- Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1829
- }
1814
+ var NAME$8 = 'FormCreate';
1815
+ var getRuleInject = function getRuleInject(vm, parent) {
1816
+ if (!vm || vm === parent) {
1817
+ return;
1818
+ }
1819
+ if (vm.formCreateInject) {
1820
+ return vm.formCreateInject;
1821
+ }
1822
+ if (vm.$parent) {
1823
+ return getRuleInject(vm.$parent, parent);
1830
1824
  }
1831
-
1832
- return a;
1833
1825
  };
1834
-
1835
- function extend() {
1836
- return _extends$1.apply(this, arguments);
1837
- }
1838
-
1839
- var NAME$8 = 'FormCreate';
1840
1826
  function $FormCreate(FormCreate) {
1841
1827
  return {
1842
1828
  name: NAME$8,
@@ -1867,7 +1853,13 @@
1867
1853
  },
1868
1854
  extendOption: Boolean,
1869
1855
  value: Object,
1870
- api: Object
1856
+ api: Object,
1857
+ name: String,
1858
+ subForm: {
1859
+ type: Boolean,
1860
+ "default": true
1861
+ },
1862
+ inFor: Boolean
1871
1863
  },
1872
1864
  data: function data() {
1873
1865
  return {
@@ -1879,7 +1871,8 @@
1879
1871
  unique: 1,
1880
1872
  renderRule: _toConsumableArray(this.rule || []),
1881
1873
  ctxInject: {},
1882
- updateValue: ''
1874
+ updateValue: JSON.stringify(this.value || {}),
1875
+ isMore: !!this.inFor
1883
1876
  };
1884
1877
  },
1885
1878
  render: function render() {
@@ -1901,8 +1894,8 @@
1901
1894
  watch: {
1902
1895
  value: {
1903
1896
  handler: function handler(n) {
1904
- if (JSON.stringify(n) === this.updateValue) return;
1905
- this.$f.setValue(n);
1897
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1898
+ this.$f.setValue(n || {});
1906
1899
  },
1907
1900
  deep: true
1908
1901
  },
@@ -1915,18 +1908,15 @@
1915
1908
  },
1916
1909
  rule: function rule(n) {
1917
1910
  var _this = this;
1918
-
1919
1911
  if (n.length === this.renderRule.length && n.every(function (v) {
1920
1912
  return _this.renderRule.indexOf(v) > -1;
1921
1913
  })) return;
1922
1914
  this.formCreate.$handle.reloadRule(n);
1923
-
1924
1915
  this._renderRule();
1925
1916
  }
1926
1917
  },
1927
1918
  beforeCreate: function beforeCreate() {
1928
1919
  var _this2 = this;
1929
-
1930
1920
  var _this$$options$propsD = this.$options.propsData,
1931
1921
  rule = _this$$options$propsD.rule,
1932
1922
  option = _this$$options$propsD.option;
@@ -1935,6 +1925,50 @@
1935
1925
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1936
1926
  });
1937
1927
  this.$emit('beforeCreate', this.formCreate.api());
1928
+ },
1929
+ created: function created() {
1930
+ var _this3 = this;
1931
+ var vm = this,
1932
+ fapi = this.formCreate.api();
1933
+ var addSubForm = function addSubForm() {
1934
+ if (vm.$pfc) {
1935
+ var inject = getRuleInject(vm, vm.$pfc);
1936
+ if (inject) {
1937
+ var sub;
1938
+ if (vm.isMore) {
1939
+ sub = toArray(inject.getSubForm());
1940
+ sub.push(fapi);
1941
+ } else {
1942
+ sub = fapi;
1943
+ }
1944
+ inject.subForm(sub);
1945
+ }
1946
+ }
1947
+ };
1948
+ var rmSubForm = function rmSubForm() {
1949
+ var inject = getRuleInject(vm, vm.$pfc);
1950
+ if (inject) {
1951
+ if (vm.isMore) {
1952
+ var sub = toArray(inject.getSubForm());
1953
+ var idx = sub.indexOf(fapi);
1954
+ if (idx > -1) {
1955
+ sub.splice(idx, 1);
1956
+ }
1957
+ } else {
1958
+ inject.subForm();
1959
+ }
1960
+ }
1961
+ };
1962
+ vm.$on('hook:beforeDestroy', function () {
1963
+ rmSubForm();
1964
+ });
1965
+ this.$watch(function () {
1966
+ return _this3.subForm;
1967
+ }, function (n) {
1968
+ n ? addSubForm() : rmSubForm();
1969
+ }, {
1970
+ immediate: true
1971
+ });
1938
1972
  }
1939
1973
  };
1940
1974
  }
@@ -1942,17 +1976,12 @@
1942
1976
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
1943
1977
  var toArrayMerge$1 = ['class', 'style', 'directives'];
1944
1978
  var functionalMerge$1 = ['on', 'nativeOn'];
1945
-
1946
1979
  var mergeProps = function mergeProps(objects) {
1947
1980
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1948
1981
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1949
-
1950
1982
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
1951
-
1952
1983
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
1953
-
1954
1984
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
1955
-
1956
1985
  var propsMerge = opt['props'] || [];
1957
1986
  return objects.reduce(function (a, b) {
1958
1987
  for (var key in b) {
@@ -1969,9 +1998,7 @@
1969
1998
  for (var event in b[key]) {
1970
1999
  if (a[key][event]) {
1971
2000
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
1972
-
1973
2001
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
1974
-
1975
2002
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
1976
2003
  } else {
1977
2004
  a[key][event] = b[key][event];
@@ -1996,11 +2023,9 @@
1996
2023
  } else a[key] = b[key];
1997
2024
  }
1998
2025
  }
1999
-
2000
2026
  return a;
2001
2027
  }, initial);
2002
2028
  };
2003
-
2004
2029
  var mergeFn$1 = function mergeFn(fn1, fn2) {
2005
2030
  return function () {
2006
2031
  fn1 && fn1.apply(this, arguments);
@@ -2008,7 +2033,7 @@
2008
2033
  };
2009
2034
  };
2010
2035
 
2011
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2036
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
2012
2037
  var arrayAttrs = ['validate', 'children', 'control'];
2013
2038
  var normalAttrs = ['effect', 'deep'];
2014
2039
  function attrs() {
@@ -2029,60 +2054,6 @@
2029
2054
  console.error(e);
2030
2055
  }
2031
2056
 
2032
- function deepExtend(origin) {
2033
- var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2034
- var mode = arguments.length > 2 ? arguments[2] : undefined;
2035
- var isArr = false;
2036
-
2037
- for (var key in target) {
2038
- if (Object.prototype.hasOwnProperty.call(target, key)) {
2039
- var clone = target[key];
2040
-
2041
- if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
2042
- var nst = origin[key] === undefined;
2043
-
2044
- if (isArr) {
2045
- isArr = false;
2046
- nst && $set(origin, key, []);
2047
- } else if (clone._clone && mode !== undefined) {
2048
- if (mode) {
2049
- clone = clone.getRule();
2050
- nst && $set(origin, key, {});
2051
- } else {
2052
- $set(origin, key, clone._clone());
2053
- continue;
2054
- }
2055
- } else {
2056
- nst && $set(origin, key, {});
2057
- }
2058
-
2059
- origin[key] = deepExtend(origin[key], clone, mode);
2060
- } else {
2061
- $set(origin, key, clone);
2062
-
2063
- if (!is.Undef(clone)) {
2064
- if (!is.Undef(clone.__json)) {
2065
- origin[key].__json = clone.__json;
2066
- }
2067
-
2068
- if (!is.Undef(clone.__origin)) {
2069
- origin[key].__origin = clone.__origin;
2070
- }
2071
- }
2072
- }
2073
- }
2074
- }
2075
-
2076
- return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
2077
- return !v || !v.__ctrl;
2078
- }) : origin;
2079
- }
2080
- function deepCopy(value) {
2081
- return deepExtend({}, {
2082
- value: value
2083
- }).value;
2084
- }
2085
-
2086
2057
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2087
2058
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2088
2059
  var $T = '$FN:';
@@ -2091,30 +2062,24 @@
2091
2062
  function toJson(obj, space) {
2092
2063
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2093
2064
  if (val && val._isVue === true) return undefined;
2094
-
2095
2065
  if (_typeof(val) !== FUNCTION) {
2096
2066
  return val;
2097
2067
  }
2098
-
2099
2068
  if (val.__json) {
2100
2069
  return val.__json;
2101
2070
  }
2102
-
2103
2071
  if (val.__origin) val = val.__origin;
2104
2072
  if (val.__emit) return undefined;
2105
2073
  return PREFIX + val + SUFFIX;
2106
2074
  }, space);
2107
2075
  }
2108
-
2109
2076
  function makeFn(fn) {
2110
2077
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2111
2078
  }
2112
-
2113
2079
  function parseFn(fn, mode) {
2114
2080
  if (fn && is.String(fn) && fn.length > 4) {
2115
2081
  var v = fn.trim();
2116
2082
  var flag = false;
2117
-
2118
2083
  try {
2119
2084
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2120
2085
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2130,7 +2095,6 @@
2130
2095
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2131
2096
  flag = true;
2132
2097
  }
2133
-
2134
2098
  if (!flag) return fn;
2135
2099
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2136
2100
  val.__json = fn;
@@ -2140,7 +2104,6 @@
2140
2104
  return undefined;
2141
2105
  }
2142
2106
  }
2143
-
2144
2107
  return fn;
2145
2108
  }
2146
2109
  function parseJson(json, mode) {
@@ -2157,8 +2120,7 @@
2157
2120
  configurable: false,
2158
2121
  writable: !!writable
2159
2122
  };
2160
- } //todo 优化位置
2161
-
2123
+ }
2162
2124
  function copyRule(rule) {
2163
2125
  return copyRules([rule])[0];
2164
2126
  }
@@ -2203,7 +2165,6 @@
2203
2165
  } catch (e) {
2204
2166
  logError(e);
2205
2167
  }
2206
-
2207
2168
  return def;
2208
2169
  }
2209
2170
 
@@ -2222,11 +2183,9 @@
2222
2183
  return function (title, field, value) {
2223
2184
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2224
2185
  var maker = new Creator(name, title, field, value, props);
2225
-
2226
2186
  if (init) {
2227
2187
  if (is.Function(init)) init(maker);else maker.props(init);
2228
2188
  }
2229
-
2230
2189
  return maker;
2231
2190
  };
2232
2191
  }
@@ -2291,13 +2250,11 @@
2291
2250
  function copy(value) {
2292
2251
  return deepCopy(value);
2293
2252
  }
2294
-
2295
2253
  function Api(h) {
2296
2254
  function tidyFields(fields) {
2297
2255
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2298
2256
  return fields;
2299
2257
  }
2300
-
2301
2258
  function props(fields, key, val) {
2302
2259
  tidyFields(fields).forEach(function (field) {
2303
2260
  h.getCtxs(field).forEach(function (ctx) {
@@ -2306,7 +2263,6 @@
2306
2263
  });
2307
2264
  });
2308
2265
  }
2309
-
2310
2266
  function allSubForm() {
2311
2267
  var subs = h.subForm;
2312
2268
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2316,39 +2272,32 @@
2316
2272
  return initial;
2317
2273
  }, []);
2318
2274
  }
2319
-
2320
2275
  var api = {
2321
2276
  get config() {
2322
2277
  return h.options;
2323
2278
  },
2324
-
2325
2279
  get options() {
2326
2280
  return h.options;
2327
2281
  },
2328
-
2329
2282
  get form() {
2330
2283
  return h.form;
2331
2284
  },
2332
-
2333
2285
  get rule() {
2334
2286
  return h.rules;
2335
2287
  },
2336
-
2337
2288
  get parent() {
2338
2289
  return h.vm.$pfc && h.vm.$pfc.$f;
2339
2290
  },
2340
-
2341
2291
  get children() {
2342
2292
  return allSubForm();
2343
2293
  },
2344
-
2345
2294
  formData: function formData(fields) {
2346
2295
  return tidyFields(fields).reduce(function (initial, id) {
2347
2296
  var ctx = h.getFieldCtx(id);
2348
2297
  if (!ctx) return initial;
2349
2298
  initial[ctx.field] = copy(ctx.rule.value);
2350
2299
  return initial;
2351
- }, copy(h.appendData));
2300
+ }, h.options.appendValue ? copy(h.appendData) : {});
2352
2301
  },
2353
2302
  getValue: function getValue(field) {
2354
2303
  var ctx = h.getFieldCtx(field);
@@ -2406,7 +2355,6 @@
2406
2355
  var index = h.sort.length - 1,
2407
2356
  rules;
2408
2357
  var ctx = h.getCtx(after);
2409
-
2410
2358
  if (ctx) {
2411
2359
  if (child) {
2412
2360
  rules = ctx.rule.children;
@@ -2416,14 +2364,12 @@
2416
2364
  rules = ctx.root;
2417
2365
  }
2418
2366
  } else rules = h.rules;
2419
-
2420
2367
  rules.splice(index + 1, 0, rule);
2421
2368
  },
2422
2369
  prepend: function prepend(rule, after, child) {
2423
2370
  var index = 0,
2424
2371
  rules;
2425
2372
  var ctx = h.getCtx(after);
2426
-
2427
2373
  if (ctx) {
2428
2374
  if (child) {
2429
2375
  rules = ctx.rule.children;
@@ -2432,7 +2378,6 @@
2432
2378
  rules = ctx.root;
2433
2379
  }
2434
2380
  } else rules = h.rules;
2435
-
2436
2381
  rules.splice(index, 0, rule);
2437
2382
  },
2438
2383
  hidden: function hidden(state, fields) {
@@ -2456,7 +2401,7 @@
2456
2401
  disabled: function disabled(_disabled, fields) {
2457
2402
  tidyFields(fields).forEach(function (field) {
2458
2403
  h.getCtxs(field).forEach(function (ctx) {
2459
- $set(ctx.rule.props, 'disabled', !!_disabled);
2404
+ ctx.rule.props && $set(ctx.rule.props, 'disabled', !!_disabled);
2460
2405
  });
2461
2406
  });
2462
2407
  h.refresh();
@@ -2505,18 +2450,14 @@
2505
2450
  });
2506
2451
  return;
2507
2452
  }
2508
-
2509
2453
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2510
-
2511
2454
  if (!ctxs) {
2512
2455
  return;
2513
2456
  }
2514
-
2515
2457
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2516
2458
  ctxs.forEach(function (ctx) {
2517
2459
  if (!ctx.deleted) {
2518
2460
  var subForm = h.subForm[ctx.id];
2519
-
2520
2461
  if (subForm) {
2521
2462
  if (Array.isArray(subForm)) {
2522
2463
  subForm.forEach(function (form) {
@@ -2525,9 +2466,7 @@
2525
2466
  } else if (subForm) {
2526
2467
  subForm.refresh();
2527
2468
  }
2528
- } //ctx.updateKey(true);
2529
-
2530
-
2469
+ }
2531
2470
  h.$render.clearCache(ctx);
2532
2471
  }
2533
2472
  });
@@ -2575,11 +2514,25 @@
2575
2514
  },
2576
2515
  getRule: function getRule(id, origin) {
2577
2516
  var ctx = h.getCtx(id);
2578
-
2579
2517
  if (ctx) {
2580
2518
  return origin ? ctx.origin : ctx.rule;
2581
2519
  }
2582
2520
  },
2521
+ setEffect: function setEffect(id, attr, value) {
2522
+ var ctx = h.getCtx(id);
2523
+ if (ctx && attr) {
2524
+ if (attr[0] === '$') {
2525
+ attr = attr.substr(1);
2526
+ }
2527
+ if (hasProperty(ctx.rule, '$' + attr)) {
2528
+ $set(ctx.rule, '$' + attr, value);
2529
+ }
2530
+ if (!hasProperty(ctx.rule, 'effect')) {
2531
+ ctx.rule.effect = {};
2532
+ }
2533
+ $set(ctx.rule.effect, attr, value);
2534
+ }
2535
+ },
2583
2536
  updateValidate: function updateValidate(id, validate, merge) {
2584
2537
  if (merge) {
2585
2538
  api.mergeRule(id, {
@@ -2618,7 +2571,6 @@
2618
2571
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2619
2572
  args[_key - 2] = arguments[_key];
2620
2573
  }
2621
-
2622
2574
  return invoke(function () {
2623
2575
  return api.method(id, name).apply(void 0, args);
2624
2576
  });
@@ -2628,11 +2580,9 @@
2628
2580
  },
2629
2581
  trigger: function trigger(id, event) {
2630
2582
  var el = api.el(id);
2631
-
2632
2583
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2633
2584
  args[_key2 - 2] = arguments[_key2];
2634
2585
  }
2635
-
2636
2586
  el && el.$emit.apply(el, [event].concat(args));
2637
2587
  },
2638
2588
  el: function el(id) {
@@ -2657,11 +2607,9 @@
2657
2607
  },
2658
2608
  emit: function emit(name) {
2659
2609
  var _h$vm;
2660
-
2661
2610
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2662
2611
  args[_key3 - 1] = arguments[_key3];
2663
2612
  }
2664
-
2665
2613
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2666
2614
  },
2667
2615
  helper: {
@@ -2672,7 +2620,6 @@
2672
2620
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2673
2621
  api[n] = function () {
2674
2622
  var _h$vm2;
2675
-
2676
2623
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2677
2624
  };
2678
2625
  });
@@ -2690,11 +2637,9 @@
2690
2637
  ctx.parent && this.clearCache(ctx.parent);
2691
2638
  return;
2692
2639
  }
2693
-
2694
2640
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2695
2641
  this.$handle.refresh();
2696
2642
  }
2697
-
2698
2643
  var parent = this.cache[ctx.id].parent;
2699
2644
  this.cache[ctx.id] = null;
2700
2645
  parent && this.clearCache(parent);
@@ -2751,10 +2696,8 @@
2751
2696
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2752
2697
  _data[to] = {};
2753
2698
  }
2754
-
2755
2699
  _data = _data[to];
2756
2700
  }
2757
-
2758
2701
  to = v;
2759
2702
  });
2760
2703
  _data[to] = val;
@@ -2774,7 +2717,6 @@
2774
2717
  var children = ctxs[id].rule.children;
2775
2718
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2776
2719
  }
2777
-
2778
2720
  return initial;
2779
2721
  }, {});
2780
2722
  },
@@ -2783,59 +2725,46 @@
2783
2725
  },
2784
2726
  getTypeSlot: function getTypeSlot(type) {
2785
2727
  var name = 'type-' + toLine(type);
2786
-
2787
2728
  var _fn = function _fn(vm) {
2788
2729
  if (vm) {
2789
2730
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2790
-
2791
2731
  if (slot) {
2792
2732
  return slot;
2793
2733
  }
2794
-
2795
2734
  return _fn(vm.$pfc);
2796
2735
  }
2797
2736
  };
2798
-
2799
2737
  return _fn(this.vm);
2800
2738
  },
2801
2739
  render: function render() {
2802
2740
  var _this = this;
2803
-
2804
2741
  if (!this.vm.isShow) {
2805
2742
  return;
2806
2743
  }
2807
-
2808
2744
  this.$h = this.vm.$createElement;
2809
2745
  this.$manager.beforeRender();
2810
2746
  var vn;
2811
-
2812
2747
  var make = function make() {
2813
2748
  return _this.renderList();
2814
2749
  };
2815
-
2816
2750
  make.renderSlot = function (slot) {
2817
2751
  return _this.renderList(slot);
2818
2752
  };
2819
-
2820
2753
  make.renderName = function (name) {
2821
2754
  return _this.renderId(name);
2822
2755
  };
2823
-
2824
2756
  make.renderField = function (field) {
2825
2757
  return _this.renderId(field, 'field');
2826
2758
  };
2827
-
2828
2759
  if (this.vm.$scopedSlots.container) {
2829
2760
  vn = [this.vm.$scopedSlots.container(make)];
2830
2761
  } else {
2831
2762
  vn = make();
2832
2763
  }
2833
-
2834
2764
  return this.$manager.render(vn);
2835
2765
  },
2836
2766
  renderList: function renderList(slot) {
2837
2767
  var _this2 = this;
2838
-
2839
2768
  return this.sort.map(function (id) {
2840
2769
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2841
2770
  }).filter(function (val) {
@@ -2844,7 +2773,6 @@
2844
2773
  },
2845
2774
  makeVm: function makeVm(rule) {
2846
2775
  var _this3 = this;
2847
-
2848
2776
  var vm = rule.vm;
2849
2777
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2850
2778
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2853,8 +2781,7 @@
2853
2781
  },
2854
2782
  mergeGlobal: function mergeGlobal(ctx) {
2855
2783
  var g = this.$handle.options.global;
2856
- if (!g) return; //todo 缓存配置,更新 option 更新
2857
-
2784
+ if (!g) return;
2858
2785
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2859
2786
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2860
2787
  },
@@ -2881,23 +2808,19 @@
2881
2808
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2882
2809
  });
2883
2810
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2884
-
2885
2811
  if (keys.indexOf(key) > -1) {
2886
2812
  vm.$props[key] = prop.value;
2887
2813
  }
2888
2814
  },
2889
2815
  renderTemp: function renderTemp(ctx) {
2890
2816
  var _this4 = this;
2891
-
2892
2817
  if (!_vue.compile) {
2893
2818
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2894
2819
  return [];
2895
2820
  }
2896
-
2897
2821
  var rule = ctx.prop;
2898
2822
  var id = ctx.id,
2899
2823
  key = ctx.key;
2900
-
2901
2824
  if (!this.tempList[id]) {
2902
2825
  if (!ctx.el) {
2903
2826
  ctx.el = this.makeVm(rule);
@@ -2905,7 +2828,6 @@
2905
2828
  return ctx.parser.mounted(ctx);
2906
2829
  });
2907
2830
  }
2908
-
2909
2831
  var _vm = ctx.el;
2910
2832
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2911
2833
  _this4.onInput(ctx, value);
@@ -2915,7 +2837,6 @@
2915
2837
  template: _vue.compile(rule.template)
2916
2838
  };
2917
2839
  }
2918
-
2919
2840
  var _this$tempList$id = this.tempList[id],
2920
2841
  vm = _this$tempList$id.vm,
2921
2842
  template = _this$tempList$id.template;
@@ -2939,7 +2860,6 @@
2939
2860
  },
2940
2861
  renderId: function renderId(name, type) {
2941
2862
  var _this5 = this;
2942
-
2943
2863
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2944
2864
  return ctxs ? ctxs.map(function (ctx) {
2945
2865
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2948,21 +2868,16 @@
2948
2868
  renderCtx: function renderCtx(ctx, parent) {
2949
2869
  if (ctx.type === 'hidden') return;
2950
2870
  var rule = ctx.rule;
2951
- var preview = this.options.preview || false;
2952
-
2953
2871
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2954
2872
  var vn;
2955
- var cacheFlag = true;
2873
+ var cacheFlag = rule.cache !== false;
2956
2874
  var _type = ctx.trueType;
2957
2875
  var none = !(is.Undef(rule.display) || !!rule.display);
2958
-
2959
2876
  if (_type === 'template' && !rule.template) {
2960
2877
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2961
-
2962
2878
  if (none) {
2963
2879
  this.display(vn);
2964
2880
  }
2965
-
2966
2881
  vn = this.item(ctx, vn);
2967
2882
  } else if (_type === 'fcFragment') {
2968
2883
  vn = this.renderChildren(ctx);
@@ -2974,27 +2889,24 @@
2974
2889
  this.setOptions(ctx);
2975
2890
  this.ctxProp(ctx);
2976
2891
  var prop = ctx.prop;
2892
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
2977
2893
  prop.props.formCreateInject = this.injectProp(ctx);
2978
-
2894
+ var preview = prop.preview;
2979
2895
  if (prop.hidden) {
2980
2896
  this.setCache(ctx, undefined, parent);
2981
2897
  return;
2982
2898
  }
2983
-
2984
2899
  if (_type === 'template' && prop.template) {
2985
2900
  vn = this.renderTemp(ctx);
2986
2901
  cacheFlag = false;
2987
2902
  } else {
2988
2903
  var children = [];
2989
-
2990
2904
  if (ctx.parser.renderChildren) {
2991
2905
  children = ctx.parser.renderChildren(ctx);
2992
2906
  } else if (ctx.parser.loadChildren !== false) {
2993
2907
  children = this.renderChildren(ctx);
2994
2908
  }
2995
-
2996
2909
  var slot = this.getTypeSlot(ctx.type);
2997
-
2998
2910
  if (slot) {
2999
2911
  vn = slot({
3000
2912
  rule: rule,
@@ -3008,32 +2920,24 @@
3008
2920
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3009
2921
  }
3010
2922
  }
3011
-
3012
2923
  vn = this.renderSides(vn, ctx);
3013
-
3014
2924
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3015
2925
  vn = this.$manager.makeWrap(ctx, vn);
3016
2926
  }
3017
-
3018
2927
  if (none) {
3019
2928
  vn = this.display(vn);
3020
2929
  }
3021
-
3022
2930
  vn = this.item(ctx, vn);
3023
2931
  }
3024
-
3025
2932
  if (cacheFlag) {
3026
2933
  this.setCache(ctx, vn, parent);
3027
2934
  }
3028
-
3029
2935
  return vn;
3030
2936
  }
3031
-
3032
2937
  return this.getCache(ctx);
3033
2938
  },
3034
2939
  display: function display(vn) {
3035
2940
  var _this6 = this;
3036
-
3037
2941
  if (Array.isArray(vn)) {
3038
2942
  var data = [];
3039
2943
  vn.forEach(function (v) {
@@ -3056,7 +2960,6 @@
3056
2960
  display: 'none'
3057
2961
  }];
3058
2962
  }
3059
-
3060
2963
  return vn;
3061
2964
  }
3062
2965
  },
@@ -3068,7 +2971,6 @@
3068
2971
  },
3069
2972
  injectProp: function injectProp(ctx) {
3070
2973
  var _this7 = this;
3071
-
3072
2974
  if (!this.vm.ctxInject[ctx.id]) {
3073
2975
  $set(this.vm.ctxInject, ctx.id, {
3074
2976
  api: this.$handle.api,
@@ -3076,23 +2978,25 @@
3076
2978
  subForm: function subForm(_subForm) {
3077
2979
  _this7.$handle.addSubForm(ctx, _subForm);
3078
2980
  },
2981
+ getSubForm: function getSubForm() {
2982
+ return _this7.$handle.subForm[ctx.id];
2983
+ },
3079
2984
  options: [],
3080
2985
  children: [],
3081
2986
  prop: {},
3082
2987
  preview: false,
3083
2988
  field: ctx.field,
3084
- rule: ctx.rule
2989
+ rule: ctx.rule,
2990
+ input: ctx.input
3085
2991
  });
3086
2992
  }
3087
-
3088
2993
  var inject = this.vm.ctxInject[ctx.id];
3089
2994
  extend(inject, {
3090
- preview: this.options.preview || false,
2995
+ preview: ctx.prop.preview,
3091
2996
  options: ctx.prop.options,
3092
2997
  children: ctx.rule.children,
3093
2998
  prop: function () {
3094
2999
  var temp = _objectSpread2({}, ctx.prop);
3095
-
3096
3000
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3097
3001
  delete temp.model;
3098
3002
  return temp;
@@ -3102,7 +3006,6 @@
3102
3006
  },
3103
3007
  ctxProp: function ctxProp(ctx, custom) {
3104
3008
  var _this8 = this;
3105
-
3106
3009
  var ref = ctx.ref,
3107
3010
  key = ctx.key,
3108
3011
  rule = ctx.rule;
@@ -3121,29 +3024,23 @@
3121
3024
  }
3122
3025
  }
3123
3026
  }];
3124
-
3125
3027
  if (!custom && ctx.input) {
3126
- props.push({
3127
- model: {
3128
- value: this.$handle.getFormData(ctx),
3129
- callback: function callback(value) {
3130
- _this8.onInput(ctx, value);
3131
- },
3132
- expression: "formData.".concat(ctx.id)
3133
- }
3134
- });
3028
+ ctx.prop.model = {
3029
+ value: this.$handle.getFormData(ctx),
3030
+ callback: function callback(value) {
3031
+ _this8.onInput(ctx, value);
3032
+ },
3033
+ expression: "formData.".concat(ctx.id)
3034
+ };
3135
3035
  }
3136
-
3137
3036
  mergeProps(props, ctx.prop);
3138
3037
  return ctx.prop;
3139
3038
  },
3140
3039
  onMounted: function onMounted(ctx) {
3141
3040
  ctx.el = this.vm.$refs[ctx.ref];
3142
-
3143
3041
  if (ctx.el) {
3144
3042
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3145
3043
  }
3146
-
3147
3044
  ctx.parser.mounted(ctx);
3148
3045
  this.$handle.effect(ctx, 'mounted');
3149
3046
  },
@@ -3152,19 +3049,15 @@
3152
3049
  },
3153
3050
  renderChildren: function renderChildren(ctx) {
3154
3051
  var _this9 = this;
3155
-
3156
3052
  var children = ctx.rule.children,
3157
3053
  orgChildren = this.orgChildren[ctx.id];
3158
-
3159
3054
  var isRm = function isRm(child) {
3160
3055
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3161
3056
  };
3162
-
3163
3057
  if (!is.trueArray(children) && orgChildren) {
3164
3058
  this.$handle.deferSyncValue(function () {
3165
3059
  orgChildren.forEach(function (child) {
3166
3060
  if (!child) return;
3167
-
3168
3061
  if (isRm(child)) {
3169
3062
  _this9.$handle.rmCtx(child.__fc__);
3170
3063
  }
@@ -3173,11 +3066,9 @@
3173
3066
  this.orgChildren[ctx.id] = [];
3174
3067
  return [];
3175
3068
  }
3176
-
3177
3069
  orgChildren && this.$handle.deferSyncValue(function () {
3178
3070
  orgChildren.forEach(function (child) {
3179
3071
  if (!child) return;
3180
-
3181
3072
  if (children.indexOf(child) === -1 && isRm(child)) {
3182
3073
  _this9.$handle.rmCtx(child.__fc__);
3183
3074
  }
@@ -3186,15 +3077,12 @@
3186
3077
  return children.map(function (child) {
3187
3078
  if (!child) return;
3188
3079
  if (is.String(child)) return child;
3189
-
3190
3080
  if (child.__fc__) {
3191
3081
  return _this9.renderCtx(child.__fc__, ctx);
3192
3082
  }
3193
-
3194
3083
  if (child.type) {
3195
3084
  _this9.vm.$nextTick(function () {
3196
3085
  _this9.$handle.loadChildren(children, ctx);
3197
-
3198
3086
  _this9.$handle.refresh();
3199
3087
  });
3200
3088
  }
@@ -3202,38 +3090,33 @@
3202
3090
  },
3203
3091
  defaultRender: function defaultRender(ctx, children) {
3204
3092
  var prop = ctx.prop;
3093
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3205
3094
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3206
3095
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3207
3096
  return this.vNode.make(lower(ctx.originType), prop, children);
3208
3097
  },
3209
3098
  renderRule: function renderRule(rule, children, origin) {
3210
3099
  var _this10 = this;
3211
-
3212
3100
  if (!rule) return undefined;
3213
3101
  if (is.String(rule)) return rule;
3214
3102
  var type;
3215
-
3216
3103
  if (origin) {
3217
3104
  type = rule.type;
3218
3105
  } else {
3219
3106
  type = rule.is;
3220
-
3221
3107
  if (rule.type) {
3222
3108
  type = toCase(rule.type);
3223
3109
  var alias = this.vNode.aliasMap[type];
3224
3110
  if (alias) type = toCase(alias);
3225
3111
  }
3226
3112
  }
3227
-
3228
3113
  if (!type) return undefined;
3229
3114
  var data = [[children]];
3230
-
3231
3115
  if (is.trueArray(rule.children)) {
3232
3116
  data.push(rule.children.map(function (v) {
3233
3117
  return _this10.renderRule(v);
3234
3118
  }));
3235
3119
  }
3236
-
3237
3120
  return this.$h(type, _objectSpread2({}, rule), data);
3238
3121
  }
3239
3122
  });
@@ -3269,10 +3152,8 @@
3269
3152
  },
3270
3153
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3271
3154
  var _this = this;
3272
-
3273
3155
  Object.keys(data).forEach(function (k) {
3274
3156
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3275
-
3276
3157
  if (fn) {
3277
3158
  data[k] = fn;
3278
3159
  }
@@ -3286,7 +3167,6 @@
3286
3167
  return this.parseEventLst(rule, fn, inject, true);
3287
3168
  } else if (is.String(fn)) {
3288
3169
  var val = parseFn(fn);
3289
-
3290
3170
  if (val && fn !== val) {
3291
3171
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3292
3172
  }
@@ -3294,7 +3174,6 @@
3294
3174
  },
3295
3175
  parseEmit: function parseEmit(ctx, on) {
3296
3176
  var _this2 = this;
3297
-
3298
3177
  var event = {},
3299
3178
  rule = ctx.rule,
3300
3179
  emitPrefix = rule.emitPrefix,
@@ -3302,48 +3181,36 @@
3302
3181
  name = rule.name,
3303
3182
  inject = rule.inject;
3304
3183
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3305
-
3306
3184
  if (is.trueArray(emit)) {
3307
3185
  var emitKey = emitPrefix || field || name;
3308
-
3309
3186
  if (emitKey) {
3310
3187
  if (!on) emitKey = "native-".concat(emitKey);
3311
3188
  emit.forEach(function (eventName) {
3312
3189
  if (!eventName) return;
3313
3190
  var eventInject;
3314
-
3315
3191
  if (is.Object(eventName)) {
3316
3192
  eventInject = eventName.inject;
3317
3193
  eventName = eventName.name;
3318
3194
  }
3319
-
3320
3195
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3321
-
3322
3196
  var fn = function fn() {
3323
3197
  var _this2$vm, _this2$vm2;
3324
-
3325
3198
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3326
3199
  arg[_key] = arguments[_key];
3327
3200
  }
3328
-
3329
3201
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3330
-
3331
3202
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3332
3203
  };
3333
-
3334
3204
  fn.__emit = true;
3335
-
3336
3205
  if (!eventInject && inject === false) {
3337
3206
  event[eventName] = fn;
3338
3207
  } else {
3339
3208
  var _inject = eventInject || inject || _this2.options.injectEvent;
3340
-
3341
3209
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3342
3210
  }
3343
3211
  });
3344
3212
  }
3345
3213
  }
3346
-
3347
3214
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3348
3215
  return event;
3349
3216
  },
@@ -3365,21 +3232,16 @@
3365
3232
  if (this.watching && !this.loading) return _fn;
3366
3233
  _fn = _fn.__origin;
3367
3234
  }
3368
-
3369
3235
  var h = this;
3370
-
3371
3236
  var fn = function fn() {
3372
3237
  var data = h.getInjectData(self, _inject2);
3373
-
3374
3238
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3375
3239
  args[_key2] = arguments[_key2];
3376
3240
  }
3377
-
3378
3241
  data.args = [].concat(args);
3379
3242
  args.unshift(data);
3380
3243
  return _fn.apply(this, args);
3381
3244
  };
3382
-
3383
3245
  fn.__origin = _fn;
3384
3246
  fn.__json = _fn.__json;
3385
3247
  return fn;
@@ -3392,17 +3254,14 @@
3392
3254
  extend(Handler.prototype, {
3393
3255
  usePage: function usePage() {
3394
3256
  var _this = this;
3395
-
3396
3257
  var page = this.options.page;
3397
3258
  if (!page) return;
3398
3259
  var first = 25;
3399
3260
  var limit = getLimit(this.rules);
3400
-
3401
3261
  if (is.Object(page)) {
3402
3262
  if (page.first) first = parseInt(page.first, 10) || first;
3403
3263
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3404
3264
  }
3405
-
3406
3265
  extend(this, {
3407
3266
  first: first,
3408
3267
  limit: limit,
@@ -3415,27 +3274,21 @@
3415
3274
  },
3416
3275
  pageLoad: function pageLoad() {
3417
3276
  var _this2 = this;
3418
-
3419
3277
  var pageFn = function pageFn() {
3420
3278
  if (_this2.pageEnd) {
3421
3279
  _this2.vm.$off(EVENT, pageFn);
3422
-
3423
3280
  _this2.bus.$emit('page-end');
3424
3281
  } else {
3425
3282
  _this2.first += _this2.limit;
3426
3283
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3427
-
3428
3284
  _this2.loadRule();
3429
-
3430
3285
  _this2.refresh();
3431
3286
  }
3432
3287
  };
3433
-
3434
3288
  this.vm.$on(EVENT, pageFn);
3435
3289
  }
3436
3290
  });
3437
3291
  }
3438
-
3439
3292
  function getLimit(rules) {
3440
3293
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3441
3294
  }
@@ -3448,7 +3301,6 @@
3448
3301
  },
3449
3302
  bindNextTick: function bindNextTick(fn) {
3450
3303
  var _this = this;
3451
-
3452
3304
  this.clearNextTick();
3453
3305
  this.nextTick = setTimeout(function () {
3454
3306
  fn();
@@ -3456,7 +3308,6 @@
3456
3308
  }, 10);
3457
3309
  },
3458
3310
  render: function render() {
3459
- // console.warn('%c render', 'color:green');
3460
3311
  ++this.loadedId;
3461
3312
  if (this.vm.unique > 0) return this.$render.render();else {
3462
3313
  this.vm.unique = 1;
@@ -3471,7 +3322,6 @@
3471
3322
  __fc__: enumerable(ctx, true)
3472
3323
  });
3473
3324
  }
3474
-
3475
3325
  function RuleContext(handle, rule) {
3476
3326
  var id = uniqueId();
3477
3327
  extend(this, {
@@ -3505,7 +3355,6 @@
3505
3355
  if (!this.payload[name]) {
3506
3356
  this.payload[name] = {};
3507
3357
  }
3508
-
3509
3358
  return this.payload[name];
3510
3359
  },
3511
3360
  clearEffectData: function clearEffectData(name) {
@@ -3525,9 +3374,7 @@
3525
3374
  },
3526
3375
  initProp: function initProp() {
3527
3376
  var _this = this;
3528
-
3529
3377
  var rule = _objectSpread2({}, this.rule);
3530
-
3531
3378
  delete rule.children;
3532
3379
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3533
3380
  return _this.payload[k];
@@ -3582,31 +3429,22 @@
3582
3429
  },
3583
3430
  rm: function rm() {
3584
3431
  var _this2 = this;
3585
-
3586
3432
  var _rm = function _rm() {
3587
3433
  var index = _this2.root.indexOf(_this2.origin);
3588
-
3589
3434
  if (index > -1) {
3590
3435
  _this2.root.splice(index, 1);
3591
-
3592
3436
  _this2.$handle && _this2.$handle.refresh();
3593
3437
  }
3594
3438
  };
3595
-
3596
3439
  if (this.deleted) {
3597
3440
  _rm();
3598
-
3599
3441
  return;
3600
3442
  }
3601
-
3602
3443
  this.$handle.noWatch(function () {
3603
3444
  _this2.$handle.deferSyncValue(function () {
3604
3445
  _this2.rmCtrl();
3605
-
3606
3446
  _rm();
3607
-
3608
3447
  _this2.$handle.rmCtx(_this2);
3609
-
3610
3448
  extend(_this2, {
3611
3449
  root: []
3612
3450
  });
@@ -3634,7 +3472,6 @@
3634
3472
  extend(Handler.prototype, {
3635
3473
  nextRefresh: function nextRefresh(fn) {
3636
3474
  var _this = this;
3637
-
3638
3475
  var id = this.loadedId;
3639
3476
  this.vm.$nextTick(function () {
3640
3477
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3642,7 +3479,6 @@
3642
3479
  },
3643
3480
  parseRule: function parseRule(_rule) {
3644
3481
  var _this2 = this;
3645
-
3646
3482
  var rule = getRule(_rule);
3647
3483
  Object.defineProperties(rule, {
3648
3484
  __origin__: enumerable(_rule, true)
@@ -3654,20 +3490,16 @@
3654
3490
  if (!item) {
3655
3491
  return;
3656
3492
  }
3657
-
3658
3493
  _this2.loadFn(item, rule);
3659
3494
  });
3660
3495
  this.loadCtrl(rule);
3661
-
3662
3496
  if (rule.update) {
3663
3497
  rule.update = parseFn(rule.update);
3664
3498
  }
3665
-
3666
3499
  return rule;
3667
3500
  },
3668
3501
  loadFn: function loadFn(item, rule) {
3669
3502
  var _this3 = this;
3670
-
3671
3503
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3672
3504
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3673
3505
  });
@@ -3681,48 +3513,35 @@
3681
3513
  },
3682
3514
  syncProp: function syncProp(ctx) {
3683
3515
  var _this4 = this;
3684
-
3685
3516
  var rule = ctx.rule;
3686
3517
  is.trueArray(rule.sync) && mergeProps([{
3687
3518
  on: rule.sync.reduce(function (pre, prop) {
3688
3519
  pre["update:".concat(prop)] = function (val) {
3689
3520
  rule.props[prop] = val;
3690
-
3691
3521
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3692
3522
  };
3693
-
3694
3523
  return pre;
3695
3524
  }, {})
3696
3525
  }], ctx.computed);
3697
3526
  },
3698
3527
  loadRule: function loadRule() {
3699
3528
  var _this5 = this;
3700
-
3701
- // console.warn('%c load', 'color:blue');
3702
3529
  this.cycleLoad = false;
3703
3530
  this.loading = true;
3704
-
3705
3531
  if (this.pageEnd) {
3706
3532
  this.bus.$emit('load-start');
3707
3533
  }
3708
-
3709
3534
  this.deferSyncValue(function () {
3710
3535
  _this5._loadRule(_this5.rules);
3711
-
3712
3536
  _this5.loading = false;
3713
-
3714
3537
  if (_this5.cycleLoad && _this5.pageEnd) {
3715
3538
  return _this5.loadRule();
3716
3539
  }
3717
-
3718
3540
  if (_this5.pageEnd) {
3719
3541
  _this5.bus.$emit('load-end');
3720
3542
  }
3721
-
3722
3543
  _this5.vm._renderRule();
3723
-
3724
3544
  _this5.$render.initOrgChildren();
3725
-
3726
3545
  _this5.syncForm();
3727
3546
  });
3728
3547
  },
@@ -3730,79 +3549,60 @@
3730
3549
  this.cycleLoad = false;
3731
3550
  this.loading = true;
3732
3551
  this.bus.$emit('load-start');
3733
-
3734
3552
  this._loadRule(children, parent);
3735
-
3736
3553
  this.loading = false;
3737
-
3738
3554
  if (this.cycleLoad) {
3739
3555
  return this.loadRule();
3740
3556
  } else {
3741
3557
  this.bus.$emit('load-end');
3742
3558
  this.syncForm();
3743
3559
  }
3744
-
3745
3560
  this.$render.clearCache(parent);
3746
3561
  },
3747
3562
  _loadRule: function _loadRule(rules, parent) {
3748
3563
  var _this6 = this;
3749
-
3750
3564
  var preIndex = function preIndex(i) {
3751
3565
  var pre = rules[i - 1];
3752
-
3753
3566
  if (!pre || !pre.__fc__) {
3754
3567
  return i > 0 ? preIndex(i - 1) : -1;
3755
3568
  }
3756
-
3757
3569
  var index = _this6.sort.indexOf(pre.__fc__.id);
3758
-
3759
3570
  return index > -1 ? index : preIndex(i - 1);
3760
3571
  };
3761
-
3762
3572
  var loadChildren = function loadChildren(children, parent) {
3763
3573
  if (is.trueArray(children)) {
3764
3574
  _this6._loadRule(children, parent);
3765
3575
  }
3766
3576
  };
3767
-
3768
3577
  rules.map(function (_rule, index) {
3769
3578
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3770
3579
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3771
3580
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3772
-
3773
3581
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3774
3582
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3775
3583
  return _rule.__fc__;
3776
3584
  }
3777
-
3778
3585
  var rule = getRule(_rule);
3779
-
3780
3586
  var isRepeat = function isRepeat() {
3781
3587
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3782
3588
  };
3783
-
3784
3589
  _this6.ruleEffect(rule, 'init', {
3785
3590
  repeat: isRepeat()
3786
3591
  });
3787
-
3788
3592
  if (isRepeat()) {
3789
3593
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3790
3594
  }
3791
-
3792
3595
  var ctx;
3793
3596
  var isCopy = false;
3794
3597
  var isInit = !!_rule.__fc__;
3795
-
3796
3598
  if (isInit) {
3797
3599
  ctx = _rule.__fc__;
3798
3600
  var check = !ctx.check(_this6);
3799
-
3800
3601
  if (ctx.deleted) {
3801
3602
  if (check) {
3802
3603
  if (isCtrl(ctx)) {
3803
3604
  return;
3804
3605
  }
3805
-
3806
3606
  ctx.update(_this6);
3807
3607
  }
3808
3608
  } else {
@@ -3810,66 +3610,49 @@
3810
3610
  if (isCtrl(ctx)) {
3811
3611
  return;
3812
3612
  }
3813
-
3814
3613
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3815
3614
  ctx = null;
3816
3615
  isCopy = true;
3817
3616
  }
3818
3617
  }
3819
3618
  }
3820
-
3821
3619
  if (!ctx) {
3822
3620
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3823
-
3824
3621
  _this6.bindParser(ctx);
3825
3622
  } else {
3826
3623
  if (ctx.originType !== ctx.rule.type) {
3827
3624
  ctx.updateType();
3828
-
3829
3625
  _this6.bindParser(ctx);
3830
3626
  }
3831
-
3832
3627
  _this6.appendValue(ctx.rule);
3833
3628
  }
3834
-
3835
3629
  [false, true].forEach(function (b) {
3836
3630
  return _this6.parseEmit(ctx, b);
3837
3631
  });
3838
-
3839
3632
  _this6.syncProp(ctx);
3840
-
3841
3633
  ctx.parent = parent || null;
3842
3634
  ctx.root = rules;
3843
-
3844
3635
  _this6.setCtx(ctx);
3845
-
3846
3636
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3847
3637
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3848
-
3849
3638
  if (!parent) {
3850
3639
  var _preIndex = preIndex(index);
3851
-
3852
3640
  if (_preIndex > -1 || !index) {
3853
3641
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3854
3642
  } else {
3855
3643
  _this6.sort.push(ctx.id);
3856
3644
  }
3857
3645
  }
3858
-
3859
3646
  var r = ctx.rule;
3860
-
3861
3647
  if (!ctx.updated) {
3862
3648
  ctx.updated = true;
3863
-
3864
3649
  if (is.Function(r.update)) {
3865
3650
  _this6.bus.$once('load-end', function () {
3866
3651
  _this6.refreshUpdate(ctx, r.value);
3867
3652
  });
3868
3653
  }
3869
-
3870
3654
  _this6.effect(ctx, 'loaded');
3871
3655
  }
3872
-
3873
3656
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3874
3657
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3875
3658
  return ctx;
@@ -3880,20 +3663,16 @@
3880
3663
  },
3881
3664
  useCtrl: function useCtrl(ctx) {
3882
3665
  var _this7 = this;
3883
-
3884
3666
  var controls = getCtrl(ctx),
3885
3667
  validate = [],
3886
3668
  api = this.api;
3887
3669
  if (!controls.length) return false;
3888
-
3889
3670
  var _loop = function _loop(i) {
3890
3671
  var control = controls[i],
3891
3672
  handleFn = control.handle || function (val) {
3892
3673
  return val === control.value;
3893
3674
  };
3894
-
3895
3675
  if (!is.trueArray(control.rule)) return "continue";
3896
-
3897
3676
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3898
3677
  valid: invoke(function () {
3899
3678
  return handleFn(ctx.rule.value, api);
@@ -3901,17 +3680,13 @@
3901
3680
  ctrl: findCtrl(ctx, control.rule),
3902
3681
  isHidden: is.String(control.rule[0])
3903
3682
  });
3904
-
3905
3683
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3906
3684
  validate.push(data);
3907
3685
  };
3908
-
3909
3686
  for (var i = 0; i < controls.length; i++) {
3910
3687
  var _ret = _loop(i);
3911
-
3912
3688
  if (_ret === "continue") continue;
3913
3689
  }
3914
-
3915
3690
  if (!validate.length) return false;
3916
3691
  var flag = false;
3917
3692
  this.deferSyncValue(function () {
@@ -3923,21 +3698,17 @@
3923
3698
  append = _ref.append,
3924
3699
  child = _ref.child,
3925
3700
  ctrl = _ref.ctrl;
3926
-
3927
3701
  if (isHidden) {
3928
3702
  valid ? ctx.ctrlRule.push({
3929
3703
  __ctrl: true,
3930
3704
  children: rule,
3931
3705
  valid: valid
3932
3706
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3933
-
3934
3707
  _this7.vm.$nextTick(function () {
3935
3708
  _this7.api.hidden(!valid, rule);
3936
3709
  });
3937
-
3938
3710
  return;
3939
3711
  }
3940
-
3941
3712
  if (valid) {
3942
3713
  flag = true;
3943
3714
  var ruleCon = {
@@ -3947,9 +3718,7 @@
3947
3718
  children: rule
3948
3719
  };
3949
3720
  ctx.ctrlRule.push(ruleCon);
3950
-
3951
3721
  _this7.bus.$once('load-start', function () {
3952
- // this.cycleLoad = true;
3953
3722
  if (prepend) {
3954
3723
  api.prepend(ruleCon, prepend, child);
3955
3724
  } else if (append || child) {
@@ -3974,60 +3743,53 @@
3974
3743
  },
3975
3744
  _reloadRule: function _reloadRule(rules) {
3976
3745
  var _this8 = this;
3977
-
3978
- // console.warn('%c reload', 'color:red');
3979
3746
  if (!rules) rules = this.rules;
3980
-
3981
3747
  var ctxs = _objectSpread2({}, this.ctxs);
3982
-
3983
3748
  this.clearNextTick();
3984
3749
  this.$render.clearOrgChildren();
3985
3750
  this.initData(rules);
3986
3751
  this.fc.rules = rules;
3987
- this.bus.$once('load-end', function () {
3988
- Object.keys(ctxs).filter(function (id) {
3989
- return _this8.ctxs[id] === undefined;
3990
- }).forEach(function (id) {
3991
- return _this8.rmCtx(ctxs[id]);
3752
+ this.deferSyncValue(function () {
3753
+ _this8.bus.$once('load-end', function () {
3754
+ Object.keys(ctxs).filter(function (id) {
3755
+ return _this8.ctxs[id] === undefined;
3756
+ }).forEach(function (id) {
3757
+ return _this8.rmCtx(ctxs[id]);
3758
+ });
3759
+ _this8.$render.clearCacheAll();
3992
3760
  });
3993
-
3994
- _this8.$render.clearCacheAll();
3761
+ _this8.reloading = true;
3762
+ _this8.loadRule();
3763
+ _this8.reloading = false;
3764
+ _this8.refresh();
3765
+ _this8.vm.$emit('reload', _this8.api);
3995
3766
  });
3996
- this.reloading = true;
3997
- this.loadRule();
3998
- this.reloading = false;
3999
- this.refresh();
4000
3767
  this.bus.$off('next-tick', this.nextReload);
4001
3768
  this.bus.$once('next-tick', this.nextReload);
4002
3769
  this.vm.$emit('update', this.api);
4003
3770
  },
4004
- //todo 组件生成全部通过 alias
4005
3771
  refresh: function refresh() {
4006
3772
  this.vm._refresh();
4007
3773
  }
4008
3774
  });
4009
3775
  }
4010
-
4011
3776
  function fullRule(rule) {
4012
3777
  var def = baseRule();
4013
3778
  Object.keys(def).forEach(function (k) {
4014
- if (!hasProperty(rule, k)) rule[k] = def[k];
3779
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4015
3780
  });
4016
3781
  return rule;
4017
3782
  }
4018
-
4019
3783
  function getCtrl(ctx) {
4020
3784
  var control = ctx.rule.control || [];
4021
3785
  if (is.Object(control)) return [control];else return control;
4022
3786
  }
4023
-
4024
3787
  function findCtrl(ctx, rule) {
4025
3788
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4026
3789
  var ctrl = ctx.ctrlRule[i];
4027
3790
  if (ctrl.children === rule) return ctrl;
4028
3791
  }
4029
3792
  }
4030
-
4031
3793
  function isCtrl(ctx) {
4032
3794
  return !!ctx.rule.__ctrl;
4033
3795
  }
@@ -4038,7 +3800,6 @@
4038
3800
  if (is.Undef(ctx.cacheValue)) {
4039
3801
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4040
3802
  }
4041
-
4042
3803
  return ctx.cacheValue;
4043
3804
  },
4044
3805
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4050,25 +3811,23 @@
4050
3811
  this.setFormData(ctx, formValue);
4051
3812
  this.syncValue();
4052
3813
  this.valueChange(ctx, value);
4053
- this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag);
3814
+ this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
4054
3815
  this.effect(ctx, 'value');
4055
3816
  },
4056
3817
  onInput: function onInput(ctx, value) {
4057
3818
  var val;
4058
-
4059
3819
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4060
3820
  this.setValue(ctx, val, value);
4061
3821
  }
4062
3822
  },
4063
3823
  setFormData: function setFormData(ctx, value) {
4064
- $set(this.formData, ctx.id, value);
3824
+ $set(this.formData, ctx.id, value === null ? undefined : value);
4065
3825
  },
4066
3826
  getFormData: function getFormData(ctx) {
4067
3827
  return this.formData[ctx.id];
4068
3828
  },
4069
3829
  validate: function validate() {
4070
3830
  var _this = this;
4071
-
4072
3831
  toEmpty(this.vm.validate);
4073
3832
  this.fields().forEach(function (id) {
4074
3833
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4079,17 +3838,14 @@
4079
3838
  },
4080
3839
  syncForm: function syncForm() {
4081
3840
  var _this2 = this;
4082
-
4083
3841
  toEmpty(this.form);
4084
3842
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4085
3843
  var ctx = _this2.getFieldCtx(field);
4086
-
4087
3844
  var handle = _this2.valueHandle(ctx);
4088
-
4089
3845
  handle.configurable = true;
4090
3846
  initial[field] = handle;
4091
3847
  return initial;
4092
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3848
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4093
3849
  initial[field] = {
4094
3850
  enumerable: true,
4095
3851
  configurable: true,
@@ -4101,12 +3857,11 @@
4101
3857
  }
4102
3858
  };
4103
3859
  return initial;
4104
- }, {})));
3860
+ }, {}) : {}));
4105
3861
  this.syncValue();
4106
3862
  },
4107
3863
  valueHandle: function valueHandle(ctx) {
4108
3864
  var _this3 = this;
4109
-
4110
3865
  return {
4111
3866
  enumerable: true,
4112
3867
  get: function get() {
@@ -4125,24 +3880,18 @@
4125
3880
  delete this.appendData[rule.field];
4126
3881
  },
4127
3882
  addSubForm: function addSubForm(ctx, subForm) {
4128
- if (ctx.input) {
4129
- this.subForm[ctx.id] = subForm;
4130
- }
3883
+ this.subForm[ctx.id] = subForm;
4131
3884
  },
4132
3885
  deferSyncValue: function deferSyncValue(fn, sync) {
4133
3886
  if (!this.deferSyncFn) {
4134
3887
  this.deferSyncFn = fn;
4135
3888
  }
4136
-
4137
3889
  if (!this.deferSyncFn.sync) {
4138
3890
  this.deferSyncFn.sync = sync;
4139
3891
  }
4140
-
4141
3892
  invoke(fn);
4142
-
4143
3893
  if (this.deferSyncFn === fn) {
4144
3894
  this.deferSyncFn = null;
4145
-
4146
3895
  if (fn.sync) {
4147
3896
  this.syncValue();
4148
3897
  }
@@ -4152,18 +3901,16 @@
4152
3901
  if (this.deferSyncFn) {
4153
3902
  return this.deferSyncFn.sync = true;
4154
3903
  }
4155
-
4156
3904
  this.vm._updateValue(_objectSpread2({}, this.form));
4157
3905
  },
4158
3906
  isChange: function isChange(ctx, value) {
4159
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3907
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4160
3908
  },
4161
3909
  isQuote: function isQuote(ctx, value) {
4162
3910
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4163
3911
  },
4164
3912
  refreshUpdate: function refreshUpdate(ctx, val) {
4165
3913
  var _this4 = this;
4166
-
4167
3914
  if (is.Function(ctx.rule.update)) {
4168
3915
  var state = invoke(function () {
4169
3916
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4183,20 +3930,16 @@
4183
3930
  this.vm.$emit('update', this.api);
4184
3931
  this.refresh();
4185
3932
  }
4186
-
4187
3933
  this.refreshUpdate(ctx, val);
4188
3934
  },
4189
3935
  appendLink: function appendLink(ctx) {
4190
3936
  var _this5 = this;
4191
-
4192
3937
  var link = ctx.rule.link;
4193
3938
  is.trueArray(link) && link.forEach(function (field) {
4194
3939
  var fn = function fn() {
4195
3940
  return _this5.refreshRule(ctx, ctx.rule.value);
4196
3941
  };
4197
-
4198
3942
  _this5.bus.$on('change-' + field, fn);
4199
-
4200
3943
  ctx.linkOn.push(function () {
4201
3944
  return _this5.bus.$off('change-' + field, fn);
4202
3945
  });
@@ -4207,11 +3950,9 @@
4207
3950
  }
4208
3951
  });
4209
3952
  }
4210
-
4211
3953
  function strFn(key, val) {
4212
3954
  return typeof val === 'function' ? '' + val : val;
4213
3955
  }
4214
-
4215
3956
  function toEmpty(obj) {
4216
3957
  Object.keys(obj).forEach(function (k) {
4217
3958
  return delete obj[k];
@@ -4231,11 +3972,12 @@
4231
3972
  return ctx.$render.defaultRender(ctx, children);
4232
3973
  },
4233
3974
  preview: function preview(children, ctx) {
4234
- return ctx.$render.defaultRender(ctx, children);
3975
+ return this.render(children, ctx);
4235
3976
  },
4236
3977
  mergeProp: function mergeProp(ctx) {}
4237
3978
  };
4238
3979
 
3980
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4239
3981
  function useContext(Handler) {
4240
3982
  extend(Handler.prototype, {
4241
3983
  getCtx: function getCtx(id) {
@@ -4246,7 +3988,6 @@
4246
3988
  },
4247
3989
  setIdCtx: function setIdCtx(ctx, key, type) {
4248
3990
  var field = "".concat(type, "Ctx");
4249
-
4250
3991
  if (!this[field][key]) {
4251
3992
  this[field][key] = [ctx];
4252
3993
  } else {
@@ -4258,11 +3999,9 @@
4258
3999
  var lst = this[field][key];
4259
4000
  if (!lst) return false;
4260
4001
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4261
-
4262
4002
  if (!lst.length) {
4263
4003
  delete this[field][key];
4264
4004
  }
4265
-
4266
4005
  return flag;
4267
4006
  },
4268
4007
  getFieldCtx: function getFieldCtx(field) {
@@ -4281,7 +4020,6 @@
4281
4020
  if (!ctx.input) return;
4282
4021
  this.setIdCtx(ctx, field, 'field');
4283
4022
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4284
-
4285
4023
  if (this.isMounted && !this.reloading) {
4286
4024
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4287
4025
  }
@@ -4302,70 +4040,51 @@
4302
4040
  if (!this.noWatchFn) {
4303
4041
  this.noWatchFn = fn;
4304
4042
  }
4305
-
4306
4043
  invoke(fn);
4307
-
4308
4044
  if (this.noWatchFn === fn) {
4309
4045
  this.noWatchFn = null;
4310
4046
  }
4311
4047
  },
4312
4048
  watchCtx: function watchCtx(ctx) {
4313
4049
  var _this = this;
4314
-
4315
4050
  var vm = this.vm;
4316
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4317
4051
  Object.keys(ctx.rule).filter(function (k) {
4318
- return k[0] !== '_' && none.indexOf(k) === -1;
4052
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4319
4053
  }).forEach(function (key) {
4320
4054
  var flag = key === 'children';
4321
4055
  ctx.watch.push(vm.$watch(function () {
4322
4056
  return ctx.rule[key];
4323
4057
  }, function (n, o) {
4324
4058
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4325
-
4326
4059
  if (flag && ctx.parser.loadChildren === false) {
4327
4060
  _this.$render.clearCache(ctx);
4328
-
4329
4061
  _this.nextRefresh();
4330
-
4331
4062
  return;
4332
4063
  }
4333
-
4334
- _this.watching = true; // if (key === 'hidden')
4335
- // ctx.updateKey(true);
4336
- // else
4337
-
4064
+ _this.watching = true;
4338
4065
  if (key === 'link') {
4339
4066
  ctx.link();
4340
4067
  return;
4341
4068
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4342
4069
  _this.parseInjectEvent(ctx.rule, n || {});
4343
-
4344
4070
  if (key === 'props' && ctx.input) {
4345
4071
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4346
4072
  }
4347
4073
  } else if (['emit', 'nativeEmit'].indexOf(key) > -1) _this.parseEmit(ctx, key === 'emit');else if (['prefix', 'suffix'].indexOf(key) > -1) n && _this.loadFn(n, ctx.rule);else if (key === 'type') {
4348
4074
  ctx.updateType();
4349
-
4350
4075
  _this.bindParser(ctx);
4351
4076
  } else if (key === 'children') {
4352
4077
  var _flag = is.trueArray(n);
4353
-
4354
4078
  _this.deferSyncValue(function () {
4355
4079
  if (n !== o) {
4356
4080
  _this.rmSub(o);
4357
-
4358
4081
  _this.$render.initOrgChildren();
4359
4082
  }
4360
-
4361
4083
  _flag && _this.loadChildren(n, ctx);
4362
-
4363
4084
  _this.vm.$emit('update', _this.api);
4364
4085
  });
4365
4086
  }
4366
-
4367
4087
  _this.$render.clearCache(ctx);
4368
-
4369
4088
  _this.watching = false;
4370
4089
  }, {
4371
4090
  deep: !flag,
@@ -4376,27 +4095,23 @@
4376
4095
  },
4377
4096
  rmSub: function rmSub(sub) {
4378
4097
  var _this2 = this;
4379
-
4380
4098
  is.trueArray(sub) && sub.forEach(function (r) {
4381
4099
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4382
4100
  });
4383
4101
  },
4384
4102
  rmCtx: function rmCtx(ctx) {
4385
4103
  var _this3 = this;
4386
-
4387
4104
  if (ctx.deleted) return;
4388
4105
  var id = ctx.id,
4389
4106
  field = ctx.field,
4390
4107
  input = ctx.input,
4391
4108
  name = ctx.name;
4392
-
4393
4109
  if (ctx.input) {
4394
4110
  Object.defineProperty(ctx.rule, 'value', {
4395
4111
  value: ctx.rule.value,
4396
4112
  writable: true
4397
4113
  });
4398
4114
  }
4399
-
4400
4115
  $del(this.ctxs, id);
4401
4116
  $del(this.$render.tempList, id);
4402
4117
  $del(this.$render.orgChildren, id);
@@ -4404,6 +4119,7 @@
4404
4119
  $del(this.formData, id);
4405
4120
  $del(this.subForm, id);
4406
4121
  $del(ctx, 'cacheValue');
4122
+ input && $del(this.form, field);
4407
4123
  input && this.rmIdCtx(ctx, field, 'field');
4408
4124
  name && this.rmIdCtx(ctx, name, 'name');
4409
4125
  this.deferSyncValue(function () {
@@ -4415,18 +4131,15 @@
4415
4131
  });
4416
4132
  }
4417
4133
  }
4418
-
4419
4134
  if (ctx.root === _this3.rules) {
4420
4135
  _this3.vm._renderRule();
4421
4136
  }
4422
4137
  }
4423
4138
  }, input);
4424
4139
  var index = this.sort.indexOf(id);
4425
-
4426
4140
  if (index > -1) {
4427
4141
  this.sort.splice(index, 1);
4428
4142
  }
4429
-
4430
4143
  this.$render.clearCache(ctx);
4431
4144
  ctx["delete"]();
4432
4145
  this.effect(ctx, 'deleted');
@@ -4441,13 +4154,10 @@
4441
4154
  extend(Handler.prototype, {
4442
4155
  mounted: function mounted() {
4443
4156
  var _this = this;
4444
-
4445
4157
  var _mounted = function _mounted() {
4446
4158
  _this.isMounted = true;
4447
-
4448
4159
  _this.lifecycle('mounted');
4449
4160
  };
4450
-
4451
4161
  if (this.pageEnd) {
4452
4162
  _mounted();
4453
4163
  } else {
@@ -4456,7 +4166,6 @@
4456
4166
  },
4457
4167
  lifecycle: function lifecycle(name) {
4458
4168
  var _this2 = this;
4459
-
4460
4169
  var fn = this.options[name];
4461
4170
  is.Function(fn) && invoke(function () {
4462
4171
  return fn(_this2.api);
@@ -4470,26 +4179,21 @@
4470
4179
  extend(Handler.prototype, {
4471
4180
  useProvider: function useProvider() {
4472
4181
  var _this = this;
4473
-
4474
4182
  var ps = this.fc.providers;
4475
4183
  Object.keys(ps).forEach(function (k) {
4476
4184
  var prop = ps[k];
4477
4185
  prop._c = getComponent(prop);
4478
-
4479
4186
  _this.onEffect(prop);
4480
-
4481
4187
  _this.providers[k] = prop;
4482
4188
  });
4483
4189
  },
4484
4190
  onEffect: function onEffect(provider) {
4485
4191
  var _this2 = this;
4486
-
4487
4192
  var used = [];
4488
4193
  (provider._c || ['*']).forEach(function (name) {
4489
4194
  var type = name === '*' ? '*' : _this2.getType(name);
4490
4195
  if (used.indexOf(type) > -1) return;
4491
4196
  used.push(type);
4492
-
4493
4197
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4494
4198
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4495
4199
  });
@@ -4498,12 +4202,22 @@
4498
4202
  },
4499
4203
  watchEffect: function watchEffect(ctx) {
4500
4204
  var _this3 = this;
4501
-
4502
4205
  var vm = this.vm;
4206
+ var effect = {};
4503
4207
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
4504
- ctx.watch.push(vm.$watch(function () {
4208
+ effect[k] = function () {
4505
4209
  return ctx.rule.effect[k];
4506
- }, function (n) {
4210
+ };
4211
+ });
4212
+ Object.keys(ctx.rule).forEach(function (k) {
4213
+ if (k[0] === '$') {
4214
+ effect[k.substr(1)] = function () {
4215
+ return ctx.rule[k];
4216
+ };
4217
+ }
4218
+ });
4219
+ Object.keys(effect || {}).forEach(function (k) {
4220
+ ctx.watch.push(vm.$watch(effect[k], function (n) {
4507
4221
  _this3.effect(ctx, 'watch', _defineProperty({}, k, n));
4508
4222
  }, {
4509
4223
  deep: true
@@ -4527,24 +4241,30 @@
4527
4241
  }, event);
4528
4242
  },
4529
4243
  getEffect: function getEffect(rule, name) {
4530
- if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];else return undefined;
4244
+ if (hasProperty(rule, '$' + name)) {
4245
+ return rule['$' + name];
4246
+ }
4247
+ if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4248
+ return undefined;
4531
4249
  },
4532
4250
  emitEffect: function emitEffect(_ref, event, append) {
4533
4251
  var _this4 = this;
4534
-
4535
4252
  var ctx = _ref.ctx,
4536
4253
  rule = _ref.rule,
4537
4254
  input = _ref.input,
4538
4255
  type = _ref.type,
4539
4256
  custom = _ref.custom;
4540
4257
  if (!type || type === 'fcFragment') return;
4541
- var effect = custom ? custom : rule.effect || {};
4258
+ var effect = custom ? custom : Object.keys(rule).reduce(function (i, k) {
4259
+ if (k[0] === '$') {
4260
+ i[k.substr(1)] = rule[k];
4261
+ }
4262
+ return i;
4263
+ }, _objectSpread2({}, rule.effect || {}));
4542
4264
  Object.keys(effect).forEach(function (attr) {
4543
4265
  var p = _this4.providers[attr];
4544
4266
  if (!p || p.input && !input) return;
4545
-
4546
4267
  var _type;
4547
-
4548
4268
  if (!p._c) {
4549
4269
  _type = '*';
4550
4270
  } else if (p._used.indexOf(type) > -1) {
@@ -4552,40 +4272,33 @@
4552
4272
  } else {
4553
4273
  return;
4554
4274
  }
4555
-
4556
4275
  var data = _objectSpread2({
4557
4276
  value: effect[attr],
4558
4277
  getValue: function getValue() {
4559
4278
  return _this4.getEffect(rule, attr);
4560
4279
  }
4561
4280
  }, append || {});
4562
-
4563
4281
  if (ctx) {
4564
4282
  data.getProp = function () {
4565
4283
  return ctx.effectData(attr);
4566
4284
  };
4567
-
4568
4285
  data.clearProp = function () {
4569
4286
  return ctx.clearEffectData(attr);
4570
4287
  };
4571
-
4572
4288
  data.mergeProp = function (prop) {
4573
4289
  return mergeProps([prop], data.getProp());
4574
4290
  };
4575
4291
  }
4576
-
4577
4292
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4578
4293
  });
4579
4294
  }
4580
4295
  });
4581
4296
  }
4582
-
4583
4297
  function unique(arr) {
4584
4298
  return arr.filter(function (item, index, arr) {
4585
4299
  return arr.indexOf(item, 0) === index;
4586
4300
  });
4587
4301
  }
4588
-
4589
4302
  function getComponent(p) {
4590
4303
  var c = p.components;
4591
4304
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4595,7 +4308,6 @@
4595
4308
 
4596
4309
  function Handler(fc) {
4597
4310
  var _this = this;
4598
-
4599
4311
  extend(this, {
4600
4312
  fc: fc,
4601
4313
  vm: fc.vm,
@@ -4647,9 +4359,7 @@
4647
4359
  this.useProvider();
4648
4360
  this.usePage();
4649
4361
  this.loadRule();
4650
-
4651
4362
  this.$manager.__init();
4652
-
4653
4363
  this.vm.$set(this.vm, 'formData', this.formData);
4654
4364
  }
4655
4365
  });
@@ -4662,7 +4372,6 @@
4662
4372
  useLifecycle(Handler);
4663
4373
  useEffect(Handler);
4664
4374
 
4665
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4666
4375
  function getError(action, option, xhr) {
4667
4376
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4668
4377
  var err = new Error(msg);
@@ -4670,44 +4379,34 @@
4670
4379
  err.url = action;
4671
4380
  return err;
4672
4381
  }
4673
-
4674
4382
  function getBody(xhr) {
4675
4383
  var text = xhr.responseText || xhr.response;
4676
-
4677
4384
  if (!text) {
4678
4385
  return text;
4679
4386
  }
4680
-
4681
4387
  try {
4682
4388
  return JSON.parse(text);
4683
4389
  } catch (e) {
4684
4390
  return text;
4685
4391
  }
4686
4392
  }
4687
-
4688
4393
  function fetch(option) {
4689
4394
  if (typeof XMLHttpRequest === 'undefined') {
4690
4395
  return;
4691
4396
  }
4692
-
4693
4397
  var xhr = new XMLHttpRequest();
4694
4398
  var action = option.action;
4695
-
4696
4399
  xhr.onerror = function error(e) {
4697
4400
  option.onError(e);
4698
4401
  };
4699
-
4700
4402
  xhr.onload = function onload() {
4701
4403
  if (xhr.status < 200 || xhr.status >= 300) {
4702
4404
  return option.onError(getError(action, option, xhr), getBody(xhr));
4703
4405
  }
4704
-
4705
4406
  option.onSuccess(getBody(xhr));
4706
4407
  };
4707
-
4708
4408
  xhr.open(option.method || 'get', action, true);
4709
4409
  var formData;
4710
-
4711
4410
  if (option.data) {
4712
4411
  if ((option.dataType || '').toLowerCase() !== 'json') {
4713
4412
  formData = new FormData();
@@ -4719,11 +4418,9 @@
4719
4418
  xhr.setRequestHeader('content-type', 'application/json');
4720
4419
  }
4721
4420
  }
4722
-
4723
4421
  if (option.withCredentials && 'withCredentials' in xhr) {
4724
4422
  xhr.withCredentials = true;
4725
4423
  }
4726
-
4727
4424
  var headers = option.headers || {};
4728
4425
  Object.keys(headers).forEach(function (item) {
4729
4426
  if (headers[item] !== null) {
@@ -4751,14 +4448,11 @@
4751
4448
  };
4752
4449
  return prop;
4753
4450
  }
4754
-
4755
4451
  function CreateNodeFactory() {
4756
4452
  var aliasMap = {};
4757
-
4758
4453
  function CreateNode(vm) {
4759
4454
  vm && this.setVm(vm);
4760
4455
  }
4761
-
4762
4456
  extend(CreateNode.prototype, {
4763
4457
  setVm: function setVm(vm) {
4764
4458
  this.vm = vm;
@@ -4766,7 +4460,10 @@
4766
4460
  },
4767
4461
  make: function make(tag, data, children) {
4768
4462
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4769
- var Node = this.$h(tag, parseProp(data), children || []);
4463
+ return this.makeComponent(tag, data, children);
4464
+ },
4465
+ makeComponent: function makeComponent(type, data, children) {
4466
+ var Node = this.$h(type, parseProp(data), children || []);
4770
4467
  Node.context = this.vm;
4771
4468
  return Node;
4772
4469
  },
@@ -4784,7 +4481,6 @@
4784
4481
  var v = nodes[k];
4785
4482
  [k, line, lower].forEach(function (n) {
4786
4483
  CreateNode.alias(k, v);
4787
-
4788
4484
  CreateNode.prototype[n] = function (data, children) {
4789
4485
  return this.make(v, data, children);
4790
4486
  };
@@ -4796,20 +4492,15 @@
4796
4492
  }
4797
4493
 
4798
4494
  function createManager(proto) {
4799
- var CustomManager = /*#__PURE__*/function (_Manager) {
4495
+ var CustomManager = function (_Manager) {
4800
4496
  _inherits(CustomManager, _Manager);
4801
-
4802
4497
  var _super = _createSuper(CustomManager);
4803
-
4804
4498
  function CustomManager() {
4805
4499
  _classCallCheck(this, CustomManager);
4806
-
4807
4500
  return _super.apply(this, arguments);
4808
4501
  }
4809
-
4810
4502
  return CustomManager;
4811
4503
  }(Manager);
4812
-
4813
4504
  Object.assign(CustomManager.prototype, proto);
4814
4505
  return CustomManager;
4815
4506
  }
@@ -4829,19 +4520,15 @@
4829
4520
  extend(Manager.prototype, {
4830
4521
  __init: function __init() {
4831
4522
  var _this = this;
4832
-
4833
4523
  this.$render = this.$handle.$render;
4834
-
4835
4524
  this.$r = function () {
4836
4525
  var _this$$render;
4837
-
4838
4526
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4839
4527
  };
4840
4528
  },
4841
4529
  updateKey: function updateKey() {
4842
4530
  this.key = uniqueId();
4843
4531
  },
4844
- //TODO interface
4845
4532
  init: function init() {},
4846
4533
  update: function update() {},
4847
4534
  beforeRender: function beforeRender() {},
@@ -4850,7 +4537,6 @@
4850
4537
  },
4851
4538
  mergeOptions: function mergeOptions(args, opt) {
4852
4539
  var _this2 = this;
4853
-
4854
4540
  return mergeProps(args.map(function (v) {
4855
4541
  return _this2.tidyOptions(v);
4856
4542
  }), opt, this.mergeOptionsRule);
@@ -4882,7 +4568,45 @@
4882
4568
  }
4883
4569
  }
4884
4570
  };
4885
-
4571
+ var $required = {
4572
+ name: 'required',
4573
+ load: function load(inject, rule, api) {
4574
+ var val = parseVa(inject.getValue());
4575
+ if (val.required === false) {
4576
+ inject.clearProp();
4577
+ } else {
4578
+ var validate = _objectSpread2(_objectSpread2({}, val), {}, {
4579
+ required: true,
4580
+ validator: function validator(_, v, call) {
4581
+ is.empty(v) ? call(validate.message) : call();
4582
+ }
4583
+ });
4584
+ if (!validate.message) {
4585
+ validate.message = rule.title + ' is required';
4586
+ }
4587
+ inject.getProp().validate = [validate];
4588
+ }
4589
+ api.sync(rule);
4590
+ },
4591
+ watch: function watch() {
4592
+ $required.load.apply($required, arguments);
4593
+ }
4594
+ };
4595
+ function parseVa(val) {
4596
+ if (is.Boolean(val)) {
4597
+ return {
4598
+ required: val
4599
+ };
4600
+ } else if (is.String(val)) {
4601
+ return {
4602
+ message: val
4603
+ };
4604
+ } else if (!is.Object(val)) {
4605
+ return {};
4606
+ } else {
4607
+ return val;
4608
+ }
4609
+ }
4886
4610
  function parseOpt(option) {
4887
4611
  if (is.String(option)) {
4888
4612
  option = {
@@ -4890,29 +4614,21 @@
4890
4614
  to: 'options'
4891
4615
  };
4892
4616
  }
4893
-
4894
4617
  return option;
4895
4618
  }
4896
-
4897
4619
  function run(inject, rule, api) {
4898
4620
  var option = inject.value;
4899
-
4900
4621
  if (is.Function(option)) {
4901
4622
  option = option(rule, api);
4902
4623
  }
4903
-
4904
4624
  option = parseOpt(option);
4905
-
4906
4625
  if (!option || !option.action) {
4907
4626
  return false;
4908
4627
  }
4909
-
4910
4628
  if (!option.to) {
4911
4629
  option.to = 'options';
4912
4630
  }
4913
-
4914
4631
  var _onError = option.onError;
4915
-
4916
4632
  var check = function check() {
4917
4633
  if (!inject.getValue()) {
4918
4634
  inject.clearProp();
@@ -4920,7 +4636,6 @@
4920
4636
  return true;
4921
4637
  }
4922
4638
  };
4923
-
4924
4639
  var set = function set(val) {
4925
4640
  if (val === undefined) {
4926
4641
  inject.clearProp();
@@ -4929,7 +4644,6 @@
4929
4644
  deepSet(inject.getProp(), option.to, val);
4930
4645
  }
4931
4646
  };
4932
-
4933
4647
  invoke(function () {
4934
4648
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
4935
4649
  onSuccess: function onSuccess(body) {
@@ -4942,7 +4656,6 @@
4942
4656
  onError: function onError(e) {
4943
4657
  set(undefined);
4944
4658
  if (check()) return;
4945
-
4946
4659
  (_onError || function (e) {
4947
4660
  return err(e.message || 'fetch fail ' + option.action);
4948
4661
  })(e, rule, api);
@@ -4951,38 +4664,54 @@
4951
4664
  });
4952
4665
  return true;
4953
4666
  }
4667
+ var $provider = {
4668
+ fetch: $fetch,
4669
+ required: $required
4670
+ };
4954
4671
 
4955
- var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
4672
+ var name = 'html';
4673
+ var html = {
4674
+ name: name,
4675
+ loadChildren: false,
4676
+ render: function render(children, ctx) {
4677
+ if (!ctx.prop.domProps) ctx.prop.domProps = {};
4678
+ ctx.prop.domProps.innerHTML = children;
4679
+ return ctx.vNode.make(ctx.prop.props.tag || 'div', ctx.prop);
4680
+ },
4681
+ renderChildren: function renderChildren(ctx) {
4682
+ if (Array.isArray(ctx.rule.children)) {
4683
+ return ctx.rule.children.filter(function (v) {
4684
+ return is.String(v);
4685
+ }).join('');
4686
+ }
4687
+ return '';
4688
+ }
4689
+ };
4956
4690
 
4691
+ var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
4957
4692
  function _parseProp(name, id) {
4958
4693
  var prop;
4959
-
4960
4694
  if (arguments.length === 2) {
4961
4695
  prop = arguments[1];
4962
4696
  id = prop[name];
4963
4697
  } else {
4964
4698
  prop = arguments[2];
4965
4699
  }
4966
-
4967
4700
  return {
4968
4701
  id: id,
4969
4702
  prop: prop
4970
4703
  };
4971
4704
  }
4972
-
4973
4705
  function nameProp() {
4974
4706
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
4975
4707
  }
4976
-
4977
4708
  function _getEl(options) {
4978
4709
  if (!options || !options.el) return window.document.body;
4979
4710
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
4980
4711
  }
4981
-
4982
4712
  function mountForm(rules, option) {
4983
4713
  var $vm = new _vue({
4984
4714
  data: function data() {
4985
- //todo 外部无法修改
4986
4715
  return {
4987
4716
  rule: rules,
4988
4717
  option: option || {}
@@ -4998,7 +4727,6 @@
4998
4727
  $vm.$mount();
4999
4728
  return $vm;
5000
4729
  }
5001
-
5002
4730
  function exportAttrs(attrs) {
5003
4731
  var key = attrs.key || [];
5004
4732
  var array = attrs.array || [];
@@ -5007,17 +4735,14 @@
5007
4735
  arrayAttrs.push.apply(arrayAttrs, _toConsumableArray(array));
5008
4736
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
5009
4737
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
5010
- } //todo 表单嵌套
5011
-
5012
-
4738
+ }
4739
+ var id$1 = 1;
4740
+ var instance = {};
5013
4741
  function FormCreateFactory(config) {
5014
4742
  var components = _defineProperty({}, fragment.name, fragment);
5015
-
5016
4743
  var parsers = {};
5017
4744
  var directives = {};
5018
- var providers = {
5019
- fetch: $fetch
5020
- };
4745
+ var providers = _objectSpread2({}, $provider);
5021
4746
  var maker = makerFactory();
5022
4747
  var globalConfig = {
5023
4748
  global: {}
@@ -5025,23 +4750,24 @@
5025
4750
  var data = {};
5026
4751
  var CreateNode = CreateNodeFactory();
5027
4752
  exportAttrs(config.attrs || {});
5028
-
4753
+ function getApi(name) {
4754
+ var val = instance[name];
4755
+ if (Array.isArray(val)) return _toConsumableArray(val);
4756
+ return val;
4757
+ }
5029
4758
  function directive() {
5030
4759
  var data = nameProp.apply(void 0, arguments);
5031
4760
  if (data.id && data.prop) directives[data.id] = data.prop;
5032
4761
  }
5033
-
5034
4762
  function register() {
5035
4763
  var data = nameProp.apply(void 0, arguments);
5036
4764
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5037
4765
  name: data.id
5038
4766
  });
5039
4767
  }
5040
-
5041
4768
  function componentAlias(alias) {
5042
4769
  CreateNode.use(alias);
5043
4770
  }
5044
-
5045
4771
  function parser() {
5046
4772
  var data = nameProp.apply(void 0, arguments);
5047
4773
  if (!data.id || !data.prop) return;
@@ -5052,13 +4778,10 @@
5052
4778
  maker[name] = creatorFactory(name);
5053
4779
  parser.maker && extend(maker, parser.maker);
5054
4780
  }
5055
-
5056
4781
  function component(id, component) {
5057
4782
  var name;
5058
-
5059
4783
  if (is.String(id)) {
5060
4784
  name = toCase(id);
5061
-
5062
4785
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5063
4786
  return $form();
5064
4787
  } else if (component === undefined) {
@@ -5068,48 +4791,54 @@
5068
4791
  name = toCase(id.name);
5069
4792
  component = id;
5070
4793
  }
5071
-
5072
4794
  if (!name || !component) return;
5073
4795
  components[name] = component;
5074
4796
  if (component.formCreateParser) parser(name, component.formCreateParser);
5075
4797
  }
5076
-
5077
4798
  function $form() {
5078
4799
  return _vue.extend($FormCreate(FormCreate));
5079
4800
  }
5080
-
5081
4801
  function $vnode() {
5082
4802
  return _vue.extend(fragment);
5083
- } //todo 检查回调函数作用域
5084
-
5085
-
4803
+ }
5086
4804
  function use(fn, opt) {
5087
4805
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5088
4806
  return this;
5089
4807
  }
5090
-
5091
4808
  function create(rules, _opt, parent) {
5092
4809
  var $vm = mountForm(rules, _opt || {});
5093
4810
  var _this = $vm.$refs.fc.formCreate;
5094
4811
  _this.$parent = parent;
5095
-
5096
4812
  _getEl(_this.options).appendChild($vm.$el);
5097
-
5098
4813
  return _this.api();
5099
4814
  }
5100
-
5101
- function factory() {
5102
- return FormCreateFactory(config);
4815
+ function factory(inherit) {
4816
+ var _config = _objectSpread2({}, config);
4817
+ if (inherit) {
4818
+ _config.inherit = {
4819
+ components: components,
4820
+ parsers: parsers,
4821
+ directives: directives,
4822
+ providers: providers,
4823
+ maker: maker,
4824
+ data: data
4825
+ };
4826
+ } else {
4827
+ delete _config.inherit;
4828
+ }
4829
+ return FormCreateFactory(_config);
5103
4830
  }
5104
-
5105
4831
  function FormCreate(vm, rules, options) {
5106
4832
  extend(this, {
4833
+ id: id$1++,
5107
4834
  vm: vm,
5108
4835
  create: create,
5109
4836
  manager: createManager(config.manager),
5110
4837
  parsers: parsers,
5111
4838
  providers: providers,
5112
4839
  rules: Array.isArray(rules) ? rules : [],
4840
+ name: vm.$options.propsData.name,
4841
+ inFor: vm.$options.propsData.inFor,
5113
4842
  prop: {
5114
4843
  components: components,
5115
4844
  directives: directives
@@ -5117,18 +4846,25 @@
5117
4846
  CreateNode: CreateNode,
5118
4847
  bus: new _vue(),
5119
4848
  unwatch: null,
4849
+ options: options || {},
5120
4850
  extendApi: config.extendApi || function (api) {
5121
4851
  return api;
5122
4852
  }
5123
4853
  });
5124
4854
  this.init();
5125
- this.initOptions(options || {});
4855
+ this.initOptions(this.options);
4856
+ if (this.name) {
4857
+ if (this.inFor) {
4858
+ if (!instance[this.name]) instance[this.name] = [];
4859
+ instance[this.name].push(this.api());
4860
+ } else {
4861
+ instance[this.name] = this.api();
4862
+ }
4863
+ }
5126
4864
  }
5127
-
5128
4865
  extend(FormCreate.prototype, {
5129
4866
  init: function init() {
5130
4867
  var _this2 = this;
5131
-
5132
4868
  var vm = this.vm;
5133
4869
  var h = new Handler(this);
5134
4870
  this.$handle = h;
@@ -5140,15 +4876,12 @@
5140
4876
  return vm.$pfc.option;
5141
4877
  }, function () {
5142
4878
  _this2.initOptions(_this2.options);
5143
-
5144
4879
  vm.$f.refresh();
5145
4880
  }, {
5146
4881
  deep: true
5147
4882
  });
5148
-
5149
4883
  _this2.initOptions(_this2.options);
5150
4884
  }
5151
-
5152
4885
  _this2.created();
5153
4886
  });
5154
4887
  vm.$on('hook:mounted', function () {
@@ -5158,6 +4891,14 @@
5158
4891
  vm.destroyed = true;
5159
4892
  _this2.unwatch && _this2.unwatch();
5160
4893
  h.reloadRule([]);
4894
+ if (_this2.name) {
4895
+ if (_this2.inFor) {
4896
+ var idx = instance[_this2.name].indexOf(_this2.api());
4897
+ instance[_this2.name].splice(idx, 1);
4898
+ } else {
4899
+ delete instance[_this2.name];
4900
+ }
4901
+ }
5161
4902
  });
5162
4903
  vm.$on('hook:updated', function () {
5163
4904
  h.bindNextTick(function () {
@@ -5174,11 +4915,9 @@
5174
4915
  submitBtn: {},
5175
4916
  resetBtn: {}
5176
4917
  }, deepCopy(globalConfig));
5177
-
5178
4918
  if (this.isSub()) {
5179
4919
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5180
4920
  }
5181
-
5182
4921
  this.updateOptions(options);
5183
4922
  },
5184
4923
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5186,12 +4925,10 @@
5186
4925
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5187
4926
  delete opt[n];
5188
4927
  });
5189
-
5190
4928
  if (opt.global) {
5191
4929
  target.global = mergeGlobal(target.global, opt.global);
5192
4930
  delete opt.global;
5193
4931
  }
5194
-
5195
4932
  this.$handle.$manager.mergeOptions([opt], target);
5196
4933
  return target;
5197
4934
  },
@@ -5213,7 +4950,6 @@
5213
4950
  this.$handle.mounted();
5214
4951
  }
5215
4952
  });
5216
-
5217
4953
  function useAttr(formCreate) {
5218
4954
  extend(formCreate, {
5219
4955
  version: config.version,
@@ -5235,17 +4971,15 @@
5235
4971
  parseFn: parseFn,
5236
4972
  parseJson: parseJson,
5237
4973
  toJson: toJson,
4974
+ getApi: getApi,
5238
4975
  init: function init(rules) {
5239
4976
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5240
-
5241
4977
  var $vm = mountForm(rules, _opt),
5242
4978
  _this = $vm.$refs.fc.formCreate;
5243
4979
  return {
5244
4980
  mount: function mount($el) {
5245
4981
  if ($el && is.Element($el)) _this.options.el = $el;
5246
-
5247
4982
  _getEl(_this.options).appendChild($vm.$el);
5248
-
5249
4983
  return _this.api();
5250
4984
  },
5251
4985
  remove: function remove() {
@@ -5260,7 +4994,6 @@
5260
4994
  }
5261
4995
  });
5262
4996
  }
5263
-
5264
4997
  function useStatic(formCreate) {
5265
4998
  extend(formCreate, {
5266
4999
  create: create,
@@ -5269,12 +5002,10 @@
5269
5002
  if (Vue._installedFormCreate === true) return;
5270
5003
  Vue._installedFormCreate = true;
5271
5004
  _vue = Vue;
5272
-
5273
5005
  var $formCreate = function $formCreate(rules) {
5274
5006
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5275
5007
  return create(rules, opt, this);
5276
5008
  };
5277
-
5278
5009
  useAttr($formCreate);
5279
5010
  Vue.prototype.$formCreate = $formCreate;
5280
5011
  Vue.component('FormCreate', $form());
@@ -5282,13 +5013,22 @@
5282
5013
  }
5283
5014
  });
5284
5015
  }
5285
-
5286
5016
  useAttr(create);
5287
5017
  useStatic(create);
5288
5018
  CreateNode.use({
5289
5019
  fragment: 'fcFragment'
5290
5020
  });
5021
+ parser(html);
5291
5022
  if (config.install) create.use(config);
5023
+ if (config.inherit) {
5024
+ var inherit = config.inherit;
5025
+ inherit.components && extend(components, inherit.components);
5026
+ inherit.parsers && extend(parsers, inherit.parsers);
5027
+ inherit.directives && extend(directives, inherit.directives);
5028
+ inherit.providers && extend(providers, inherit.providers);
5029
+ inherit.maker && extend(maker, inherit.maker);
5030
+ inherit.data && extend(data, inherit.data);
5031
+ }
5292
5032
  return create;
5293
5033
  }
5294
5034
 
@@ -5296,19 +5036,18 @@
5296
5036
  date: 'yyyy-MM-dd',
5297
5037
  month: 'yyyy-MM',
5298
5038
  datetime: 'yyyy-MM-dd HH:mm:ss',
5299
- week: 'yyyywWW',
5300
5039
  timerange: 'HH:mm:ss',
5301
5040
  daterange: 'yyyy-MM-dd',
5302
5041
  monthrange: 'yyyy-MM',
5303
5042
  datetimerange: 'yyyy-MM-dd HH:mm:ss',
5304
5043
  year: 'yyyy'
5305
5044
  };
5306
- var name = 'datePicker';
5045
+ var name$1 = 'datePicker';
5307
5046
  var datePicker = {
5308
- name: name,
5047
+ name: name$1,
5309
5048
  maker: function () {
5310
5049
  return ['year', 'month', 'date', 'dates', 'week', 'datetime', 'datetimeRange', 'dateRange', 'monthRange'].reduce(function (initial, type) {
5311
- initial[type] = creatorFactory(name, {
5050
+ initial[type] = creatorFactory(name$1, {
5312
5051
  type: type.toLowerCase()
5313
5052
  });
5314
5053
  return initial;
@@ -5316,53 +5055,51 @@
5316
5055
  }(),
5317
5056
  mergeProp: function mergeProp(ctx) {
5318
5057
  var props = ctx.prop.props;
5319
-
5320
5058
  if (!props.valueFormat) {
5321
5059
  props.valueFormat = DEFAULT_FORMATS[props.type] || DEFAULT_FORMATS['date'];
5322
5060
  }
5323
5061
  }
5324
5062
  };
5325
5063
 
5326
- var name$1 = 'hidden';
5064
+ var name$2 = 'hidden';
5327
5065
  var hidden = {
5328
- name: name$1,
5329
- maker: _defineProperty({}, name$1, function (field, value) {
5330
- return creatorFactory(name$1)('', field, value);
5066
+ name: name$2,
5067
+ maker: _defineProperty({}, name$2, function (field, value) {
5068
+ return creatorFactory(name$2)('', field, value);
5331
5069
  }),
5332
5070
  render: function render() {
5333
5071
  return [];
5334
5072
  }
5335
5073
  };
5336
5074
 
5337
- var name$2 = 'input';
5075
+ var name$3 = 'input';
5338
5076
  var input = {
5339
- name: name$2,
5077
+ name: name$3,
5340
5078
  maker: function () {
5341
5079
  var maker = ['password', 'url', 'email', 'text', 'textarea'].reduce(function (maker, type) {
5342
- maker[type] = creatorFactory(name$2, {
5080
+ maker[type] = creatorFactory(name$3, {
5343
5081
  type: type
5344
5082
  });
5345
5083
  return maker;
5346
5084
  }, {});
5347
- maker.idate = creatorFactory(name$2, {
5085
+ maker.idate = creatorFactory(name$3, {
5348
5086
  type: 'date'
5349
5087
  });
5350
5088
  return maker;
5351
5089
  }(),
5352
5090
  mergeProp: function mergeProp(ctx) {
5353
5091
  var props = ctx.prop.props;
5354
-
5355
5092
  if (props && props.autosize && props.autosize.minRows) {
5356
5093
  props.rows = props.autosize.minRows || 2;
5357
5094
  }
5358
5095
  }
5359
5096
  };
5360
5097
 
5361
- var name$3 = 'slider';
5098
+ var name$4 = 'slider';
5362
5099
  var slider = {
5363
- name: name$3,
5100
+ name: name$4,
5364
5101
  maker: {
5365
- sliderRange: creatorFactory(name$3, {
5102
+ sliderRange: creatorFactory(name$4, {
5366
5103
  range: true
5367
5104
  })
5368
5105
  },
@@ -5371,31 +5108,28 @@
5371
5108
  props = ctx.prop.props,
5372
5109
  min = props.min || 0,
5373
5110
  parseValue;
5374
-
5375
5111
  if (props.range === true) {
5376
5112
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5377
5113
  } else {
5378
5114
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5379
5115
  }
5380
-
5381
5116
  return parseValue;
5382
5117
  }
5383
5118
  };
5384
5119
 
5385
- var name$4 = 'timePicker';
5120
+ var name$5 = 'timePicker';
5386
5121
  var timePicker = {
5387
- name: name$4,
5122
+ name: name$5,
5388
5123
  maker: {
5389
- time: creatorFactory(name$4, function (m) {
5124
+ time: creatorFactory(name$5, function (m) {
5390
5125
  return m.props.isRange = false;
5391
5126
  }),
5392
- timeRange: creatorFactory(name$4, function (m) {
5127
+ timeRange: creatorFactory(name$5, function (m) {
5393
5128
  return m.props.isRange = true;
5394
5129
  })
5395
5130
  },
5396
5131
  mergeProp: function mergeProp(ctx) {
5397
5132
  var props = ctx.prop.props;
5398
-
5399
5133
  if (!props.valueFormat) {
5400
5134
  props.valueFormat = 'HH:mm:ss';
5401
5135
  }
@@ -5413,9 +5147,9 @@
5413
5147
  }
5414
5148
  };
5415
5149
 
5416
- var name$5 = 'select';
5150
+ var name$6 = 'select';
5417
5151
  var select = {
5418
- name: name$5,
5152
+ name: name$6,
5419
5153
  toFormValue: function toFormValue(value, ctx) {
5420
5154
  if (ctx.prop.props.multiple && !Array.isArray(value)) {
5421
5155
  return toArray(value);
@@ -5499,26 +5233,20 @@
5499
5233
  function isTooltip(info) {
5500
5234
  return info.type === 'tooltip';
5501
5235
  }
5502
-
5503
5236
  var upperCaseReg = /[A-Z]/;
5504
5237
  function isAttr(name, value) {
5505
5238
  return !upperCaseReg.test(name) && (is.String(value) || is.Number(value));
5506
5239
  }
5507
-
5508
5240
  function tidy(props, name) {
5509
5241
  if (!hasProperty(props, name)) return;
5510
-
5511
5242
  if (is.String(props[name])) {
5512
5243
  var _props$name;
5513
-
5514
5244
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5515
5245
  }
5516
5246
  }
5517
-
5518
5247
  function isFalse(val) {
5519
5248
  return val === false;
5520
5249
  }
5521
-
5522
5250
  function tidyBool(opt, name) {
5523
5251
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5524
5252
  opt[name] = {
@@ -5526,7 +5254,6 @@
5526
5254
  };
5527
5255
  }
5528
5256
  }
5529
-
5530
5257
  var manager = {
5531
5258
  validate: function validate(call) {
5532
5259
  this.form().validate(call);
@@ -5536,7 +5263,6 @@
5536
5263
  },
5537
5264
  clearValidateState: function clearValidateState(ctx) {
5538
5265
  var fItem = this.vm.$refs[ctx.wrapRef];
5539
-
5540
5266
  if (fItem) {
5541
5267
  fItem.validateMessage = '';
5542
5268
  fItem.validateState = '';
@@ -5613,7 +5339,6 @@
5613
5339
  if (children.length) {
5614
5340
  children.push(this.makeFormBtn());
5615
5341
  }
5616
-
5617
5342
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5618
5343
  },
5619
5344
  makeWrap: function makeWrap(ctx, children) {
@@ -5651,7 +5376,6 @@
5651
5376
  var isTip = isTooltip(infoProp);
5652
5377
  var form = this.options.form;
5653
5378
  var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
5654
-
5655
5379
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5656
5380
  var prop = {
5657
5381
  type: infoProp.type || 'popover',
@@ -5660,11 +5384,9 @@
5660
5384
  slot: 'label'
5661
5385
  };
5662
5386
  var field = 'content';
5663
-
5664
5387
  if (infoProp.info && !hasProperty(prop.props, field)) {
5665
5388
  prop.props[field] = infoProp.info;
5666
5389
  }
5667
-
5668
5390
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5669
5391
  type: 'i',
5670
5392
  slot: isTip ? 'default' : 'reference',
@@ -5672,7 +5394,6 @@
5672
5394
  key: "".concat(uni, "i")
5673
5395
  })]));
5674
5396
  }
5675
-
5676
5397
  return this.$r(mergeProps([titleProp, {
5677
5398
  props: titleProp,
5678
5399
  slot: titleProp.slot || 'label',
@@ -5702,19 +5423,15 @@
5702
5423
  },
5703
5424
  makeFormBtn: function makeFormBtn() {
5704
5425
  var vn = [];
5705
-
5706
5426
  if (!isFalse(this.options.submitBtn.show)) {
5707
5427
  vn.push(this.makeSubmitBtn());
5708
5428
  }
5709
-
5710
5429
  if (!isFalse(this.options.resetBtn.show)) {
5711
5430
  vn.push(this.makeResetBtn());
5712
5431
  }
5713
-
5714
5432
  if (!vn.length) {
5715
5433
  return;
5716
5434
  }
5717
-
5718
5435
  var item = this.$r({
5719
5436
  type: 'formItem',
5720
5437
  key: "".concat(this.key, "fb")
@@ -5729,7 +5446,6 @@
5729
5446
  },
5730
5447
  makeResetBtn: function makeResetBtn() {
5731
5448
  var _this = this;
5732
-
5733
5449
  var resetBtn = this.options.resetBtn;
5734
5450
  return this.$r({
5735
5451
  type: 'button',
@@ -5748,7 +5464,6 @@
5748
5464
  },
5749
5465
  makeSubmitBtn: function makeSubmitBtn() {
5750
5466
  var _this2 = this;
5751
-
5752
5467
  var submitBtn = this.options.submitBtn;
5753
5468
  return this.$r({
5754
5469
  type: 'button',
@@ -5773,7 +5488,6 @@
5773
5488
  useTree(maker);
5774
5489
  useUpload(maker);
5775
5490
  useFrame(maker);
5776
-
5777
5491
  function useAlias(maker) {
5778
5492
  ['group', 'tree', 'switch', 'upload', 'autoComplete', 'checkbox', 'cascader', 'colorPicker', 'datePicker', 'frame', 'inputNumber', 'radio', 'rate'].forEach(function (name) {
5779
5493
  maker[name] = creatorFactory(name);
@@ -5782,14 +5496,12 @@
5782
5496
  maker.number = maker.inputNumber;
5783
5497
  maker.color = maker.colorPicker;
5784
5498
  }
5785
-
5786
5499
  function useSelect(maker) {
5787
5500
  var select = 'select';
5788
5501
  var multiple = 'multiple';
5789
5502
  maker['selectMultiple'] = creatorFactory(select, _defineProperty({}, multiple, true));
5790
5503
  maker['selectOne'] = creatorFactory(select, _defineProperty({}, multiple, false));
5791
5504
  }
5792
-
5793
5505
  function useTree(maker) {
5794
5506
  var name = 'tree';
5795
5507
  var types = {
@@ -5803,7 +5515,6 @@
5803
5515
  return m;
5804
5516
  }, maker);
5805
5517
  }
5806
-
5807
5518
  function useUpload(maker) {
5808
5519
  var name = 'upload';
5809
5520
  var types = {
@@ -5824,7 +5535,6 @@
5824
5535
  maker.uploadImage = maker.image;
5825
5536
  maker.uploadFile = maker.file;
5826
5537
  }
5827
-
5828
5538
  function useFrame(maker) {
5829
5539
  var types = {
5830
5540
  frameInputs: ['input', 0],
@@ -5849,7 +5559,7 @@
5849
5559
  return maker;
5850
5560
  }
5851
5561
 
5852
- var css_248z$2 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n\n.form-create{\n transform: rotateZ(0);\n}\n";
5562
+ var css_248z$2 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n";
5853
5563
  styleInject(css_248z$2);
5854
5564
 
5855
5565
  function tidyBtnProp(btn, def) {
@@ -5860,28 +5570,23 @@
5860
5570
  };
5861
5571
  return btn;
5862
5572
  }
5863
-
5864
5573
  function extendApi(api, h) {
5865
5574
  extend(api, {
5866
5575
  validate: function validate(callback) {
5867
5576
  var flag;
5868
5577
  var forms = api.children;
5869
5578
  var len = forms.length;
5870
-
5871
5579
  var validate = function validate() {
5872
5580
  h.$manager.validate(function () {
5873
5581
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5874
5582
  args[_key] = arguments[_key];
5875
5583
  }
5876
-
5877
5584
  if (!args[0] || !flag) {
5878
5585
  flag = args;
5879
5586
  }
5880
-
5881
5587
  callback && callback.apply(void 0, _toConsumableArray(flag));
5882
5588
  });
5883
5589
  };
5884
-
5885
5590
  var validFn = function validFn(args) {
5886
5591
  setTimeout(function () {
5887
5592
  if (!args[0]) {
@@ -5889,23 +5594,19 @@
5889
5594
  flag = args;
5890
5595
  }
5891
5596
  }
5892
-
5893
5597
  if (! --len) {
5894
5598
  validate();
5895
5599
  }
5896
5600
  });
5897
5601
  };
5898
-
5899
5602
  forms.forEach(function (form) {
5900
5603
  form.validate(function () {
5901
5604
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5902
5605
  args[_key2] = arguments[_key2];
5903
5606
  }
5904
-
5905
5607
  return validFn(args);
5906
5608
  });
5907
5609
  });
5908
-
5909
5610
  if (!len) {
5910
5611
  validate();
5911
5612
  }
@@ -5916,23 +5617,19 @@
5916
5617
  var sub = h.subForm[ctx.id];
5917
5618
  var len = 0;
5918
5619
  var flag;
5919
-
5920
5620
  var validate = function validate() {
5921
5621
  h.$manager.validateField(ctx.id, function () {
5922
5622
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
5923
5623
  args[_key3] = arguments[_key3];
5924
5624
  }
5925
-
5926
5625
  if (args[0]) {
5927
5626
  flag = args;
5928
5627
  } else if (flag) {
5929
5628
  return callback && callback('子表单验证未通过', flag[1]);
5930
5629
  }
5931
-
5932
5630
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
5933
5631
  });
5934
5632
  };
5935
-
5936
5633
  var validFn = function validFn(args) {
5937
5634
  setTimeout(function () {
5938
5635
  if (!args[0]) {
@@ -5940,31 +5637,26 @@
5940
5637
  flag = args;
5941
5638
  }
5942
5639
  }
5943
-
5944
5640
  if (! --len) {
5945
5641
  validate();
5946
5642
  }
5947
5643
  });
5948
5644
  };
5949
-
5950
5645
  sub && toArray(sub).forEach(function (form) {
5951
5646
  len++;
5952
5647
  form.validate(function () {
5953
5648
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
5954
5649
  args[_key4] = arguments[_key4];
5955
5650
  }
5956
-
5957
5651
  return validFn(args);
5958
5652
  });
5959
5653
  });
5960
-
5961
5654
  if (!len) {
5962
5655
  validate();
5963
5656
  }
5964
5657
  },
5965
5658
  clearValidateState: function clearValidateState(fields) {
5966
5659
  var _this = this;
5967
-
5968
5660
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5969
5661
  api.helper.tidyFields(fields).forEach(function (field) {
5970
5662
  if (clearSub) _this.clearSubValidateState(field);
@@ -5978,7 +5670,6 @@
5978
5670
  h.getCtxs(field).forEach(function (ctx) {
5979
5671
  var subForm = h.subForm[ctx.id];
5980
5672
  if (!subForm) return;
5981
-
5982
5673
  if (Array.isArray(subForm)) {
5983
5674
  subForm.forEach(function (form) {
5984
5675
  form.clearValidateState();
@@ -5992,14 +5683,12 @@
5992
5683
  btn: {
5993
5684
  loading: function loading() {
5994
5685
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
5995
-
5996
5686
  api.submitBtnProps({
5997
5687
  loading: !!_loading
5998
5688
  });
5999
5689
  },
6000
5690
  disabled: function disabled() {
6001
5691
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6002
-
6003
5692
  api.submitBtnProps({
6004
5693
  disabled: !!_disabled
6005
5694
  });
@@ -6014,14 +5703,12 @@
6014
5703
  resetBtn: {
6015
5704
  loading: function loading() {
6016
5705
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6017
-
6018
5706
  api.resetBtnProps({
6019
5707
  loading: !!_loading2
6020
5708
  });
6021
5709
  },
6022
5710
  disabled: function disabled() {
6023
5711
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6024
-
6025
5712
  api.resetBtnProps({
6026
5713
  disabled: !!_disabled2
6027
5714
  });
@@ -6050,7 +5737,6 @@
6050
5737
  submit: function submit(successFn, failFn) {
6051
5738
  var _arguments = arguments,
6052
5739
  _this2 = this;
6053
-
6054
5740
  api.validate(function (valid) {
6055
5741
  if (valid) {
6056
5742
  var formData = api.formData();
@@ -6085,11 +5771,10 @@
6085
5771
  FormCreate.maker[name] = maker[name];
6086
5772
  });
6087
5773
  }
6088
-
6089
5774
  function elmFormCreate() {
6090
5775
  return FormCreateFactory({
6091
5776
  ui: "".concat("element-ui"),
6092
- version: "".concat("2.5.17"),
5777
+ version: "".concat("2.5.20"),
6093
5778
  manager: manager,
6094
5779
  extendApi: extendApi,
6095
5780
  install: install,
@@ -6102,15 +5787,12 @@
6102
5787
  }
6103
5788
 
6104
5789
  var FormCreate = elmFormCreate();
6105
-
6106
5790
  if (typeof window !== 'undefined') {
6107
5791
  window.formCreate = FormCreate;
6108
-
6109
5792
  if (window.Vue) {
6110
5793
  FormCreate.install(window.Vue);
6111
5794
  }
6112
5795
  }
6113
-
6114
5796
  var maker$1 = FormCreate.maker;
6115
5797
 
6116
5798
  exports.default = FormCreate;