@form-create/element-ui 3.1.33 → 3.1.34

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.1.33
2
+ * @form-create/element-ui v3.1.34
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1616,14 +1616,6 @@
1616
1616
  },
1617
1617
  deep: true
1618
1618
  },
1619
- disabled: function disabled(n) {
1620
- if (this.syncDisabled) {
1621
- var lst = this.cacheRule;
1622
- Object.keys(lst).forEach(function (k) {
1623
- lst[k].$f.disabled(n);
1624
- });
1625
- }
1626
- },
1627
1619
  expand: function expand(n) {
1628
1620
  var d = n - this.modelValue.length;
1629
1621
 
@@ -1745,10 +1737,6 @@
1745
1737
 
1746
1738
  this.cacheRule[key].$f = $f;
1747
1739
  vue.nextTick(function () {
1748
- if (_this5.syncDisabled) {
1749
- $f.disabled(_this5.disabled);
1750
- }
1751
-
1752
1740
  _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1753
1741
  });
1754
1742
  },
@@ -1919,6 +1907,7 @@
1919
1907
  }, [vue.createVNode(Type, vue.mergeProps({
1920
1908
  "key": key
1921
1909
  }, {
1910
+ disabled: disabled,
1922
1911
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
1923
1912
  return _this12.formData(key, formData);
1924
1913
  },
@@ -1989,9 +1978,6 @@
1989
1978
  },
1990
1979
  emits: ['fc:subform', 'update:modelValue', 'change', 'itemMounted'],
1991
1980
  watch: {
1992
- disabled: function disabled(n) {
1993
- this.syncDisabled && this.subApi.disabled(n);
1994
- },
1995
1981
  modelValue: function modelValue(n) {
1996
1982
  this.setValue(n);
1997
1983
  }
@@ -2017,8 +2003,6 @@
2017
2003
 
2018
2004
  this.subApi = api;
2019
2005
  vue.nextTick(function () {
2020
- _this.syncDisabled && api.disabled(_this.disabled);
2021
-
2022
2006
  _this.$emit('itemMounted', api);
2023
2007
  });
2024
2008
  }
@@ -2026,6 +2010,7 @@
2026
2010
  render: function render() {
2027
2011
  var Type = this.form;
2028
2012
  return vue.createVNode(Type, {
2013
+ "disabled": this.disabled,
2029
2014
  "onUpdate:modelValue": this.formData,
2030
2015
  "modelValue": this.modelValue,
2031
2016
  "onEmit-event": this.$emit,
@@ -2967,7 +2952,7 @@
2967
2952
  if (!ctx) return initial;
2968
2953
  initial[ctx.field] = copy(ctx.rule.value);
2969
2954
  return initial;
2970
- }, h.options.appendValue ? copy(h.appendData) : {});
2955
+ }, h.options.appendValue !== false ? copy(h.appendData) : {});
2971
2956
  },
2972
2957
  getValue: function getValue(field) {
2973
2958
  var ctx = h.getFieldCtx(field);
@@ -3412,12 +3397,17 @@
3412
3397
  },
3413
3398
  bus: h.bus,
3414
3399
  fetch: function fetch(opt) {
3415
- h.options.beforeFetch && invoke(function () {
3416
- return h.options.beforeFetch(opt, {
3417
- api: api
3400
+ return new Promise(function (resolve, reject) {
3401
+ h.beforeFetch(opt).then(function () {
3402
+ return asyncFetch(opt).then(resolve)["catch"](reject);
3418
3403
  });
3419
3404
  });
3420
- return asyncFetch(opt);
3405
+ },
3406
+ getData: function getData(id, def) {
3407
+ return h.fc.getData(id, def);
3408
+ },
3409
+ setData: function setData(id, data) {
3410
+ return h.fc.setData(id, data);
3421
3411
  },
3422
3412
  helper: {
3423
3413
  tidyFields: tidyFields,
@@ -3819,8 +3809,8 @@
3819
3809
  }];
3820
3810
 
3821
3811
  if (ctx.input) {
3822
- if (this.vm.props.disabled !== undefined) {
3823
- ctx.prop.props.disabled = !!this.vm.props.disabled;
3812
+ if (this.vm.props.disabled === true) {
3813
+ ctx.prop.props.disabled = true;
3824
3814
  }
3825
3815
 
3826
3816
  var field = this.getModelField(ctx);
@@ -5031,7 +5021,7 @@
5031
5021
  return this.deferSyncFn.sync = true;
5032
5022
  }
5033
5023
 
5034
- this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
5024
+ this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue !== false ? this.appendData : {}), this.form));
5035
5025
  },
5036
5026
  isChange: function isChange(ctx, value) {
5037
5027
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
@@ -5687,7 +5677,11 @@
5687
5677
  this.initData(fc.rules);
5688
5678
  this.$manager = new fc.manager(this);
5689
5679
  this.$render = new Render(this);
5690
- this.api = fc.extendApi(Api(this), this);
5680
+ this.api = fc.extendApiFn.reduce(function (api, fn) {
5681
+ return _objectSpread2(_objectSpread2({}, api), invoke(function () {
5682
+ return fn(_objectSpread2({}, api), _this);
5683
+ }, {}));
5684
+ }, Api(this));
5691
5685
  }
5692
5686
  extend(Handler.prototype, {
5693
5687
  initData: function initData(rules) {
@@ -5711,6 +5705,23 @@
5711
5705
  },
5712
5706
  isBreakWatch: function isBreakWatch() {
5713
5707
  return this.loading || this.noWatchFn || this.reloading;
5708
+ },
5709
+ beforeFetch: function beforeFetch(opt) {
5710
+ var _this2 = this;
5711
+
5712
+ return new Promise(function (resolve) {
5713
+ var source = _this2.options.beforeFetch && invoke(function () {
5714
+ return _this2.options.beforeFetch(opt, {
5715
+ api: _this2.api
5716
+ });
5717
+ });
5718
+
5719
+ if (source && is.Function(source.then)) {
5720
+ source.then(resolve);
5721
+ } else {
5722
+ resolve();
5723
+ }
5724
+ });
5714
5725
  }
5715
5726
  });
5716
5727
  useInject(Handler);
@@ -5925,7 +5936,7 @@
5925
5936
  if (attr.attr) {
5926
5937
  value = fc.loadData[attr.attr] || attr["default"];
5927
5938
 
5928
- if (attr.copy) {
5939
+ if (attr.copy !== false) {
5929
5940
  value = deepCopy(value);
5930
5941
  }
5931
5942
  }
@@ -6064,7 +6075,7 @@
6064
6075
  if (check()) return;
6065
6076
 
6066
6077
  var fn = function fn(v) {
6067
- return flag ? v : v.data;
6078
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
6068
6079
  };
6069
6080
 
6070
6081
  var parse = parseFn(option.parse);
@@ -6095,27 +6106,25 @@
6095
6106
  }
6096
6107
  });
6097
6108
 
6098
- fc.$handle.options.beforeFetch && invoke(function () {
6099
- return fc.$handle.options.beforeFetch(config, {
6100
- rule: rule,
6101
- api: api
6102
- });
6103
- });
6104
-
6105
- if (is.Function(option.action)) {
6106
- option.action(rule, api).then(function (val) {
6107
- config.onSuccess(val, true);
6108
- })["catch"](function (e) {
6109
- config.onError(e);
6110
- });
6111
- return;
6112
- }
6109
+ fc.$handle.beforeFetch(config, {
6110
+ rule: rule,
6111
+ api: api
6112
+ }).then(function () {
6113
+ if (is.Function(option.action)) {
6114
+ option.action(rule, api).then(function (val) {
6115
+ config.onSuccess(val, true);
6116
+ })["catch"](function (e) {
6117
+ config.onError(e);
6118
+ });
6119
+ return;
6120
+ }
6113
6121
 
6114
- invoke(function () {
6115
- return fc.create.fetch(config, {
6116
- inject: inject,
6117
- rule: rule,
6118
- api: api
6122
+ invoke(function () {
6123
+ return fc.create.fetch(config, {
6124
+ inject: inject,
6125
+ rule: rule,
6126
+ api: api
6127
+ });
6119
6128
  });
6120
6129
  });
6121
6130
  }
@@ -6196,6 +6205,7 @@
6196
6205
  var directives = {};
6197
6206
  var modelFields = {};
6198
6207
  var useApps = [];
6208
+ var extendApiFn = [config.extendApi];
6199
6209
 
6200
6210
  var providers = _objectSpread2({}, $provider);
6201
6211
 
@@ -6203,7 +6213,7 @@
6203
6213
  var globalConfig = {
6204
6214
  global: {}
6205
6215
  };
6206
- var loadData = {};
6216
+ var loadData = vue.reactive({});
6207
6217
  var CreateNode = CreateNodeFactory();
6208
6218
  var formulas = {};
6209
6219
  exportAttrs(config.attrs || {});
@@ -6365,6 +6375,14 @@
6365
6375
  _emitData(id);
6366
6376
  }
6367
6377
 
6378
+ function getData(id, def) {
6379
+ return hasProperty(loadData, id) ? loadData[id] : def;
6380
+ }
6381
+
6382
+ function extendApi(fn) {
6383
+ extendApiFn.push(fn);
6384
+ }
6385
+
6368
6386
  function removeData(id) {
6369
6387
  delete loadData[id];
6370
6388
 
@@ -6390,14 +6408,14 @@
6390
6408
  components: components,
6391
6409
  directives: directives
6392
6410
  },
6411
+ setData: setData,
6412
+ getData: getData,
6393
6413
  loadData: loadData,
6394
6414
  CreateNode: CreateNode,
6395
6415
  bus: new Mitt(),
6396
6416
  unwatch: null,
6397
6417
  options: vue.ref({}),
6398
- extendApi: config.extendApi || function (api) {
6399
- return api;
6400
- }
6418
+ extendApiFn: extendApiFn
6401
6419
  });
6402
6420
  vue.nextTick(function () {
6403
6421
  vue.watch(_this.options, function () {
@@ -6515,6 +6533,8 @@
6515
6533
  extend(formCreate, {
6516
6534
  version: config.version,
6517
6535
  ui: config.ui,
6536
+ extendApi: extendApi,
6537
+ getData: getData,
6518
6538
  setData: setData,
6519
6539
  removeData: removeData,
6520
6540
  maker: maker,
@@ -7232,7 +7252,7 @@
7232
7252
  }
7233
7253
 
7234
7254
  function extendApi(api, h) {
7235
- extend(api, {
7255
+ return {
7236
7256
  formEl: function formEl() {
7237
7257
  return h.$manager.form();
7238
7258
  },
@@ -7391,8 +7411,7 @@
7391
7411
  });
7392
7412
  });
7393
7413
  }
7394
- });
7395
- return api;
7414
+ };
7396
7415
  }
7397
7416
 
7398
7417
  var required = {
@@ -7473,7 +7492,7 @@
7473
7492
  function elmFormCreate() {
7474
7493
  return FormCreateFactory({
7475
7494
  ui: 'element-ui',
7476
- version: '3.1.33',
7495
+ version: '3.1.34',
7477
7496
  manager: manager,
7478
7497
  extendApi: extendApi,
7479
7498
  install: install,