@form-create/iview 2.5.19 → 2.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/iview v2.5.19
2
+ * @form-create/iview v2.5.22
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -19,11 +19,9 @@
19
19
  Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]);
20
20
  }
21
21
  }
22
-
23
22
  return a;
24
23
  }, _extends.apply(this, arguments);
25
24
  }
26
-
27
25
  var normalMerge = ["attrs", "props", "domProps"],
28
26
  toArrayMerge = ["class", "style", "directives"],
29
27
  functionalMerge = ["on", "nativeOn"],
@@ -46,7 +44,6 @@
46
44
  c[b][i] = c[b][i] ? mergeFn(c[b][i], a[b][i]) : a[b][i];
47
45
  } else c[b] = a[b];
48
46
  }
49
-
50
47
  return c;
51
48
  }, {});
52
49
  },
@@ -55,7 +52,6 @@
55
52
  a && a.apply(this, arguments), b && b.apply(this, arguments);
56
53
  };
57
54
  };
58
-
59
55
  var helper = mergeJsxProps;
60
56
 
61
57
  function _typeof(obj) {
@@ -246,7 +242,6 @@
246
242
  if (!exclude || exclude.indexOf(name) === -1) {
247
243
  lst.push(slots[name]);
248
244
  }
249
-
250
245
  return lst;
251
246
  }, []);
252
247
  }
@@ -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 {
@@ -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,26 +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'] = {
689
666
  api: this.formCreateInject.api,
690
667
  close: function close(field) {
691
668
  _this7.valid(field);
692
-
693
669
  _this7.closeModel();
694
670
  },
695
671
  set: function set(field, value) {
696
672
  _this7.valid(field);
697
-
698
673
  if (!_this7.disabled) _this7.$emit('input', value);
699
674
  },
700
675
  get: function get(field) {
701
676
  _this7.valid(field);
702
-
703
677
  return _this7.value;
704
678
  },
705
679
  onOk: function onOk(fn) {
@@ -716,7 +690,6 @@
716
690
  },
717
691
  makeFooter: function makeFooter() {
718
692
  var _this8 = this;
719
-
720
693
  var h = this.$createElement;
721
694
  var _this$$props = this.$props,
722
695
  okBtnText = _this$$props.okBtnText,
@@ -748,7 +721,6 @@
748
721
  },
749
722
  render: function render() {
750
723
  var _this9 = this;
751
-
752
724
  var h = arguments[0];
753
725
  var type = this.type;
754
726
  var node;
@@ -783,10 +755,11 @@
783
755
  "attrs": {
784
756
  "src": this.previewImage
785
757
  }
786
- })]), h("Modal", helper([{}, _objectSpread2({
787
- width: width,
788
- title: title
789
- }, this.modal), {
758
+ })]), h("Modal", {
759
+ "props": _objectSpread2({}, _objectSpread2({
760
+ width: width,
761
+ title: title
762
+ }, this.modal)),
790
763
  "on": {
791
764
  "on-cancel": function onCancel() {
792
765
  return _this9.closeModel(true);
@@ -798,7 +771,7 @@
798
771
  _this9.frameVisible = $$v;
799
772
  }
800
773
  }
801
- }]), [this.frameVisible || !this.reload ? h("iframe", {
774
+ }, [this.frameVisible || !this.reload ? h("iframe", {
802
775
  "ref": "frame",
803
776
  "attrs": {
804
777
  "src": src,
@@ -868,7 +841,6 @@
868
841
  },
869
842
  update: function update() {
870
843
  var _this = this;
871
-
872
844
  this.trueValue = this.options().filter(function (opt) {
873
845
  return opt.value === _this.value;
874
846
  }).reduce(function (initial, opt) {
@@ -890,7 +862,6 @@
890
862
  }
891
863
  }]), [this.options().map(function (opt, index) {
892
864
  var props = _objectSpread2({}, opt);
893
-
894
865
  delete props.value;
895
866
  return h("Radio", {
896
867
  "props": _objectSpread2({}, props),
@@ -925,11 +896,9 @@
925
896
  if (value === undefined || value === null) {
926
897
  return true;
927
898
  }
928
-
929
899
  if (Array.isArray(value) && Array.isArray(value) && !value.length) {
930
900
  return true;
931
901
  }
932
-
933
902
  return typeof value === 'string' && !value;
934
903
  }
935
904
  };
@@ -1007,10 +976,8 @@
1007
976
  },
1008
977
  checked: function checked(_data, value, type) {
1009
978
  var _this = this;
1010
-
1011
979
  _data.forEach(function (node) {
1012
980
  _this.$set(node, type, value.indexOf(node.id) !== -1);
1013
-
1014
981
  if (node.children !== undefined && Array.isArray(node.children)) _this.checked(node.children, value, type);
1015
982
  });
1016
983
  },
@@ -1023,13 +990,11 @@
1023
990
  render: function render() {
1024
991
  var h = arguments[0];
1025
992
  var on = {};
1026
-
1027
993
  if (this.type === 'selected') {
1028
994
  on['on-select-change'] = this.onInput;
1029
995
  } else {
1030
996
  on['on-check-change'] = this.onInput;
1031
997
  }
1032
-
1033
998
  return h("Tree", helper([{}, this.formCreateInject.prop, {
1034
999
  "ref": "tree"
1035
1000
  }, {
@@ -1047,11 +1012,9 @@
1047
1012
  name: getFileName(file)
1048
1013
  };
1049
1014
  }
1050
-
1051
1015
  function getFileName(file) {
1052
1016
  return ('' + file).split('/').pop();
1053
1017
  }
1054
-
1055
1018
  var NAME$5 = 'fcUpload';
1056
1019
  function createUpload(config) {
1057
1020
  return {
@@ -1146,7 +1109,6 @@
1146
1109
  },
1147
1110
  makeRemoveIcon: function makeRemoveIcon(file, index) {
1148
1111
  var _this = this;
1149
-
1150
1112
  var h = this.$createElement;
1151
1113
  return h("icon", {
1152
1114
  "attrs": {
@@ -1162,7 +1124,6 @@
1162
1124
  },
1163
1125
  makeHandleIcon: function makeHandleIcon(file, index) {
1164
1126
  var _this2 = this;
1165
-
1166
1127
  var h = this.$createElement;
1167
1128
  return h("icon", {
1168
1129
  "attrs": {
@@ -1191,7 +1152,6 @@
1191
1152
  makeIcons: function makeIcons(file, index) {
1192
1153
  var h = this.$createElement;
1193
1154
  var icons = [];
1194
-
1195
1155
  if (this.allowRemove || this.handleIcon !== false) {
1196
1156
  if (this.uploadType !== 'file' && this.handleIcon !== false || this.uploadType === 'file' && this.handleIcon) icons.push(this.makeHandleIcon(file, index));
1197
1157
  if (this.allowRemove) icons.push(this.makeRemoveIcon(file, index));
@@ -1202,7 +1162,6 @@
1202
1162
  },
1203
1163
  makeFiles: function makeFiles() {
1204
1164
  var _this3 = this;
1205
-
1206
1165
  var h = this.$createElement;
1207
1166
  return this.uploadList.map(function (file, index) {
1208
1167
  return _this3.$scopedSlots.fileList ? _this3.$scopedSlots.fileList({
@@ -1241,7 +1200,6 @@
1241
1200
  }).filter(function (url) {
1242
1201
  return url !== undefined;
1243
1202
  });
1244
-
1245
1203
  if (this.cacheFiles.length !== files.length) {
1246
1204
  this.cacheFiles = _toConsumableArray(files);
1247
1205
  this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
@@ -1253,14 +1211,11 @@
1253
1211
  },
1254
1212
  render: function render() {
1255
1213
  var _this4 = this;
1256
-
1257
1214
  var h = arguments[0];
1258
-
1259
1215
  if (this.$refs.upload) {
1260
1216
  if (this.formCreateInject.prop.props.showUploadList === undefined) this.formCreateInject.prop.props.showUploadList = this.$refs.upload.showUploadList;
1261
1217
  this.formCreateInject.prop.props.defaultFileList = this.$refs.upload.defaultFileList;
1262
1218
  }
1263
-
1264
1219
  return h("div", {
1265
1220
  "class": "_fc-upload"
1266
1221
  }, [[this.formCreateInject.prop.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], h("Modal", {
@@ -1284,7 +1239,6 @@
1284
1239
  },
1285
1240
  mounted: function mounted() {
1286
1241
  var _this5 = this;
1287
-
1288
1242
  this.uploadList = this.$refs.upload.fileList;
1289
1243
  this.$watch(function () {
1290
1244
  return _this5.$refs.upload.fileList;
@@ -1317,14 +1271,11 @@
1317
1271
  var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1318
1272
  var mode = arguments.length > 2 ? arguments[2] : undefined;
1319
1273
  var isArr = false;
1320
-
1321
1274
  for (var key in target) {
1322
1275
  if (Object.prototype.hasOwnProperty.call(target, key)) {
1323
1276
  var clone = target[key];
1324
-
1325
1277
  if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1326
1278
  var nst = origin[key] === undefined;
1327
-
1328
1279
  if (isArr) {
1329
1280
  isArr = false;
1330
1281
  nst && $set(origin, key, []);
@@ -1339,16 +1290,13 @@
1339
1290
  } else {
1340
1291
  nst && $set(origin, key, {});
1341
1292
  }
1342
-
1343
1293
  origin[key] = deepExtend(origin[key], clone, mode);
1344
1294
  } else {
1345
1295
  $set(origin, key, clone);
1346
-
1347
1296
  if (!is.Undef(clone)) {
1348
1297
  if (!is.Undef(clone.__json)) {
1349
1298
  origin[key].__json = clone.__json;
1350
1299
  }
1351
-
1352
1300
  if (!is.Undef(clone.__origin)) {
1353
1301
  origin[key].__origin = clone.__origin;
1354
1302
  }
@@ -1356,7 +1304,6 @@
1356
1304
  }
1357
1305
  }
1358
1306
  }
1359
-
1360
1307
  return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1361
1308
  return !v || !v.__ctrl;
1362
1309
  }) : origin;
@@ -1373,10 +1320,8 @@
1373
1320
  Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1374
1321
  }
1375
1322
  }
1376
-
1377
1323
  return a;
1378
1324
  };
1379
-
1380
1325
  function extend() {
1381
1326
  return _extends$1.apply(this, arguments);
1382
1327
  }
@@ -1445,18 +1390,40 @@
1445
1390
  },
1446
1391
  computed: {
1447
1392
  formRule: function formRule() {
1448
- if (this.rule) {
1449
- return Array.isArray(this.rule) ? this.rule : [this.rule];
1450
- }
1451
-
1452
1393
  if (this.rules) {
1453
1394
  return this.rules;
1454
1395
  }
1455
-
1396
+ if (this.rule) {
1397
+ return Array.isArray(this.rule) ? this.rule : [this.rule];
1398
+ }
1456
1399
  return [];
1457
1400
  }
1458
1401
  },
1459
1402
  watch: {
1403
+ formRule: {
1404
+ handler: function handler(n, o) {
1405
+ var _this = this;
1406
+ Object.keys(this.cacheRule).forEach(function (v) {
1407
+ var item = _this.cacheRule[v];
1408
+ if (item.$f) {
1409
+ var val = item.$f.formData();
1410
+ if (n === o) {
1411
+ item.$f.deferSyncValue(function () {
1412
+ deepExtend(item.rule, n);
1413
+ item.$f.setValue(val);
1414
+ }, true);
1415
+ } else {
1416
+ var _val = item.$f.formData();
1417
+ item.$f.once('reloading', function () {
1418
+ item.$f.setValue(_val);
1419
+ });
1420
+ item.rule = deepCopy(n);
1421
+ }
1422
+ }
1423
+ });
1424
+ },
1425
+ deep: true
1426
+ },
1460
1427
  disabled: function disabled(n) {
1461
1428
  if (this.syncDisabled) {
1462
1429
  var lst = this.cacheRule;
@@ -1467,24 +1434,20 @@
1467
1434
  },
1468
1435
  expand: function expand(n) {
1469
1436
  var d = n - this.value.length;
1470
-
1471
1437
  if (d > 0) {
1472
1438
  this.expandRule(d);
1473
1439
  }
1474
1440
  },
1475
1441
  value: function value(n) {
1476
- var _this = this;
1477
-
1442
+ var _this2 = this;
1478
1443
  n = n || [];
1479
1444
  var keys = Object.keys(this.cacheRule),
1480
1445
  total = keys.length,
1481
1446
  len = total - n.length;
1482
-
1483
1447
  if (len < 0) {
1484
1448
  for (var i = len; i < 0; i++) {
1485
1449
  this.addRule(n.length + i);
1486
1450
  }
1487
-
1488
1451
  for (var _i = 0; _i < total; _i++) {
1489
1452
  this.setValue(keys[_i], n[_i]);
1490
1453
  }
@@ -1493,12 +1456,9 @@
1493
1456
  for (var _i2 = 0; _i2 < len; _i2++) {
1494
1457
  this.removeRule(keys[total - _i2 - 1]);
1495
1458
  }
1496
-
1497
- this.subForm();
1498
1459
  }
1499
-
1500
1460
  n.forEach(function (val, i) {
1501
- _this.setValue(keys[i], n[i]);
1461
+ _this2.setValue(keys[i], n[i]);
1502
1462
  });
1503
1463
  }
1504
1464
  }
@@ -1515,23 +1475,18 @@
1515
1475
  this.$emit('change', value);
1516
1476
  },
1517
1477
  formData: function formData(key, _formData) {
1518
- var _this2 = this;
1519
-
1478
+ var _this3 = this;
1520
1479
  var cacheRule = this.cacheRule;
1521
1480
  var keys = Object.keys(cacheRule);
1522
-
1523
1481
  if (keys.filter(function (k) {
1524
1482
  return cacheRule[k].$f;
1525
1483
  }).length !== keys.length) {
1526
1484
  return;
1527
1485
  }
1528
-
1529
1486
  var value = keys.map(function (k) {
1530
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1531
- var value = _this2.field ? data[_this2.field] || null : data;
1532
-
1533
- _this2.cache(k, value);
1534
-
1487
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1488
+ var value = _this3.field ? data[_this3.field] || null : data;
1489
+ _this3.cache(k, value);
1535
1490
  return value;
1536
1491
  });
1537
1492
  this.input(value);
@@ -1539,72 +1494,53 @@
1539
1494
  setValue: function setValue(key, value) {
1540
1495
  var field = this.field,
1541
1496
  $f = this.cacheRule[key].$f;
1542
-
1543
1497
  if (field) {
1544
1498
  value = _defineProperty({}, field, this._value(value));
1545
1499
  }
1546
-
1547
1500
  if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
1548
1501
  return;
1549
1502
  }
1550
-
1551
1503
  this.cache(key, value);
1552
1504
  $f.coverValue(value || {});
1553
1505
  },
1554
1506
  addRule: function addRule(i, emit) {
1555
- var _this3 = this;
1556
-
1507
+ var _this4 = this;
1557
1508
  var rule = this.formCreateInject.form.copyRules(this.formRule);
1558
1509
  var options = this.options ? _objectSpread2({}, this.options) : {
1559
1510
  submitBtn: false,
1560
1511
  resetBtn: false
1561
1512
  };
1562
-
1563
1513
  if (this.defaultValue) {
1564
1514
  if (!options.formData) options.formData = {};
1565
1515
  var defVal = deepCopy(this.defaultValue);
1566
1516
  extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1567
1517
  }
1568
-
1569
1518
  this.$set(this.cacheRule, ++this.len, {
1570
1519
  rule: rule,
1571
1520
  options: options
1572
1521
  });
1573
-
1574
1522
  if (emit) {
1575
1523
  this.$nextTick(function () {
1576
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1524
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1577
1525
  });
1578
1526
  }
1579
1527
  },
1580
1528
  add$f: function add$f(i, key, $f) {
1581
- var _this4 = this;
1582
-
1529
+ var _this5 = this;
1583
1530
  this.cacheRule[key].$f = $f;
1584
- this.subForm();
1585
1531
  this.formData(key, $f.formData());
1586
1532
  this.$nextTick(function () {
1587
- if (_this4.syncDisabled) {
1588
- $f.disabled(_this4.disabled);
1533
+ if (_this5.syncDisabled) {
1534
+ $f.disabled(_this5.disabled);
1589
1535
  }
1590
-
1591
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1536
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1592
1537
  });
1593
1538
  },
1594
- subForm: function subForm() {
1595
- var _this5 = this;
1596
-
1597
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1598
- return _this5.cacheRule[k].$f;
1599
- }));
1600
- },
1601
1539
  removeRule: function removeRule(key, emit) {
1602
1540
  var _this6 = this;
1603
-
1604
1541
  var index = Object.keys(this.cacheRule).indexOf(key);
1605
1542
  this.$delete(this.cacheRule, key);
1606
1543
  this.$delete(this.cacheValue, key);
1607
-
1608
1544
  if (emit) {
1609
1545
  this.$nextTick(function () {
1610
1546
  return _this6.$emit('remove', index);
@@ -1615,16 +1551,13 @@
1615
1551
  if (this.disabled || false === this.onBeforeAdd(this.value)) {
1616
1552
  return;
1617
1553
  }
1618
-
1619
1554
  this.addRule(i, true);
1620
1555
  },
1621
1556
  del: function del(index, key) {
1622
1557
  if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1623
1558
  return;
1624
1559
  }
1625
-
1626
1560
  this.removeRule(key, true);
1627
- this.subForm();
1628
1561
  this.value.splice(index, 1);
1629
1562
  this.input(this.value);
1630
1563
  },
@@ -1643,7 +1576,6 @@
1643
1576
  },
1644
1577
  delIcon: function delIcon(index, key) {
1645
1578
  var _this7 = this;
1646
-
1647
1579
  var h = this.$createElement;
1648
1580
  return h("Icon", {
1649
1581
  "key": "d".concat(key),
@@ -1660,7 +1592,6 @@
1660
1592
  },
1661
1593
  makeIcon: function makeIcon(total, index, key) {
1662
1594
  var _this8 = this;
1663
-
1664
1595
  if (this.$scopedSlots.button) {
1665
1596
  return this.$scopedSlots.button({
1666
1597
  total: total,
@@ -1673,11 +1604,9 @@
1673
1604
  add: this.add
1674
1605
  });
1675
1606
  }
1676
-
1677
1607
  if (index === 0) {
1678
1608
  return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
1679
1609
  }
1680
-
1681
1610
  if (index >= this.min) {
1682
1611
  return this.delIcon(index, key);
1683
1612
  }
@@ -1694,18 +1623,15 @@
1694
1623
  created: function created() {
1695
1624
  this.type = this.formCreateInject.form.$form();
1696
1625
  var d = (this.expand || 0) - this.value.length;
1697
-
1698
1626
  if (d > 0) {
1699
1627
  this.expandRule(d);
1700
1628
  }
1701
-
1702
1629
  for (var i = 0; i < this.value.length; i++) {
1703
1630
  this.addRule(i);
1704
1631
  }
1705
1632
  },
1706
1633
  render: function render() {
1707
1634
  var _this9 = this;
1708
-
1709
1635
  var h = arguments[0];
1710
1636
  var keys = Object.keys(this.cacheRule);
1711
1637
  var button = this.button;
@@ -1740,7 +1666,10 @@
1740
1666
  "span": button ? 20 : 24
1741
1667
  }
1742
1668
  }, [h("FormItem", [h(Type, helper([{
1743
- "key": key
1669
+ "key": key,
1670
+ "attrs": {
1671
+ "inFor": true
1672
+ }
1744
1673
  }, {
1745
1674
  "on": {
1746
1675
  'update:value': function updateValue(formData) {
@@ -1750,7 +1679,6 @@
1750
1679
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1751
1680
  args[_key - 1] = arguments[_key];
1752
1681
  }
1753
-
1754
1682
  return _this9.emitEvent(name, args, index, key);
1755
1683
  },
1756
1684
  input: function input($f) {
@@ -1833,11 +1761,9 @@
1833
1761
  },
1834
1762
  setValue: function setValue(value) {
1835
1763
  var str = JSON.stringify(value);
1836
-
1837
1764
  if (this.cacheValue === str) {
1838
1765
  return;
1839
1766
  }
1840
-
1841
1767
  this.cacheValue = str;
1842
1768
  this.cacheRule.$f.coverValue(value || {});
1843
1769
  },
@@ -1854,23 +1780,16 @@
1854
1780
  },
1855
1781
  add$f: function add$f($f) {
1856
1782
  var _this = this;
1857
-
1858
1783
  this.cacheRule.$f = $f;
1859
- this.subForm();
1860
1784
  this.$nextTick(function () {
1861
1785
  _this.syncDisabled && $f.disabled(_this.disabled);
1862
-
1863
1786
  _this.$emit('itemMounted', $f);
1864
1787
  });
1865
1788
  },
1866
- subForm: function subForm() {
1867
- this.formCreateInject.subForm(this.cacheRule.$f);
1868
- },
1869
1789
  emitEvent: function emitEvent(name) {
1870
1790
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1871
1791
  args[_key - 1] = arguments[_key];
1872
1792
  }
1873
-
1874
1793
  this.$emit.apply(this, [name].concat(args));
1875
1794
  }
1876
1795
  },
@@ -1903,6 +1822,17 @@
1903
1822
  var components = [Checkbox, Radio, Select, Tree, Sub, frame, upload, group];
1904
1823
 
1905
1824
  var NAME$8 = 'FormCreate';
1825
+ var getRuleInject = function getRuleInject(vm, parent) {
1826
+ if (!vm || vm === parent) {
1827
+ return;
1828
+ }
1829
+ if (vm.formCreateInject) {
1830
+ return vm.formCreateInject;
1831
+ }
1832
+ if (vm.$parent) {
1833
+ return getRuleInject(vm.$parent, parent);
1834
+ }
1835
+ };
1906
1836
  function $FormCreate(FormCreate) {
1907
1837
  return {
1908
1838
  name: NAME$8,
@@ -1934,7 +1864,12 @@
1934
1864
  extendOption: Boolean,
1935
1865
  value: Object,
1936
1866
  api: Object,
1937
- name: String
1867
+ name: String,
1868
+ subForm: {
1869
+ type: Boolean,
1870
+ "default": true
1871
+ },
1872
+ inFor: Boolean
1938
1873
  },
1939
1874
  data: function data() {
1940
1875
  return {
@@ -1946,7 +1881,8 @@
1946
1881
  unique: 1,
1947
1882
  renderRule: _toConsumableArray(this.rule || []),
1948
1883
  ctxInject: {},
1949
- updateValue: ''
1884
+ updateValue: JSON.stringify(this.value || {}),
1885
+ isMore: !!this.inFor
1950
1886
  };
1951
1887
  },
1952
1888
  render: function render() {
@@ -1968,8 +1904,8 @@
1968
1904
  watch: {
1969
1905
  value: {
1970
1906
  handler: function handler(n) {
1971
- if (JSON.stringify(n) === this.updateValue) return;
1972
- this.$f.setValue(n);
1907
+ if (JSON.stringify(n || {}) === this.updateValue) return;
1908
+ this.$f.setValue(n || {});
1973
1909
  },
1974
1910
  deep: true
1975
1911
  },
@@ -1982,18 +1918,15 @@
1982
1918
  },
1983
1919
  rule: function rule(n) {
1984
1920
  var _this = this;
1985
-
1986
1921
  if (n.length === this.renderRule.length && n.every(function (v) {
1987
1922
  return _this.renderRule.indexOf(v) > -1;
1988
1923
  })) return;
1989
1924
  this.formCreate.$handle.reloadRule(n);
1990
-
1991
1925
  this._renderRule();
1992
1926
  }
1993
1927
  },
1994
1928
  beforeCreate: function beforeCreate() {
1995
1929
  var _this2 = this;
1996
-
1997
1930
  var _this$$options$propsD = this.$options.propsData,
1998
1931
  rule = _this$$options$propsD.rule,
1999
1932
  option = _this$$options$propsD.option;
@@ -2002,6 +1935,50 @@
2002
1935
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
2003
1936
  });
2004
1937
  this.$emit('beforeCreate', this.formCreate.api());
1938
+ },
1939
+ created: function created() {
1940
+ var _this3 = this;
1941
+ var vm = this,
1942
+ fapi = this.formCreate.api();
1943
+ var addSubForm = function addSubForm() {
1944
+ if (vm.$pfc) {
1945
+ var inject = getRuleInject(vm, vm.$pfc);
1946
+ if (inject) {
1947
+ var sub;
1948
+ if (vm.isMore) {
1949
+ sub = toArray(inject.getSubForm());
1950
+ sub.push(fapi);
1951
+ } else {
1952
+ sub = fapi;
1953
+ }
1954
+ inject.subForm(sub);
1955
+ }
1956
+ }
1957
+ };
1958
+ var rmSubForm = function rmSubForm() {
1959
+ var inject = getRuleInject(vm, vm.$pfc);
1960
+ if (inject) {
1961
+ if (vm.isMore) {
1962
+ var sub = toArray(inject.getSubForm());
1963
+ var idx = sub.indexOf(fapi);
1964
+ if (idx > -1) {
1965
+ sub.splice(idx, 1);
1966
+ }
1967
+ } else {
1968
+ inject.subForm();
1969
+ }
1970
+ }
1971
+ };
1972
+ vm.$on('hook:beforeDestroy', function () {
1973
+ rmSubForm();
1974
+ });
1975
+ this.$watch(function () {
1976
+ return _this3.subForm;
1977
+ }, function (n) {
1978
+ n ? addSubForm() : rmSubForm();
1979
+ }, {
1980
+ immediate: true
1981
+ });
2005
1982
  }
2006
1983
  };
2007
1984
  }
@@ -2009,17 +1986,12 @@
2009
1986
  var normalMerge$1 = ['attrs', 'props', 'domProps', 'scopedSlots'];
2010
1987
  var toArrayMerge$1 = ['class', 'style', 'directives'];
2011
1988
  var functionalMerge$1 = ['on', 'nativeOn'];
2012
-
2013
1989
  var mergeProps = function mergeProps(objects) {
2014
1990
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2015
1991
  var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2016
-
2017
1992
  var _normalMerge = [].concat(normalMerge$1, _toConsumableArray(opt['normal'] || []));
2018
-
2019
1993
  var _toArrayMerge = [].concat(toArrayMerge$1, _toConsumableArray(opt['array'] || []));
2020
-
2021
1994
  var _functionalMerge = [].concat(functionalMerge$1, _toConsumableArray(opt['functional'] || []));
2022
-
2023
1995
  var propsMerge = opt['props'] || [];
2024
1996
  return objects.reduce(function (a, b) {
2025
1997
  for (var key in b) {
@@ -2036,9 +2008,7 @@
2036
2008
  for (var event in b[key]) {
2037
2009
  if (a[key][event]) {
2038
2010
  var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
2039
-
2040
2011
  var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
2041
-
2042
2012
  a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
2043
2013
  } else {
2044
2014
  a[key][event] = b[key][event];
@@ -2063,11 +2033,9 @@
2063
2033
  } else a[key] = b[key];
2064
2034
  }
2065
2035
  }
2066
-
2067
2036
  return a;
2068
2037
  }, initial);
2069
2038
  };
2070
-
2071
2039
  var mergeFn$1 = function mergeFn(fn1, fn2) {
2072
2040
  return function () {
2073
2041
  fn1 && fn1.apply(this, arguments);
@@ -2075,7 +2043,7 @@
2075
2043
  };
2076
2044
  };
2077
2045
 
2078
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2046
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'preview', 'component', 'cache'];
2079
2047
  var arrayAttrs = ['validate', 'children', 'control'];
2080
2048
  var normalAttrs = ['effect', 'deep'];
2081
2049
  function attrs() {
@@ -2104,30 +2072,24 @@
2104
2072
  function toJson(obj, space) {
2105
2073
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2106
2074
  if (val && val._isVue === true) return undefined;
2107
-
2108
2075
  if (_typeof(val) !== FUNCTION) {
2109
2076
  return val;
2110
2077
  }
2111
-
2112
2078
  if (val.__json) {
2113
2079
  return val.__json;
2114
2080
  }
2115
-
2116
2081
  if (val.__origin) val = val.__origin;
2117
2082
  if (val.__emit) return undefined;
2118
2083
  return PREFIX + val + SUFFIX;
2119
2084
  }, space);
2120
2085
  }
2121
-
2122
2086
  function makeFn(fn) {
2123
2087
  return eval('(' + FUNCTION + '(){return ' + fn + ' })()');
2124
2088
  }
2125
-
2126
2089
  function parseFn(fn, mode) {
2127
2090
  if (fn && is.String(fn) && fn.length > 4) {
2128
2091
  var v = fn.trim();
2129
2092
  var flag = false;
2130
-
2131
2093
  try {
2132
2094
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2133
2095
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
@@ -2143,7 +2105,6 @@
2143
2105
  } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2144
2106
  flag = true;
2145
2107
  }
2146
-
2147
2108
  if (!flag) return fn;
2148
2109
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2149
2110
  val.__json = fn;
@@ -2153,7 +2114,6 @@
2153
2114
  return undefined;
2154
2115
  }
2155
2116
  }
2156
-
2157
2117
  return fn;
2158
2118
  }
2159
2119
  function parseJson(json, mode) {
@@ -2170,8 +2130,7 @@
2170
2130
  configurable: false,
2171
2131
  writable: !!writable
2172
2132
  };
2173
- } //todo 优化位置
2174
-
2133
+ }
2175
2134
  function copyRule(rule) {
2176
2135
  return copyRules([rule])[0];
2177
2136
  }
@@ -2216,7 +2175,6 @@
2216
2175
  } catch (e) {
2217
2176
  logError(e);
2218
2177
  }
2219
-
2220
2178
  return def;
2221
2179
  }
2222
2180
 
@@ -2235,11 +2193,9 @@
2235
2193
  return function (title, field, value) {
2236
2194
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2237
2195
  var maker = new Creator(name, title, field, value, props);
2238
-
2239
2196
  if (init) {
2240
2197
  if (is.Function(init)) init(maker);else maker.props(init);
2241
2198
  }
2242
-
2243
2199
  return maker;
2244
2200
  };
2245
2201
  }
@@ -2304,13 +2260,11 @@
2304
2260
  function copy(value) {
2305
2261
  return deepCopy(value);
2306
2262
  }
2307
-
2308
2263
  function Api(h) {
2309
2264
  function tidyFields(fields) {
2310
2265
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
2311
2266
  return fields;
2312
2267
  }
2313
-
2314
2268
  function props(fields, key, val) {
2315
2269
  tidyFields(fields).forEach(function (field) {
2316
2270
  h.getCtxs(field).forEach(function (ctx) {
@@ -2319,7 +2273,6 @@
2319
2273
  });
2320
2274
  });
2321
2275
  }
2322
-
2323
2276
  function allSubForm() {
2324
2277
  var subs = h.subForm;
2325
2278
  return Object.keys(subs).reduce(function (initial, k) {
@@ -2329,39 +2282,32 @@
2329
2282
  return initial;
2330
2283
  }, []);
2331
2284
  }
2332
-
2333
2285
  var api = {
2334
2286
  get config() {
2335
2287
  return h.options;
2336
2288
  },
2337
-
2338
2289
  get options() {
2339
2290
  return h.options;
2340
2291
  },
2341
-
2342
2292
  get form() {
2343
2293
  return h.form;
2344
2294
  },
2345
-
2346
2295
  get rule() {
2347
2296
  return h.rules;
2348
2297
  },
2349
-
2350
2298
  get parent() {
2351
2299
  return h.vm.$pfc && h.vm.$pfc.$f;
2352
2300
  },
2353
-
2354
2301
  get children() {
2355
2302
  return allSubForm();
2356
2303
  },
2357
-
2358
2304
  formData: function formData(fields) {
2359
2305
  return tidyFields(fields).reduce(function (initial, id) {
2360
2306
  var ctx = h.getFieldCtx(id);
2361
2307
  if (!ctx) return initial;
2362
2308
  initial[ctx.field] = copy(ctx.rule.value);
2363
2309
  return initial;
2364
- }, copy(h.appendData));
2310
+ }, h.options.appendValue ? copy(h.appendData) : {});
2365
2311
  },
2366
2312
  getValue: function getValue(field) {
2367
2313
  var ctx = h.getFieldCtx(field);
@@ -2419,7 +2365,6 @@
2419
2365
  var index = h.sort.length - 1,
2420
2366
  rules;
2421
2367
  var ctx = h.getCtx(after);
2422
-
2423
2368
  if (ctx) {
2424
2369
  if (child) {
2425
2370
  rules = ctx.rule.children;
@@ -2429,14 +2374,12 @@
2429
2374
  rules = ctx.root;
2430
2375
  }
2431
2376
  } else rules = h.rules;
2432
-
2433
2377
  rules.splice(index + 1, 0, rule);
2434
2378
  },
2435
2379
  prepend: function prepend(rule, after, child) {
2436
2380
  var index = 0,
2437
2381
  rules;
2438
2382
  var ctx = h.getCtx(after);
2439
-
2440
2383
  if (ctx) {
2441
2384
  if (child) {
2442
2385
  rules = ctx.rule.children;
@@ -2445,7 +2388,6 @@
2445
2388
  rules = ctx.root;
2446
2389
  }
2447
2390
  } else rules = h.rules;
2448
-
2449
2391
  rules.splice(index, 0, rule);
2450
2392
  },
2451
2393
  hidden: function hidden(state, fields) {
@@ -2518,18 +2460,14 @@
2518
2460
  });
2519
2461
  return;
2520
2462
  }
2521
-
2522
2463
  var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2523
-
2524
2464
  if (!ctxs) {
2525
2465
  return;
2526
2466
  }
2527
-
2528
2467
  ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2529
2468
  ctxs.forEach(function (ctx) {
2530
2469
  if (!ctx.deleted) {
2531
2470
  var subForm = h.subForm[ctx.id];
2532
-
2533
2471
  if (subForm) {
2534
2472
  if (Array.isArray(subForm)) {
2535
2473
  subForm.forEach(function (form) {
@@ -2538,9 +2476,7 @@
2538
2476
  } else if (subForm) {
2539
2477
  subForm.refresh();
2540
2478
  }
2541
- } //ctx.updateKey(true);
2542
-
2543
-
2479
+ }
2544
2480
  h.$render.clearCache(ctx);
2545
2481
  }
2546
2482
  });
@@ -2588,11 +2524,25 @@
2588
2524
  },
2589
2525
  getRule: function getRule(id, origin) {
2590
2526
  var ctx = h.getCtx(id);
2591
-
2592
2527
  if (ctx) {
2593
2528
  return origin ? ctx.origin : ctx.rule;
2594
2529
  }
2595
2530
  },
2531
+ setEffect: function setEffect(id, attr, value) {
2532
+ var ctx = h.getCtx(id);
2533
+ if (ctx && attr) {
2534
+ if (attr[0] === '$') {
2535
+ attr = attr.substr(1);
2536
+ }
2537
+ if (hasProperty(ctx.rule, '$' + attr)) {
2538
+ $set(ctx.rule, '$' + attr, value);
2539
+ }
2540
+ if (!hasProperty(ctx.rule, 'effect')) {
2541
+ ctx.rule.effect = {};
2542
+ }
2543
+ $set(ctx.rule.effect, attr, value);
2544
+ }
2545
+ },
2596
2546
  updateValidate: function updateValidate(id, validate, merge) {
2597
2547
  if (merge) {
2598
2548
  api.mergeRule(id, {
@@ -2631,7 +2581,6 @@
2631
2581
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2632
2582
  args[_key - 2] = arguments[_key];
2633
2583
  }
2634
-
2635
2584
  return invoke(function () {
2636
2585
  return api.method(id, name).apply(void 0, args);
2637
2586
  });
@@ -2641,11 +2590,9 @@
2641
2590
  },
2642
2591
  trigger: function trigger(id, event) {
2643
2592
  var el = api.el(id);
2644
-
2645
2593
  for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2646
2594
  args[_key2 - 2] = arguments[_key2];
2647
2595
  }
2648
-
2649
2596
  el && el.$emit.apply(el, [event].concat(args));
2650
2597
  },
2651
2598
  el: function el(id) {
@@ -2670,13 +2617,14 @@
2670
2617
  },
2671
2618
  emit: function emit(name) {
2672
2619
  var _h$vm;
2673
-
2674
2620
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2675
2621
  args[_key3 - 1] = arguments[_key3];
2676
2622
  }
2677
-
2678
2623
  (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2679
2624
  },
2625
+ deferSyncValue: function deferSyncValue(fn, sync) {
2626
+ h.deferSyncValue(fn, sync);
2627
+ },
2680
2628
  helper: {
2681
2629
  tidyFields: tidyFields,
2682
2630
  props: props
@@ -2685,7 +2633,6 @@
2685
2633
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2686
2634
  api[n] = function () {
2687
2635
  var _h$vm2;
2688
-
2689
2636
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2690
2637
  };
2691
2638
  });
@@ -2703,11 +2650,9 @@
2703
2650
  ctx.parent && this.clearCache(ctx.parent);
2704
2651
  return;
2705
2652
  }
2706
-
2707
2653
  if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
2708
2654
  this.$handle.refresh();
2709
2655
  }
2710
-
2711
2656
  var parent = this.cache[ctx.id].parent;
2712
2657
  this.cache[ctx.id] = null;
2713
2658
  parent && this.clearCache(parent);
@@ -2764,10 +2709,8 @@
2764
2709
  if (!_data[to] || _typeof(_data[to]) != 'object') {
2765
2710
  _data[to] = {};
2766
2711
  }
2767
-
2768
2712
  _data = _data[to];
2769
2713
  }
2770
-
2771
2714
  to = v;
2772
2715
  });
2773
2716
  _data[to] = val;
@@ -2787,7 +2730,6 @@
2787
2730
  var children = ctxs[id].rule.children;
2788
2731
  initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2789
2732
  }
2790
-
2791
2733
  return initial;
2792
2734
  }, {});
2793
2735
  },
@@ -2796,59 +2738,46 @@
2796
2738
  },
2797
2739
  getTypeSlot: function getTypeSlot(type) {
2798
2740
  var name = 'type-' + toLine(type);
2799
-
2800
2741
  var _fn = function _fn(vm) {
2801
2742
  if (vm) {
2802
2743
  var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2803
-
2804
2744
  if (slot) {
2805
2745
  return slot;
2806
2746
  }
2807
-
2808
2747
  return _fn(vm.$pfc);
2809
2748
  }
2810
2749
  };
2811
-
2812
2750
  return _fn(this.vm);
2813
2751
  },
2814
2752
  render: function render() {
2815
2753
  var _this = this;
2816
-
2817
2754
  if (!this.vm.isShow) {
2818
2755
  return;
2819
2756
  }
2820
-
2821
2757
  this.$h = this.vm.$createElement;
2822
2758
  this.$manager.beforeRender();
2823
2759
  var vn;
2824
-
2825
2760
  var make = function make() {
2826
2761
  return _this.renderList();
2827
2762
  };
2828
-
2829
2763
  make.renderSlot = function (slot) {
2830
2764
  return _this.renderList(slot);
2831
2765
  };
2832
-
2833
2766
  make.renderName = function (name) {
2834
2767
  return _this.renderId(name);
2835
2768
  };
2836
-
2837
2769
  make.renderField = function (field) {
2838
2770
  return _this.renderId(field, 'field');
2839
2771
  };
2840
-
2841
2772
  if (this.vm.$scopedSlots.container) {
2842
2773
  vn = [this.vm.$scopedSlots.container(make)];
2843
2774
  } else {
2844
2775
  vn = make();
2845
2776
  }
2846
-
2847
2777
  return this.$manager.render(vn);
2848
2778
  },
2849
2779
  renderList: function renderList(slot) {
2850
2780
  var _this2 = this;
2851
-
2852
2781
  return this.sort.map(function (id) {
2853
2782
  return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2854
2783
  }).filter(function (val) {
@@ -2857,7 +2786,6 @@
2857
2786
  },
2858
2787
  makeVm: function makeVm(rule) {
2859
2788
  var _this3 = this;
2860
-
2861
2789
  var vm = rule.vm;
2862
2790
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2863
2791
  return rule.vm(_this3.$handle.getInjectData(rule));
@@ -2866,8 +2794,7 @@
2866
2794
  },
2867
2795
  mergeGlobal: function mergeGlobal(ctx) {
2868
2796
  var g = this.$handle.options.global;
2869
- if (!g) return; //todo 缓存配置,更新 option 更新
2870
-
2797
+ if (!g) return;
2871
2798
  if (!ctx.cacheConfig) ctx.cacheConfig = g[ctx.originType] || g[ctx.type] || g[ctx.trueType] || {};
2872
2799
  ctx.prop = mergeRule({}, [g['*'], ctx.cacheConfig, ctx.prop]);
2873
2800
  },
@@ -2894,23 +2821,19 @@
2894
2821
  if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2895
2822
  });
2896
2823
  var key = vm.$options.model && vm.$options.model.prop || 'value';
2897
-
2898
2824
  if (keys.indexOf(key) > -1) {
2899
2825
  vm.$props[key] = prop.value;
2900
2826
  }
2901
2827
  },
2902
2828
  renderTemp: function renderTemp(ctx) {
2903
2829
  var _this4 = this;
2904
-
2905
2830
  if (!_vue.compile) {
2906
2831
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
2907
2832
  return [];
2908
2833
  }
2909
-
2910
2834
  var rule = ctx.prop;
2911
2835
  var id = ctx.id,
2912
2836
  key = ctx.key;
2913
-
2914
2837
  if (!this.tempList[id]) {
2915
2838
  if (!ctx.el) {
2916
2839
  ctx.el = this.makeVm(rule);
@@ -2918,7 +2841,6 @@
2918
2841
  return ctx.parser.mounted(ctx);
2919
2842
  });
2920
2843
  }
2921
-
2922
2844
  var _vm = ctx.el;
2923
2845
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2924
2846
  _this4.onInput(ctx, value);
@@ -2928,7 +2850,6 @@
2928
2850
  template: _vue.compile(rule.template)
2929
2851
  };
2930
2852
  }
2931
-
2932
2853
  var _this$tempList$id = this.tempList[id],
2933
2854
  vm = _this$tempList$id.vm,
2934
2855
  template = _this$tempList$id.template;
@@ -2952,7 +2873,6 @@
2952
2873
  },
2953
2874
  renderId: function renderId(name, type) {
2954
2875
  var _this5 = this;
2955
-
2956
2876
  var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2957
2877
  return ctxs ? ctxs.map(function (ctx) {
2958
2878
  return _this5.renderCtx(ctx, ctx.parent);
@@ -2961,21 +2881,16 @@
2961
2881
  renderCtx: function renderCtx(ctx, parent) {
2962
2882
  if (ctx.type === 'hidden') return;
2963
2883
  var rule = ctx.rule;
2964
- var preview = this.options.preview || false;
2965
-
2966
2884
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2967
2885
  var vn;
2968
- var cacheFlag = true;
2886
+ var cacheFlag = rule.cache !== false;
2969
2887
  var _type = ctx.trueType;
2970
2888
  var none = !(is.Undef(rule.display) || !!rule.display);
2971
-
2972
2889
  if (_type === 'template' && !rule.template) {
2973
2890
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2974
-
2975
2891
  if (none) {
2976
2892
  this.display(vn);
2977
2893
  }
2978
-
2979
2894
  vn = this.item(ctx, vn);
2980
2895
  } else if (_type === 'fcFragment') {
2981
2896
  vn = this.renderChildren(ctx);
@@ -2987,27 +2902,24 @@
2987
2902
  this.setOptions(ctx);
2988
2903
  this.ctxProp(ctx);
2989
2904
  var prop = ctx.prop;
2905
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
2990
2906
  prop.props.formCreateInject = this.injectProp(ctx);
2991
-
2907
+ var preview = prop.preview;
2992
2908
  if (prop.hidden) {
2993
2909
  this.setCache(ctx, undefined, parent);
2994
2910
  return;
2995
2911
  }
2996
-
2997
2912
  if (_type === 'template' && prop.template) {
2998
2913
  vn = this.renderTemp(ctx);
2999
2914
  cacheFlag = false;
3000
2915
  } else {
3001
2916
  var children = [];
3002
-
3003
2917
  if (ctx.parser.renderChildren) {
3004
2918
  children = ctx.parser.renderChildren(ctx);
3005
2919
  } else if (ctx.parser.loadChildren !== false) {
3006
2920
  children = this.renderChildren(ctx);
3007
2921
  }
3008
-
3009
2922
  var slot = this.getTypeSlot(ctx.type);
3010
-
3011
2923
  if (slot) {
3012
2924
  vn = slot({
3013
2925
  rule: rule,
@@ -3021,32 +2933,24 @@
3021
2933
  vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3022
2934
  }
3023
2935
  }
3024
-
3025
2936
  vn = this.renderSides(vn, ctx);
3026
-
3027
2937
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3028
2938
  vn = this.$manager.makeWrap(ctx, vn);
3029
2939
  }
3030
-
3031
2940
  if (none) {
3032
2941
  vn = this.display(vn);
3033
2942
  }
3034
-
3035
2943
  vn = this.item(ctx, vn);
3036
2944
  }
3037
-
3038
2945
  if (cacheFlag) {
3039
2946
  this.setCache(ctx, vn, parent);
3040
2947
  }
3041
-
3042
2948
  return vn;
3043
2949
  }
3044
-
3045
2950
  return this.getCache(ctx);
3046
2951
  },
3047
2952
  display: function display(vn) {
3048
2953
  var _this6 = this;
3049
-
3050
2954
  if (Array.isArray(vn)) {
3051
2955
  var data = [];
3052
2956
  vn.forEach(function (v) {
@@ -3064,12 +2968,13 @@
3064
2968
  vn.data.style.push({
3065
2969
  display: 'none'
3066
2970
  });
2971
+ } else if (is.String(vn.data.style)) {
2972
+ vn.data.style += ';display:none;';
3067
2973
  } else {
3068
2974
  vn.data.style = [vn.data.style, {
3069
2975
  display: 'none'
3070
2976
  }];
3071
2977
  }
3072
-
3073
2978
  return vn;
3074
2979
  }
3075
2980
  },
@@ -3081,7 +2986,6 @@
3081
2986
  },
3082
2987
  injectProp: function injectProp(ctx) {
3083
2988
  var _this7 = this;
3084
-
3085
2989
  if (!this.vm.ctxInject[ctx.id]) {
3086
2990
  $set(this.vm.ctxInject, ctx.id, {
3087
2991
  api: this.$handle.api,
@@ -3089,23 +2993,25 @@
3089
2993
  subForm: function subForm(_subForm) {
3090
2994
  _this7.$handle.addSubForm(ctx, _subForm);
3091
2995
  },
2996
+ getSubForm: function getSubForm() {
2997
+ return _this7.$handle.subForm[ctx.id];
2998
+ },
3092
2999
  options: [],
3093
3000
  children: [],
3094
3001
  prop: {},
3095
3002
  preview: false,
3096
3003
  field: ctx.field,
3097
- rule: ctx.rule
3004
+ rule: ctx.rule,
3005
+ input: ctx.input
3098
3006
  });
3099
3007
  }
3100
-
3101
3008
  var inject = this.vm.ctxInject[ctx.id];
3102
3009
  extend(inject, {
3103
- preview: this.options.preview || false,
3010
+ preview: ctx.prop.preview,
3104
3011
  options: ctx.prop.options,
3105
3012
  children: ctx.rule.children,
3106
3013
  prop: function () {
3107
3014
  var temp = _objectSpread2({}, ctx.prop);
3108
-
3109
3015
  temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3110
3016
  delete temp.model;
3111
3017
  return temp;
@@ -3115,7 +3021,6 @@
3115
3021
  },
3116
3022
  ctxProp: function ctxProp(ctx, custom) {
3117
3023
  var _this8 = this;
3118
-
3119
3024
  var ref = ctx.ref,
3120
3025
  key = ctx.key,
3121
3026
  rule = ctx.rule;
@@ -3134,7 +3039,6 @@
3134
3039
  }
3135
3040
  }
3136
3041
  }];
3137
-
3138
3042
  if (!custom && ctx.input) {
3139
3043
  ctx.prop.model = {
3140
3044
  value: this.$handle.getFormData(ctx),
@@ -3144,17 +3048,14 @@
3144
3048
  expression: "formData.".concat(ctx.id)
3145
3049
  };
3146
3050
  }
3147
-
3148
3051
  mergeProps(props, ctx.prop);
3149
3052
  return ctx.prop;
3150
3053
  },
3151
3054
  onMounted: function onMounted(ctx) {
3152
3055
  ctx.el = this.vm.$refs[ctx.ref];
3153
-
3154
3056
  if (ctx.el) {
3155
3057
  (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3156
3058
  }
3157
-
3158
3059
  ctx.parser.mounted(ctx);
3159
3060
  this.$handle.effect(ctx, 'mounted');
3160
3061
  },
@@ -3163,19 +3064,15 @@
3163
3064
  },
3164
3065
  renderChildren: function renderChildren(ctx) {
3165
3066
  var _this9 = this;
3166
-
3167
3067
  var children = ctx.rule.children,
3168
3068
  orgChildren = this.orgChildren[ctx.id];
3169
-
3170
3069
  var isRm = function isRm(child) {
3171
3070
  return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3172
3071
  };
3173
-
3174
3072
  if (!is.trueArray(children) && orgChildren) {
3175
3073
  this.$handle.deferSyncValue(function () {
3176
3074
  orgChildren.forEach(function (child) {
3177
3075
  if (!child) return;
3178
-
3179
3076
  if (isRm(child)) {
3180
3077
  _this9.$handle.rmCtx(child.__fc__);
3181
3078
  }
@@ -3184,11 +3081,9 @@
3184
3081
  this.orgChildren[ctx.id] = [];
3185
3082
  return [];
3186
3083
  }
3187
-
3188
3084
  orgChildren && this.$handle.deferSyncValue(function () {
3189
3085
  orgChildren.forEach(function (child) {
3190
3086
  if (!child) return;
3191
-
3192
3087
  if (children.indexOf(child) === -1 && isRm(child)) {
3193
3088
  _this9.$handle.rmCtx(child.__fc__);
3194
3089
  }
@@ -3197,15 +3092,12 @@
3197
3092
  return children.map(function (child) {
3198
3093
  if (!child) return;
3199
3094
  if (is.String(child)) return child;
3200
-
3201
3095
  if (child.__fc__) {
3202
3096
  return _this9.renderCtx(child.__fc__, ctx);
3203
3097
  }
3204
-
3205
3098
  if (child.type) {
3206
3099
  _this9.vm.$nextTick(function () {
3207
3100
  _this9.$handle.loadChildren(children, ctx);
3208
-
3209
3101
  _this9.$handle.refresh();
3210
3102
  });
3211
3103
  }
@@ -3213,38 +3105,33 @@
3213
3105
  },
3214
3106
  defaultRender: function defaultRender(ctx, children) {
3215
3107
  var prop = ctx.prop;
3108
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3216
3109
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3217
3110
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3218
3111
  return this.vNode.make(lower(ctx.originType), prop, children);
3219
3112
  },
3220
3113
  renderRule: function renderRule(rule, children, origin) {
3221
3114
  var _this10 = this;
3222
-
3223
3115
  if (!rule) return undefined;
3224
3116
  if (is.String(rule)) return rule;
3225
3117
  var type;
3226
-
3227
3118
  if (origin) {
3228
3119
  type = rule.type;
3229
3120
  } else {
3230
3121
  type = rule.is;
3231
-
3232
3122
  if (rule.type) {
3233
3123
  type = toCase(rule.type);
3234
3124
  var alias = this.vNode.aliasMap[type];
3235
3125
  if (alias) type = toCase(alias);
3236
3126
  }
3237
3127
  }
3238
-
3239
3128
  if (!type) return undefined;
3240
3129
  var data = [[children]];
3241
-
3242
3130
  if (is.trueArray(rule.children)) {
3243
3131
  data.push(rule.children.map(function (v) {
3244
3132
  return _this10.renderRule(v);
3245
3133
  }));
3246
3134
  }
3247
-
3248
3135
  return this.$h(type, _objectSpread2({}, rule), data);
3249
3136
  }
3250
3137
  });
@@ -3280,10 +3167,8 @@
3280
3167
  },
3281
3168
  parseEventLst: function parseEventLst(rule, data, inject, deep) {
3282
3169
  var _this = this;
3283
-
3284
3170
  Object.keys(data).forEach(function (k) {
3285
3171
  var fn = _this.parseEvent(rule, data[k], inject, deep);
3286
-
3287
3172
  if (fn) {
3288
3173
  data[k] = fn;
3289
3174
  }
@@ -3297,7 +3182,6 @@
3297
3182
  return this.parseEventLst(rule, fn, inject, true);
3298
3183
  } else if (is.String(fn)) {
3299
3184
  var val = parseFn(fn);
3300
-
3301
3185
  if (val && fn !== val) {
3302
3186
  return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3303
3187
  }
@@ -3305,7 +3189,6 @@
3305
3189
  },
3306
3190
  parseEmit: function parseEmit(ctx, on) {
3307
3191
  var _this2 = this;
3308
-
3309
3192
  var event = {},
3310
3193
  rule = ctx.rule,
3311
3194
  emitPrefix = rule.emitPrefix,
@@ -3313,48 +3196,36 @@
3313
3196
  name = rule.name,
3314
3197
  inject = rule.inject;
3315
3198
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3316
-
3317
3199
  if (is.trueArray(emit)) {
3318
3200
  var emitKey = emitPrefix || field || name;
3319
-
3320
3201
  if (emitKey) {
3321
3202
  if (!on) emitKey = "native-".concat(emitKey);
3322
3203
  emit.forEach(function (eventName) {
3323
3204
  if (!eventName) return;
3324
3205
  var eventInject;
3325
-
3326
3206
  if (is.Object(eventName)) {
3327
3207
  eventInject = eventName.inject;
3328
3208
  eventName = eventName.name;
3329
3209
  }
3330
-
3331
3210
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3332
-
3333
3211
  var fn = function fn() {
3334
3212
  var _this2$vm, _this2$vm2;
3335
-
3336
3213
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3337
3214
  arg[_key] = arguments[_key];
3338
3215
  }
3339
-
3340
3216
  (_this2$vm = _this2.vm).$emit.apply(_this2$vm, [fieldKey].concat(arg));
3341
-
3342
3217
  (_this2$vm2 = _this2.vm).$emit.apply(_this2$vm2, ['emit-event', fieldKey].concat(arg));
3343
3218
  };
3344
-
3345
3219
  fn.__emit = true;
3346
-
3347
3220
  if (!eventInject && inject === false) {
3348
3221
  event[eventName] = fn;
3349
3222
  } else {
3350
3223
  var _inject = eventInject || inject || _this2.options.injectEvent;
3351
-
3352
3224
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3353
3225
  }
3354
3226
  });
3355
3227
  }
3356
3228
  }
3357
-
3358
3229
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3359
3230
  return event;
3360
3231
  },
@@ -3376,21 +3247,16 @@
3376
3247
  if (this.watching && !this.loading) return _fn;
3377
3248
  _fn = _fn.__origin;
3378
3249
  }
3379
-
3380
3250
  var h = this;
3381
-
3382
3251
  var fn = function fn() {
3383
3252
  var data = h.getInjectData(self, _inject2);
3384
-
3385
3253
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3386
3254
  args[_key2] = arguments[_key2];
3387
3255
  }
3388
-
3389
3256
  data.args = [].concat(args);
3390
3257
  args.unshift(data);
3391
3258
  return _fn.apply(this, args);
3392
3259
  };
3393
-
3394
3260
  fn.__origin = _fn;
3395
3261
  fn.__json = _fn.__json;
3396
3262
  return fn;
@@ -3403,17 +3269,14 @@
3403
3269
  extend(Handler.prototype, {
3404
3270
  usePage: function usePage() {
3405
3271
  var _this = this;
3406
-
3407
3272
  var page = this.options.page;
3408
3273
  if (!page) return;
3409
3274
  var first = 25;
3410
3275
  var limit = getLimit(this.rules);
3411
-
3412
3276
  if (is.Object(page)) {
3413
3277
  if (page.first) first = parseInt(page.first, 10) || first;
3414
3278
  if (page.limit) limit = parseInt(page.limit, 10) || limit;
3415
3279
  }
3416
-
3417
3280
  extend(this, {
3418
3281
  first: first,
3419
3282
  limit: limit,
@@ -3426,27 +3289,21 @@
3426
3289
  },
3427
3290
  pageLoad: function pageLoad() {
3428
3291
  var _this2 = this;
3429
-
3430
3292
  var pageFn = function pageFn() {
3431
3293
  if (_this2.pageEnd) {
3432
3294
  _this2.vm.$off(EVENT, pageFn);
3433
-
3434
3295
  _this2.bus.$emit('page-end');
3435
3296
  } else {
3436
3297
  _this2.first += _this2.limit;
3437
3298
  _this2.pageEnd = _this2.rules.length <= _this2.first;
3438
-
3439
3299
  _this2.loadRule();
3440
-
3441
3300
  _this2.refresh();
3442
3301
  }
3443
3302
  };
3444
-
3445
3303
  this.vm.$on(EVENT, pageFn);
3446
3304
  }
3447
3305
  });
3448
3306
  }
3449
-
3450
3307
  function getLimit(rules) {
3451
3308
  return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
3452
3309
  }
@@ -3459,7 +3316,6 @@
3459
3316
  },
3460
3317
  bindNextTick: function bindNextTick(fn) {
3461
3318
  var _this = this;
3462
-
3463
3319
  this.clearNextTick();
3464
3320
  this.nextTick = setTimeout(function () {
3465
3321
  fn();
@@ -3467,7 +3323,6 @@
3467
3323
  }, 10);
3468
3324
  },
3469
3325
  render: function render() {
3470
- // console.warn('%c render', 'color:green');
3471
3326
  ++this.loadedId;
3472
3327
  if (this.vm.unique > 0) return this.$render.render();else {
3473
3328
  this.vm.unique = 1;
@@ -3482,7 +3337,6 @@
3482
3337
  __fc__: enumerable(ctx, true)
3483
3338
  });
3484
3339
  }
3485
-
3486
3340
  function RuleContext(handle, rule) {
3487
3341
  var id = uniqueId();
3488
3342
  extend(this, {
@@ -3516,7 +3370,6 @@
3516
3370
  if (!this.payload[name]) {
3517
3371
  this.payload[name] = {};
3518
3372
  }
3519
-
3520
3373
  return this.payload[name];
3521
3374
  },
3522
3375
  clearEffectData: function clearEffectData(name) {
@@ -3536,9 +3389,7 @@
3536
3389
  },
3537
3390
  initProp: function initProp() {
3538
3391
  var _this = this;
3539
-
3540
3392
  var rule = _objectSpread2({}, this.rule);
3541
-
3542
3393
  delete rule.children;
3543
3394
  this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3544
3395
  return _this.payload[k];
@@ -3593,31 +3444,22 @@
3593
3444
  },
3594
3445
  rm: function rm() {
3595
3446
  var _this2 = this;
3596
-
3597
3447
  var _rm = function _rm() {
3598
3448
  var index = _this2.root.indexOf(_this2.origin);
3599
-
3600
3449
  if (index > -1) {
3601
3450
  _this2.root.splice(index, 1);
3602
-
3603
3451
  _this2.$handle && _this2.$handle.refresh();
3604
3452
  }
3605
3453
  };
3606
-
3607
3454
  if (this.deleted) {
3608
3455
  _rm();
3609
-
3610
3456
  return;
3611
3457
  }
3612
-
3613
3458
  this.$handle.noWatch(function () {
3614
3459
  _this2.$handle.deferSyncValue(function () {
3615
3460
  _this2.rmCtrl();
3616
-
3617
3461
  _rm();
3618
-
3619
3462
  _this2.$handle.rmCtx(_this2);
3620
-
3621
3463
  extend(_this2, {
3622
3464
  root: []
3623
3465
  });
@@ -3645,7 +3487,6 @@
3645
3487
  extend(Handler.prototype, {
3646
3488
  nextRefresh: function nextRefresh(fn) {
3647
3489
  var _this = this;
3648
-
3649
3490
  var id = this.loadedId;
3650
3491
  this.vm.$nextTick(function () {
3651
3492
  id === _this.loadedId && (fn ? fn() : _this.refresh());
@@ -3653,7 +3494,6 @@
3653
3494
  },
3654
3495
  parseRule: function parseRule(_rule) {
3655
3496
  var _this2 = this;
3656
-
3657
3497
  var rule = getRule(_rule);
3658
3498
  Object.defineProperties(rule, {
3659
3499
  __origin__: enumerable(_rule, true)
@@ -3665,20 +3505,16 @@
3665
3505
  if (!item) {
3666
3506
  return;
3667
3507
  }
3668
-
3669
3508
  _this2.loadFn(item, rule);
3670
3509
  });
3671
3510
  this.loadCtrl(rule);
3672
-
3673
3511
  if (rule.update) {
3674
3512
  rule.update = parseFn(rule.update);
3675
3513
  }
3676
-
3677
3514
  return rule;
3678
3515
  },
3679
3516
  loadFn: function loadFn(item, rule) {
3680
3517
  var _this3 = this;
3681
-
3682
3518
  ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3683
3519
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3684
3520
  });
@@ -3692,48 +3528,35 @@
3692
3528
  },
3693
3529
  syncProp: function syncProp(ctx) {
3694
3530
  var _this4 = this;
3695
-
3696
3531
  var rule = ctx.rule;
3697
3532
  is.trueArray(rule.sync) && mergeProps([{
3698
3533
  on: rule.sync.reduce(function (pre, prop) {
3699
3534
  pre["update:".concat(prop)] = function (val) {
3700
3535
  rule.props[prop] = val;
3701
-
3702
3536
  _this4.vm.$emit('sync', prop, val, rule, _this4.fapi);
3703
3537
  };
3704
-
3705
3538
  return pre;
3706
3539
  }, {})
3707
3540
  }], ctx.computed);
3708
3541
  },
3709
3542
  loadRule: function loadRule() {
3710
3543
  var _this5 = this;
3711
-
3712
- // console.warn('%c load', 'color:blue');
3713
3544
  this.cycleLoad = false;
3714
3545
  this.loading = true;
3715
-
3716
3546
  if (this.pageEnd) {
3717
3547
  this.bus.$emit('load-start');
3718
3548
  }
3719
-
3720
3549
  this.deferSyncValue(function () {
3721
3550
  _this5._loadRule(_this5.rules);
3722
-
3723
3551
  _this5.loading = false;
3724
-
3725
3552
  if (_this5.cycleLoad && _this5.pageEnd) {
3726
3553
  return _this5.loadRule();
3727
3554
  }
3728
-
3729
3555
  if (_this5.pageEnd) {
3730
3556
  _this5.bus.$emit('load-end');
3731
3557
  }
3732
-
3733
3558
  _this5.vm._renderRule();
3734
-
3735
3559
  _this5.$render.initOrgChildren();
3736
-
3737
3560
  _this5.syncForm();
3738
3561
  });
3739
3562
  },
@@ -3741,79 +3564,60 @@
3741
3564
  this.cycleLoad = false;
3742
3565
  this.loading = true;
3743
3566
  this.bus.$emit('load-start');
3744
-
3745
3567
  this._loadRule(children, parent);
3746
-
3747
3568
  this.loading = false;
3748
-
3749
3569
  if (this.cycleLoad) {
3750
3570
  return this.loadRule();
3751
3571
  } else {
3752
3572
  this.bus.$emit('load-end');
3753
3573
  this.syncForm();
3754
3574
  }
3755
-
3756
3575
  this.$render.clearCache(parent);
3757
3576
  },
3758
3577
  _loadRule: function _loadRule(rules, parent) {
3759
3578
  var _this6 = this;
3760
-
3761
3579
  var preIndex = function preIndex(i) {
3762
3580
  var pre = rules[i - 1];
3763
-
3764
3581
  if (!pre || !pre.__fc__) {
3765
3582
  return i > 0 ? preIndex(i - 1) : -1;
3766
3583
  }
3767
-
3768
3584
  var index = _this6.sort.indexOf(pre.__fc__.id);
3769
-
3770
3585
  return index > -1 ? index : preIndex(i - 1);
3771
3586
  };
3772
-
3773
3587
  var loadChildren = function loadChildren(children, parent) {
3774
3588
  if (is.trueArray(children)) {
3775
3589
  _this6._loadRule(children, parent);
3776
3590
  }
3777
3591
  };
3778
-
3779
3592
  rules.map(function (_rule, index) {
3780
3593
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
3781
3594
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
3782
3595
  if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
3783
-
3784
3596
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
3785
3597
  loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
3786
3598
  return _rule.__fc__;
3787
3599
  }
3788
-
3789
3600
  var rule = getRule(_rule);
3790
-
3791
3601
  var isRepeat = function isRepeat() {
3792
3602
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3793
3603
  };
3794
-
3795
3604
  _this6.ruleEffect(rule, 'init', {
3796
3605
  repeat: isRepeat()
3797
3606
  });
3798
-
3799
3607
  if (isRepeat()) {
3800
3608
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3801
3609
  }
3802
-
3803
3610
  var ctx;
3804
3611
  var isCopy = false;
3805
3612
  var isInit = !!_rule.__fc__;
3806
-
3807
3613
  if (isInit) {
3808
3614
  ctx = _rule.__fc__;
3809
3615
  var check = !ctx.check(_this6);
3810
-
3811
3616
  if (ctx.deleted) {
3812
3617
  if (check) {
3813
3618
  if (isCtrl(ctx)) {
3814
3619
  return;
3815
3620
  }
3816
-
3817
3621
  ctx.update(_this6);
3818
3622
  }
3819
3623
  } else {
@@ -3821,66 +3625,49 @@
3821
3625
  if (isCtrl(ctx)) {
3822
3626
  return;
3823
3627
  }
3824
-
3825
3628
  rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
3826
3629
  ctx = null;
3827
3630
  isCopy = true;
3828
3631
  }
3829
3632
  }
3830
3633
  }
3831
-
3832
3634
  if (!ctx) {
3833
3635
  ctx = new RuleContext(_this6, _this6.parseRule(_rule));
3834
-
3835
3636
  _this6.bindParser(ctx);
3836
3637
  } else {
3837
3638
  if (ctx.originType !== ctx.rule.type) {
3838
3639
  ctx.updateType();
3839
-
3840
3640
  _this6.bindParser(ctx);
3841
3641
  }
3842
-
3843
3642
  _this6.appendValue(ctx.rule);
3844
3643
  }
3845
-
3846
3644
  [false, true].forEach(function (b) {
3847
3645
  return _this6.parseEmit(ctx, b);
3848
3646
  });
3849
-
3850
3647
  _this6.syncProp(ctx);
3851
-
3852
3648
  ctx.parent = parent || null;
3853
3649
  ctx.root = rules;
3854
-
3855
3650
  _this6.setCtx(ctx);
3856
-
3857
3651
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3858
3652
  ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3859
-
3860
3653
  if (!parent) {
3861
3654
  var _preIndex = preIndex(index);
3862
-
3863
3655
  if (_preIndex > -1 || !index) {
3864
3656
  _this6.sort.splice(_preIndex + 1, 0, ctx.id);
3865
3657
  } else {
3866
3658
  _this6.sort.push(ctx.id);
3867
3659
  }
3868
3660
  }
3869
-
3870
3661
  var r = ctx.rule;
3871
-
3872
3662
  if (!ctx.updated) {
3873
3663
  ctx.updated = true;
3874
-
3875
3664
  if (is.Function(r.update)) {
3876
3665
  _this6.bus.$once('load-end', function () {
3877
3666
  _this6.refreshUpdate(ctx, r.value);
3878
3667
  });
3879
3668
  }
3880
-
3881
3669
  _this6.effect(ctx, 'loaded');
3882
3670
  }
3883
-
3884
3671
  if (ctx.input) Object.defineProperty(r, 'value', _this6.valueHandle(ctx));
3885
3672
  if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
3886
3673
  return ctx;
@@ -3891,20 +3678,16 @@
3891
3678
  },
3892
3679
  useCtrl: function useCtrl(ctx) {
3893
3680
  var _this7 = this;
3894
-
3895
3681
  var controls = getCtrl(ctx),
3896
3682
  validate = [],
3897
3683
  api = this.api;
3898
3684
  if (!controls.length) return false;
3899
-
3900
3685
  var _loop = function _loop(i) {
3901
3686
  var control = controls[i],
3902
3687
  handleFn = control.handle || function (val) {
3903
3688
  return val === control.value;
3904
3689
  };
3905
-
3906
3690
  if (!is.trueArray(control.rule)) return "continue";
3907
-
3908
3691
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3909
3692
  valid: invoke(function () {
3910
3693
  return handleFn(ctx.rule.value, api);
@@ -3912,17 +3695,13 @@
3912
3695
  ctrl: findCtrl(ctx, control.rule),
3913
3696
  isHidden: is.String(control.rule[0])
3914
3697
  });
3915
-
3916
3698
  if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3917
3699
  validate.push(data);
3918
3700
  };
3919
-
3920
3701
  for (var i = 0; i < controls.length; i++) {
3921
3702
  var _ret = _loop(i);
3922
-
3923
3703
  if (_ret === "continue") continue;
3924
3704
  }
3925
-
3926
3705
  if (!validate.length) return false;
3927
3706
  var flag = false;
3928
3707
  this.deferSyncValue(function () {
@@ -3934,21 +3713,17 @@
3934
3713
  append = _ref.append,
3935
3714
  child = _ref.child,
3936
3715
  ctrl = _ref.ctrl;
3937
-
3938
3716
  if (isHidden) {
3939
3717
  valid ? ctx.ctrlRule.push({
3940
3718
  __ctrl: true,
3941
3719
  children: rule,
3942
3720
  valid: valid
3943
3721
  }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3944
-
3945
3722
  _this7.vm.$nextTick(function () {
3946
3723
  _this7.api.hidden(!valid, rule);
3947
3724
  });
3948
-
3949
3725
  return;
3950
3726
  }
3951
-
3952
3727
  if (valid) {
3953
3728
  flag = true;
3954
3729
  var ruleCon = {
@@ -3958,9 +3733,7 @@
3958
3733
  children: rule
3959
3734
  };
3960
3735
  ctx.ctrlRule.push(ruleCon);
3961
-
3962
3736
  _this7.bus.$once('load-start', function () {
3963
- // this.cycleLoad = true;
3964
3737
  if (prepend) {
3965
3738
  api.prepend(ruleCon, prepend, child);
3966
3739
  } else if (append || child) {
@@ -3985,60 +3758,53 @@
3985
3758
  },
3986
3759
  _reloadRule: function _reloadRule(rules) {
3987
3760
  var _this8 = this;
3988
-
3989
- // console.warn('%c reload', 'color:red');
3990
3761
  if (!rules) rules = this.rules;
3991
-
3992
3762
  var ctxs = _objectSpread2({}, this.ctxs);
3993
-
3994
3763
  this.clearNextTick();
3995
3764
  this.$render.clearOrgChildren();
3996
3765
  this.initData(rules);
3997
3766
  this.fc.rules = rules;
3998
- this.bus.$once('load-end', function () {
3999
- Object.keys(ctxs).filter(function (id) {
4000
- return _this8.ctxs[id] === undefined;
4001
- }).forEach(function (id) {
4002
- return _this8.rmCtx(ctxs[id]);
3767
+ this.deferSyncValue(function () {
3768
+ _this8.bus.$once('load-end', function () {
3769
+ Object.keys(ctxs).filter(function (id) {
3770
+ return _this8.ctxs[id] === undefined;
3771
+ }).forEach(function (id) {
3772
+ return _this8.rmCtx(ctxs[id]);
3773
+ });
3774
+ _this8.$render.clearCacheAll();
4003
3775
  });
4004
-
4005
- _this8.$render.clearCacheAll();
3776
+ _this8.reloading = true;
3777
+ _this8.loadRule();
3778
+ _this8.reloading = false;
3779
+ _this8.refresh();
3780
+ _this8.vm.$emit('reloading', _this8.api);
4006
3781
  });
4007
- this.reloading = true;
4008
- this.loadRule();
4009
- this.reloading = false;
4010
- this.refresh();
4011
3782
  this.bus.$off('next-tick', this.nextReload);
4012
3783
  this.bus.$once('next-tick', this.nextReload);
4013
3784
  this.vm.$emit('update', this.api);
4014
3785
  },
4015
- //todo 组件生成全部通过 alias
4016
3786
  refresh: function refresh() {
4017
3787
  this.vm._refresh();
4018
3788
  }
4019
3789
  });
4020
3790
  }
4021
-
4022
3791
  function fullRule(rule) {
4023
3792
  var def = baseRule();
4024
3793
  Object.keys(def).forEach(function (k) {
4025
- if (!hasProperty(rule, k)) rule[k] = def[k];
3794
+ if (!hasProperty(rule, k)) $set(rule, k, def[k]);
4026
3795
  });
4027
3796
  return rule;
4028
3797
  }
4029
-
4030
3798
  function getCtrl(ctx) {
4031
3799
  var control = ctx.rule.control || [];
4032
3800
  if (is.Object(control)) return [control];else return control;
4033
3801
  }
4034
-
4035
3802
  function findCtrl(ctx, rule) {
4036
3803
  for (var i = 0; i < ctx.ctrlRule.length; i++) {
4037
3804
  var ctrl = ctx.ctrlRule[i];
4038
3805
  if (ctrl.children === rule) return ctrl;
4039
3806
  }
4040
3807
  }
4041
-
4042
3808
  function isCtrl(ctx) {
4043
3809
  return !!ctx.rule.__ctrl;
4044
3810
  }
@@ -4049,7 +3815,6 @@
4049
3815
  if (is.Undef(ctx.cacheValue)) {
4050
3816
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
4051
3817
  }
4052
-
4053
3818
  return ctx.cacheValue;
4054
3819
  },
4055
3820
  setValue: function setValue(ctx, value, formValue, setFlag) {
@@ -4066,7 +3831,6 @@
4066
3831
  },
4067
3832
  onInput: function onInput(ctx, value) {
4068
3833
  var val;
4069
-
4070
3834
  if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, val))) {
4071
3835
  this.setValue(ctx, val, value);
4072
3836
  }
@@ -4079,7 +3843,6 @@
4079
3843
  },
4080
3844
  validate: function validate() {
4081
3845
  var _this = this;
4082
-
4083
3846
  toEmpty(this.vm.validate);
4084
3847
  this.fields().forEach(function (id) {
4085
3848
  _this.fieldCtx[id].forEach(function (ctx) {
@@ -4090,17 +3853,14 @@
4090
3853
  },
4091
3854
  syncForm: function syncForm() {
4092
3855
  var _this2 = this;
4093
-
4094
3856
  toEmpty(this.form);
4095
3857
  Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4096
3858
  var ctx = _this2.getFieldCtx(field);
4097
-
4098
3859
  var handle = _this2.valueHandle(ctx);
4099
-
4100
3860
  handle.configurable = true;
4101
3861
  initial[field] = handle;
4102
3862
  return initial;
4103
- }, Object.keys(this.appendData).reduce(function (initial, field) {
3863
+ }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4104
3864
  initial[field] = {
4105
3865
  enumerable: true,
4106
3866
  configurable: true,
@@ -4112,12 +3872,11 @@
4112
3872
  }
4113
3873
  };
4114
3874
  return initial;
4115
- }, {})));
3875
+ }, {}) : {}));
4116
3876
  this.syncValue();
4117
3877
  },
4118
3878
  valueHandle: function valueHandle(ctx) {
4119
3879
  var _this3 = this;
4120
-
4121
3880
  return {
4122
3881
  enumerable: true,
4123
3882
  get: function get() {
@@ -4136,24 +3895,18 @@
4136
3895
  delete this.appendData[rule.field];
4137
3896
  },
4138
3897
  addSubForm: function addSubForm(ctx, subForm) {
4139
- if (ctx.input) {
4140
- this.subForm[ctx.id] = subForm;
4141
- }
3898
+ this.subForm[ctx.id] = subForm;
4142
3899
  },
4143
3900
  deferSyncValue: function deferSyncValue(fn, sync) {
4144
3901
  if (!this.deferSyncFn) {
4145
3902
  this.deferSyncFn = fn;
4146
3903
  }
4147
-
4148
3904
  if (!this.deferSyncFn.sync) {
4149
3905
  this.deferSyncFn.sync = sync;
4150
3906
  }
4151
-
4152
3907
  invoke(fn);
4153
-
4154
3908
  if (this.deferSyncFn === fn) {
4155
3909
  this.deferSyncFn = null;
4156
-
4157
3910
  if (fn.sync) {
4158
3911
  this.syncValue();
4159
3912
  }
@@ -4163,18 +3916,16 @@
4163
3916
  if (this.deferSyncFn) {
4164
3917
  return this.deferSyncFn.sync = true;
4165
3918
  }
4166
-
4167
3919
  this.vm._updateValue(_objectSpread2({}, this.form));
4168
3920
  },
4169
3921
  isChange: function isChange(ctx, value) {
4170
- return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
3922
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
4171
3923
  },
4172
3924
  isQuote: function isQuote(ctx, value) {
4173
3925
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4174
3926
  },
4175
3927
  refreshUpdate: function refreshUpdate(ctx, val) {
4176
3928
  var _this4 = this;
4177
-
4178
3929
  if (is.Function(ctx.rule.update)) {
4179
3930
  var state = invoke(function () {
4180
3931
  return ctx.rule.update(val, ctx.origin, _this4.api);
@@ -4194,20 +3945,16 @@
4194
3945
  this.vm.$emit('update', this.api);
4195
3946
  this.refresh();
4196
3947
  }
4197
-
4198
3948
  this.refreshUpdate(ctx, val);
4199
3949
  },
4200
3950
  appendLink: function appendLink(ctx) {
4201
3951
  var _this5 = this;
4202
-
4203
3952
  var link = ctx.rule.link;
4204
3953
  is.trueArray(link) && link.forEach(function (field) {
4205
3954
  var fn = function fn() {
4206
3955
  return _this5.refreshRule(ctx, ctx.rule.value);
4207
3956
  };
4208
-
4209
3957
  _this5.bus.$on('change-' + field, fn);
4210
-
4211
3958
  ctx.linkOn.push(function () {
4212
3959
  return _this5.bus.$off('change-' + field, fn);
4213
3960
  });
@@ -4218,11 +3965,9 @@
4218
3965
  }
4219
3966
  });
4220
3967
  }
4221
-
4222
3968
  function strFn(key, val) {
4223
3969
  return typeof val === 'function' ? '' + val : val;
4224
3970
  }
4225
-
4226
3971
  function toEmpty(obj) {
4227
3972
  Object.keys(obj).forEach(function (k) {
4228
3973
  return delete obj[k];
@@ -4242,11 +3987,12 @@
4242
3987
  return ctx.$render.defaultRender(ctx, children);
4243
3988
  },
4244
3989
  preview: function preview(children, ctx) {
4245
- return ctx.$render.defaultRender(ctx, children);
3990
+ return this.render(children, ctx);
4246
3991
  },
4247
3992
  mergeProp: function mergeProp(ctx) {}
4248
3993
  };
4249
3994
 
3995
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'component', 'cache'];
4250
3996
  function useContext(Handler) {
4251
3997
  extend(Handler.prototype, {
4252
3998
  getCtx: function getCtx(id) {
@@ -4257,7 +4003,6 @@
4257
4003
  },
4258
4004
  setIdCtx: function setIdCtx(ctx, key, type) {
4259
4005
  var field = "".concat(type, "Ctx");
4260
-
4261
4006
  if (!this[field][key]) {
4262
4007
  this[field][key] = [ctx];
4263
4008
  } else {
@@ -4269,11 +4014,9 @@
4269
4014
  var lst = this[field][key];
4270
4015
  if (!lst) return false;
4271
4016
  var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4272
-
4273
4017
  if (!lst.length) {
4274
4018
  delete this[field][key];
4275
4019
  }
4276
-
4277
4020
  return flag;
4278
4021
  },
4279
4022
  getFieldCtx: function getFieldCtx(field) {
@@ -4292,7 +4035,6 @@
4292
4035
  if (!ctx.input) return;
4293
4036
  this.setIdCtx(ctx, field, 'field');
4294
4037
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4295
-
4296
4038
  if (this.isMounted && !this.reloading) {
4297
4039
  this.vm.$emit('change', ctx.field, rule.value, ctx.origin, this.api);
4298
4040
  }
@@ -4313,70 +4055,51 @@
4313
4055
  if (!this.noWatchFn) {
4314
4056
  this.noWatchFn = fn;
4315
4057
  }
4316
-
4317
4058
  invoke(fn);
4318
-
4319
4059
  if (this.noWatchFn === fn) {
4320
4060
  this.noWatchFn = null;
4321
4061
  }
4322
4062
  },
4323
4063
  watchCtx: function watchCtx(ctx) {
4324
4064
  var _this = this;
4325
-
4326
4065
  var vm = this.vm;
4327
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4328
4066
  Object.keys(ctx.rule).filter(function (k) {
4329
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4067
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4330
4068
  }).forEach(function (key) {
4331
4069
  var flag = key === 'children';
4332
4070
  ctx.watch.push(vm.$watch(function () {
4333
4071
  return ctx.rule[key];
4334
4072
  }, function (n, o) {
4335
4073
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4336
-
4337
4074
  if (flag && ctx.parser.loadChildren === false) {
4338
4075
  _this.$render.clearCache(ctx);
4339
-
4340
4076
  _this.nextRefresh();
4341
-
4342
4077
  return;
4343
4078
  }
4344
-
4345
- _this.watching = true; // if (key === 'hidden')
4346
- // ctx.updateKey(true);
4347
- // else
4348
-
4079
+ _this.watching = true;
4349
4080
  if (key === 'link') {
4350
4081
  ctx.link();
4351
4082
  return;
4352
4083
  } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4353
4084
  _this.parseInjectEvent(ctx.rule, n || {});
4354
-
4355
4085
  if (key === 'props' && ctx.input) {
4356
4086
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
4357
4087
  }
4358
4088
  } 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') {
4359
4089
  ctx.updateType();
4360
-
4361
4090
  _this.bindParser(ctx);
4362
4091
  } else if (key === 'children') {
4363
4092
  var _flag = is.trueArray(n);
4364
-
4365
4093
  _this.deferSyncValue(function () {
4366
4094
  if (n !== o) {
4367
4095
  _this.rmSub(o);
4368
-
4369
4096
  _this.$render.initOrgChildren();
4370
4097
  }
4371
-
4372
4098
  _flag && _this.loadChildren(n, ctx);
4373
-
4374
4099
  _this.vm.$emit('update', _this.api);
4375
4100
  });
4376
4101
  }
4377
-
4378
4102
  _this.$render.clearCache(ctx);
4379
-
4380
4103
  _this.watching = false;
4381
4104
  }, {
4382
4105
  deep: !flag,
@@ -4387,27 +4110,23 @@
4387
4110
  },
4388
4111
  rmSub: function rmSub(sub) {
4389
4112
  var _this2 = this;
4390
-
4391
4113
  is.trueArray(sub) && sub.forEach(function (r) {
4392
4114
  r && r.__fc__ && _this2.rmCtx(r.__fc__);
4393
4115
  });
4394
4116
  },
4395
4117
  rmCtx: function rmCtx(ctx) {
4396
4118
  var _this3 = this;
4397
-
4398
4119
  if (ctx.deleted) return;
4399
4120
  var id = ctx.id,
4400
4121
  field = ctx.field,
4401
4122
  input = ctx.input,
4402
4123
  name = ctx.name;
4403
-
4404
4124
  if (ctx.input) {
4405
4125
  Object.defineProperty(ctx.rule, 'value', {
4406
4126
  value: ctx.rule.value,
4407
4127
  writable: true
4408
4128
  });
4409
4129
  }
4410
-
4411
4130
  $del(this.ctxs, id);
4412
4131
  $del(this.$render.tempList, id);
4413
4132
  $del(this.$render.orgChildren, id);
@@ -4415,6 +4134,7 @@
4415
4134
  $del(this.formData, id);
4416
4135
  $del(this.subForm, id);
4417
4136
  $del(ctx, 'cacheValue');
4137
+ input && $del(this.form, field);
4418
4138
  input && this.rmIdCtx(ctx, field, 'field');
4419
4139
  name && this.rmIdCtx(ctx, name, 'name');
4420
4140
  this.deferSyncValue(function () {
@@ -4426,18 +4146,15 @@
4426
4146
  });
4427
4147
  }
4428
4148
  }
4429
-
4430
4149
  if (ctx.root === _this3.rules) {
4431
4150
  _this3.vm._renderRule();
4432
4151
  }
4433
4152
  }
4434
4153
  }, input);
4435
4154
  var index = this.sort.indexOf(id);
4436
-
4437
4155
  if (index > -1) {
4438
4156
  this.sort.splice(index, 1);
4439
4157
  }
4440
-
4441
4158
  this.$render.clearCache(ctx);
4442
4159
  ctx["delete"]();
4443
4160
  this.effect(ctx, 'deleted');
@@ -4452,13 +4169,10 @@
4452
4169
  extend(Handler.prototype, {
4453
4170
  mounted: function mounted() {
4454
4171
  var _this = this;
4455
-
4456
4172
  var _mounted = function _mounted() {
4457
4173
  _this.isMounted = true;
4458
-
4459
4174
  _this.lifecycle('mounted');
4460
4175
  };
4461
-
4462
4176
  if (this.pageEnd) {
4463
4177
  _mounted();
4464
4178
  } else {
@@ -4467,7 +4181,6 @@
4467
4181
  },
4468
4182
  lifecycle: function lifecycle(name) {
4469
4183
  var _this2 = this;
4470
-
4471
4184
  var fn = this.options[name];
4472
4185
  is.Function(fn) && invoke(function () {
4473
4186
  return fn(_this2.api);
@@ -4481,26 +4194,21 @@
4481
4194
  extend(Handler.prototype, {
4482
4195
  useProvider: function useProvider() {
4483
4196
  var _this = this;
4484
-
4485
4197
  var ps = this.fc.providers;
4486
4198
  Object.keys(ps).forEach(function (k) {
4487
4199
  var prop = ps[k];
4488
4200
  prop._c = getComponent(prop);
4489
-
4490
4201
  _this.onEffect(prop);
4491
-
4492
4202
  _this.providers[k] = prop;
4493
4203
  });
4494
4204
  },
4495
4205
  onEffect: function onEffect(provider) {
4496
4206
  var _this2 = this;
4497
-
4498
4207
  var used = [];
4499
4208
  (provider._c || ['*']).forEach(function (name) {
4500
4209
  var type = name === '*' ? '*' : _this2.getType(name);
4501
4210
  if (used.indexOf(type) > -1) return;
4502
4211
  used.push(type);
4503
-
4504
4212
  _this2.bus.$on("p:".concat(provider.name, ":").concat(type, ":").concat(provider.input ? 1 : 0), function (event, args) {
4505
4213
  provider[event] && provider[event].apply(provider, _toConsumableArray(args));
4506
4214
  });
@@ -4509,7 +4217,6 @@
4509
4217
  },
4510
4218
  watchEffect: function watchEffect(ctx) {
4511
4219
  var _this3 = this;
4512
-
4513
4220
  var vm = this.vm;
4514
4221
  var effect = {};
4515
4222
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
@@ -4552,13 +4259,11 @@
4552
4259
  if (hasProperty(rule, '$' + name)) {
4553
4260
  return rule['$' + name];
4554
4261
  }
4555
-
4556
4262
  if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4557
4263
  return undefined;
4558
4264
  },
4559
4265
  emitEffect: function emitEffect(_ref, event, append) {
4560
4266
  var _this4 = this;
4561
-
4562
4267
  var ctx = _ref.ctx,
4563
4268
  rule = _ref.rule,
4564
4269
  input = _ref.input,
@@ -4569,15 +4274,12 @@
4569
4274
  if (k[0] === '$') {
4570
4275
  i[k.substr(1)] = rule[k];
4571
4276
  }
4572
-
4573
4277
  return i;
4574
4278
  }, _objectSpread2({}, rule.effect || {}));
4575
4279
  Object.keys(effect).forEach(function (attr) {
4576
4280
  var p = _this4.providers[attr];
4577
4281
  if (!p || p.input && !input) return;
4578
-
4579
4282
  var _type;
4580
-
4581
4283
  if (!p._c) {
4582
4284
  _type = '*';
4583
4285
  } else if (p._used.indexOf(type) > -1) {
@@ -4585,40 +4287,33 @@
4585
4287
  } else {
4586
4288
  return;
4587
4289
  }
4588
-
4589
4290
  var data = _objectSpread2({
4590
4291
  value: effect[attr],
4591
4292
  getValue: function getValue() {
4592
4293
  return _this4.getEffect(rule, attr);
4593
4294
  }
4594
4295
  }, append || {});
4595
-
4596
4296
  if (ctx) {
4597
4297
  data.getProp = function () {
4598
4298
  return ctx.effectData(attr);
4599
4299
  };
4600
-
4601
4300
  data.clearProp = function () {
4602
4301
  return ctx.clearEffectData(attr);
4603
4302
  };
4604
-
4605
4303
  data.mergeProp = function (prop) {
4606
4304
  return mergeProps([prop], data.getProp());
4607
4305
  };
4608
4306
  }
4609
-
4610
4307
  _this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
4611
4308
  });
4612
4309
  }
4613
4310
  });
4614
4311
  }
4615
-
4616
4312
  function unique(arr) {
4617
4313
  return arr.filter(function (item, index, arr) {
4618
4314
  return arr.indexOf(item, 0) === index;
4619
4315
  });
4620
4316
  }
4621
-
4622
4317
  function getComponent(p) {
4623
4318
  var c = p.components;
4624
4319
  if (Array.isArray(c)) return unique(c.filter(function (v) {
@@ -4628,7 +4323,6 @@
4628
4323
 
4629
4324
  function Handler(fc) {
4630
4325
  var _this = this;
4631
-
4632
4326
  extend(this, {
4633
4327
  fc: fc,
4634
4328
  vm: fc.vm,
@@ -4680,9 +4374,7 @@
4680
4374
  this.useProvider();
4681
4375
  this.usePage();
4682
4376
  this.loadRule();
4683
-
4684
4377
  this.$manager.__init();
4685
-
4686
4378
  this.vm.$set(this.vm, 'formData', this.formData);
4687
4379
  }
4688
4380
  });
@@ -4695,7 +4387,6 @@
4695
4387
  useLifecycle(Handler);
4696
4388
  useEffect(Handler);
4697
4389
 
4698
- // https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
4699
4390
  function getError(action, option, xhr) {
4700
4391
  var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4701
4392
  var err = new Error(msg);
@@ -4703,44 +4394,34 @@
4703
4394
  err.url = action;
4704
4395
  return err;
4705
4396
  }
4706
-
4707
4397
  function getBody(xhr) {
4708
4398
  var text = xhr.responseText || xhr.response;
4709
-
4710
4399
  if (!text) {
4711
4400
  return text;
4712
4401
  }
4713
-
4714
4402
  try {
4715
4403
  return JSON.parse(text);
4716
4404
  } catch (e) {
4717
4405
  return text;
4718
4406
  }
4719
4407
  }
4720
-
4721
4408
  function fetch(option) {
4722
4409
  if (typeof XMLHttpRequest === 'undefined') {
4723
4410
  return;
4724
4411
  }
4725
-
4726
4412
  var xhr = new XMLHttpRequest();
4727
4413
  var action = option.action;
4728
-
4729
4414
  xhr.onerror = function error(e) {
4730
4415
  option.onError(e);
4731
4416
  };
4732
-
4733
4417
  xhr.onload = function onload() {
4734
4418
  if (xhr.status < 200 || xhr.status >= 300) {
4735
4419
  return option.onError(getError(action, option, xhr), getBody(xhr));
4736
4420
  }
4737
-
4738
4421
  option.onSuccess(getBody(xhr));
4739
4422
  };
4740
-
4741
4423
  xhr.open(option.method || 'get', action, true);
4742
4424
  var formData;
4743
-
4744
4425
  if (option.data) {
4745
4426
  if ((option.dataType || '').toLowerCase() !== 'json') {
4746
4427
  formData = new FormData();
@@ -4752,11 +4433,9 @@
4752
4433
  xhr.setRequestHeader('content-type', 'application/json');
4753
4434
  }
4754
4435
  }
4755
-
4756
4436
  if (option.withCredentials && 'withCredentials' in xhr) {
4757
4437
  xhr.withCredentials = true;
4758
4438
  }
4759
-
4760
4439
  var headers = option.headers || {};
4761
4440
  Object.keys(headers).forEach(function (item) {
4762
4441
  if (headers[item] !== null) {
@@ -4784,14 +4463,11 @@
4784
4463
  };
4785
4464
  return prop;
4786
4465
  }
4787
-
4788
4466
  function CreateNodeFactory() {
4789
4467
  var aliasMap = {};
4790
-
4791
4468
  function CreateNode(vm) {
4792
4469
  vm && this.setVm(vm);
4793
4470
  }
4794
-
4795
4471
  extend(CreateNode.prototype, {
4796
4472
  setVm: function setVm(vm) {
4797
4473
  this.vm = vm;
@@ -4799,7 +4475,10 @@
4799
4475
  },
4800
4476
  make: function make(tag, data, children) {
4801
4477
  if (Vue.config.isReservedTag(tag) && data.nativeOn) delete data.nativeOn;
4802
- var Node = this.$h(tag, parseProp(data), children || []);
4478
+ return this.makeComponent(tag, data, children);
4479
+ },
4480
+ makeComponent: function makeComponent(type, data, children) {
4481
+ var Node = this.$h(type, parseProp(data), children || []);
4803
4482
  Node.context = this.vm;
4804
4483
  return Node;
4805
4484
  },
@@ -4817,7 +4496,6 @@
4817
4496
  var v = nodes[k];
4818
4497
  [k, line, lower].forEach(function (n) {
4819
4498
  CreateNode.alias(k, v);
4820
-
4821
4499
  CreateNode.prototype[n] = function (data, children) {
4822
4500
  return this.make(v, data, children);
4823
4501
  };
@@ -4829,20 +4507,15 @@
4829
4507
  }
4830
4508
 
4831
4509
  function createManager(proto) {
4832
- var CustomManager = /*#__PURE__*/function (_Manager) {
4510
+ var CustomManager = function (_Manager) {
4833
4511
  _inherits(CustomManager, _Manager);
4834
-
4835
4512
  var _super = _createSuper(CustomManager);
4836
-
4837
4513
  function CustomManager() {
4838
4514
  _classCallCheck(this, CustomManager);
4839
-
4840
4515
  return _super.apply(this, arguments);
4841
4516
  }
4842
-
4843
4517
  return CustomManager;
4844
4518
  }(Manager);
4845
-
4846
4519
  Object.assign(CustomManager.prototype, proto);
4847
4520
  return CustomManager;
4848
4521
  }
@@ -4862,19 +4535,15 @@
4862
4535
  extend(Manager.prototype, {
4863
4536
  __init: function __init() {
4864
4537
  var _this = this;
4865
-
4866
4538
  this.$render = this.$handle.$render;
4867
-
4868
4539
  this.$r = function () {
4869
4540
  var _this$$render;
4870
-
4871
4541
  return (_this$$render = _this.$render).renderRule.apply(_this$$render, arguments);
4872
4542
  };
4873
4543
  },
4874
4544
  updateKey: function updateKey() {
4875
4545
  this.key = uniqueId();
4876
4546
  },
4877
- //TODO interface
4878
4547
  init: function init() {},
4879
4548
  update: function update() {},
4880
4549
  beforeRender: function beforeRender() {},
@@ -4883,7 +4552,6 @@
4883
4552
  },
4884
4553
  mergeOptions: function mergeOptions(args, opt) {
4885
4554
  var _this2 = this;
4886
-
4887
4555
  return mergeProps(args.map(function (v) {
4888
4556
  return _this2.tidyOptions(v);
4889
4557
  }), opt, this.mergeOptionsRule);
@@ -4918,33 +4586,28 @@
4918
4586
  var $required = {
4919
4587
  name: 'required',
4920
4588
  load: function load(inject, rule, api) {
4921
- var val = parseVa(inject.getValue());
4922
-
4589
+ var val = parseVal(inject.getValue());
4923
4590
  if (val.required === false) {
4924
4591
  inject.clearProp();
4925
4592
  } else {
4926
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
4593
+ var validate = _objectSpread2({
4927
4594
  required: true,
4928
4595
  validator: function validator(_, v, call) {
4929
4596
  is.empty(v) ? call(validate.message) : call();
4930
4597
  }
4931
- });
4932
-
4598
+ }, val);
4933
4599
  if (!validate.message) {
4934
4600
  validate.message = rule.title + ' is required';
4935
4601
  }
4936
-
4937
4602
  inject.getProp().validate = [validate];
4938
4603
  }
4939
-
4940
4604
  api.sync(rule);
4941
4605
  },
4942
4606
  watch: function watch() {
4943
4607
  $required.load.apply($required, arguments);
4944
4608
  }
4945
4609
  };
4946
-
4947
- function parseVa(val) {
4610
+ function parseVal(val) {
4948
4611
  if (is.Boolean(val)) {
4949
4612
  return {
4950
4613
  required: val
@@ -4953,13 +4616,16 @@
4953
4616
  return {
4954
4617
  message: val
4955
4618
  };
4619
+ } else if (is.Function(val)) {
4620
+ return {
4621
+ validator: val
4622
+ };
4956
4623
  } else if (!is.Object(val)) {
4957
4624
  return {};
4958
4625
  } else {
4959
4626
  return val;
4960
4627
  }
4961
4628
  }
4962
-
4963
4629
  function parseOpt(option) {
4964
4630
  if (is.String(option)) {
4965
4631
  option = {
@@ -4967,29 +4633,21 @@
4967
4633
  to: 'options'
4968
4634
  };
4969
4635
  }
4970
-
4971
4636
  return option;
4972
4637
  }
4973
-
4974
4638
  function run(inject, rule, api) {
4975
4639
  var option = inject.value;
4976
-
4977
4640
  if (is.Function(option)) {
4978
4641
  option = option(rule, api);
4979
4642
  }
4980
-
4981
4643
  option = parseOpt(option);
4982
-
4983
4644
  if (!option || !option.action) {
4984
4645
  return false;
4985
4646
  }
4986
-
4987
4647
  if (!option.to) {
4988
4648
  option.to = 'options';
4989
4649
  }
4990
-
4991
4650
  var _onError = option.onError;
4992
-
4993
4651
  var check = function check() {
4994
4652
  if (!inject.getValue()) {
4995
4653
  inject.clearProp();
@@ -4997,7 +4655,6 @@
4997
4655
  return true;
4998
4656
  }
4999
4657
  };
5000
-
5001
4658
  var set = function set(val) {
5002
4659
  if (val === undefined) {
5003
4660
  inject.clearProp();
@@ -5006,7 +4663,6 @@
5006
4663
  deepSet(inject.getProp(), option.to, val);
5007
4664
  }
5008
4665
  };
5009
-
5010
4666
  invoke(function () {
5011
4667
  return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5012
4668
  onSuccess: function onSuccess(body) {
@@ -5019,7 +4675,6 @@
5019
4675
  onError: function onError(e) {
5020
4676
  set(undefined);
5021
4677
  if (check()) return;
5022
-
5023
4678
  (_onError || function (e) {
5024
4679
  return err(e.message || 'fetch fail ' + option.action);
5025
4680
  })(e, rule, api);
@@ -5028,7 +4683,6 @@
5028
4683
  });
5029
4684
  return true;
5030
4685
  }
5031
-
5032
4686
  var $provider = {
5033
4687
  fetch: $fetch,
5034
4688
  required: $required
@@ -5049,42 +4703,34 @@
5049
4703
  return is.String(v);
5050
4704
  }).join('');
5051
4705
  }
5052
-
5053
4706
  return '';
5054
4707
  }
5055
4708
  };
5056
4709
 
5057
4710
  var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue;
5058
-
5059
4711
  function _parseProp(name, id) {
5060
4712
  var prop;
5061
-
5062
4713
  if (arguments.length === 2) {
5063
4714
  prop = arguments[1];
5064
4715
  id = prop[name];
5065
4716
  } else {
5066
4717
  prop = arguments[2];
5067
4718
  }
5068
-
5069
4719
  return {
5070
4720
  id: id,
5071
4721
  prop: prop
5072
4722
  };
5073
4723
  }
5074
-
5075
4724
  function nameProp() {
5076
4725
  return _parseProp.apply(void 0, ['name'].concat(Array.prototype.slice.call(arguments)));
5077
4726
  }
5078
-
5079
4727
  function _getEl(options) {
5080
4728
  if (!options || !options.el) return window.document.body;
5081
4729
  return is.Element(options.el) ? options.el : document.querySelector(options.el);
5082
4730
  }
5083
-
5084
4731
  function mountForm(rules, option) {
5085
4732
  var $vm = new _vue({
5086
4733
  data: function data() {
5087
- //todo 外部无法修改
5088
4734
  return {
5089
4735
  rule: rules,
5090
4736
  option: option || {}
@@ -5100,7 +4746,6 @@
5100
4746
  $vm.$mount();
5101
4747
  return $vm;
5102
4748
  }
5103
-
5104
4749
  function exportAttrs(attrs) {
5105
4750
  var key = attrs.key || [];
5106
4751
  var array = attrs.array || [];
@@ -5110,18 +4755,13 @@
5110
4755
  normalAttrs.push.apply(normalAttrs, _toConsumableArray(normal));
5111
4756
  appendProto([].concat(_toConsumableArray(key), _toConsumableArray(array), _toConsumableArray(normal)));
5112
4757
  }
5113
-
5114
4758
  var id$1 = 1;
5115
- var instance = {}; //todo 表单嵌套
5116
-
4759
+ var instance = {};
5117
4760
  function FormCreateFactory(config) {
5118
4761
  var components = _defineProperty({}, fragment.name, fragment);
5119
-
5120
4762
  var parsers = {};
5121
4763
  var directives = {};
5122
-
5123
4764
  var providers = _objectSpread2({}, $provider);
5124
-
5125
4765
  var maker = makerFactory();
5126
4766
  var globalConfig = {
5127
4767
  global: {}
@@ -5129,27 +4769,24 @@
5129
4769
  var data = {};
5130
4770
  var CreateNode = CreateNodeFactory();
5131
4771
  exportAttrs(config.attrs || {});
5132
-
5133
4772
  function getApi(name) {
5134
- return instance[name];
4773
+ var val = instance[name];
4774
+ if (Array.isArray(val)) return _toConsumableArray(val);
4775
+ return val;
5135
4776
  }
5136
-
5137
4777
  function directive() {
5138
4778
  var data = nameProp.apply(void 0, arguments);
5139
4779
  if (data.id && data.prop) directives[data.id] = data.prop;
5140
4780
  }
5141
-
5142
4781
  function register() {
5143
4782
  var data = nameProp.apply(void 0, arguments);
5144
4783
  if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
5145
4784
  name: data.id
5146
4785
  });
5147
4786
  }
5148
-
5149
4787
  function componentAlias(alias) {
5150
4788
  CreateNode.use(alias);
5151
4789
  }
5152
-
5153
4790
  function parser() {
5154
4791
  var data = nameProp.apply(void 0, arguments);
5155
4792
  if (!data.id || !data.prop) return;
@@ -5160,13 +4797,10 @@
5160
4797
  maker[name] = creatorFactory(name);
5161
4798
  parser.maker && extend(maker, parser.maker);
5162
4799
  }
5163
-
5164
4800
  function component(id, component) {
5165
4801
  var name;
5166
-
5167
4802
  if (is.String(id)) {
5168
4803
  name = toCase(id);
5169
-
5170
4804
  if (['form-create', 'formcreate'].indexOf(name) > -1) {
5171
4805
  return $form();
5172
4806
  } else if (component === undefined) {
@@ -5176,39 +4810,29 @@
5176
4810
  name = toCase(id.name);
5177
4811
  component = id;
5178
4812
  }
5179
-
5180
4813
  if (!name || !component) return;
5181
4814
  components[name] = component;
5182
4815
  if (component.formCreateParser) parser(name, component.formCreateParser);
5183
4816
  }
5184
-
5185
4817
  function $form() {
5186
4818
  return _vue.extend($FormCreate(FormCreate));
5187
4819
  }
5188
-
5189
4820
  function $vnode() {
5190
4821
  return _vue.extend(fragment);
5191
- } //todo 检查回调函数作用域
5192
-
5193
-
4822
+ }
5194
4823
  function use(fn, opt) {
5195
4824
  if (is.Function(fn.install)) fn.install(create, opt);else if (is.Function(fn)) fn(create, opt);
5196
4825
  return this;
5197
4826
  }
5198
-
5199
4827
  function create(rules, _opt, parent) {
5200
4828
  var $vm = mountForm(rules, _opt || {});
5201
4829
  var _this = $vm.$refs.fc.formCreate;
5202
4830
  _this.$parent = parent;
5203
-
5204
4831
  _getEl(_this.options).appendChild($vm.$el);
5205
-
5206
4832
  return _this.api();
5207
4833
  }
5208
-
5209
4834
  function factory(inherit) {
5210
4835
  var _config = _objectSpread2({}, config);
5211
-
5212
4836
  if (inherit) {
5213
4837
  _config.inherit = {
5214
4838
  components: components,
@@ -5221,10 +4845,8 @@
5221
4845
  } else {
5222
4846
  delete _config.inherit;
5223
4847
  }
5224
-
5225
4848
  return FormCreateFactory(_config);
5226
4849
  }
5227
-
5228
4850
  function FormCreate(vm, rules, options) {
5229
4851
  extend(this, {
5230
4852
  id: id$1++,
@@ -5235,6 +4857,7 @@
5235
4857
  providers: providers,
5236
4858
  rules: Array.isArray(rules) ? rules : [],
5237
4859
  name: vm.$options.propsData.name,
4860
+ inFor: vm.$options.propsData.inFor,
5238
4861
  prop: {
5239
4862
  components: components,
5240
4863
  directives: directives
@@ -5242,22 +4865,25 @@
5242
4865
  CreateNode: CreateNode,
5243
4866
  bus: new _vue(),
5244
4867
  unwatch: null,
4868
+ options: options || {},
5245
4869
  extendApi: config.extendApi || function (api) {
5246
4870
  return api;
5247
4871
  }
5248
4872
  });
5249
4873
  this.init();
5250
- this.initOptions(options || {});
5251
-
4874
+ this.initOptions(this.options);
5252
4875
  if (this.name) {
5253
- instance[this.name] = this.api();
4876
+ if (this.inFor) {
4877
+ if (!instance[this.name]) instance[this.name] = [];
4878
+ instance[this.name].push(this.api());
4879
+ } else {
4880
+ instance[this.name] = this.api();
4881
+ }
5254
4882
  }
5255
4883
  }
5256
-
5257
4884
  extend(FormCreate.prototype, {
5258
4885
  init: function init() {
5259
4886
  var _this2 = this;
5260
-
5261
4887
  var vm = this.vm;
5262
4888
  var h = new Handler(this);
5263
4889
  this.$handle = h;
@@ -5269,15 +4895,12 @@
5269
4895
  return vm.$pfc.option;
5270
4896
  }, function () {
5271
4897
  _this2.initOptions(_this2.options);
5272
-
5273
4898
  vm.$f.refresh();
5274
4899
  }, {
5275
4900
  deep: true
5276
4901
  });
5277
-
5278
4902
  _this2.initOptions(_this2.options);
5279
4903
  }
5280
-
5281
4904
  _this2.created();
5282
4905
  });
5283
4906
  vm.$on('hook:mounted', function () {
@@ -5287,9 +4910,13 @@
5287
4910
  vm.destroyed = true;
5288
4911
  _this2.unwatch && _this2.unwatch();
5289
4912
  h.reloadRule([]);
5290
-
5291
4913
  if (_this2.name) {
5292
- delete instance[_this2.name];
4914
+ if (_this2.inFor) {
4915
+ var idx = instance[_this2.name].indexOf(_this2.api());
4916
+ instance[_this2.name].splice(idx, 1);
4917
+ } else {
4918
+ delete instance[_this2.name];
4919
+ }
5293
4920
  }
5294
4921
  });
5295
4922
  vm.$on('hook:updated', function () {
@@ -5307,11 +4934,9 @@
5307
4934
  submitBtn: {},
5308
4935
  resetBtn: {}
5309
4936
  }, deepCopy(globalConfig));
5310
-
5311
4937
  if (this.isSub()) {
5312
4938
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5313
4939
  }
5314
-
5315
4940
  this.updateOptions(options);
5316
4941
  },
5317
4942
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5319,12 +4944,10 @@
5319
4944
  parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
5320
4945
  delete opt[n];
5321
4946
  });
5322
-
5323
4947
  if (opt.global) {
5324
4948
  target.global = mergeGlobal(target.global, opt.global);
5325
4949
  delete opt.global;
5326
4950
  }
5327
-
5328
4951
  this.$handle.$manager.mergeOptions([opt], target);
5329
4952
  return target;
5330
4953
  },
@@ -5346,7 +4969,6 @@
5346
4969
  this.$handle.mounted();
5347
4970
  }
5348
4971
  });
5349
-
5350
4972
  function useAttr(formCreate) {
5351
4973
  extend(formCreate, {
5352
4974
  version: config.version,
@@ -5371,15 +4993,12 @@
5371
4993
  getApi: getApi,
5372
4994
  init: function init(rules) {
5373
4995
  var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5374
-
5375
4996
  var $vm = mountForm(rules, _opt),
5376
4997
  _this = $vm.$refs.fc.formCreate;
5377
4998
  return {
5378
4999
  mount: function mount($el) {
5379
5000
  if ($el && is.Element($el)) _this.options.el = $el;
5380
-
5381
5001
  _getEl(_this.options).appendChild($vm.$el);
5382
-
5383
5002
  return _this.api();
5384
5003
  },
5385
5004
  remove: function remove() {
@@ -5394,7 +5013,6 @@
5394
5013
  }
5395
5014
  });
5396
5015
  }
5397
-
5398
5016
  function useStatic(formCreate) {
5399
5017
  extend(formCreate, {
5400
5018
  create: create,
@@ -5403,12 +5021,10 @@
5403
5021
  if (Vue._installedFormCreate === true) return;
5404
5022
  Vue._installedFormCreate = true;
5405
5023
  _vue = Vue;
5406
-
5407
5024
  var $formCreate = function $formCreate(rules) {
5408
5025
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5409
5026
  return create(rules, opt, this);
5410
5027
  };
5411
-
5412
5028
  useAttr($formCreate);
5413
5029
  Vue.prototype.$formCreate = $formCreate;
5414
5030
  Vue.component('FormCreate', $form());
@@ -5416,7 +5032,6 @@
5416
5032
  }
5417
5033
  });
5418
5034
  }
5419
-
5420
5035
  useAttr(create);
5421
5036
  useStatic(create);
5422
5037
  CreateNode.use({
@@ -5424,7 +5039,6 @@
5424
5039
  });
5425
5040
  parser(html);
5426
5041
  if (config.install) create.use(config);
5427
-
5428
5042
  if (config.inherit) {
5429
5043
  var inherit = config.inherit;
5430
5044
  inherit.components && extend(components, inherit.components);
@@ -5434,7 +5048,6 @@
5434
5048
  inherit.maker && extend(maker, inherit.maker);
5435
5049
  inherit.data && extend(data, inherit.data);
5436
5050
  }
5437
-
5438
5051
  return create;
5439
5052
  }
5440
5053
 
@@ -5457,7 +5070,6 @@
5457
5070
  }(),
5458
5071
  mergeProp: function mergeProp(ctx) {
5459
5072
  var props = ctx.prop.props;
5460
-
5461
5073
  if (props.startDate) {
5462
5074
  props.startDate = props.startDate && timeStampToDate(props.startDate);
5463
5075
  }
@@ -5473,12 +5085,10 @@
5473
5085
  },
5474
5086
  toValue: function toValue(formValue, ctx) {
5475
5087
  var el = ctx.el;
5476
-
5477
5088
  if (el) {
5478
5089
  this.el = el;
5479
5090
  return this._toValue(formValue, ctx);
5480
5091
  }
5481
-
5482
5092
  return formValue;
5483
5093
  },
5484
5094
  toFormValue: function toFormValue(value, ctx) {
@@ -5490,7 +5100,6 @@
5490
5100
  props = ctx.prop.props,
5491
5101
  parseValue,
5492
5102
  type = props.type || 'date';
5493
-
5494
5103
  if (['daterange', 'datetimerange'].indexOf(type) !== -1) {
5495
5104
  if (isArr) {
5496
5105
  parseValue = value.map(function (time) {
@@ -5505,7 +5114,6 @@
5505
5114
  parseValue = isArr ? value[0] || '' : value;
5506
5115
  parseValue = !parseValue ? '' : timeStampToDate(parseValue);
5507
5116
  }
5508
-
5509
5117
  return parseValue;
5510
5118
  }
5511
5119
  },
@@ -5542,7 +5150,6 @@
5542
5150
  }(),
5543
5151
  mergeProp: function mergeProp(ctx) {
5544
5152
  var props = ctx.prop.props;
5545
-
5546
5153
  if (props.autosize && props.autosize.minRows) {
5547
5154
  props.rows = props.autosize.minRows || 2;
5548
5155
  }
@@ -5562,13 +5169,11 @@
5562
5169
  props = ctx.prop.props,
5563
5170
  min = props.min || 0,
5564
5171
  parseValue;
5565
-
5566
5172
  if (props.range === true) {
5567
5173
  parseValue = isArr ? value : [min, parseFloat(value) || min];
5568
5174
  } else {
5569
5175
  parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
5570
5176
  }
5571
-
5572
5177
  return parseValue;
5573
5178
  }
5574
5179
  };
@@ -5678,18 +5283,14 @@
5678
5283
 
5679
5284
  function tidy(props, name) {
5680
5285
  if (!hasProperty(props, name)) return;
5681
-
5682
5286
  if (is.String(props[name])) {
5683
5287
  var _props$name;
5684
-
5685
5288
  props[name] = (_props$name = {}, _defineProperty(_props$name, name, props[name]), _defineProperty(_props$name, "show", true), _props$name);
5686
5289
  }
5687
5290
  }
5688
-
5689
5291
  function isFalse(val) {
5690
5292
  return val === false;
5691
5293
  }
5692
-
5693
5294
  function tidyBool(opt, name) {
5694
5295
  if (hasProperty(opt, name) && !is.Object(opt[name])) {
5695
5296
  opt[name] = {
@@ -5697,7 +5298,6 @@
5697
5298
  };
5698
5299
  }
5699
5300
  }
5700
-
5701
5301
  var manager = {
5702
5302
  validate: function validate(call) {
5703
5303
  this.form().validate(call);
@@ -5707,7 +5307,6 @@
5707
5307
  },
5708
5308
  clearValidateState: function clearValidateState(ctx) {
5709
5309
  var fItem = this.vm.$refs[ctx.wrapRef];
5710
-
5711
5310
  if (fItem) {
5712
5311
  fItem.validateMessage = '';
5713
5312
  fItem.validateState = '';
@@ -5781,7 +5380,6 @@
5781
5380
  if (children.length) {
5782
5381
  children.push(this.makeFormBtn());
5783
5382
  }
5784
-
5785
5383
  return this.$r(this.rule, isFalse(this.options.row.show) ? children : [this.makeRow(children)]);
5786
5384
  },
5787
5385
  makeWrap: function makeWrap(ctx, children) {
@@ -5813,11 +5411,9 @@
5813
5411
  return !(!title.title && !title["native"] || isFalse(title.show));
5814
5412
  },
5815
5413
  makeInfo: function makeInfo(rule, uni) {
5816
-
5817
5414
  var titleProp = rule.title;
5818
5415
  var infoProp = rule.info;
5819
5416
  var children = [titleProp.title];
5820
-
5821
5417
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5822
5418
  var prop = {
5823
5419
  type: infoProp.type || 'poptip',
@@ -5826,11 +5422,9 @@
5826
5422
  slot: 'label'
5827
5423
  };
5828
5424
  var field = 'content';
5829
-
5830
5425
  if (infoProp.info && !hasProperty(prop.props, field)) {
5831
5426
  prop.props[field] = infoProp.info;
5832
5427
  }
5833
-
5834
5428
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5835
5429
  type: 'icon',
5836
5430
  props: {
@@ -5841,7 +5435,6 @@
5841
5435
  key: "".concat(uni, "i")
5842
5436
  })]));
5843
5437
  }
5844
-
5845
5438
  return this.$r(mergeProps([titleProp, {
5846
5439
  props: titleProp,
5847
5440
  slot: titleProp.slot || 'label',
@@ -5871,19 +5464,15 @@
5871
5464
  },
5872
5465
  makeFormBtn: function makeFormBtn() {
5873
5466
  var vn = [];
5874
-
5875
5467
  if (!isFalse(this.options.submitBtn.show)) {
5876
5468
  vn.push(this.makeSubmitBtn());
5877
5469
  }
5878
-
5879
5470
  if (!isFalse(this.options.resetBtn.show)) {
5880
5471
  vn.push(this.makeResetBtn());
5881
5472
  }
5882
-
5883
5473
  if (!vn.length) {
5884
5474
  return;
5885
5475
  }
5886
-
5887
5476
  var item = this.$r({
5888
5477
  type: 'formItem',
5889
5478
  key: "".concat(this.key, "fb")
@@ -5898,7 +5487,6 @@
5898
5487
  },
5899
5488
  makeResetBtn: function makeResetBtn() {
5900
5489
  var _this2 = this;
5901
-
5902
5490
  var resetBtn = this.options.resetBtn;
5903
5491
  this.setSize(resetBtn);
5904
5492
  return this.$r({
@@ -5919,7 +5507,6 @@
5919
5507
  },
5920
5508
  makeSubmitBtn: function makeSubmitBtn() {
5921
5509
  var _this3 = this;
5922
-
5923
5510
  var submitBtn = this.options.submitBtn;
5924
5511
  this.setSize(submitBtn);
5925
5512
  return this.$r({
@@ -5941,7 +5528,6 @@
5941
5528
 
5942
5529
  var maker = {};
5943
5530
  var names = ['upload', 'select', 'tree', 'checkbox', 'autoComplete', 'cascader', 'colorPicker', 'frame', 'inputNumber', 'radio', 'rate', 'timePicker', 'group'];
5944
-
5945
5531
  function useAlias(maker) {
5946
5532
  names.forEach(function (name) {
5947
5533
  maker[name] = creatorFactory(name);
@@ -5950,7 +5536,6 @@
5950
5536
  maker.number = maker.inputNumber;
5951
5537
  maker.color = maker.colorPicker;
5952
5538
  }
5953
-
5954
5539
  function useUpload(maker) {
5955
5540
  var name = 'upload';
5956
5541
  var types = {
@@ -5971,7 +5556,6 @@
5971
5556
  maker.uploadImage = maker.image;
5972
5557
  maker.uploadFile = maker.file;
5973
5558
  }
5974
-
5975
5559
  function useTree(maker) {
5976
5560
  var name = 'tree';
5977
5561
  var types = {
@@ -5985,7 +5569,6 @@
5985
5569
  return maker;
5986
5570
  }, maker);
5987
5571
  }
5988
-
5989
5572
  function useTimePicker(maker) {
5990
5573
  var name = 'timePicker';
5991
5574
  maker.time = creatorFactory(name, {
@@ -5995,7 +5578,6 @@
5995
5578
  type: 'timerange'
5996
5579
  });
5997
5580
  }
5998
-
5999
5581
  function useSelect(maker) {
6000
5582
  var name = 'select';
6001
5583
  maker.selectMultiple = creatorFactory(name, {
@@ -6005,7 +5587,6 @@
6005
5587
  multiple: false
6006
5588
  });
6007
5589
  }
6008
-
6009
5590
  function useFrame(maker) {
6010
5591
  var name = 'frame';
6011
5592
  var types = {
@@ -6029,7 +5610,6 @@
6029
5610
  maker.frameFile = maker.frameFiles;
6030
5611
  maker.frameImage = maker.frameImages;
6031
5612
  }
6032
-
6033
5613
  useAlias(maker);
6034
5614
  useUpload(maker);
6035
5615
  useTree(maker);
@@ -6048,28 +5628,23 @@
6048
5628
  };
6049
5629
  return btn;
6050
5630
  }
6051
-
6052
5631
  function extendApi(api, h) {
6053
5632
  extend(api, {
6054
5633
  validate: function validate(callback) {
6055
5634
  var flag;
6056
5635
  var forms = api.children;
6057
5636
  var len = forms.length;
6058
-
6059
5637
  var validate = function validate() {
6060
5638
  h.$manager.validate(function () {
6061
5639
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6062
5640
  args[_key] = arguments[_key];
6063
5641
  }
6064
-
6065
5642
  if (!args[0] || !flag) {
6066
5643
  flag = args;
6067
5644
  }
6068
-
6069
5645
  callback && callback.apply(void 0, _toConsumableArray(flag));
6070
5646
  });
6071
5647
  };
6072
-
6073
5648
  var validFn = function validFn(args) {
6074
5649
  setTimeout(function () {
6075
5650
  if (!args[0]) {
@@ -6077,23 +5652,19 @@
6077
5652
  flag = args;
6078
5653
  }
6079
5654
  }
6080
-
6081
5655
  if (! --len) {
6082
5656
  validate();
6083
5657
  }
6084
5658
  });
6085
5659
  };
6086
-
6087
5660
  forms.forEach(function (form) {
6088
5661
  form.validate(function () {
6089
5662
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6090
5663
  args[_key2] = arguments[_key2];
6091
5664
  }
6092
-
6093
5665
  return validFn(args);
6094
5666
  });
6095
5667
  });
6096
-
6097
5668
  if (!len) {
6098
5669
  validate();
6099
5670
  }
@@ -6104,23 +5675,19 @@
6104
5675
  var sub = h.subForm[ctx.id];
6105
5676
  var len = 0;
6106
5677
  var flag;
6107
-
6108
5678
  var validate = function validate() {
6109
5679
  h.$manager.validateField(ctx.id, function () {
6110
5680
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
6111
5681
  args[_key3] = arguments[_key3];
6112
5682
  }
6113
-
6114
5683
  if (args[0]) {
6115
5684
  flag = args;
6116
5685
  } else if (flag) {
6117
5686
  return callback && callback('子表单验证未通过');
6118
5687
  }
6119
-
6120
5688
  callback && callback.apply(void 0, _toConsumableArray(flag || args));
6121
5689
  });
6122
5690
  };
6123
-
6124
5691
  var validFn = function validFn(args) {
6125
5692
  setTimeout(function () {
6126
5693
  if (!args[0]) {
@@ -6128,31 +5695,26 @@
6128
5695
  flag = args;
6129
5696
  }
6130
5697
  }
6131
-
6132
5698
  if (! --len) {
6133
5699
  validate();
6134
5700
  }
6135
5701
  });
6136
5702
  };
6137
-
6138
5703
  sub && toArray(sub).forEach(function (form) {
6139
5704
  len++;
6140
5705
  form.validate(function () {
6141
5706
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
6142
5707
  args[_key4] = arguments[_key4];
6143
5708
  }
6144
-
6145
5709
  return validFn(args);
6146
5710
  });
6147
5711
  });
6148
-
6149
5712
  if (!len) {
6150
5713
  validate();
6151
5714
  }
6152
5715
  },
6153
5716
  clearValidateState: function clearValidateState(fields) {
6154
5717
  var _this = this;
6155
-
6156
5718
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6157
5719
  api.helper.tidyFields(fields).forEach(function (field) {
6158
5720
  if (clearSub) _this.clearSubValidateState(field);
@@ -6166,7 +5728,6 @@
6166
5728
  h.getCtxs(field).forEach(function (ctx) {
6167
5729
  var subForm = h.subForm[ctx.id];
6168
5730
  if (!subForm) return;
6169
-
6170
5731
  if (Array.isArray(subForm)) {
6171
5732
  subForm.forEach(function (form) {
6172
5733
  form.clearValidateState();
@@ -6180,14 +5741,12 @@
6180
5741
  btn: {
6181
5742
  loading: function loading() {
6182
5743
  var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6183
-
6184
5744
  api.submitBtnProps({
6185
5745
  loading: !!_loading
6186
5746
  });
6187
5747
  },
6188
5748
  disabled: function disabled() {
6189
5749
  var _disabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6190
-
6191
5750
  api.submitBtnProps({
6192
5751
  disabled: !!_disabled
6193
5752
  });
@@ -6202,14 +5761,12 @@
6202
5761
  resetBtn: {
6203
5762
  loading: function loading() {
6204
5763
  var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6205
-
6206
5764
  api.resetBtnProps({
6207
5765
  loading: !!_loading2
6208
5766
  });
6209
5767
  },
6210
5768
  disabled: function disabled() {
6211
5769
  var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6212
-
6213
5770
  api.resetBtnProps({
6214
5771
  disabled: !!_disabled2
6215
5772
  });
@@ -6238,7 +5795,6 @@
6238
5795
  submit: function submit(successFn, failFn) {
6239
5796
  var _arguments = arguments,
6240
5797
  _this2 = this;
6241
-
6242
5798
  api.validate(function (valid) {
6243
5799
  if (valid) {
6244
5800
  var formData = api.formData();
@@ -6273,11 +5829,10 @@
6273
5829
  FormCreate.maker[name] = maker[name];
6274
5830
  });
6275
5831
  }
6276
-
6277
5832
  function ivuFormCreate() {
6278
5833
  return FormCreateFactory({
6279
5834
  ui: "".concat("iview"),
6280
- version: "".concat("2.5.19"),
5835
+ version: "".concat("2.5.22"),
6281
5836
  manager: manager,
6282
5837
  install: install,
6283
5838
  extendApi: extendApi,
@@ -6290,15 +5845,12 @@
6290
5845
  }
6291
5846
 
6292
5847
  var FormCreate = ivuFormCreate();
6293
-
6294
5848
  if (typeof window !== 'undefined') {
6295
5849
  window.formCreate = FormCreate;
6296
-
6297
5850
  if (window.Vue) {
6298
5851
  FormCreate.install(window.Vue);
6299
5852
  }
6300
5853
  }
6301
-
6302
5854
  var maker$1 = FormCreate.maker;
6303
5855
 
6304
5856
  exports.default = FormCreate;