@form-create/element-ui 3.2.22 → 3.2.23

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.22
2
+ * @form-create/element-ui v3.2.23
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2353,7 +2353,7 @@ function parseFn(fn, mode) {
2353
2353
  v.__inject = true;
2354
2354
  return v;
2355
2355
  } else if (v.indexOf('$FNX:') === 0) {
2356
- v = makeFn('function($inject){' + v.substring(5) + '}');
2356
+ v = makeFn('function($inject){\n' + v.substring(5) + '\n}');
2357
2357
  v.__json = fn;
2358
2358
  v.__inject = true;
2359
2359
  return v;
@@ -6069,7 +6069,6 @@ function useContext(Handler) {
6069
6069
  }
6070
6070
 
6071
6071
  Object.keys(computedRule).forEach(function (k) {
6072
- var oldValue = undefined;
6073
6072
  var computedValue = computed(function () {
6074
6073
  var item = computedRule[k];
6075
6074
  if (!item) return undefined;
@@ -6077,7 +6076,7 @@ function useContext(Handler) {
6077
6076
  var value = _this.compute(ctx, item);
6078
6077
 
6079
6078
  if (item.linkage && value === oldValueTag) {
6080
- return oldValue;
6079
+ return oldValueTag;
6081
6080
  }
6082
6081
 
6083
6082
  return value;
@@ -6098,10 +6097,15 @@ function useContext(Handler) {
6098
6097
  }
6099
6098
 
6100
6099
  ctx.watch.push(watch(computedValue, function (n) {
6101
- oldValue = n;
6100
+ if (n === oldValueTag) {
6101
+ return;
6102
+ }
6103
+
6102
6104
  setTimeout(function () {
6103
6105
  callback(n);
6104
6106
  });
6107
+ }, {
6108
+ deep: true
6105
6109
  }));
6106
6110
  });
6107
6111
  });
@@ -6123,7 +6127,7 @@ function useContext(Handler) {
6123
6127
  if (before === false) {
6124
6128
  callback();
6125
6129
  } else {
6126
- var key = _this2.validator(value, validate);
6130
+ var key = _this2.validator(ctx, value, validate);
6127
6131
 
6128
6132
  if (!key) {
6129
6133
  if (validate.validator) {
@@ -6176,7 +6180,9 @@ function useContext(Handler) {
6176
6180
  var formatRule = Array.isArray(invalid.rule) ? invalid.rule.join(',') : '' + invalid.rule;
6177
6181
  return this.api.t(invalid.key === 'required' ? invalid.key : 'validate.' + invalid.key, (_this$api$t = {}, _defineProperty(_this$api$t, invalid.key, formatRule), _defineProperty(_this$api$t, "title", (_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), _this$api$t));
6178
6182
  },
6179
- validator: function validator(value, validate) {
6183
+ validator: function validator(ctx, value, validate) {
6184
+ var _this3 = this;
6185
+
6180
6186
  var isEmpty = is.empty(value);
6181
6187
 
6182
6188
  if (isEmpty) {
@@ -6370,6 +6376,15 @@ function useContext(Handler) {
6370
6376
  };
6371
6377
  }
6372
6378
 
6379
+ break;
6380
+
6381
+ case 'computed':
6382
+ if (!_this3.compute(ctx, rule)) {
6383
+ return {
6384
+ v: key
6385
+ };
6386
+ }
6387
+
6373
6388
  break;
6374
6389
  }
6375
6390
  };
@@ -6381,7 +6396,7 @@ function useContext(Handler) {
6381
6396
  }
6382
6397
  },
6383
6398
  compute: function compute(ctx, item) {
6384
- var _this3 = this;
6399
+ var _this4 = this;
6385
6400
 
6386
6401
  var fn;
6387
6402
 
@@ -6407,7 +6422,7 @@ function useContext(Handler) {
6407
6422
  var field = null;
6408
6423
 
6409
6424
  if (one.variable) {
6410
- field = JSON.stringify(_this3.fc.getLoadData(one.variable) || '');
6425
+ field = JSON.stringify(_this4.fc.getLoadData(one.variable) || '');
6411
6426
  } else if (one.field) {
6412
6427
  field = convertFieldToConditions(one.field || '');
6413
6428
  } else if (!one.mode) {
@@ -6428,11 +6443,11 @@ function useContext(Handler) {
6428
6443
  flag = false;
6429
6444
  } else if (is.Function(one.handler)) {
6430
6445
  flag = invoke(function () {
6431
- return one.handler(_this3.api, ctx.rule);
6446
+ return one.handler(_this4.api, ctx.rule);
6432
6447
  });
6433
6448
  } else {
6434
6449
  flag = invoke(function () {
6435
- 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(_this3.api.form, condition, one.value, _this3.api.top.form, _this3.api.top === _this3.api.scope ? {} : _this3.api.scope.form, group ? _this3.subRuleData[group.id] || {} : {}, ctx.rule);
6450
+ 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(_this4.api.form, condition, one.value, _this4.api.top.form, _this4.api.top === _this4.api.scope ? {} : _this4.api.scope.form, group ? _this4.subRuleData[group.id] || {} : {}, ctx.rule);
6436
6451
  });
6437
6452
  }
6438
6453
 
@@ -6461,27 +6476,27 @@ function useContext(Handler) {
6461
6476
 
6462
6477
  if (item.linkage) {
6463
6478
  return val ? invoke(function () {
6464
- return _this3.computeValue(item.linkage, ctx, group);
6479
+ return _this4.computeValue(item.linkage, ctx, group);
6465
6480
  }, undefined) : oldValueTag;
6466
6481
  }
6467
6482
 
6468
6483
  return val;
6469
6484
  } else if (is.Function(item)) {
6470
6485
  fn = function fn() {
6471
- return item(_this3.api.form, _this3.api);
6486
+ return item(_this4.api.form, _this4.api);
6472
6487
  };
6473
6488
  } else {
6474
6489
  var _group = ctx.getParentGroup();
6475
6490
 
6476
6491
  fn = function fn() {
6477
- return _this3.computeValue(item, ctx, _group);
6492
+ return _this4.computeValue(item, ctx, _group);
6478
6493
  };
6479
6494
  }
6480
6495
 
6481
6496
  return invoke(fn, undefined);
6482
6497
  },
6483
6498
  computeValue: function computeValue(str, ctx, group) {
6484
- var _this4 = this;
6499
+ var _this5 = this;
6485
6500
 
6486
6501
  var that = this;
6487
6502
  var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
@@ -6503,35 +6518,35 @@ function useContext(Handler) {
6503
6518
  return obj;
6504
6519
  }, {});
6505
6520
  return invoke(function () {
6506
- return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this4.api.form, formulas, _this4.api.top.form, _this4.api.top === _this4.api.scope ? {} : _this4.api.scope.form, group ? _this4.subRuleData[group.id] || {} : {}, ctx.rule, _this4.api);
6521
+ return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this5.api.form, formulas, _this5.api.top.form, _this5.api.top === _this5.api.scope ? {} : _this5.api.scope.form, group ? _this5.subRuleData[group.id] || {} : {}, ctx.rule, _this5.api);
6507
6522
  }, undefined);
6508
6523
  },
6509
6524
  updateChildren: function updateChildren(ctx, n, o) {
6510
- var _this5 = this;
6525
+ var _this6 = this;
6511
6526
 
6512
6527
  this.deferSyncValue(function () {
6513
6528
  o && o.forEach(function (child) {
6514
6529
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
6515
- _this5.rmCtx(child.__fc__);
6530
+ _this6.rmCtx(child.__fc__);
6516
6531
  }
6517
6532
  });
6518
6533
 
6519
6534
  if (is.trueArray(n)) {
6520
- _this5.loadChildren(n, ctx);
6535
+ _this6.loadChildren(n, ctx);
6521
6536
 
6522
- _this5.bus.$emit('update', _this5.api);
6537
+ _this6.bus.$emit('update', _this6.api);
6523
6538
  }
6524
6539
  });
6525
6540
  },
6526
6541
  rmSub: function rmSub(sub) {
6527
- var _this6 = this;
6542
+ var _this7 = this;
6528
6543
 
6529
6544
  is.trueArray(sub) && sub.forEach(function (r) {
6530
- r && r.__fc__ && _this6.rmCtx(r.__fc__);
6545
+ r && r.__fc__ && _this7.rmCtx(r.__fc__);
6531
6546
  });
6532
6547
  },
6533
6548
  rmCtx: function rmCtx(ctx) {
6534
- var _this7 = this;
6549
+ var _this8 = this;
6535
6550
 
6536
6551
  if (ctx.deleted) return;
6537
6552
  var id = ctx.id,
@@ -6560,19 +6575,19 @@ function useContext(Handler) {
6560
6575
  }
6561
6576
 
6562
6577
  this.deferSyncValue(function () {
6563
- if (!_this7.reloading) {
6578
+ if (!_this8.reloading) {
6564
6579
  if (ctx.parser.loadChildren !== false) {
6565
6580
  var children = ctx.getPending('children', ctx.rule.children);
6566
6581
 
6567
6582
  if (is.trueArray(children)) {
6568
6583
  children.forEach(function (h) {
6569
- return h.__fc__ && _this7.rmCtx(h.__fc__);
6584
+ return h.__fc__ && _this8.rmCtx(h.__fc__);
6570
6585
  });
6571
6586
  }
6572
6587
  }
6573
6588
 
6574
- if (ctx.root === _this7.rules) {
6575
- _this7.vm.setupState.renderRule();
6589
+ if (ctx.root === _this8.rules) {
6590
+ _this8.vm.setupState.renderRule();
6576
6591
  }
6577
6592
  }
6578
6593
  }, input);
@@ -7183,14 +7198,30 @@ var loadData = function loadData(fc) {
7183
7198
  attrs.forEach(function (attr) {
7184
7199
  if (attr && (attr.attr || attr.template)) {
7185
7200
  var fn = function fn(get) {
7201
+ var group;
7202
+
7203
+ if (rule && rule.__fc__) {
7204
+ group = rule.__fc__.getParentGroup();
7205
+ }
7206
+
7186
7207
  var value;
7187
7208
 
7188
7209
  if (attr.template) {
7189
- value = fc.$handle.loadStrVar(attr.template, get);
7210
+ value = fc.$handle.loadStrVar(attr.template, get, group ? {
7211
+ rule: rule,
7212
+ value: fc.$handle.subRuleData[group.id] || {}
7213
+ } : null);
7190
7214
  } else if (attr.handler && is.Function(attr.handler)) {
7191
7215
  value = attr.handler(get, rule, api);
7192
7216
  } else {
7193
- value = get(attr.attr, attr["default"]);
7217
+ value = fc.$handle.loadStrVar("{{".concat(attr.attr, "}}"), get, group ? {
7218
+ rule: rule,
7219
+ value: fc.$handle.subRuleData[group.id] || {}
7220
+ } : null);
7221
+ }
7222
+
7223
+ if ((value == null || value === '') && attr["default"] != null) {
7224
+ value = attr["default"];
7194
7225
  }
7195
7226
 
7196
7227
  if (attr.copy !== false) {
@@ -9468,7 +9499,7 @@ function install(FormCreate) {
9468
9499
  function elmFormCreate() {
9469
9500
  return FormCreateFactory({
9470
9501
  ui: 'element-ui',
9471
- version: '3.2.22',
9502
+ version: '3.2.23',
9472
9503
  manager: manager,
9473
9504
  extendApi: extendApi,
9474
9505
  install: install,