@form-create/iview 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/iview v2.5.36
2
+ * @form-create/iview 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.
@@ -1473,14 +1473,6 @@
1473
1473
  },
1474
1474
  deep: true
1475
1475
  },
1476
- disabled: function disabled(n) {
1477
- if (this.syncDisabled) {
1478
- var lst = this.cacheRule;
1479
- Object.keys(lst).forEach(function (k) {
1480
- lst[k].$f.disabled(n);
1481
- });
1482
- }
1483
- },
1484
1476
  expand: function expand(n) {
1485
1477
  var d = n - this.value.length;
1486
1478
  if (d > 0) {
@@ -1585,9 +1577,6 @@
1585
1577
  var _this5 = this;
1586
1578
  this.cacheRule[key].$f = $f;
1587
1579
  this.$nextTick(function () {
1588
- if (_this5.syncDisabled) {
1589
- $f.disabled(_this5.disabled);
1590
- }
1591
1580
  _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1592
1581
  });
1593
1582
  },
@@ -1759,6 +1748,7 @@
1759
1748
  }
1760
1749
  }, {}, {
1761
1750
  "props": {
1751
+ disabled: disabled,
1762
1752
  inFor: true,
1763
1753
  value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
1764
1754
  rule: rule,
@@ -1811,9 +1801,6 @@
1811
1801
  };
1812
1802
  },
1813
1803
  watch: {
1814
- disabled: function disabled(n) {
1815
- this.syncDisabled && this.cacheRule.$f.disabled(n);
1816
- },
1817
1804
  value: function value(n) {
1818
1805
  this.setValue(n);
1819
1806
  }
@@ -1847,7 +1834,6 @@
1847
1834
  var _this = this;
1848
1835
  this.cacheRule.$f = $f;
1849
1836
  this.$nextTick(function () {
1850
- _this.syncDisabled && $f.disabled(_this.disabled);
1851
1837
  _this.$emit('itemMounted', $f);
1852
1838
  });
1853
1839
  },
@@ -1878,6 +1864,7 @@
1878
1864
  "props": {
1879
1865
  rule: rule,
1880
1866
  option: options,
1867
+ disabled: this.disabled,
1881
1868
  extendOption: true
1882
1869
  }
1883
1870
  }]));
@@ -2528,7 +2515,7 @@
2528
2515
  if (!ctx) return initial;
2529
2516
  initial[ctx.field] = copy(ctx.rule.value);
2530
2517
  return initial;
2531
- }, h.options.appendValue ? copy(h.appendData) : {});
2518
+ }, h.options.appendValue !== false ? copy(h.appendData) : {});
2532
2519
  },
2533
2520
  getValue: function getValue(field) {
2534
2521
  var ctx = h.getFieldCtx(field);
@@ -2875,15 +2862,17 @@
2875
2862
  h.deferSyncValue(fn, sync);
2876
2863
  },
2877
2864
  fetch: function fetch(opt) {
2878
- h.options.beforeFetch && invoke(function () {
2879
- return h.options.beforeFetch(opt, {
2880
- api: api
2865
+ return new Promise(function (resolve, reject) {
2866
+ h.beforeFetch(opt).then(function () {
2867
+ return asyncFetch(opt).then(resolve)["catch"](reject);
2881
2868
  });
2882
2869
  });
2883
- return asyncFetch(opt);
2884
2870
  },
2885
2871
  getData: function getData(id, def) {
2886
- return hasProperty(h.fc.loadData, id) ? h.fc.loadData[id] : def;
2872
+ return h.fc.getData(id, def);
2873
+ },
2874
+ setData: function setData(id, data) {
2875
+ return h.fc.setData(id, data);
2887
2876
  },
2888
2877
  helper: {
2889
2878
  tidyFields: tidyFields,
@@ -3323,8 +3312,8 @@
3323
3312
  }
3324
3313
  }];
3325
3314
  if (ctx.input) {
3326
- if (this.vm.$props.disabled !== undefined) {
3327
- ctx.prop.props.disabled = !!this.vm.$props.disabled;
3315
+ if (this.vm.$props.disabled === true) {
3316
+ ctx.prop.props.disabled = true;
3328
3317
  }
3329
3318
  ctx.prop.model = {
3330
3319
  value: this.$handle.getFormData(ctx),
@@ -4205,7 +4194,7 @@
4205
4194
  handle.configurable = true;
4206
4195
  initial[field] = handle;
4207
4196
  return initial;
4208
- }, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
4197
+ }, this.options.appendValue !== false ? Object.keys(this.appendData).reduce(function (initial, field) {
4209
4198
  initial[field] = {
4210
4199
  enumerable: true,
4211
4200
  configurable: true,
@@ -4261,7 +4250,7 @@
4261
4250
  if (this.deferSyncFn) {
4262
4251
  return this.deferSyncFn.sync = true;
4263
4252
  }
4264
- this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
4253
+ this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue !== false ? this.appendData : {}), this.form));
4265
4254
  },
4266
4255
  isChange: function isChange(ctx, value) {
4267
4256
  return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
@@ -4750,6 +4739,21 @@
4750
4739
  this.$manager.__init();
4751
4740
  this.lifecycle('created');
4752
4741
  this.vm.$set(this.vm, 'formData', this.formData);
4742
+ },
4743
+ beforeFetch: function beforeFetch(opt) {
4744
+ var _this2 = this;
4745
+ return new Promise(function (resolve) {
4746
+ var source = _this2.options.beforeFetch && invoke(function () {
4747
+ return _this2.options.beforeFetch(opt, {
4748
+ api: _this2.api
4749
+ });
4750
+ });
4751
+ if (source && is.Function(source.then)) {
4752
+ source.then(resolve);
4753
+ } else {
4754
+ resolve();
4755
+ }
4756
+ });
4753
4757
  }
4754
4758
  });
4755
4759
  useInject(Handler);
@@ -4918,7 +4922,7 @@
4918
4922
  var value = undefined;
4919
4923
  if (attr.attr) {
4920
4924
  value = fc.loadData[attr.attr] || attr["default"];
4921
- if (attr.copy) {
4925
+ if (attr.copy !== false) {
4922
4926
  value = deepCopy(value);
4923
4927
  }
4924
4928
  }
@@ -5021,7 +5025,7 @@
5021
5025
  onSuccess: function onSuccess(body, flag) {
5022
5026
  if (check()) return;
5023
5027
  var fn = function fn(v) {
5024
- return flag ? v : v.data;
5028
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
5025
5029
  };
5026
5030
  if (is.Function(option.parse)) {
5027
5031
  fn = option.parse;
@@ -5046,25 +5050,24 @@
5046
5050
  })(e, rule, api);
5047
5051
  }
5048
5052
  });
5049
- fc.options.beforeFetch && invoke(function () {
5050
- return fc.options.beforeFetch(config, {
5051
- rule: rule,
5052
- api: api
5053
- });
5054
- });
5055
- if (is.Function(option.action)) {
5056
- option.action(rule, api).then(function (val) {
5057
- config.onSuccess(val, true);
5058
- })["catch"](function (e) {
5059
- config.onError(e);
5060
- });
5061
- return;
5062
- }
5063
- invoke(function () {
5064
- return fc.create.fetch(config, {
5065
- inject: inject,
5066
- rule: rule,
5067
- api: api
5053
+ fc.$handle.beforeFetch(config, {
5054
+ rule: rule,
5055
+ api: api
5056
+ }).then(function () {
5057
+ if (is.Function(option.action)) {
5058
+ option.action(rule, api).then(function (val) {
5059
+ config.onSuccess(val, true);
5060
+ })["catch"](function (e) {
5061
+ config.onError(e);
5062
+ });
5063
+ return;
5064
+ }
5065
+ invoke(function () {
5066
+ return fc.create.fetch(config, {
5067
+ inject: inject,
5068
+ rule: rule,
5069
+ api: api
5070
+ });
5068
5071
  });
5069
5072
  });
5070
5073
  }
@@ -5284,6 +5287,9 @@
5284
5287
  loadData[id] = data;
5285
5288
  _emitData(id);
5286
5289
  }
5290
+ function getData(id, def) {
5291
+ return hasProperty(loadData, id) ? loadData[id] : def;
5292
+ }
5287
5293
  function removeData(id) {
5288
5294
  delete loadData[id];
5289
5295
  _emitData(id);
@@ -5337,6 +5343,8 @@
5337
5343
  components: components,
5338
5344
  directives: directives
5339
5345
  },
5346
+ setData: setData,
5347
+ getData: getData,
5340
5348
  loadData: loadData,
5341
5349
  CreateNode: CreateNode,
5342
5350
  bus: new _vue(),
@@ -5455,6 +5463,7 @@
5455
5463
  version: config.version,
5456
5464
  ui: config.ui,
5457
5465
  setData: setData,
5466
+ getData: getData,
5458
5467
  removeData: removeData,
5459
5468
  maker: maker,
5460
5469
  component: component,
@@ -6307,7 +6316,7 @@
6307
6316
  function ivuFormCreate() {
6308
6317
  return FormCreateFactory({
6309
6318
  ui: "".concat("iview"),
6310
- version: "".concat("2.5.36"),
6319
+ version: "".concat("2.5.37"),
6311
6320
  manager: manager,
6312
6321
  install: install,
6313
6322
  extendApi: extendApi,