@form-create/element-ui 3.2.19 → 3.2.20

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.19
2
+ * @form-create/element-ui v3.2.20
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2327,6 +2327,9 @@
2327
2327
  var emit$topForm = debounce(function () {
2328
2328
  fc.bus.$emit('$loadData.$topForm');
2329
2329
  }, 100);
2330
+ var emit$scopeForm = debounce(function () {
2331
+ fc.bus.$emit('$loadData.$scopeForm');
2332
+ }, 100);
2330
2333
  var emit$form = debounce(function () {
2331
2334
  fc.bus.$emit('$loadData.$form');
2332
2335
  }, 100);
@@ -2341,6 +2344,10 @@
2341
2344
  fapi.top.bus.$on('change', emit$change);
2342
2345
  }
2343
2346
 
2347
+ if (fapi !== fapi.scope) {
2348
+ fapi.scope.bus.$on('$loadData.$scopeForm', emit$scopeForm);
2349
+ }
2350
+
2344
2351
  fc.mounted();
2345
2352
  });
2346
2353
  vue.onBeforeUnmount(function () {
@@ -2349,6 +2356,10 @@
2349
2356
  fapi.top.bus.$off('change', emit$change);
2350
2357
  }
2351
2358
 
2359
+ if (fapi !== fapi.scope) {
2360
+ fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
2361
+ }
2362
+
2352
2363
  styleEl && document.head.removeChild(styleEl);
2353
2364
  rmSubForm();
2354
2365
  data.destroyed = true;
@@ -2362,6 +2373,14 @@
2362
2373
  }, {
2363
2374
  immediate: true
2364
2375
  });
2376
+ vue.watch(function () {
2377
+ return props.option;
2378
+ }, function () {
2379
+ fc.initOptions();
2380
+ fapi.refresh();
2381
+ }, {
2382
+ deep: true
2383
+ });
2365
2384
  vue.watch(function () {
2366
2385
  return _toConsumableArray(rule.value);
2367
2386
  }, function (n) {
@@ -2372,14 +2391,6 @@
2372
2391
  fc.$handle.reloadRule(rule.value);
2373
2392
  vm.setupState.renderRule();
2374
2393
  });
2375
- vue.watch(function () {
2376
- return props.option;
2377
- }, function () {
2378
- fc.initOptions();
2379
- fapi.refresh();
2380
- }, {
2381
- deep: true
2382
- });
2383
2394
  vue.watch(function () {
2384
2395
  return [props.disabled, props.preview];
2385
2396
  }, function () {
@@ -2440,6 +2451,9 @@
2440
2451
 
2441
2452
  if (!parent) {
2442
2453
  emit$topForm();
2454
+ emit$scopeForm();
2455
+ } else if (!subForm.value) {
2456
+ emit$scopeForm();
2443
2457
  }
2444
2458
  });
2445
2459
  }
@@ -3166,6 +3180,20 @@
3166
3180
  return api;
3167
3181
  },
3168
3182
 
3183
+ get scope() {
3184
+ var parent = h.vm;
3185
+
3186
+ while (parent && parent.setupState.fapi) {
3187
+ if (!parent.props.subForm) {
3188
+ return parent.setupState.fapi;
3189
+ } else {
3190
+ parent = parent.setupState.parent;
3191
+ }
3192
+ }
3193
+
3194
+ return api.top;
3195
+ },
3196
+
3169
3197
  get children() {
3170
3198
  return allSubForm();
3171
3199
  },
@@ -3196,10 +3224,10 @@
3196
3224
  },
3197
3225
 
3198
3226
  formData: function formData(fields) {
3199
- if (fields == null) {
3227
+ if (fields == null || typeof fields === 'boolean') {
3200
3228
  var data = {};
3201
3229
  Object.keys(h.form).forEach(function (k) {
3202
- if (h.ignoreFields.indexOf(k) === -1) {
3230
+ if (fields === true || h.ignoreFields.indexOf(k) === -1) {
3203
3231
  data[k] = copy(h.form[k]);
3204
3232
  }
3205
3233
  });
@@ -3750,7 +3778,11 @@
3750
3778
  }, opt.wait == null ? 1000 : opt.wait);
3751
3779
  },
3752
3780
  getData: function getData(id, def) {
3753
- return h.fc.getLoadData(id, def);
3781
+ if (h.fc.get) {
3782
+ return h.fc.get(id, def);
3783
+ } else {
3784
+ return h.fc.getLoadData(id, def);
3785
+ }
3754
3786
  },
3755
3787
  watchData: function watchData(fn) {
3756
3788
  return h.fc.watchLoadData(function (get, change) {
@@ -5308,7 +5340,7 @@
5308
5340
  hideLst[valid ? 'push' : 'unshift'](function () {
5309
5341
  if (method === 'disabled' || method === 'enabled') {
5310
5342
  _this7.api.disabled(!valid, rule);
5311
- } else if (method === 'display') {
5343
+ } else if (method === 'display' || method === 'show') {
5312
5344
  _this7.api.display(valid, rule);
5313
5345
  } else if (method === 'required') {
5314
5346
  rule.forEach(function (item) {
@@ -5318,6 +5350,8 @@
5318
5350
  if (!valid) {
5319
5351
  _this7.api.clearValidateState(rule);
5320
5352
  }
5353
+ } else if (method === 'if') {
5354
+ _this7.api.hidden(!valid, rule);
5321
5355
  } else {
5322
5356
  _this7.api.hidden(!valid, rule);
5323
5357
  }
@@ -5908,8 +5942,10 @@
5908
5942
  var match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5909
5943
 
5910
5944
  if (match) {
5945
+ var _ctx$refRule, _ctx$refRule$__$title;
5946
+
5911
5947
  temp.message = _this.api.t(match[1], {
5912
- title: ctx.refRule.__$title.value
5948
+ title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : (_ctx$refRule$__$title = _ctx$refRule.__$title) === null || _ctx$refRule$__$title === void 0 ? void 0 : _ctx$refRule$__$title.value
5913
5949
  });
5914
5950
  }
5915
5951
  }
@@ -6057,7 +6093,7 @@
6057
6093
  });
6058
6094
  } else {
6059
6095
  flag = invoke(function () {
6060
- return 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);
6096
+ return new Function('$condition', '$val', '$form', '$scope', '$group', '$rule', "with($form){with($scope){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, _this2.api.top === _this2.api.scope ? {} : _this2.api.scope.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
6061
6097
  });
6062
6098
  }
6063
6099
 
@@ -6125,7 +6161,7 @@
6125
6161
 
6126
6162
  return obj;
6127
6163
  }, {});
6128
- return new Function('$formulas', '$form', '$group', '$rule', '$api', "with($form){with(this){with($group){with($formulas){ return ".concat(str, " }}}}")).call(this.api.form, formulas, this.api.top.form, group ? this.subRuleData[group.id] || {} : {}, ctx.rule, this.api);
6164
+ return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(this.api.form, formulas, this.api.top.form, this.api.top === this.api.scope ? {} : this.api.scope.form, group ? this.subRuleData[group.id] || {} : {}, ctx.rule, this.api);
6129
6165
  },
6130
6166
  updateChildren: function updateChildren(ctx, n, o) {
6131
6167
  var _this3 = this;
@@ -6266,8 +6302,11 @@
6266
6302
  hook.forEach(function (fn) {
6267
6303
  invoke(function () {
6268
6304
  return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6305
+ self: ctx.rule,
6269
6306
  rule: ctx.rule,
6270
- api: _this2.api
6307
+ $f: _this2.api,
6308
+ api: _this2.api,
6309
+ option: _this2.vm.props.option
6271
6310
  }));
6272
6311
  });
6273
6312
  });
@@ -6521,10 +6560,10 @@
6521
6560
  isBreakWatch: function isBreakWatch() {
6522
6561
  return this.loading || this.noWatchFn || this.reloading;
6523
6562
  },
6524
- beforeFetch: function beforeFetch(opt) {
6563
+ globalBeforeFetch: function globalBeforeFetch(opt) {
6525
6564
  var _this2 = this;
6526
6565
 
6527
- return new Promise(function (resolve) {
6566
+ return new Promise(function (resolve, reject) {
6528
6567
  var source = _this2.options.beforeFetch && invoke(function () {
6529
6568
  return _this2.options.beforeFetch(opt, {
6530
6569
  api: _this2.api
@@ -6532,10 +6571,31 @@
6532
6571
  });
6533
6572
 
6534
6573
  if (source && is.Function(source.then)) {
6535
- source.then(resolve);
6574
+ source.then(resolve)["catch"](reject);
6575
+ } else {
6576
+ resolve();
6577
+ }
6578
+ });
6579
+ },
6580
+ beforeFetch: function beforeFetch(opt) {
6581
+ var _this3 = this;
6582
+
6583
+ return new Promise(function (resolve, reject) {
6584
+ var res = opt && opt.beforeFetch && invoke(function () {
6585
+ return opt.beforeFetch(opt, {
6586
+ api: _this3.api
6587
+ });
6588
+ });
6589
+
6590
+ if (res && is.Function(res.then)) {
6591
+ res.then(resolve)["catch"](reject);
6592
+ } else if (res === false) {
6593
+ reject();
6536
6594
  } else {
6537
6595
  resolve();
6538
6596
  }
6597
+ }).then(function () {
6598
+ return _this3.globalBeforeFetch(opt);
6539
6599
  });
6540
6600
  }
6541
6601
  });
@@ -6738,7 +6798,7 @@
6738
6798
  var loadData = {
6739
6799
  name: 'loadData',
6740
6800
  _fn: [],
6741
- loaded: function loaded(inject, rule, api) {
6801
+ mounted: function mounted(inject, rule, api) {
6742
6802
  this.deleted(inject);
6743
6803
  var attrs = toArray(inject.getValue());
6744
6804
  var unwatchs = [];
@@ -7494,6 +7554,7 @@
7494
7554
  components: components,
7495
7555
  directives: directives
7496
7556
  },
7557
+ get: null,
7497
7558
  drivers: drivers,
7498
7559
  renderDriver: null,
7499
7560
  refreshData: refreshData,
@@ -7751,9 +7812,11 @@
7751
7812
  var key = split.shift();
7752
7813
 
7753
7814
  if (key === '$topForm') {
7754
- val = this.$handle.api.top.formData();
7815
+ val = this.$handle.api.top.formData(true);
7816
+ } else if (key === '$scopeForm') {
7817
+ val = this.$handle.api.scope.formData(true);
7755
7818
  } else if (key === '$form') {
7756
- val = this.$handle.api.formData();
7819
+ val = this.$handle.api.formData(true);
7757
7820
  } else if (key === '$options') {
7758
7821
  val = this.options.value;
7759
7822
  } else if (key === '$globalData') {
@@ -7794,9 +7857,17 @@
7794
7857
  var unwatch = {};
7795
7858
 
7796
7859
  var run = function run(flag) {
7860
+ if (!_this6.get) {
7861
+ _this6.get = get;
7862
+ }
7863
+
7797
7864
  invoke(function () {
7798
7865
  fn(get, flag);
7799
7866
  });
7867
+
7868
+ if (_this6.get === get) {
7869
+ _this6.get = undefined;
7870
+ }
7800
7871
  };
7801
7872
 
7802
7873
  var get = function get(id, def) {
@@ -8441,7 +8512,9 @@
8441
8512
  },
8442
8513
  makeInfo: function makeInfo(rule, uni, ctx) {
8443
8514
  var _ctx$refRule,
8515
+ _ctx$refRule$__$title,
8444
8516
  _ctx$refRule2,
8517
+ _ctx$refRule2$__$titl,
8445
8518
  _this5 = this;
8446
8519
 
8447
8520
  var titleProp = _objectSpread2({}, rule.title);
@@ -8452,10 +8525,10 @@
8452
8525
  var form = this.options.form;
8453
8526
  var titleSlot = this.getSlot('title');
8454
8527
  var children = [titleSlot ? titleSlot({
8455
- title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : _ctx$refRule.__$title.value,
8528
+ title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : (_ctx$refRule$__$title = _ctx$refRule.__$title) === null || _ctx$refRule$__$title === void 0 ? void 0 : _ctx$refRule$__$title.value,
8456
8529
  rule: ctx.rule,
8457
8530
  options: this.options
8458
- }) : ((_ctx$refRule2 = ctx.refRule) === null || _ctx$refRule2 === void 0 ? void 0 : _ctx$refRule2.__$title.value) + (form.labelSuffix || form['label-suffix'] || '')];
8531
+ }) : ((_ctx$refRule2 = ctx.refRule) === null || _ctx$refRule2 === void 0 ? void 0 : (_ctx$refRule2$__$titl = _ctx$refRule2.__$title) === null || _ctx$refRule2$__$titl === void 0 ? void 0 : _ctx$refRule2$__$titl.value) + (form.labelSuffix || form['label-suffix'] || '')];
8459
8532
 
8460
8533
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
8461
8534
  var prop = {
@@ -8471,9 +8544,9 @@
8471
8544
  var field = 'content';
8472
8545
 
8473
8546
  if (infoProp.info && !hasProperty(prop.props, field)) {
8474
- var _ctx$refRule3;
8547
+ var _ctx$refRule3, _ctx$refRule3$__$info;
8475
8548
 
8476
- prop.props[field] = (_ctx$refRule3 = ctx.refRule) === null || _ctx$refRule3 === void 0 ? void 0 : _ctx$refRule3.__$info.value;
8549
+ prop.props[field] = (_ctx$refRule3 = ctx.refRule) === null || _ctx$refRule3 === void 0 ? void 0 : (_ctx$refRule3$__$info = _ctx$refRule3.__$info) === null || _ctx$refRule3$__$info === void 0 ? void 0 : _ctx$refRule3$__$info.value;
8477
8550
  }
8478
8551
 
8479
8552
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), _defineProperty({}, titleProp.slot || (isTip ? 'default' : 'reference'), function () {
@@ -8872,6 +8945,8 @@
8872
8945
  inject.clearProp();
8873
8946
  api.clearValidateState([rule.field]);
8874
8947
  } else {
8948
+ var _rule$__fc__$refRule$;
8949
+
8875
8950
  var validate = _objectSpread2({
8876
8951
  required: true,
8877
8952
  validator: function validator(_, v, call) {
@@ -8879,7 +8954,7 @@
8879
8954
  }
8880
8955
  }, val);
8881
8956
 
8882
- var title = rule.__fc__.refRule.__$title.value;
8957
+ var title = (_rule$__fc__$refRule$ = rule.__fc__.refRule.__$title) === null || _rule$__fc__$refRule$ === void 0 ? void 0 : _rule$__fc__$refRule$.value;
8883
8958
 
8884
8959
  if (!validate.message) {
8885
8960
  validate.message = api.t('required', {
@@ -8952,7 +9027,7 @@
8952
9027
  function elmFormCreate() {
8953
9028
  return FormCreateFactory({
8954
9029
  ui: 'element-ui',
8955
- version: '3.2.19',
9030
+ version: '3.2.20',
8956
9031
  manager: manager,
8957
9032
  extendApi: extendApi,
8958
9033
  install: install,