@form-create/view-design 2.5.9 → 2.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/view-design v2.5.9
2
+ * @form-create/view-design v2.5.13
3
3
  * (c) 2018-2021 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -255,17 +255,9 @@
255
255
  var Checkbox = {
256
256
  name: NAME,
257
257
  props: {
258
- formCreateRule: {
258
+ formCreateInject: {
259
259
  type: Object,
260
- "default": function _default() {
261
- return {};
262
- }
263
- },
264
- formCreateOptions: {
265
- type: Array,
266
- "default": function _default() {
267
- return [];
268
- }
260
+ required: true
269
261
  },
270
262
  value: {
271
263
  type: Array,
@@ -285,8 +277,12 @@
285
277
  };
286
278
  },
287
279
  methods: {
280
+ options: function options() {
281
+ var opt = this.formCreateInject.options;
282
+ return Array.isArray(opt) ? opt : [];
283
+ },
288
284
  onInput: function onInput(n) {
289
- this.$emit('input', this.formCreateOptions.filter(function (opt) {
285
+ this.$emit('input', this.options().filter(function (opt) {
290
286
  return n.indexOf(opt.label) !== -1;
291
287
  }).map(function (opt) {
292
288
  return opt.value;
@@ -297,7 +293,7 @@
297
293
  update: function update() {
298
294
  var _this = this;
299
295
 
300
- this.trueValue = this.value ? this.formCreateOptions.filter(function (opt) {
296
+ this.trueValue = this.value ? this.options().filter(function (opt) {
301
297
  return _this.value.indexOf(opt.value) !== -1;
302
298
  }).map(function (option) {
303
299
  return option.label;
@@ -309,14 +305,14 @@
309
305
  },
310
306
  render: function render() {
311
307
  var h = arguments[0];
312
- return h("CheckboxGroup", helper([{}, this.formCreateRule, {
308
+ return h("CheckboxGroup", helper([{}, this.formCreateInject.prop, {
313
309
  "attrs": {
314
310
  "value": this.trueValue
315
311
  },
316
312
  "on": {
317
313
  "input": this.onInput
318
314
  }
319
- }]), [this.formCreateOptions.map(function (opt, index) {
315
+ }]), [this.options().map(function (opt, index) {
320
316
  var props = _objectSpread2({}, opt);
321
317
 
322
318
  delete props.value;
@@ -369,7 +365,10 @@
369
365
  return {
370
366
  name: NAME$1,
371
367
  props: {
372
- formCreateField: String,
368
+ formCreateInject: {
369
+ type: Object,
370
+ required: true
371
+ },
373
372
  type: {
374
373
  type: String,
375
374
  "default": 'input'
@@ -559,7 +558,7 @@
559
558
  }, _toConsumableArray(children));
560
559
  },
561
560
  valid: function valid(f) {
562
- var field = this.formCreateField || this.field;
561
+ var field = this.formCreateInject.field || this.field;
563
562
  if (field && f !== field) throw new Error('[frame]无效的字段值');
564
563
  },
565
564
  makeIcons: function makeIcons(val, index) {
@@ -660,7 +659,6 @@
660
659
  }]))]);
661
660
  },
662
661
  handleClick: function handleClick(src) {
663
- if (this.disabled) return;
664
662
  return this.onHandle(src);
665
663
  },
666
664
  handleRemove: function handleRemove(src) {
@@ -830,17 +828,9 @@
830
828
  var Radio = {
831
829
  name: NAME$2,
832
830
  props: {
833
- formCreateRule: {
831
+ formCreateInject: {
834
832
  type: Object,
835
- "default": function _default() {
836
- return {};
837
- }
838
- },
839
- formCreateOptions: {
840
- type: Array,
841
- "default": function _default() {
842
- return [];
843
- }
833
+ required: true
844
834
  },
845
835
  value: {}
846
836
  },
@@ -855,8 +845,12 @@
855
845
  };
856
846
  },
857
847
  methods: {
848
+ options: function options() {
849
+ var opt = this.formCreateInject.options;
850
+ return Array.isArray(opt) ? opt : [];
851
+ },
858
852
  onInput: function onInput(n) {
859
- this.$emit('input', this.formCreateOptions.filter(function (opt) {
853
+ this.$emit('input', this.options().filter(function (opt) {
860
854
  return opt.label === n;
861
855
  }).reduce(function (initial, opt) {
862
856
  return opt.value;
@@ -865,7 +859,7 @@
865
859
  update: function update() {
866
860
  var _this = this;
867
861
 
868
- this.trueValue = this.formCreateOptions.filter(function (opt) {
862
+ this.trueValue = this.options().filter(function (opt) {
869
863
  return opt.value === _this.value;
870
864
  }).reduce(function (initial, opt) {
871
865
  return opt.label;
@@ -877,14 +871,14 @@
877
871
  },
878
872
  render: function render() {
879
873
  var h = arguments[0];
880
- return h("RadioGroup", helper([{}, this.formCreateRule, {
874
+ return h("RadioGroup", helper([{}, this.formCreateInject.prop, {
881
875
  "attrs": {
882
876
  "value": this.trueValue
883
877
  },
884
878
  "on": {
885
879
  "input": this.onInput
886
880
  }
887
- }]), [this.formCreateOptions.map(function (opt, index) {
881
+ }]), [this.options().map(function (opt, index) {
888
882
  var props = _objectSpread2({}, opt);
889
883
 
890
884
  delete props.value;
@@ -924,15 +918,14 @@
924
918
  name: NAME$3,
925
919
  functional: true,
926
920
  props: {
927
- formCreateOptions: {
928
- type: Array,
929
- "default": function _default() {
930
- return [];
931
- }
921
+ formCreateInject: {
922
+ type: Object,
923
+ required: true
932
924
  }
933
925
  },
934
926
  render: function render(h, ctx) {
935
- return h("Select", helper([{}, ctx.data]), [ctx.props.formCreateOptions.map(function (props, index) {
927
+ var options = ctx.props.formCreateInject.options;
928
+ return h("Select", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
936
929
  var slot = props.slot;
937
930
  return h("Option", {
938
931
  "props": _objectSpread2({}, props),
@@ -948,13 +941,9 @@
948
941
  var Tree = {
949
942
  name: NAME$4,
950
943
  props: {
951
- formCreateRule: {
944
+ formCreateInject: {
952
945
  type: Object,
953
- "default": function _default() {
954
- return {
955
- props: {}
956
- };
957
- }
946
+ required: true
958
947
  },
959
948
  type: {
960
949
  type: String,
@@ -983,7 +972,7 @@
983
972
  methods: {
984
973
  setStatus: function setStatus(value) {
985
974
  var n = toArray(value);
986
- var data = this.formCreateRule.props.data;
975
+ var data = this.formCreateInject.prop.props.data;
987
976
  this.type === 'selected' ? this.checked(data, n, 'selected') : this.checked(data, n, 'checked');
988
977
  this.$forceUpdate();
989
978
  },
@@ -1012,7 +1001,7 @@
1012
1001
  on['on-check-change'] = this.onInput;
1013
1002
  }
1014
1003
 
1015
- return h("Tree", helper([{}, this.formCreateRule, {
1004
+ return h("Tree", helper([{}, this.formCreateInject.prop, {
1016
1005
  "ref": "tree"
1017
1006
  }, {
1018
1007
  "on": on
@@ -1039,13 +1028,9 @@
1039
1028
  return {
1040
1029
  name: NAME$5,
1041
1030
  props: {
1042
- formCreateRule: {
1031
+ formCreateInject: {
1043
1032
  type: Object,
1044
- "default": function _default() {
1045
- return {
1046
- props: {}
1047
- };
1048
- }
1033
+ required: true
1049
1034
  },
1050
1035
  onHandle: {
1051
1036
  type: Function,
@@ -1083,8 +1068,8 @@
1083
1068
  };
1084
1069
  },
1085
1070
  created: function created() {
1086
- if (this.formCreateRule.props.showUploadList === undefined) this.formCreateRule.props.showUploadList = false;
1087
- this.formCreateRule.props.defaultFileList = toArray(this.value).map(parseFile);
1071
+ if (this.formCreateInject.prop.props.showUploadList === undefined) this.formCreateInject.prop.props.showUploadList = false;
1072
+ this.formCreateInject.prop.props.defaultFileList = toArray(this.value).map(parseFile);
1088
1073
  },
1089
1074
  watch: {
1090
1075
  value: function value(n) {
@@ -1104,14 +1089,13 @@
1104
1089
  return unique;
1105
1090
  },
1106
1091
  isDisabled: function isDisabled() {
1107
- return this.formCreateRule.props.disabled === true;
1092
+ return this.formCreateInject.prop.props.disabled === true;
1108
1093
  },
1109
1094
  onRemove: function onRemove(file) {
1110
1095
  if (this.isDisabled()) return;
1111
1096
  this.$refs.upload.handleRemove(file);
1112
1097
  },
1113
1098
  handleClick: function handleClick(file) {
1114
- if (this.isDisabled()) return;
1115
1099
  this.onHandle(file);
1116
1100
  },
1117
1101
  makeItem: function makeItem(file, index) {
@@ -1204,7 +1188,7 @@
1204
1188
  makeUpload: function makeUpload() {
1205
1189
  var h = this.$createElement;
1206
1190
  var isShow = !this.maxLength || this.maxLength > this.uploadList.length;
1207
- return h("Upload", helper([{}, this.formCreateRule, {
1191
+ return h("Upload", helper([{}, this.formCreateInject.prop, {
1208
1192
  "ref": "upload",
1209
1193
  "style": {
1210
1194
  display: 'inline-block'
@@ -1239,13 +1223,13 @@
1239
1223
  var h = arguments[0];
1240
1224
 
1241
1225
  if (this.$refs.upload) {
1242
- if (this.formCreateRule.props.showUploadList === undefined) this.formCreateRule.props.showUploadList = this.$refs.upload.showUploadList;
1243
- this.formCreateRule.props.defaultFileList = this.$refs.upload.defaultFileList;
1226
+ if (this.formCreateInject.prop.props.showUploadList === undefined) this.formCreateInject.prop.props.showUploadList = this.$refs.upload.showUploadList;
1227
+ this.formCreateInject.prop.props.defaultFileList = this.$refs.upload.defaultFileList;
1244
1228
  }
1245
1229
 
1246
1230
  return h("div", {
1247
1231
  "class": "_fc-upload"
1248
- }, [[this.formCreateRule.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], h("Modal", {
1232
+ }, [[this.formCreateInject.prop.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], h("Modal", {
1249
1233
  "attrs": {
1250
1234
  "title": this.modalTitle,
1251
1235
  "footerHide": true
@@ -1298,7 +1282,10 @@
1298
1282
  rules: Array,
1299
1283
  expand: Number,
1300
1284
  options: Object,
1301
- formCreate: Object,
1285
+ formCreateInject: {
1286
+ type: Object,
1287
+ required: true
1288
+ },
1302
1289
  button: {
1303
1290
  type: Boolean,
1304
1291
  "default": true
@@ -1342,7 +1329,8 @@
1342
1329
  return {
1343
1330
  len: 0,
1344
1331
  cacheRule: {},
1345
- cacheValue: {}
1332
+ cacheValue: {},
1333
+ type: undefined
1346
1334
  };
1347
1335
  },
1348
1336
  computed: {
@@ -1456,7 +1444,7 @@
1456
1444
  addRule: function addRule(i, emit) {
1457
1445
  var _this3 = this;
1458
1446
 
1459
- var rule = this.$formCreate.copyRules(this.formRule);
1447
+ var rule = this.formCreateInject.form.copyRules(this.formRule);
1460
1448
  var options = this.options ? _objectSpread2({}, this.options) : {
1461
1449
  submitBtn: false,
1462
1450
  resetBtn: false
@@ -1489,7 +1477,7 @@
1489
1477
  subForm: function subForm() {
1490
1478
  var _this5 = this;
1491
1479
 
1492
- this.$emit('fc.sub-form', Object.keys(this.cacheRule).map(function (k) {
1480
+ this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1493
1481
  return _this5.cacheRule[k].$f;
1494
1482
  }));
1495
1483
  },
@@ -1514,7 +1502,7 @@
1514
1502
  this.addRule(i, true);
1515
1503
  },
1516
1504
  del: function del(index, key) {
1517
- if (this.disabled || false === this.onBeforeRemove(this.value)) {
1505
+ if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1518
1506
  return;
1519
1507
  }
1520
1508
 
@@ -1587,6 +1575,7 @@
1587
1575
  }
1588
1576
  },
1589
1577
  created: function created() {
1578
+ this.type = this.formCreateInject.form.$form();
1590
1579
  var d = (this.expand || 0) - this.value.length;
1591
1580
 
1592
1581
  if (d > 0) {
@@ -1603,6 +1592,7 @@
1603
1592
  var h = arguments[0];
1604
1593
  var keys = Object.keys(this.cacheRule);
1605
1594
  var button = this.button;
1595
+ var Type = this.type;
1606
1596
  return keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1607
1597
  vm: this,
1608
1598
  add: this.add
@@ -1632,7 +1622,7 @@
1632
1622
  "attrs": {
1633
1623
  "span": button ? 20 : 24
1634
1624
  }
1635
- }, [h("FormItem", [h("FormCreate", helper([{
1625
+ }, [h("FormItem", [h(Type, helper([{
1636
1626
  "key": key
1637
1627
  }, {
1638
1628
  "on": {
@@ -1683,7 +1673,10 @@
1683
1673
  props: {
1684
1674
  rule: Array,
1685
1675
  options: Object,
1686
- formCreate: Object,
1676
+ formCreateInject: {
1677
+ type: Object,
1678
+ required: true
1679
+ },
1687
1680
  value: {
1688
1681
  type: Object,
1689
1682
  "default": function _default() {
@@ -1702,7 +1695,8 @@
1702
1695
  data: function data() {
1703
1696
  return {
1704
1697
  cacheRule: {},
1705
- cacheValue: {}
1698
+ cacheValue: {},
1699
+ type: undefined
1706
1700
  };
1707
1701
  },
1708
1702
  watch: {
@@ -1752,7 +1746,7 @@
1752
1746
  });
1753
1747
  },
1754
1748
  subForm: function subForm() {
1755
- this.$emit('fc.sub-form', this.cacheRule.$f);
1749
+ this.formCreateInject.subForm(this.cacheRule.$f);
1756
1750
  },
1757
1751
  emitEvent: function emitEvent(name) {
1758
1752
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -1764,13 +1758,15 @@
1764
1758
  },
1765
1759
  created: function created() {
1766
1760
  this.addRule();
1761
+ this.type = this.formCreateInject.form.$form();
1767
1762
  },
1768
1763
  render: function render() {
1769
1764
  var h = arguments[0];
1770
1765
  var _this$cacheRule = this.cacheRule,
1771
1766
  rule = _this$cacheRule.rule,
1772
1767
  options = _this$cacheRule.options;
1773
- return h("FormCreate", helper([{}, {
1768
+ var Type = this.type;
1769
+ return h(Type, helper([{}, {
1774
1770
  "on": {
1775
1771
  'update:value': this.formData,
1776
1772
  'emit-event': this.emitEvent,
@@ -1851,6 +1847,7 @@
1851
1847
  isShow: true,
1852
1848
  unique: 1,
1853
1849
  renderRule: _toConsumableArray(this.rule || []),
1850
+ ctxInject: {},
1854
1851
  updateValue: ''
1855
1852
  };
1856
1853
  },
@@ -1906,6 +1903,7 @@
1906
1903
  Object.keys(this.formCreate.prop).forEach(function (k) {
1907
1904
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1908
1905
  });
1906
+ this.$emit('beforeCreate', this.formCreate.api());
1909
1907
  }
1910
1908
  };
1911
1909
  }
@@ -1981,7 +1979,7 @@
1981
1979
 
1982
1980
  var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
1983
1981
  var arrayAttrs = ['validate', 'children', 'control'];
1984
- var normalAttrs = ['effect'];
1982
+ var normalAttrs = ['effect', 'deep'];
1985
1983
  function attrs() {
1986
1984
  return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
1987
1985
  }
@@ -2014,6 +2012,12 @@
2014
2012
  }
2015
2013
 
2016
2014
  origin[key] = deepExtend(origin[key], clone, mode);
2015
+ } else if (is.Undef(clone)) {
2016
+ $set(origin, key, clone);
2017
+ } else if (clone.__json !== undefined) {
2018
+ $set(origin, key, clone.__json);
2019
+ } else if (clone.__origin !== undefined) {
2020
+ $set(origin, key, clone.__origin);
2017
2021
  } else {
2018
2022
  $set(origin, key, clone);
2019
2023
  }
@@ -2047,6 +2051,7 @@
2047
2051
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2048
2052
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2049
2053
  var $T = '$FN:';
2054
+ var $TX = '$FNX:';
2050
2055
  var FUNCTION = 'function';
2051
2056
  function toJson(obj, space) {
2052
2057
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
@@ -2056,7 +2061,7 @@
2056
2061
  return val;
2057
2062
  }
2058
2063
 
2059
- if (val.__json) {
2064
+ if (hasProperty(val, '__json')) {
2060
2065
  return val.__json;
2061
2066
  }
2062
2067
 
@@ -2071,28 +2076,32 @@
2071
2076
  }
2072
2077
 
2073
2078
  function parseFn(fn, mode) {
2074
- if (fn && is.String(fn)) {
2079
+ if (fn && is.String(fn) && fn.length > 4) {
2075
2080
  var v = fn.trim();
2076
2081
  var flag = false;
2077
2082
 
2078
- if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2079
- v = v.replace(SUFFIX, '').replace(PREFIX, '');
2080
- flag = true;
2081
- } else if (v.indexOf($T) === 0) {
2082
- v = v.replace($T, '');
2083
- flag = true;
2084
- } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2085
- flag = true;
2086
- }
2087
-
2088
- if (!flag) return fn;
2089
-
2090
2083
  try {
2084
+ if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2085
+ v = v.replace(SUFFIX, '').replace(PREFIX, '');
2086
+ flag = true;
2087
+ } else if (v.indexOf($T) === 0) {
2088
+ v = v.replace($T, '');
2089
+ flag = true;
2090
+ } else if (v.indexOf($TX) === 0) {
2091
+ v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2092
+ v.__json = fn;
2093
+ v.__inject = true;
2094
+ return v;
2095
+ } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2096
+ flag = true;
2097
+ }
2098
+
2099
+ if (!flag) return fn;
2091
2100
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2092
2101
  val.__json = fn;
2093
2102
  return val;
2094
2103
  } catch (e) {
2095
- err("\u89E3\u6790\u5931\u8D25:".concat(v));
2104
+ err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
2096
2105
  return undefined;
2097
2106
  }
2098
2107
  }
@@ -2183,7 +2192,7 @@
2183
2192
  to;
2184
2193
  (idx || '').split('.').forEach(function (v) {
2185
2194
  if (to) {
2186
- if (!_data[to]) {
2195
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2187
2196
  _data[to] = {};
2188
2197
  }
2189
2198
 
@@ -2281,13 +2290,6 @@
2281
2290
  return deepCopy(value);
2282
2291
  }
2283
2292
 
2284
- function byRules(ctxs, origin) {
2285
- return Object.keys(ctxs).reduce(function (initial, key) {
2286
- initial[key] = origin ? ctxs[key].origin : ctxs[key].rule;
2287
- return initial;
2288
- }, {});
2289
- }
2290
-
2291
2293
  function Api(h) {
2292
2294
  function tidyFields(fields) {
2293
2295
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
@@ -2296,10 +2298,10 @@
2296
2298
 
2297
2299
  function props(fields, key, val) {
2298
2300
  tidyFields(fields).forEach(function (field) {
2299
- var ctx = h.getCtx(field);
2300
- if (!ctx) return;
2301
- $set(ctx.rule, key, val);
2302
- h.$render.clearCache(ctx);
2301
+ h.getCtxs(field).forEach(function (ctx) {
2302
+ $set(ctx.rule, key, val);
2303
+ h.$render.clearCache(ctx);
2304
+ });
2303
2305
  });
2304
2306
  }
2305
2307
 
@@ -2314,11 +2316,6 @@
2314
2316
  }
2315
2317
 
2316
2318
  var api = {
2317
- helper: {
2318
- tidyFields: tidyFields,
2319
- props: props
2320
- },
2321
-
2322
2319
  get config() {
2323
2320
  return h.options;
2324
2321
  },
@@ -2345,23 +2342,26 @@
2345
2342
 
2346
2343
  formData: function formData(fields) {
2347
2344
  return tidyFields(fields).reduce(function (initial, id) {
2348
- var ctx = h.fieldCtx[id];
2345
+ var ctx = h.getFieldCtx(id);
2349
2346
  if (!ctx) return initial;
2350
2347
  initial[ctx.field] = copy(ctx.rule.value);
2351
2348
  return initial;
2352
2349
  }, copy(h.appendData));
2353
2350
  },
2354
2351
  getValue: function getValue(field) {
2355
- var ctx = h.fieldCtx[field];
2352
+ var ctx = h.getFieldCtx(field);
2356
2353
  if (!ctx) return;
2357
2354
  return copy(ctx.rule.value);
2358
2355
  },
2359
2356
  coverValue: function coverValue(formData) {
2360
2357
  h.deferSyncValue(function () {
2361
- Object.keys(h.fieldCtx).forEach(function (key) {
2362
- var ctx = h.fieldCtx[key];
2363
- if (!ctx) return h.appendData[key] = formData[key];
2364
- ctx.rule.value = hasProperty(formData, key) ? formData[key] : undefined;
2358
+ api.fields().forEach(function (key) {
2359
+ var ctxs = h.fieldCtx[key];
2360
+ if (!ctxs) return h.appendData[key] = formData[key];
2361
+ var flag = hasProperty(formData, key);
2362
+ ctxs.forEach(function (ctx) {
2363
+ ctx.rule.value = flag ? formData[key] : undefined;
2364
+ });
2365
2365
  });
2366
2366
  });
2367
2367
  },
@@ -2370,17 +2370,22 @@
2370
2370
  if (arguments.length >= 2) formData = _defineProperty({}, field, arguments[1]);
2371
2371
  h.deferSyncValue(function () {
2372
2372
  Object.keys(formData).forEach(function (key) {
2373
- var ctx = h.fieldCtx[key];
2374
- if (!ctx) return h.appendData[key] = formData[key];
2375
- ctx.rule.value = formData[key];
2373
+ var ctxs = h.fieldCtx[key];
2374
+ if (!ctxs) return h.appendData[key] = formData[key];
2375
+ ctxs.forEach(function (ctx) {
2376
+ ctx.rule.value = formData[key];
2377
+ });
2376
2378
  });
2377
2379
  });
2378
2380
  },
2379
2381
  removeField: function removeField(field) {
2380
2382
  var ctx = h.getCtx(field);
2381
- if (!ctx) return;
2382
- ctx.rm();
2383
- return ctx.origin;
2383
+ h.deferSyncValue(function () {
2384
+ h.getCtxs(field).forEach(function (ctx) {
2385
+ ctx.rm();
2386
+ });
2387
+ }, true);
2388
+ return ctx ? ctx.origin : undefined;
2384
2389
  },
2385
2390
  removeRule: function removeRule(rule) {
2386
2391
  var ctx = rule && byCtx(rule);
@@ -2396,10 +2401,8 @@
2396
2401
  return h.fields();
2397
2402
  },
2398
2403
  append: function append(rule, after, child) {
2399
- var fields = Object.keys(h.fieldCtx),
2400
- index = h.sort.length - 1,
2404
+ var index = h.sort.length - 1,
2401
2405
  rules;
2402
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2403
2406
  var ctx = h.getCtx(after);
2404
2407
 
2405
2408
  if (ctx) {
@@ -2415,10 +2418,8 @@
2415
2418
  rules.splice(index + 1, 0, rule);
2416
2419
  },
2417
2420
  prepend: function prepend(rule, after, child) {
2418
- var fields = Object.keys(h.fieldCtx),
2419
- index = 0,
2421
+ var index = 0,
2420
2422
  rules;
2421
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2422
2423
  var ctx = h.getCtx(after);
2423
2424
 
2424
2425
  if (ctx) {
@@ -2452,17 +2453,33 @@
2452
2453
  },
2453
2454
  disabled: function disabled(_disabled, fields) {
2454
2455
  tidyFields(fields).forEach(function (field) {
2455
- var ctx = h.fieldCtx[field];
2456
- if (!ctx) return;
2457
- $set(ctx.rule.props, 'disabled', !!_disabled);
2456
+ h.getCtxs(field).forEach(function (ctx) {
2457
+ $set(ctx.rule.props, 'disabled', !!_disabled);
2458
+ });
2458
2459
  });
2459
2460
  h.refresh();
2460
2461
  },
2462
+ all: function all(origin) {
2463
+ return Object.keys(h.ctxs).map(function (k) {
2464
+ var ctx = h.ctxs[k];
2465
+ return origin ? ctx.origin : ctx.rule;
2466
+ });
2467
+ },
2461
2468
  model: function model(origin) {
2462
- return byRules(h.fieldCtx, origin);
2469
+ return h.fields().reduce(function (initial, key) {
2470
+ var ctx = h.fieldCtx[key][0];
2471
+ initial[key] = origin ? ctx.origin : ctx.rule;
2472
+ return initial;
2473
+ }, {});
2463
2474
  },
2464
2475
  component: function component(origin) {
2465
- return byRules(h.nameCtx, origin);
2476
+ return Object.keys(h.nameCtx).reduce(function (initial, key) {
2477
+ var ctx = h.nameCtx[key].map(function (ctx) {
2478
+ return origin ? ctx.origin : ctx.rule;
2479
+ });
2480
+ initial[key] = ctx.length === 1 ? ctx[0] : ctx;
2481
+ return initial;
2482
+ }, {});
2466
2483
  },
2467
2484
  bind: function bind() {
2468
2485
  return api.form;
@@ -2480,25 +2497,39 @@
2480
2497
  });
2481
2498
  },
2482
2499
  sync: function sync(field) {
2483
- var ctx = is.Object(field) ? byCtx(field) : h.getCtx(field);
2500
+ if (Array.isArray(field)) {
2501
+ field.forEach(function (v) {
2502
+ return api.sync(v);
2503
+ });
2504
+ return;
2505
+ }
2484
2506
 
2485
- if (ctx && !ctx.deleted) {
2486
- var subForm = h.subForm[field];
2507
+ var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2487
2508
 
2488
- if (subForm) {
2489
- if (Array.isArray(subForm)) {
2490
- subForm.forEach(function (form) {
2491
- form.refresh();
2492
- });
2493
- } else if (subForm) {
2494
- subForm.refresh();
2495
- }
2496
- } //ctx.updateKey(true);
2509
+ if (!ctxs) {
2510
+ return;
2511
+ }
2497
2512
 
2513
+ ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2514
+ ctxs.forEach(function (ctx) {
2515
+ if (!ctx.deleted) {
2516
+ var subForm = h.subForm[ctx.id];
2517
+
2518
+ if (subForm) {
2519
+ if (Array.isArray(subForm)) {
2520
+ subForm.forEach(function (form) {
2521
+ form.refresh();
2522
+ });
2523
+ } else if (subForm) {
2524
+ subForm.refresh();
2525
+ }
2526
+ } //ctx.updateKey(true);
2498
2527
 
2499
- h.$render.clearCache(ctx);
2500
- h.refresh();
2501
- }
2528
+
2529
+ h.$render.clearCache(ctx);
2530
+ }
2531
+ });
2532
+ h.refresh();
2502
2533
  },
2503
2534
  refresh: function refresh() {
2504
2535
  allSubForm().forEach(function (sub) {
@@ -2521,8 +2552,9 @@
2521
2552
  h.changeStatus = false;
2522
2553
  },
2523
2554
  updateRule: function updateRule(id, rule) {
2524
- var r = api.getRule(id);
2525
- r && extend(r, rule);
2555
+ h.getCtxs(id).forEach(function (ctx) {
2556
+ extend(ctx.rule, rule);
2557
+ });
2526
2558
  },
2527
2559
  updateRules: function updateRules(rules) {
2528
2560
  Object.keys(rules).forEach(function (id) {
@@ -2530,8 +2562,9 @@
2530
2562
  });
2531
2563
  },
2532
2564
  mergeRule: function mergeRule$1(id, rule) {
2533
- var ctx = h.getCtx(id);
2534
- ctx && mergeRule(ctx.rule, rule);
2565
+ h.getCtxs(id).forEach(function (ctx) {
2566
+ mergeRule(ctx.rule, rule);
2567
+ });
2535
2568
  },
2536
2569
  mergeRules: function mergeRules(rules) {
2537
2570
  Object.keys(rules).forEach(function (id) {
@@ -2564,13 +2597,12 @@
2564
2597
  api.refresh();
2565
2598
  },
2566
2599
  resetFields: function resetFields(fields) {
2567
- var ctxs = h.fieldCtx;
2568
2600
  tidyFields(fields).forEach(function (field) {
2569
- var ctx = ctxs[field];
2570
- if (!ctx) return;
2571
- h.$render.clearCache(ctx);
2572
- ctx.rule.value = copy(ctx.defaultValue);
2573
- h.refreshControl(ctx);
2601
+ h.getCtxs(field).forEach(function (ctx) {
2602
+ h.$render.clearCache(ctx);
2603
+ ctx.rule.value = copy(ctx.defaultValue);
2604
+ h.refreshControl(ctx);
2605
+ });
2574
2606
  });
2575
2607
  },
2576
2608
  method: function method(id, name) {
@@ -2610,7 +2642,8 @@
2610
2642
  el && el.$emit && el.$emit('close-modal');
2611
2643
  },
2612
2644
  getSubForm: function getSubForm(field) {
2613
- return h.subForm[field];
2645
+ var ctx = h.getCtx(field);
2646
+ return ctx ? h.subForm[ctx.id] : undefined;
2614
2647
  },
2615
2648
  nextTick: function nextTick(fn) {
2616
2649
  h.bus.$once('next-tick', fn);
@@ -2619,13 +2652,26 @@
2619
2652
  nextRefresh: function nextRefresh(fn) {
2620
2653
  h.nextRefresh();
2621
2654
  fn && invoke(fn);
2655
+ },
2656
+ emit: function emit(name) {
2657
+ var _h$vm;
2658
+
2659
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2660
+ args[_key3 - 1] = arguments[_key3];
2661
+ }
2662
+
2663
+ (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2664
+ },
2665
+ helper: {
2666
+ tidyFields: tidyFields,
2667
+ props: props
2622
2668
  }
2623
2669
  };
2624
2670
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2625
2671
  api[n] = function () {
2626
- var _h$vm;
2672
+ var _h$vm2;
2627
2673
 
2628
- (_h$vm = h.vm)["$".concat(n)].apply(_h$vm, arguments);
2674
+ (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2629
2675
  };
2630
2676
  });
2631
2677
  api.changeValue = api.changeField = api.setValue;
@@ -2658,7 +2704,8 @@
2658
2704
  this.cache[ctx.id] = {
2659
2705
  vnode: vnode,
2660
2706
  use: false,
2661
- parent: parent
2707
+ parent: parent,
2708
+ slot: ctx.rule.slot
2662
2709
  };
2663
2710
  },
2664
2711
  getCache: function getCache(ctx) {
@@ -2679,46 +2726,20 @@
2679
2726
  return str.replace(str[0], str[0].toLowerCase());
2680
2727
  }
2681
2728
 
2682
- function setTempProps(vm, ctx, api) {
2683
- if (!vm.$props) return;
2684
- var prop = ctx.prop;
2685
- var keys = Object.keys(vm.$props);
2686
- var inject = injectProp(ctx, api);
2687
- var injectKeys = Object.keys(inject);
2688
- keys.forEach(function (key) {
2689
- if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2690
- });
2691
- var key = vm.$options.model && vm.$options.model.prop || 'value';
2692
-
2693
- if (keys.indexOf(key) > -1) {
2694
- vm.$props[key] = prop.value;
2695
- }
2696
- }
2697
-
2698
- function injectProp(ctx, api) {
2699
- return {
2700
- formCreate: api,
2701
- formCreateField: ctx.field,
2702
- formCreateOptions: ctx.prop.options,
2703
- formCreateRule: function () {
2704
- var temp = _objectSpread2({}, ctx.prop);
2705
-
2706
- return temp.on = temp.on ? _objectSpread2({}, temp.on) : {}, temp;
2707
- }()
2708
- };
2709
- }
2710
-
2711
2729
  function useRender(Render) {
2712
2730
  extend(Render.prototype, {
2713
2731
  initRender: function initRender() {
2714
- this.renderList = {};
2732
+ this.tempList = {};
2715
2733
  this.clearOrgChildren();
2716
2734
  },
2717
2735
  initOrgChildren: function initOrgChildren() {
2718
2736
  var ctxs = this.$handle.ctxs;
2719
2737
  this.orgChildren = Object.keys(ctxs).reduce(function (initial, id) {
2720
- var children = ctxs[id].rule.children;
2721
- initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2738
+ if (ctxs[id].parser.loadChildren !== false) {
2739
+ var children = ctxs[id].rule.children;
2740
+ initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2741
+ }
2742
+
2722
2743
  return initial;
2723
2744
  }, {});
2724
2745
  },
@@ -2734,19 +2755,47 @@
2734
2755
 
2735
2756
  this.$h = this.vm.$createElement;
2736
2757
  this.$manager.beforeRender();
2737
- var vn = this.sort.map(function (id) {
2738
- return _this.renderCtx(_this.$handle.ctxs[id]);
2758
+ var vn;
2759
+
2760
+ var make = function make() {
2761
+ return _this.renderList();
2762
+ };
2763
+
2764
+ make.renderSlot = function (slot) {
2765
+ return _this.renderList(slot);
2766
+ };
2767
+
2768
+ make.renderName = function (name) {
2769
+ return _this.renderId(name);
2770
+ };
2771
+
2772
+ make.renderField = function (field) {
2773
+ return _this.renderId(field, 'field');
2774
+ };
2775
+
2776
+ if (this.vm.$scopedSlots.container) {
2777
+ vn = [this.vm.$scopedSlots.container(make)];
2778
+ } else {
2779
+ vn = make();
2780
+ }
2781
+
2782
+ return this.$manager.render(vn);
2783
+ },
2784
+ renderList: function renderList(slot) {
2785
+ var _this2 = this;
2786
+
2787
+ return this.sort.map(function (id) {
2788
+ return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2739
2789
  }).filter(function (val) {
2740
2790
  return val !== undefined;
2741
2791
  });
2742
- return this.$manager.render(vn);
2743
2792
  },
2744
2793
  makeVm: function makeVm(rule) {
2745
- var _this2 = this;
2794
+ var _this3 = this;
2746
2795
 
2747
2796
  var vm = rule.vm;
2748
2797
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2749
- return vm(_this2.$handle.getInjectData(rule));
2798
+ return rule.vm(_this3.$handle.getInjectData(rule));
2750
2799
  });else if (!vm._isVue) return new _vue(vm);
2751
2800
  return vm;
2752
2801
  },
@@ -2762,8 +2811,31 @@
2762
2811
  deepSet(ctx.prop, ctx.prop.optionsTo, ctx.prop.options);
2763
2812
  }
2764
2813
  },
2814
+ deepSet: function deepSet$1(ctx) {
2815
+ var deep = ctx.rule.deep;
2816
+ deep && Object.keys(deep).sort(function (a, b) {
2817
+ return a.length < b.length ? -1 : 1;
2818
+ }).forEach(function (str) {
2819
+ deepSet(ctx.prop, str, deep[str]);
2820
+ });
2821
+ },
2822
+ setTempProps: function setTempProps(vm, ctx) {
2823
+ if (!vm.$props) return;
2824
+ var prop = ctx.prop;
2825
+ var keys = Object.keys(vm.$props);
2826
+ var inject = this.injectProp(ctx);
2827
+ var injectKeys = Object.keys(inject);
2828
+ keys.forEach(function (key) {
2829
+ if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2830
+ });
2831
+ var key = vm.$options.model && vm.$options.model.prop || 'value';
2832
+
2833
+ if (keys.indexOf(key) > -1) {
2834
+ vm.$props[key] = prop.value;
2835
+ }
2836
+ },
2765
2837
  renderTemp: function renderTemp(ctx) {
2766
- var _this3 = this;
2838
+ var _this4 = this;
2767
2839
 
2768
2840
  if (!_vue.compile) {
2769
2841
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
@@ -2774,7 +2846,7 @@
2774
2846
  var id = ctx.id,
2775
2847
  key = ctx.key;
2776
2848
 
2777
- if (!this.renderList[id]) {
2849
+ if (!this.tempList[id]) {
2778
2850
  if (!ctx.el) {
2779
2851
  ctx.el = this.makeVm(rule);
2780
2852
  this.vm.$nextTick(function () {
@@ -2784,18 +2856,18 @@
2784
2856
 
2785
2857
  var _vm = ctx.el;
2786
2858
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2787
- _this3.onInput(ctx, value);
2859
+ _this4.onInput(ctx, value);
2788
2860
  });
2789
- this.renderList[id] = {
2861
+ this.tempList[id] = {
2790
2862
  vm: _vm,
2791
2863
  template: _vue.compile(rule.template)
2792
2864
  };
2793
2865
  }
2794
2866
 
2795
- var _this$renderList$id = this.renderList[id],
2796
- vm = _this$renderList$id.vm,
2797
- template = _this$renderList$id.template;
2798
- setTempProps(vm, ctx, this.$handle.api);
2867
+ var _this$tempList$id = this.tempList[id],
2868
+ vm = _this$tempList$id.vm,
2869
+ template = _this$tempList$id.template;
2870
+ this.setTempProps(vm, ctx);
2799
2871
  var vn = template.render.call(vm);
2800
2872
  if (is.Undef(vn.data)) vn.data = {};
2801
2873
  vn.key = key;
@@ -2810,16 +2882,29 @@
2810
2882
  var prop = ctx[temp ? 'rule' : 'prop'];
2811
2883
  return [this.renderRule(this.parseSide(prop.prefix)), vn, this.renderRule(this.parseSide(prop.suffix))];
2812
2884
  },
2885
+ renderSlot: function renderSlot(ctx, slot) {
2886
+ return ctx.rule.slot === slot ? this.renderCtx(ctx) : undefined;
2887
+ },
2888
+ renderId: function renderId(name, type) {
2889
+ var _this5 = this;
2890
+
2891
+ var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2892
+ return ctxs ? ctxs.map(function (ctx) {
2893
+ return _this5.renderCtx(ctx, ctx.parent);
2894
+ }) : undefined;
2895
+ },
2813
2896
  renderCtx: function renderCtx(ctx, parent) {
2814
2897
  if (ctx.type === 'hidden') return;
2898
+ var rule = ctx.rule;
2899
+ var preview = this.options.preview || false;
2815
2900
 
2816
- if (!this.cache[ctx.id]) {
2901
+ if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2817
2902
  var vn;
2818
2903
  var cacheFlag = true;
2819
2904
  var _type = ctx.trueType;
2820
- var none = !(is.Undef(ctx.rule.display) || !!ctx.rule.display);
2905
+ var none = !(is.Undef(rule.display) || !!rule.display);
2821
2906
 
2822
- if (_type === 'template' && !ctx.rule.template) {
2907
+ if (_type === 'template' && !rule.template) {
2823
2908
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2824
2909
 
2825
2910
  if (none) {
@@ -2833,9 +2918,11 @@
2833
2918
  ctx.initProp();
2834
2919
  this.mergeGlobal(ctx);
2835
2920
  this.$manager.tidyRule(ctx);
2921
+ this.deepSet(ctx);
2836
2922
  this.setOptions(ctx);
2837
2923
  this.ctxProp(ctx);
2838
2924
  var prop = ctx.prop;
2925
+ prop.props.formCreateInject = this.injectProp(ctx);
2839
2926
 
2840
2927
  if (prop.hidden) {
2841
2928
  this.setCache(ctx, undefined, parent);
@@ -2846,7 +2933,28 @@
2846
2933
  vn = this.renderTemp(ctx);
2847
2934
  cacheFlag = false;
2848
2935
  } else {
2849
- vn = ctx.parser.render(this.renderChildren(ctx), ctx);
2936
+ var children = [];
2937
+
2938
+ if (ctx.parser.renderChildren) {
2939
+ children = ctx.parser.renderChildren(ctx);
2940
+ } else if (ctx.parser.loadChildren !== false) {
2941
+ children = this.renderChildren(ctx);
2942
+ }
2943
+
2944
+ var slot = 'type-' + toLine(ctx.type);
2945
+
2946
+ if (this.vm.$scopedSlots[slot]) {
2947
+ vn = this.vm.$scopedSlots[slot]({
2948
+ rule: rule,
2949
+ prop: prop,
2950
+ preview: preview,
2951
+ children: children,
2952
+ api: this.$handle.api,
2953
+ model: prop.model || {}
2954
+ });
2955
+ } else {
2956
+ vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
2957
+ }
2850
2958
  }
2851
2959
 
2852
2960
  vn = this.renderSides(vn, ctx);
@@ -2872,13 +2980,13 @@
2872
2980
  return this.getCache(ctx);
2873
2981
  },
2874
2982
  display: function display(vn) {
2875
- var _this4 = this;
2983
+ var _this6 = this;
2876
2984
 
2877
2985
  if (Array.isArray(vn)) {
2878
2986
  var data = [];
2879
2987
  vn.forEach(function (v) {
2880
- if (Array.isArray(v)) return _this4.display(v);
2881
- if (_this4.none(v)) data.push(v);
2988
+ if (Array.isArray(v)) return _this6.display(v);
2989
+ if (_this6.none(v)) data.push(v);
2882
2990
  });
2883
2991
  return data;
2884
2992
  } else {
@@ -2906,8 +3014,38 @@
2906
3014
  key: ctx.key
2907
3015
  }, [vn]);
2908
3016
  },
3017
+ injectProp: function injectProp(ctx) {
3018
+ var _this7 = this;
3019
+
3020
+ if (!this.vm.ctxInject[ctx.id]) {
3021
+ $set(this.vm.ctxInject, ctx.id, {
3022
+ api: this.$handle.api,
3023
+ form: this.fc.create,
3024
+ subForm: function subForm(_subForm) {
3025
+ _this7.$handle.addSubForm(ctx, _subForm);
3026
+ },
3027
+ field: ctx.field,
3028
+ rule: ctx.rule
3029
+ });
3030
+ }
3031
+
3032
+ var inject = this.vm.ctxInject[ctx.id];
3033
+ extend(inject, {
3034
+ preview: this.options.preview || false,
3035
+ options: ctx.prop.options,
3036
+ children: ctx.rule.children,
3037
+ prop: function () {
3038
+ var temp = _objectSpread2({}, ctx.prop);
3039
+
3040
+ temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3041
+ delete temp.model;
3042
+ return temp;
3043
+ }()
3044
+ });
3045
+ return inject;
3046
+ },
2909
3047
  ctxProp: function ctxProp(ctx, custom) {
2910
- var _this5 = this;
3048
+ var _this8 = this;
2911
3049
 
2912
3050
  var ref = ctx.ref,
2913
3051
  key = ctx.key,
@@ -2915,29 +3053,28 @@
2915
3053
  this.$manager.mergeProp(ctx, custom);
2916
3054
  ctx.parser.mergeProp(ctx, custom);
2917
3055
  var props = [{
2918
- props: injectProp(ctx, this.$handle.api),
2919
3056
  ref: ref,
2920
3057
  key: rule.key || "".concat(key, "fc"),
2921
- slot: undefined
3058
+ slot: undefined,
3059
+ on: {
3060
+ 'hook:mounted': function hookMounted() {
3061
+ _this8.onMounted(ctx);
3062
+ },
3063
+ 'fc.sub-form': function fcSubForm(subForm) {
3064
+ _this8.$handle.addSubForm(ctx, subForm);
3065
+ }
3066
+ }
2922
3067
  }];
2923
3068
 
2924
- if (!custom) {
3069
+ if (!custom && ctx.input) {
2925
3070
  props.push({
2926
- on: {
2927
- 'hook:mounted': function hookMounted() {
2928
- _this5.onMounted(ctx);
2929
- },
2930
- 'fc.sub-form': function fcSubForm(subForm) {
2931
- _this5.$handle.addSubForm(ctx, subForm);
2932
- }
2933
- },
2934
- model: ctx.input ? {
3071
+ model: {
2935
3072
  value: this.$handle.getFormData(ctx),
2936
3073
  callback: function callback(value) {
2937
- _this5.onInput(ctx, value);
3074
+ _this8.onInput(ctx, value);
2938
3075
  },
2939
- expression: "formData.".concat(ctx.field)
2940
- } : undefined
3076
+ expression: "formData.".concat(ctx.id)
3077
+ }
2941
3078
  });
2942
3079
  }
2943
3080
 
@@ -2946,6 +3083,11 @@
2946
3083
  },
2947
3084
  onMounted: function onMounted(ctx) {
2948
3085
  ctx.el = this.vm.$refs[ctx.ref];
3086
+
3087
+ if (ctx.el) {
3088
+ (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3089
+ }
3090
+
2949
3091
  ctx.parser.mounted(ctx);
2950
3092
  this.$handle.effect(ctx, 'mounted');
2951
3093
  },
@@ -2953,13 +3095,13 @@
2953
3095
  this.$handle.onInput(ctx, value);
2954
3096
  },
2955
3097
  renderChildren: function renderChildren(ctx) {
2956
- var _this6 = this;
3098
+ var _this9 = this;
2957
3099
 
2958
3100
  var children = ctx.rule.children,
2959
3101
  orgChildren = this.orgChildren[ctx.id];
2960
3102
 
2961
3103
  var isRm = function isRm(child) {
2962
- return !is.String(child) && child.__fc__ && !_this6.$handle.ctxs[child.__fc__.id];
3104
+ return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
2963
3105
  };
2964
3106
 
2965
3107
  if (!is.trueArray(children) && orgChildren) {
@@ -2968,7 +3110,7 @@
2968
3110
  if (!child) return;
2969
3111
 
2970
3112
  if (isRm(child)) {
2971
- _this6.$handle.rmCtx(child.__fc__);
3113
+ _this9.$handle.rmCtx(child.__fc__);
2972
3114
  }
2973
3115
  });
2974
3116
  });
@@ -2981,7 +3123,7 @@
2981
3123
  if (!child) return;
2982
3124
 
2983
3125
  if (children.indexOf(child) === -1 && isRm(child)) {
2984
- _this6.$handle.rmCtx(child.__fc__);
3126
+ _this9.$handle.rmCtx(child.__fc__);
2985
3127
  }
2986
3128
  });
2987
3129
  });
@@ -2990,14 +3132,14 @@
2990
3132
  if (is.String(child)) return child;
2991
3133
 
2992
3134
  if (child.__fc__) {
2993
- return _this6.renderCtx(child.__fc__, ctx);
3135
+ return _this9.renderCtx(child.__fc__, ctx);
2994
3136
  }
2995
3137
 
2996
- if (!_this6.$handle.isRepeatRule(child.__origin__ || child) && child.type) {
2997
- _this6.vm.$nextTick(function () {
2998
- _this6.$handle.loadChildren(children, ctx);
3138
+ if (child.type) {
3139
+ _this9.vm.$nextTick(function () {
3140
+ _this9.$handle.loadChildren(children, ctx);
2999
3141
 
3000
- _this6.$handle.refresh();
3142
+ _this9.$handle.refresh();
3001
3143
  });
3002
3144
  }
3003
3145
  });
@@ -3009,7 +3151,7 @@
3009
3151
  return this.vNode.make(lower(ctx.originType), prop, children);
3010
3152
  },
3011
3153
  renderRule: function renderRule(rule, children, origin) {
3012
- var _this7 = this;
3154
+ var _this10 = this;
3013
3155
 
3014
3156
  if (!rule) return undefined;
3015
3157
  if (is.String(rule)) return rule;
@@ -3032,7 +3174,7 @@
3032
3174
 
3033
3175
  if (is.trueArray(rule.children)) {
3034
3176
  data.push(rule.children.map(function (v) {
3035
- return _this7.renderRule(v);
3177
+ return _this10.renderRule(v);
3036
3178
  }));
3037
3179
  }
3038
3180
 
@@ -3066,20 +3208,33 @@
3066
3208
  function useInject(Handler) {
3067
3209
  extend(Handler.prototype, {
3068
3210
  parseInjectEvent: function parseInjectEvent(rule, on) {
3069
- var _this = this;
3070
-
3071
- if (rule.inject === false) return;
3072
3211
  var inject = rule.inject || this.options.injectEvent;
3073
- if (is.Undef(inject)) return;
3074
- Object.keys(on).forEach(function (k) {
3075
- if (is.Function(on[k])) on[k] = _this.inject(rule, on[k], inject);
3076
- });
3077
- return on;
3212
+ return this.parseEventLst(rule, on, inject);
3078
3213
  },
3079
- parseFn: function parseFn$1(obj) {
3080
- obj && Object.keys(obj).forEach(function (n) {
3081
- obj[n] = parseFn(obj[n]);
3214
+ parseEventLst: function parseEventLst(rule, data, inject, deep) {
3215
+ var _this = this;
3216
+
3217
+ Object.keys(data).forEach(function (k) {
3218
+ var fn = _this.parseEvent(rule, data[k], inject, deep);
3219
+
3220
+ if (fn) {
3221
+ data[k] = fn;
3222
+ }
3082
3223
  });
3224
+ return data;
3225
+ },
3226
+ parseEvent: function parseEvent(rule, fn, inject, deep) {
3227
+ if (is.Function(fn) && (inject !== false && !is.Undef(inject) || fn.__inject)) {
3228
+ return this.inject(rule, fn, inject);
3229
+ } else if (!deep && Array.isArray(fn) && fn[0] && (is.String(fn[0]) || is.Function(fn[0]))) {
3230
+ return this.parseEventLst(rule, fn, inject, true);
3231
+ } else if (is.String(fn)) {
3232
+ var val = parseFn(fn);
3233
+
3234
+ if (val && fn !== val) {
3235
+ return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3236
+ }
3237
+ }
3083
3238
  },
3084
3239
  parseEmit: function parseEmit(ctx, on) {
3085
3240
  var _this2 = this;
@@ -3141,6 +3296,7 @@
3141
3296
  option = _this$vm$$options$pro.option,
3142
3297
  rule = _this$vm$$options$pro.rule;
3143
3298
  return {
3299
+ api: this.api,
3144
3300
  $f: this.api,
3145
3301
  rule: rule,
3146
3302
  self: self.__origin__,
@@ -3157,15 +3313,19 @@
3157
3313
  var h = this;
3158
3314
 
3159
3315
  var fn = function fn() {
3316
+ var data = h.getInjectData(self, _inject2);
3317
+
3160
3318
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3161
3319
  args[_key2] = arguments[_key2];
3162
3320
  }
3163
3321
 
3164
- args.unshift(h.getInjectData(self, _inject2));
3322
+ data.args = [].concat(args);
3323
+ args.unshift(data);
3165
3324
  return _fn.apply(this, args);
3166
3325
  };
3167
3326
 
3168
3327
  fn.__origin = _fn;
3328
+ fn.__json = _fn.__json;
3169
3329
  return fn;
3170
3330
  }
3171
3331
  });
@@ -3310,7 +3470,10 @@
3310
3470
  initProp: function initProp() {
3311
3471
  var _this = this;
3312
3472
 
3313
- this.prop = mergeProps([this.rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3473
+ var rule = _objectSpread2({}, this.rule);
3474
+
3475
+ delete rule.children;
3476
+ this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3314
3477
  return _this.payload[k];
3315
3478
  })), [this.computed]));
3316
3479
  },
@@ -3357,7 +3520,7 @@
3357
3520
  },
3358
3521
  rmCtrl: function rmCtrl() {
3359
3522
  this.ctrlRule.forEach(function (ctrl) {
3360
- return ctrl.__fc__.rm();
3523
+ return ctrl.__fc__ && ctrl.__fc__.rm();
3361
3524
  });
3362
3525
  this.ctrlRule = [];
3363
3526
  },
@@ -3391,7 +3554,7 @@
3391
3554
  extend(_this2, {
3392
3555
  root: []
3393
3556
  });
3394
- });
3557
+ }, _this2.input);
3395
3558
  });
3396
3559
  },
3397
3560
  update: function update(handle, init) {
@@ -3449,14 +3612,8 @@
3449
3612
  loadFn: function loadFn(item, rule) {
3450
3613
  var _this3 = this;
3451
3614
 
3452
- ['on', 'props', 'nativeOn'].forEach(function (k) {
3453
- var v = item[k];
3454
-
3455
- if (v) {
3456
- _this3.parseFn(v);
3457
-
3458
- _this3.parseInjectEvent(rule, v);
3459
- }
3615
+ ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3616
+ item[k] && _this3.parseInjectEvent(rule, item[k]);
3460
3617
  });
3461
3618
  },
3462
3619
  loadCtrl: function loadCtrl(rule) {
@@ -3482,9 +3639,6 @@
3482
3639
  }, {})
3483
3640
  }], ctx.computed);
3484
3641
  },
3485
- isRepeatRule: function isRepeatRule(rule) {
3486
- return this.repeatRule.indexOf(rule) > -1;
3487
- },
3488
3642
  loadRule: function loadRule() {
3489
3643
  var _this5 = this;
3490
3644
 
@@ -3568,7 +3722,7 @@
3568
3722
  var rule = getRule(_rule);
3569
3723
 
3570
3724
  var isRepeat = function isRepeat() {
3571
- return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field] !== _rule.__fc__);
3725
+ return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3572
3726
  };
3573
3727
 
3574
3728
  _this6.ruleEffect(rule, 'init', {
@@ -3576,11 +3730,7 @@
3576
3730
  });
3577
3731
 
3578
3732
  if (isRepeat()) {
3579
- _this6.repeatRule.push(_rule);
3580
-
3581
- _this6.vm.$emit('repeat', _rule, _this6.api);
3582
-
3583
- return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), _rule);
3733
+ _this6.vm.$emit('repeat-field', _rule, _this6.api);
3584
3734
  }
3585
3735
 
3586
3736
  var ctx;
@@ -3638,7 +3788,7 @@
3638
3788
  _this6.setCtx(ctx);
3639
3789
 
3640
3790
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3641
- loadChildren(ctx.rule.children, ctx);
3791
+ ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3642
3792
 
3643
3793
  if (!parent) {
3644
3794
  var _preIndex = preIndex(index);
@@ -3686,14 +3836,17 @@
3686
3836
  return val === control.value;
3687
3837
  };
3688
3838
 
3839
+ if (!is.trueArray(control.rule)) return "continue";
3840
+
3689
3841
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3690
3842
  valid: invoke(function () {
3691
3843
  return handleFn(ctx.rule.value, api);
3692
3844
  }),
3693
- ctrl: findCtrl(ctx, control.rule)
3845
+ ctrl: findCtrl(ctx, control.rule),
3846
+ isHidden: is.String(control.rule[0])
3694
3847
  });
3695
3848
 
3696
- if (data.valid && data.ctrl || !data.valid && !data.ctrl) return "continue";
3849
+ if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3697
3850
  validate.push(data);
3698
3851
  };
3699
3852
 
@@ -3705,39 +3858,56 @@
3705
3858
 
3706
3859
  if (!validate.length) return false;
3707
3860
  var flag = false;
3708
- validate.reverse().forEach(function (_ref) {
3709
- var valid = _ref.valid,
3710
- rule = _ref.rule,
3711
- prepend = _ref.prepend,
3712
- append = _ref.append,
3713
- child = _ref.child,
3714
- ctrl = _ref.ctrl;
3861
+ this.deferSyncValue(function () {
3862
+ validate.reverse().forEach(function (_ref) {
3863
+ var isHidden = _ref.isHidden,
3864
+ valid = _ref.valid,
3865
+ rule = _ref.rule,
3866
+ prepend = _ref.prepend,
3867
+ append = _ref.append,
3868
+ child = _ref.child,
3869
+ ctrl = _ref.ctrl;
3870
+
3871
+ if (isHidden) {
3872
+ valid ? ctx.ctrlRule.push({
3873
+ __ctrl: true,
3874
+ children: rule,
3875
+ valid: valid
3876
+ }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3877
+
3878
+ _this7.vm.$nextTick(function () {
3879
+ _this7.api.hidden(!valid, rule);
3880
+ });
3715
3881
 
3716
- if (valid) {
3717
- flag = true;
3718
- var ruleCon = {
3719
- type: 'fcFragment',
3720
- "native": true,
3721
- __ctrl: true,
3722
- children: rule
3723
- };
3724
- ctx.ctrlRule.push(ruleCon);
3725
-
3726
- _this7.bus.$once('load-start', function () {
3727
- // this.cycleLoad = true;
3728
- if (prepend) {
3729
- api.prepend(ruleCon, prepend, child);
3730
- } else if (append || child) {
3731
- api.append(ruleCon, append || ctx.id, child);
3732
- } else {
3733
- ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3734
- }
3735
- });
3736
- } else {
3737
- ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3738
- var ctrlCtx = byCtx(ctrl);
3739
- ctrlCtx && ctrlCtx.rm();
3740
- }
3882
+ return;
3883
+ }
3884
+
3885
+ if (valid) {
3886
+ flag = true;
3887
+ var ruleCon = {
3888
+ type: 'fcFragment',
3889
+ "native": true,
3890
+ __ctrl: true,
3891
+ children: rule
3892
+ };
3893
+ ctx.ctrlRule.push(ruleCon);
3894
+
3895
+ _this7.bus.$once('load-start', function () {
3896
+ // this.cycleLoad = true;
3897
+ if (prepend) {
3898
+ api.prepend(ruleCon, prepend, child);
3899
+ } else if (append || child) {
3900
+ api.append(ruleCon, append || ctx.id, child);
3901
+ } else {
3902
+ ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3903
+ }
3904
+ });
3905
+ } else {
3906
+ ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3907
+ var ctrlCtx = byCtx(ctrl);
3908
+ ctrlCtx && ctrlCtx.rm();
3909
+ }
3910
+ });
3741
3911
  });
3742
3912
  this.vm.$emit('control', ctx.origin, this.api);
3743
3913
  this.effect(ctx, 'control');
@@ -3773,6 +3943,7 @@
3773
3943
  this.refresh();
3774
3944
  this.bus.$off('next-tick', this.nextReload);
3775
3945
  this.bus.$once('next-tick', this.nextReload);
3946
+ this.vm.$emit('update', this.api);
3776
3947
  },
3777
3948
  //todo 组件生成全部通过 alias
3778
3949
  refresh: function refresh() {
@@ -3808,7 +3979,7 @@
3808
3979
  function useInput(Handler) {
3809
3980
  extend(Handler.prototype, {
3810
3981
  getValue: function getValue(ctx) {
3811
- if (!hasProperty(ctx, 'cacheValue')) {
3982
+ if (is.Undef(ctx.cacheValue)) {
3812
3983
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
3813
3984
  }
3814
3985
 
@@ -3834,18 +4005,19 @@
3834
4005
  }
3835
4006
  },
3836
4007
  setFormData: function setFormData(ctx, value) {
3837
- $set(this.formData, ctx.field, value);
4008
+ $set(this.formData, ctx.id, value);
3838
4009
  },
3839
4010
  getFormData: function getFormData(ctx) {
3840
- return this.formData[ctx.field];
4011
+ return this.formData[ctx.id];
3841
4012
  },
3842
4013
  validate: function validate() {
3843
4014
  var _this = this;
3844
4015
 
3845
4016
  toEmpty(this.vm.validate);
3846
- Object.keys(this.fieldCtx).forEach(function (id) {
3847
- var ctx = _this.fieldCtx[id];
3848
- _this.vm.validate[ctx.field] = toArray(ctx.rule.validate);
4017
+ this.fields().forEach(function (id) {
4018
+ _this.fieldCtx[id].forEach(function (ctx) {
4019
+ _this.vm.validate[ctx.id] = toArray(ctx.rule.validate);
4020
+ });
3849
4021
  });
3850
4022
  return this.vm.validate;
3851
4023
  },
@@ -3853,8 +4025,8 @@
3853
4025
  var _this2 = this;
3854
4026
 
3855
4027
  toEmpty(this.form);
3856
- Object.defineProperties(this.form, Object.keys(this.formData).reduce(function (initial, field) {
3857
- var ctx = _this2.getCtx(field);
4028
+ Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4029
+ var ctx = _this2.getFieldCtx(field);
3858
4030
 
3859
4031
  var handle = _this2.valueHandle(ctx);
3860
4032
 
@@ -3897,13 +4069,19 @@
3897
4069
  delete this.appendData[rule.field];
3898
4070
  },
3899
4071
  addSubForm: function addSubForm(ctx, subForm) {
3900
- this.subForm[ctx.field] = subForm;
4072
+ if (ctx.input) {
4073
+ this.subForm[ctx.id] = subForm;
4074
+ }
3901
4075
  },
3902
- deferSyncValue: function deferSyncValue(fn) {
4076
+ deferSyncValue: function deferSyncValue(fn, sync) {
3903
4077
  if (!this.deferSyncFn) {
3904
4078
  this.deferSyncFn = fn;
3905
4079
  }
3906
4080
 
4081
+ if (!this.deferSyncFn.sync) {
4082
+ this.deferSyncFn.sync = sync;
4083
+ }
4084
+
3907
4085
  invoke(fn);
3908
4086
 
3909
4087
  if (this.deferSyncFn === fn) {
@@ -3930,11 +4108,9 @@
3930
4108
  refreshUpdate: function refreshUpdate(ctx, val) {
3931
4109
  var _this4 = this;
3932
4110
 
3933
- var fn = ctx.rule.update;
3934
-
3935
- if (is.Function(fn)) {
4111
+ if (is.Function(ctx.rule.update)) {
3936
4112
  var state = invoke(function () {
3937
- return fn(val, ctx.origin, _this4.api);
4113
+ return ctx.rule.update(val, ctx.origin, _this4.api);
3938
4114
  });
3939
4115
  if (state === undefined) return;
3940
4116
  ctx.rule.hidden = state === true;
@@ -3948,6 +4124,7 @@
3948
4124
  if (this.refreshControl(ctx)) {
3949
4125
  this.$render.clearCacheAll();
3950
4126
  this.loadRule();
4127
+ this.vm.$emit('update', this.api);
3951
4128
  this.refresh();
3952
4129
  }
3953
4130
 
@@ -3970,7 +4147,7 @@
3970
4147
  });
3971
4148
  },
3972
4149
  fields: function fields() {
3973
- return Object.keys(this.formData);
4150
+ return Object.keys(this.fieldCtx);
3974
4151
  }
3975
4152
  });
3976
4153
  }
@@ -3981,49 +4158,6 @@
3981
4158
  });
3982
4159
  }
3983
4160
 
3984
- function useHelper(rules) {
3985
- if (!Array.isArray(rules) || rules.findField) return;
3986
- Object.defineProperties(rules, {
3987
- findField: enumerable(findField),
3988
- findName: enumerable(findName),
3989
- setValue: enumerable(setValue)
3990
- });
3991
- }
3992
-
3993
- function find(field, name, origin) {
3994
- if (!this.length) return;
3995
- var children = [];
3996
-
3997
- for (var i = 0; i < this.length; i++) {
3998
- if (!is.Object(this[i])) continue;
3999
- var rule = getRule(this[i]);
4000
- if (rule[name] === field) return origin ? rule : this[i];
4001
- if (is.trueArray(rule.children)) children = children.concat(rule.children);
4002
- is.trueArray(rule.control) && rule.control.forEach(function (r) {
4003
- children = children.concat(r.rule);
4004
- });
4005
- }
4006
-
4007
- return find.call(children, field, name, origin);
4008
- }
4009
-
4010
- function findField(field) {
4011
- return find.call(this, field, 'field');
4012
- }
4013
-
4014
- function findName(field) {
4015
- return find.call(this, field, 'name');
4016
- }
4017
-
4018
- function setValue(formData) {
4019
- var _this = this;
4020
-
4021
- Object.keys(formData).forEach(function (field) {
4022
- var rule = find.call(_this, field, 'field', true);
4023
- if (rule) rule.value = formData[field];
4024
- });
4025
- }
4026
-
4027
4161
  var BaseParser = {
4028
4162
  init: function init(ctx) {},
4029
4163
  toFormValue: function toFormValue(value, ctx) {
@@ -4036,13 +4170,46 @@
4036
4170
  render: function render(children, ctx) {
4037
4171
  return ctx.$render.defaultRender(ctx, children);
4038
4172
  },
4173
+ preview: function preview(children, ctx) {
4174
+ return ctx.$render.defaultRender(ctx, children);
4175
+ },
4039
4176
  mergeProp: function mergeProp(ctx) {}
4040
4177
  };
4041
4178
 
4042
4179
  function useContext(Handler) {
4043
4180
  extend(Handler.prototype, {
4044
4181
  getCtx: function getCtx(id) {
4045
- return this.fieldCtx[id] || this.nameCtx[id] || this.ctxs[id];
4182
+ return this.getFieldCtx(id) || this.getNameCtx(id)[0] || this.ctxs[id];
4183
+ },
4184
+ getCtxs: function getCtxs(id) {
4185
+ return this.fieldCtx[id] || this.nameCtx[id] || (this.ctxs[id] ? [this.ctxs[id]] : []);
4186
+ },
4187
+ setIdCtx: function setIdCtx(ctx, key, type) {
4188
+ var field = "".concat(type, "Ctx");
4189
+
4190
+ if (!this[field][key]) {
4191
+ this[field][key] = [ctx];
4192
+ } else {
4193
+ this[field][key].push(ctx);
4194
+ }
4195
+ },
4196
+ rmIdCtx: function rmIdCtx(ctx, key, type) {
4197
+ var field = "".concat(type, "Ctx");
4198
+ var lst = this[field][key];
4199
+ if (!lst) return false;
4200
+ var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4201
+
4202
+ if (!lst.length) {
4203
+ delete this[field][key];
4204
+ }
4205
+
4206
+ return flag;
4207
+ },
4208
+ getFieldCtx: function getFieldCtx(field) {
4209
+ return (this.fieldCtx[field] || [])[0];
4210
+ },
4211
+ getNameCtx: function getNameCtx(name) {
4212
+ return this.nameCtx[name] || [];
4046
4213
  },
4047
4214
  setCtx: function setCtx(ctx) {
4048
4215
  var id = ctx.id,
@@ -4050,9 +4217,9 @@
4050
4217
  name = ctx.name,
4051
4218
  rule = ctx.rule;
4052
4219
  this.ctxs[id] = ctx;
4053
- if (name) $set(this.nameCtx, name, ctx);
4220
+ name && this.setIdCtx(ctx, name, 'name');
4054
4221
  if (!ctx.input) return;
4055
- this.fieldCtx[field] = ctx;
4222
+ this.setIdCtx(ctx, field, 'field');
4056
4223
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4057
4224
 
4058
4225
  if (this.isMounted && !this.reloading) {
@@ -4095,6 +4262,15 @@
4095
4262
  return ctx.rule[key];
4096
4263
  }, function (n, o) {
4097
4264
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4265
+
4266
+ if (flag && ctx.parser.loadChildren === false) {
4267
+ _this.$render.clearCache(ctx);
4268
+
4269
+ _this.nextRefresh();
4270
+
4271
+ return;
4272
+ }
4273
+
4098
4274
  _this.watching = true; // if (key === 'hidden')
4099
4275
  // ctx.updateKey(true);
4100
4276
  // else
@@ -4102,9 +4278,7 @@
4102
4278
  if (key === 'link') {
4103
4279
  ctx.link();
4104
4280
  return;
4105
- } else if (['props', 'on', 'nativeOn'].indexOf(key) > -1) {
4106
- _this.parseFn(n || {});
4107
-
4281
+ } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4108
4282
  _this.parseInjectEvent(ctx.rule, n || {});
4109
4283
 
4110
4284
  if (key === 'props' && ctx.input) {
@@ -4125,6 +4299,8 @@
4125
4299
  }
4126
4300
 
4127
4301
  _flag && _this.loadChildren(n, ctx);
4302
+
4303
+ _this.vm.$emit('update', _this.api);
4128
4304
  });
4129
4305
  }
4130
4306
 
@@ -4151,6 +4327,7 @@
4151
4327
  if (ctx.deleted) return;
4152
4328
  var id = ctx.id,
4153
4329
  field = ctx.field,
4330
+ input = ctx.input,
4154
4331
  name = ctx.name;
4155
4332
 
4156
4333
  if (ctx.input) {
@@ -4161,40 +4338,29 @@
4161
4338
  }
4162
4339
 
4163
4340
  $del(this.ctxs, id);
4164
- $del(this.$render.renderList, id);
4341
+ $del(this.$render.tempList, id);
4165
4342
  $del(this.$render.orgChildren, id);
4343
+ $del(this.vm.ctxInject, id);
4344
+ $del(this.formData, id);
4345
+ $del(this.subForm, id);
4166
4346
  $del(ctx, 'cacheValue');
4167
- var f = this.fieldCtx[field];
4168
- var flag = false;
4169
-
4170
- if (field && (!f || f === ctx)) {
4171
- $del(this.formData, field);
4172
- $del(this.form, field);
4173
- $del(this.fieldCtx, field);
4174
- $del(this.subForm, field);
4175
- flag = true;
4176
- }
4177
-
4178
- if (name && this.nameCtx[name] === ctx) {
4179
- $del(this.nameCtx, name);
4180
- }
4181
-
4182
- if (!this.reloading) {
4183
- this.deferSyncValue(function () {
4184
- if (is.trueArray(ctx.rule.children)) {
4185
- ctx.rule.children.forEach(function (h) {
4186
- return h.__fc__ && _this3.rmCtx(h.__fc__);
4187
- });
4347
+ input && this.rmIdCtx(ctx, field, 'field');
4348
+ name && this.rmIdCtx(ctx, name, 'name');
4349
+ this.deferSyncValue(function () {
4350
+ if (!_this3.reloading) {
4351
+ if (ctx.parser.loadChildren !== false) {
4352
+ if (is.trueArray(ctx.rule.children)) {
4353
+ ctx.rule.children.forEach(function (h) {
4354
+ return h.__fc__ && _this3.rmCtx(h.__fc__);
4355
+ });
4356
+ }
4188
4357
  }
4189
4358
 
4190
- _this3.syncValue();
4191
- });
4192
-
4193
- if (ctx.root === this.rules) {
4194
- this.vm._renderRule();
4359
+ if (ctx.root === _this3.rules) {
4360
+ _this3.vm._renderRule();
4361
+ }
4195
4362
  }
4196
- }
4197
-
4363
+ }, input);
4198
4364
  var index = this.sort.indexOf(id);
4199
4365
 
4200
4366
  if (index > -1) {
@@ -4204,7 +4370,7 @@
4204
4370
  this.$render.clearCache(ctx);
4205
4371
  ctx["delete"]();
4206
4372
  this.effect(ctx, 'deleted');
4207
- flag && this.vm.$emit('removeField', field, ctx.rule, this.api);
4373
+ input && !this.fieldCtx[field] && this.vm.$emit('removeField', field, ctx.rule, this.api);
4208
4374
  ctx.rule.__ctrl || this.vm.$emit('removeRule', ctx.rule, this.api);
4209
4375
  return ctx;
4210
4376
  }
@@ -4409,14 +4575,12 @@
4409
4575
  extend(Handler.prototype, {
4410
4576
  initData: function initData(rules) {
4411
4577
  extend(this, {
4412
- fieldCtx: {},
4413
4578
  ctxs: {},
4579
+ fieldCtx: {},
4414
4580
  nameCtx: {},
4415
4581
  sort: [],
4416
- rules: rules,
4417
- repeatRule: []
4582
+ rules: rules
4418
4583
  });
4419
- useHelper(rules);
4420
4584
  },
4421
4585
  init: function init() {
4422
4586
  this.appendData = _objectSpread2(_objectSpread2(_objectSpread2({}, this.fc.options.formData || {}), this.vm.value || {}), this.appendData);
@@ -4513,8 +4677,9 @@
4513
4677
  var fragment = {
4514
4678
  name: NAME$9,
4515
4679
  functional: true,
4680
+ props: ['vnode'],
4516
4681
  render: function render(h, ctx) {
4517
- return ctx.children;
4682
+ return ctx.props.vnode ? ctx.props.vnode : ctx.children;
4518
4683
  }
4519
4684
  };
4520
4685
 
@@ -4846,6 +5011,10 @@
4846
5011
 
4847
5012
  function $form() {
4848
5013
  return _vue.extend($FormCreate(FormCreate));
5014
+ }
5015
+
5016
+ function $vnode() {
5017
+ return _vue.extend(fragment);
4849
5018
  } //todo 检查回调函数作用域
4850
5019
 
4851
5020
 
@@ -4871,6 +5040,7 @@
4871
5040
  function FormCreate(vm, rules, options) {
4872
5041
  extend(this, {
4873
5042
  vm: vm,
5043
+ create: create,
4874
5044
  manager: createManager(config.manager),
4875
5045
  parsers: parsers,
4876
5046
  providers: providers,
@@ -4966,6 +5136,7 @@
4966
5136
  },
4967
5137
  created: function created() {
4968
5138
  this.$handle.init();
5139
+ this.vm.$emit('created', this.api());
4969
5140
  },
4970
5141
  api: function api() {
4971
5142
  return this.$handle.api;
@@ -4987,6 +5158,7 @@
4987
5158
  component: component,
4988
5159
  directive: directive,
4989
5160
  register: register,
5161
+ $vnode: $vnode,
4990
5162
  parser: parser,
4991
5163
  use: use,
4992
5164
  factory: factory,
@@ -5040,6 +5212,7 @@
5040
5212
  useAttr($formCreate);
5041
5213
  Vue.prototype.$formCreate = $formCreate;
5042
5214
  Vue.component('FormCreate', $form());
5215
+ Vue.component('FcFragment', $vnode());
5043
5216
  }
5044
5217
  });
5045
5218
  }
@@ -5410,10 +5583,9 @@
5410
5583
  _col = _this$rule$props.col;
5411
5584
  var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
5412
5585
  props: _objectSpread2(_objectSpread2({
5413
- label: rule.title.title,
5414
5586
  labelWidth: labelWidth
5415
5587
  }, rule.wrap || {}), {}, {
5416
- prop: ctx.field,
5588
+ prop: ctx.id,
5417
5589
  rules: rule.validate
5418
5590
  }),
5419
5591
  "class": rule.className,
@@ -5424,38 +5596,17 @@
5424
5596
  return inline === true || isFalse(_col) || isFalse(col.show) ? item : this.makeCol(rule, uni, [item]);
5425
5597
  },
5426
5598
  isTitle: function isTitle(rule) {
5599
+ if (this.options.form.title === false) return false;
5427
5600
  var title = rule.title;
5428
5601
  return !(!title.title && !title["native"] || isFalse(title.show));
5429
5602
  },
5430
5603
  makeInfo: function makeInfo(rule, uni) {
5431
- var _this = this;
5432
5604
 
5433
5605
  var titleProp = rule.title;
5434
5606
  var infoProp = rule.info;
5435
5607
  var children = [titleProp.title];
5436
5608
 
5437
- var titleFn = function titleFn(pop) {
5438
- return _this.$r(mergeProps([titleProp, {
5439
- props: titleProp,
5440
- slot: titleProp.slot || (pop ? 'default' : 'label'),
5441
- key: "".concat(uni, "tit"),
5442
- type: titleProp.type || 'span'
5443
- }]), children);
5444
- };
5445
-
5446
- if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"])) {
5447
- if (infoProp.icon !== false) {
5448
- children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
5449
- type: 'icon',
5450
- props: {
5451
- type: infoProp.icon === true ? iviewConfig.infoIcon : infoProp.icon,
5452
- size: 16
5453
- },
5454
- style: 'margin-top: -1px',
5455
- key: "".concat(uni, "i")
5456
- }));
5457
- }
5458
-
5609
+ if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5459
5610
  var prop = {
5460
5611
  type: infoProp.type || 'poptip',
5461
5612
  props: _objectSpread2({}, infoProp),
@@ -5468,10 +5619,23 @@
5468
5619
  prop.props[field] = infoProp.info;
5469
5620
  }
5470
5621
 
5471
- return this.$r(mergeProps([infoProp, prop]), [titleFn(true)]);
5622
+ children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5623
+ type: 'icon',
5624
+ props: {
5625
+ type: infoProp.icon === true ? iviewConfig.infoIcon : infoProp.icon,
5626
+ size: 16
5627
+ },
5628
+ style: 'margin-top: -1px',
5629
+ key: "".concat(uni, "i")
5630
+ })]));
5472
5631
  }
5473
5632
 
5474
- return titleFn();
5633
+ return this.$r(mergeProps([titleProp, {
5634
+ props: titleProp,
5635
+ slot: titleProp.slot || 'label',
5636
+ key: "".concat(uni, "tit"),
5637
+ type: titleProp.type || 'span'
5638
+ }]), children);
5475
5639
  },
5476
5640
  makeCol: function makeCol(rule, uni, children) {
5477
5641
  var col = rule.col;
@@ -5661,7 +5825,7 @@
5661
5825
  useFrame(maker);
5662
5826
  useTimePicker(maker);
5663
5827
 
5664
- var css_248z$2 = ".form-create .form-create .ivu-form-item {\n margin-bottom: 24px;\n}\n\n.form-create .form-create .ivu-form-item .ivu-form-item {\n margin-bottom: 0px;\n}\n";
5828
+ var css_248z$2 = ".form-create .form-create .ivu-form-item {\n margin-bottom: 24px;\n}\n\n.form-create .form-create .ivu-form-item .ivu-form-item {\n margin-bottom: 0px;\n}\n\n.form-create{\n transform: rotateZ(0);\n}\n";
5665
5829
  styleInject(css_248z$2);
5666
5830
 
5667
5831
  function tidyBtnProp(btn, def) {
@@ -5723,13 +5887,14 @@
5723
5887
  }
5724
5888
  },
5725
5889
  validateField: function validateField(field, callback) {
5726
- if (!h.fieldCtx[field]) return;
5727
- var sub = h.subForm[field];
5890
+ var ctx = h.getFieldCtx(field);
5891
+ if (!ctx) return;
5892
+ var sub = h.subForm[ctx.id];
5728
5893
  var len = 0;
5729
5894
  var flag;
5730
5895
 
5731
5896
  var validate = function validate() {
5732
- h.$manager.validateField(field, function () {
5897
+ h.$manager.validateField(ctx.id, function () {
5733
5898
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
5734
5899
  args[_key3] = arguments[_key3];
5735
5900
  }
@@ -5779,23 +5944,25 @@
5779
5944
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5780
5945
  api.helper.tidyFields(fields).forEach(function (field) {
5781
5946
  if (clearSub) _this.clearSubValidateState(field);
5782
- var ctx = h.fieldCtx[field];
5783
- if (!ctx) return;
5784
- h.$manager.clearValidateState(ctx);
5947
+ h.getCtxs(field).forEach(function (ctx) {
5948
+ h.$manager.clearValidateState(ctx);
5949
+ });
5785
5950
  });
5786
5951
  },
5787
5952
  clearSubValidateState: function clearSubValidateState(fields) {
5788
5953
  api.helper.tidyFields(fields).forEach(function (field) {
5789
- var subForm = h.subForm[field];
5790
- if (!subForm) return;
5954
+ h.getCtxs(field).forEach(function (ctx) {
5955
+ var subForm = h.subForm[ctx.id];
5956
+ if (!subForm) return;
5791
5957
 
5792
- if (Array.isArray(subForm)) {
5793
- subForm.forEach(function (form) {
5794
- form.clearValidateState();
5795
- });
5796
- } else if (subForm) {
5797
- subForm.clearValidateState();
5798
- }
5958
+ if (Array.isArray(subForm)) {
5959
+ subForm.forEach(function (form) {
5960
+ form.clearValidateState();
5961
+ });
5962
+ } else if (subForm) {
5963
+ subForm.clearValidateState();
5964
+ }
5965
+ });
5799
5966
  });
5800
5967
  },
5801
5968
  btn: {
@@ -5898,7 +6065,7 @@
5898
6065
  function ivuFormCreate() {
5899
6066
  return FormCreateFactory({
5900
6067
  ui: "".concat("view-design"),
5901
- version: "".concat("2.5.9"),
6068
+ version: "".concat("2.5.13"),
5902
6069
  manager: manager,
5903
6070
  install: install,
5904
6071
  extendApi: extendApi,