@form-create/view-design 2.5.10 → 2.5.11

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.10
2
+ * @form-create/view-design v2.5.11
3
3
  * (c) 2018-2021 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -655,7 +655,6 @@
655
655
  }]))]);
656
656
  },
657
657
  handleClick: function handleClick(src) {
658
- if (this.disabled) return;
659
658
  return this.onHandle(src);
660
659
  },
661
660
  handleRemove: function handleRemove(src) {
@@ -1088,7 +1087,6 @@
1088
1087
  this.$refs.upload.handleRemove(file);
1089
1088
  },
1090
1089
  handleClick: function handleClick(file) {
1091
- if (this.isDisabled()) return;
1092
1090
  this.onHandle(file);
1093
1091
  },
1094
1092
  makeItem: function makeItem(file, index) {
@@ -1971,7 +1969,7 @@
1971
1969
 
1972
1970
  var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'nativeEmit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
1973
1971
  var arrayAttrs = ['validate', 'children', 'control'];
1974
- var normalAttrs = ['effect'];
1972
+ var normalAttrs = ['effect', 'deep'];
1975
1973
  function attrs() {
1976
1974
  return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
1977
1975
  }
@@ -2043,6 +2041,7 @@
2043
2041
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2044
2042
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2045
2043
  var $T = '$FN:';
2044
+ var $TX = '$FNX:';
2046
2045
  var FUNCTION = 'function';
2047
2046
  function toJson(obj, space) {
2048
2047
  return JSON.stringify(deepExtend([], obj, true), function (key, val) {
@@ -2067,7 +2066,7 @@
2067
2066
  }
2068
2067
 
2069
2068
  function parseFn(fn, mode) {
2070
- if (fn && is.String(fn)) {
2069
+ if (fn && is.String(fn) && fn.length > 4) {
2071
2070
  var v = fn.trim();
2072
2071
  var flag = false;
2073
2072
 
@@ -2078,8 +2077,8 @@
2078
2077
  } else if (v.indexOf($T) === 0) {
2079
2078
  v = v.replace($T, '');
2080
2079
  flag = true;
2081
- } else if (v.indexOf('$FNX:') === 0) {
2082
- v = makeFn('function($inject){' + v.replace('$FNX:', '') + '}');
2080
+ } else if (v.indexOf($TX) === 0) {
2081
+ v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2083
2082
  v.__json = fn;
2084
2083
  v.__inject = true;
2085
2084
  return v;
@@ -2092,7 +2091,7 @@
2092
2091
  val.__json = fn;
2093
2092
  return val;
2094
2093
  } catch (e) {
2095
- err("\u89E3\u6790\u5931\u8D25:".concat(v));
2094
+ err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
2096
2095
  return undefined;
2097
2096
  }
2098
2097
  }
@@ -2183,7 +2182,7 @@
2183
2182
  to;
2184
2183
  (idx || '').split('.').forEach(function (v) {
2185
2184
  if (to) {
2186
- if (!_data[to]) {
2185
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2187
2186
  _data[to] = {};
2188
2187
  }
2189
2188
 
@@ -2281,13 +2280,6 @@
2281
2280
  return deepCopy(value);
2282
2281
  }
2283
2282
 
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
2283
  function Api(h) {
2292
2284
  function tidyFields(fields) {
2293
2285
  if (is.Undef(fields)) fields = h.fields();else if (!Array.isArray(fields)) fields = [fields];
@@ -2296,10 +2288,10 @@
2296
2288
 
2297
2289
  function props(fields, key, val) {
2298
2290
  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);
2291
+ h.getCtxs(field).forEach(function (ctx) {
2292
+ $set(ctx.rule, key, val);
2293
+ h.$render.clearCache(ctx);
2294
+ });
2303
2295
  });
2304
2296
  }
2305
2297
 
@@ -2345,23 +2337,26 @@
2345
2337
 
2346
2338
  formData: function formData(fields) {
2347
2339
  return tidyFields(fields).reduce(function (initial, id) {
2348
- var ctx = h.fieldCtx[id];
2340
+ var ctx = h.getFieldCtx(id);
2349
2341
  if (!ctx) return initial;
2350
2342
  initial[ctx.field] = copy(ctx.rule.value);
2351
2343
  return initial;
2352
2344
  }, copy(h.appendData));
2353
2345
  },
2354
2346
  getValue: function getValue(field) {
2355
- var ctx = h.fieldCtx[field];
2347
+ var ctx = h.getFieldCtx(field);
2356
2348
  if (!ctx) return;
2357
2349
  return copy(ctx.rule.value);
2358
2350
  },
2359
2351
  coverValue: function coverValue(formData) {
2360
2352
  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;
2353
+ api.fields().forEach(function (key) {
2354
+ var ctxs = h.fieldCtx[key];
2355
+ if (!ctxs) return h.appendData[key] = formData[key];
2356
+ var flag = hasProperty(formData, key);
2357
+ ctxs.forEach(function (ctx) {
2358
+ ctx.rule.value = flag ? formData[key] : undefined;
2359
+ });
2365
2360
  });
2366
2361
  });
2367
2362
  },
@@ -2370,17 +2365,22 @@
2370
2365
  if (arguments.length >= 2) formData = _defineProperty({}, field, arguments[1]);
2371
2366
  h.deferSyncValue(function () {
2372
2367
  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];
2368
+ var ctxs = h.fieldCtx[key];
2369
+ if (!ctxs) return h.appendData[key] = formData[key];
2370
+ ctxs.forEach(function (ctx) {
2371
+ ctx.rule.value = formData[key];
2372
+ });
2376
2373
  });
2377
2374
  });
2378
2375
  },
2379
2376
  removeField: function removeField(field) {
2380
2377
  var ctx = h.getCtx(field);
2381
- if (!ctx) return;
2382
- ctx.rm();
2383
- return ctx.origin;
2378
+ h.deferSyncValue(function () {
2379
+ h.getCtxs(field).forEach(function (ctx) {
2380
+ ctx.rm();
2381
+ });
2382
+ }, true);
2383
+ return ctx ? ctx.origin : undefined;
2384
2384
  },
2385
2385
  removeRule: function removeRule(rule) {
2386
2386
  var ctx = rule && byCtx(rule);
@@ -2396,10 +2396,8 @@
2396
2396
  return h.fields();
2397
2397
  },
2398
2398
  append: function append(rule, after, child) {
2399
- var fields = Object.keys(h.fieldCtx),
2400
- index = h.sort.length - 1,
2399
+ var index = h.sort.length - 1,
2401
2400
  rules;
2402
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2403
2401
  var ctx = h.getCtx(after);
2404
2402
 
2405
2403
  if (ctx) {
@@ -2415,10 +2413,8 @@
2415
2413
  rules.splice(index + 1, 0, rule);
2416
2414
  },
2417
2415
  prepend: function prepend(rule, after, child) {
2418
- var fields = Object.keys(h.fieldCtx),
2419
- index = 0,
2416
+ var index = 0,
2420
2417
  rules;
2421
- if (rule.field && fields.indexOf(rule.field) > -1) return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), rule);
2422
2418
  var ctx = h.getCtx(after);
2423
2419
 
2424
2420
  if (ctx) {
@@ -2452,17 +2448,27 @@
2452
2448
  },
2453
2449
  disabled: function disabled(_disabled, fields) {
2454
2450
  tidyFields(fields).forEach(function (field) {
2455
- var ctx = h.fieldCtx[field];
2456
- if (!ctx) return;
2457
- $set(ctx.rule.props, 'disabled', !!_disabled);
2451
+ h.getCtxs(field).forEach(function (ctx) {
2452
+ $set(ctx.rule.props, 'disabled', !!_disabled);
2453
+ });
2458
2454
  });
2459
2455
  h.refresh();
2460
2456
  },
2461
2457
  model: function model(origin) {
2462
- return byRules(h.fieldCtx, origin);
2458
+ return h.fields().reduce(function (initial, key) {
2459
+ var ctx = h.fieldCtx[key][0];
2460
+ initial[key] = origin ? ctx.origin : ctx.rule;
2461
+ return initial;
2462
+ }, {});
2463
2463
  },
2464
2464
  component: function component(origin) {
2465
- return byRules(h.nameCtx, origin);
2465
+ return Object.keys(h.nameCtx).reduce(function (initial, key) {
2466
+ var ctx = h.nameCtx[key].map(function (ctx) {
2467
+ return origin ? ctx.origin : ctx.rule;
2468
+ });
2469
+ initial[key] = ctx.length === 1 ? ctx[0] : ctx;
2470
+ return initial;
2471
+ }, {});
2466
2472
  },
2467
2473
  bind: function bind() {
2468
2474
  return api.form;
@@ -2480,25 +2486,39 @@
2480
2486
  });
2481
2487
  },
2482
2488
  sync: function sync(field) {
2483
- var ctx = is.Object(field) ? byCtx(field) : h.getCtx(field);
2489
+ if (Array.isArray(field)) {
2490
+ field.forEach(function (v) {
2491
+ return api.sync(v);
2492
+ });
2493
+ return;
2494
+ }
2484
2495
 
2485
- if (ctx && !ctx.deleted) {
2486
- var subForm = h.subForm[field];
2496
+ var ctxs = is.Object(field) ? byCtx(field) : h.getCtxs(field);
2487
2497
 
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);
2498
+ if (!ctxs) {
2499
+ return;
2500
+ }
2497
2501
 
2502
+ ctxs = Array.isArray(ctxs) ? ctxs : [ctxs];
2503
+ ctxs.forEach(function (ctx) {
2504
+ if (!ctx.deleted) {
2505
+ var subForm = h.subForm[ctx.id];
2498
2506
 
2499
- h.$render.clearCache(ctx);
2500
- h.refresh();
2501
- }
2507
+ if (subForm) {
2508
+ if (Array.isArray(subForm)) {
2509
+ subForm.forEach(function (form) {
2510
+ form.refresh();
2511
+ });
2512
+ } else if (subForm) {
2513
+ subForm.refresh();
2514
+ }
2515
+ } //ctx.updateKey(true);
2516
+
2517
+
2518
+ h.$render.clearCache(ctx);
2519
+ }
2520
+ });
2521
+ h.refresh();
2502
2522
  },
2503
2523
  refresh: function refresh() {
2504
2524
  allSubForm().forEach(function (sub) {
@@ -2521,8 +2541,9 @@
2521
2541
  h.changeStatus = false;
2522
2542
  },
2523
2543
  updateRule: function updateRule(id, rule) {
2524
- var r = api.getRule(id);
2525
- r && extend(r, rule);
2544
+ h.getCtxs(id).forEach(function (ctx) {
2545
+ extend(ctx.rule, rule);
2546
+ });
2526
2547
  },
2527
2548
  updateRules: function updateRules(rules) {
2528
2549
  Object.keys(rules).forEach(function (id) {
@@ -2530,8 +2551,9 @@
2530
2551
  });
2531
2552
  },
2532
2553
  mergeRule: function mergeRule$1(id, rule) {
2533
- var ctx = h.getCtx(id);
2534
- ctx && mergeRule(ctx.rule, rule);
2554
+ h.getCtxs(id).forEach(function (ctx) {
2555
+ mergeRule(ctx.rule, rule);
2556
+ });
2535
2557
  },
2536
2558
  mergeRules: function mergeRules(rules) {
2537
2559
  Object.keys(rules).forEach(function (id) {
@@ -2564,13 +2586,12 @@
2564
2586
  api.refresh();
2565
2587
  },
2566
2588
  resetFields: function resetFields(fields) {
2567
- var ctxs = h.fieldCtx;
2568
2589
  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);
2590
+ h.getCtxs(field).forEach(function (ctx) {
2591
+ h.$render.clearCache(ctx);
2592
+ ctx.rule.value = copy(ctx.defaultValue);
2593
+ h.refreshControl(ctx);
2594
+ });
2574
2595
  });
2575
2596
  },
2576
2597
  method: function method(id, name) {
@@ -2610,7 +2631,8 @@
2610
2631
  el && el.$emit && el.$emit('close-modal');
2611
2632
  },
2612
2633
  getSubForm: function getSubForm(field) {
2613
- return h.subForm[field];
2634
+ var ctx = h.getCtx(field);
2635
+ return ctx ? h.subForm[ctx.id] : undefined;
2614
2636
  },
2615
2637
  nextTick: function nextTick(fn) {
2616
2638
  h.bus.$once('next-tick', fn);
@@ -2749,7 +2771,7 @@
2749
2771
 
2750
2772
  var vm = rule.vm;
2751
2773
  if (!vm) return new _vue();else if (is.Function(vm)) return invoke(function () {
2752
- return vm(_this3.$handle.getInjectData(rule));
2774
+ return rule.vm(_this3.$handle.getInjectData(rule));
2753
2775
  });else if (!vm._isVue) return new _vue(vm);
2754
2776
  return vm;
2755
2777
  },
@@ -2765,6 +2787,14 @@
2765
2787
  deepSet(ctx.prop, ctx.prop.optionsTo, ctx.prop.options);
2766
2788
  }
2767
2789
  },
2790
+ deepSet: function deepSet$1(ctx) {
2791
+ var deep = ctx.rule.deep;
2792
+ deep && Object.keys(deep).sort(function (a, b) {
2793
+ return a.length < b.length ? -1 : 1;
2794
+ }).forEach(function (str) {
2795
+ deepSet(ctx.prop, str, deep[str]);
2796
+ });
2797
+ },
2768
2798
  setTempProps: function setTempProps(vm, ctx) {
2769
2799
  if (!vm.$props) return;
2770
2800
  var prop = ctx.prop;
@@ -2832,8 +2862,12 @@
2832
2862
  return ctx.rule.slot === slot ? this.renderCtx(ctx) : undefined;
2833
2863
  },
2834
2864
  renderId: function renderId(name, type) {
2835
- var ctx = this.$handle[type === 'field' ? 'nameCtx' : 'fieldCtx'][name];
2836
- return ctx ? this.renderCtx(ctx, ctx.parent) : undefined;
2865
+ var _this5 = this;
2866
+
2867
+ var ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name];
2868
+ return ctxs ? ctxs.map(function (ctx) {
2869
+ return _this5.renderCtx(ctx, ctx.parent);
2870
+ }) : undefined;
2837
2871
  },
2838
2872
  renderCtx: function renderCtx(ctx, parent) {
2839
2873
  if (ctx.type === 'hidden') return;
@@ -2859,6 +2893,7 @@
2859
2893
  ctx.initProp();
2860
2894
  this.mergeGlobal(ctx);
2861
2895
  this.$manager.tidyRule(ctx);
2896
+ this.deepSet(ctx);
2862
2897
  this.setOptions(ctx);
2863
2898
  this.ctxProp(ctx);
2864
2899
  var prop = ctx.prop;
@@ -2888,6 +2923,7 @@
2888
2923
  rule: rule,
2889
2924
  prop: prop,
2890
2925
  children: children,
2926
+ api: this.$handle.api,
2891
2927
  model: prop.model || {}
2892
2928
  });
2893
2929
  } else {
@@ -2918,13 +2954,13 @@
2918
2954
  return this.getCache(ctx);
2919
2955
  },
2920
2956
  display: function display(vn) {
2921
- var _this5 = this;
2957
+ var _this6 = this;
2922
2958
 
2923
2959
  if (Array.isArray(vn)) {
2924
2960
  var data = [];
2925
2961
  vn.forEach(function (v) {
2926
- if (Array.isArray(v)) return _this5.display(v);
2927
- if (_this5.none(v)) data.push(v);
2962
+ if (Array.isArray(v)) return _this6.display(v);
2963
+ if (_this6.none(v)) data.push(v);
2928
2964
  });
2929
2965
  return data;
2930
2966
  } else {
@@ -2953,17 +2989,18 @@
2953
2989
  }, [vn]);
2954
2990
  },
2955
2991
  injectProp: function injectProp(ctx) {
2956
- var _this6 = this;
2992
+ var _this7 = this;
2957
2993
 
2958
2994
  if (!this.vm.ctxInject[ctx.id]) {
2959
2995
  $set(this.vm.ctxInject, ctx.id, {});
2960
2996
  }
2961
2997
 
2962
- extend(this.vm.ctxInject[ctx.id], {
2998
+ var inject = this.vm.ctxInject[ctx.id];
2999
+ extend(inject, {
2963
3000
  api: this.$handle.api,
2964
3001
  form: this.fc.create,
2965
3002
  subForm: function subForm(_subForm) {
2966
- _this6.$handle.addSubForm(ctx, _subForm);
3003
+ _this7.$handle.addSubForm(ctx, _subForm);
2967
3004
  },
2968
3005
  field: ctx.field,
2969
3006
  options: ctx.prop.options,
@@ -2977,10 +3014,10 @@
2977
3014
  return temp;
2978
3015
  }()
2979
3016
  });
2980
- return this.vm.ctxInject[ctx.id];
3017
+ return inject;
2981
3018
  },
2982
3019
  ctxProp: function ctxProp(ctx, custom) {
2983
- var _this7 = this;
3020
+ var _this8 = this;
2984
3021
 
2985
3022
  var ref = ctx.ref,
2986
3023
  key = ctx.key,
@@ -2993,7 +3030,7 @@
2993
3030
  slot: undefined,
2994
3031
  on: {
2995
3032
  'hook:mounted': function hookMounted() {
2996
- _this7.onMounted(ctx);
3033
+ _this8.onMounted(ctx);
2997
3034
  }
2998
3035
  }
2999
3036
  }];
@@ -3003,9 +3040,9 @@
3003
3040
  model: {
3004
3041
  value: this.$handle.getFormData(ctx),
3005
3042
  callback: function callback(value) {
3006
- _this7.onInput(ctx, value);
3043
+ _this8.onInput(ctx, value);
3007
3044
  },
3008
- expression: "formData.".concat(ctx.field)
3045
+ expression: "formData.".concat(ctx.id)
3009
3046
  }
3010
3047
  });
3011
3048
  }
@@ -3027,13 +3064,13 @@
3027
3064
  this.$handle.onInput(ctx, value);
3028
3065
  },
3029
3066
  renderChildren: function renderChildren(ctx) {
3030
- var _this8 = this;
3067
+ var _this9 = this;
3031
3068
 
3032
3069
  var children = ctx.rule.children,
3033
3070
  orgChildren = this.orgChildren[ctx.id];
3034
3071
 
3035
3072
  var isRm = function isRm(child) {
3036
- return !is.String(child) && child.__fc__ && !_this8.$handle.ctxs[child.__fc__.id];
3073
+ return !is.String(child) && child.__fc__ && !_this9.$handle.ctxs[child.__fc__.id];
3037
3074
  };
3038
3075
 
3039
3076
  if (!is.trueArray(children) && orgChildren) {
@@ -3042,7 +3079,7 @@
3042
3079
  if (!child) return;
3043
3080
 
3044
3081
  if (isRm(child)) {
3045
- _this8.$handle.rmCtx(child.__fc__);
3082
+ _this9.$handle.rmCtx(child.__fc__);
3046
3083
  }
3047
3084
  });
3048
3085
  });
@@ -3055,7 +3092,7 @@
3055
3092
  if (!child) return;
3056
3093
 
3057
3094
  if (children.indexOf(child) === -1 && isRm(child)) {
3058
- _this8.$handle.rmCtx(child.__fc__);
3095
+ _this9.$handle.rmCtx(child.__fc__);
3059
3096
  }
3060
3097
  });
3061
3098
  });
@@ -3064,14 +3101,14 @@
3064
3101
  if (is.String(child)) return child;
3065
3102
 
3066
3103
  if (child.__fc__) {
3067
- return _this8.renderCtx(child.__fc__, ctx);
3104
+ return _this9.renderCtx(child.__fc__, ctx);
3068
3105
  }
3069
3106
 
3070
- if (!_this8.$handle.isRepeatRule(child.__origin__ || child) && child.type) {
3071
- _this8.vm.$nextTick(function () {
3072
- _this8.$handle.loadChildren(children, ctx);
3107
+ if (child.type) {
3108
+ _this9.vm.$nextTick(function () {
3109
+ _this9.$handle.loadChildren(children, ctx);
3073
3110
 
3074
- _this8.$handle.refresh();
3111
+ _this9.$handle.refresh();
3075
3112
  });
3076
3113
  }
3077
3114
  });
@@ -3083,7 +3120,7 @@
3083
3120
  return this.vNode.make(lower(ctx.originType), prop, children);
3084
3121
  },
3085
3122
  renderRule: function renderRule(rule, children, origin) {
3086
- var _this9 = this;
3123
+ var _this10 = this;
3087
3124
 
3088
3125
  if (!rule) return undefined;
3089
3126
  if (is.String(rule)) return rule;
@@ -3106,7 +3143,7 @@
3106
3143
 
3107
3144
  if (is.trueArray(rule.children)) {
3108
3145
  data.push(rule.children.map(function (v) {
3109
- return _this9.renderRule(v);
3146
+ return _this10.renderRule(v);
3110
3147
  }));
3111
3148
  }
3112
3149
 
@@ -3140,7 +3177,6 @@
3140
3177
  function useInject(Handler) {
3141
3178
  extend(Handler.prototype, {
3142
3179
  parseInjectEvent: function parseInjectEvent(rule, on) {
3143
- if (rule.inject === false) return;
3144
3180
  var inject = rule.inject || this.options.injectEvent;
3145
3181
  return this.parseEventLst(rule, on, inject);
3146
3182
  },
@@ -3157,13 +3193,16 @@
3157
3193
  return data;
3158
3194
  },
3159
3195
  parseEvent: function parseEvent(rule, fn, inject, deep) {
3160
- if (is.Function(fn) && (!is.Undef(inject) || fn.__inject)) {
3196
+ if (is.Function(fn) && (inject !== false && !is.Undef(inject) || fn.__inject)) {
3161
3197
  return this.inject(rule, fn, inject);
3162
3198
  } else if (!deep && Array.isArray(fn) && fn[0] && (is.String(fn[0]) || is.Function(fn[0]))) {
3163
3199
  return this.parseEventLst(rule, fn, inject, true);
3164
3200
  } else if (is.String(fn)) {
3165
3201
  var val = parseFn(fn);
3166
- return is.String(val) ? val : this.parseEvent(rule, val, inject, true);
3202
+
3203
+ if (val && fn !== val) {
3204
+ return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
3205
+ }
3167
3206
  }
3168
3207
  },
3169
3208
  parseEmit: function parseEmit(ctx, on) {
@@ -3226,6 +3265,7 @@
3226
3265
  option = _this$vm$$options$pro.option,
3227
3266
  rule = _this$vm$$options$pro.rule;
3228
3267
  return {
3268
+ api: this.api,
3229
3269
  $f: this.api,
3230
3270
  rule: rule,
3231
3271
  self: self.__origin__,
@@ -3483,7 +3523,7 @@
3483
3523
  extend(_this2, {
3484
3524
  root: []
3485
3525
  });
3486
- });
3526
+ }, _this2.input);
3487
3527
  });
3488
3528
  },
3489
3529
  update: function update(handle, init) {
@@ -3541,7 +3581,7 @@
3541
3581
  loadFn: function loadFn(item, rule) {
3542
3582
  var _this3 = this;
3543
3583
 
3544
- ['on', 'props', 'nativeOn'].forEach(function (k) {
3584
+ ['on', 'props', 'nativeOn', 'deep'].forEach(function (k) {
3545
3585
  item[k] && _this3.parseInjectEvent(rule, item[k]);
3546
3586
  });
3547
3587
  },
@@ -3568,9 +3608,6 @@
3568
3608
  }, {})
3569
3609
  }], ctx.computed);
3570
3610
  },
3571
- isRepeatRule: function isRepeatRule(rule) {
3572
- return this.repeatRule.indexOf(rule) > -1;
3573
- },
3574
3611
  loadRule: function loadRule() {
3575
3612
  var _this5 = this;
3576
3613
 
@@ -3654,7 +3691,7 @@
3654
3691
  var rule = getRule(_rule);
3655
3692
 
3656
3693
  var isRepeat = function isRepeat() {
3657
- return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field] !== _rule.__fc__);
3694
+ return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
3658
3695
  };
3659
3696
 
3660
3697
  _this6.ruleEffect(rule, 'init', {
@@ -3662,11 +3699,7 @@
3662
3699
  });
3663
3700
 
3664
3701
  if (isRepeat()) {
3665
- _this6.repeatRule.push(_rule);
3666
-
3667
3702
  _this6.vm.$emit('repeat-field', _rule, _this6.api);
3668
-
3669
- return err("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728"), _rule);
3670
3703
  }
3671
3704
 
3672
3705
  var ctx;
@@ -3772,14 +3805,17 @@
3772
3805
  return val === control.value;
3773
3806
  };
3774
3807
 
3808
+ if (!is.trueArray(control.rule)) return "continue";
3809
+
3775
3810
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3776
3811
  valid: invoke(function () {
3777
3812
  return handleFn(ctx.rule.value, api);
3778
3813
  }),
3779
- ctrl: findCtrl(ctx, control.rule)
3814
+ ctrl: findCtrl(ctx, control.rule),
3815
+ isHidden: is.String(control.rule[0])
3780
3816
  });
3781
3817
 
3782
- if (data.valid && data.ctrl || !data.valid && !data.ctrl) return "continue";
3818
+ if (data.valid && data.ctrl || !data.valid && !data.ctrl && !data.isHidden) return "continue";
3783
3819
  validate.push(data);
3784
3820
  };
3785
3821
 
@@ -3791,53 +3827,56 @@
3791
3827
 
3792
3828
  if (!validate.length) return false;
3793
3829
  var flag = false;
3794
- validate.reverse().forEach(function (_ref) {
3795
- var valid = _ref.valid,
3796
- rule = _ref.rule,
3797
- prepend = _ref.prepend,
3798
- append = _ref.append,
3799
- child = _ref.child,
3800
- ctrl = _ref.ctrl;
3801
-
3802
- if (is.String(rule[0])) {
3803
- valid ? ctx.ctrlRule.push({
3804
- __ctrl: true,
3805
- children: rule,
3806
- valid: valid
3807
- }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3808
-
3809
- _this7.vm.$nextTick(function () {
3810
- _this7.api.hidden(!valid, rule);
3811
- });
3830
+ this.deferSyncValue(function () {
3831
+ validate.reverse().forEach(function (_ref) {
3832
+ var isHidden = _ref.isHidden,
3833
+ valid = _ref.valid,
3834
+ rule = _ref.rule,
3835
+ prepend = _ref.prepend,
3836
+ append = _ref.append,
3837
+ child = _ref.child,
3838
+ ctrl = _ref.ctrl;
3839
+
3840
+ if (isHidden) {
3841
+ valid ? ctx.ctrlRule.push({
3842
+ __ctrl: true,
3843
+ children: rule,
3844
+ valid: valid
3845
+ }) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3846
+
3847
+ _this7.vm.$nextTick(function () {
3848
+ _this7.api.hidden(!valid, rule);
3849
+ });
3812
3850
 
3813
- return;
3814
- }
3851
+ return;
3852
+ }
3815
3853
 
3816
- if (valid) {
3817
- flag = true;
3818
- var ruleCon = {
3819
- type: 'fcFragment',
3820
- "native": true,
3821
- __ctrl: true,
3822
- children: rule
3823
- };
3824
- ctx.ctrlRule.push(ruleCon);
3825
-
3826
- _this7.bus.$once('load-start', function () {
3827
- // this.cycleLoad = true;
3828
- if (prepend) {
3829
- api.prepend(ruleCon, prepend, child);
3830
- } else if (append || child) {
3831
- api.append(ruleCon, append || ctx.id, child);
3832
- } else {
3833
- ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3834
- }
3835
- });
3836
- } else {
3837
- ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3838
- var ctrlCtx = byCtx(ctrl);
3839
- ctrlCtx && ctrlCtx.rm();
3840
- }
3854
+ if (valid) {
3855
+ flag = true;
3856
+ var ruleCon = {
3857
+ type: 'fcFragment',
3858
+ "native": true,
3859
+ __ctrl: true,
3860
+ children: rule
3861
+ };
3862
+ ctx.ctrlRule.push(ruleCon);
3863
+
3864
+ _this7.bus.$once('load-start', function () {
3865
+ // this.cycleLoad = true;
3866
+ if (prepend) {
3867
+ api.prepend(ruleCon, prepend, child);
3868
+ } else if (append || child) {
3869
+ api.append(ruleCon, append || ctx.id, child);
3870
+ } else {
3871
+ ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
3872
+ }
3873
+ });
3874
+ } else {
3875
+ ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
3876
+ var ctrlCtx = byCtx(ctrl);
3877
+ ctrlCtx && ctrlCtx.rm();
3878
+ }
3879
+ });
3841
3880
  });
3842
3881
  this.vm.$emit('control', ctx.origin, this.api);
3843
3882
  this.effect(ctx, 'control');
@@ -3934,18 +3973,19 @@
3934
3973
  }
3935
3974
  },
3936
3975
  setFormData: function setFormData(ctx, value) {
3937
- $set(this.formData, ctx.field, value);
3976
+ $set(this.formData, ctx.id, value);
3938
3977
  },
3939
3978
  getFormData: function getFormData(ctx) {
3940
- return this.formData[ctx.field];
3979
+ return this.formData[ctx.id];
3941
3980
  },
3942
3981
  validate: function validate() {
3943
3982
  var _this = this;
3944
3983
 
3945
3984
  toEmpty(this.vm.validate);
3946
- Object.keys(this.fieldCtx).forEach(function (id) {
3947
- var ctx = _this.fieldCtx[id];
3948
- _this.vm.validate[ctx.field] = toArray(ctx.rule.validate);
3985
+ this.fields().forEach(function (id) {
3986
+ _this.fieldCtx[id].forEach(function (ctx) {
3987
+ _this.vm.validate[ctx.id] = toArray(ctx.rule.validate);
3988
+ });
3949
3989
  });
3950
3990
  return this.vm.validate;
3951
3991
  },
@@ -3953,8 +3993,8 @@
3953
3993
  var _this2 = this;
3954
3994
 
3955
3995
  toEmpty(this.form);
3956
- Object.defineProperties(this.form, Object.keys(this.formData).reduce(function (initial, field) {
3957
- var ctx = _this2.getCtx(field);
3996
+ Object.defineProperties(this.form, this.fields().reduce(function (initial, field) {
3997
+ var ctx = _this2.getFieldCtx(field);
3958
3998
 
3959
3999
  var handle = _this2.valueHandle(ctx);
3960
4000
 
@@ -3998,14 +4038,18 @@
3998
4038
  },
3999
4039
  addSubForm: function addSubForm(ctx, subForm) {
4000
4040
  if (ctx.input) {
4001
- this.subForm[ctx.field] = subForm;
4041
+ this.subForm[ctx.id] = subForm;
4002
4042
  }
4003
4043
  },
4004
- deferSyncValue: function deferSyncValue(fn) {
4044
+ deferSyncValue: function deferSyncValue(fn, sync) {
4005
4045
  if (!this.deferSyncFn) {
4006
4046
  this.deferSyncFn = fn;
4007
4047
  }
4008
4048
 
4049
+ if (!this.deferSyncFn.sync) {
4050
+ this.deferSyncFn.sync = sync;
4051
+ }
4052
+
4009
4053
  invoke(fn);
4010
4054
 
4011
4055
  if (this.deferSyncFn === fn) {
@@ -4032,11 +4076,9 @@
4032
4076
  refreshUpdate: function refreshUpdate(ctx, val) {
4033
4077
  var _this4 = this;
4034
4078
 
4035
- var fn = ctx.rule.update;
4036
-
4037
- if (is.Function(fn)) {
4079
+ if (is.Function(ctx.rule.update)) {
4038
4080
  var state = invoke(function () {
4039
- return fn(val, ctx.origin, _this4.api);
4081
+ return ctx.rule.update(val, ctx.origin, _this4.api);
4040
4082
  });
4041
4083
  if (state === undefined) return;
4042
4084
  ctx.rule.hidden = state === true;
@@ -4072,7 +4114,7 @@
4072
4114
  });
4073
4115
  },
4074
4116
  fields: function fields() {
4075
- return Object.keys(this.formData);
4117
+ return Object.keys(this.fieldCtx);
4076
4118
  }
4077
4119
  });
4078
4120
  }
@@ -4083,49 +4125,6 @@
4083
4125
  });
4084
4126
  }
4085
4127
 
4086
- function useHelper(rules) {
4087
- if (!Array.isArray(rules) || rules.findField) return;
4088
- Object.defineProperties(rules, {
4089
- findField: enumerable(findField),
4090
- findName: enumerable(findName),
4091
- setValue: enumerable(setValue)
4092
- });
4093
- }
4094
-
4095
- function find(field, name, origin) {
4096
- if (!this.length) return;
4097
- var children = [];
4098
-
4099
- for (var i = 0; i < this.length; i++) {
4100
- if (!is.Object(this[i])) continue;
4101
- var rule = getRule(this[i]);
4102
- if (rule[name] === field) return origin ? rule : this[i];
4103
- if (is.trueArray(rule.children)) children = children.concat(rule.children);
4104
- is.trueArray(rule.control) && rule.control.forEach(function (r) {
4105
- children = children.concat(r.rule);
4106
- });
4107
- }
4108
-
4109
- return find.call(children, field, name, origin);
4110
- }
4111
-
4112
- function findField(field) {
4113
- return find.call(this, field, 'field');
4114
- }
4115
-
4116
- function findName(field) {
4117
- return find.call(this, field, 'name');
4118
- }
4119
-
4120
- function setValue(formData) {
4121
- var _this = this;
4122
-
4123
- Object.keys(formData).forEach(function (field) {
4124
- var rule = find.call(_this, field, 'field', true);
4125
- if (rule) rule.value = formData[field];
4126
- });
4127
- }
4128
-
4129
4128
  var BaseParser = {
4130
4129
  init: function init(ctx) {},
4131
4130
  toFormValue: function toFormValue(value, ctx) {
@@ -4144,7 +4143,37 @@
4144
4143
  function useContext(Handler) {
4145
4144
  extend(Handler.prototype, {
4146
4145
  getCtx: function getCtx(id) {
4147
- return this.fieldCtx[id] || this.nameCtx[id] || this.ctxs[id];
4146
+ return this.getFieldCtx(id) || this.getNameCtx(id)[0] || this.ctxs[id];
4147
+ },
4148
+ getCtxs: function getCtxs(id) {
4149
+ return this.fieldCtx[id] || this.nameCtx[id] || (this.ctxs[id] ? [this.ctxs[id]] : []);
4150
+ },
4151
+ setIdCtx: function setIdCtx(ctx, key, type) {
4152
+ var field = "".concat(type, "Ctx");
4153
+
4154
+ if (!this[field][key]) {
4155
+ this[field][key] = [ctx];
4156
+ } else {
4157
+ this[field][key].push(ctx);
4158
+ }
4159
+ },
4160
+ rmIdCtx: function rmIdCtx(ctx, key, type) {
4161
+ var field = "".concat(type, "Ctx");
4162
+ var lst = this[field][key];
4163
+ if (!lst) return false;
4164
+ var flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
4165
+
4166
+ if (!lst.length) {
4167
+ delete this[field][key];
4168
+ }
4169
+
4170
+ return flag;
4171
+ },
4172
+ getFieldCtx: function getFieldCtx(field) {
4173
+ return (this.fieldCtx[field] || [])[0];
4174
+ },
4175
+ getNameCtx: function getNameCtx(name) {
4176
+ return this.nameCtx[name] || [];
4148
4177
  },
4149
4178
  setCtx: function setCtx(ctx) {
4150
4179
  var id = ctx.id,
@@ -4152,9 +4181,9 @@
4152
4181
  name = ctx.name,
4153
4182
  rule = ctx.rule;
4154
4183
  this.ctxs[id] = ctx;
4155
- if (name) $set(this.nameCtx, name, ctx);
4184
+ name && this.setIdCtx(ctx, name, 'name');
4156
4185
  if (!ctx.input) return;
4157
- this.fieldCtx[field] = ctx;
4186
+ this.setIdCtx(ctx, field, 'field');
4158
4187
  this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
4159
4188
 
4160
4189
  if (this.isMounted && !this.reloading) {
@@ -4213,7 +4242,7 @@
4213
4242
  if (key === 'link') {
4214
4243
  ctx.link();
4215
4244
  return;
4216
- } else if (['props', 'on', 'nativeOn'].indexOf(key) > -1) {
4245
+ } else if (['props', 'on', 'nativeOn', 'deep'].indexOf(key) > -1) {
4217
4246
  _this.parseInjectEvent(ctx.rule, n || {});
4218
4247
 
4219
4248
  if (key === 'props' && ctx.input) {
@@ -4260,6 +4289,7 @@
4260
4289
  if (ctx.deleted) return;
4261
4290
  var id = ctx.id,
4262
4291
  field = ctx.field,
4292
+ input = ctx.input,
4263
4293
  name = ctx.name;
4264
4294
 
4265
4295
  if (ctx.input) {
@@ -4273,40 +4303,26 @@
4273
4303
  $del(this.$render.tempList, id);
4274
4304
  $del(this.$render.orgChildren, id);
4275
4305
  $del(this.vm.ctxInject, id);
4306
+ $del(this.formData, id);
4307
+ $del(this.subForm, id);
4276
4308
  $del(ctx, 'cacheValue');
4277
- var f = this.fieldCtx[field];
4278
- var flag = false;
4279
-
4280
- if (field && (!f || f === ctx)) {
4281
- $del(this.formData, field);
4282
- $del(this.form, field);
4283
- $del(this.fieldCtx, field);
4284
- $del(this.subForm, field);
4285
- flag = true;
4286
- }
4287
-
4288
- if (name && this.nameCtx[name] === ctx) {
4289
- $del(this.nameCtx, name);
4290
- }
4291
-
4292
- if (!this.reloading) {
4293
- if (ctx.parser.loadChildren !== false) {
4294
- this.deferSyncValue(function () {
4309
+ input && this.rmIdCtx(ctx, field, 'field');
4310
+ name && this.rmIdCtx(ctx, name, 'name');
4311
+ this.deferSyncValue(function () {
4312
+ if (!_this3.reloading) {
4313
+ if (ctx.parser.loadChildren !== false) {
4295
4314
  if (is.trueArray(ctx.rule.children)) {
4296
4315
  ctx.rule.children.forEach(function (h) {
4297
4316
  return h.__fc__ && _this3.rmCtx(h.__fc__);
4298
4317
  });
4299
4318
  }
4319
+ }
4300
4320
 
4301
- _this3.syncValue();
4302
- });
4303
- }
4304
-
4305
- if (ctx.root === this.rules) {
4306
- this.vm._renderRule();
4321
+ if (ctx.root === _this3.rules) {
4322
+ _this3.vm._renderRule();
4323
+ }
4307
4324
  }
4308
- }
4309
-
4325
+ }, input);
4310
4326
  var index = this.sort.indexOf(id);
4311
4327
 
4312
4328
  if (index > -1) {
@@ -4316,7 +4332,7 @@
4316
4332
  this.$render.clearCache(ctx);
4317
4333
  ctx["delete"]();
4318
4334
  this.effect(ctx, 'deleted');
4319
- flag && this.vm.$emit('removeField', field, ctx.rule, this.api);
4335
+ input && !this.fieldCtx[field] && this.vm.$emit('removeField', field, ctx.rule, this.api);
4320
4336
  ctx.rule.__ctrl || this.vm.$emit('removeRule', ctx.rule, this.api);
4321
4337
  return ctx;
4322
4338
  }
@@ -4521,14 +4537,12 @@
4521
4537
  extend(Handler.prototype, {
4522
4538
  initData: function initData(rules) {
4523
4539
  extend(this, {
4524
- fieldCtx: {},
4525
4540
  ctxs: {},
4541
+ fieldCtx: {},
4526
4542
  nameCtx: {},
4527
4543
  sort: [],
4528
- rules: rules,
4529
- repeatRule: []
4544
+ rules: rules
4530
4545
  });
4531
- useHelper(rules);
4532
4546
  },
4533
4547
  init: function init() {
4534
4548
  this.appendData = _objectSpread2(_objectSpread2(_objectSpread2({}, this.fc.options.formData || {}), this.vm.value || {}), this.appendData);
@@ -5530,7 +5544,7 @@
5530
5544
  props: _objectSpread2(_objectSpread2({
5531
5545
  labelWidth: labelWidth
5532
5546
  }, rule.wrap || {}), {}, {
5533
- prop: ctx.field,
5547
+ prop: ctx.id,
5534
5548
  rules: rule.validate
5535
5549
  }),
5536
5550
  "class": rule.className,
@@ -5841,13 +5855,14 @@
5841
5855
  }
5842
5856
  },
5843
5857
  validateField: function validateField(field, callback) {
5844
- if (!h.fieldCtx[field]) return;
5845
- var sub = h.subForm[field];
5858
+ var ctx = h.getFieldCtx(field);
5859
+ if (!ctx) return;
5860
+ var sub = h.subForm[ctx.id];
5846
5861
  var len = 0;
5847
5862
  var flag;
5848
5863
 
5849
5864
  var validate = function validate() {
5850
- h.$manager.validateField(field, function () {
5865
+ h.$manager.validateField(ctx.id, function () {
5851
5866
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
5852
5867
  args[_key3] = arguments[_key3];
5853
5868
  }
@@ -5897,23 +5912,25 @@
5897
5912
  var clearSub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5898
5913
  api.helper.tidyFields(fields).forEach(function (field) {
5899
5914
  if (clearSub) _this.clearSubValidateState(field);
5900
- var ctx = h.fieldCtx[field];
5901
- if (!ctx) return;
5902
- h.$manager.clearValidateState(ctx);
5915
+ h.getCtxs(field).forEach(function (ctx) {
5916
+ h.$manager.clearValidateState(ctx);
5917
+ });
5903
5918
  });
5904
5919
  },
5905
5920
  clearSubValidateState: function clearSubValidateState(fields) {
5906
5921
  api.helper.tidyFields(fields).forEach(function (field) {
5907
- var subForm = h.subForm[field];
5908
- if (!subForm) return;
5922
+ h.getCtxs(field).forEach(function (ctx) {
5923
+ var subForm = h.subForm[ctx.id];
5924
+ if (!subForm) return;
5909
5925
 
5910
- if (Array.isArray(subForm)) {
5911
- subForm.forEach(function (form) {
5912
- form.clearValidateState();
5913
- });
5914
- } else if (subForm) {
5915
- subForm.clearValidateState();
5916
- }
5926
+ if (Array.isArray(subForm)) {
5927
+ subForm.forEach(function (form) {
5928
+ form.clearValidateState();
5929
+ });
5930
+ } else if (subForm) {
5931
+ subForm.clearValidateState();
5932
+ }
5933
+ });
5917
5934
  });
5918
5935
  },
5919
5936
  btn: {
@@ -6016,7 +6033,7 @@
6016
6033
  function ivuFormCreate() {
6017
6034
  return FormCreateFactory({
6018
6035
  ui: "".concat("view-design"),
6019
- version: "".concat("2.5.10"),
6036
+ version: "".concat("2.5.11"),
6020
6037
  manager: manager,
6021
6038
  install: install,
6022
6039
  extendApi: extendApi,