@form-create/element-ui 3.2.2 → 3.2.4

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 v3.2.2
2
+ * @form-create/element-ui v3.2.4
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1624,7 +1624,7 @@ var Group = defineComponent({
1624
1624
  var _this2 = this;
1625
1625
 
1626
1626
  n = n || [];
1627
- var keys = Object.keys(this.sort),
1627
+ var keys = this.sort,
1628
1628
  total = keys.length,
1629
1629
  len = total - n.length;
1630
1630
 
@@ -2274,7 +2274,13 @@ function $FormCreate(FormCreate, components, directives) {
2274
2274
  });
2275
2275
  watch(modelValue, function (n) {
2276
2276
  if (JSON.stringify(n || {}) === data.updateValue) return;
2277
- fapi.config.forceCoverValue ? fapi.coverValue(n || {}) : fapi.setValue(n || {});
2277
+
2278
+ if (fapi.config.forceCoverValue) {
2279
+ fc.$handle.appendData = {};
2280
+ fapi.coverValue(n || {});
2281
+ } else {
2282
+ fapi.setValue(n || {});
2283
+ }
2278
2284
  }, {
2279
2285
  deep: true
2280
2286
  });
@@ -2644,6 +2650,7 @@ function toProps(rule) {
2644
2650
  prop.key = rule.key;
2645
2651
  prop.ref = rule.ref;
2646
2652
  prop["class"] = rule["class"];
2653
+ prop.id = rule.id;
2647
2654
  prop.style = rule.style;
2648
2655
  if (prop.slot) delete prop.slot;
2649
2656
  return prop;
@@ -2876,9 +2883,9 @@ function fetch$1(option) {
2876
2883
  });
2877
2884
  xhr.send(formData);
2878
2885
  }
2879
- function asyncFetch(config) {
2886
+ function asyncFetch(config, _fetch) {
2880
2887
  return new Promise(function (resolve, reject) {
2881
- fetch$1(_objectSpread2(_objectSpread2({}, config), {}, {
2888
+ (_fetch || fetch$1)(_objectSpread2(_objectSpread2({}, config), {}, {
2882
2889
  onSuccess: function onSuccess(res) {
2883
2890
  var fn = function fn(v) {
2884
2891
  return v;
@@ -3439,8 +3446,24 @@ function Api(h) {
3439
3446
  bus: h.bus,
3440
3447
  fetch: function fetch(opt) {
3441
3448
  return new Promise(function (resolve, reject) {
3449
+ opt = deepCopy(opt);
3450
+ opt = h.loadFetchVar(opt);
3442
3451
  h.beforeFetch(opt).then(function () {
3443
- return asyncFetch(opt).then(resolve)["catch"](reject);
3452
+ return asyncFetch(opt, h.fc.create.fetch).then(resolve)["catch"](reject);
3453
+ });
3454
+ });
3455
+ },
3456
+ watchFetch: function watchFetch(opt, callback, error) {
3457
+ return h.fc.watchLoadData(function (get, change) {
3458
+ var _opt = deepCopy(opt);
3459
+
3460
+ _opt = h.loadFetchVar(_opt, get);
3461
+ h.beforeFetch(_opt).then(function () {
3462
+ return asyncFetch(_opt, h.fc.create.fetch).then(function (res) {
3463
+ callback && callback(res, change);
3464
+ })["catch"](function (e) {
3465
+ error && error(e);
3466
+ });
3444
3467
  });
3445
3468
  });
3446
3469
  },
@@ -4532,7 +4555,6 @@ extend(RuleContext.prototype, {
4532
4555
  this.$handle.watchCtx(this);
4533
4556
  },
4534
4557
  "delete": function _delete() {
4535
- var undef = void 0;
4536
4558
  this.unwatch();
4537
4559
  this.unlink();
4538
4560
  this.rmCtrl();
@@ -4543,13 +4565,7 @@ extend(RuleContext.prototype, {
4543
4565
 
4544
4566
  extend(this, {
4545
4567
  deleted: true,
4546
- prop: _objectSpread2({}, this.rule),
4547
4568
  computed: {},
4548
- el: undef,
4549
- $handle: undef,
4550
- $api: undef,
4551
- vm: undef,
4552
- vNode: undef,
4553
4569
  parent: null,
4554
4570
  children: [],
4555
4571
  cacheConfig: null,
@@ -4776,18 +4792,15 @@ function useLoader(Handler) {
4776
4792
  if (isInit) {
4777
4793
  ctx = _rule.__fc__;
4778
4794
  defaultValue = ctx.defaultValue;
4779
- var check = !ctx.check(_this6);
4780
4795
 
4781
4796
  if (ctx.deleted) {
4782
- if (check) {
4783
- if (isCtrl(ctx)) {
4784
- return;
4785
- }
4786
-
4787
- ctx.update(_this6);
4797
+ if (isCtrl(ctx)) {
4798
+ return;
4788
4799
  }
4800
+
4801
+ ctx.update(_this6);
4789
4802
  } else {
4790
- if (check) {
4803
+ if (!ctx.check(_this6)) {
4791
4804
  if (isCtrl(ctx)) {
4792
4805
  return;
4793
4806
  }
@@ -5459,6 +5472,8 @@ function useContext(Handler) {
5459
5472
  }
5460
5473
 
5461
5474
  Object.keys(computed).forEach(function (k) {
5475
+ var _val = deepGet(ctx.rule, k);
5476
+
5462
5477
  ctx.watch.push(watch(function () {
5463
5478
  var item = computed[k];
5464
5479
  if (!item) return undefined;
@@ -5489,7 +5504,7 @@ function useContext(Handler) {
5489
5504
  } else if (!condition[one.condition]) {
5490
5505
  flag = false;
5491
5506
  } else {
5492
- flag = new Function('_$', '_$val', 'top', 'group', "with(top){with(this){with(group){ return _$['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '_$val', "); }}}")).call(_this.api.form, condition, one.value, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
5507
+ flag = new Function('_$', '_$val', '$form', '_group', "with($form){with(this){with(_group){ return _$['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '_$val', "); }}}")).call(_this.api.form, condition, one.value, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
5493
5508
  }
5494
5509
 
5495
5510
  if (or && flag) {
@@ -5513,7 +5528,7 @@ function useContext(Handler) {
5513
5528
  var _group = ctx.getParentGroup();
5514
5529
 
5515
5530
  fn = function fn() {
5516
- return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, _group ? _this.subRuleData[_group.id] || {} : {}, ctx.rule, _this.api);
5531
+ return new Function('_formulas', '$form', '_group', '$rule', '$api', "with($form){with(this){with(_group){with(_formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, _group ? _this.subRuleData[_group.id] || {} : {}, ctx.rule, _this.api);
5517
5532
  };
5518
5533
  }
5519
5534
 
@@ -5529,7 +5544,7 @@ function useContext(Handler) {
5529
5544
  }
5530
5545
  });
5531
5546
  }, {
5532
- immediate: true
5547
+ immediate: _val == null || _val === ''
5533
5548
  }));
5534
5549
  });
5535
5550
  });
@@ -6653,14 +6668,19 @@ function FormCreateFactory(config) {
6653
6668
  }
6654
6669
 
6655
6670
  function setDriver(name, driver) {
6671
+ var parent = drivers[name] || {};
6672
+ var parsers = parent.parsers || {};
6673
+
6656
6674
  if (driver.parsers) {
6657
6675
  Object.keys(driver.parsers).forEach(function (k) {
6658
- driver.parsers[k] = setPrototypeOf(driver.parsers[k], BaseParser);
6676
+ parsers[k] = setPrototypeOf(driver.parsers[k], BaseParser);
6659
6677
  });
6660
6678
  }
6661
6679
 
6662
6680
  driver.name = name;
6663
- drivers[name] = driver;
6681
+ drivers[name] = _objectSpread2(_objectSpread2(_objectSpread2({}, parent), driver), {}, {
6682
+ parsers: parsers
6683
+ });
6664
6684
  }
6665
6685
 
6666
6686
  function refreshData(id) {
@@ -7190,6 +7210,16 @@ function FormCreateFactory(config) {
7190
7210
 
7191
7211
  var FcComponent = $form();
7192
7212
  setPrototypeOf(FcComponent, create);
7213
+ Object.defineProperties(FcComponent, {
7214
+ fetch: {
7215
+ get: function get() {
7216
+ return create.fetch;
7217
+ },
7218
+ set: function set(val) {
7219
+ create.fetch = val;
7220
+ }
7221
+ }
7222
+ });
7193
7223
  FcComponent.util = create;
7194
7224
  return FcComponent;
7195
7225
  }
@@ -8074,7 +8104,7 @@ function install(FormCreate) {
8074
8104
  function elmFormCreate() {
8075
8105
  return FormCreateFactory({
8076
8106
  ui: 'element-ui',
8077
- version: '3.2.2',
8107
+ version: '3.2.4',
8078
8108
  manager: manager,
8079
8109
  extendApi: extendApi,
8080
8110
  install: install,