@form-create/element-ui 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/element-ui v2.5.9
2
+ * @form-create/element-ui 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,
@@ -286,8 +278,12 @@
286
278
  };
287
279
  },
288
280
  methods: {
281
+ options: function options() {
282
+ var opt = this.formCreateInject.options;
283
+ return Array.isArray(opt) ? opt : [];
284
+ },
289
285
  onInput: function onInput(n) {
290
- this.$emit('input', this.formCreateOptions.filter(function (opt) {
286
+ this.$emit('input', this.options().filter(function (opt) {
291
287
  return n.indexOf(opt.label) !== -1;
292
288
  }).map(function (opt) {
293
289
  return opt.value;
@@ -298,7 +294,7 @@
298
294
  update: function update() {
299
295
  var _this = this;
300
296
 
301
- this.trueValue = this.value ? this.formCreateOptions.filter(function (opt) {
297
+ this.trueValue = this.value ? this.options().filter(function (opt) {
302
298
  return _this.value.indexOf(opt.value) !== -1;
303
299
  }).map(function (option) {
304
300
  return option.label;
@@ -312,14 +308,14 @@
312
308
  var _this2 = this;
313
309
 
314
310
  var h = arguments[0];
315
- return h("ElCheckboxGroup", helper([{}, this.formCreateRule, {
311
+ return h("ElCheckboxGroup", helper([{}, this.formCreateInject.prop, {
316
312
  "attrs": {
317
313
  "value": this.trueValue
318
314
  },
319
315
  "on": {
320
316
  "input": this.onInput
321
317
  }
322
- }]), [this.formCreateOptions.map(function (opt, index) {
318
+ }]), [this.options().map(function (opt, index) {
323
319
  var props = _objectSpread2({}, opt);
324
320
 
325
321
  var Type = _this2.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
@@ -372,7 +368,10 @@
372
368
  var Frame = {
373
369
  name: NAME$1,
374
370
  props: {
375
- formCreateField: String,
371
+ formCreateInject: {
372
+ type: Object,
373
+ required: true
374
+ },
376
375
  type: {
377
376
  type: String,
378
377
  "default": 'input'
@@ -584,7 +583,7 @@
584
583
  }, _toConsumableArray(children));
585
584
  },
586
585
  valid: function valid(f) {
587
- var field = this.formCreateField || this.field;
586
+ var field = this.formCreateInject.field || this.field;
588
587
 
589
588
  if (field && f !== field) {
590
589
  throw new Error('[frame]无效的字段值');
@@ -682,10 +681,6 @@
682
681
  })]);
683
682
  },
684
683
  handleClick: function handleClick(src) {
685
- if (this.disabled) {
686
- return;
687
- }
688
-
689
684
  return this.onHandle(src);
690
685
  },
691
686
  handleRemove: function handleRemove(src) {
@@ -856,17 +851,9 @@
856
851
  var Radio = {
857
852
  name: NAME$2,
858
853
  props: {
859
- formCreateRule: {
854
+ formCreateInject: {
860
855
  type: Object,
861
- "default": function _default() {
862
- return {};
863
- }
864
- },
865
- formCreateOptions: {
866
- type: Array,
867
- "default": function _default() {
868
- return [];
869
- }
856
+ required: true
870
857
  },
871
858
  value: {},
872
859
  type: String
@@ -882,8 +869,12 @@
882
869
  };
883
870
  },
884
871
  methods: {
872
+ options: function options() {
873
+ var opt = this.formCreateInject.options;
874
+ return Array.isArray(opt) ? opt : [];
875
+ },
885
876
  onInput: function onInput(n) {
886
- this.$emit('input', this.formCreateOptions.filter(function (opt) {
877
+ this.$emit('input', this.options().filter(function (opt) {
887
878
  return opt.label === n;
888
879
  }).reduce(function (initial, opt) {
889
880
  return opt.value;
@@ -892,7 +883,7 @@
892
883
  update: function update() {
893
884
  var _this = this;
894
885
 
895
- this.trueValue = this.formCreateOptions.filter(function (opt) {
886
+ this.trueValue = this.options().filter(function (opt) {
896
887
  return opt.value === _this.value;
897
888
  }).reduce(function (initial, opt) {
898
889
  return opt.label;
@@ -906,14 +897,14 @@
906
897
  var _this2 = this;
907
898
 
908
899
  var h = arguments[0];
909
- return h("ElRadioGroup", helper([{}, this.formCreateRule, {
900
+ return h("ElRadioGroup", helper([{}, this.formCreateInject.prop, {
910
901
  "attrs": {
911
902
  "value": this.trueValue
912
903
  },
913
904
  "on": {
914
905
  "input": this.onInput
915
906
  }
916
- }]), [this.formCreateOptions.map(function (opt, index) {
907
+ }]), [this.options().map(function (opt, index) {
917
908
  var props = _objectSpread2({}, opt);
918
909
 
919
910
  var Type = _this2.type === 'button' ? 'ElRadioButton' : 'ElRadio';
@@ -954,15 +945,14 @@
954
945
  name: NAME$3,
955
946
  functional: true,
956
947
  props: {
957
- formCreateOptions: {
958
- type: Array,
959
- "default": function _default() {
960
- return [];
961
- }
948
+ formCreateInject: {
949
+ type: Object,
950
+ required: true
962
951
  }
963
952
  },
964
953
  render: function render(h, ctx) {
965
- return h("ElSelect", helper([{}, ctx.data]), [ctx.props.formCreateOptions.map(function (props, index) {
954
+ var options = ctx.props.formCreateInject.options;
955
+ return h("ElSelect", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
966
956
  var slot = props.slot;
967
957
  return h("ElOption", {
968
958
  "props": _objectSpread2({}, props),
@@ -987,13 +977,9 @@
987
977
  }
988
978
  },
989
979
  props: {
990
- formCreateRule: {
980
+ formCreateInject: {
991
981
  type: Object,
992
- "default": function _default() {
993
- return {
994
- props: {}
995
- };
996
- }
982
+ required: true
997
983
  },
998
984
  type: {
999
985
  type: String,
@@ -1042,7 +1028,7 @@
1042
1028
  var _this = this;
1043
1029
 
1044
1030
  var h = arguments[0];
1045
- return h("ElTree", helper([{}, this.formCreateRule, {
1031
+ return h("ElTree", helper([{}, this.formCreateInject.prop, {
1046
1032
  "ref": "tree",
1047
1033
  "on": {
1048
1034
  "check": function check() {
@@ -1078,13 +1064,9 @@
1078
1064
  var Upload = {
1079
1065
  name: NAME$5,
1080
1066
  props: {
1081
- formCreateRule: {
1067
+ formCreateInject: {
1082
1068
  type: Object,
1083
- "default": function _default() {
1084
- return {
1085
- props: {}
1086
- };
1087
- }
1069
+ required: true
1088
1070
  },
1089
1071
  onHandle: {
1090
1072
  type: Function,
@@ -1123,11 +1105,11 @@
1123
1105
  };
1124
1106
  },
1125
1107
  created: function created() {
1126
- if (this.formCreateRule.props.showFileList === undefined) {
1127
- this.formCreateRule.props.showFileList = false;
1108
+ if (this.formCreateInject.prop.props.showFileList === undefined) {
1109
+ this.formCreateInject.prop.props.showFileList = false;
1128
1110
  }
1129
1111
 
1130
- this.formCreateRule.props.fileList = toArray(this.value).map(parseFile);
1112
+ this.formCreateInject.prop.props.fileList = toArray(this.value).map(parseFile);
1131
1113
  },
1132
1114
  watch: {
1133
1115
  value: function value(n) {
@@ -1149,7 +1131,7 @@
1149
1131
  return unique;
1150
1132
  },
1151
1133
  isDisabled: function isDisabled() {
1152
- return this.formCreateRule.props.disabled === true;
1134
+ return this.formCreateInject.prop.props.disabled === true;
1153
1135
  },
1154
1136
  onRemove: function onRemove(file) {
1155
1137
  if (this.isDisabled()) {
@@ -1159,10 +1141,6 @@
1159
1141
  this.$refs.upload.handleRemove(file);
1160
1142
  },
1161
1143
  handleClick: function handleClick(file) {
1162
- if (this.isDisabled()) {
1163
- return;
1164
- }
1165
-
1166
1144
  this.onHandle(file);
1167
1145
  },
1168
1146
  makeItem: function makeItem(file, index) {
@@ -1254,7 +1232,7 @@
1254
1232
  makeUpload: function makeUpload() {
1255
1233
  var h = this.$createElement;
1256
1234
  var isShow = !this.limit || this.limit > this.uploadList.length;
1257
- return h("ElUpload", helper([{}, this.formCreateRule, {
1235
+ return h("ElUpload", helper([{}, this.formCreateInject.prop, {
1258
1236
  "ref": "upload",
1259
1237
  "style": {
1260
1238
  display: 'inline-block'
@@ -1284,16 +1262,16 @@
1284
1262
  var h = arguments[0];
1285
1263
 
1286
1264
  if (this.$refs.upload) {
1287
- if (this.formCreateRule.props.showFileList === undefined) {
1288
- this.formCreateRule.props.showFileList = this.$refs.upload.showFileList;
1265
+ if (this.formCreateInject.prop.props.showFileList === undefined) {
1266
+ this.formCreateInject.prop.props.showFileList = this.$refs.upload.showFileList;
1289
1267
  }
1290
1268
 
1291
- this.formCreateRule.props.fileList = this.$refs.upload.fileList;
1269
+ this.formCreateInject.prop.props.fileList = this.$refs.upload.fileList;
1292
1270
  }
1293
1271
 
1294
1272
  return h("div", {
1295
1273
  "class": '_fc-upload'
1296
- }, [[this.formCreateRule.props.showFileList ? [] : this.makeFiles(), this.makeUpload()], h("el-dialog", {
1274
+ }, [[this.formCreateInject.prop.props.showFileList ? [] : this.makeFiles(), this.makeUpload()], h("el-dialog", {
1297
1275
  "attrs": {
1298
1276
  "appendToBody": true,
1299
1277
  "modal": this.previewMask,
@@ -1334,7 +1312,10 @@
1334
1312
  rules: Array,
1335
1313
  expand: Number,
1336
1314
  options: Object,
1337
- formCreate: Object,
1315
+ formCreateInject: {
1316
+ type: Object,
1317
+ required: true
1318
+ },
1338
1319
  button: {
1339
1320
  type: Boolean,
1340
1321
  "default": true
@@ -1378,7 +1359,8 @@
1378
1359
  return {
1379
1360
  len: 0,
1380
1361
  cacheRule: {},
1381
- cacheValue: {}
1362
+ cacheValue: {},
1363
+ type: undefined
1382
1364
  };
1383
1365
  },
1384
1366
  computed: {
@@ -1492,7 +1474,7 @@
1492
1474
  addRule: function addRule(i, emit) {
1493
1475
  var _this3 = this;
1494
1476
 
1495
- var rule = this.$formCreate.copyRules(this.formRule);
1477
+ var rule = this.formCreateInject.form.copyRules(this.formRule);
1496
1478
  var options = this.options ? _objectSpread2({}, this.options) : {
1497
1479
  submitBtn: false,
1498
1480
  resetBtn: false
@@ -1525,7 +1507,7 @@
1525
1507
  subForm: function subForm() {
1526
1508
  var _this5 = this;
1527
1509
 
1528
- this.$emit('fc.sub-form', Object.keys(this.cacheRule).map(function (k) {
1510
+ this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1529
1511
  return _this5.cacheRule[k].$f;
1530
1512
  }));
1531
1513
  },
@@ -1550,7 +1532,7 @@
1550
1532
  this.addRule(i, true);
1551
1533
  },
1552
1534
  del: function del(index, key) {
1553
- if (this.disabled || false === this.onBeforeRemove(this.value)) {
1535
+ if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
1554
1536
  return;
1555
1537
  }
1556
1538
 
@@ -1619,6 +1601,7 @@
1619
1601
  }
1620
1602
  },
1621
1603
  created: function created() {
1604
+ this.type = this.formCreateInject.form.$form();
1622
1605
  var d = (this.expand || 0) - this.value.length;
1623
1606
 
1624
1607
  if (d > 0) {
@@ -1635,6 +1618,7 @@
1635
1618
  var h = arguments[0];
1636
1619
  var keys = Object.keys(this.cacheRule);
1637
1620
  var button = this.button;
1621
+ var Type = this.type;
1638
1622
  return keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
1639
1623
  vm: this,
1640
1624
  add: this.add
@@ -1662,7 +1646,7 @@
1662
1646
  "attrs": {
1663
1647
  "span": button ? 20 : 24
1664
1648
  }
1665
- }, [h("ElFormItem", [h("FormCreate", helper([{
1649
+ }, [h("ElFormItem", [h(Type, helper([{
1666
1650
  "key": key
1667
1651
  }, {
1668
1652
  "on": {
@@ -1703,7 +1687,10 @@
1703
1687
  props: {
1704
1688
  rule: Array,
1705
1689
  options: Object,
1706
- formCreate: Object,
1690
+ formCreateInject: {
1691
+ type: Object,
1692
+ required: true
1693
+ },
1707
1694
  value: {
1708
1695
  type: Object,
1709
1696
  "default": function _default() {
@@ -1722,7 +1709,8 @@
1722
1709
  data: function data() {
1723
1710
  return {
1724
1711
  cacheRule: {},
1725
- cacheValue: {}
1712
+ cacheValue: {},
1713
+ type: undefined
1726
1714
  };
1727
1715
  },
1728
1716
  watch: {
@@ -1772,7 +1760,7 @@
1772
1760
  });
1773
1761
  },
1774
1762
  subForm: function subForm() {
1775
- this.$emit('fc.sub-form', this.cacheRule.$f);
1763
+ this.formCreateInject.subForm(this.cacheRule.$f);
1776
1764
  },
1777
1765
  emitEvent: function emitEvent(name) {
1778
1766
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -1784,13 +1772,15 @@
1784
1772
  },
1785
1773
  created: function created() {
1786
1774
  this.addRule();
1775
+ this.type = this.formCreateInject.form.$form();
1787
1776
  },
1788
1777
  render: function render() {
1789
1778
  var h = arguments[0];
1790
1779
  var _this$cacheRule = this.cacheRule,
1791
1780
  rule = _this$cacheRule.rule,
1792
1781
  options = _this$cacheRule.options;
1793
- return h("FormCreate", helper([{}, {
1782
+ var Type = this.type;
1783
+ return h(Type, helper([{}, {
1794
1784
  "on": {
1795
1785
  'update:value': this.formData,
1796
1786
  'emit-event': this.emitEvent,
@@ -1871,6 +1861,7 @@
1871
1861
  isShow: true,
1872
1862
  unique: 1,
1873
1863
  renderRule: _toConsumableArray(this.rule || []),
1864
+ ctxInject: {},
1874
1865
  updateValue: ''
1875
1866
  };
1876
1867
  },
@@ -1926,6 +1917,7 @@
1926
1917
  Object.keys(this.formCreate.prop).forEach(function (k) {
1927
1918
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1928
1919
  });
1920
+ this.$emit('beforeCreate', this.formCreate.api());
1929
1921
  }
1930
1922
  };
1931
1923
  }
@@ -2001,7 +1993,7 @@
2001
1993
 
2002
1994
  var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2003
1995
  var arrayAttrs = ['validate', 'children', 'control'];
2004
- var normalAttrs = ['effect'];
1996
+ var normalAttrs = ['effect', 'deep'];
2005
1997
  function attrs() {
2006
1998
  return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
2007
1999
  }
@@ -2034,6 +2026,12 @@
2034
2026
  }
2035
2027
 
2036
2028
  origin[key] = deepExtend(origin[key], clone, mode);
2029
+ } else if (is.Undef(clone)) {
2030
+ $set(origin, key, clone);
2031
+ } else if (clone.__json !== undefined) {
2032
+ $set(origin, key, clone.__json);
2033
+ } else if (clone.__origin !== undefined) {
2034
+ $set(origin, key, clone.__origin);
2037
2035
  } else {
2038
2036
  $set(origin, key, clone);
2039
2037
  }
@@ -2067,6 +2065,7 @@
2067
2065
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2068
2066
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2069
2067
  var $T = '$FN:';
2068
+ var $TX = '$FNX:';
2070
2069
  var FUNCTION = 'function';
2071
2070
  function toJson(obj, space) {
2072
2071
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
@@ -2076,7 +2075,7 @@
2076
2075
  return val;
2077
2076
  }
2078
2077
 
2079
- if (val.__json) {
2078
+ if (hasProperty(val, '__json')) {
2080
2079
  return val.__json;
2081
2080
  }
2082
2081
 
@@ -2091,28 +2090,32 @@
2091
2090
  }
2092
2091
 
2093
2092
  function parseFn(fn, mode) {
2094
- if (fn && is.String(fn)) {
2093
+ if (fn && is.String(fn) && fn.length > 4) {
2095
2094
  var v = fn.trim();
2096
2095
  var flag = false;
2097
2096
 
2098
- if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2099
- v = v.replace(SUFFIX, '').replace(PREFIX, '');
2100
- flag = true;
2101
- } else if (v.indexOf($T) === 0) {
2102
- v = v.replace($T, '');
2103
- flag = true;
2104
- } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2105
- flag = true;
2106
- }
2107
-
2108
- if (!flag) return fn;
2109
-
2110
2097
  try {
2098
+ if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2099
+ v = v.replace(SUFFIX, '').replace(PREFIX, '');
2100
+ flag = true;
2101
+ } else if (v.indexOf($T) === 0) {
2102
+ v = v.replace($T, '');
2103
+ flag = true;
2104
+ } else if (v.indexOf($TX) === 0) {
2105
+ v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2106
+ v.__json = fn;
2107
+ v.__inject = true;
2108
+ return v;
2109
+ } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2110
+ flag = true;
2111
+ }
2112
+
2113
+ if (!flag) return fn;
2111
2114
  var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2112
2115
  val.__json = fn;
2113
2116
  return val;
2114
2117
  } catch (e) {
2115
- err("\u89E3\u6790\u5931\u8D25:".concat(v));
2118
+ err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
2116
2119
  return undefined;
2117
2120
  }
2118
2121
  }
@@ -2203,7 +2206,7 @@
2203
2206
  to;
2204
2207
  (idx || '').split('.').forEach(function (v) {
2205
2208
  if (to) {
2206
- if (!_data[to]) {
2209
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2207
2210
  _data[to] = {};
2208
2211
  }
2209
2212
 
@@ -2301,13 +2304,6 @@
2301
2304
  return deepCopy(value);
2302
2305
  }
2303
2306
 
2304
- function byRules(ctxs, origin) {
2305
- return Object.keys(ctxs).reduce(function (initial, key) {
2306
- initial[key] = origin ? ctxs[key].origin : ctxs[key].rule;
2307
- return initial;
2308
- }, {});
2309
- }
2310
-
2311
2307
  function Api(h) {
2312
2308
  function tidyFields(fields) {
2313
2309
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
@@ -2316,10 +2312,10 @@
2316
2312
 
2317
2313
  function props(fields, key, val) {
2318
2314
  tidyFields(fields).forEach(function (field) {
2319
- var ctx = h.getCtx(field);
2320
- if (!ctx) return;
2321
- $set(ctx.rule, key, val);
2322
- h.$render.clearCache(ctx);
2315
+ h.getCtxs(field).forEach(function (ctx) {
2316
+ $set(ctx.rule, key, val);
2317
+ h.$render.clearCache(ctx);
2318
+ });
2323
2319
  });
2324
2320
  }
2325
2321
 
@@ -2334,11 +2330,6 @@
2334
2330
  }
2335
2331
 
2336
2332
  var api = {
2337
- helper: {
2338
- tidyFields: tidyFields,
2339
- props: props
2340
- },
2341
-
2342
2333
  get config() {
2343
2334
  return h.options;
2344
2335
  },
@@ -2365,23 +2356,26 @@
2365
2356
 
2366
2357
  formData: function formData(fields) {
2367
2358
  return tidyFields(fields).reduce(function (initial, id) {
2368
- var ctx = h.fieldCtx[id];
2359
+ var ctx = h.getFieldCtx(id);
2369
2360
  if (!ctx) return initial;
2370
2361
  initial[ctx.field] = copy(ctx.rule.value);
2371
2362
  return initial;
2372
2363
  }, copy(h.appendData));
2373
2364
  },
2374
2365
  getValue: function getValue(field) {
2375
- var ctx = h.fieldCtx[field];
2366
+ var ctx = h.getFieldCtx(field);
2376
2367
  if (!ctx) return;
2377
2368
  return copy(ctx.rule.value);
2378
2369
  },
2379
2370
  coverValue: function coverValue(formData) {
2380
2371
  h.deferSyncValue(function () {
2381
- Object.keys(h.fieldCtx).forEach(function (key) {
2382
- var ctx = h.fieldCtx[key];
2383
- if (!ctx) return h.appendData[key] = formData[key];
2384
- ctx.rule.value = hasProperty(formData, key) ? formData[key] : undefined;
2372
+ api.fields().forEach(function (key) {
2373
+ var ctxs = h.fieldCtx[key];
2374
+ if (!ctxs) return h.appendData[key] = formData[key];
2375
+ var flag = hasProperty(formData, key);
2376
+ ctxs.forEach(function (ctx) {
2377
+ ctx.rule.value = flag ? formData[key] : undefined;
2378
+ });
2385
2379
  });
2386
2380
  });
2387
2381
  },
@@ -2390,17 +2384,22 @@
2390
2384
  if (arguments.length >= 2) formData = _defineProperty({}, field, arguments[1]);
2391
2385
  h.deferSyncValue(function () {
2392
2386
  Object.keys(formData).forEach(function (key) {
2393
- var ctx = h.fieldCtx[key];
2394
- if (!ctx) return h.appendData[key] = formData[key];
2395
- ctx.rule.value = formData[key];
2387
+ var ctxs = h.fieldCtx[key];
2388
+ if (!ctxs) return h.appendData[key] = formData[key];
2389
+ ctxs.forEach(function (ctx) {
2390
+ ctx.rule.value = formData[key];
2391
+ });
2396
2392
  });
2397
2393
  });
2398
2394
  },
2399
2395
  removeField: function removeField(field) {
2400
2396
  var ctx = h.getCtx(field);
2401
- if (!ctx) return;
2402
- ctx.rm();
2403
- return ctx.origin;
2397
+ h.deferSyncValue(function () {
2398
+ h.getCtxs(field).forEach(function (ctx) {
2399
+ ctx.rm();
2400
+ });
2401
+ }, true);
2402
+ return ctx ? ctx.origin : undefined;
2404
2403
  },
2405
2404
  removeRule: function removeRule(rule) {
2406
2405
  var ctx = rule && byCtx(rule);
@@ -2416,10 +2415,8 @@
2416
2415
  return h.fields();
2417
2416
  },
2418
2417
  append: function append(rule, after, child) {
2419
- var fields = Object.keys(h.fieldCtx),
2420
- index = h.sort.length - 1,
2418
+ var index = h.sort.length - 1,
2421
2419
  rules;
2422
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2423
2420
  var ctx = h.getCtx(after);
2424
2421
 
2425
2422
  if (ctx) {
@@ -2435,10 +2432,8 @@
2435
2432
  rules.splice(index + 1, 0, rule);
2436
2433
  },
2437
2434
  prepend: function prepend(rule, after, child) {
2438
- var fields = Object.keys(h.fieldCtx),
2439
- index = 0,
2435
+ var index = 0,
2440
2436
  rules;
2441
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2442
2437
  var ctx = h.getCtx(after);
2443
2438
 
2444
2439
  if (ctx) {
@@ -2472,17 +2467,33 @@
2472
2467
  },
2473
2468
  disabled: function disabled(_disabled, fields) {
2474
2469
  tidyFields(fields).forEach(function (field) {
2475
- var ctx = h.fieldCtx[field];
2476
- if (!ctx) return;
2477
- $set(ctx.rule.props, 'disabled', !!_disabled);
2470
+ h.getCtxs(field).forEach(function (ctx) {
2471
+ $set(ctx.rule.props, 'disabled', !!_disabled);
2472
+ });
2478
2473
  });
2479
2474
  h.refresh();
2480
2475
  },
2476
+ all: function all(origin) {
2477
+ return Object.keys(h.ctxs).map(function (k) {
2478
+ var ctx = h.ctxs[k];
2479
+ return origin ? ctx.origin : ctx.rule;
2480
+ });
2481
+ },
2481
2482
  model: function model(origin) {
2482
- return byRules(h.fieldCtx, origin);
2483
+ return h.fields().reduce(function (initial, key) {
2484
+ var ctx = h.fieldCtx[key][0];
2485
+ initial[key] = origin ? ctx.origin : ctx.rule;
2486
+ return initial;
2487
+ }, {});
2483
2488
  },
2484
2489
  component: function component(origin) {
2485
- return byRules(h.nameCtx, origin);
2490
+ return Object.keys(h.nameCtx).reduce(function (initial, key) {
2491
+ var ctx = h.nameCtx[key].map(function (ctx) {
2492
+ return origin ? ctx.origin : ctx.rule;
2493
+ });
2494
+ initial[key] = ctx.length === 1 ? ctx[0] : ctx;
2495
+ return initial;
2496
+ }, {});
2486
2497
  },
2487
2498
  bind: function bind() {
2488
2499
  return api.form;
@@ -2500,25 +2511,39 @@
2500
2511
  });
2501
2512
  },
2502
2513
  sync: function sync(field) {
2503
- var ctx = is.Object(field) ? byCtx(field) : h.getCtx(field);
2514
+ if (Array.isArray(field)) {
2515
+ field.forEach(function (v) {
2516
+ return api.sync(v);
2517
+ });
2518
+ return;
2519
+ }
2504
2520
 
2505
- if (ctx && !ctx.deleted) {
2506
- var subForm = h.subForm[field];
2521
+ var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2507
2522
 
2508
- if (subForm) {
2509
- if (Array.isArray(subForm)) {
2510
- subForm.forEach(function (form) {
2511
- form.refresh();
2512
- });
2513
- } else if (subForm) {
2514
- subForm.refresh();
2515
- }
2516
- } //ctx.updateKey(true);
2523
+ if (!ctxs) {
2524
+ return;
2525
+ }
2517
2526
 
2527
+ ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2528
+ ctxs.forEach(function (ctx) {
2529
+ if (!ctx.deleted) {
2530
+ var subForm = h.subForm[ctx.id];
2518
2531
 
2519
- h.$render.clearCache(ctx);
2520
- h.refresh();
2521
- }
2532
+ if (subForm) {
2533
+ if (Array.isArray(subForm)) {
2534
+ subForm.forEach(function (form) {
2535
+ form.refresh();
2536
+ });
2537
+ } else if (subForm) {
2538
+ subForm.refresh();
2539
+ }
2540
+ } //ctx.updateKey(true);
2541
+
2542
+
2543
+ h.$render.clearCache(ctx);
2544
+ }
2545
+ });
2546
+ h.refresh();
2522
2547
  },
2523
2548
  refresh: function refresh() {
2524
2549
  allSubForm().forEach(function (sub) {
@@ -2541,8 +2566,9 @@
2541
2566
  h.changeStatus = false;
2542
2567
  },
2543
2568
  updateRule: function updateRule(id, rule) {
2544
- var r = api.getRule(id);
2545
- r && extend(r, rule);
2569
+ h.getCtxs(id).forEach(function (ctx) {
2570
+ extend(ctx.rule, rule);
2571
+ });
2546
2572
  },
2547
2573
  updateRules: function updateRules(rules) {
2548
2574
  Object.keys(rules).forEach(function (id) {
@@ -2550,8 +2576,9 @@
2550
2576
  });
2551
2577
  },
2552
2578
  mergeRule: function mergeRule$1(id, rule) {
2553
- var ctx = h.getCtx(id);
2554
- ctx && mergeRule(ctx.rule, rule);
2579
+ h.getCtxs(id).forEach(function (ctx) {
2580
+ mergeRule(ctx.rule, rule);
2581
+ });
2555
2582
  },
2556
2583
  mergeRules: function mergeRules(rules) {
2557
2584
  Object.keys(rules).forEach(function (id) {
@@ -2584,13 +2611,12 @@
2584
2611
  api.refresh();
2585
2612
  },
2586
2613
  resetFields: function resetFields(fields) {
2587
- var ctxs = h.fieldCtx;
2588
2614
  tidyFields(fields).forEach(function (field) {
2589
- var ctx = ctxs[field];
2590
- if (!ctx) return;
2591
- h.$render.clearCache(ctx);
2592
- ctx.rule.value = copy(ctx.defaultValue);
2593
- h.refreshControl(ctx);
2615
+ h.getCtxs(field).forEach(function (ctx) {
2616
+ h.$render.clearCache(ctx);
2617
+ ctx.rule.value = copy(ctx.defaultValue);
2618
+ h.refreshControl(ctx);
2619
+ });
2594
2620
  });
2595
2621
  },
2596
2622
  method: function method(id, name) {
@@ -2630,7 +2656,8 @@
2630
2656
  el && el.$emit && el.$emit('close-modal');
2631
2657
  },
2632
2658
  getSubForm: function getSubForm(field) {
2633
- return h.subForm[field];
2659
+ var ctx = h.getCtx(field);
2660
+ return ctx ? h.subForm[ctx.id] : undefined;
2634
2661
  },
2635
2662
  nextTick: function nextTick(fn) {
2636
2663
  h.bus.$once('next-tick', fn);
@@ -2639,13 +2666,26 @@
2639
2666
  nextRefresh: function nextRefresh(fn) {
2640
2667
  h.nextRefresh();
2641
2668
  fn && invoke(fn);
2669
+ },
2670
+ emit: function emit(name) {
2671
+ var _h$vm;
2672
+
2673
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2674
+ args[_key3 - 1] = arguments[_key3];
2675
+ }
2676
+
2677
+ (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2678
+ },
2679
+ helper: {
2680
+ tidyFields: tidyFields,
2681
+ props: props
2642
2682
  }
2643
2683
  };
2644
2684
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2645
2685
  api[n] = function () {
2646
- var _h$vm;
2686
+ var _h$vm2;
2647
2687
 
2648
- (_h$vm = h.vm)["$".concat(n)].apply(_h$vm, arguments);
2688
+ (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2649
2689
  };
2650
2690
  });
2651
2691
  api.changeValue = api.changeField = api.setValue;
@@ -2678,7 +2718,8 @@
2678
2718
  this.cache[ctx.id] = {
2679
2719
  vnode: vnode,
2680
2720
  use: false,
2681
- parent: parent
2721
+ parent: parent,
2722
+ slot: ctx.rule.slot
2682
2723
  };
2683
2724
  },
2684
2725
  getCache: function getCache(ctx) {
@@ -2699,46 +2740,20 @@
2699
2740
  return str.replace(str[0], str[0].toLowerCase());
2700
2741
  }
2701
2742
 
2702
- function setTempProps(vm, ctx, api) {
2703
- if (!vm.$props) return;
2704
- var prop = ctx.prop;
2705
- var keys = Object.keys(vm.$props);
2706
- var inject = injectProp(ctx, api);
2707
- var injectKeys = Object.keys(inject);
2708
- keys.forEach(function (key) {
2709
- if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2710
- });
2711
- var key = vm.$options.model && vm.$options.model.prop || 'value';
2712
-
2713
- if (keys.indexOf(key) > -1) {
2714
- vm.$props[key] = prop.value;
2715
- }
2716
- }
2717
-
2718
- function injectProp(ctx, api) {
2719
- return {
2720
- formCreate: api,
2721
- formCreateField: ctx.field,
2722
- formCreateOptions: ctx.prop.options,
2723
- formCreateRule: function () {
2724
- var temp = _objectSpread2({}, ctx.prop);
2725
-
2726
- return temp.on = temp.on ? _objectSpread2({}, temp.on) : {}, temp;
2727
- }()
2728
- };
2729
- }
2730
-
2731
2743
  function useRender(Render) {
2732
2744
  extend(Render.prototype, {
2733
2745
  initRender: function initRender() {
2734
- this.renderList = {};
2746
+ this.tempList = {};
2735
2747
  this.clearOrgChildren();
2736
2748
  },
2737
2749
  initOrgChildren: function initOrgChildren() {
2738
2750
  var ctxs = this.$handle.ctxs;
2739
2751
  this.orgChildren = Object.keys(ctxs).reduce(function (initial, id) {
2740
- var children = ctxs[id].rule.children;
2741
- initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2752
+ if (ctxs[id].parser.loadChildren !== false) {
2753
+ var children = ctxs[id].rule.children;
2754
+ initial[id] = is.trueArray(children) ? _toConsumableArray(children) : [];
2755
+ }
2756
+
2742
2757
  return initial;
2743
2758
  }, {});
2744
2759
  },
@@ -2754,19 +2769,47 @@
2754
2769
 
2755
2770
  this.$h = this.vm.$createElement;
2756
2771
  this.$manager.beforeRender();
2757
- var vn = this.sort.map(function (id) {
2758
- return _this.renderCtx(_this.$handle.ctxs[id]);
2772
+ var vn;
2773
+
2774
+ var make = function make() {
2775
+ return _this.renderList();
2776
+ };
2777
+
2778
+ make.renderSlot = function (slot) {
2779
+ return _this.renderList(slot);
2780
+ };
2781
+
2782
+ make.renderName = function (name) {
2783
+ return _this.renderId(name);
2784
+ };
2785
+
2786
+ make.renderField = function (field) {
2787
+ return _this.renderId(field, 'field');
2788
+ };
2789
+
2790
+ if (this.vm.$scopedSlots.container) {
2791
+ vn = [this.vm.$scopedSlots.container(make)];
2792
+ } else {
2793
+ vn = make();
2794
+ }
2795
+
2796
+ return this.$manager.render(vn);
2797
+ },
2798
+ renderList: function renderList(slot) {
2799
+ var _this2 = this;
2800
+
2801
+ return this.sort.map(function (id) {
2802
+ return slot ? _this2.renderSlot(_this2.$handle.ctxs[id], slot) : _this2.renderCtx(_this2.$handle.ctxs[id]);
2759
2803
  }).filter(function (val) {
2760
2804
  return val !== undefined;
2761
2805
  });
2762
- return this.$manager.render(vn);
2763
2806
  },
2764
2807
  makeVm: function makeVm(rule) {
2765
- var _this2 = this;
2808
+ var _this3 = this;
2766
2809
 
2767
2810
  var vm = rule.vm;
2768
2811
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2769
- return vm(_this2.$handle.getInjectData(rule));
2812
+ return rule.vm(_this3.$handle.getInjectData(rule));
2770
2813
  });else if (!vm._isVue) return new _vue(vm);
2771
2814
  return vm;
2772
2815
  },
@@ -2782,8 +2825,31 @@
2782
2825
  deepSet(ctx.prop, ctx.prop.optionsTo, ctx.prop.options);
2783
2826
  }
2784
2827
  },
2828
+ deepSet: function deepSet$1(ctx) {
2829
+ var deep = ctx.rule.deep;
2830
+ deep && Object.keys(deep).sort(function (a, b) {
2831
+ return a.length < b.length ? -1 : 1;
2832
+ }).forEach(function (str) {
2833
+ deepSet(ctx.prop, str, deep[str]);
2834
+ });
2835
+ },
2836
+ setTempProps: function setTempProps(vm, ctx) {
2837
+ if (!vm.$props) return;
2838
+ var prop = ctx.prop;
2839
+ var keys = Object.keys(vm.$props);
2840
+ var inject = this.injectProp(ctx);
2841
+ var injectKeys = Object.keys(inject);
2842
+ keys.forEach(function (key) {
2843
+ if (hasProperty(prop.props, key)) vm.$props[key] = prop.props[key];else if (injectKeys.indexOf(key) > -1) vm.$props[key] = inject[key];
2844
+ });
2845
+ var key = vm.$options.model && vm.$options.model.prop || 'value';
2846
+
2847
+ if (keys.indexOf(key) > -1) {
2848
+ vm.$props[key] = prop.value;
2849
+ }
2850
+ },
2785
2851
  renderTemp: function renderTemp(ctx) {
2786
- var _this3 = this;
2852
+ var _this4 = this;
2787
2853
 
2788
2854
  if (!_vue.compile) {
2789
2855
  tip('当前使用的Vue构建版本不支持compile,无法使用template功能');
@@ -2794,7 +2860,7 @@
2794
2860
  var id = ctx.id,
2795
2861
  key = ctx.key;
2796
2862
 
2797
- if (!this.renderList[id]) {
2863
+ if (!this.tempList[id]) {
2798
2864
  if (!ctx.el) {
2799
2865
  ctx.el = this.makeVm(rule);
2800
2866
  this.vm.$nextTick(function () {
@@ -2804,18 +2870,18 @@
2804
2870
 
2805
2871
  var _vm = ctx.el;
2806
2872
  if (ctx.input) _vm.$on(_vm.$options.model && _vm.$options.model.event || 'input', function (value) {
2807
- _this3.onInput(ctx, value);
2873
+ _this4.onInput(ctx, value);
2808
2874
  });
2809
- this.renderList[id] = {
2875
+ this.tempList[id] = {
2810
2876
  vm: _vm,
2811
2877
  template: _vue.compile(rule.template)
2812
2878
  };
2813
2879
  }
2814
2880
 
2815
- var _this$renderList$id = this.renderList[id],
2816
- vm = _this$renderList$id.vm,
2817
- template = _this$renderList$id.template;
2818
- setTempProps(vm, ctx, this.$handle.api);
2881
+ var _this$tempList$id = this.tempList[id],
2882
+ vm = _this$tempList$id.vm,
2883
+ template = _this$tempList$id.template;
2884
+ this.setTempProps(vm, ctx);
2819
2885
  var vn = template.render.call(vm);
2820
2886
  if (is.Undef(vn.data)) vn.data = {};
2821
2887
  vn.key = key;
@@ -2830,16 +2896,29 @@
2830
2896
  var prop = ctx[temp ? 'rule' : 'prop'];
2831
2897
  return [this.renderRule(this.parseSide(prop.prefix)), vn, this.renderRule(this.parseSide(prop.suffix))];
2832
2898
  },
2899
+ renderSlot: function renderSlot(ctx, slot) {
2900
+ return ctx.rule.slot === slot ? this.renderCtx(ctx) : undefined;
2901
+ },
2902
+ renderId: function renderId(name, type) {
2903
+ var _this5 = this;
2904
+
2905
+ var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2906
+ return ctxs ? ctxs.map(function (ctx) {
2907
+ return _this5.renderCtx(ctx, ctx.parent);
2908
+ }) : undefined;
2909
+ },
2833
2910
  renderCtx: function renderCtx(ctx, parent) {
2834
2911
  if (ctx.type === 'hidden') return;
2912
+ var rule = ctx.rule;
2913
+ var preview = this.options.preview || false;
2835
2914
 
2836
- if (!this.cache[ctx.id]) {
2915
+ if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2837
2916
  var vn;
2838
2917
  var cacheFlag = true;
2839
2918
  var _type = ctx.trueType;
2840
- var none = !(is.Undef(ctx.rule.display) || !!ctx.rule.display);
2919
+ var none = !(is.Undef(rule.display) || !!rule.display);
2841
2920
 
2842
- if (_type === 'template' && !ctx.rule.template) {
2921
+ if (_type === 'template' && !rule.template) {
2843
2922
  vn = this.renderSides(this.renderChildren(ctx), ctx, true);
2844
2923
 
2845
2924
  if (none) {
@@ -2853,9 +2932,11 @@
2853
2932
  ctx.initProp();
2854
2933
  this.mergeGlobal(ctx);
2855
2934
  this.$manager.tidyRule(ctx);
2935
+ this.deepSet(ctx);
2856
2936
  this.setOptions(ctx);
2857
2937
  this.ctxProp(ctx);
2858
2938
  var prop = ctx.prop;
2939
+ prop.props.formCreateInject = this.injectProp(ctx);
2859
2940
 
2860
2941
  if (prop.hidden) {
2861
2942
  this.setCache(ctx, undefined, parent);
@@ -2866,7 +2947,28 @@
2866
2947
  vn = this.renderTemp(ctx);
2867
2948
  cacheFlag = false;
2868
2949
  } else {
2869
- vn = ctx.parser.render(this.renderChildren(ctx), ctx);
2950
+ var children = [];
2951
+
2952
+ if (ctx.parser.renderChildren) {
2953
+ children = ctx.parser.renderChildren(ctx);
2954
+ } else if (ctx.parser.loadChildren !== false) {
2955
+ children = this.renderChildren(ctx);
2956
+ }
2957
+
2958
+ var slot = 'type-' + toLine(ctx.type);
2959
+
2960
+ if (this.vm.$scopedSlots[slot]) {
2961
+ vn = this.vm.$scopedSlots[slot]({
2962
+ rule: rule,
2963
+ prop: prop,
2964
+ preview: preview,
2965
+ children: children,
2966
+ api: this.$handle.api,
2967
+ model: prop.model || {}
2968
+ });
2969
+ } else {
2970
+ vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
2971
+ }
2870
2972
  }
2871
2973
 
2872
2974
  vn = this.renderSides(vn, ctx);
@@ -2892,13 +2994,13 @@
2892
2994
  return this.getCache(ctx);
2893
2995
  },
2894
2996
  display: function display(vn) {
2895
- var _this4 = this;
2997
+ var _this6 = this;
2896
2998
 
2897
2999
  if (Array.isArray(vn)) {
2898
3000
  var data = [];
2899
3001
  vn.forEach(function (v) {
2900
- if (Array.isArray(v)) return _this4.display(v);
2901
- if (_this4.none(v)) data.push(v);
3002
+ if (Array.isArray(v)) return _this6.display(v);
3003
+ if (_this6.none(v)) data.push(v);
2902
3004
  });
2903
3005
  return data;
2904
3006
  } else {
@@ -2926,8 +3028,38 @@
2926
3028
  key: ctx.key
2927
3029
  }, [vn]);
2928
3030
  },
3031
+ injectProp: function injectProp(ctx) {
3032
+ var _this7 = this;
3033
+
3034
+ if (!this.vm.ctxInject[ctx.id]) {
3035
+ $set(this.vm.ctxInject, ctx.id, {
3036
+ api: this.$handle.api,
3037
+ form: this.fc.create,
3038
+ subForm: function subForm(_subForm) {
3039
+ _this7.$handle.addSubForm(ctx, _subForm);
3040
+ },
3041
+ field: ctx.field,
3042
+ rule: ctx.rule
3043
+ });
3044
+ }
3045
+
3046
+ var inject = this.vm.ctxInject[ctx.id];
3047
+ extend(inject, {
3048
+ preview: this.options.preview || false,
3049
+ options: ctx.prop.options,
3050
+ children: ctx.rule.children,
3051
+ prop: function () {
3052
+ var temp = _objectSpread2({}, ctx.prop);
3053
+
3054
+ temp.on = temp.on ? _objectSpread2({}, temp.on) : {};
3055
+ delete temp.model;
3056
+ return temp;
3057
+ }()
3058
+ });
3059
+ return inject;
3060
+ },
2929
3061
  ctxProp: function ctxProp(ctx, custom) {
2930
- var _this5 = this;
3062
+ var _this8 = this;
2931
3063
 
2932
3064
  var ref = ctx.ref,
2933
3065
  key = ctx.key,
@@ -2935,29 +3067,28 @@
2935
3067
  this.$manager.mergeProp(ctx, custom);
2936
3068
  ctx.parser.mergeProp(ctx, custom);
2937
3069
  var props = [{
2938
- props: injectProp(ctx, this.$handle.api),
2939
3070
  ref: ref,
2940
3071
  key: rule.key || "".concat(key, "fc"),
2941
- slot: undefined
3072
+ slot: undefined,
3073
+ on: {
3074
+ 'hook:mounted': function hookMounted() {
3075
+ _this8.onMounted(ctx);
3076
+ },
3077
+ 'fc.sub-form': function fcSubForm(subForm) {
3078
+ _this8.$handle.addSubForm(ctx, subForm);
3079
+ }
3080
+ }
2942
3081
  }];
2943
3082
 
2944
- if (!custom) {
3083
+ if (!custom && ctx.input) {
2945
3084
  props.push({
2946
- on: {
2947
- 'hook:mounted': function hookMounted() {
2948
- _this5.onMounted(ctx);
2949
- },
2950
- 'fc.sub-form': function fcSubForm(subForm) {
2951
- _this5.$handle.addSubForm(ctx, subForm);
2952
- }
2953
- },
2954
- model: ctx.input ? {
3085
+ model: {
2955
3086
  value: this.$handle.getFormData(ctx),
2956
3087
  callback: function callback(value) {
2957
- _this5.onInput(ctx, value);
3088
+ _this8.onInput(ctx, value);
2958
3089
  },
2959
- expression: "formData.".concat(ctx.field)
2960
- } : undefined
3090
+ expression: "formData.".concat(ctx.id)
3091
+ }
2961
3092
  });
2962
3093
  }
2963
3094
 
@@ -2966,6 +3097,11 @@
2966
3097
  },
2967
3098
  onMounted: function onMounted(ctx) {
2968
3099
  ctx.el = this.vm.$refs[ctx.ref];
3100
+
3101
+ if (ctx.el) {
3102
+ (ctx.el.$el || ctx.el).__rule__ = ctx.rule;
3103
+ }
3104
+
2969
3105
  ctx.parser.mounted(ctx);
2970
3106
  this.$handle.effect(ctx, 'mounted');
2971
3107
  },
@@ -2973,13 +3109,13 @@
2973
3109
  this.$handle.onInput(ctx, value);
2974
3110
  },
2975
3111
  renderChildren: function renderChildren(ctx) {
2976
- var _this6 = this;
3112
+ var _this9 = this;
2977
3113
 
2978
3114
  var children = ctx.rule.children,
2979
3115
  orgChildren = this.orgChildren[ctx.id];
2980
3116
 
2981
3117
  var isRm = function isRm(child) {
2982
- return !is.String(child) && child.__fc__ && !_this6.$handle.ctxs[child.__fc__.id];
3118
+ return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
2983
3119
  };
2984
3120
 
2985
3121
  if (!is.trueArray(children) && orgChildren) {
@@ -2988,7 +3124,7 @@
2988
3124
  if (!child) return;
2989
3125
 
2990
3126
  if (isRm(child)) {
2991
- _this6.$handle.rmCtx(child.__fc__);
3127
+ _this9.$handle.rmCtx(child.__fc__);
2992
3128
  }
2993
3129
  });
2994
3130
  });
@@ -3001,7 +3137,7 @@
3001
3137
  if (!child) return;
3002
3138
 
3003
3139
  if (children.indexOf(child) === -1 && isRm(child)) {
3004
- _this6.$handle.rmCtx(child.__fc__);
3140
+ _this9.$handle.rmCtx(child.__fc__);
3005
3141
  }
3006
3142
  });
3007
3143
  });
@@ -3010,14 +3146,14 @@
3010
3146
  if (is.String(child)) return child;
3011
3147
 
3012
3148
  if (child.__fc__) {
3013
- return _this6.renderCtx(child.__fc__, ctx);
3149
+ return _this9.renderCtx(child.__fc__, ctx);
3014
3150
  }
3015
3151
 
3016
- if (!_this6.$handle.isRepeatRule(child.__origin__ || child) && child.type) {
3017
- _this6.vm.$nextTick(function () {
3018
- _this6.$handle.loadChildren(children, ctx);
3152
+ if (child.type) {
3153
+ _this9.vm.$nextTick(function () {
3154
+ _this9.$handle.loadChildren(children, ctx);
3019
3155
 
3020
- _this6.$handle.refresh();
3156
+ _this9.$handle.refresh();
3021
3157
  });
3022
3158
  }
3023
3159
  });
@@ -3029,7 +3165,7 @@
3029
3165
  return this.vNode.make(lower(ctx.originType), prop, children);
3030
3166
  },
3031
3167
  renderRule: function renderRule(rule, children, origin) {
3032
- var _this7 = this;
3168
+ var _this10 = this;
3033
3169
 
3034
3170
  if (!rule) return undefined;
3035
3171
  if (is.String(rule)) return rule;
@@ -3052,7 +3188,7 @@
3052
3188
 
3053
3189
  if (is.trueArray(rule.children)) {
3054
3190
  data.push(rule.children.map(function (v) {
3055
- return _this7.renderRule(v);
3191
+ return _this10.renderRule(v);
3056
3192
  }));
3057
3193
  }
3058
3194
 
@@ -3086,20 +3222,33 @@
3086
3222
  function useInject(Handler) {
3087
3223
  extend(Handler.prototype, {
3088
3224
  parseInjectEvent: function parseInjectEvent(rule, on) {
3089
- var _this = this;
3090
-
3091
- if (rule.inject === false) return;
3092
3225
  var inject = rule.inject || this.options.injectEvent;
3093
- if (is.Undef(inject)) return;
3094
- Object.keys(on).forEach(function (k) {
3095
- if (is.Function(on[k])) on[k] = _this.inject(rule, on[k], inject);
3096
- });
3097
- return on;
3226
+ return this.parseEventLst(rule, on, inject);
3098
3227
  },
3099
- parseFn: function parseFn$1(obj) {
3100
- obj && Object.keys(obj).forEach(function (n) {
3101
- obj[n] = parseFn(obj[n]);
3228
+ parseEventLst: function parseEventLst(rule, data, inject, deep) {
3229
+ var _this = this;
3230
+
3231
+ Object.keys(data).forEach(function (k) {
3232
+ var fn = _this.parseEvent(rule, data[k], inject, deep);
3233
+
3234
+ if (fn) {
3235
+ data[k] = fn;
3236
+ }
3102
3237
  });
3238
+ return data;
3239
+ },
3240
+ parseEvent: function parseEvent(rule, fn, inject, deep) {
3241
+ if (is.Function(fn) && (inject !== false && !is.Undef(inject) || fn.__inject)) {
3242
+ return this.inject(rule, fn, inject);
3243
+ } else if (!deep && Array.isArray(fn) && fn[0] && (is.String(fn[0]) || is.Function(fn[0]))) {
3244
+ return this.parseEventLst(rule, fn, inject, true);
3245
+ } else if (is.String(fn)) {
3246
+ var val = parseFn(fn);
3247
+
3248
+ if (val && fn !== val) {
3249
+ return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3250
+ }
3251
+ }
3103
3252
  },
3104
3253
  parseEmit: function parseEmit(ctx, on) {
3105
3254
  var _this2 = this;
@@ -3161,6 +3310,7 @@
3161
3310
  option = _this$vm$$options$pro.option,
3162
3311
  rule = _this$vm$$options$pro.rule;
3163
3312
  return {
3313
+ api: this.api,
3164
3314
  $f: this.api,
3165
3315
  rule: rule,
3166
3316
  self: self.__origin__,
@@ -3177,15 +3327,19 @@
3177
3327
  var h = this;
3178
3328
 
3179
3329
  var fn = function fn() {
3330
+ var data = h.getInjectData(self, _inject2);
3331
+
3180
3332
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3181
3333
  args[_key2] = arguments[_key2];
3182
3334
  }
3183
3335
 
3184
- args.unshift(h.getInjectData(self, _inject2));
3336
+ data.args = [].concat(args);
3337
+ args.unshift(data);
3185
3338
  return _fn.apply(this, args);
3186
3339
  };
3187
3340
 
3188
3341
  fn.__origin = _fn;
3342
+ fn.__json = _fn.__json;
3189
3343
  return fn;
3190
3344
  }
3191
3345
  });
@@ -3330,7 +3484,10 @@
3330
3484
  initProp: function initProp() {
3331
3485
  var _this = this;
3332
3486
 
3333
- this.prop = mergeProps([this.rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3487
+ var rule = _objectSpread2({}, this.rule);
3488
+
3489
+ delete rule.children;
3490
+ this.prop = mergeProps([rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
3334
3491
  return _this.payload[k];
3335
3492
  })), [this.computed]));
3336
3493
  },
@@ -3377,7 +3534,7 @@
3377
3534
  },
3378
3535
  rmCtrl: function rmCtrl() {
3379
3536
  this.ctrlRule.forEach(function (ctrl) {
3380
- return ctrl.__fc__.rm();
3537
+ return ctrl.__fc__ && ctrl.__fc__.rm();
3381
3538
  });
3382
3539
  this.ctrlRule = [];
3383
3540
  },
@@ -3411,7 +3568,7 @@
3411
3568
  extend(_this2, {
3412
3569
  root: []
3413
3570
  });
3414
- });
3571
+ }, _this2.input);
3415
3572
  });
3416
3573
  },
3417
3574
  update: function update(handle, init) {
@@ -3469,14 +3626,8 @@
3469
3626
  loadFn: function loadFn(item, rule) {
3470
3627
  var _this3 = this;
3471
3628
 
3472
- ['on', 'props', 'nativeOn'].forEach(function (k) {
3473
- var v = item[k];
3474
-
3475
- if (v) {
3476
- _this3.parseFn(v);
3477
-
3478
- _this3.parseInjectEvent(rule, v);
3479
- }
3629
+ ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3630
+ item[k] && _this3.parseInjectEvent(rule, item[k]);
3480
3631
  });
3481
3632
  },
3482
3633
  loadCtrl: function loadCtrl(rule) {
@@ -3502,9 +3653,6 @@
3502
3653
  }, {})
3503
3654
  }], ctx.computed);
3504
3655
  },
3505
- isRepeatRule: function isRepeatRule(rule) {
3506
- return this.repeatRule.indexOf(rule) > -1;
3507
- },
3508
3656
  loadRule: function loadRule() {
3509
3657
  var _this5 = this;
3510
3658
 
@@ -3588,7 +3736,7 @@
3588
3736
  var rule = getRule(_rule);
3589
3737
 
3590
3738
  var isRepeat = function isRepeat() {
3591
- return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field] !== _rule.__fc__);
3739
+ return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3592
3740
  };
3593
3741
 
3594
3742
  _this6.ruleEffect(rule, 'init', {
@@ -3596,11 +3744,7 @@
3596
3744
  });
3597
3745
 
3598
3746
  if (isRepeat()) {
3599
- _this6.repeatRule.push(_rule);
3600
-
3601
- _this6.vm.$emit('repeat', _rule, _this6.api);
3602
-
3603
- return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), _rule);
3747
+ _this6.vm.$emit('repeat-field', _rule, _this6.api);
3604
3748
  }
3605
3749
 
3606
3750
  var ctx;
@@ -3658,7 +3802,7 @@
3658
3802
  _this6.setCtx(ctx);
3659
3803
 
3660
3804
  !isCopy && !isInit && _this6.effect(ctx, 'load');
3661
- loadChildren(ctx.rule.children, ctx);
3805
+ ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
3662
3806
 
3663
3807
  if (!parent) {
3664
3808
  var _preIndex = preIndex(index);
@@ -3706,14 +3850,17 @@
3706
3850
  return val === control.value;
3707
3851
  };
3708
3852
 
3853
+ if (!is.trueArray(control.rule)) return "continue";
3854
+
3709
3855
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3710
3856
  valid: invoke(function () {
3711
3857
  return handleFn(ctx.rule.value, api);
3712
3858
  }),
3713
- ctrl: findCtrl(ctx, control.rule)
3859
+ ctrl: findCtrl(ctx, control.rule),
3860
+ isHidden: is.String(control.rule[0])
3714
3861
  });
3715
3862
 
3716
- if (data.valid && data.ctrl || !data.valid && !data.ctrl) return "continue";
3863
+ if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3717
3864
  validate.push(data);
3718
3865
  };
3719
3866
 
@@ -3725,39 +3872,56 @@
3725
3872
 
3726
3873
  if (!validate.length) return false;
3727
3874
  var flag = false;
3728
- validate.reverse().forEach(function (_ref) {
3729
- var valid = _ref.valid,
3730
- rule = _ref.rule,
3731
- prepend = _ref.prepend,
3732
- append = _ref.append,
3733
- child = _ref.child,
3734
- ctrl = _ref.ctrl;
3875
+ this.deferSyncValue(function () {
3876
+ validate.reverse().forEach(function (_ref) {
3877
+ var isHidden = _ref.isHidden,
3878
+ valid = _ref.valid,
3879
+ rule = _ref.rule,
3880
+ prepend = _ref.prepend,
3881
+ append = _ref.append,
3882
+ child = _ref.child,
3883
+ ctrl = _ref.ctrl;
3884
+
3885
+ if (isHidden) {
3886
+ valid ? ctx.ctrlRule.push({
3887
+ __ctrl: true,
3888
+ children: rule,
3889
+ valid: valid
3890
+ }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3891
+
3892
+ _this7.vm.$nextTick(function () {
3893
+ _this7.api.hidden(!valid, rule);
3894
+ });
3735
3895
 
3736
- if (valid) {
3737
- flag = true;
3738
- var ruleCon = {
3739
- type: 'fcFragment',
3740
- "native": true,
3741
- __ctrl: true,
3742
- children: rule
3743
- };
3744
- ctx.ctrlRule.push(ruleCon);
3745
-
3746
- _this7.bus.$once('load-start', function () {
3747
- // this.cycleLoad = true;
3748
- if (prepend) {
3749
- api.prepend(ruleCon, prepend, child);
3750
- } else if (append || child) {
3751
- api.append(ruleCon, append || ctx.id, child);
3752
- } else {
3753
- ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3754
- }
3755
- });
3756
- } else {
3757
- ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3758
- var ctrlCtx = byCtx(ctrl);
3759
- ctrlCtx && ctrlCtx.rm();
3760
- }
3896
+ return;
3897
+ }
3898
+
3899
+ if (valid) {
3900
+ flag = true;
3901
+ var ruleCon = {
3902
+ type: 'fcFragment',
3903
+ "native": true,
3904
+ __ctrl: true,
3905
+ children: rule
3906
+ };
3907
+ ctx.ctrlRule.push(ruleCon);
3908
+
3909
+ _this7.bus.$once('load-start', function () {
3910
+ // this.cycleLoad = true;
3911
+ if (prepend) {
3912
+ api.prepend(ruleCon, prepend, child);
3913
+ } else if (append || child) {
3914
+ api.append(ruleCon, append || ctx.id, child);
3915
+ } else {
3916
+ ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3917
+ }
3918
+ });
3919
+ } else {
3920
+ ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3921
+ var ctrlCtx = byCtx(ctrl);
3922
+ ctrlCtx && ctrlCtx.rm();
3923
+ }
3924
+ });
3761
3925
  });
3762
3926
  this.vm.$emit('control', ctx.origin, this.api);
3763
3927
  this.effect(ctx, 'control');
@@ -3793,6 +3957,7 @@
3793
3957
  this.refresh();
3794
3958
  this.bus.$off('next-tick', this.nextReload);
3795
3959
  this.bus.$once('next-tick', this.nextReload);
3960
+ this.vm.$emit('update', this.api);
3796
3961
  },
3797
3962
  //todo 组件生成全部通过 alias
3798
3963
  refresh: function refresh() {
@@ -3828,7 +3993,7 @@
3828
3993
  function useInput(Handler) {
3829
3994
  extend(Handler.prototype, {
3830
3995
  getValue: function getValue(ctx) {
3831
- if (!hasProperty(ctx, 'cacheValue')) {
3996
+ if (is.Undef(ctx.cacheValue)) {
3832
3997
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
3833
3998
  }
3834
3999
 
@@ -3854,18 +4019,19 @@
3854
4019
  }
3855
4020
  },
3856
4021
  setFormData: function setFormData(ctx, value) {
3857
- $set(this.formData, ctx.field, value);
4022
+ $set(this.formData, ctx.id, value);
3858
4023
  },
3859
4024
  getFormData: function getFormData(ctx) {
3860
- return this.formData[ctx.field];
4025
+ return this.formData[ctx.id];
3861
4026
  },
3862
4027
  validate: function validate() {
3863
4028
  var _this = this;
3864
4029
 
3865
4030
  toEmpty(this.vm.validate);
3866
- Object.keys(this.fieldCtx).forEach(function (id) {
3867
- var ctx = _this.fieldCtx[id];
3868
- _this.vm.validate[ctx.field] = toArray(ctx.rule.validate);
4031
+ this.fields().forEach(function (id) {
4032
+ _this.fieldCtx[id].forEach(function (ctx) {
4033
+ _this.vm.validate[ctx.id] = toArray(ctx.rule.validate);
4034
+ });
3869
4035
  });
3870
4036
  return this.vm.validate;
3871
4037
  },
@@ -3873,8 +4039,8 @@
3873
4039
  var _this2 = this;
3874
4040
 
3875
4041
  toEmpty(this.form);
3876
- Object.defineProperties(this.form, Object.keys(this.formData).reduce(function (initial, field) {
3877
- var ctx = _this2.getCtx(field);
4042
+ Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
4043
+ var ctx = _this2.getFieldCtx(field);
3878
4044
 
3879
4045
  var handle = _this2.valueHandle(ctx);
3880
4046
 
@@ -3917,13 +4083,19 @@
3917
4083
  delete this.appendData[rule.field];
3918
4084
  },
3919
4085
  addSubForm: function addSubForm(ctx, subForm) {
3920
- this.subForm[ctx.field] = subForm;
4086
+ if (ctx.input) {
4087
+ this.subForm[ctx.id] = subForm;
4088
+ }
3921
4089
  },
3922
- deferSyncValue: function deferSyncValue(fn) {
4090
+ deferSyncValue: function deferSyncValue(fn, sync) {
3923
4091
  if (!this.deferSyncFn) {
3924
4092
  this.deferSyncFn = fn;
3925
4093
  }
3926
4094
 
4095
+ if (!this.deferSyncFn.sync) {
4096
+ this.deferSyncFn.sync = sync;
4097
+ }
4098
+
3927
4099
  invoke(fn);
3928
4100
 
3929
4101
  if (this.deferSyncFn === fn) {
@@ -3950,11 +4122,9 @@
3950
4122
  refreshUpdate: function refreshUpdate(ctx, val) {
3951
4123
  var _this4 = this;
3952
4124
 
3953
- var fn = ctx.rule.update;
3954
-
3955
- if (is.Function(fn)) {
4125
+ if (is.Function(ctx.rule.update)) {
3956
4126
  var state = invoke(function () {
3957
- return fn(val, ctx.origin, _this4.api);
4127
+ return ctx.rule.update(val, ctx.origin, _this4.api);
3958
4128
  });
3959
4129
  if (state === undefined) return;
3960
4130
  ctx.rule.hidden = state === true;
@@ -3968,6 +4138,7 @@
3968
4138
  if (this.refreshControl(ctx)) {
3969
4139
  this.$render.clearCacheAll();
3970
4140
  this.loadRule();
4141
+ this.vm.$emit('update', this.api);
3971
4142
  this.refresh();
3972
4143
  }
3973
4144
 
@@ -3990,7 +4161,7 @@
3990
4161
  });
3991
4162
  },
3992
4163
  fields: function fields() {
3993
- return Object.keys(this.formData);
4164
+ return Object.keys(this.fieldCtx);
3994
4165
  }
3995
4166
  });
3996
4167
  }
@@ -4001,49 +4172,6 @@
4001
4172
  });
4002
4173
  }
4003
4174
 
4004
- function useHelper(rules) {
4005
- if (!Array.isArray(rules) || rules.findField) return;
4006
- Object.defineProperties(rules, {
4007
- findField: enumerable(findField),
4008
- findName: enumerable(findName),
4009
- setValue: enumerable(setValue)
4010
- });
4011
- }
4012
-
4013
- function find(field, name, origin) {
4014
- if (!this.length) return;
4015
- var children = [];
4016
-
4017
- for (var i = 0; i < this.length; i++) {
4018
- if (!is.Object(this[i])) continue;
4019
- var rule = getRule(this[i]);
4020
- if (rule[name] === field) return origin ? rule : this[i];
4021
- if (is.trueArray(rule.children)) children = children.concat(rule.children);
4022
- is.trueArray(rule.control) && rule.control.forEach(function (r) {
4023
- children = children.concat(r.rule);
4024
- });
4025
- }
4026
-
4027
- return find.call(children, field, name, origin);
4028
- }
4029
-
4030
- function findField(field) {
4031
- return find.call(this, field, 'field');
4032
- }
4033
-
4034
- function findName(field) {
4035
- return find.call(this, field, 'name');
4036
- }
4037
-
4038
- function setValue(formData) {
4039
- var _this = this;
4040
-
4041
- Object.keys(formData).forEach(function (field) {
4042
- var rule = find.call(_this, field, 'field', true);
4043
- if (rule) rule.value = formData[field];
4044
- });
4045
- }
4046
-
4047
4175
  var BaseParser = {
4048
4176
  init: function init(ctx) {},
4049
4177
  toFormValue: function toFormValue(value, ctx) {
@@ -4056,13 +4184,46 @@
4056
4184
  render: function render(children, ctx) {
4057
4185
  return ctx.$render.defaultRender(ctx, children);
4058
4186
  },
4187
+ preview: function preview(children, ctx) {
4188
+ return ctx.$render.defaultRender(ctx, children);
4189
+ },
4059
4190
  mergeProp: function mergeProp(ctx) {}
4060
4191
  };
4061
4192
 
4062
4193
  function useContext(Handler) {
4063
4194
  extend(Handler.prototype, {
4064
4195
  getCtx: function getCtx(id) {
4065
- return this.fieldCtx[id] || this.nameCtx[id] || this.ctxs[id];
4196
+ return this.getFieldCtx(id) || this.getNameCtx(id)[0] || this.ctxs[id];
4197
+ },
4198
+ getCtxs: function getCtxs(id) {
4199
+ return this.fieldCtx[id] || this.nameCtx[id] || (this.ctxs[id] ? [this.ctxs[id]] : []);
4200
+ },
4201
+ setIdCtx: function setIdCtx(ctx, key, type) {
4202
+ var field = "".concat(type, "Ctx");
4203
+
4204
+ if (!this[field][key]) {
4205
+ this[field][key] = [ctx];
4206
+ } else {
4207
+ this[field][key].push(ctx);
4208
+ }
4209
+ },
4210
+ rmIdCtx: function rmIdCtx(ctx, key, type) {
4211
+ var field = "".concat(type, "Ctx");
4212
+ var lst = this[field][key];
4213
+ if (!lst) return false;
4214
+ var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4215
+
4216
+ if (!lst.length) {
4217
+ delete this[field][key];
4218
+ }
4219
+
4220
+ return flag;
4221
+ },
4222
+ getFieldCtx: function getFieldCtx(field) {
4223
+ return (this.fieldCtx[field] || [])[0];
4224
+ },
4225
+ getNameCtx: function getNameCtx(name) {
4226
+ return this.nameCtx[name] || [];
4066
4227
  },
4067
4228
  setCtx: function setCtx(ctx) {
4068
4229
  var id = ctx.id,
@@ -4070,9 +4231,9 @@
4070
4231
  name = ctx.name,
4071
4232
  rule = ctx.rule;
4072
4233
  this.ctxs[id] = ctx;
4073
- if (name) $set(this.nameCtx, name, ctx);
4234
+ name && this.setIdCtx(ctx, name, 'name');
4074
4235
  if (!ctx.input) return;
4075
- this.fieldCtx[field] = ctx;
4236
+ this.setIdCtx(ctx, field, 'field');
4076
4237
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4077
4238
 
4078
4239
  if (this.isMounted && !this.reloading) {
@@ -4115,6 +4276,15 @@
4115
4276
  return ctx.rule[key];
4116
4277
  }, function (n, o) {
4117
4278
  if (_this.loading || _this.noWatchFn || _this.reloading) return;
4279
+
4280
+ if (flag && ctx.parser.loadChildren === false) {
4281
+ _this.$render.clearCache(ctx);
4282
+
4283
+ _this.nextRefresh();
4284
+
4285
+ return;
4286
+ }
4287
+
4118
4288
  _this.watching = true; // if (key === 'hidden')
4119
4289
  // ctx.updateKey(true);
4120
4290
  // else
@@ -4122,9 +4292,7 @@
4122
4292
  if (key === 'link') {
4123
4293
  ctx.link();
4124
4294
  return;
4125
- } else if (['props', 'on', 'nativeOn'].indexOf(key) > -1) {
4126
- _this.parseFn(n || {});
4127
-
4295
+ } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4128
4296
  _this.parseInjectEvent(ctx.rule, n || {});
4129
4297
 
4130
4298
  if (key === 'props' && ctx.input) {
@@ -4145,6 +4313,8 @@
4145
4313
  }
4146
4314
 
4147
4315
  _flag && _this.loadChildren(n, ctx);
4316
+
4317
+ _this.vm.$emit('update', _this.api);
4148
4318
  });
4149
4319
  }
4150
4320
 
@@ -4171,6 +4341,7 @@
4171
4341
  if (ctx.deleted) return;
4172
4342
  var id = ctx.id,
4173
4343
  field = ctx.field,
4344
+ input = ctx.input,
4174
4345
  name = ctx.name;
4175
4346
 
4176
4347
  if (ctx.input) {
@@ -4181,40 +4352,29 @@
4181
4352
  }
4182
4353
 
4183
4354
  $del(this.ctxs, id);
4184
- $del(this.$render.renderList, id);
4355
+ $del(this.$render.tempList, id);
4185
4356
  $del(this.$render.orgChildren, id);
4357
+ $del(this.vm.ctxInject, id);
4358
+ $del(this.formData, id);
4359
+ $del(this.subForm, id);
4186
4360
  $del(ctx, 'cacheValue');
4187
- var f = this.fieldCtx[field];
4188
- var flag = false;
4189
-
4190
- if (field && (!f || f === ctx)) {
4191
- $del(this.formData, field);
4192
- $del(this.form, field);
4193
- $del(this.fieldCtx, field);
4194
- $del(this.subForm, field);
4195
- flag = true;
4196
- }
4197
-
4198
- if (name && this.nameCtx[name] === ctx) {
4199
- $del(this.nameCtx, name);
4200
- }
4201
-
4202
- if (!this.reloading) {
4203
- this.deferSyncValue(function () {
4204
- if (is.trueArray(ctx.rule.children)) {
4205
- ctx.rule.children.forEach(function (h) {
4206
- return h.__fc__ && _this3.rmCtx(h.__fc__);
4207
- });
4361
+ input && this.rmIdCtx(ctx, field, 'field');
4362
+ name && this.rmIdCtx(ctx, name, 'name');
4363
+ this.deferSyncValue(function () {
4364
+ if (!_this3.reloading) {
4365
+ if (ctx.parser.loadChildren !== false) {
4366
+ if (is.trueArray(ctx.rule.children)) {
4367
+ ctx.rule.children.forEach(function (h) {
4368
+ return h.__fc__ && _this3.rmCtx(h.__fc__);
4369
+ });
4370
+ }
4208
4371
  }
4209
4372
 
4210
- _this3.syncValue();
4211
- });
4212
-
4213
- if (ctx.root === this.rules) {
4214
- this.vm._renderRule();
4373
+ if (ctx.root === _this3.rules) {
4374
+ _this3.vm._renderRule();
4375
+ }
4215
4376
  }
4216
- }
4217
-
4377
+ }, input);
4218
4378
  var index = this.sort.indexOf(id);
4219
4379
 
4220
4380
  if (index > -1) {
@@ -4224,7 +4384,7 @@
4224
4384
  this.$render.clearCache(ctx);
4225
4385
  ctx["delete"]();
4226
4386
  this.effect(ctx, 'deleted');
4227
- flag && this.vm.$emit('removeField', field, ctx.rule, this.api);
4387
+ input && !this.fieldCtx[field] && this.vm.$emit('removeField', field, ctx.rule, this.api);
4228
4388
  ctx.rule.__ctrl || this.vm.$emit('removeRule', ctx.rule, this.api);
4229
4389
  return ctx;
4230
4390
  }
@@ -4429,14 +4589,12 @@
4429
4589
  extend(Handler.prototype, {
4430
4590
  initData: function initData(rules) {
4431
4591
  extend(this, {
4432
- fieldCtx: {},
4433
4592
  ctxs: {},
4593
+ fieldCtx: {},
4434
4594
  nameCtx: {},
4435
4595
  sort: [],
4436
- rules: rules,
4437
- repeatRule: []
4596
+ rules: rules
4438
4597
  });
4439
- useHelper(rules);
4440
4598
  },
4441
4599
  init: function init() {
4442
4600
  this.appendData = _objectSpread2(_objectSpread2(_objectSpread2({}, this.fc.options.formData || {}), this.vm.value || {}), this.appendData);
@@ -4533,8 +4691,9 @@
4533
4691
  var fragment = {
4534
4692
  name: NAME$9,
4535
4693
  functional: true,
4694
+ props: ['vnode'],
4536
4695
  render: function render(h, ctx) {
4537
- return ctx.children;
4696
+ return ctx.props.vnode ? ctx.props.vnode : ctx.children;
4538
4697
  }
4539
4698
  };
4540
4699
 
@@ -4866,6 +5025,10 @@
4866
5025
 
4867
5026
  function $form() {
4868
5027
  return _vue.extend($FormCreate(FormCreate));
5028
+ }
5029
+
5030
+ function $vnode() {
5031
+ return _vue.extend(fragment);
4869
5032
  } //todo 检查回调函数作用域
4870
5033
 
4871
5034
 
@@ -4891,6 +5054,7 @@
4891
5054
  function FormCreate(vm, rules, options) {
4892
5055
  extend(this, {
4893
5056
  vm: vm,
5057
+ create: create,
4894
5058
  manager: createManager(config.manager),
4895
5059
  parsers: parsers,
4896
5060
  providers: providers,
@@ -4986,6 +5150,7 @@
4986
5150
  },
4987
5151
  created: function created() {
4988
5152
  this.$handle.init();
5153
+ this.vm.$emit('created', this.api());
4989
5154
  },
4990
5155
  api: function api() {
4991
5156
  return this.$handle.api;
@@ -5007,6 +5172,7 @@
5007
5172
  component: component,
5008
5173
  directive: directive,
5009
5174
  register: register,
5175
+ $vnode: $vnode,
5010
5176
  parser: parser,
5011
5177
  use: use,
5012
5178
  factory: factory,
@@ -5060,6 +5226,7 @@
5060
5226
  useAttr($formCreate);
5061
5227
  Vue.prototype.$formCreate = $formCreate;
5062
5228
  Vue.component('FormCreate', $form());
5229
+ Vue.component('FcFragment', $vnode());
5063
5230
  }
5064
5231
  });
5065
5232
  }
@@ -5408,10 +5575,10 @@
5408
5575
  _col = _this$rule$props.col;
5409
5576
  var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
5410
5577
  props: _objectSpread2(_objectSpread2({
5411
- label: rule.title.title,
5412
- labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth)
5578
+ labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth),
5579
+ label: isTitle ? rule.title.title : undefined
5413
5580
  }, rule.wrap || {}), {}, {
5414
- prop: ctx.field,
5581
+ prop: ctx.id,
5415
5582
  rules: rule.validate
5416
5583
  }),
5417
5584
  "class": rule.className,
@@ -5422,36 +5589,18 @@
5422
5589
  return inline === true || isFalse(_col) || isFalse(col.show) ? item : this.makeCol(rule, uni, [item]);
5423
5590
  },
5424
5591
  isTitle: function isTitle(rule) {
5592
+ if (this.options.form.title === false) return false;
5425
5593
  var title = rule.title;
5426
5594
  return !(!title.title && !title["native"] || isFalse(title.show));
5427
5595
  },
5428
5596
  makeInfo: function makeInfo(rule, uni) {
5429
- var _this = this;
5430
-
5431
5597
  var titleProp = rule.title;
5432
5598
  var infoProp = rule.info;
5433
5599
  var isTip = isTooltip(infoProp);
5434
5600
  var form = this.options.form;
5435
- var children = [titleProp.title + (form.labelSuffix || form['label-suffix'] || '')];
5436
-
5437
- var titleFn = function titleFn(pop) {
5438
- return _this.$r(mergeProps([titleProp, {
5439
- props: titleProp,
5440
- slot: titleProp.slot || (pop ? isTip ? 'default' : 'reference' : '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: 'i',
5450
- "class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
5451
- key: "".concat(uni, "i")
5452
- }));
5453
- }
5601
+ var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
5454
5602
 
5603
+ if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5455
5604
  var prop = {
5456
5605
  type: infoProp.type || 'popover',
5457
5606
  props: _objectSpread2({}, infoProp),
@@ -5464,10 +5613,20 @@
5464
5613
  prop.props[field] = infoProp.info;
5465
5614
  }
5466
5615
 
5467
- return this.$r(mergeProps([infoProp, prop]), [titleFn(true)]);
5616
+ children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5617
+ type: 'i',
5618
+ slot: isTip ? 'default' : 'reference',
5619
+ "class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
5620
+ key: "".concat(uni, "i")
5621
+ })]));
5468
5622
  }
5469
5623
 
5470
- return titleFn();
5624
+ return this.$r(mergeProps([titleProp, {
5625
+ props: titleProp,
5626
+ slot: titleProp.slot || 'label',
5627
+ key: "".concat(uni, "tit"),
5628
+ type: titleProp.type || 'span'
5629
+ }]), children);
5471
5630
  },
5472
5631
  makeCol: function makeCol(rule, uni, children) {
5473
5632
  var col = rule.col;
@@ -5517,7 +5676,7 @@
5517
5676
  }, [item]);
5518
5677
  },
5519
5678
  makeResetBtn: function makeResetBtn() {
5520
- var _this2 = this;
5679
+ var _this = this;
5521
5680
 
5522
5681
  var resetBtn = this.options.resetBtn;
5523
5682
  return this.$r({
@@ -5528,7 +5687,7 @@
5528
5687
  },
5529
5688
  on: {
5530
5689
  click: function click() {
5531
- var fApi = _this2.$handle.api;
5690
+ var fApi = _this.$handle.api;
5532
5691
  resetBtn.click ? resetBtn.click(fApi) : fApi.resetFields();
5533
5692
  }
5534
5693
  },
@@ -5536,7 +5695,7 @@
5536
5695
  }, [resetBtn.innerText]);
5537
5696
  },
5538
5697
  makeSubmitBtn: function makeSubmitBtn() {
5539
- var _this3 = this;
5698
+ var _this2 = this;
5540
5699
 
5541
5700
  var submitBtn = this.options.submitBtn;
5542
5701
  return this.$r({
@@ -5547,7 +5706,7 @@
5547
5706
  },
5548
5707
  on: {
5549
5708
  click: function click() {
5550
- var fApi = _this3.$handle.api;
5709
+ var fApi = _this2.$handle.api;
5551
5710
  submitBtn.click ? submitBtn.click(fApi) : fApi.submit();
5552
5711
  }
5553
5712
  },
@@ -5638,7 +5797,7 @@
5638
5797
  return maker;
5639
5798
  }
5640
5799
 
5641
- var css_248z$2 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n";
5800
+ var css_248z$2 = ".form-create .form-create .el-form-item {\n margin-bottom: 22px;\n}\n\n.form-create .form-create .el-form-item .el-form-item {\n margin-bottom: 0px;\n}\n\n.form-create{\n transform: rotateZ(0);\n}\n";
5642
5801
  styleInject(css_248z$2);
5643
5802
 
5644
5803
  function tidyBtnProp(btn, def) {
@@ -5700,13 +5859,14 @@
5700
5859
  }
5701
5860
  },
5702
5861
  validateField: function validateField(field, callback) {
5703
- if (!h.fieldCtx[field]) return;
5704
- var sub = h.subForm[field];
5862
+ var ctx = h.getFieldCtx(field);
5863
+ if (!ctx) return;
5864
+ var sub = h.subForm[ctx.id];
5705
5865
  var len = 0;
5706
5866
  var flag;
5707
5867
 
5708
5868
  var validate = function validate() {
5709
- h.$manager.validateField(field, function () {
5869
+ h.$manager.validateField(ctx.id, function () {
5710
5870
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
5711
5871
  args[_key3] = arguments[_key3];
5712
5872
  }
@@ -5756,23 +5916,25 @@
5756
5916
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5757
5917
  api.helper.tidyFields(fields).forEach(function (field) {
5758
5918
  if (clearSub) _this.clearSubValidateState(field);
5759
- var ctx = h.fieldCtx[field];
5760
- if (!ctx) return;
5761
- h.$manager.clearValidateState(ctx);
5919
+ h.getCtxs(field).forEach(function (ctx) {
5920
+ h.$manager.clearValidateState(ctx);
5921
+ });
5762
5922
  });
5763
5923
  },
5764
5924
  clearSubValidateState: function clearSubValidateState(fields) {
5765
5925
  api.helper.tidyFields(fields).forEach(function (field) {
5766
- var subForm = h.subForm[field];
5767
- if (!subForm) return;
5926
+ h.getCtxs(field).forEach(function (ctx) {
5927
+ var subForm = h.subForm[ctx.id];
5928
+ if (!subForm) return;
5768
5929
 
5769
- if (Array.isArray(subForm)) {
5770
- subForm.forEach(function (form) {
5771
- form.clearValidateState();
5772
- });
5773
- } else if (subForm) {
5774
- subForm.clearValidateState();
5775
- }
5930
+ if (Array.isArray(subForm)) {
5931
+ subForm.forEach(function (form) {
5932
+ form.clearValidateState();
5933
+ });
5934
+ } else if (subForm) {
5935
+ subForm.clearValidateState();
5936
+ }
5937
+ });
5776
5938
  });
5777
5939
  },
5778
5940
  btn: {
@@ -5875,7 +6037,7 @@
5875
6037
  function elmFormCreate() {
5876
6038
  return FormCreateFactory({
5877
6039
  ui: "".concat("element-ui"),
5878
- version: "".concat("2.5.9"),
6040
+ version: "".concat("2.5.13"),
5879
6041
  manager: manager,
5880
6042
  extendApi: extendApi,
5881
6043
  install: install,