@form-create/element-ui 3.2.14 → 3.2.16

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.14
2
+ * @form-create/element-ui v3.2.16
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1418,7 +1418,7 @@
1418
1418
  onPreview: Function,
1419
1419
  modalTitle: String,
1420
1420
  listType: String,
1421
- modelValue: [Array, String]
1421
+ modelValue: [Array, String, Object]
1422
1422
  },
1423
1423
  emits: ['update:modelValue', 'change', 'remove', 'fc.el'],
1424
1424
  data: function data() {
@@ -1453,7 +1453,7 @@
1453
1453
  var files = fileList.map(function (v) {
1454
1454
  return v.is_string ? v.url : v.value || v.url;
1455
1455
  }).filter(function (url) {
1456
- return url !== undefined && url.indexOf('blob:') !== 0;
1456
+ return url !== undefined;
1457
1457
  });
1458
1458
  this.$emit('update:modelValue', files);
1459
1459
  },
@@ -2613,7 +2613,14 @@
2613
2613
  }
2614
2614
 
2615
2615
  if (!flag) return fn;
2616
- var val = makeFn(v);
2616
+ var val;
2617
+
2618
+ try {
2619
+ val = makeFn(v);
2620
+ } catch (e) {
2621
+ val = makeFn('function ' + v);
2622
+ }
2623
+
2617
2624
  val.__json = fn;
2618
2625
  return val;
2619
2626
  } catch (e) {
@@ -2875,6 +2882,21 @@
2875
2882
 
2876
2883
  return Object.keys(matches);
2877
2884
  }
2885
+ function convertFieldToConditions(field) {
2886
+ var parts = field.split('.');
2887
+ var conditions = [];
2888
+ var currentCondition = '';
2889
+ parts.forEach(function (part, index) {
2890
+ if (index === 0) {
2891
+ currentCondition = part;
2892
+ } else {
2893
+ currentCondition += '.' + part;
2894
+ }
2895
+
2896
+ conditions.push(currentCondition);
2897
+ });
2898
+ return conditions.join(' && ');
2899
+ }
2878
2900
 
2879
2901
  function baseRule() {
2880
2902
  return {
@@ -3667,11 +3689,16 @@
3667
3689
  });
3668
3690
  });
3669
3691
  },
3670
- watchFetch: function watchFetch(opt, callback, error) {
3692
+ watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
3671
3693
  return h.fc.watchLoadData(function (get, change) {
3672
3694
  var _opt = deepCopy(opt);
3673
3695
 
3674
3696
  _opt = h.loadFetchVar(_opt, get);
3697
+
3698
+ if (beforeFetch && beforeFetch(_opt, change) === false) {
3699
+ return;
3700
+ }
3701
+
3675
3702
  h.beforeFetch(_opt).then(function () {
3676
3703
  return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
3677
3704
  invoke(function () {
@@ -3685,11 +3712,18 @@
3685
3712
  error && error(e);
3686
3713
  });
3687
3714
  });
3688
- });
3715
+ }, opt.wait == null ? 1000 : opt.wait);
3689
3716
  },
3690
3717
  getData: function getData(id, def) {
3691
3718
  return h.fc.getLoadData(id, def);
3692
3719
  },
3720
+ watchData: function watchData(fn) {
3721
+ return h.fc.watchLoadData(function (get, change) {
3722
+ invoke(function () {
3723
+ return fn(get, change);
3724
+ });
3725
+ });
3726
+ },
3693
3727
  setData: function setData(id, data, isGlobal) {
3694
3728
  return h.fc.setData(id, data, isGlobal);
3695
3729
  },
@@ -4370,7 +4404,7 @@
4370
4404
  },
4371
4405
  getInjectData: function getInjectData(self, inject) {
4372
4406
  var $api = self.__fc__ && self.__fc__.$api;
4373
- var vm = self.__fc__ && self.__fc__.$handle.vm || this.vm.props;
4407
+ var vm = self.__fc__ && self.__fc__.$handle.vm || this.vm;
4374
4408
  var _vm$props = vm.props,
4375
4409
  option = _vm$props.option,
4376
4410
  rule = _vm$props.rule;
@@ -4546,6 +4580,12 @@
4546
4580
  Object.defineProperties(ctx.origin, {
4547
4581
  __fc__: enumerable(vue.markRaw(ctx), true)
4548
4582
  });
4583
+
4584
+ if (ctx.rule !== ctx.origin) {
4585
+ Object.defineProperties(ctx.rule, {
4586
+ __fc__: enumerable(vue.markRaw(ctx), true)
4587
+ });
4588
+ }
4549
4589
  }
4550
4590
 
4551
4591
  function RuleContext(handle, rule, defaultValue) {
@@ -4889,8 +4929,8 @@
4889
4929
  var rule = ctx.rule;
4890
4930
  is.trueArray(rule.sync) && mergeProps([{
4891
4931
  on: rule.sync.reduce(function (pre, prop) {
4892
- pre["update:".concat(prop)] = function (val) {
4893
- rule.props[prop] = val;
4932
+ pre[_typeof(prop) === 'object' && prop.event || "update:".concat(prop)] = function (val) {
4933
+ rule.props[_typeof(prop) === 'object' && prop.prop || prop] = val;
4894
4934
 
4895
4935
  _this4.vm.emit('sync', prop, val, rule, _this4.fapi);
4896
4936
  };
@@ -5016,7 +5056,7 @@
5016
5056
  return;
5017
5057
  }
5018
5058
 
5019
- rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
5059
+ rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
5020
5060
  ctx = null;
5021
5061
  isCopy = true;
5022
5062
  }
@@ -5544,6 +5584,7 @@
5544
5584
  };
5545
5585
 
5546
5586
  var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
5587
+ var oldValueTag = Symbol('oldValue');
5547
5588
  function useContext(Handler) {
5548
5589
  extend(Handler.prototype, {
5549
5590
  getCtx: function getCtx(id) {
@@ -5813,7 +5854,7 @@
5813
5854
 
5814
5855
  var value = _this.compute(ctx, item);
5815
5856
 
5816
- if (item.linkage && value === undefined) {
5857
+ if (item.linkage && value === oldValueTag) {
5817
5858
  return oldValue;
5818
5859
  }
5819
5860
 
@@ -5868,10 +5909,22 @@
5868
5909
  var _loop = function _loop(i) {
5869
5910
  var one = item.group[i];
5870
5911
  var flag = void 0;
5871
- var field = one.field;
5912
+ var field = null;
5872
5913
 
5873
5914
  if (one.variable) {
5874
5915
  field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
5916
+ } else if (one.field) {
5917
+ field = convertFieldToConditions(one.field || '');
5918
+ } else {
5919
+ return {
5920
+ v: true
5921
+ };
5922
+ }
5923
+
5924
+ var compare = one.compare;
5925
+
5926
+ if (compare) {
5927
+ compare = convertFieldToConditions(compare || '');
5875
5928
  }
5876
5929
 
5877
5930
  if (one.mode) {
@@ -5883,7 +5936,7 @@
5883
5936
  return one.handler(_this2.api, ctx.rule);
5884
5937
  });
5885
5938
  } else {
5886
- flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
5939
+ flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
5887
5940
  }
5888
5941
 
5889
5942
  if (or && flag) {
@@ -5912,7 +5965,7 @@
5912
5965
  if (item.linkage) {
5913
5966
  return val ? invoke(function () {
5914
5967
  return _this2.computeValue(item.linkage, ctx, group);
5915
- }, undefined) : undefined;
5968
+ }, undefined) : oldValueTag;
5916
5969
  }
5917
5970
 
5918
5971
  return val;
@@ -6309,9 +6362,14 @@
6309
6362
  this.$manager = new fc.manager(this);
6310
6363
  this.$render = new Render(this);
6311
6364
  this.api = fc.extendApiFn.reduce(function (api, fn) {
6312
- extend(api, invoke(function () {
6365
+ var extendApi = invoke(function () {
6313
6366
  return fn(api, _this);
6314
- }, {}));
6367
+ });
6368
+
6369
+ if (extendApi && extendApi !== api) {
6370
+ extend(api, extendApi);
6371
+ }
6372
+
6315
6373
  return api;
6316
6374
  }, Api(this));
6317
6375
  }
@@ -6613,6 +6671,8 @@
6613
6671
  this._fn[inject.id].forEach(function (un) {
6614
6672
  un();
6615
6673
  });
6674
+
6675
+ delete this._fn[inject.id];
6616
6676
  }
6617
6677
 
6618
6678
  inject.clearProp();
@@ -6675,6 +6735,8 @@
6675
6735
  this._fn[inject.id].forEach(function (un) {
6676
6736
  un();
6677
6737
  });
6738
+
6739
+ delete this._fn[inject.id];
6678
6740
  }
6679
6741
 
6680
6742
  inject.clearProp();
@@ -6754,6 +6816,13 @@
6754
6816
  deepSet(inject.getProp(), option.to || 'options', val);
6755
6817
  }
6756
6818
 
6819
+ if (val != null && option && option.key && fc.$handle.options.globalData[option.key]) {
6820
+ fc.fetchCache.set(fc.$handle.options.globalData[option.key], {
6821
+ status: true,
6822
+ data: val
6823
+ });
6824
+ }
6825
+
6757
6826
  api.sync(rule);
6758
6827
  };
6759
6828
 
@@ -6871,6 +6940,8 @@
6871
6940
  deleted: function deleted(inject) {
6872
6941
  if (this._fn[inject.id]) {
6873
6942
  this._fn[inject.id]();
6943
+
6944
+ delete this._fn[inject.id];
6874
6945
  }
6875
6946
 
6876
6947
  inject.clearProp();
@@ -7001,7 +7072,8 @@
7001
7072
  }
7002
7073
 
7003
7074
  var id = 1;
7004
- var instance = {}; //todo 表单嵌套
7075
+ var instance = {};
7076
+ var defValueTag = Symbol('defValue'); //todo 表单嵌套
7005
7077
 
7006
7078
  function FormCreateFactory(config) {
7007
7079
  var components = _defineProperty({}, fragment.name, fragment);
@@ -7224,7 +7296,11 @@
7224
7296
  id = split.shift();
7225
7297
  var field = split.join('.');
7226
7298
 
7227
- if (hasProperty(loadData, id)) {
7299
+ if (!hasProperty(loadData, id)) {
7300
+ loadData[id] = defValueTag;
7301
+ }
7302
+
7303
+ if (loadData[id] !== defValueTag) {
7228
7304
  var val = loadData[id];
7229
7305
 
7230
7306
  if (val && val._driver) {
@@ -7277,6 +7353,7 @@
7277
7353
  },
7278
7354
  drivers: drivers,
7279
7355
  renderDriver: null,
7356
+ get: null,
7280
7357
  refreshData: refreshData,
7281
7358
  loadData: loadData,
7282
7359
  CreateNode: CreateNode,
@@ -7509,22 +7586,11 @@
7509
7586
  var handle = is.Function(option) ? option : option.handle;
7510
7587
 
7511
7588
  if (handle) {
7512
- var val;
7513
- var unwatch = this.watchLoadData(function (get, change) {
7514
- if (change) {
7515
- unwatch();
7516
-
7517
- _this5.bus.$emit('$loadData.$var.' + key);
7518
-
7519
- return val;
7520
- }
7521
-
7522
- val = invoke(function () {
7523
- return handle(get, _this5.$handle.api);
7524
- });
7525
- });
7526
- this.unwatch.push(unwatch);
7527
- return val;
7589
+ return deepGet(invoke(function () {
7590
+ return handle(_this5.get || function () {
7591
+ return _this5.getLoadData.apply(_this5, arguments);
7592
+ }, _this5.$handle.api);
7593
+ }), split);
7528
7594
  }
7529
7595
  }
7530
7596
  },
@@ -7563,7 +7629,12 @@
7563
7629
  split = [];
7564
7630
  } else {
7565
7631
  var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7566
- val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(id);
7632
+
7633
+ if (!hasProperty(tmpData, key)) {
7634
+ tmpData[key] = defValueTag;
7635
+ }
7636
+
7637
+ val = tmpData[key] !== defValueTag ? deepGet(tmpData, id) : getData(id);
7567
7638
  split = [];
7568
7639
  }
7569
7640
 
@@ -7574,15 +7645,23 @@
7574
7645
 
7575
7646
  return val == null || val === '' ? def : val;
7576
7647
  },
7577
- watchLoadData: function watchLoadData(fn) {
7648
+ watchLoadData: function watchLoadData(fn, wait) {
7578
7649
  var _this6 = this;
7579
7650
 
7580
7651
  var unwatch = {};
7581
7652
 
7582
7653
  var run = function run(flag) {
7654
+ if (!_this6.get) {
7655
+ _this6.get = get;
7656
+ }
7657
+
7583
7658
  invoke(function () {
7584
7659
  fn(get, flag);
7585
7660
  });
7661
+
7662
+ if (_this6.get === get) {
7663
+ _this6.get = undefined;
7664
+ }
7586
7665
  };
7587
7666
 
7588
7667
  var get = function get(id, def) {
@@ -7605,7 +7684,7 @@
7605
7684
  unwatch[id].val = temp;
7606
7685
  run(true);
7607
7686
  }
7608
- }, 0);
7687
+ }, wait || 0);
7609
7688
  var un = vue.watch(data, function (n) {
7610
7689
  callback();
7611
7690
  });
@@ -7665,8 +7744,8 @@
7665
7744
  this.updateOptions(options);
7666
7745
  },
7667
7746
  mergeOptions: function mergeOptions(target, opt, parent) {
7668
- opt = deepCopy(opt);
7669
- parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
7747
+ opt = _objectSpread2({}, opt || {});
7748
+ parent && ['page', 'onSubmit', 'onReset', 'onCreated', 'onChange', 'onMounted', 'mounted', 'onReload', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
7670
7749
  delete opt[n];
7671
7750
  });
7672
7751
 
@@ -8462,7 +8541,7 @@
8462
8541
  return maker;
8463
8542
  }
8464
8543
 
8465
- var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-right .el-form-item__label{justify-content:flex-end}.fc-wrap-left .el-form-item__label{justify-content:flex-start}.fc-wrap-top.el-form-item{display:block}.fc-wrap-top.el-form-item .el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left}.el-form--large .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .fc-wrap-top.el-form-item .el-form-item__label{line-height:20px;margin-bottom:4px}.fc-form-footer{margin-top:12px}";
8544
+ var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-right>.el-form-item__label{display:flex;justify-content:flex-end}.fc-wrap-left>.el-form-item__label{display:flex;justify-content:flex-start}.fc-wrap-top.el-form-item{display:block}.fc-wrap-top.el-form-item>.el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left}.el-form--large .fc-wrap-top.el-form-item>.el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .fc-wrap-top.el-form-item>.el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .fc-wrap-top.el-form-item>.el-form-item__label{line-height:20px;margin-bottom:4px}.fc-form-footer{margin-top:12px}";
8466
8545
  styleInject(css_248z);
8467
8546
 
8468
8547
  function tidyBtnProp(btn, def) {
@@ -8722,7 +8801,7 @@
8722
8801
  function elmFormCreate() {
8723
8802
  return FormCreateFactory({
8724
8803
  ui: 'element-ui',
8725
- version: '3.2.14',
8804
+ version: '3.2.16',
8726
8805
  manager: manager,
8727
8806
  extendApi: extendApi,
8728
8807
  install: install,