@form-create/element-ui 2.5.36 → 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.36
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
  }]));
@@ -2536,7 +2523,7 @@
2536
2523
  if (!ctx) return initial;
2537
2524
  initial[ctx.field] = copy(ctx.rule.value);
2538
2525
  return initial;
2539
- }, h.options.appendValue ? copy(h.appendData) : {});
2526
+ }, h.options.appendValue !== false ? copy(h.appendData) : {});
2540
2527
  },
2541
2528
  getValue: function getValue(field) {
2542
2529
  var ctx = h.getFieldCtx(field);
@@ -2883,15 +2870,17 @@
2883
2870
  h.deferSyncValue(fn, sync);
2884
2871
  },
2885
2872
  fetch: function fetch(opt) {
2886
- h.options.beforeFetch && invoke(function () {
2887
- return h.options.beforeFetch(opt, {
2888
- api: api
2873
+ return new Promise(function (resolve, reject) {
2874
+ h.beforeFetch(opt).then(function () {
2875
+ return asyncFetch(opt).then(resolve)["catch"](reject);
2889
2876
  });
2890
2877
  });
2891
- return asyncFetch(opt);
2892
2878
  },
2893
2879
  getData: function getData(id, def) {
2894
- return hasProperty(h.fc.loadData, id) ? h.fc.loadData[id] : def;
2880
+ return h.fc.getData(id, def);
2881
+ },
2882
+ setData: function setData(id, data) {
2883
+ return h.fc.setData(id, data);
2895
2884
  },
2896
2885
  helper: {
2897
2886
  tidyFields: tidyFields,
@@ -3331,8 +3320,8 @@
3331
3320
  }
3332
3321
  }];
3333
3322
  if (ctx.input) {
3334
- if (this.vm.$props.disabled !== undefined) {
3335
- ctx.prop.props.disabled = !!this.vm.$props.disabled;
3323
+ if (this.vm.$props.disabled === true) {
3324
+ ctx.prop.props.disabled = true;
3336
3325
  }
3337
3326
  ctx.prop.model = {
3338
3327
  value: this.$handle.getFormData(ctx),
@@ -4213,7 +4202,7 @@
4213
4202
  handle.configurable = true;
4214
4203
  initial[field] = handle;
4215
4204
  return initial;
4216
- }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4205
+ }, this.options.appendValue !== false ? Object.keys(this.appendData).reduce(function (initial, field) {
4217
4206
  initial[field] = {
4218
4207
  enumerable: true,
4219
4208
  configurable: true,
@@ -4269,7 +4258,7 @@
4269
4258
  if (this.deferSyncFn) {
4270
4259
  return this.deferSyncFn.sync = true;
4271
4260
  }
4272
- 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));
4273
4262
  },
4274
4263
  isChange: function isChange(ctx, value) {
4275
4264
  return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
@@ -4758,6 +4747,21 @@
4758
4747
  this.$manager.__init();
4759
4748
  this.lifecycle('created');
4760
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
+ });
4761
4765
  }
4762
4766
  });
4763
4767
  useInject(Handler);
@@ -4926,7 +4930,7 @@
4926
4930
  var value = undefined;
4927
4931
  if (attr.attr) {
4928
4932
  value = fc.loadData[attr.attr] || attr["default"];
4929
- if (attr.copy) {
4933
+ if (attr.copy !== false) {
4930
4934
  value = deepCopy(value);
4931
4935
  }
4932
4936
  }
@@ -5029,7 +5033,7 @@
5029
5033
  onSuccess: function onSuccess(body, flag) {
5030
5034
  if (check()) return;
5031
5035
  var fn = function fn(v) {
5032
- return flag ? v : v.data;
5036
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
5033
5037
  };
5034
5038
  if (is.Function(option.parse)) {
5035
5039
  fn = option.parse;
@@ -5054,25 +5058,24 @@
5054
5058
  })(e, rule, api);
5055
5059
  }
5056
5060
  });
5057
- fc.options.beforeFetch && invoke(function () {
5058
- return fc.options.beforeFetch(config, {
5059
- rule: rule,
5060
- api: api
5061
- });
5062
- });
5063
- if (is.Function(option.action)) {
5064
- option.action(rule, api).then(function (val) {
5065
- config.onSuccess(val, true);
5066
- })["catch"](function (e) {
5067
- config.onError(e);
5068
- });
5069
- return;
5070
- }
5071
- invoke(function () {
5072
- return fc.create.fetch(config, {
5073
- inject: inject,
5074
- rule: rule,
5075
- 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
+ });
5076
5079
  });
5077
5080
  });
5078
5081
  }
@@ -5292,6 +5295,9 @@
5292
5295
  loadData[id] = data;
5293
5296
  _emitData(id);
5294
5297
  }
5298
+ function getData(id, def) {
5299
+ return hasProperty(loadData, id) ? loadData[id] : def;
5300
+ }
5295
5301
  function removeData(id) {
5296
5302
  delete loadData[id];
5297
5303
  _emitData(id);
@@ -5345,6 +5351,8 @@
5345
5351
  components: components,
5346
5352
  directives: directives
5347
5353
  },
5354
+ setData: setData,
5355
+ getData: getData,
5348
5356
  loadData: loadData,
5349
5357
  CreateNode: CreateNode,
5350
5358
  bus: new _vue(),
@@ -5463,6 +5471,7 @@
5463
5471
  version: config.version,
5464
5472
  ui: config.ui,
5465
5473
  setData: setData,
5474
+ getData: getData,
5466
5475
  removeData: removeData,
5467
5476
  maker: maker,
5468
5477
  component: component,
@@ -6272,7 +6281,7 @@
6272
6281
  function elmFormCreate() {
6273
6282
  return FormCreateFactory({
6274
6283
  ui: "".concat("element-ui"),
6275
- version: "".concat("2.5.36"),
6284
+ version: "".concat("2.5.37"),
6276
6285
  manager: manager,
6277
6286
  extendApi: extendApi,
6278
6287
  install: install,