@form-create/element-ui 3.2.15 → 3.2.17

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,6 +1,6 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.15
3
- * (c) 2018-2024 xaboy
2
+ * @form-create/element-ui v3.2.17
3
+ * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
@@ -2882,6 +2882,21 @@
2882
2882
 
2883
2883
  return Object.keys(matches);
2884
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
+ }
2885
2900
 
2886
2901
  function baseRule() {
2887
2902
  return {
@@ -3674,11 +3689,16 @@
3674
3689
  });
3675
3690
  });
3676
3691
  },
3677
- watchFetch: function watchFetch(opt, callback, error) {
3692
+ watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
3678
3693
  return h.fc.watchLoadData(function (get, change) {
3679
3694
  var _opt = deepCopy(opt);
3680
3695
 
3681
3696
  _opt = h.loadFetchVar(_opt, get);
3697
+
3698
+ if (beforeFetch && beforeFetch(_opt, change) === false) {
3699
+ return;
3700
+ }
3701
+
3682
3702
  h.beforeFetch(_opt).then(function () {
3683
3703
  return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
3684
3704
  invoke(function () {
@@ -3692,7 +3712,7 @@
3692
3712
  error && error(e);
3693
3713
  });
3694
3714
  });
3695
- });
3715
+ }, opt.wait == null ? 1000 : opt.wait);
3696
3716
  },
3697
3717
  getData: function getData(id, def) {
3698
3718
  return h.fc.getLoadData(id, def);
@@ -4454,24 +4474,16 @@
4454
4474
  return _this4.loadStrVar(str, get);
4455
4475
  };
4456
4476
 
4457
- options.action = loadVal(options.action);
4458
-
4459
- if (options.headers) {
4460
- var _headers = {};
4461
- Object.keys(options.headers).forEach(function (k) {
4462
- _headers[loadVal(k)] = loadVal(options.headers[k]);
4463
- });
4464
- options.headers = _headers;
4465
- }
4466
-
4467
- if (options.data) {
4468
- var _data = {};
4469
- Object.keys(options.data).forEach(function (k) {
4470
- _data[loadVal(k)] = loadVal(options.data[k]);
4471
- });
4472
- options.data = _data;
4473
- }
4474
-
4477
+ options.action = loadVal(options.action || '');
4478
+ ['headers', 'data', 'query'].forEach(function (key) {
4479
+ if (options[key]) {
4480
+ var data = {};
4481
+ Object.keys(options[key]).forEach(function (k) {
4482
+ data[loadVal(k)] = loadVal(options[key][k]);
4483
+ });
4484
+ options[key] = data;
4485
+ }
4486
+ });
4475
4487
  return options;
4476
4488
  }
4477
4489
  });
@@ -4909,8 +4921,8 @@
4909
4921
  var rule = ctx.rule;
4910
4922
  is.trueArray(rule.sync) && mergeProps([{
4911
4923
  on: rule.sync.reduce(function (pre, prop) {
4912
- pre["update:".concat(prop)] = function (val) {
4913
- rule.props[prop] = val;
4924
+ pre[_typeof(prop) === 'object' && prop.event || "update:".concat(prop)] = function (val) {
4925
+ rule.props[_typeof(prop) === 'object' && prop.prop || prop] = val;
4914
4926
 
4915
4927
  _this4.vm.emit('sync', prop, val, rule, _this4.fapi);
4916
4928
  };
@@ -5036,7 +5048,7 @@
5036
5048
  return;
5037
5049
  }
5038
5050
 
5039
- rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
5051
+ rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
5040
5052
  ctx = null;
5041
5053
  isCopy = true;
5042
5054
  }
@@ -5564,6 +5576,7 @@
5564
5576
  };
5565
5577
 
5566
5578
  var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
5579
+ var oldValueTag = Symbol('oldValue');
5567
5580
  function useContext(Handler) {
5568
5581
  extend(Handler.prototype, {
5569
5582
  getCtx: function getCtx(id) {
@@ -5833,7 +5846,7 @@
5833
5846
 
5834
5847
  var value = _this.compute(ctx, item);
5835
5848
 
5836
- if (item.linkage && value === undefined) {
5849
+ if (item.linkage && value === oldValueTag) {
5837
5850
  return oldValue;
5838
5851
  }
5839
5852
 
@@ -5888,10 +5901,22 @@
5888
5901
  var _loop = function _loop(i) {
5889
5902
  var one = item.group[i];
5890
5903
  var flag = void 0;
5891
- var field = one.field;
5904
+ var field = null;
5892
5905
 
5893
5906
  if (one.variable) {
5894
5907
  field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
5908
+ } else if (one.field) {
5909
+ field = convertFieldToConditions(one.field || '');
5910
+ } else {
5911
+ return {
5912
+ v: true
5913
+ };
5914
+ }
5915
+
5916
+ var compare = one.compare;
5917
+
5918
+ if (compare) {
5919
+ compare = convertFieldToConditions(compare || '');
5895
5920
  }
5896
5921
 
5897
5922
  if (one.mode) {
@@ -5903,7 +5928,7 @@
5903
5928
  return one.handler(_this2.api, ctx.rule);
5904
5929
  });
5905
5930
  } else {
5906
- 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);
5931
+ 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);
5907
5932
  }
5908
5933
 
5909
5934
  if (or && flag) {
@@ -5932,7 +5957,7 @@
5932
5957
  if (item.linkage) {
5933
5958
  return val ? invoke(function () {
5934
5959
  return _this2.computeValue(item.linkage, ctx, group);
5935
- }, undefined) : undefined;
5960
+ }, undefined) : oldValueTag;
5936
5961
  }
5937
5962
 
5938
5963
  return val;
@@ -6329,9 +6354,14 @@
6329
6354
  this.$manager = new fc.manager(this);
6330
6355
  this.$render = new Render(this);
6331
6356
  this.api = fc.extendApiFn.reduce(function (api, fn) {
6332
- extend(api, invoke(function () {
6357
+ var extendApi = invoke(function () {
6333
6358
  return fn(api, _this);
6334
- }, {}));
6359
+ });
6360
+
6361
+ if (extendApi && extendApi !== api) {
6362
+ extend(api, extendApi);
6363
+ }
6364
+
6335
6365
  return api;
6336
6366
  }, Api(this));
6337
6367
  }
@@ -6589,6 +6619,8 @@
6589
6619
 
6590
6620
  if (attr.template) {
6591
6621
  value = fc.$handle.loadStrVar(attr.template, get);
6622
+ } else if (attr.handler && is.Function(attr.handler)) {
6623
+ value = attr.handler(get, rule, api);
6592
6624
  } else {
6593
6625
  value = get(attr.attr, attr["default"]);
6594
6626
  }
@@ -7034,7 +7066,8 @@
7034
7066
  }
7035
7067
 
7036
7068
  var id = 1;
7037
- var instance = {}; //todo 表单嵌套
7069
+ var instance = {};
7070
+ var defValueTag = Symbol('defValue'); //todo 表单嵌套
7038
7071
 
7039
7072
  function FormCreateFactory(config) {
7040
7073
  var components = _defineProperty({}, fragment.name, fragment);
@@ -7257,7 +7290,11 @@
7257
7290
  id = split.shift();
7258
7291
  var field = split.join('.');
7259
7292
 
7260
- if (hasProperty(loadData, id)) {
7293
+ if (!hasProperty(loadData, id)) {
7294
+ loadData[id] = defValueTag;
7295
+ }
7296
+
7297
+ if (loadData[id] !== defValueTag) {
7261
7298
  var val = loadData[id];
7262
7299
 
7263
7300
  if (val && val._driver) {
@@ -7310,6 +7347,7 @@
7310
7347
  },
7311
7348
  drivers: drivers,
7312
7349
  renderDriver: null,
7350
+ get: null,
7313
7351
  refreshData: refreshData,
7314
7352
  loadData: loadData,
7315
7353
  CreateNode: CreateNode,
@@ -7396,10 +7434,6 @@
7396
7434
  t: function t(id, params, get) {
7397
7435
  var value = get ? get('$t.' + id) : this.globalLanguageDriver(id);
7398
7436
 
7399
- if (value == null && this.vm.appContext.config.globalProperties.$i18n) {
7400
- return this.vm.appContext.config.globalProperties.$i18n.t(id, params);
7401
- }
7402
-
7403
7437
  if (value == null) {
7404
7438
  value = '';
7405
7439
  }
@@ -7507,10 +7541,6 @@
7507
7541
  return locale;
7508
7542
  }
7509
7543
 
7510
- if (this.vm.appContext.config.globalProperties.$i18n && this.vm.appContext.config.globalProperties.$i18n.locale) {
7511
- return this.vm.appContext.config.globalProperties.$i18n.locale;
7512
- }
7513
-
7514
7544
  return 'zh-cn';
7515
7545
  },
7516
7546
  globalLanguageDriver: function globalLanguageDriver(id) {
@@ -7539,25 +7569,14 @@
7539
7569
  var option = this.options.value.globalVariable && this.options.value.globalVariable[key];
7540
7570
 
7541
7571
  if (option) {
7542
- var handle = is.Function(option) ? option : option.handle;
7572
+ var handle = is.Function(option) ? option : parseFn(option.handle);
7543
7573
 
7544
7574
  if (handle) {
7545
- var val;
7546
- var unwatch = this.watchLoadData(function (get, change) {
7547
- if (change) {
7548
- unwatch();
7549
-
7550
- _this5.bus.$emit('$loadData.$var.' + key);
7551
-
7552
- return val;
7553
- }
7554
-
7555
- val = invoke(function () {
7556
- return handle(get, _this5.$handle.api);
7557
- });
7558
- });
7559
- this.unwatch.push(unwatch);
7560
- return val;
7575
+ return deepGet(invoke(function () {
7576
+ return handle(_this5.get || function () {
7577
+ return _this5.getLoadData.apply(_this5, arguments);
7578
+ }, _this5.$handle.api);
7579
+ }), split);
7561
7580
  }
7562
7581
  }
7563
7582
  },
@@ -7596,7 +7615,12 @@
7596
7615
  split = [];
7597
7616
  } else {
7598
7617
  var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7599
- val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(id);
7618
+
7619
+ if (!hasProperty(tmpData, key)) {
7620
+ tmpData[key] = defValueTag;
7621
+ }
7622
+
7623
+ val = tmpData[key] !== defValueTag ? deepGet(tmpData, id) : getData(id);
7600
7624
  split = [];
7601
7625
  }
7602
7626
 
@@ -7607,15 +7631,23 @@
7607
7631
 
7608
7632
  return val == null || val === '' ? def : val;
7609
7633
  },
7610
- watchLoadData: function watchLoadData(fn) {
7634
+ watchLoadData: function watchLoadData(fn, wait) {
7611
7635
  var _this6 = this;
7612
7636
 
7613
7637
  var unwatch = {};
7614
7638
 
7615
7639
  var run = function run(flag) {
7640
+ if (!_this6.get) {
7641
+ _this6.get = get;
7642
+ }
7643
+
7616
7644
  invoke(function () {
7617
7645
  fn(get, flag);
7618
7646
  });
7647
+
7648
+ if (_this6.get === get) {
7649
+ _this6.get = undefined;
7650
+ }
7619
7651
  };
7620
7652
 
7621
7653
  var get = function get(id, def) {
@@ -7638,7 +7670,7 @@
7638
7670
  unwatch[id].val = temp;
7639
7671
  run(true);
7640
7672
  }
7641
- }, 0);
7673
+ }, wait || 0);
7642
7674
  var un = vue.watch(data, function (n) {
7643
7675
  callback();
7644
7676
  });
@@ -7698,7 +7730,7 @@
7698
7730
  this.updateOptions(options);
7699
7731
  },
7700
7732
  mergeOptions: function mergeOptions(target, opt, parent) {
7701
- opt = deepCopy(opt);
7733
+ opt = _objectSpread2({}, opt || {});
7702
7734
  parent && ['page', 'onSubmit', 'onReset', 'onCreated', 'onChange', 'onMounted', 'mounted', 'onReload', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
7703
7735
  delete opt[n];
7704
7736
  });
@@ -8755,7 +8787,7 @@
8755
8787
  function elmFormCreate() {
8756
8788
  return FormCreateFactory({
8757
8789
  ui: 'element-ui',
8758
- version: '3.2.15',
8790
+ version: '3.2.17',
8759
8791
  manager: manager,
8760
8792
  extendApi: extendApi,
8761
8793
  install: install,