@form-create/view-design 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/view-design v2.5.17
2
+ * @form-create/view-design 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
  }
@@ -298,7 +293,6 @@
298
293
  },
299
294
  update: function update() {
300
295
  var _this = this;
301
-
302
296
  this.trueValue = this.value ? this.options().filter(function (opt) {
303
297
  return _this.value.indexOf(opt.value) !== -1;
304
298
  }).map(function (option) {
@@ -320,7 +314,6 @@
320
314
  }
321
315
  }]), [this.options().map(function (opt, index) {
322
316
  var props = _objectSpread2({}, opt);
323
-
324
317
  delete props.value;
325
318
  return h("Checkbox", {
326
319
  "props": _objectSpread2({}, props),
@@ -337,15 +330,12 @@
337
330
  function styleInject(css, ref) {
338
331
  if (ref === void 0) ref = {};
339
332
  var insertAt = ref.insertAt;
340
-
341
333
  if (!css || typeof document === 'undefined') {
342
334
  return;
343
335
  }
344
-
345
336
  var head = document.head || document.getElementsByTagName('head')[0];
346
337
  var style = document.createElement('style');
347
338
  style.type = 'text/css';
348
-
349
339
  if (insertAt === 'top') {
350
340
  if (head.firstChild) {
351
341
  head.insertBefore(style, head.firstChild);
@@ -355,7 +345,6 @@
355
345
  } else {
356
346
  head.appendChild(style);
357
347
  }
358
-
359
348
  if (style.styleSheet) {
360
349
  style.styleSheet.cssText = css;
361
350
  } else {
@@ -401,8 +390,8 @@
401
390
  "default": 500
402
391
  },
403
392
  height: {
404
- type: [Number, String],
405
- "default": 370
393
+ type: String,
394
+ "default": '370px'
406
395
  },
407
396
  maxLength: {
408
397
  type: Number,
@@ -512,12 +501,10 @@
512
501
  },
513
502
  closeModel: function closeModel(close) {
514
503
  this.$emit(close ? '$close' : '$ok');
515
-
516
504
  if (this.reload) {
517
505
  this.$off('$ok');
518
506
  this.$off('$close');
519
507
  }
520
-
521
508
  this.frameVisible = false;
522
509
  },
523
510
  showModel: function showModel() {
@@ -526,7 +513,6 @@
526
513
  },
527
514
  makeInput: function makeInput() {
528
515
  var _this = this;
529
-
530
516
  var h = this.$createElement;
531
517
  var props = {
532
518
  type: 'text',
@@ -569,7 +555,6 @@
569
555
  },
570
556
  makeIcons: function makeIcons(val, index) {
571
557
  var h = this.$createElement;
572
-
573
558
  if (this.handleIcon !== false || this.allowRemove === true) {
574
559
  var icons = [];
575
560
  if (this.type !== 'file' && this.handleIcon !== false || this.type === 'file' && this.handleIcon) icons.push(this.makeHandleIcon(val, index));
@@ -582,7 +567,6 @@
582
567
  },
583
568
  makeHandleIcon: function makeHandleIcon(val, index) {
584
569
  var _this2 = this;
585
-
586
570
  var h = this.$createElement;
587
571
  return h("icon", helper([{}, {
588
572
  "props": {
@@ -599,7 +583,6 @@
599
583
  },
600
584
  makeRemoveIcon: function makeRemoveIcon(val, index) {
601
585
  var _this3 = this;
602
-
603
586
  var h = this.$createElement;
604
587
  return h("icon", helper([{}, {
605
588
  "props": {
@@ -616,7 +599,6 @@
616
599
  },
617
600
  makeFiles: function makeFiles() {
618
601
  var _this4 = this;
619
-
620
602
  var h = this.$createElement;
621
603
  return this.makeGroup(this.fileList.map(function (src, index) {
622
604
  return _this4.makeItem(index, [h("icon", helper([{}, {
@@ -635,7 +617,6 @@
635
617
  },
636
618
  makeImages: function makeImages() {
637
619
  var _this5 = this;
638
-
639
620
  var h = this.$createElement;
640
621
  return this.makeGroup(this.fileList.map(function (src, index) {
641
622
  return _this5.makeItem(index, [h("img", {
@@ -647,7 +628,6 @@
647
628
  },
648
629
  makeBtn: function makeBtn() {
649
630
  var _this6 = this;
650
-
651
631
  var h = this.$createElement;
652
632
  return h("div", {
653
633
  "class": 'fc-upload-btn',
@@ -669,7 +649,6 @@
669
649
  },
670
650
  handleRemove: function handleRemove(src) {
671
651
  if (this.disabled) return;
672
-
673
652
  if (false !== this.onBeforeRemove(src)) {
674
653
  this.fileList.splice(this.fileList.indexOf(src), 1);
675
654
  this.onRemove(src);
@@ -680,25 +659,21 @@
680
659
  },
681
660
  frameLoad: function frameLoad(iframe) {
682
661
  var _this7 = this;
683
-
684
662
  this.onLoad(iframe);
685
-
686
663
  try {
687
664
  if (this.helper === true) {
688
665
  iframe['form_create_helper'] = {
666
+ api: this.formCreateInject.api,
689
667
  close: function close(field) {
690
668
  _this7.valid(field);
691
-
692
669
  _this7.closeModel();
693
670
  },
694
671
  set: function set(field, value) {
695
672
  _this7.valid(field);
696
-
697
673
  if (!_this7.disabled) _this7.$emit('input', value);
698
674
  },
699
675
  get: function get(field) {
700
676
  _this7.valid(field);
701
-
702
677
  return _this7.value;
703
678
  },
704
679
  onOk: function onOk(fn) {
@@ -715,7 +690,6 @@
715
690
  },
716
691
  makeFooter: function makeFooter() {
717
692
  var _this8 = this;
718
-
719
693
  var h = this.$createElement;
720
694
  var _this$$props = this.$props,
721
695
  okBtnText = _this$$props.okBtnText,
@@ -747,7 +721,6 @@
747
721
  },
748
722
  render: function render() {
749
723
  var _this9 = this;
750
-
751
724
  var h = arguments[0];
752
725
  var type = this.type;
753
726
  var node;
@@ -778,17 +751,14 @@
778
751
  }
779
752
  }
780
753
  }, [h("img", {
754
+ "style": "width: 100%",
781
755
  "attrs": {
782
- "alt": "example",
783
756
  "src": this.previewImage
784
- },
785
- "style": "width: 100%"
786
- })]), h("Modal", helper([{}, {
787
- "props": _objectSpread2({
788
- width: width,
789
- title: title
790
- }, this.modal)
791
- }, {
757
+ }
758
+ })]), h("Modal", helper([{}, _objectSpread2({
759
+ width: width,
760
+ title: title
761
+ }, this.modal), {
792
762
  "on": {
793
763
  "on-cancel": function onCancel() {
794
764
  return _this9.closeModel(true);
@@ -870,7 +840,6 @@
870
840
  },
871
841
  update: function update() {
872
842
  var _this = this;
873
-
874
843
  this.trueValue = this.options().filter(function (opt) {
875
844
  return opt.value === _this.value;
876
845
  }).reduce(function (initial, opt) {
@@ -892,7 +861,6 @@
892
861
  }
893
862
  }]), [this.options().map(function (opt, index) {
894
863
  var props = _objectSpread2({}, opt);
895
-
896
864
  delete props.value;
897
865
  return h("Radio", {
898
866
  "props": _objectSpread2({}, props),
@@ -914,9 +882,26 @@
914
882
  },
915
883
  trueArray: function trueArray(data) {
916
884
  return Array.isArray(data) && data.length > 0;
885
+ },
886
+ Function: function Function(v) {
887
+ var type = this.getType(v);
888
+ return type === 'Function' || type === 'AsyncFunction';
889
+ },
890
+ getType: function getType(v) {
891
+ var str = Object.prototype.toString.call(v);
892
+ return /^\[object (.*)\]$/.exec(str)[1];
893
+ },
894
+ empty: function empty(value) {
895
+ if (value === undefined || value === null) {
896
+ return true;
897
+ }
898
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
899
+ return true;
900
+ }
901
+ return typeof value === 'string' && !value;
917
902
  }
918
903
  };
919
- ['Date', 'Object', 'Function', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
904
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
920
905
  is[t] = function (arg) {
921
906
  return is.type(arg, t);
922
907
  };
@@ -990,10 +975,8 @@
990
975
  },
991
976
  checked: function checked(_data, value, type) {
992
977
  var _this = this;
993
-
994
978
  _data.forEach(function (node) {
995
979
  _this.$set(node, type, value.indexOf(node.id) !== -1);
996
-
997
980
  if (node.children !== undefined && Array.isArray(node.children)) _this.checked(node.children, value, type);
998
981
  });
999
982
  },
@@ -1006,13 +989,11 @@
1006
989
  render: function render() {
1007
990
  var h = arguments[0];
1008
991
  var on = {};
1009
-
1010
992
  if (this.type === 'selected') {
1011
993
  on['on-select-change'] = this.onInput;
1012
994
  } else {
1013
995
  on['on-check-change'] = this.onInput;
1014
996
  }
1015
-
1016
997
  return h("Tree", helper([{}, this.formCreateInject.prop, {
1017
998
  "ref": "tree"
1018
999
  }, {
@@ -1030,11 +1011,9 @@
1030
1011
  name: getFileName(file)
1031
1012
  };
1032
1013
  }
1033
-
1034
1014
  function getFileName(file) {
1035
1015
  return ('' + file).split('/').pop();
1036
1016
  }
1037
-
1038
1017
  var NAME$5 = 'fcUpload';
1039
1018
  function createUpload(config) {
1040
1019
  return {
@@ -1129,7 +1108,6 @@
1129
1108
  },
1130
1109
  makeRemoveIcon: function makeRemoveIcon(file, index) {
1131
1110
  var _this = this;
1132
-
1133
1111
  var h = this.$createElement;
1134
1112
  return h("icon", {
1135
1113
  "attrs": {
@@ -1145,7 +1123,6 @@
1145
1123
  },
1146
1124
  makeHandleIcon: function makeHandleIcon(file, index) {
1147
1125
  var _this2 = this;
1148
-
1149
1126
  var h = this.$createElement;
1150
1127
  return h("icon", {
1151
1128
  "attrs": {
@@ -1174,7 +1151,6 @@
1174
1151
  makeIcons: function makeIcons(file, index) {
1175
1152
  var h = this.$createElement;
1176
1153
  var icons = [];
1177
-
1178
1154
  if (this.allowRemove || this.handleIcon !== false) {
1179
1155
  if (this.uploadType !== 'file' && this.handleIcon !== false || this.uploadType === 'file' && this.handleIcon) icons.push(this.makeHandleIcon(file, index));
1180
1156
  if (this.allowRemove) icons.push(this.makeRemoveIcon(file, index));
@@ -1185,7 +1161,6 @@
1185
1161
  },
1186
1162
  makeFiles: function makeFiles() {
1187
1163
  var _this3 = this;
1188
-
1189
1164
  var h = this.$createElement;
1190
1165
  return this.uploadList.map(function (file, index) {
1191
1166
  return _this3.$scopedSlots.fileList ? _this3.$scopedSlots.fileList({
@@ -1224,7 +1199,6 @@
1224
1199
  }).filter(function (url) {
1225
1200
  return url !== undefined;
1226
1201
  });
1227
-
1228
1202
  if (this.cacheFiles.length !== files.length) {
1229
1203
  this.cacheFiles = _toConsumableArray(files);
1230
1204
  this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
@@ -1236,14 +1210,11 @@
1236
1210
  },
1237
1211
  render: function render() {
1238
1212
  var _this4 = this;
1239
-
1240
1213
  var h = arguments[0];
1241
-
1242
1214
  if (this.$refs.upload) {
1243
1215
  if (this.formCreateInject.prop.props.showUploadList === undefined) this.formCreateInject.prop.props.showUploadList = this.$refs.upload.showUploadList;
1244
1216
  this.formCreateInject.prop.props.defaultFileList = this.$refs.upload.defaultFileList;
1245
1217
  }
1246
-
1247
1218
  return h("div", {
1248
1219
  "class": "_fc-upload"
1249
1220
  }, [[this.formCreateInject.prop.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], h("Modal", {
@@ -1267,7 +1238,6 @@
1267
1238
  },
1268
1239
  mounted: function mounted() {
1269
1240
  var _this5 = this;
1270
-
1271
1241
  this.uploadList = this.$refs.upload.fileList;
1272
1242
  this.$watch(function () {
1273
1243
  return _this5.$refs.upload.fileList;
@@ -1289,6 +1259,72 @@
1289
1259
  imgUpIcon: 'image'
1290
1260
  });
1291
1261
 
1262
+ function $set(target, field, value) {
1263
+ Vue.set(target, field, value);
1264
+ }
1265
+ function $del(target, field) {
1266
+ Vue["delete"](target, field);
1267
+ }
1268
+
1269
+ function deepExtend(origin) {
1270
+ var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1271
+ var mode = arguments.length > 2 ? arguments[2] : undefined;
1272
+ var isArr = false;
1273
+ for (var key in target) {
1274
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
1275
+ var clone = target[key];
1276
+ if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1277
+ var nst = origin[key] === undefined;
1278
+ if (isArr) {
1279
+ isArr = false;
1280
+ nst && $set(origin, key, []);
1281
+ } else if (clone._clone && mode !== undefined) {
1282
+ if (mode) {
1283
+ clone = clone.getRule();
1284
+ nst && $set(origin, key, {});
1285
+ } else {
1286
+ $set(origin, key, clone._clone());
1287
+ continue;
1288
+ }
1289
+ } else {
1290
+ nst && $set(origin, key, {});
1291
+ }
1292
+ origin[key] = deepExtend(origin[key], clone, mode);
1293
+ } else {
1294
+ $set(origin, key, clone);
1295
+ if (!is.Undef(clone)) {
1296
+ if (!is.Undef(clone.__json)) {
1297
+ origin[key].__json = clone.__json;
1298
+ }
1299
+ if (!is.Undef(clone.__origin)) {
1300
+ origin[key].__origin = clone.__origin;
1301
+ }
1302
+ }
1303
+ }
1304
+ }
1305
+ }
1306
+ return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1307
+ return !v || !v.__ctrl;
1308
+ }) : origin;
1309
+ }
1310
+ function deepCopy(value) {
1311
+ return deepExtend({}, {
1312
+ value: value
1313
+ }).value;
1314
+ }
1315
+
1316
+ var _extends$1 = Object.assign || function (a) {
1317
+ for (var b, c = 1; c < arguments.length; c++) {
1318
+ for (var d in b = arguments[c], b) {
1319
+ Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1320
+ }
1321
+ }
1322
+ return a;
1323
+ };
1324
+ function extend() {
1325
+ return _extends$1.apply(this, arguments);
1326
+ }
1327
+
1292
1328
  var NAME$6 = 'fcGroup';
1293
1329
  function createGroup(config) {
1294
1330
  return {
@@ -1321,6 +1357,7 @@
1321
1357
  return [];
1322
1358
  }
1323
1359
  },
1360
+ defaultValue: Object,
1324
1361
  disabled: {
1325
1362
  type: Boolean,
1326
1363
  "default": false
@@ -1352,18 +1389,34 @@
1352
1389
  },
1353
1390
  computed: {
1354
1391
  formRule: function formRule() {
1355
- if (this.rule) {
1356
- return Array.isArray(this.rule) ? this.rule : [this.rule];
1357
- }
1358
-
1359
1392
  if (this.rules) {
1360
1393
  return this.rules;
1361
1394
  }
1362
-
1395
+ if (this.rule) {
1396
+ return Array.isArray(this.rule) ? this.rule : [this.rule];
1397
+ }
1363
1398
  return [];
1364
1399
  }
1365
1400
  },
1366
1401
  watch: {
1402
+ formRule: {
1403
+ handler: function handler(n, o) {
1404
+ var _this = this;
1405
+ Object.keys(this.cacheRule).forEach(function (v) {
1406
+ var item = _this.cacheRule[v];
1407
+ if (n === o) {
1408
+ deepExtend(item.rule, n);
1409
+ } else {
1410
+ var val = item.$f.formData();
1411
+ item.$f.once('reload', function () {
1412
+ item.$f.setValue(val);
1413
+ });
1414
+ item.rule = deepCopy(n);
1415
+ }
1416
+ });
1417
+ },
1418
+ deep: true
1419
+ },
1367
1420
  disabled: function disabled(n) {
1368
1421
  if (this.syncDisabled) {
1369
1422
  var lst = this.cacheRule;
@@ -1374,24 +1427,20 @@
1374
1427
  },
1375
1428
  expand: function expand(n) {
1376
1429
  var d = n - this.value.length;
1377
-
1378
1430
  if (d > 0) {
1379
1431
  this.expandRule(d);
1380
1432
  }
1381
1433
  },
1382
1434
  value: function value(n) {
1383
- var _this = this;
1384
-
1435
+ var _this2 = this;
1385
1436
  n = n || [];
1386
1437
  var keys = Object.keys(this.cacheRule),
1387
1438
  total = keys.length,
1388
1439
  len = total - n.length;
1389
-
1390
1440
  if (len < 0) {
1391
1441
  for (var i = len; i < 0; i++) {
1392
1442
  this.addRule(n.length + i);
1393
1443
  }
1394
-
1395
1444
  for (var _i = 0; _i < total; _i++) {
1396
1445
  this.setValue(keys[_i], n[_i]);
1397
1446
  }
@@ -1400,12 +1449,9 @@
1400
1449
  for (var _i2 = 0; _i2 < len; _i2++) {
1401
1450
  this.removeRule(keys[total - _i2 - 1]);
1402
1451
  }
1403
-
1404
- this.subForm();
1405
1452
  }
1406
-
1407
1453
  n.forEach(function (val, i) {
1408
- _this.setValue(keys[i], n[i]);
1454
+ _this2.setValue(keys[i], n[i]);
1409
1455
  });
1410
1456
  }
1411
1457
  }
@@ -1422,23 +1468,18 @@
1422
1468
  this.$emit('change', value);
1423
1469
  },
1424
1470
  formData: function formData(key, _formData) {
1425
- var _this2 = this;
1426
-
1471
+ var _this3 = this;
1427
1472
  var cacheRule = this.cacheRule;
1428
1473
  var keys = Object.keys(cacheRule);
1429
-
1430
1474
  if (keys.filter(function (k) {
1431
1475
  return cacheRule[k].$f;
1432
1476
  }).length !== keys.length) {
1433
1477
  return;
1434
1478
  }
1435
-
1436
1479
  var value = keys.map(function (k) {
1437
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1438
- var value = _this2.field ? data[_this2.field] || null : data;
1439
-
1440
- _this2.cache(k, value);
1441
-
1480
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1481
+ var value = _this3.field ? data[_this3.field] || null : data;
1482
+ _this3.cache(k, value);
1442
1483
  return value;
1443
1484
  });
1444
1485
  this.input(value);
@@ -1446,65 +1487,53 @@
1446
1487
  setValue: function setValue(key, value) {
1447
1488
  var field = this.field,
1448
1489
  $f = this.cacheRule[key].$f;
1449
-
1450
1490
  if (field) {
1451
1491
  value = _defineProperty({}, field, this._value(value));
1452
1492
  }
1453
-
1454
1493
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1455
1494
  return;
1456
1495
  }
1457
-
1458
1496
  this.cache(key, value);
1459
1497
  $f.coverValue(value || {});
1460
1498
  },
1461
1499
  addRule: function addRule(i, emit) {
1462
- var _this3 = this;
1463
-
1500
+ var _this4 = this;
1464
1501
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1465
1502
  var options = this.options ? _objectSpread2({}, this.options) : {
1466
1503
  submitBtn: false,
1467
1504
  resetBtn: false
1468
1505
  };
1469
- options.formData = this.field ? _defineProperty({}, this.field, this._value(this.value[i])) : this.value[i] || {};
1506
+ if (this.defaultValue) {
1507
+ if (!options.formData) options.formData = {};
1508
+ var defVal = deepCopy(this.defaultValue);
1509
+ extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1510
+ }
1470
1511
  this.$set(this.cacheRule, ++this.len, {
1471
1512
  rule: rule,
1472
1513
  options: options
1473
1514
  });
1474
-
1475
1515
  if (emit) {
1476
1516
  this.$nextTick(function () {
1477
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1517
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1478
1518
  });
1479
1519
  }
1480
1520
  },
1481
1521
  add$f: function add$f(i, key, $f) {
1482
- var _this4 = this;
1483
-
1522
+ var _this5 = this;
1484
1523
  this.cacheRule[key].$f = $f;
1485
- this.subForm();
1524
+ this.formData(key, $f.formData());
1486
1525
  this.$nextTick(function () {
1487
- if (_this4.syncDisabled) {
1488
- $f.disabled(_this4.disabled);
1526
+ if (_this5.syncDisabled) {
1527
+ $f.disabled(_this5.disabled);
1489
1528
  }
1490
-
1491
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1529
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1492
1530
  });
1493
1531
  },
1494
- subForm: function subForm() {
1495
- var _this5 = this;
1496
-
1497
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1498
- return _this5.cacheRule[k].$f;
1499
- }));
1500
- },
1501
1532
  removeRule: function removeRule(key, emit) {
1502
1533
  var _this6 = this;
1503
-
1504
1534
  var index = Object.keys(this.cacheRule).indexOf(key);
1505
1535
  this.$delete(this.cacheRule, key);
1506
1536
  this.$delete(this.cacheValue, key);
1507
-
1508
1537
  if (emit) {
1509
1538
  this.$nextTick(function () {
1510
1539
  return _this6.$emit('remove', index);
@@ -1515,16 +1544,13 @@
1515
1544
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1516
1545
  return;
1517
1546
  }
1518
-
1519
1547
  this.addRule(i, true);
1520
1548
  },
1521
1549
  del: function del(index, key) {
1522
1550
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1523
1551
  return;
1524
1552
  }
1525
-
1526
1553
  this.removeRule(key, true);
1527
- this.subForm();
1528
1554
  this.value.splice(index, 1);
1529
1555
  this.input(this.value);
1530
1556
  },
@@ -1543,7 +1569,6 @@
1543
1569
  },
1544
1570
  delIcon: function delIcon(index, key) {
1545
1571
  var _this7 = this;
1546
-
1547
1572
  var h = this.$createElement;
1548
1573
  return h("Icon", {
1549
1574
  "key": "d".concat(key),
@@ -1560,7 +1585,6 @@
1560
1585
  },
1561
1586
  makeIcon: function makeIcon(total, index, key) {
1562
1587
  var _this8 = this;
1563
-
1564
1588
  if (this.$scopedSlots.button) {
1565
1589
  return this.$scopedSlots.button({
1566
1590
  total: total,
@@ -1573,11 +1597,9 @@
1573
1597
  add: this.add
1574
1598
  });
1575
1599
  }
1576
-
1577
1600
  if (index === 0) {
1578
1601
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1579
1602
  }
1580
-
1581
1603
  if (index >= this.min) {
1582
1604
  return this.delIcon(index, key);
1583
1605
  }
@@ -1594,18 +1616,15 @@
1594
1616
  created: function created() {
1595
1617
  this.type = this.formCreateInject.form.$form();
1596
1618
  var d = (this.expand || 0) - this.value.length;
1597
-
1598
1619
  if (d > 0) {
1599
1620
  this.expandRule(d);
1600
1621
  }
1601
-
1602
1622
  for (var i = 0; i < this.value.length; i++) {
1603
1623
  this.addRule(i);
1604
1624
  }
1605
1625
  },
1606
1626
  render: function render() {
1607
1627
  var _this9 = this;
1608
-
1609
1628
  var h = arguments[0];
1610
1629
  var keys = Object.keys(this.cacheRule);
1611
1630
  var button = this.button;
@@ -1640,7 +1659,10 @@
1640
1659
  "span": button ? 20 : 24
1641
1660
  }
1642
1661
  }, [h("FormItem", [h(Type, helper([{
1643
- "key": key
1662
+ "key": key,
1663
+ "attrs": {
1664
+ "inFor": true
1665
+ }
1644
1666
  }, {
1645
1667
  "on": {
1646
1668
  'update:value': function updateValue(formData) {
@@ -1650,7 +1672,6 @@
1650
1672
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1651
1673
  args[_key - 1] = arguments[_key];
1652
1674
  }
1653
-
1654
1675
  return _this9.emitEvent(name, args, index, key);
1655
1676
  },
1656
1677
  input: function input($f) {
@@ -1659,6 +1680,7 @@
1659
1680
  }
1660
1681
  }, {
1661
1682
  "attrs": {
1683
+ "value": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.value[index])) : _this9.value[index],
1662
1684
  "rule": rule,
1663
1685
  "option": options,
1664
1686
  "extendOption": true
@@ -1732,11 +1754,9 @@
1732
1754
  },
1733
1755
  setValue: function setValue(value) {
1734
1756
  var str = JSON.stringify(value);
1735
-
1736
1757
  if (this.cacheValue === str) {
1737
1758
  return;
1738
1759
  }
1739
-
1740
1760
  this.cacheValue = str;
1741
1761
  this.cacheRule.$f.coverValue(value || {});
1742
1762
  },
@@ -1753,23 +1773,16 @@
1753
1773
  },
1754
1774
  add$f: function add$f($f) {
1755
1775
  var _this = this;
1756
-
1757
1776
  this.cacheRule.$f = $f;
1758
- this.subForm();
1759
1777
  this.$nextTick(function () {
1760
1778
  _this.syncDisabled && $f.disabled(_this.disabled);
1761
-
1762
1779
  _this.$emit('itemMounted', $f);
1763
1780
  });
1764
1781
  },
1765
- subForm: function subForm() {
1766
- this.formCreateInject.subForm(this.cacheRule.$f);
1767
- },
1768
1782
  emitEvent: function emitEvent(name) {
1769
1783
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1770
1784
  args[_key - 1] = arguments[_key];
1771
1785
  }
1772
-
1773
1786
  this.$emit.apply(this, [name].concat(args));
1774
1787
  }
1775
1788
  },
@@ -1801,28 +1814,18 @@
1801
1814
 
1802
1815
  var components = [Checkbox, Radio, Select, Tree, Sub, frame, upload, group];
1803
1816
 
1804
- function $set(target, field, value) {
1805
- Vue.set(target, field, value);
1806
- }
1807
- function $del(target, field) {
1808
- Vue["delete"](target, field);
1809
- }
1810
-
1811
- var _extends$1 = Object.assign || function (a) {
1812
- for (var b, c = 1; c < arguments.length; c++) {
1813
- for (var d in b = arguments[c], b) {
1814
- Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1815
- }
1817
+ var NAME$8 = 'FormCreate';
1818
+ var getRuleInject = function getRuleInject(vm, parent) {
1819
+ if (!vm || vm === parent) {
1820
+ return;
1821
+ }
1822
+ if (vm.formCreateInject) {
1823
+ return vm.formCreateInject;
1824
+ }
1825
+ if (vm.$parent) {
1826
+ return getRuleInject(vm.$parent, parent);
1816
1827
  }
1817
-
1818
- return a;
1819
1828
  };
1820
-
1821
- function extend() {
1822
- return _extends$1.apply(this, arguments);
1823
- }
1824
-
1825
- var NAME$8 = 'FormCreate';
1826
1829
  function $FormCreate(FormCreate) {
1827
1830
  return {
1828
1831
  name: NAME$8,
@@ -1853,7 +1856,13 @@
1853
1856
  },
1854
1857
  extendOption: Boolean,
1855
1858
  value: Object,
1856
- api: Object
1859
+ api: Object,
1860
+ name: String,
1861
+ subForm: {
1862
+ type: Boolean,
1863
+ "default": true
1864
+ },
1865
+ inFor: Boolean
1857
1866
  },
1858
1867
  data: function data() {
1859
1868
  return {
@@ -1865,7 +1874,8 @@
1865
1874
  unique: 1,
1866
1875
  renderRule: _toConsumableArray(this.rule || []),
1867
1876
  ctxInject: {},
1868
- updateValue: ''
1877
+ updateValue: JSON.stringify(this.value || {}),
1878
+ isMore: !!this.inFor
1869
1879
  };
1870
1880
  },
1871
1881
  render: function render() {
@@ -1887,8 +1897,8 @@
1887
1897
  watch: {
1888
1898
  value: {
1889
1899
  handler: function handler(n) {
1890
- if (JSON.stringify(n) === this.updateValue) return;
1891
- this.$f.setValue(n);
1900
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1901
+ this.$f.setValue(n || {});
1892
1902
  },
1893
1903
  deep: true
1894
1904
  },
@@ -1901,18 +1911,15 @@
1901
1911
  },
1902
1912
  rule: function rule(n) {
1903
1913
  var _this = this;
1904
-
1905
1914
  if (n.length === this.renderRule.length && n.every(function (v) {
1906
1915
  return _this.renderRule.indexOf(v) > -1;
1907
1916
  })) return;
1908
1917
  this.formCreate.$handle.reloadRule(n);
1909
-
1910
1918
  this._renderRule();
1911
1919
  }
1912
1920
  },
1913
1921
  beforeCreate: function beforeCreate() {
1914
1922
  var _this2 = this;
1915
-
1916
1923
  var _this$$options$propsD = this.$options.propsData,
1917
1924
  rule = _this$$options$propsD.rule,
1918
1925
  option = _this$$options$propsD.option;
@@ -1921,6 +1928,50 @@
1921
1928
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1922
1929
  });
1923
1930
  this.$emit('beforeCreate', this.formCreate.api());
1931
+ },
1932
+ created: function created() {
1933
+ var _this3 = this;
1934
+ var vm = this,
1935
+ fapi = this.formCreate.api();
1936
+ var addSubForm = function addSubForm() {
1937
+ if (vm.$pfc) {
1938
+ var inject = getRuleInject(vm, vm.$pfc);
1939
+ if (inject) {
1940
+ var sub;
1941
+ if (vm.isMore) {
1942
+ sub = toArray(inject.getSubForm());
1943
+ sub.push(fapi);
1944
+ } else {
1945
+ sub = fapi;
1946
+ }
1947
+ inject.subForm(sub);
1948
+ }
1949
+ }
1950
+ };
1951
+ var rmSubForm = function rmSubForm() {
1952
+ var inject = getRuleInject(vm, vm.$pfc);
1953
+ if (inject) {
1954
+ if (vm.isMore) {
1955
+ var sub = toArray(inject.getSubForm());
1956
+ var idx = sub.indexOf(fapi);
1957
+ if (idx > -1) {
1958
+ sub.splice(idx, 1);
1959
+ }
1960
+ } else {
1961
+ inject.subForm();
1962
+ }
1963
+ }
1964
+ };
1965
+ vm.$on('hook:beforeDestroy', function () {
1966
+ rmSubForm();
1967
+ });
1968
+ this.$watch(function () {
1969
+ return _this3.subForm;
1970
+ }, function (n) {
1971
+ n ? addSubForm() : rmSubForm();
1972
+ }, {
1973
+ immediate: true
1974
+ });
1924
1975
  }
1925
1976
  };
1926
1977
  }
@@ -1928,17 +1979,12 @@
1928
1979
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
1929
1980
  var toArrayMerge$1 = ['class', 'style', 'directives'];
1930
1981
  var functionalMerge$1 = ['on', 'nativeOn'];
1931
-
1932
1982
  var mergeProps = function mergeProps(objects) {
1933
1983
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1934
1984
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1935
-
1936
1985
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
1937
-
1938
1986
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
1939
-
1940
1987
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
1941
-
1942
1988
  var propsMerge = opt['props'] || [];
1943
1989
  return objects.reduce(function (a, b) {
1944
1990
  for (var key in b) {
@@ -1955,9 +2001,7 @@
1955
2001
  for (var event in b[key]) {
1956
2002
  if (a[key][event]) {
1957
2003
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
1958
-
1959
2004
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
1960
-
1961
2005
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
1962
2006
  } else {
1963
2007
  a[key][event] = b[key][event];
@@ -1982,11 +2026,9 @@
1982
2026
  } else a[key] = b[key];
1983
2027
  }
1984
2028
  }
1985
-
1986
2029
  return a;
1987
2030
  }, initial);
1988
2031
  };
1989
-
1990
2032
  var mergeFn$1 = function mergeFn(fn1, fn2) {
1991
2033
  return function () {
1992
2034
  fn1 && fn1.apply(this, arguments);
@@ -1994,7 +2036,7 @@
1994
2036
  };
1995
2037
  };
1996
2038
 
1997
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2039
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
1998
2040
  var arrayAttrs = ['validate', 'children', 'control'];
1999
2041
  var normalAttrs = ['effect', 'deep'];
2000
2042
  function attrs() {
@@ -2015,60 +2057,6 @@
2015
2057
  console.error(e);
2016
2058
  }
2017
2059
 
2018
- function deepExtend(origin) {
2019
- var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2020
- var mode = arguments.length > 2 ? arguments[2] : undefined;
2021
- var isArr = false;
2022
-
2023
- for (var key in target) {
2024
- if (Object.prototype.hasOwnProperty.call(target, key)) {
2025
- var clone = target[key];
2026
-
2027
- if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
2028
- var nst = origin[key] === undefined;
2029
-
2030
- if (isArr) {
2031
- isArr = false;
2032
- nst && $set(origin, key, []);
2033
- } else if (clone._clone && mode !== undefined) {
2034
- if (mode) {
2035
- clone = clone.getRule();
2036
- nst && $set(origin, key, {});
2037
- } else {
2038
- $set(origin, key, clone._clone());
2039
- continue;
2040
- }
2041
- } else {
2042
- nst && $set(origin, key, {});
2043
- }
2044
-
2045
- origin[key] = deepExtend(origin[key], clone, mode);
2046
- } else {
2047
- $set(origin, key, clone);
2048
-
2049
- if (!is.Undef(clone)) {
2050
- if (!is.Undef(clone.__json)) {
2051
- origin[key].__json = clone.__json;
2052
- }
2053
-
2054
- if (!is.Undef(clone.__origin)) {
2055
- origin[key].__origin = clone.__origin;
2056
- }
2057
- }
2058
- }
2059
- }
2060
- }
2061
-
2062
- return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
2063
- return !v || !v.__ctrl;
2064
- }) : origin;
2065
- }
2066
- function deepCopy(value) {
2067
- return deepExtend({}, {
2068
- value: value
2069
- }).value;
2070
- }
2071
-
2072
2060
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2073
2061
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2074
2062
  var $T = '$FN:';
@@ -2077,30 +2065,24 @@
2077
2065
  function toJson(obj, space) {
2078
2066
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2079
2067
  if (val && val._isVue === true) return undefined;
2080
-
2081
2068
  if (_typeof(val) !== FUNCTION) {
2082
2069
  return val;
2083
2070
  }
2084
-
2085
2071
  if (val.__json) {
2086
2072
  return val.__json;
2087
2073
  }
2088
-
2089
2074
  if (val.__origin) val = val.__origin;
2090
2075
  if (val.__emit) return undefined;
2091
2076
  return PREFIX + val + SUFFIX;
2092
2077
  }, space);
2093
2078
  }
2094
-
2095
2079
  function makeFn(fn) {
2096
2080
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2097
2081
  }
2098
-
2099
2082
  function parseFn(fn, mode) {
2100
2083
  if (fn && is.String(fn) && fn.length > 4) {
2101
2084
  var v = fn.trim();
2102
2085
  var flag = false;
2103
-
2104
2086
  try {
2105
2087
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2106
2088
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2116,7 +2098,6 @@
2116
2098
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2117
2099
  flag = true;
2118
2100
  }
2119
-
2120
2101
  if (!flag) return fn;
2121
2102
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2122
2103
  val.__json = fn;
@@ -2126,7 +2107,6 @@
2126
2107
  return undefined;
2127
2108
  }
2128
2109
  }
2129
-
2130
2110
  return fn;
2131
2111
  }
2132
2112
  function parseJson(json, mode) {
@@ -2143,8 +2123,7 @@
2143
2123
  configurable: false,
2144
2124
  writable: !!writable
2145
2125
  };
2146
- } //todo 优化位置
2147
-
2126
+ }
2148
2127
  function copyRule(rule) {
2149
2128
  return copyRules([rule])[0];
2150
2129
  }
@@ -2189,7 +2168,6 @@
2189
2168
  } catch (e) {
2190
2169
  logError(e);
2191
2170
  }
2192
-
2193
2171
  return def;
2194
2172
  }
2195
2173
 
@@ -2208,11 +2186,9 @@
2208
2186
  return function (title, field, value) {
2209
2187
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2210
2188
  var maker = new Creator(name, title, field, value, props);
2211
-
2212
2189
  if (init) {
2213
2190
  if (is.Function(init)) init(maker);else maker.props(init);
2214
2191
  }
2215
-
2216
2192
  return maker;
2217
2193
  };
2218
2194
  }
@@ -2277,13 +2253,11 @@
2277
2253
  function copy(value) {
2278
2254
  return deepCopy(value);
2279
2255
  }
2280
-
2281
2256
  function Api(h) {
2282
2257
  function tidyFields(fields) {
2283
2258
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2284
2259
  return fields;
2285
2260
  }
2286
-
2287
2261
  function props(fields, key, val) {
2288
2262
  tidyFields(fields).forEach(function (field) {
2289
2263
  h.getCtxs(field).forEach(function (ctx) {
@@ -2292,7 +2266,6 @@
2292
2266
  });
2293
2267
  });
2294
2268
  }
2295
-
2296
2269
  function allSubForm() {
2297
2270
  var subs = h.subForm;
2298
2271
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2302,39 +2275,32 @@
2302
2275
  return initial;
2303
2276
  }, []);
2304
2277
  }
2305
-
2306
2278
  var api = {
2307
2279
  get config() {
2308
2280
  return h.options;
2309
2281
  },
2310
-
2311
2282
  get options() {
2312
2283
  return h.options;
2313
2284
  },
2314
-
2315
2285
  get form() {
2316
2286
  return h.form;
2317
2287
  },
2318
-
2319
2288
  get rule() {
2320
2289
  return h.rules;
2321
2290
  },
2322
-
2323
2291
  get parent() {
2324
2292
  return h.vm.$pfc && h.vm.$pfc.$f;
2325
2293
  },
2326
-
2327
2294
  get children() {
2328
2295
  return allSubForm();
2329
2296
  },
2330
-
2331
2297
  formData: function formData(fields) {
2332
2298
  return tidyFields(fields).reduce(function (initial, id) {
2333
2299
  var ctx = h.getFieldCtx(id);
2334
2300
  if (!ctx) return initial;
2335
2301
  initial[ctx.field] = copy(ctx.rule.value);
2336
2302
  return initial;
2337
- }, copy(h.appendData));
2303
+ }, h.options.appendValue ? copy(h.appendData) : {});
2338
2304
  },
2339
2305
  getValue: function getValue(field) {
2340
2306
  var ctx = h.getFieldCtx(field);
@@ -2392,7 +2358,6 @@
2392
2358
  var index = h.sort.length - 1,
2393
2359
  rules;
2394
2360
  var ctx = h.getCtx(after);
2395
-
2396
2361
  if (ctx) {
2397
2362
  if (child) {
2398
2363
  rules = ctx.rule.children;
@@ -2402,14 +2367,12 @@
2402
2367
  rules = ctx.root;
2403
2368
  }
2404
2369
  } else rules = h.rules;
2405
-
2406
2370
  rules.splice(index + 1, 0, rule);
2407
2371
  },
2408
2372
  prepend: function prepend(rule, after, child) {
2409
2373
  var index = 0,
2410
2374
  rules;
2411
2375
  var ctx = h.getCtx(after);
2412
-
2413
2376
  if (ctx) {
2414
2377
  if (child) {
2415
2378
  rules = ctx.rule.children;
@@ -2418,7 +2381,6 @@
2418
2381
  rules = ctx.root;
2419
2382
  }
2420
2383
  } else rules = h.rules;
2421
-
2422
2384
  rules.splice(index, 0, rule);
2423
2385
  },
2424
2386
  hidden: function hidden(state, fields) {
@@ -2442,7 +2404,7 @@
2442
2404
  disabled: function disabled(_disabled, fields) {
2443
2405
  tidyFields(fields).forEach(function (field) {
2444
2406
  h.getCtxs(field).forEach(function (ctx) {
2445
- $set(ctx.rule.props, 'disabled', !!_disabled);
2407
+ ctx.rule.props && $set(ctx.rule.props, 'disabled', !!_disabled);
2446
2408
  });
2447
2409
  });
2448
2410
  h.refresh();
@@ -2491,18 +2453,14 @@
2491
2453
  });
2492
2454
  return;
2493
2455
  }
2494
-
2495
2456
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2496
-
2497
2457
  if (!ctxs) {
2498
2458
  return;
2499
2459
  }
2500
-
2501
2460
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2502
2461
  ctxs.forEach(function (ctx) {
2503
2462
  if (!ctx.deleted) {
2504
2463
  var subForm = h.subForm[ctx.id];
2505
-
2506
2464
  if (subForm) {
2507
2465
  if (Array.isArray(subForm)) {
2508
2466
  subForm.forEach(function (form) {
@@ -2511,9 +2469,7 @@
2511
2469
  } else if (subForm) {
2512
2470
  subForm.refresh();
2513
2471
  }
2514
- } //ctx.updateKey(true);
2515
-
2516
-
2472
+ }
2517
2473
  h.$render.clearCache(ctx);
2518
2474
  }
2519
2475
  });
@@ -2561,11 +2517,25 @@
2561
2517
  },
2562
2518
  getRule: function getRule(id, origin) {
2563
2519
  var ctx = h.getCtx(id);
2564
-
2565
2520
  if (ctx) {
2566
2521
  return origin ? ctx.origin : ctx.rule;
2567
2522
  }
2568
2523
  },
2524
+ setEffect: function setEffect(id, attr, value) {
2525
+ var ctx = h.getCtx(id);
2526
+ if (ctx && attr) {
2527
+ if (attr[0] === '$') {
2528
+ attr = attr.substr(1);
2529
+ }
2530
+ if (hasProperty(ctx.rule, '$' + attr)) {
2531
+ $set(ctx.rule, '$' + attr, value);
2532
+ }
2533
+ if (!hasProperty(ctx.rule, 'effect')) {
2534
+ ctx.rule.effect = {};
2535
+ }
2536
+ $set(ctx.rule.effect, attr, value);
2537
+ }
2538
+ },
2569
2539
  updateValidate: function updateValidate(id, validate, merge) {
2570
2540
  if (merge) {
2571
2541
  api.mergeRule(id, {
@@ -2604,7 +2574,6 @@
2604
2574
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2605
2575
  args[_key - 2] = arguments[_key];
2606
2576
  }
2607
-
2608
2577
  return invoke(function () {
2609
2578
  return api.method(id, name).apply(void 0, args);
2610
2579
  });
@@ -2614,11 +2583,9 @@
2614
2583
  },
2615
2584
  trigger: function trigger(id, event) {
2616
2585
  var el = api.el(id);
2617
-
2618
2586
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2619
2587
  args[_key2 - 2] = arguments[_key2];
2620
2588
  }
2621
-
2622
2589
  el && el.$emit.apply(el, [event].concat(args));
2623
2590
  },
2624
2591
  el: function el(id) {
@@ -2643,11 +2610,9 @@
2643
2610
  },
2644
2611
  emit: function emit(name) {
2645
2612
  var _h$vm;
2646
-
2647
2613
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2648
2614
  args[_key3 - 1] = arguments[_key3];
2649
2615
  }
2650
-
2651
2616
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2652
2617
  },
2653
2618
  helper: {
@@ -2658,7 +2623,6 @@
2658
2623
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2659
2624
  api[n] = function () {
2660
2625
  var _h$vm2;
2661
-
2662
2626
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2663
2627
  };
2664
2628
  });
@@ -2676,11 +2640,9 @@
2676
2640
  ctx.parent && this.clearCache(ctx.parent);
2677
2641
  return;
2678
2642
  }
2679
-
2680
2643
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2681
2644
  this.$handle.refresh();
2682
2645
  }
2683
-
2684
2646
  var parent = this.cache[ctx.id].parent;
2685
2647
  this.cache[ctx.id] = null;
2686
2648
  parent && this.clearCache(parent);
@@ -2737,10 +2699,8 @@
2737
2699
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2738
2700
  _data[to] = {};
2739
2701
  }
2740
-
2741
2702
  _data = _data[to];
2742
2703
  }
2743
-
2744
2704
  to = v;
2745
2705
  });
2746
2706
  _data[to] = val;
@@ -2760,7 +2720,6 @@
2760
2720
  var children = ctxs[id].rule.children;
2761
2721
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2762
2722
  }
2763
-
2764
2723
  return initial;
2765
2724
  }, {});
2766
2725
  },
@@ -2769,59 +2728,46 @@
2769
2728
  },
2770
2729
  getTypeSlot: function getTypeSlot(type) {
2771
2730
  var name = 'type-' + toLine(type);
2772
-
2773
2731
  var _fn = function _fn(vm) {
2774
2732
  if (vm) {
2775
2733
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2776
-
2777
2734
  if (slot) {
2778
2735
  return slot;
2779
2736
  }
2780
-
2781
2737
  return _fn(vm.$pfc);
2782
2738
  }
2783
2739
  };
2784
-
2785
2740
  return _fn(this.vm);
2786
2741
  },
2787
2742
  render: function render() {
2788
2743
  var _this = this;
2789
-
2790
2744
  if (!this.vm.isShow) {
2791
2745
  return;
2792
2746
  }
2793
-
2794
2747
  this.$h = this.vm.$createElement;
2795
2748
  this.$manager.beforeRender();
2796
2749
  var vn;
2797
-
2798
2750
  var make = function make() {
2799
2751
  return _this.renderList();
2800
2752
  };
2801
-
2802
2753
  make.renderSlot = function (slot) {
2803
2754
  return _this.renderList(slot);
2804
2755
  };
2805
-
2806
2756
  make.renderName = function (name) {
2807
2757
  return _this.renderId(name);
2808
2758
  };
2809
-
2810
2759
  make.renderField = function (field) {
2811
2760
  return _this.renderId(field, 'field');
2812
2761
  };
2813
-
2814
2762
  if (this.vm.$scopedSlots.container) {
2815
2763
  vn = [this.vm.$scopedSlots.container(make)];
2816
2764
  } else {
2817
2765
  vn = make();
2818
2766
  }
2819
-
2820
2767
  return this.$manager.render(vn);
2821
2768
  },
2822
2769
  renderList: function renderList(slot) {
2823
2770
  var _this2 = this;
2824
-
2825
2771
  return this.sort.map(function (id) {
2826
2772
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2827
2773
  }).filter(function (val) {
@@ -2830,7 +2776,6 @@
2830
2776
  },
2831
2777
  makeVm: function makeVm(rule) {
2832
2778
  var _this3 = this;
2833
-
2834
2779
  var vm = rule.vm;
2835
2780
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2836
2781
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2839,8 +2784,7 @@
2839
2784
  },
2840
2785
  mergeGlobal: function mergeGlobal(ctx) {
2841
2786
  var g = this.$handle.options.global;
2842
- if (!g) return; //todo 缓存配置,更新 option 更新
2843
-
2787
+ if (!g) return;
2844
2788
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2845
2789
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2846
2790
  },
@@ -2867,23 +2811,19 @@
2867
2811
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2868
2812
  });
2869
2813
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2870
-
2871
2814
  if (keys.indexOf(key) > -1) {
2872
2815
  vm.$props[key] = prop.value;
2873
2816
  }
2874
2817
  },
2875
2818
  renderTemp: function renderTemp(ctx) {
2876
2819
  var _this4 = this;
2877
-
2878
2820
  if (!_vue.compile) {
2879
2821
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2880
2822
  return [];
2881
2823
  }
2882
-
2883
2824
  var rule = ctx.prop;
2884
2825
  var id = ctx.id,
2885
2826
  key = ctx.key;
2886
-
2887
2827
  if (!this.tempList[id]) {
2888
2828
  if (!ctx.el) {
2889
2829
  ctx.el = this.makeVm(rule);
@@ -2891,7 +2831,6 @@
2891
2831
  return ctx.parser.mounted(ctx);
2892
2832
  });
2893
2833
  }
2894
-
2895
2834
  var _vm = ctx.el;
2896
2835
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2897
2836
  _this4.onInput(ctx, value);
@@ -2901,7 +2840,6 @@
2901
2840
  template: _vue.compile(rule.template)
2902
2841
  };
2903
2842
  }
2904
-
2905
2843
  var _this$tempList$id = this.tempList[id],
2906
2844
  vm = _this$tempList$id.vm,
2907
2845
  template = _this$tempList$id.template;
@@ -2925,7 +2863,6 @@
2925
2863
  },
2926
2864
  renderId: function renderId(name, type) {
2927
2865
  var _this5 = this;
2928
-
2929
2866
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2930
2867
  return ctxs ? ctxs.map(function (ctx) {
2931
2868
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2934,21 +2871,16 @@
2934
2871
  renderCtx: function renderCtx(ctx, parent) {
2935
2872
  if (ctx.type === 'hidden') return;
2936
2873
  var rule = ctx.rule;
2937
- var preview = this.options.preview || false;
2938
-
2939
2874
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2940
2875
  var vn;
2941
- var cacheFlag = true;
2876
+ var cacheFlag = rule.cache !== false;
2942
2877
  var _type = ctx.trueType;
2943
2878
  var none = !(is.Undef(rule.display) || !!rule.display);
2944
-
2945
2879
  if (_type === 'template' && !rule.template) {
2946
2880
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2947
-
2948
2881
  if (none) {
2949
2882
  this.display(vn);
2950
2883
  }
2951
-
2952
2884
  vn = this.item(ctx, vn);
2953
2885
  } else if (_type === 'fcFragment') {
2954
2886
  vn = this.renderChildren(ctx);
@@ -2960,27 +2892,24 @@
2960
2892
  this.setOptions(ctx);
2961
2893
  this.ctxProp(ctx);
2962
2894
  var prop = ctx.prop;
2895
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
2963
2896
  prop.props.formCreateInject = this.injectProp(ctx);
2964
-
2897
+ var preview = prop.preview;
2965
2898
  if (prop.hidden) {
2966
2899
  this.setCache(ctx, undefined, parent);
2967
2900
  return;
2968
2901
  }
2969
-
2970
2902
  if (_type === 'template' && prop.template) {
2971
2903
  vn = this.renderTemp(ctx);
2972
2904
  cacheFlag = false;
2973
2905
  } else {
2974
2906
  var children = [];
2975
-
2976
2907
  if (ctx.parser.renderChildren) {
2977
2908
  children = ctx.parser.renderChildren(ctx);
2978
2909
  } else if (ctx.parser.loadChildren !== false) {
2979
2910
  children = this.renderChildren(ctx);
2980
2911
  }
2981
-
2982
2912
  var slot = this.getTypeSlot(ctx.type);
2983
-
2984
2913
  if (slot) {
2985
2914
  vn = slot({
2986
2915
  rule: rule,
@@ -2994,32 +2923,24 @@
2994
2923
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
2995
2924
  }
2996
2925
  }
2997
-
2998
2926
  vn = this.renderSides(vn, ctx);
2999
-
3000
2927
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3001
2928
  vn = this.$manager.makeWrap(ctx, vn);
3002
2929
  }
3003
-
3004
2930
  if (none) {
3005
2931
  vn = this.display(vn);
3006
2932
  }
3007
-
3008
2933
  vn = this.item(ctx, vn);
3009
2934
  }
3010
-
3011
2935
  if (cacheFlag) {
3012
2936
  this.setCache(ctx, vn, parent);
3013
2937
  }
3014
-
3015
2938
  return vn;
3016
2939
  }
3017
-
3018
2940
  return this.getCache(ctx);
3019
2941
  },
3020
2942
  display: function display(vn) {
3021
2943
  var _this6 = this;
3022
-
3023
2944
  if (Array.isArray(vn)) {
3024
2945
  var data = [];
3025
2946
  vn.forEach(function (v) {
@@ -3042,7 +2963,6 @@
3042
2963
  display: 'none'
3043
2964
  }];
3044
2965
  }
3045
-
3046
2966
  return vn;
3047
2967
  }
3048
2968
  },
@@ -3054,7 +2974,6 @@
3054
2974
  },
3055
2975
  injectProp: function injectProp(ctx) {
3056
2976
  var _this7 = this;
3057
-
3058
2977
  if (!this.vm.ctxInject[ctx.id]) {
3059
2978
  $set(this.vm.ctxInject, ctx.id, {
3060
2979
  api: this.$handle.api,
@@ -3062,23 +2981,25 @@
3062
2981
  subForm: function subForm(_subForm) {
3063
2982
  _this7.$handle.addSubForm(ctx, _subForm);
3064
2983
  },
2984
+ getSubForm: function getSubForm() {
2985
+ return _this7.$handle.subForm[ctx.id];
2986
+ },
3065
2987
  options: [],
3066
2988
  children: [],
3067
2989
  prop: {},
3068
2990
  preview: false,
3069
2991
  field: ctx.field,
3070
- rule: ctx.rule
2992
+ rule: ctx.rule,
2993
+ input: ctx.input
3071
2994
  });
3072
2995
  }
3073
-
3074
2996
  var inject = this.vm.ctxInject[ctx.id];
3075
2997
  extend(inject, {
3076
- preview: this.options.preview || false,
2998
+ preview: ctx.prop.preview,
3077
2999
  options: ctx.prop.options,
3078
3000
  children: ctx.rule.children,
3079
3001
  prop: function () {
3080
3002
  var temp = _objectSpread2({}, ctx.prop);
3081
-
3082
3003
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3083
3004
  delete temp.model;
3084
3005
  return temp;
@@ -3088,7 +3009,6 @@
3088
3009
  },
3089
3010
  ctxProp: function ctxProp(ctx, custom) {
3090
3011
  var _this8 = this;
3091
-
3092
3012
  var ref = ctx.ref,
3093
3013
  key = ctx.key,
3094
3014
  rule = ctx.rule;
@@ -3107,29 +3027,23 @@
3107
3027
  }
3108
3028
  }
3109
3029
  }];
3110
-
3111
3030
  if (!custom && ctx.input) {
3112
- props.push({
3113
- model: {
3114
- value: this.$handle.getFormData(ctx),
3115
- callback: function callback(value) {
3116
- _this8.onInput(ctx, value);
3117
- },
3118
- expression: "formData.".concat(ctx.id)
3119
- }
3120
- });
3031
+ ctx.prop.model = {
3032
+ value: this.$handle.getFormData(ctx),
3033
+ callback: function callback(value) {
3034
+ _this8.onInput(ctx, value);
3035
+ },
3036
+ expression: "formData.".concat(ctx.id)
3037
+ };
3121
3038
  }
3122
-
3123
3039
  mergeProps(props, ctx.prop);
3124
3040
  return ctx.prop;
3125
3041
  },
3126
3042
  onMounted: function onMounted(ctx) {
3127
3043
  ctx.el = this.vm.$refs[ctx.ref];
3128
-
3129
3044
  if (ctx.el) {
3130
3045
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3131
3046
  }
3132
-
3133
3047
  ctx.parser.mounted(ctx);
3134
3048
  this.$handle.effect(ctx, 'mounted');
3135
3049
  },
@@ -3138,19 +3052,15 @@
3138
3052
  },
3139
3053
  renderChildren: function renderChildren(ctx) {
3140
3054
  var _this9 = this;
3141
-
3142
3055
  var children = ctx.rule.children,
3143
3056
  orgChildren = this.orgChildren[ctx.id];
3144
-
3145
3057
  var isRm = function isRm(child) {
3146
3058
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3147
3059
  };
3148
-
3149
3060
  if (!is.trueArray(children) && orgChildren) {
3150
3061
  this.$handle.deferSyncValue(function () {
3151
3062
  orgChildren.forEach(function (child) {
3152
3063
  if (!child) return;
3153
-
3154
3064
  if (isRm(child)) {
3155
3065
  _this9.$handle.rmCtx(child.__fc__);
3156
3066
  }
@@ -3159,11 +3069,9 @@
3159
3069
  this.orgChildren[ctx.id] = [];
3160
3070
  return [];
3161
3071
  }
3162
-
3163
3072
  orgChildren && this.$handle.deferSyncValue(function () {
3164
3073
  orgChildren.forEach(function (child) {
3165
3074
  if (!child) return;
3166
-
3167
3075
  if (children.indexOf(child) === -1 && isRm(child)) {
3168
3076
  _this9.$handle.rmCtx(child.__fc__);
3169
3077
  }
@@ -3172,15 +3080,12 @@
3172
3080
  return children.map(function (child) {
3173
3081
  if (!child) return;
3174
3082
  if (is.String(child)) return child;
3175
-
3176
3083
  if (child.__fc__) {
3177
3084
  return _this9.renderCtx(child.__fc__, ctx);
3178
3085
  }
3179
-
3180
3086
  if (child.type) {
3181
3087
  _this9.vm.$nextTick(function () {
3182
3088
  _this9.$handle.loadChildren(children, ctx);
3183
-
3184
3089
  _this9.$handle.refresh();
3185
3090
  });
3186
3091
  }
@@ -3188,38 +3093,33 @@
3188
3093
  },
3189
3094
  defaultRender: function defaultRender(ctx, children) {
3190
3095
  var prop = ctx.prop;
3096
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3191
3097
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3192
3098
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3193
3099
  return this.vNode.make(lower(ctx.originType), prop, children);
3194
3100
  },
3195
3101
  renderRule: function renderRule(rule, children, origin) {
3196
3102
  var _this10 = this;
3197
-
3198
3103
  if (!rule) return undefined;
3199
3104
  if (is.String(rule)) return rule;
3200
3105
  var type;
3201
-
3202
3106
  if (origin) {
3203
3107
  type = rule.type;
3204
3108
  } else {
3205
3109
  type = rule.is;
3206
-
3207
3110
  if (rule.type) {
3208
3111
  type = toCase(rule.type);
3209
3112
  var alias = this.vNode.aliasMap[type];
3210
3113
  if (alias) type = toCase(alias);
3211
3114
  }
3212
3115
  }
3213
-
3214
3116
  if (!type) return undefined;
3215
3117
  var data = [[children]];
3216
-
3217
3118
  if (is.trueArray(rule.children)) {
3218
3119
  data.push(rule.children.map(function (v) {
3219
3120
  return _this10.renderRule(v);
3220
3121
  }));
3221
3122
  }
3222
-
3223
3123
  return this.$h(type, _objectSpread2({}, rule), data);
3224
3124
  }
3225
3125
  });
@@ -3255,10 +3155,8 @@
3255
3155
  },
3256
3156
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3257
3157
  var _this = this;
3258
-
3259
3158
  Object.keys(data).forEach(function (k) {
3260
3159
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3261
-
3262
3160
  if (fn) {
3263
3161
  data[k] = fn;
3264
3162
  }
@@ -3272,7 +3170,6 @@
3272
3170
  return this.parseEventLst(rule, fn, inject, true);
3273
3171
  } else if (is.String(fn)) {
3274
3172
  var val = parseFn(fn);
3275
-
3276
3173
  if (val && fn !== val) {
3277
3174
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3278
3175
  }
@@ -3280,7 +3177,6 @@
3280
3177
  },
3281
3178
  parseEmit: function parseEmit(ctx, on) {
3282
3179
  var _this2 = this;
3283
-
3284
3180
  var event = {},
3285
3181
  rule = ctx.rule,
3286
3182
  emitPrefix = rule.emitPrefix,
@@ -3288,48 +3184,36 @@
3288
3184
  name = rule.name,
3289
3185
  inject = rule.inject;
3290
3186
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3291
-
3292
3187
  if (is.trueArray(emit)) {
3293
3188
  var emitKey = emitPrefix || field || name;
3294
-
3295
3189
  if (emitKey) {
3296
3190
  if (!on) emitKey = "native-".concat(emitKey);
3297
3191
  emit.forEach(function (eventName) {
3298
3192
  if (!eventName) return;
3299
3193
  var eventInject;
3300
-
3301
3194
  if (is.Object(eventName)) {
3302
3195
  eventInject = eventName.inject;
3303
3196
  eventName = eventName.name;
3304
3197
  }
3305
-
3306
3198
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3307
-
3308
3199
  var fn = function fn() {
3309
3200
  var _this2$vm, _this2$vm2;
3310
-
3311
3201
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3312
3202
  arg[_key] = arguments[_key];
3313
3203
  }
3314
-
3315
3204
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3316
-
3317
3205
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3318
3206
  };
3319
-
3320
3207
  fn.__emit = true;
3321
-
3322
3208
  if (!eventInject && inject === false) {
3323
3209
  event[eventName] = fn;
3324
3210
  } else {
3325
3211
  var _inject = eventInject || inject || _this2.options.injectEvent;
3326
-
3327
3212
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3328
3213
  }
3329
3214
  });
3330
3215
  }
3331
3216
  }
3332
-
3333
3217
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3334
3218
  return event;
3335
3219
  },
@@ -3351,21 +3235,16 @@
3351
3235
  if (this.watching && !this.loading) return _fn;
3352
3236
  _fn = _fn.__origin;
3353
3237
  }
3354
-
3355
3238
  var h = this;
3356
-
3357
3239
  var fn = function fn() {
3358
3240
  var data = h.getInjectData(self, _inject2);
3359
-
3360
3241
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3361
3242
  args[_key2] = arguments[_key2];
3362
3243
  }
3363
-
3364
3244
  data.args = [].concat(args);
3365
3245
  args.unshift(data);
3366
3246
  return _fn.apply(this, args);
3367
3247
  };
3368
-
3369
3248
  fn.__origin = _fn;
3370
3249
  fn.__json = _fn.__json;
3371
3250
  return fn;
@@ -3378,17 +3257,14 @@
3378
3257
  extend(Handler.prototype, {
3379
3258
  usePage: function usePage() {
3380
3259
  var _this = this;
3381
-
3382
3260
  var page = this.options.page;
3383
3261
  if (!page) return;
3384
3262
  var first = 25;
3385
3263
  var limit = getLimit(this.rules);
3386
-
3387
3264
  if (is.Object(page)) {
3388
3265
  if (page.first) first = parseInt(page.first, 10) || first;
3389
3266
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3390
3267
  }
3391
-
3392
3268
  extend(this, {
3393
3269
  first: first,
3394
3270
  limit: limit,
@@ -3401,27 +3277,21 @@
3401
3277
  },
3402
3278
  pageLoad: function pageLoad() {
3403
3279
  var _this2 = this;
3404
-
3405
3280
  var pageFn = function pageFn() {
3406
3281
  if (_this2.pageEnd) {
3407
3282
  _this2.vm.$off(EVENT, pageFn);
3408
-
3409
3283
  _this2.bus.$emit('page-end');
3410
3284
  } else {
3411
3285
  _this2.first += _this2.limit;
3412
3286
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3413
-
3414
3287
  _this2.loadRule();
3415
-
3416
3288
  _this2.refresh();
3417
3289
  }
3418
3290
  };
3419
-
3420
3291
  this.vm.$on(EVENT, pageFn);
3421
3292
  }
3422
3293
  });
3423
3294
  }
3424
-
3425
3295
  function getLimit(rules) {
3426
3296
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3427
3297
  }
@@ -3434,7 +3304,6 @@
3434
3304
  },
3435
3305
  bindNextTick: function bindNextTick(fn) {
3436
3306
  var _this = this;
3437
-
3438
3307
  this.clearNextTick();
3439
3308
  this.nextTick = setTimeout(function () {
3440
3309
  fn();
@@ -3442,7 +3311,6 @@
3442
3311
  }, 10);
3443
3312
  },
3444
3313
  render: function render() {
3445
- // console.warn('%c render', 'color:green');
3446
3314
  ++this.loadedId;
3447
3315
  if (this.vm.unique > 0) return this.$render.render();else {
3448
3316
  this.vm.unique = 1;
@@ -3457,7 +3325,6 @@
3457
3325
  __fc__: enumerable(ctx, true)
3458
3326
  });
3459
3327
  }
3460
-
3461
3328
  function RuleContext(handle, rule) {
3462
3329
  var id = uniqueId();
3463
3330
  extend(this, {
@@ -3491,7 +3358,6 @@
3491
3358
  if (!this.payload[name]) {
3492
3359
  this.payload[name] = {};
3493
3360
  }
3494
-
3495
3361
  return this.payload[name];
3496
3362
  },
3497
3363
  clearEffectData: function clearEffectData(name) {
@@ -3511,9 +3377,7 @@
3511
3377
  },
3512
3378
  initProp: function initProp() {
3513
3379
  var _this = this;
3514
-
3515
3380
  var rule = _objectSpread2({}, this.rule);
3516
-
3517
3381
  delete rule.children;
3518
3382
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3519
3383
  return _this.payload[k];
@@ -3568,31 +3432,22 @@
3568
3432
  },
3569
3433
  rm: function rm() {
3570
3434
  var _this2 = this;
3571
-
3572
3435
  var _rm = function _rm() {
3573
3436
  var index = _this2.root.indexOf(_this2.origin);
3574
-
3575
3437
  if (index > -1) {
3576
3438
  _this2.root.splice(index, 1);
3577
-
3578
3439
  _this2.$handle && _this2.$handle.refresh();
3579
3440
  }
3580
3441
  };
3581
-
3582
3442
  if (this.deleted) {
3583
3443
  _rm();
3584
-
3585
3444
  return;
3586
3445
  }
3587
-
3588
3446
  this.$handle.noWatch(function () {
3589
3447
  _this2.$handle.deferSyncValue(function () {
3590
3448
  _this2.rmCtrl();
3591
-
3592
3449
  _rm();
3593
-
3594
3450
  _this2.$handle.rmCtx(_this2);
3595
-
3596
3451
  extend(_this2, {
3597
3452
  root: []
3598
3453
  });
@@ -3620,7 +3475,6 @@
3620
3475
  extend(Handler.prototype, {
3621
3476
  nextRefresh: function nextRefresh(fn) {
3622
3477
  var _this = this;
3623
-
3624
3478
  var id = this.loadedId;
3625
3479
  this.vm.$nextTick(function () {
3626
3480
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3628,7 +3482,6 @@
3628
3482
  },
3629
3483
  parseRule: function parseRule(_rule) {
3630
3484
  var _this2 = this;
3631
-
3632
3485
  var rule = getRule(_rule);
3633
3486
  Object.defineProperties(rule, {
3634
3487
  __origin__: enumerable(_rule, true)
@@ -3640,20 +3493,16 @@
3640
3493
  if (!item) {
3641
3494
  return;
3642
3495
  }
3643
-
3644
3496
  _this2.loadFn(item, rule);
3645
3497
  });
3646
3498
  this.loadCtrl(rule);
3647
-
3648
3499
  if (rule.update) {
3649
3500
  rule.update = parseFn(rule.update);
3650
3501
  }
3651
-
3652
3502
  return rule;
3653
3503
  },
3654
3504
  loadFn: function loadFn(item, rule) {
3655
3505
  var _this3 = this;
3656
-
3657
3506
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3658
3507
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3659
3508
  });
@@ -3667,48 +3516,35 @@
3667
3516
  },
3668
3517
  syncProp: function syncProp(ctx) {
3669
3518
  var _this4 = this;
3670
-
3671
3519
  var rule = ctx.rule;
3672
3520
  is.trueArray(rule.sync) && mergeProps([{
3673
3521
  on: rule.sync.reduce(function (pre, prop) {
3674
3522
  pre["update:".concat(prop)] = function (val) {
3675
3523
  rule.props[prop] = val;
3676
-
3677
3524
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3678
3525
  };
3679
-
3680
3526
  return pre;
3681
3527
  }, {})
3682
3528
  }], ctx.computed);
3683
3529
  },
3684
3530
  loadRule: function loadRule() {
3685
3531
  var _this5 = this;
3686
-
3687
- // console.warn('%c load', 'color:blue');
3688
3532
  this.cycleLoad = false;
3689
3533
  this.loading = true;
3690
-
3691
3534
  if (this.pageEnd) {
3692
3535
  this.bus.$emit('load-start');
3693
3536
  }
3694
-
3695
3537
  this.deferSyncValue(function () {
3696
3538
  _this5._loadRule(_this5.rules);
3697
-
3698
3539
  _this5.loading = false;
3699
-
3700
3540
  if (_this5.cycleLoad && _this5.pageEnd) {
3701
3541
  return _this5.loadRule();
3702
3542
  }
3703
-
3704
3543
  if (_this5.pageEnd) {
3705
3544
  _this5.bus.$emit('load-end');
3706
3545
  }
3707
-
3708
3546
  _this5.vm._renderRule();
3709
-
3710
3547
  _this5.$render.initOrgChildren();
3711
-
3712
3548
  _this5.syncForm();
3713
3549
  });
3714
3550
  },
@@ -3716,79 +3552,60 @@
3716
3552
  this.cycleLoad = false;
3717
3553
  this.loading = true;
3718
3554
  this.bus.$emit('load-start');
3719
-
3720
3555
  this._loadRule(children, parent);
3721
-
3722
3556
  this.loading = false;
3723
-
3724
3557
  if (this.cycleLoad) {
3725
3558
  return this.loadRule();
3726
3559
  } else {
3727
3560
  this.bus.$emit('load-end');
3728
3561
  this.syncForm();
3729
3562
  }
3730
-
3731
3563
  this.$render.clearCache(parent);
3732
3564
  },
3733
3565
  _loadRule: function _loadRule(rules, parent) {
3734
3566
  var _this6 = this;
3735
-
3736
3567
  var preIndex = function preIndex(i) {
3737
3568
  var pre = rules[i - 1];
3738
-
3739
3569
  if (!pre || !pre.__fc__) {
3740
3570
  return i > 0 ? preIndex(i - 1) : -1;
3741
3571
  }
3742
-
3743
3572
  var index = _this6.sort.indexOf(pre.__fc__.id);
3744
-
3745
3573
  return index > -1 ? index : preIndex(i - 1);
3746
3574
  };
3747
-
3748
3575
  var loadChildren = function loadChildren(children, parent) {
3749
3576
  if (is.trueArray(children)) {
3750
3577
  _this6._loadRule(children, parent);
3751
3578
  }
3752
3579
  };
3753
-
3754
3580
  rules.map(function (_rule, index) {
3755
3581
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3756
3582
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3757
3583
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3758
-
3759
3584
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3760
3585
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3761
3586
  return _rule.__fc__;
3762
3587
  }
3763
-
3764
3588
  var rule = getRule(_rule);
3765
-
3766
3589
  var isRepeat = function isRepeat() {
3767
3590
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3768
3591
  };
3769
-
3770
3592
  _this6.ruleEffect(rule, 'init', {
3771
3593
  repeat: isRepeat()
3772
3594
  });
3773
-
3774
3595
  if (isRepeat()) {
3775
3596
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3776
3597
  }
3777
-
3778
3598
  var ctx;
3779
3599
  var isCopy = false;
3780
3600
  var isInit = !!_rule.__fc__;
3781
-
3782
3601
  if (isInit) {
3783
3602
  ctx = _rule.__fc__;
3784
3603
  var check = !ctx.check(_this6);
3785
-
3786
3604
  if (ctx.deleted) {
3787
3605
  if (check) {
3788
3606
  if (isCtrl(ctx)) {
3789
3607
  return;
3790
3608
  }
3791
-
3792
3609
  ctx.update(_this6);
3793
3610
  }
3794
3611
  } else {
@@ -3796,66 +3613,49 @@
3796
3613
  if (isCtrl(ctx)) {
3797
3614
  return;
3798
3615
  }
3799
-
3800
3616
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3801
3617
  ctx = null;
3802
3618
  isCopy = true;
3803
3619
  }
3804
3620
  }
3805
3621
  }
3806
-
3807
3622
  if (!ctx) {
3808
3623
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3809
-
3810
3624
  _this6.bindParser(ctx);
3811
3625
  } else {
3812
3626
  if (ctx.originType !== ctx.rule.type) {
3813
3627
  ctx.updateType();
3814
-
3815
3628
  _this6.bindParser(ctx);
3816
3629
  }
3817
-
3818
3630
  _this6.appendValue(ctx.rule);
3819
3631
  }
3820
-
3821
3632
  [false, true].forEach(function (b) {
3822
3633
  return _this6.parseEmit(ctx, b);
3823
3634
  });
3824
-
3825
3635
  _this6.syncProp(ctx);
3826
-
3827
3636
  ctx.parent = parent || null;
3828
3637
  ctx.root = rules;
3829
-
3830
3638
  _this6.setCtx(ctx);
3831
-
3832
3639
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3833
3640
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3834
-
3835
3641
  if (!parent) {
3836
3642
  var _preIndex = preIndex(index);
3837
-
3838
3643
  if (_preIndex > -1 || !index) {
3839
3644
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3840
3645
  } else {
3841
3646
  _this6.sort.push(ctx.id);
3842
3647
  }
3843
3648
  }
3844
-
3845
3649
  var r = ctx.rule;
3846
-
3847
3650
  if (!ctx.updated) {
3848
3651
  ctx.updated = true;
3849
-
3850
3652
  if (is.Function(r.update)) {
3851
3653
  _this6.bus.$once('load-end', function () {
3852
3654
  _this6.refreshUpdate(ctx, r.value);
3853
3655
  });
3854
3656
  }
3855
-
3856
3657
  _this6.effect(ctx, 'loaded');
3857
3658
  }
3858
-
3859
3659
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3860
3660
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3861
3661
  return ctx;
@@ -3866,20 +3666,16 @@
3866
3666
  },
3867
3667
  useCtrl: function useCtrl(ctx) {
3868
3668
  var _this7 = this;
3869
-
3870
3669
  var controls = getCtrl(ctx),
3871
3670
  validate = [],
3872
3671
  api = this.api;
3873
3672
  if (!controls.length) return false;
3874
-
3875
3673
  var _loop = function _loop(i) {
3876
3674
  var control = controls[i],
3877
3675
  handleFn = control.handle || function (val) {
3878
3676
  return val === control.value;
3879
3677
  };
3880
-
3881
3678
  if (!is.trueArray(control.rule)) return "continue";
3882
-
3883
3679
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3884
3680
  valid: invoke(function () {
3885
3681
  return handleFn(ctx.rule.value, api);
@@ -3887,17 +3683,13 @@
3887
3683
  ctrl: findCtrl(ctx, control.rule),
3888
3684
  isHidden: is.String(control.rule[0])
3889
3685
  });
3890
-
3891
3686
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3892
3687
  validate.push(data);
3893
3688
  };
3894
-
3895
3689
  for (var i = 0; i < controls.length; i++) {
3896
3690
  var _ret = _loop(i);
3897
-
3898
3691
  if (_ret === "continue") continue;
3899
3692
  }
3900
-
3901
3693
  if (!validate.length) return false;
3902
3694
  var flag = false;
3903
3695
  this.deferSyncValue(function () {
@@ -3909,21 +3701,17 @@
3909
3701
  append = _ref.append,
3910
3702
  child = _ref.child,
3911
3703
  ctrl = _ref.ctrl;
3912
-
3913
3704
  if (isHidden) {
3914
3705
  valid ? ctx.ctrlRule.push({
3915
3706
  __ctrl: true,
3916
3707
  children: rule,
3917
3708
  valid: valid
3918
3709
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3919
-
3920
3710
  _this7.vm.$nextTick(function () {
3921
3711
  _this7.api.hidden(!valid, rule);
3922
3712
  });
3923
-
3924
3713
  return;
3925
3714
  }
3926
-
3927
3715
  if (valid) {
3928
3716
  flag = true;
3929
3717
  var ruleCon = {
@@ -3933,9 +3721,7 @@
3933
3721
  children: rule
3934
3722
  };
3935
3723
  ctx.ctrlRule.push(ruleCon);
3936
-
3937
3724
  _this7.bus.$once('load-start', function () {
3938
- // this.cycleLoad = true;
3939
3725
  if (prepend) {
3940
3726
  api.prepend(ruleCon, prepend, child);
3941
3727
  } else if (append || child) {
@@ -3960,60 +3746,53 @@
3960
3746
  },
3961
3747
  _reloadRule: function _reloadRule(rules) {
3962
3748
  var _this8 = this;
3963
-
3964
- // console.warn('%c reload', 'color:red');
3965
3749
  if (!rules) rules = this.rules;
3966
-
3967
3750
  var ctxs = _objectSpread2({}, this.ctxs);
3968
-
3969
3751
  this.clearNextTick();
3970
3752
  this.$render.clearOrgChildren();
3971
3753
  this.initData(rules);
3972
3754
  this.fc.rules = rules;
3973
- this.bus.$once('load-end', function () {
3974
- Object.keys(ctxs).filter(function (id) {
3975
- return _this8.ctxs[id] === undefined;
3976
- }).forEach(function (id) {
3977
- return _this8.rmCtx(ctxs[id]);
3755
+ this.deferSyncValue(function () {
3756
+ _this8.bus.$once('load-end', function () {
3757
+ Object.keys(ctxs).filter(function (id) {
3758
+ return _this8.ctxs[id] === undefined;
3759
+ }).forEach(function (id) {
3760
+ return _this8.rmCtx(ctxs[id]);
3761
+ });
3762
+ _this8.$render.clearCacheAll();
3978
3763
  });
3979
-
3980
- _this8.$render.clearCacheAll();
3764
+ _this8.reloading = true;
3765
+ _this8.loadRule();
3766
+ _this8.reloading = false;
3767
+ _this8.refresh();
3768
+ _this8.vm.$emit('reload', _this8.api);
3981
3769
  });
3982
- this.reloading = true;
3983
- this.loadRule();
3984
- this.reloading = false;
3985
- this.refresh();
3986
3770
  this.bus.$off('next-tick', this.nextReload);
3987
3771
  this.bus.$once('next-tick', this.nextReload);
3988
3772
  this.vm.$emit('update', this.api);
3989
3773
  },
3990
- //todo 组件生成全部通过 alias
3991
3774
  refresh: function refresh() {
3992
3775
  this.vm._refresh();
3993
3776
  }
3994
3777
  });
3995
3778
  }
3996
-
3997
3779
  function fullRule(rule) {
3998
3780
  var def = baseRule();
3999
3781
  Object.keys(def).forEach(function (k) {
4000
- if (!hasProperty(rule, k)) rule[k] = def[k];
3782
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4001
3783
  });
4002
3784
  return rule;
4003
3785
  }
4004
-
4005
3786
  function getCtrl(ctx) {
4006
3787
  var control = ctx.rule.control || [];
4007
3788
  if (is.Object(control)) return [control];else return control;
4008
3789
  }
4009
-
4010
3790
  function findCtrl(ctx, rule) {
4011
3791
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4012
3792
  var ctrl = ctx.ctrlRule[i];
4013
3793
  if (ctrl.children === rule) return ctrl;
4014
3794
  }
4015
3795
  }
4016
-
4017
3796
  function isCtrl(ctx) {
4018
3797
  return !!ctx.rule.__ctrl;
4019
3798
  }
@@ -4024,7 +3803,6 @@
4024
3803
  if (is.Undef(ctx.cacheValue)) {
4025
3804
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4026
3805
  }
4027
-
4028
3806
  return ctx.cacheValue;
4029
3807
  },
4030
3808
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4036,25 +3814,23 @@
4036
3814
  this.setFormData(ctx, formValue);
4037
3815
  this.syncValue();
4038
3816
  this.valueChange(ctx, value);
4039
- this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag);
3817
+ this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
4040
3818
  this.effect(ctx, 'value');
4041
3819
  },
4042
3820
  onInput: function onInput(ctx, value) {
4043
3821
  var val;
4044
-
4045
3822
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4046
3823
  this.setValue(ctx, val, value);
4047
3824
  }
4048
3825
  },
4049
3826
  setFormData: function setFormData(ctx, value) {
4050
- $set(this.formData, ctx.id, value);
3827
+ $set(this.formData, ctx.id, value === null ? undefined : value);
4051
3828
  },
4052
3829
  getFormData: function getFormData(ctx) {
4053
3830
  return this.formData[ctx.id];
4054
3831
  },
4055
3832
  validate: function validate() {
4056
3833
  var _this = this;
4057
-
4058
3834
  toEmpty(this.vm.validate);
4059
3835
  this.fields().forEach(function (id) {
4060
3836
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4065,17 +3841,14 @@
4065
3841
  },
4066
3842
  syncForm: function syncForm() {
4067
3843
  var _this2 = this;
4068
-
4069
3844
  toEmpty(this.form);
4070
3845
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4071
3846
  var ctx = _this2.getFieldCtx(field);
4072
-
4073
3847
  var handle = _this2.valueHandle(ctx);
4074
-
4075
3848
  handle.configurable = true;
4076
3849
  initial[field] = handle;
4077
3850
  return initial;
4078
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3851
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4079
3852
  initial[field] = {
4080
3853
  enumerable: true,
4081
3854
  configurable: true,
@@ -4087,12 +3860,11 @@
4087
3860
  }
4088
3861
  };
4089
3862
  return initial;
4090
- }, {})));
3863
+ }, {}) : {}));
4091
3864
  this.syncValue();
4092
3865
  },
4093
3866
  valueHandle: function valueHandle(ctx) {
4094
3867
  var _this3 = this;
4095
-
4096
3868
  return {
4097
3869
  enumerable: true,
4098
3870
  get: function get() {
@@ -4111,24 +3883,18 @@
4111
3883
  delete this.appendData[rule.field];
4112
3884
  },
4113
3885
  addSubForm: function addSubForm(ctx, subForm) {
4114
- if (ctx.input) {
4115
- this.subForm[ctx.id] = subForm;
4116
- }
3886
+ this.subForm[ctx.id] = subForm;
4117
3887
  },
4118
3888
  deferSyncValue: function deferSyncValue(fn, sync) {
4119
3889
  if (!this.deferSyncFn) {
4120
3890
  this.deferSyncFn = fn;
4121
3891
  }
4122
-
4123
3892
  if (!this.deferSyncFn.sync) {
4124
3893
  this.deferSyncFn.sync = sync;
4125
3894
  }
4126
-
4127
3895
  invoke(fn);
4128
-
4129
3896
  if (this.deferSyncFn === fn) {
4130
3897
  this.deferSyncFn = null;
4131
-
4132
3898
  if (fn.sync) {
4133
3899
  this.syncValue();
4134
3900
  }
@@ -4138,18 +3904,16 @@
4138
3904
  if (this.deferSyncFn) {
4139
3905
  return this.deferSyncFn.sync = true;
4140
3906
  }
4141
-
4142
3907
  this.vm._updateValue(_objectSpread2({}, this.form));
4143
3908
  },
4144
3909
  isChange: function isChange(ctx, value) {
4145
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3910
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4146
3911
  },
4147
3912
  isQuote: function isQuote(ctx, value) {
4148
3913
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4149
3914
  },
4150
3915
  refreshUpdate: function refreshUpdate(ctx, val) {
4151
3916
  var _this4 = this;
4152
-
4153
3917
  if (is.Function(ctx.rule.update)) {
4154
3918
  var state = invoke(function () {
4155
3919
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4169,20 +3933,16 @@
4169
3933
  this.vm.$emit('update', this.api);
4170
3934
  this.refresh();
4171
3935
  }
4172
-
4173
3936
  this.refreshUpdate(ctx, val);
4174
3937
  },
4175
3938
  appendLink: function appendLink(ctx) {
4176
3939
  var _this5 = this;
4177
-
4178
3940
  var link = ctx.rule.link;
4179
3941
  is.trueArray(link) && link.forEach(function (field) {
4180
3942
  var fn = function fn() {
4181
3943
  return _this5.refreshRule(ctx, ctx.rule.value);
4182
3944
  };
4183
-
4184
3945
  _this5.bus.$on('change-' + field, fn);
4185
-
4186
3946
  ctx.linkOn.push(function () {
4187
3947
  return _this5.bus.$off('change-' + field, fn);
4188
3948
  });
@@ -4193,11 +3953,9 @@
4193
3953
  }
4194
3954
  });
4195
3955
  }
4196
-
4197
3956
  function strFn(key, val) {
4198
3957
  return typeof val === 'function' ? '' + val : val;
4199
3958
  }
4200
-
4201
3959
  function toEmpty(obj) {
4202
3960
  Object.keys(obj).forEach(function (k) {
4203
3961
  return delete obj[k];
@@ -4217,11 +3975,12 @@
4217
3975
  return ctx.$render.defaultRender(ctx, children);
4218
3976
  },
4219
3977
  preview: function preview(children, ctx) {
4220
- return ctx.$render.defaultRender(ctx, children);
3978
+ return this.render(children, ctx);
4221
3979
  },
4222
3980
  mergeProp: function mergeProp(ctx) {}
4223
3981
  };
4224
3982
 
3983
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4225
3984
  function useContext(Handler) {
4226
3985
  extend(Handler.prototype, {
4227
3986
  getCtx: function getCtx(id) {
@@ -4232,7 +3991,6 @@
4232
3991
  },
4233
3992
  setIdCtx: function setIdCtx(ctx, key, type) {
4234
3993
  var field = "".concat(type, "Ctx");
4235
-
4236
3994
  if (!this[field][key]) {
4237
3995
  this[field][key] = [ctx];
4238
3996
  } else {
@@ -4244,11 +4002,9 @@
4244
4002
  var lst = this[field][key];
4245
4003
  if (!lst) return false;
4246
4004
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4247
-
4248
4005
  if (!lst.length) {
4249
4006
  delete this[field][key];
4250
4007
  }
4251
-
4252
4008
  return flag;
4253
4009
  },
4254
4010
  getFieldCtx: function getFieldCtx(field) {
@@ -4267,7 +4023,6 @@
4267
4023
  if (!ctx.input) return;
4268
4024
  this.setIdCtx(ctx, field, 'field');
4269
4025
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4270
-
4271
4026
  if (this.isMounted && !this.reloading) {
4272
4027
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4273
4028
  }
@@ -4288,70 +4043,51 @@
4288
4043
  if (!this.noWatchFn) {
4289
4044
  this.noWatchFn = fn;
4290
4045
  }
4291
-
4292
4046
  invoke(fn);
4293
-
4294
4047
  if (this.noWatchFn === fn) {
4295
4048
  this.noWatchFn = null;
4296
4049
  }
4297
4050
  },
4298
4051
  watchCtx: function watchCtx(ctx) {
4299
4052
  var _this = this;
4300
-
4301
4053
  var vm = this.vm;
4302
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4303
4054
  Object.keys(ctx.rule).filter(function (k) {
4304
- return k[0] !== '_' && none.indexOf(k) === -1;
4055
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4305
4056
  }).forEach(function (key) {
4306
4057
  var flag = key === 'children';
4307
4058
  ctx.watch.push(vm.$watch(function () {
4308
4059
  return ctx.rule[key];
4309
4060
  }, function (n, o) {
4310
4061
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4311
-
4312
4062
  if (flag && ctx.parser.loadChildren === false) {
4313
4063
  _this.$render.clearCache(ctx);
4314
-
4315
4064
  _this.nextRefresh();
4316
-
4317
4065
  return;
4318
4066
  }
4319
-
4320
- _this.watching = true; // if (key === 'hidden')
4321
- // ctx.updateKey(true);
4322
- // else
4323
-
4067
+ _this.watching = true;
4324
4068
  if (key === 'link') {
4325
4069
  ctx.link();
4326
4070
  return;
4327
4071
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4328
4072
  _this.parseInjectEvent(ctx.rule, n || {});
4329
-
4330
4073
  if (key === 'props' && ctx.input) {
4331
4074
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4332
4075
  }
4333
4076
  } 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') {
4334
4077
  ctx.updateType();
4335
-
4336
4078
  _this.bindParser(ctx);
4337
4079
  } else if (key === 'children') {
4338
4080
  var _flag = is.trueArray(n);
4339
-
4340
4081
  _this.deferSyncValue(function () {
4341
4082
  if (n !== o) {
4342
4083
  _this.rmSub(o);
4343
-
4344
4084
  _this.$render.initOrgChildren();
4345
4085
  }
4346
-
4347
4086
  _flag && _this.loadChildren(n, ctx);
4348
-
4349
4087
  _this.vm.$emit('update', _this.api);
4350
4088
  });
4351
4089
  }
4352
-
4353
4090
  _this.$render.clearCache(ctx);
4354
-
4355
4091
  _this.watching = false;
4356
4092
  }, {
4357
4093
  deep: !flag,
@@ -4362,27 +4098,23 @@
4362
4098
  },
4363
4099
  rmSub: function rmSub(sub) {
4364
4100
  var _this2 = this;
4365
-
4366
4101
  is.trueArray(sub) && sub.forEach(function (r) {
4367
4102
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4368
4103
  });
4369
4104
  },
4370
4105
  rmCtx: function rmCtx(ctx) {
4371
4106
  var _this3 = this;
4372
-
4373
4107
  if (ctx.deleted) return;
4374
4108
  var id = ctx.id,
4375
4109
  field = ctx.field,
4376
4110
  input = ctx.input,
4377
4111
  name = ctx.name;
4378
-
4379
4112
  if (ctx.input) {
4380
4113
  Object.defineProperty(ctx.rule, 'value', {
4381
4114
  value: ctx.rule.value,
4382
4115
  writable: true
4383
4116
  });
4384
4117
  }
4385
-
4386
4118
  $del(this.ctxs, id);
4387
4119
  $del(this.$render.tempList, id);
4388
4120
  $del(this.$render.orgChildren, id);
@@ -4390,6 +4122,7 @@
4390
4122
  $del(this.formData, id);
4391
4123
  $del(this.subForm, id);
4392
4124
  $del(ctx, 'cacheValue');
4125
+ input && $del(this.form, field);
4393
4126
  input && this.rmIdCtx(ctx, field, 'field');
4394
4127
  name && this.rmIdCtx(ctx, name, 'name');
4395
4128
  this.deferSyncValue(function () {
@@ -4401,18 +4134,15 @@
4401
4134
  });
4402
4135
  }
4403
4136
  }
4404
-
4405
4137
  if (ctx.root === _this3.rules) {
4406
4138
  _this3.vm._renderRule();
4407
4139
  }
4408
4140
  }
4409
4141
  }, input);
4410
4142
  var index = this.sort.indexOf(id);
4411
-
4412
4143
  if (index > -1) {
4413
4144
  this.sort.splice(index, 1);
4414
4145
  }
4415
-
4416
4146
  this.$render.clearCache(ctx);
4417
4147
  ctx["delete"]();
4418
4148
  this.effect(ctx, 'deleted');
@@ -4427,13 +4157,10 @@
4427
4157
  extend(Handler.prototype, {
4428
4158
  mounted: function mounted() {
4429
4159
  var _this = this;
4430
-
4431
4160
  var _mounted = function _mounted() {
4432
4161
  _this.isMounted = true;
4433
-
4434
4162
  _this.lifecycle('mounted');
4435
4163
  };
4436
-
4437
4164
  if (this.pageEnd) {
4438
4165
  _mounted();
4439
4166
  } else {
@@ -4442,7 +4169,6 @@
4442
4169
  },
4443
4170
  lifecycle: function lifecycle(name) {
4444
4171
  var _this2 = this;
4445
-
4446
4172
  var fn = this.options[name];
4447
4173
  is.Function(fn) && invoke(function () {
4448
4174
  return fn(_this2.api);
@@ -4456,26 +4182,21 @@
4456
4182
  extend(Handler.prototype, {
4457
4183
  useProvider: function useProvider() {
4458
4184
  var _this = this;
4459
-
4460
4185
  var ps = this.fc.providers;
4461
4186
  Object.keys(ps).forEach(function (k) {
4462
4187
  var prop = ps[k];
4463
4188
  prop._c = getComponent(prop);
4464
-
4465
4189
  _this.onEffect(prop);
4466
-
4467
4190
  _this.providers[k] = prop;
4468
4191
  });
4469
4192
  },
4470
4193
  onEffect: function onEffect(provider) {
4471
4194
  var _this2 = this;
4472
-
4473
4195
  var used = [];
4474
4196
  (provider._c || ['*']).forEach(function (name) {
4475
4197
  var type = name === '*' ? '*' : _this2.getType(name);
4476
4198
  if (used.indexOf(type) > -1) return;
4477
4199
  used.push(type);
4478
-
4479
4200
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4480
4201
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4481
4202
  });
@@ -4484,12 +4205,22 @@
4484
4205
  },
4485
4206
  watchEffect: function watchEffect(ctx) {
4486
4207
  var _this3 = this;
4487
-
4488
4208
  var vm = this.vm;
4209
+ var effect = {};
4489
4210
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
4490
- ctx.watch.push(vm.$watch(function () {
4211
+ effect[k] = function () {
4491
4212
  return ctx.rule.effect[k];
4492
- }, function (n) {
4213
+ };
4214
+ });
4215
+ Object.keys(ctx.rule).forEach(function (k) {
4216
+ if (k[0] === '$') {
4217
+ effect[k.substr(1)] = function () {
4218
+ return ctx.rule[k];
4219
+ };
4220
+ }
4221
+ });
4222
+ Object.keys(effect || {}).forEach(function (k) {
4223
+ ctx.watch.push(vm.$watch(effect[k], function (n) {
4493
4224
  _this3.effect(ctx, 'watch', _defineProperty({}, k, n));
4494
4225
  }, {
4495
4226
  deep: true
@@ -4513,24 +4244,30 @@
4513
4244
  }, event);
4514
4245
  },
4515
4246
  getEffect: function getEffect(rule, name) {
4516
- if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];else return undefined;
4247
+ if (hasProperty(rule, '$' + name)) {
4248
+ return rule['$' + name];
4249
+ }
4250
+ if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4251
+ return undefined;
4517
4252
  },
4518
4253
  emitEffect: function emitEffect(_ref, event, append) {
4519
4254
  var _this4 = this;
4520
-
4521
4255
  var ctx = _ref.ctx,
4522
4256
  rule = _ref.rule,
4523
4257
  input = _ref.input,
4524
4258
  type = _ref.type,
4525
4259
  custom = _ref.custom;
4526
4260
  if (!type || type === 'fcFragment') return;
4527
- var effect = custom ? custom : rule.effect || {};
4261
+ var effect = custom ? custom : Object.keys(rule).reduce(function (i, k) {
4262
+ if (k[0] === '$') {
4263
+ i[k.substr(1)] = rule[k];
4264
+ }
4265
+ return i;
4266
+ }, _objectSpread2({}, rule.effect || {}));
4528
4267
  Object.keys(effect).forEach(function (attr) {
4529
4268
  var p = _this4.providers[attr];
4530
4269
  if (!p || p.input && !input) return;
4531
-
4532
4270
  var _type;
4533
-
4534
4271
  if (!p._c) {
4535
4272
  _type = '*';
4536
4273
  } else if (p._used.indexOf(type) > -1) {
@@ -4538,40 +4275,33 @@
4538
4275
  } else {
4539
4276
  return;
4540
4277
  }
4541
-
4542
4278
  var data = _objectSpread2({
4543
4279
  value: effect[attr],
4544
4280
  getValue: function getValue() {
4545
4281
  return _this4.getEffect(rule, attr);
4546
4282
  }
4547
4283
  }, append || {});
4548
-
4549
4284
  if (ctx) {
4550
4285
  data.getProp = function () {
4551
4286
  return ctx.effectData(attr);
4552
4287
  };
4553
-
4554
4288
  data.clearProp = function () {
4555
4289
  return ctx.clearEffectData(attr);
4556
4290
  };
4557
-
4558
4291
  data.mergeProp = function (prop) {
4559
4292
  return mergeProps([prop], data.getProp());
4560
4293
  };
4561
4294
  }
4562
-
4563
4295
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4564
4296
  });
4565
4297
  }
4566
4298
  });
4567
4299
  }
4568
-
4569
4300
  function unique(arr) {
4570
4301
  return arr.filter(function (item, index, arr) {
4571
4302
  return arr.indexOf(item, 0) === index;
4572
4303
  });
4573
4304
  }
4574
-
4575
4305
  function getComponent(p) {
4576
4306
  var c = p.components;
4577
4307
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4581,7 +4311,6 @@
4581
4311
 
4582
4312
  function Handler(fc) {
4583
4313
  var _this = this;
4584
-
4585
4314
  extend(this, {
4586
4315
  fc: fc,
4587
4316
  vm: fc.vm,
@@ -4633,9 +4362,7 @@
4633
4362
  this.useProvider();
4634
4363
  this.usePage();
4635
4364
  this.loadRule();
4636
-
4637
4365
  this.$manager.__init();
4638
-
4639
4366
  this.vm.$set(this.vm, 'formData', this.formData);
4640
4367
  }
4641
4368
  });
@@ -4648,7 +4375,6 @@
4648
4375
  useLifecycle(Handler);
4649
4376
  useEffect(Handler);
4650
4377
 
4651
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4652
4378
  function getError(action, option, xhr) {
4653
4379
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4654
4380
  var err = new Error(msg);
@@ -4656,44 +4382,34 @@
4656
4382
  err.url = action;
4657
4383
  return err;
4658
4384
  }
4659
-
4660
4385
  function getBody(xhr) {
4661
4386
  var text = xhr.responseText || xhr.response;
4662
-
4663
4387
  if (!text) {
4664
4388
  return text;
4665
4389
  }
4666
-
4667
4390
  try {
4668
4391
  return JSON.parse(text);
4669
4392
  } catch (e) {
4670
4393
  return text;
4671
4394
  }
4672
4395
  }
4673
-
4674
4396
  function fetch(option) {
4675
4397
  if (typeof XMLHttpRequest === 'undefined') {
4676
4398
  return;
4677
4399
  }
4678
-
4679
4400
  var xhr = new XMLHttpRequest();
4680
4401
  var action = option.action;
4681
-
4682
4402
  xhr.onerror = function error(e) {
4683
4403
  option.onError(e);
4684
4404
  };
4685
-
4686
4405
  xhr.onload = function onload() {
4687
4406
  if (xhr.status < 200 || xhr.status >= 300) {
4688
4407
  return option.onError(getError(action, option, xhr), getBody(xhr));
4689
4408
  }
4690
-
4691
4409
  option.onSuccess(getBody(xhr));
4692
4410
  };
4693
-
4694
4411
  xhr.open(option.method || 'get', action, true);
4695
4412
  var formData;
4696
-
4697
4413
  if (option.data) {
4698
4414
  if ((option.dataType || '').toLowerCase() !== 'json') {
4699
4415
  formData = new FormData();
@@ -4705,11 +4421,9 @@
4705
4421
  xhr.setRequestHeader('content-type', 'application/json');
4706
4422
  }
4707
4423
  }
4708
-
4709
4424
  if (option.withCredentials && 'withCredentials' in xhr) {
4710
4425
  xhr.withCredentials = true;
4711
4426
  }
4712
-
4713
4427
  var headers = option.headers || {};
4714
4428
  Object.keys(headers).forEach(function (item) {
4715
4429
  if (headers[item] !== null) {
@@ -4737,14 +4451,11 @@
4737
4451
  };
4738
4452
  return prop;
4739
4453
  }
4740
-
4741
4454
  function CreateNodeFactory() {
4742
4455
  var aliasMap = {};
4743
-
4744
4456
  function CreateNode(vm) {
4745
4457
  vm && this.setVm(vm);
4746
4458
  }
4747
-
4748
4459
  extend(CreateNode.prototype, {
4749
4460
  setVm: function setVm(vm) {
4750
4461
  this.vm = vm;
@@ -4752,7 +4463,10 @@
4752
4463
  },
4753
4464
  make: function make(tag, data, children) {
4754
4465
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4755
- var Node = this.$h(tag, parseProp(data), children || []);
4466
+ return this.makeComponent(tag, data, children);
4467
+ },
4468
+ makeComponent: function makeComponent(type, data, children) {
4469
+ var Node = this.$h(type, parseProp(data), children || []);
4756
4470
  Node.context = this.vm;
4757
4471
  return Node;
4758
4472
  },
@@ -4770,7 +4484,6 @@
4770
4484
  var v = nodes[k];
4771
4485
  [k, line, lower].forEach(function (n) {
4772
4486
  CreateNode.alias(k, v);
4773
-
4774
4487
  CreateNode.prototype[n] = function (data, children) {
4775
4488
  return this.make(v, data, children);
4776
4489
  };
@@ -4782,20 +4495,15 @@
4782
4495
  }
4783
4496
 
4784
4497
  function createManager(proto) {
4785
- var CustomManager = /*#__PURE__*/function (_Manager) {
4498
+ var CustomManager = function (_Manager) {
4786
4499
  _inherits(CustomManager, _Manager);
4787
-
4788
4500
  var _super = _createSuper(CustomManager);
4789
-
4790
4501
  function CustomManager() {
4791
4502
  _classCallCheck(this, CustomManager);
4792
-
4793
4503
  return _super.apply(this, arguments);
4794
4504
  }
4795
-
4796
4505
  return CustomManager;
4797
4506
  }(Manager);
4798
-
4799
4507
  Object.assign(CustomManager.prototype, proto);
4800
4508
  return CustomManager;
4801
4509
  }
@@ -4815,19 +4523,15 @@
4815
4523
  extend(Manager.prototype, {
4816
4524
  __init: function __init() {
4817
4525
  var _this = this;
4818
-
4819
4526
  this.$render = this.$handle.$render;
4820
-
4821
4527
  this.$r = function () {
4822
4528
  var _this$$render;
4823
-
4824
4529
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4825
4530
  };
4826
4531
  },
4827
4532
  updateKey: function updateKey() {
4828
4533
  this.key = uniqueId();
4829
4534
  },
4830
- //TODO interface
4831
4535
  init: function init() {},
4832
4536
  update: function update() {},
4833
4537
  beforeRender: function beforeRender() {},
@@ -4836,7 +4540,6 @@
4836
4540
  },
4837
4541
  mergeOptions: function mergeOptions(args, opt) {
4838
4542
  var _this2 = this;
4839
-
4840
4543
  return mergeProps(args.map(function (v) {
4841
4544
  return _this2.tidyOptions(v);
4842
4545
  }), opt, this.mergeOptionsRule);
@@ -4868,7 +4571,45 @@
4868
4571
  }
4869
4572
  }
4870
4573
  };
4871
-
4574
+ var $required = {
4575
+ name: 'required',
4576
+ load: function load(inject, rule, api) {
4577
+ var val = parseVa(inject.getValue());
4578
+ if (val.required === false) {
4579
+ inject.clearProp();
4580
+ } else {
4581
+ var validate = _objectSpread2(_objectSpread2({}, val), {}, {
4582
+ required: true,
4583
+ validator: function validator(_, v, call) {
4584
+ is.empty(v) ? call(validate.message) : call();
4585
+ }
4586
+ });
4587
+ if (!validate.message) {
4588
+ validate.message = rule.title + ' is required';
4589
+ }
4590
+ inject.getProp().validate = [validate];
4591
+ }
4592
+ api.sync(rule);
4593
+ },
4594
+ watch: function watch() {
4595
+ $required.load.apply($required, arguments);
4596
+ }
4597
+ };
4598
+ function parseVa(val) {
4599
+ if (is.Boolean(val)) {
4600
+ return {
4601
+ required: val
4602
+ };
4603
+ } else if (is.String(val)) {
4604
+ return {
4605
+ message: val
4606
+ };
4607
+ } else if (!is.Object(val)) {
4608
+ return {};
4609
+ } else {
4610
+ return val;
4611
+ }
4612
+ }
4872
4613
  function parseOpt(option) {
4873
4614
  if (is.String(option)) {
4874
4615
  option = {
@@ -4876,29 +4617,21 @@
4876
4617
  to: 'options'
4877
4618
  };
4878
4619
  }
4879
-
4880
4620
  return option;
4881
4621
  }
4882
-
4883
4622
  function run(inject, rule, api) {
4884
4623
  var option = inject.value;
4885
-
4886
4624
  if (is.Function(option)) {
4887
4625
  option = option(rule, api);
4888
4626
  }
4889
-
4890
4627
  option = parseOpt(option);
4891
-
4892
4628
  if (!option || !option.action) {
4893
4629
  return false;
4894
4630
  }
4895
-
4896
4631
  if (!option.to) {
4897
4632
  option.to = 'options';
4898
4633
  }
4899
-
4900
4634
  var _onError = option.onError;
4901
-
4902
4635
  var check = function check() {
4903
4636
  if (!inject.getValue()) {
4904
4637
  inject.clearProp();
@@ -4906,7 +4639,6 @@
4906
4639
  return true;
4907
4640
  }
4908
4641
  };
4909
-
4910
4642
  var set = function set(val) {
4911
4643
  if (val === undefined) {
4912
4644
  inject.clearProp();
@@ -4915,7 +4647,6 @@
4915
4647
  deepSet(inject.getProp(), option.to, val);
4916
4648
  }
4917
4649
  };
4918
-
4919
4650
  invoke(function () {
4920
4651
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
4921
4652
  onSuccess: function onSuccess(body) {
@@ -4928,7 +4659,6 @@
4928
4659
  onError: function onError(e) {
4929
4660
  set(undefined);
4930
4661
  if (check()) return;
4931
-
4932
4662
  (_onError || function (e) {
4933
4663
  return err(e.message || 'fetch fail ' + option.action);
4934
4664
  })(e, rule, api);
@@ -4937,38 +4667,54 @@
4937
4667
  });
4938
4668
  return true;
4939
4669
  }
4670
+ var $provider = {
4671
+ fetch: $fetch,
4672
+ required: $required
4673
+ };
4940
4674
 
4941
- var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
4675
+ var name = 'html';
4676
+ var html = {
4677
+ name: name,
4678
+ loadChildren: false,
4679
+ render: function render(children, ctx) {
4680
+ if (!ctx.prop.domProps) ctx.prop.domProps = {};
4681
+ ctx.prop.domProps.innerHTML = children;
4682
+ return ctx.vNode.make(ctx.prop.props.tag || 'div', ctx.prop);
4683
+ },
4684
+ renderChildren: function renderChildren(ctx) {
4685
+ if (Array.isArray(ctx.rule.children)) {
4686
+ return ctx.rule.children.filter(function (v) {
4687
+ return is.String(v);
4688
+ }).join('');
4689
+ }
4690
+ return '';
4691
+ }
4692
+ };
4942
4693
 
4694
+ var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
4943
4695
  function _parseProp(name, id) {
4944
4696
  var prop;
4945
-
4946
4697
  if (arguments.length === 2) {
4947
4698
  prop = arguments[1];
4948
4699
  id = prop[name];
4949
4700
  } else {
4950
4701
  prop = arguments[2];
4951
4702
  }
4952
-
4953
4703
  return {
4954
4704
  id: id,
4955
4705
  prop: prop
4956
4706
  };
4957
4707
  }
4958
-
4959
4708
  function nameProp() {
4960
4709
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
4961
4710
  }
4962
-
4963
4711
  function _getEl(options) {
4964
4712
  if (!options || !options.el) return window.document.body;
4965
4713
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
4966
4714
  }
4967
-
4968
4715
  function mountForm(rules, option) {
4969
4716
  var $vm = new _vue({
4970
4717
  data: function data() {
4971
- //todo 外部无法修改
4972
4718
  return {
4973
4719
  rule: rules,
4974
4720
  option: option || {}
@@ -4984,7 +4730,6 @@
4984
4730
  $vm.$mount();
4985
4731
  return $vm;
4986
4732
  }
4987
-
4988
4733
  function exportAttrs(attrs) {
4989
4734
  var key = attrs.key || [];
4990
4735
  var array = attrs.array || [];
@@ -4993,17 +4738,14 @@
4993
4738
  arrayAttrs.push.apply(arrayAttrs, _toConsumableArray(array));
4994
4739
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
4995
4740
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
4996
- } //todo 表单嵌套
4997
-
4998
-
4741
+ }
4742
+ var id$1 = 1;
4743
+ var instance = {};
4999
4744
  function FormCreateFactory(config) {
5000
4745
  var components = _defineProperty({}, fragment.name, fragment);
5001
-
5002
4746
  var parsers = {};
5003
4747
  var directives = {};
5004
- var providers = {
5005
- fetch: $fetch
5006
- };
4748
+ var providers = _objectSpread2({}, $provider);
5007
4749
  var maker = makerFactory();
5008
4750
  var globalConfig = {
5009
4751
  global: {}
@@ -5011,23 +4753,24 @@
5011
4753
  var data = {};
5012
4754
  var CreateNode = CreateNodeFactory();
5013
4755
  exportAttrs(config.attrs || {});
5014
-
4756
+ function getApi(name) {
4757
+ var val = instance[name];
4758
+ if (Array.isArray(val)) return _toConsumableArray(val);
4759
+ return val;
4760
+ }
5015
4761
  function directive() {
5016
4762
  var data = nameProp.apply(void 0, arguments);
5017
4763
  if (data.id && data.prop) directives[data.id] = data.prop;
5018
4764
  }
5019
-
5020
4765
  function register() {
5021
4766
  var data = nameProp.apply(void 0, arguments);
5022
4767
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5023
4768
  name: data.id
5024
4769
  });
5025
4770
  }
5026
-
5027
4771
  function componentAlias(alias) {
5028
4772
  CreateNode.use(alias);
5029
4773
  }
5030
-
5031
4774
  function parser() {
5032
4775
  var data = nameProp.apply(void 0, arguments);
5033
4776
  if (!data.id || !data.prop) return;
@@ -5038,13 +4781,10 @@
5038
4781
  maker[name] = creatorFactory(name);
5039
4782
  parser.maker && extend(maker, parser.maker);
5040
4783
  }
5041
-
5042
4784
  function component(id, component) {
5043
4785
  var name;
5044
-
5045
4786
  if (is.String(id)) {
5046
4787
  name = toCase(id);
5047
-
5048
4788
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5049
4789
  return $form();
5050
4790
  } else if (component === undefined) {
@@ -5054,48 +4794,54 @@
5054
4794
  name = toCase(id.name);
5055
4795
  component = id;
5056
4796
  }
5057
-
5058
4797
  if (!name || !component) return;
5059
4798
  components[name] = component;
5060
4799
  if (component.formCreateParser) parser(name, component.formCreateParser);
5061
4800
  }
5062
-
5063
4801
  function $form() {
5064
4802
  return _vue.extend($FormCreate(FormCreate));
5065
4803
  }
5066
-
5067
4804
  function $vnode() {
5068
4805
  return _vue.extend(fragment);
5069
- } //todo 检查回调函数作用域
5070
-
5071
-
4806
+ }
5072
4807
  function use(fn, opt) {
5073
4808
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5074
4809
  return this;
5075
4810
  }
5076
-
5077
4811
  function create(rules, _opt, parent) {
5078
4812
  var $vm = mountForm(rules, _opt || {});
5079
4813
  var _this = $vm.$refs.fc.formCreate;
5080
4814
  _this.$parent = parent;
5081
-
5082
4815
  _getEl(_this.options).appendChild($vm.$el);
5083
-
5084
4816
  return _this.api();
5085
4817
  }
5086
-
5087
- function factory() {
5088
- return FormCreateFactory(config);
4818
+ function factory(inherit) {
4819
+ var _config = _objectSpread2({}, config);
4820
+ if (inherit) {
4821
+ _config.inherit = {
4822
+ components: components,
4823
+ parsers: parsers,
4824
+ directives: directives,
4825
+ providers: providers,
4826
+ maker: maker,
4827
+ data: data
4828
+ };
4829
+ } else {
4830
+ delete _config.inherit;
4831
+ }
4832
+ return FormCreateFactory(_config);
5089
4833
  }
5090
-
5091
4834
  function FormCreate(vm, rules, options) {
5092
4835
  extend(this, {
4836
+ id: id$1++,
5093
4837
  vm: vm,
5094
4838
  create: create,
5095
4839
  manager: createManager(config.manager),
5096
4840
  parsers: parsers,
5097
4841
  providers: providers,
5098
4842
  rules: Array.isArray(rules) ? rules : [],
4843
+ name: vm.$options.propsData.name,
4844
+ inFor: vm.$options.propsData.inFor,
5099
4845
  prop: {
5100
4846
  components: components,
5101
4847
  directives: directives
@@ -5103,18 +4849,25 @@
5103
4849
  CreateNode: CreateNode,
5104
4850
  bus: new _vue(),
5105
4851
  unwatch: null,
4852
+ options: options || {},
5106
4853
  extendApi: config.extendApi || function (api) {
5107
4854
  return api;
5108
4855
  }
5109
4856
  });
5110
4857
  this.init();
5111
- this.initOptions(options || {});
4858
+ this.initOptions(this.options);
4859
+ if (this.name) {
4860
+ if (this.inFor) {
4861
+ if (!instance[this.name]) instance[this.name] = [];
4862
+ instance[this.name].push(this.api());
4863
+ } else {
4864
+ instance[this.name] = this.api();
4865
+ }
4866
+ }
5112
4867
  }
5113
-
5114
4868
  extend(FormCreate.prototype, {
5115
4869
  init: function init() {
5116
4870
  var _this2 = this;
5117
-
5118
4871
  var vm = this.vm;
5119
4872
  var h = new Handler(this);
5120
4873
  this.$handle = h;
@@ -5126,15 +4879,12 @@
5126
4879
  return vm.$pfc.option;
5127
4880
  }, function () {
5128
4881
  _this2.initOptions(_this2.options);
5129
-
5130
4882
  vm.$f.refresh();
5131
4883
  }, {
5132
4884
  deep: true
5133
4885
  });
5134
-
5135
4886
  _this2.initOptions(_this2.options);
5136
4887
  }
5137
-
5138
4888
  _this2.created();
5139
4889
  });
5140
4890
  vm.$on('hook:mounted', function () {
@@ -5144,6 +4894,14 @@
5144
4894
  vm.destroyed = true;
5145
4895
  _this2.unwatch && _this2.unwatch();
5146
4896
  h.reloadRule([]);
4897
+ if (_this2.name) {
4898
+ if (_this2.inFor) {
4899
+ var idx = instance[_this2.name].indexOf(_this2.api());
4900
+ instance[_this2.name].splice(idx, 1);
4901
+ } else {
4902
+ delete instance[_this2.name];
4903
+ }
4904
+ }
5147
4905
  });
5148
4906
  vm.$on('hook:updated', function () {
5149
4907
  h.bindNextTick(function () {
@@ -5160,11 +4918,9 @@
5160
4918
  submitBtn: {},
5161
4919
  resetBtn: {}
5162
4920
  }, deepCopy(globalConfig));
5163
-
5164
4921
  if (this.isSub()) {
5165
4922
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5166
4923
  }
5167
-
5168
4924
  this.updateOptions(options);
5169
4925
  },
5170
4926
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5172,12 +4928,10 @@
5172
4928
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5173
4929
  delete opt[n];
5174
4930
  });
5175
-
5176
4931
  if (opt.global) {
5177
4932
  target.global = mergeGlobal(target.global, opt.global);
5178
4933
  delete opt.global;
5179
4934
  }
5180
-
5181
4935
  this.$handle.$manager.mergeOptions([opt], target);
5182
4936
  return target;
5183
4937
  },
@@ -5199,7 +4953,6 @@
5199
4953
  this.$handle.mounted();
5200
4954
  }
5201
4955
  });
5202
-
5203
4956
  function useAttr(formCreate) {
5204
4957
  extend(formCreate, {
5205
4958
  version: config.version,
@@ -5221,17 +4974,15 @@
5221
4974
  parseFn: parseFn,
5222
4975
  parseJson: parseJson,
5223
4976
  toJson: toJson,
4977
+ getApi: getApi,
5224
4978
  init: function init(rules) {
5225
4979
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5226
-
5227
4980
  var $vm = mountForm(rules, _opt),
5228
4981
  _this = $vm.$refs.fc.formCreate;
5229
4982
  return {
5230
4983
  mount: function mount($el) {
5231
4984
  if ($el && is.Element($el)) _this.options.el = $el;
5232
-
5233
4985
  _getEl(_this.options).appendChild($vm.$el);
5234
-
5235
4986
  return _this.api();
5236
4987
  },
5237
4988
  remove: function remove() {
@@ -5246,7 +4997,6 @@
5246
4997
  }
5247
4998
  });
5248
4999
  }
5249
-
5250
5000
  function useStatic(formCreate) {
5251
5001
  extend(formCreate, {
5252
5002
  create: create,
@@ -5255,12 +5005,10 @@
5255
5005
  if (Vue._installedFormCreate === true) return;
5256
5006
  Vue._installedFormCreate = true;
5257
5007
  _vue = Vue;
5258
-
5259
5008
  var $formCreate = function $formCreate(rules) {
5260
5009
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5261
5010
  return create(rules, opt, this);
5262
5011
  };
5263
-
5264
5012
  useAttr($formCreate);
5265
5013
  Vue.prototype.$formCreate = $formCreate;
5266
5014
  Vue.component('FormCreate', $form());
@@ -5268,13 +5016,22 @@
5268
5016
  }
5269
5017
  });
5270
5018
  }
5271
-
5272
5019
  useAttr(create);
5273
5020
  useStatic(create);
5274
5021
  CreateNode.use({
5275
5022
  fragment: 'fcFragment'
5276
5023
  });
5024
+ parser(html);
5277
5025
  if (config.install) create.use(config);
5026
+ if (config.inherit) {
5027
+ var inherit = config.inherit;
5028
+ inherit.components && extend(components, inherit.components);
5029
+ inherit.parsers && extend(parsers, inherit.parsers);
5030
+ inherit.directives && extend(directives, inherit.directives);
5031
+ inherit.providers && extend(providers, inherit.providers);
5032
+ inherit.maker && extend(maker, inherit.maker);
5033
+ inherit.data && extend(data, inherit.data);
5034
+ }
5278
5035
  return create;
5279
5036
  }
5280
5037
 
@@ -5284,12 +5041,12 @@
5284
5041
  return date.toString() === 'Invalid Date' ? timeStamp : date;
5285
5042
  }
5286
5043
  }
5287
- var name = 'datePicker';
5044
+ var name$1 = 'datePicker';
5288
5045
  var datePicker = {
5289
- name: name,
5046
+ name: name$1,
5290
5047
  maker: function () {
5291
5048
  return ['date', 'dateRange', 'datetime', 'datetimeRange', 'year', 'month'].reduce(function (maker, type) {
5292
- maker[type] = creatorFactory(name, {
5049
+ maker[type] = creatorFactory(name$1, {
5293
5050
  type: type.toLowerCase()
5294
5051
  });
5295
5052
  return maker;
@@ -5297,7 +5054,6 @@
5297
5054
  }(),
5298
5055
  mergeProp: function mergeProp(ctx) {
5299
5056
  var props = ctx.prop.props;
5300
-
5301
5057
  if (props.startDate) {
5302
5058
  props.startDate = props.startDate && timeStampToDate(props.startDate);
5303
5059
  }
@@ -5313,12 +5069,10 @@
5313
5069
  },
5314
5070
  toValue: function toValue(formValue, ctx) {
5315
5071
  var el = ctx.el;
5316
-
5317
5072
  if (el) {
5318
5073
  this.el = el;
5319
5074
  return this._toValue(formValue, ctx);
5320
5075
  }
5321
-
5322
5076
  return formValue;
5323
5077
  },
5324
5078
  toFormValue: function toFormValue(value, ctx) {
@@ -5330,7 +5084,6 @@
5330
5084
  props = ctx.prop.props,
5331
5085
  parseValue,
5332
5086
  type = props.type || 'date';
5333
-
5334
5087
  if (['daterange', 'datetimerange'].indexOf(type) !== -1) {
5335
5088
  if (isArr) {
5336
5089
  parseValue = value.map(function (time) {
@@ -5345,7 +5098,6 @@
5345
5098
  parseValue = isArr ? value[0] || '' : value;
5346
5099
  parseValue = !parseValue ? '' : timeStampToDate(parseValue);
5347
5100
  }
5348
-
5349
5101
  return parseValue;
5350
5102
  }
5351
5103
  },
@@ -5354,46 +5106,45 @@
5354
5106
  }
5355
5107
  };
5356
5108
 
5357
- var name$1 = 'hidden';
5109
+ var name$2 = 'hidden';
5358
5110
  var hidden = {
5359
- name: name$1,
5360
- maker: _defineProperty({}, name$1, function (field, value) {
5361
- return creatorFactory(name$1)('', field, value);
5111
+ name: name$2,
5112
+ maker: _defineProperty({}, name$2, function (field, value) {
5113
+ return creatorFactory(name$2)('', field, value);
5362
5114
  }),
5363
5115
  render: function render() {
5364
5116
  return [];
5365
5117
  }
5366
5118
  };
5367
5119
 
5368
- var name$2 = 'input';
5120
+ var name$3 = 'input';
5369
5121
  var input = {
5370
- name: name$2,
5122
+ name: name$3,
5371
5123
  maker: function () {
5372
5124
  var maker = ['password', 'url', 'email', 'text', 'textarea'].reduce(function (maker, type) {
5373
- maker[type] = creatorFactory(name$2, {
5125
+ maker[type] = creatorFactory(name$3, {
5374
5126
  type: type
5375
5127
  });
5376
5128
  return maker;
5377
5129
  }, {});
5378
- maker.idate = creatorFactory(name$2, {
5130
+ maker.idate = creatorFactory(name$3, {
5379
5131
  type: 'date'
5380
5132
  });
5381
5133
  return maker;
5382
5134
  }(),
5383
5135
  mergeProp: function mergeProp(ctx) {
5384
5136
  var props = ctx.prop.props;
5385
-
5386
5137
  if (props.autosize && props.autosize.minRows) {
5387
5138
  props.rows = props.autosize.minRows || 2;
5388
5139
  }
5389
5140
  }
5390
5141
  };
5391
5142
 
5392
- var name$3 = 'slider';
5143
+ var name$4 = 'slider';
5393
5144
  var slider = {
5394
- name: name$3,
5145
+ name: name$4,
5395
5146
  maker: {
5396
- sliderRange: creatorFactory(name$3, {
5147
+ sliderRange: creatorFactory(name$4, {
5397
5148
  range: true
5398
5149
  })
5399
5150
  },
@@ -5402,13 +5153,11 @@
5402
5153
  props = ctx.prop.props,
5403
5154
  min = props.min || 0,
5404
5155
  parseValue;
5405
-
5406
5156
  if (props.range === true) {
5407
5157
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5408
5158
  } else {
5409
5159
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5410
5160
  }
5411
-
5412
5161
  return parseValue;
5413
5162
  }
5414
5163
  };
@@ -5518,18 +5267,14 @@
5518
5267
 
5519
5268
  function tidy(props, name) {
5520
5269
  if (!hasProperty(props, name)) return;
5521
-
5522
5270
  if (is.String(props[name])) {
5523
5271
  var _props$name;
5524
-
5525
5272
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5526
5273
  }
5527
5274
  }
5528
-
5529
5275
  function isFalse(val) {
5530
5276
  return val === false;
5531
5277
  }
5532
-
5533
5278
  function tidyBool(opt, name) {
5534
5279
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5535
5280
  opt[name] = {
@@ -5537,7 +5282,6 @@
5537
5282
  };
5538
5283
  }
5539
5284
  }
5540
-
5541
5285
  var manager = {
5542
5286
  validate: function validate(call) {
5543
5287
  this.form().validate(call);
@@ -5547,7 +5291,6 @@
5547
5291
  },
5548
5292
  clearValidateState: function clearValidateState(ctx) {
5549
5293
  var fItem = this.vm.$refs[ctx.wrapRef];
5550
-
5551
5294
  if (fItem) {
5552
5295
  fItem.validateMessage = '';
5553
5296
  fItem.validateState = '';
@@ -5621,7 +5364,6 @@
5621
5364
  if (children.length) {
5622
5365
  children.push(this.makeFormBtn());
5623
5366
  }
5624
-
5625
5367
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5626
5368
  },
5627
5369
  makeWrap: function makeWrap(ctx, children) {
@@ -5653,11 +5395,9 @@
5653
5395
  return !(!title.title && !title["native"] || isFalse(title.show));
5654
5396
  },
5655
5397
  makeInfo: function makeInfo(rule, uni) {
5656
-
5657
5398
  var titleProp = rule.title;
5658
5399
  var infoProp = rule.info;
5659
5400
  var children = [titleProp.title];
5660
-
5661
5401
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5662
5402
  var prop = {
5663
5403
  type: infoProp.type || 'poptip',
@@ -5666,11 +5406,9 @@
5666
5406
  slot: 'label'
5667
5407
  };
5668
5408
  var field = 'content';
5669
-
5670
5409
  if (infoProp.info && !hasProperty(prop.props, field)) {
5671
5410
  prop.props[field] = infoProp.info;
5672
5411
  }
5673
-
5674
5412
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5675
5413
  type: 'icon',
5676
5414
  props: {
@@ -5681,7 +5419,6 @@
5681
5419
  key: "".concat(uni, "i")
5682
5420
  })]));
5683
5421
  }
5684
-
5685
5422
  return this.$r(mergeProps([titleProp, {
5686
5423
  props: titleProp,
5687
5424
  slot: titleProp.slot || 'label',
@@ -5711,19 +5448,15 @@
5711
5448
  },
5712
5449
  makeFormBtn: function makeFormBtn() {
5713
5450
  var vn = [];
5714
-
5715
5451
  if (!isFalse(this.options.submitBtn.show)) {
5716
5452
  vn.push(this.makeSubmitBtn());
5717
5453
  }
5718
-
5719
5454
  if (!isFalse(this.options.resetBtn.show)) {
5720
5455
  vn.push(this.makeResetBtn());
5721
5456
  }
5722
-
5723
5457
  if (!vn.length) {
5724
5458
  return;
5725
5459
  }
5726
-
5727
5460
  var item = this.$r({
5728
5461
  type: 'formItem',
5729
5462
  key: "".concat(this.key, "fb")
@@ -5738,7 +5471,6 @@
5738
5471
  },
5739
5472
  makeResetBtn: function makeResetBtn() {
5740
5473
  var _this2 = this;
5741
-
5742
5474
  var resetBtn = this.options.resetBtn;
5743
5475
  this.setSize(resetBtn);
5744
5476
  return this.$r({
@@ -5759,7 +5491,6 @@
5759
5491
  },
5760
5492
  makeSubmitBtn: function makeSubmitBtn() {
5761
5493
  var _this3 = this;
5762
-
5763
5494
  var submitBtn = this.options.submitBtn;
5764
5495
  this.setSize(submitBtn);
5765
5496
  return this.$r({
@@ -5781,7 +5512,6 @@
5781
5512
 
5782
5513
  var maker = {};
5783
5514
  var names = ['upload', 'select', 'tree', 'checkbox', 'autoComplete', 'cascader', 'colorPicker', 'frame', 'inputNumber', 'radio', 'rate', 'timePicker', 'group'];
5784
-
5785
5515
  function useAlias(maker) {
5786
5516
  names.forEach(function (name) {
5787
5517
  maker[name] = creatorFactory(name);
@@ -5790,7 +5520,6 @@
5790
5520
  maker.number = maker.inputNumber;
5791
5521
  maker.color = maker.colorPicker;
5792
5522
  }
5793
-
5794
5523
  function useUpload(maker) {
5795
5524
  var name = 'upload';
5796
5525
  var types = {
@@ -5811,7 +5540,6 @@
5811
5540
  maker.uploadImage = maker.image;
5812
5541
  maker.uploadFile = maker.file;
5813
5542
  }
5814
-
5815
5543
  function useTree(maker) {
5816
5544
  var name = 'tree';
5817
5545
  var types = {
@@ -5825,7 +5553,6 @@
5825
5553
  return maker;
5826
5554
  }, maker);
5827
5555
  }
5828
-
5829
5556
  function useTimePicker(maker) {
5830
5557
  var name = 'timePicker';
5831
5558
  maker.time = creatorFactory(name, {
@@ -5835,7 +5562,6 @@
5835
5562
  type: 'timerange'
5836
5563
  });
5837
5564
  }
5838
-
5839
5565
  function useSelect(maker) {
5840
5566
  var name = 'select';
5841
5567
  maker.selectMultiple = creatorFactory(name, {
@@ -5845,7 +5571,6 @@
5845
5571
  multiple: false
5846
5572
  });
5847
5573
  }
5848
-
5849
5574
  function useFrame(maker) {
5850
5575
  var name = 'frame';
5851
5576
  var types = {
@@ -5869,7 +5594,6 @@
5869
5594
  maker.frameFile = maker.frameFiles;
5870
5595
  maker.frameImage = maker.frameImages;
5871
5596
  }
5872
-
5873
5597
  useAlias(maker);
5874
5598
  useUpload(maker);
5875
5599
  useTree(maker);
@@ -5877,7 +5601,7 @@
5877
5601
  useFrame(maker);
5878
5602
  useTimePicker(maker);
5879
5603
 
5880
- var css_248z$2 = ".form-create .form-create .ivu-form-item {\n margin-bottom: 24px;\n}\n\n.form-create .form-create .ivu-form-item .ivu-form-item {\n margin-bottom: 0px;\n}\n\n.form-create{\n transform: rotateZ(0);\n}\n";
5604
+ var css_248z$2 = ".form-create .form-create .ivu-form-item {\n margin-bottom: 24px;\n}\n\n.form-create .form-create .ivu-form-item .ivu-form-item {\n margin-bottom: 0px;\n}\n";
5881
5605
  styleInject(css_248z$2);
5882
5606
 
5883
5607
  function tidyBtnProp(btn, def) {
@@ -5888,28 +5612,23 @@
5888
5612
  };
5889
5613
  return btn;
5890
5614
  }
5891
-
5892
5615
  function extendApi(api, h) {
5893
5616
  extend(api, {
5894
5617
  validate: function validate(callback) {
5895
5618
  var flag;
5896
5619
  var forms = api.children;
5897
5620
  var len = forms.length;
5898
-
5899
5621
  var validate = function validate() {
5900
5622
  h.$manager.validate(function () {
5901
5623
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5902
5624
  args[_key] = arguments[_key];
5903
5625
  }
5904
-
5905
5626
  if (!args[0] || !flag) {
5906
5627
  flag = args;
5907
5628
  }
5908
-
5909
5629
  callback && callback.apply(void 0, _toConsumableArray(flag));
5910
5630
  });
5911
5631
  };
5912
-
5913
5632
  var validFn = function validFn(args) {
5914
5633
  setTimeout(function () {
5915
5634
  if (!args[0]) {
@@ -5917,23 +5636,19 @@
5917
5636
  flag = args;
5918
5637
  }
5919
5638
  }
5920
-
5921
5639
  if (! --len) {
5922
5640
  validate();
5923
5641
  }
5924
5642
  });
5925
5643
  };
5926
-
5927
5644
  forms.forEach(function (form) {
5928
5645
  form.validate(function () {
5929
5646
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5930
5647
  args[_key2] = arguments[_key2];
5931
5648
  }
5932
-
5933
5649
  return validFn(args);
5934
5650
  });
5935
5651
  });
5936
-
5937
5652
  if (!len) {
5938
5653
  validate();
5939
5654
  }
@@ -5944,23 +5659,19 @@
5944
5659
  var sub = h.subForm[ctx.id];
5945
5660
  var len = 0;
5946
5661
  var flag;
5947
-
5948
5662
  var validate = function validate() {
5949
5663
  h.$manager.validateField(ctx.id, function () {
5950
5664
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
5951
5665
  args[_key3] = arguments[_key3];
5952
5666
  }
5953
-
5954
5667
  if (args[0]) {
5955
5668
  flag = args;
5956
5669
  } else if (flag) {
5957
5670
  return callback && callback('子表单验证未通过');
5958
5671
  }
5959
-
5960
5672
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
5961
5673
  });
5962
5674
  };
5963
-
5964
5675
  var validFn = function validFn(args) {
5965
5676
  setTimeout(function () {
5966
5677
  if (!args[0]) {
@@ -5968,31 +5679,26 @@
5968
5679
  flag = args;
5969
5680
  }
5970
5681
  }
5971
-
5972
5682
  if (! --len) {
5973
5683
  validate();
5974
5684
  }
5975
5685
  });
5976
5686
  };
5977
-
5978
5687
  sub && toArray(sub).forEach(function (form) {
5979
5688
  len++;
5980
5689
  form.validate(function () {
5981
5690
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
5982
5691
  args[_key4] = arguments[_key4];
5983
5692
  }
5984
-
5985
5693
  return validFn(args);
5986
5694
  });
5987
5695
  });
5988
-
5989
5696
  if (!len) {
5990
5697
  validate();
5991
5698
  }
5992
5699
  },
5993
5700
  clearValidateState: function clearValidateState(fields) {
5994
5701
  var _this = this;
5995
-
5996
5702
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5997
5703
  api.helper.tidyFields(fields).forEach(function (field) {
5998
5704
  if (clearSub) _this.clearSubValidateState(field);
@@ -6006,7 +5712,6 @@
6006
5712
  h.getCtxs(field).forEach(function (ctx) {
6007
5713
  var subForm = h.subForm[ctx.id];
6008
5714
  if (!subForm) return;
6009
-
6010
5715
  if (Array.isArray(subForm)) {
6011
5716
  subForm.forEach(function (form) {
6012
5717
  form.clearValidateState();
@@ -6020,14 +5725,12 @@
6020
5725
  btn: {
6021
5726
  loading: function loading() {
6022
5727
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6023
-
6024
5728
  api.submitBtnProps({
6025
5729
  loading: !!_loading
6026
5730
  });
6027
5731
  },
6028
5732
  disabled: function disabled() {
6029
5733
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6030
-
6031
5734
  api.submitBtnProps({
6032
5735
  disabled: !!_disabled
6033
5736
  });
@@ -6042,14 +5745,12 @@
6042
5745
  resetBtn: {
6043
5746
  loading: function loading() {
6044
5747
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6045
-
6046
5748
  api.resetBtnProps({
6047
5749
  loading: !!_loading2
6048
5750
  });
6049
5751
  },
6050
5752
  disabled: function disabled() {
6051
5753
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6052
-
6053
5754
  api.resetBtnProps({
6054
5755
  disabled: !!_disabled2
6055
5756
  });
@@ -6078,7 +5779,6 @@
6078
5779
  submit: function submit(successFn, failFn) {
6079
5780
  var _arguments = arguments,
6080
5781
  _this2 = this;
6081
-
6082
5782
  api.validate(function (valid) {
6083
5783
  if (valid) {
6084
5784
  var formData = api.formData();
@@ -6113,11 +5813,10 @@
6113
5813
  FormCreate.maker[name] = maker[name];
6114
5814
  });
6115
5815
  }
6116
-
6117
5816
  function ivuFormCreate() {
6118
5817
  return FormCreateFactory({
6119
5818
  ui: "".concat("view-design"),
6120
- version: "".concat("2.5.17"),
5819
+ version: "".concat("2.5.20"),
6121
5820
  manager: manager,
6122
5821
  install: install,
6123
5822
  extendApi: extendApi,
@@ -6130,15 +5829,12 @@
6130
5829
  }
6131
5830
 
6132
5831
  var FormCreate = ivuFormCreate();
6133
-
6134
5832
  if (typeof window !== 'undefined') {
6135
5833
  window.formCreate = FormCreate;
6136
-
6137
5834
  if (window.Vue) {
6138
5835
  FormCreate.install(window.Vue);
6139
5836
  }
6140
5837
  }
6141
-
6142
5838
  var maker$1 = FormCreate.maker;
6143
5839
 
6144
5840
  exports.default = FormCreate;