@form-create/element-ui 2.5.35 → 2.5.37

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.35
2
+ * @form-create/element-ui v2.5.37
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1481,14 +1481,6 @@
1481
1481
  },
1482
1482
  deep: true
1483
1483
  },
1484
- disabled: function disabled(n) {
1485
- if (this.syncDisabled) {
1486
- var lst = this.cacheRule;
1487
- Object.keys(lst).forEach(function (k) {
1488
- lst[k].$f.disabled(n);
1489
- });
1490
- }
1491
- },
1492
1484
  expand: function expand(n) {
1493
1485
  var d = n - this.value.length;
1494
1486
  if (d > 0) {
@@ -1593,9 +1585,6 @@
1593
1585
  var _this5 = this;
1594
1586
  this.cacheRule[key].$f = $f;
1595
1587
  this.$nextTick(function () {
1596
- if (_this5.syncDisabled) {
1597
- $f.disabled(_this5.disabled);
1598
- }
1599
1588
  _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1600
1589
  });
1601
1590
  },
@@ -1767,6 +1756,7 @@
1767
1756
  }
1768
1757
  }, {}, {
1769
1758
  "props": {
1759
+ disabled: disabled,
1770
1760
  inFor: true,
1771
1761
  value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
1772
1762
  rule: rule,
@@ -1819,9 +1809,6 @@
1819
1809
  };
1820
1810
  },
1821
1811
  watch: {
1822
- disabled: function disabled(n) {
1823
- this.syncDisabled && this.cacheRule.$f.disabled(n);
1824
- },
1825
1812
  value: function value(n) {
1826
1813
  this.setValue(n);
1827
1814
  }
@@ -1855,7 +1842,6 @@
1855
1842
  var _this = this;
1856
1843
  this.cacheRule.$f = $f;
1857
1844
  this.$nextTick(function () {
1858
- _this.syncDisabled && $f.disabled(_this.disabled);
1859
1845
  _this.$emit('itemMounted', $f);
1860
1846
  });
1861
1847
  },
@@ -1886,6 +1872,7 @@
1886
1872
  "props": {
1887
1873
  rule: rule,
1888
1874
  option: options,
1875
+ disabled: this.disabled,
1889
1876
  extendOption: true
1890
1877
  }
1891
1878
  }]));
@@ -1935,7 +1922,10 @@
1935
1922
  }
1936
1923
  },
1937
1924
  extendOption: Boolean,
1938
- disabled: Boolean,
1925
+ disabled: {
1926
+ type: Boolean,
1927
+ "default": undefined
1928
+ },
1939
1929
  value: Object,
1940
1930
  api: Object,
1941
1931
  name: String,
@@ -1998,8 +1988,8 @@
1998
1988
  this.formCreate.$handle.reloadRule(n);
1999
1989
  this._renderRule();
2000
1990
  },
2001
- disabled: function disabled(n) {
2002
- this.$f.disabled(!!n);
1991
+ disabled: function disabled() {
1992
+ this.$f.refresh();
2003
1993
  }
2004
1994
  },
2005
1995
  beforeCreate: function beforeCreate() {
@@ -2144,7 +2134,7 @@
2144
2134
  var $TX = '$FNX:';
2145
2135
  var FUNCTION = 'function';
2146
2136
  function toJson(obj, space) {
2147
- return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2137
+ return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
2148
2138
  if (val && val._isVue === true) return undefined;
2149
2139
  if (_typeof(val) !== FUNCTION) {
2150
2140
  return val;
@@ -2255,6 +2245,61 @@
2255
2245
  }
2256
2246
  return def;
2257
2247
  }
2248
+ var changeType = function changeType(a, b) {
2249
+ if (typeof a === 'string') {
2250
+ return String(b);
2251
+ } else if (typeof a === 'number') {
2252
+ return Number(b);
2253
+ }
2254
+ return b;
2255
+ };
2256
+ var condition = {
2257
+ '==': function _(a, b) {
2258
+ return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2259
+ },
2260
+ '!=': function _(a, b) {
2261
+ return !condition['=='](a, b);
2262
+ },
2263
+ '>': function _(a, b) {
2264
+ return a > b;
2265
+ },
2266
+ '>=': function _(a, b) {
2267
+ return a >= b;
2268
+ },
2269
+ '<': function _(a, b) {
2270
+ return a < b;
2271
+ },
2272
+ '<=': function _(a, b) {
2273
+ return a <= b;
2274
+ },
2275
+ on: function on(a, b) {
2276
+ return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2277
+ },
2278
+ notOn: function notOn(a, b) {
2279
+ return !condition.on(a, b);
2280
+ },
2281
+ "in": function _in(a, b) {
2282
+ return b && b.indexOf && b.indexOf(a) > -1;
2283
+ },
2284
+ notIn: function notIn(a, b) {
2285
+ return !condition["in"](a, b);
2286
+ },
2287
+ between: function between(a, b) {
2288
+ return a > b[0] && a < b[1];
2289
+ },
2290
+ notBetween: function notBetween(a, b) {
2291
+ return a < b[0] || a > b[1];
2292
+ },
2293
+ empty: function empty(a) {
2294
+ return is.empty(a);
2295
+ },
2296
+ notEmpty: function notEmpty(a) {
2297
+ return !is.empty(a);
2298
+ },
2299
+ pattern: function pattern(a, b) {
2300
+ return new RegExp(b, 'g').test(a);
2301
+ }
2302
+ };
2258
2303
 
2259
2304
  function baseRule() {
2260
2305
  return {
@@ -2336,6 +2381,92 @@
2336
2381
  };
2337
2382
  }
2338
2383
 
2384
+ function getError(action, option, xhr) {
2385
+ var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
2386
+ var err = new Error(msg);
2387
+ err.status = xhr.status;
2388
+ err.url = action;
2389
+ return err;
2390
+ }
2391
+ function getBody(xhr) {
2392
+ var text = xhr.responseText || xhr.response;
2393
+ if (!text) {
2394
+ return text;
2395
+ }
2396
+ try {
2397
+ return JSON.parse(text);
2398
+ } catch (e) {
2399
+ return text;
2400
+ }
2401
+ }
2402
+ function fetch(option) {
2403
+ if (typeof XMLHttpRequest === 'undefined') {
2404
+ return;
2405
+ }
2406
+ var xhr = new XMLHttpRequest();
2407
+ var action = option.action;
2408
+ xhr.onerror = function error(e) {
2409
+ option.onError(e);
2410
+ };
2411
+ xhr.onload = function onload() {
2412
+ if (xhr.status < 200 || xhr.status >= 300) {
2413
+ return option.onError(getError(action, option, xhr), getBody(xhr));
2414
+ }
2415
+ option.onSuccess(getBody(xhr));
2416
+ };
2417
+ xhr.open(option.method || 'get', action, true);
2418
+ var formData;
2419
+ if (option.data) {
2420
+ if ((option.dataType || '').toLowerCase() !== 'json') {
2421
+ formData = new FormData();
2422
+ Object.keys(option.data).map(function (key) {
2423
+ formData.append(key, option.data[key]);
2424
+ });
2425
+ } else {
2426
+ formData = JSON.stringify(option.data);
2427
+ xhr.setRequestHeader('content-type', 'application/json');
2428
+ }
2429
+ }
2430
+ if (option.withCredentials && 'withCredentials' in xhr) {
2431
+ xhr.withCredentials = true;
2432
+ }
2433
+ var headers = option.headers || {};
2434
+ Object.keys(headers).forEach(function (item) {
2435
+ if (headers[item] !== null) {
2436
+ xhr.setRequestHeader(item, headers[item]);
2437
+ }
2438
+ });
2439
+ xhr.send(formData);
2440
+ }
2441
+ function asyncFetch(config) {
2442
+ return new Promise(function (resolve, reject) {
2443
+ fetch(_objectSpread2(_objectSpread2({}, config), {}, {
2444
+ onSuccess: function onSuccess(res) {
2445
+ var fn = function fn(v) {
2446
+ return v;
2447
+ };
2448
+ var parse = parseFn(config.parse);
2449
+ if (is.Function(parse)) {
2450
+ fn = parse;
2451
+ } else if (parse && is.String(parse)) {
2452
+ fn = function fn(v) {
2453
+ parse.split('.').forEach(function (k) {
2454
+ if (v) {
2455
+ v = v[k];
2456
+ }
2457
+ });
2458
+ return v;
2459
+ };
2460
+ }
2461
+ resolve(fn(res));
2462
+ },
2463
+ onError: function onError(err) {
2464
+ reject(err);
2465
+ }
2466
+ }));
2467
+ });
2468
+ }
2469
+
2339
2470
  function copy(value) {
2340
2471
  return deepCopy(value);
2341
2472
  }
@@ -2392,7 +2523,7 @@
2392
2523
  if (!ctx) return initial;
2393
2524
  initial[ctx.field] = copy(ctx.rule.value);
2394
2525
  return initial;
2395
- }, h.options.appendValue ? copy(h.appendData) : {});
2526
+ }, h.options.appendValue !== false ? copy(h.appendData) : {});
2396
2527
  },
2397
2528
  getValue: function getValue(field) {
2398
2529
  var ctx = h.getFieldCtx(field);
@@ -2617,6 +2748,21 @@
2617
2748
  return origin ? ctx.origin : ctx.rule;
2618
2749
  }
2619
2750
  },
2751
+ getRenderRule: function getRenderRule(id) {
2752
+ var ctx = h.getCtx(id);
2753
+ if (ctx) {
2754
+ return ctx.prop;
2755
+ }
2756
+ },
2757
+ getRefRule: function getRefRule(id) {
2758
+ var ctxs = h.getCtxs(id);
2759
+ if (ctxs && ctxs.length) {
2760
+ var rules = ctxs.map(function (ctx) {
2761
+ return ctx.rule;
2762
+ });
2763
+ return rules.length === 1 ? rules[0] : rules;
2764
+ }
2765
+ },
2620
2766
  setEffect: function setEffect(id, attr, value) {
2621
2767
  var ctx = h.getCtx(id);
2622
2768
  if (ctx && attr) {
@@ -2723,12 +2869,25 @@
2723
2869
  deferSyncValue: function deferSyncValue(fn, sync) {
2724
2870
  h.deferSyncValue(fn, sync);
2725
2871
  },
2872
+ fetch: function fetch(opt) {
2873
+ return new Promise(function (resolve, reject) {
2874
+ h.beforeFetch(opt).then(function () {
2875
+ return asyncFetch(opt).then(resolve)["catch"](reject);
2876
+ });
2877
+ });
2878
+ },
2879
+ getData: function getData(id, def) {
2880
+ return h.fc.getData(id, def);
2881
+ },
2882
+ setData: function setData(id, data) {
2883
+ return h.fc.setData(id, data);
2884
+ },
2726
2885
  helper: {
2727
2886
  tidyFields: tidyFields,
2728
2887
  props: props
2729
2888
  }
2730
2889
  };
2731
- ['on', 'once', 'off', 'set'].forEach(function (n) {
2890
+ ['on', 'once', 'off', 'set', 'emit'].forEach(function (n) {
2732
2891
  api[n] = function () {
2733
2892
  var _h$vm2;
2734
2893
  (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
@@ -3114,6 +3273,7 @@
3114
3273
  children: [],
3115
3274
  prop: {},
3116
3275
  preview: false,
3276
+ id: ctx.id,
3117
3277
  field: ctx.field,
3118
3278
  rule: ctx.rule,
3119
3279
  input: ctx.input
@@ -3133,13 +3293,13 @@
3133
3293
  });
3134
3294
  return inject;
3135
3295
  },
3136
- ctxProp: function ctxProp(ctx, custom) {
3296
+ ctxProp: function ctxProp(ctx) {
3137
3297
  var _this8 = this;
3138
3298
  var ref = ctx.ref,
3139
3299
  key = ctx.key,
3140
3300
  rule = ctx.rule;
3141
- this.$manager.mergeProp(ctx, custom);
3142
- ctx.parser.mergeProp(ctx, custom);
3301
+ this.$manager.mergeProp(ctx);
3302
+ ctx.parser.mergeProp(ctx);
3143
3303
  var props = [{
3144
3304
  ref: ref,
3145
3305
  key: rule.key || "".concat(key, "fc"),
@@ -3159,7 +3319,10 @@
3159
3319
  }
3160
3320
  }
3161
3321
  }];
3162
- if (!custom && ctx.input) {
3322
+ if (ctx.input) {
3323
+ if (this.vm.$props.disabled === true) {
3324
+ ctx.prop.props.disabled = true;
3325
+ }
3163
3326
  ctx.prop.model = {
3164
3327
  value: this.$handle.getFormData(ctx),
3165
3328
  callback: function callback(value) {
@@ -3317,16 +3480,17 @@
3317
3480
  inject = rule.inject;
3318
3481
  var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
3319
3482
  if (is.trueArray(emit)) {
3320
- var emitKey = emitPrefix || field || name;
3321
- if (emitKey) {
3322
- if (!on) emitKey = "native-".concat(emitKey);
3323
- emit.forEach(function (eventName) {
3324
- if (!eventName) return;
3325
- var eventInject;
3326
- if (is.Object(eventName)) {
3327
- eventInject = eventName.inject;
3328
- eventName = eventName.name;
3329
- }
3483
+ emit.forEach(function (eventName) {
3484
+ if (!eventName) return;
3485
+ var eventInject;
3486
+ var emitKey = emitPrefix || field || name;
3487
+ if (is.Object(eventName)) {
3488
+ eventInject = eventName.inject;
3489
+ eventName = eventName.name;
3490
+ emitKey = eventName.prefix || emitKey;
3491
+ }
3492
+ if (emitKey) {
3493
+ if (!on) emitKey = "native-".concat(emitKey);
3330
3494
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3331
3495
  var fn = function fn() {
3332
3496
  var _this2$vm, _this2$vm2;
@@ -3343,8 +3507,8 @@
3343
3507
  var _inject = eventInject || inject || _this2.options.injectEvent;
3344
3508
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3345
3509
  }
3346
- });
3347
- }
3510
+ }
3511
+ });
3348
3512
  }
3349
3513
  ctx.computed[on ? 'on' : 'nativeOn'] = event;
3350
3514
  return event;
@@ -3520,6 +3684,30 @@
3520
3684
  return _this.payload[k];
3521
3685
  })), [this.computed]));
3522
3686
  },
3687
+ injectValidate: function injectValidate() {
3688
+ var _this2 = this;
3689
+ return toArray(this.prop.validate).map(function (item) {
3690
+ if (is.Function(item.validator)) {
3691
+ var temp = _objectSpread2({}, item);
3692
+ var that = _this2;
3693
+ temp.validator = function () {
3694
+ var _item$validator;
3695
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3696
+ args[_key] = arguments[_key];
3697
+ }
3698
+ return (_item$validator = item.validator).call.apply(_item$validator, [{
3699
+ that: this,
3700
+ id: that.id,
3701
+ field: that.field,
3702
+ rule: that.rule,
3703
+ api: that.$handle.api
3704
+ }].concat(args));
3705
+ };
3706
+ return temp;
3707
+ }
3708
+ return item;
3709
+ });
3710
+ },
3523
3711
  check: function check(handle) {
3524
3712
  return this.vm === handle.vm;
3525
3713
  },
@@ -3568,12 +3756,12 @@
3568
3756
  this.ctrlRule = [];
3569
3757
  },
3570
3758
  rm: function rm() {
3571
- var _this2 = this;
3759
+ var _this3 = this;
3572
3760
  var _rm = function _rm() {
3573
- var index = _this2.root.indexOf(_this2.origin);
3761
+ var index = _this3.root.indexOf(_this3.origin);
3574
3762
  if (index > -1) {
3575
- _this2.root.splice(index, 1);
3576
- _this2.$handle && _this2.$handle.refresh();
3763
+ _this3.root.splice(index, 1);
3764
+ _this3.$handle && _this3.$handle.refresh();
3577
3765
  }
3578
3766
  };
3579
3767
  if (this.deleted) {
@@ -3581,14 +3769,14 @@
3581
3769
  return;
3582
3770
  }
3583
3771
  this.$handle.noWatch(function () {
3584
- _this2.$handle.deferSyncValue(function () {
3585
- _this2.rmCtrl();
3772
+ _this3.$handle.deferSyncValue(function () {
3773
+ _this3.rmCtrl();
3586
3774
  _rm();
3587
- _this2.$handle.rmCtx(_this2);
3588
- extend(_this2, {
3775
+ _this3.$handle.rmCtx(_this3);
3776
+ extend(_this3, {
3589
3777
  root: []
3590
3778
  });
3591
- }, _this2.input);
3779
+ }, _this3.input);
3592
3780
  });
3593
3781
  },
3594
3782
  update: function update(handle, init) {
@@ -3609,73 +3797,6 @@
3609
3797
  }
3610
3798
  });
3611
3799
 
3612
- var condition = {
3613
- '==': function _(b) {
3614
- return function (a) {
3615
- return a === b;
3616
- };
3617
- },
3618
- '!=': function _(b) {
3619
- return function (a) {
3620
- return a !== b;
3621
- };
3622
- },
3623
- '<>': function _(b) {
3624
- return function (a) {
3625
- return a !== b;
3626
- };
3627
- },
3628
- '>': function _(b) {
3629
- return function (a) {
3630
- return a > b;
3631
- };
3632
- },
3633
- '>=': function _(b) {
3634
- return function (a) {
3635
- return a >= b;
3636
- };
3637
- },
3638
- '<': function _(b) {
3639
- return function (a) {
3640
- return a < b;
3641
- };
3642
- },
3643
- '<=': function _(b) {
3644
- return function (a) {
3645
- return a <= b;
3646
- };
3647
- },
3648
- 'in': function _in(b) {
3649
- return function (a) {
3650
- return b && b.indexOf && b.indexOf(a) > -1;
3651
- };
3652
- },
3653
- 'on': function on(b) {
3654
- return function (a) {
3655
- return a && a.indexOf && a.indexOf(b) > -1;
3656
- };
3657
- },
3658
- 'notIn': function notIn(b) {
3659
- return function (a) {
3660
- return !condition["in"](b)(a);
3661
- };
3662
- },
3663
- 'notOn': function notOn(b) {
3664
- return function (a) {
3665
- return !condition.on(b)(a);
3666
- };
3667
- },
3668
- 'between': function between(b) {
3669
- return function (a) {
3670
- return a > b[0] && a < b[1];
3671
- };
3672
- },
3673
- 'notBetween': function notBetween(b) {
3674
- return function (a) {
3675
- return a < b[0] || a > b[1];
3676
- };
3677
- }
3678
- };
3679
3800
  function useLoader(Handler) {
3680
3801
  extend(Handler.prototype, {
3681
3802
  nextRefresh: function nextRefresh(fn) {
@@ -3827,7 +3948,7 @@
3827
3948
  }
3828
3949
  if (!ctx) {
3829
3950
  var _rule2 = _this6.parseRule(_rule);
3830
- ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
3951
+ ctx = new RuleContext(_this6, _rule2, defaultValue);
3831
3952
  _this6.bindParser(ctx);
3832
3953
  } else {
3833
3954
  if (ctx.originType !== ctx.rule.type) {
@@ -3880,7 +4001,9 @@
3880
4001
  if (!controls.length) return false;
3881
4002
  var _loop = function _loop(i) {
3882
4003
  var control = controls[i],
3883
- handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
4004
+ handleFn = control.handle || function (val) {
4005
+ return (condition[control.condition || '=='] || condition['=='])(val, control.value);
4006
+ };
3884
4007
  if (!is.trueArray(control.rule)) return "continue";
3885
4008
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
3886
4009
  valid: invoke(function () {
@@ -4042,6 +4165,11 @@
4042
4165
  this.valueChange(ctx, value);
4043
4166
  this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
4044
4167
  this.effect(ctx, 'value');
4168
+ this.emitEvent('change', ctx.field, value, {
4169
+ rule: ctx.origin,
4170
+ api: this.api,
4171
+ setFlag: setFlag || false
4172
+ });
4045
4173
  },
4046
4174
  onInput: function onInput(ctx, value) {
4047
4175
  var val;
@@ -4074,7 +4202,7 @@
4074
4202
  handle.configurable = true;
4075
4203
  initial[field] = handle;
4076
4204
  return initial;
4077
- }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4205
+ }, this.options.appendValue !== false ? Object.keys(this.appendData).reduce(function (initial, field) {
4078
4206
  initial[field] = {
4079
4207
  enumerable: true,
4080
4208
  configurable: true,
@@ -4130,7 +4258,7 @@
4130
4258
  if (this.deferSyncFn) {
4131
4259
  return this.deferSyncFn.sync = true;
4132
4260
  }
4133
- this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
4261
+ this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue !== false ? this.appendData : {}), this.form));
4134
4262
  },
4135
4263
  isChange: function isChange(ctx, value) {
4136
4264
  return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
@@ -4138,12 +4266,13 @@
4138
4266
  isQuote: function isQuote(ctx, value) {
4139
4267
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4140
4268
  },
4141
- refreshUpdate: function refreshUpdate(ctx, val, origin) {
4269
+ refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
4142
4270
  var _this4 = this;
4143
4271
  if (is.Function(ctx.rule.update)) {
4144
4272
  var state = invoke(function () {
4145
4273
  return ctx.rule.update(val, ctx.origin, _this4.api, {
4146
- origin: origin || 'change'
4274
+ origin: origin || 'change',
4275
+ linkField: field
4147
4276
  });
4148
4277
  });
4149
4278
  if (state === undefined) return;
@@ -4154,21 +4283,21 @@
4154
4283
  this.refreshRule(ctx, val);
4155
4284
  this.bus.$emit('change-' + ctx.field, val);
4156
4285
  },
4157
- refreshRule: function refreshRule(ctx, val, origin) {
4286
+ refreshRule: function refreshRule(ctx, val, origin, field) {
4158
4287
  if (this.refreshControl(ctx)) {
4159
4288
  this.$render.clearCacheAll();
4160
4289
  this.loadRule();
4161
4290
  this.vm.$emit('update', this.api);
4162
4291
  this.refresh();
4163
4292
  }
4164
- this.refreshUpdate(ctx, val, origin);
4293
+ this.refreshUpdate(ctx, val, origin, field);
4165
4294
  },
4166
4295
  appendLink: function appendLink(ctx) {
4167
4296
  var _this5 = this;
4168
4297
  var link = ctx.rule.link;
4169
4298
  is.trueArray(link) && link.forEach(function (field) {
4170
4299
  var fn = function fn() {
4171
- return _this5.refreshRule(ctx, ctx.rule.value, 'link');
4300
+ return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
4172
4301
  };
4173
4302
  _this5.bus.$on('change-' + field, fn);
4174
4303
  ctx.linkOn.push(function () {
@@ -4399,12 +4528,22 @@
4399
4528
  }
4400
4529
  },
4401
4530
  lifecycle: function lifecycle(name) {
4402
- var _this2 = this;
4403
- var fn = this.options[name];
4404
- is.Function(fn) && invoke(function () {
4405
- return fn(_this2.api);
4406
- });
4407
4531
  this.vm.$emit(name, this.api);
4532
+ this.emitEvent(name, this.api);
4533
+ },
4534
+ emitEvent: function emitEvent(name) {
4535
+ var _this$bus;
4536
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4537
+ args[_key - 1] = arguments[_key];
4538
+ }
4539
+ var _fn = this.options[name] || this.options[toCase('on-' + name)];
4540
+ if (_fn) {
4541
+ var fn = parseFn(_fn);
4542
+ is.Function(fn) && invoke(function () {
4543
+ return fn.apply(void 0, args);
4544
+ });
4545
+ }
4546
+ (_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
4408
4547
  }
4409
4548
  });
4410
4549
  }
@@ -4606,7 +4745,23 @@
4606
4745
  this.usePage();
4607
4746
  this.loadRule();
4608
4747
  this.$manager.__init();
4748
+ this.lifecycle('created');
4609
4749
  this.vm.$set(this.vm, 'formData', this.formData);
4750
+ },
4751
+ beforeFetch: function beforeFetch(opt) {
4752
+ var _this2 = this;
4753
+ return new Promise(function (resolve) {
4754
+ var source = _this2.options.beforeFetch && invoke(function () {
4755
+ return _this2.options.beforeFetch(opt, {
4756
+ api: _this2.api
4757
+ });
4758
+ });
4759
+ if (source && is.Function(source.then)) {
4760
+ source.then(resolve);
4761
+ } else {
4762
+ resolve();
4763
+ }
4764
+ });
4610
4765
  }
4611
4766
  });
4612
4767
  useInject(Handler);
@@ -4618,64 +4773,6 @@
4618
4773
  useLifecycle(Handler);
4619
4774
  useEffect(Handler);
4620
4775
 
4621
- function getError(action, option, xhr) {
4622
- var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
4623
- var err = new Error(msg);
4624
- err.status = xhr.status;
4625
- err.url = action;
4626
- return err;
4627
- }
4628
- function getBody(xhr) {
4629
- var text = xhr.responseText || xhr.response;
4630
- if (!text) {
4631
- return text;
4632
- }
4633
- try {
4634
- return JSON.parse(text);
4635
- } catch (e) {
4636
- return text;
4637
- }
4638
- }
4639
- function fetch(option) {
4640
- if (typeof XMLHttpRequest === 'undefined') {
4641
- return;
4642
- }
4643
- var xhr = new XMLHttpRequest();
4644
- var action = option.action;
4645
- xhr.onerror = function error(e) {
4646
- option.onError(e);
4647
- };
4648
- xhr.onload = function onload() {
4649
- if (xhr.status < 200 || xhr.status >= 300) {
4650
- return option.onError(getError(action, option, xhr), getBody(xhr));
4651
- }
4652
- option.onSuccess(getBody(xhr));
4653
- };
4654
- xhr.open(option.method || 'get', action, true);
4655
- var formData;
4656
- if (option.data) {
4657
- if ((option.dataType || '').toLowerCase() !== 'json') {
4658
- formData = new FormData();
4659
- Object.keys(option.data).map(function (key) {
4660
- formData.append(key, option.data[key]);
4661
- });
4662
- } else {
4663
- formData = JSON.stringify(option.data);
4664
- xhr.setRequestHeader('content-type', 'application/json');
4665
- }
4666
- }
4667
- if (option.withCredentials && 'withCredentials' in xhr) {
4668
- xhr.withCredentials = true;
4669
- }
4670
- var headers = option.headers || {};
4671
- Object.keys(headers).forEach(function (item) {
4672
- if (headers[item] !== null) {
4673
- xhr.setRequestHeader(item, headers[item]);
4674
- }
4675
- });
4676
- xhr.send(formData);
4677
- }
4678
-
4679
4776
  var NAME$9 = 'fcFragment';
4680
4777
  var fragment = {
4681
4778
  name: NAME$9,
@@ -4833,7 +4930,7 @@
4833
4930
  var value = undefined;
4834
4931
  if (attr.attr) {
4835
4932
  value = fc.loadData[attr.attr] || attr["default"];
4836
- if (attr.copy) {
4933
+ if (attr.copy !== false) {
4837
4934
  value = deepCopy(value);
4838
4935
  }
4839
4936
  }
@@ -4918,6 +5015,7 @@
4918
5015
  set(undefined);
4919
5016
  return;
4920
5017
  }
5018
+ option = deepCopy(option);
4921
5019
  if (!option.to) {
4922
5020
  option.to = 'options';
4923
5021
  }
@@ -4935,7 +5033,7 @@
4935
5033
  onSuccess: function onSuccess(body, flag) {
4936
5034
  if (check()) return;
4937
5035
  var fn = function fn(v) {
4938
- return flag ? v : v.data;
5036
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
4939
5037
  };
4940
5038
  if (is.Function(option.parse)) {
4941
5039
  fn = option.parse;
@@ -4960,25 +5058,24 @@
4960
5058
  })(e, rule, api);
4961
5059
  }
4962
5060
  });
4963
- fc.options.beforeFetch && invoke(function () {
4964
- return fc.options.beforeFetch(config, {
4965
- rule: rule,
4966
- api: api
4967
- });
4968
- });
4969
- if (is.Function(option.action)) {
4970
- option.action(rule, api).then(function (val) {
4971
- config.onSuccess(val, true);
4972
- })["catch"](function (e) {
4973
- config.onError(e);
4974
- });
4975
- return;
4976
- }
4977
- invoke(function () {
4978
- return fc.create.fetch(config, {
4979
- inject: inject,
4980
- rule: rule,
4981
- api: api
5061
+ fc.$handle.beforeFetch(config, {
5062
+ rule: rule,
5063
+ api: api
5064
+ }).then(function () {
5065
+ if (is.Function(option.action)) {
5066
+ option.action(rule, api).then(function (val) {
5067
+ config.onSuccess(val, true);
5068
+ })["catch"](function (e) {
5069
+ config.onError(e);
5070
+ });
5071
+ return;
5072
+ }
5073
+ invoke(function () {
5074
+ return fc.create.fetch(config, {
5075
+ inject: inject,
5076
+ rule: rule,
5077
+ api: api
5078
+ });
4982
5079
  });
4983
5080
  });
4984
5081
  }
@@ -4998,6 +5095,7 @@
4998
5095
  var val = parseVal(inject.getValue());
4999
5096
  if (val.required === false) {
5000
5097
  inject.clearProp();
5098
+ api.clearValidateState([rule.field]);
5001
5099
  } else {
5002
5100
  var validate = _objectSpread2({
5003
5101
  required: true,
@@ -5176,9 +5274,13 @@
5176
5274
  component = id;
5177
5275
  }
5178
5276
  if (!name || !component) return;
5277
+ var nameAlias = toCase(name);
5179
5278
  components[name] = component;
5279
+ components[nameAlias] = component;
5180
5280
  delete CreateNode.aliasMap[name];
5281
+ delete CreateNode.aliasMap[nameAlias];
5181
5282
  delete parsers[name];
5283
+ delete parsers[nameAlias];
5182
5284
  if (component.formCreateParser) parser(name, component.formCreateParser);
5183
5285
  }
5184
5286
  function _emitData(id) {
@@ -5193,6 +5295,9 @@
5193
5295
  loadData[id] = data;
5194
5296
  _emitData(id);
5195
5297
  }
5298
+ function getData(id, def) {
5299
+ return hasProperty(loadData, id) ? loadData[id] : def;
5300
+ }
5196
5301
  function removeData(id) {
5197
5302
  delete loadData[id];
5198
5303
  _emitData(id);
@@ -5246,6 +5351,8 @@
5246
5351
  components: components,
5247
5352
  directives: directives
5248
5353
  },
5354
+ setData: setData,
5355
+ getData: getData,
5249
5356
  loadData: loadData,
5250
5357
  CreateNode: CreateNode,
5251
5358
  bus: new _vue(),
@@ -5287,7 +5394,6 @@
5287
5394
  _this2.initOptions();
5288
5395
  }
5289
5396
  _this2.created();
5290
- vm.disabled && vm.$f.disabled(true);
5291
5397
  });
5292
5398
  vm.$on('hook:mounted', function () {
5293
5399
  _this2.mounted();
@@ -5365,6 +5471,7 @@
5365
5471
  version: config.version,
5366
5472
  ui: config.ui,
5367
5473
  setData: setData,
5474
+ getData: getData,
5368
5475
  removeData: removeData,
5369
5476
  maker: maker,
5370
5477
  component: component,
@@ -5759,8 +5866,7 @@
5759
5866
  ref: ref
5760
5867
  });
5761
5868
  extend(this.rule.props, {
5762
- model: $handle.formData,
5763
- rules: $handle.validate()
5869
+ model: $handle.formData
5764
5870
  });
5765
5871
  },
5766
5872
  render: function render(children) {
@@ -5784,7 +5890,7 @@
5784
5890
  label: isTitle ? rule.title.title : undefined
5785
5891
  }, rule.wrap || {}), {}, {
5786
5892
  prop: ctx.id,
5787
- rules: rule.validate
5893
+ rules: ctx.injectValidate()
5788
5894
  }),
5789
5895
  "class": rule.className,
5790
5896
  key: "".concat(uni, "fi"),
@@ -6175,7 +6281,7 @@
6175
6281
  function elmFormCreate() {
6176
6282
  return FormCreateFactory({
6177
6283
  ui: "".concat("element-ui"),
6178
- version: "".concat("2.5.35"),
6284
+ version: "".concat("2.5.37"),
6179
6285
  manager: manager,
6180
6286
  extendApi: extendApi,
6181
6287
  install: install,