@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.
@@ -2357,7 +2357,7 @@
2357
2357
  v.__inject = true;
2358
2358
  return v;
2359
2359
  } else if (v.indexOf('$FNX:') === 0) {
2360
- v = makeFn('function($inject){' + v.substring(5) + '}');
2360
+ v = makeFn('function($inject){\n' + v.substring(5) + '\n}');
2361
2361
  v.__json = fn;
2362
2362
  v.__inject = true;
2363
2363
  return v;
@@ -6073,7 +6073,6 @@
6073
6073
  }
6074
6074
 
6075
6075
  Object.keys(computedRule).forEach(function (k) {
6076
- var oldValue = undefined;
6077
6076
  var computedValue = vue.computed(function () {
6078
6077
  var item = computedRule[k];
6079
6078
  if (!item) return undefined;
@@ -6081,7 +6080,7 @@
6081
6080
  var value = _this.compute(ctx, item);
6082
6081
 
6083
6082
  if (item.linkage && value === oldValueTag) {
6084
- return oldValue;
6083
+ return oldValueTag;
6085
6084
  }
6086
6085
 
6087
6086
  return value;
@@ -6102,10 +6101,15 @@
6102
6101
  }
6103
6102
 
6104
6103
  ctx.watch.push(vue.watch(computedValue, function (n) {
6105
- oldValue = n;
6104
+ if (n === oldValueTag) {
6105
+ return;
6106
+ }
6107
+
6106
6108
  setTimeout(function () {
6107
6109
  callback(n);
6108
6110
  });
6111
+ }, {
6112
+ deep: true
6109
6113
  }));
6110
6114
  });
6111
6115
  });
@@ -6127,7 +6131,7 @@
6127
6131
  if (before === false) {
6128
6132
  callback();
6129
6133
  } else {
6130
- var key = _this2.validator(value, validate);
6134
+ var key = _this2.validator(ctx, value, validate);
6131
6135
 
6132
6136
  if (!key) {
6133
6137
  if (validate.validator) {
@@ -6180,7 +6184,9 @@
6180
6184
  var formatRule = Array.isArray(invalid.rule) ? invalid.rule.join(',') : '' + invalid.rule;
6181
6185
  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));
6182
6186
  },
6183
- validator: function validator(value, validate) {
6187
+ validator: function validator(ctx, value, validate) {
6188
+ var _this3 = this;
6189
+
6184
6190
  var isEmpty = is.empty(value);
6185
6191
 
6186
6192
  if (isEmpty) {
@@ -6374,6 +6380,15 @@
6374
6380
  };
6375
6381
  }
6376
6382
 
6383
+ break;
6384
+
6385
+ case 'computed':
6386
+ if (!_this3.compute(ctx, rule)) {
6387
+ return {
6388
+ v: key
6389
+ };
6390
+ }
6391
+
6377
6392
  break;
6378
6393
  }
6379
6394
  };
@@ -6385,7 +6400,7 @@
6385
6400
  }
6386
6401
  },
6387
6402
  compute: function compute(ctx, item) {
6388
- var _this3 = this;
6403
+ var _this4 = this;
6389
6404
 
6390
6405
  var fn;
6391
6406
 
@@ -6411,7 +6426,7 @@
6411
6426
  var field = null;
6412
6427
 
6413
6428
  if (one.variable) {
6414
- field = JSON.stringify(_this3.fc.getLoadData(one.variable) || '');
6429
+ field = JSON.stringify(_this4.fc.getLoadData(one.variable) || '');
6415
6430
  } else if (one.field) {
6416
6431
  field = convertFieldToConditions(one.field || '');
6417
6432
  } else if (!one.mode) {
@@ -6432,11 +6447,11 @@
6432
6447
  flag = false;
6433
6448
  } else if (is.Function(one.handler)) {
6434
6449
  flag = invoke(function () {
6435
- return one.handler(_this3.api, ctx.rule);
6450
+ return one.handler(_this4.api, ctx.rule);
6436
6451
  });
6437
6452
  } else {
6438
6453
  flag = invoke(function () {
6439
- 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);
6454
+ 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);
6440
6455
  });
6441
6456
  }
6442
6457
 
@@ -6465,27 +6480,27 @@
6465
6480
 
6466
6481
  if (item.linkage) {
6467
6482
  return val ? invoke(function () {
6468
- return _this3.computeValue(item.linkage, ctx, group);
6483
+ return _this4.computeValue(item.linkage, ctx, group);
6469
6484
  }, undefined) : oldValueTag;
6470
6485
  }
6471
6486
 
6472
6487
  return val;
6473
6488
  } else if (is.Function(item)) {
6474
6489
  fn = function fn() {
6475
- return item(_this3.api.form, _this3.api);
6490
+ return item(_this4.api.form, _this4.api);
6476
6491
  };
6477
6492
  } else {
6478
6493
  var _group = ctx.getParentGroup();
6479
6494
 
6480
6495
  fn = function fn() {
6481
- return _this3.computeValue(item, ctx, _group);
6496
+ return _this4.computeValue(item, ctx, _group);
6482
6497
  };
6483
6498
  }
6484
6499
 
6485
6500
  return invoke(fn, undefined);
6486
6501
  },
6487
6502
  computeValue: function computeValue(str, ctx, group) {
6488
- var _this4 = this;
6503
+ var _this5 = this;
6489
6504
 
6490
6505
  var that = this;
6491
6506
  var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
@@ -6507,35 +6522,35 @@
6507
6522
  return obj;
6508
6523
  }, {});
6509
6524
  return invoke(function () {
6510
- 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);
6525
+ 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);
6511
6526
  }, undefined);
6512
6527
  },
6513
6528
  updateChildren: function updateChildren(ctx, n, o) {
6514
- var _this5 = this;
6529
+ var _this6 = this;
6515
6530
 
6516
6531
  this.deferSyncValue(function () {
6517
6532
  o && o.forEach(function (child) {
6518
6533
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
6519
- _this5.rmCtx(child.__fc__);
6534
+ _this6.rmCtx(child.__fc__);
6520
6535
  }
6521
6536
  });
6522
6537
 
6523
6538
  if (is.trueArray(n)) {
6524
- _this5.loadChildren(n, ctx);
6539
+ _this6.loadChildren(n, ctx);
6525
6540
 
6526
- _this5.bus.$emit('update', _this5.api);
6541
+ _this6.bus.$emit('update', _this6.api);
6527
6542
  }
6528
6543
  });
6529
6544
  },
6530
6545
  rmSub: function rmSub(sub) {
6531
- var _this6 = this;
6546
+ var _this7 = this;
6532
6547
 
6533
6548
  is.trueArray(sub) && sub.forEach(function (r) {
6534
- r && r.__fc__ && _this6.rmCtx(r.__fc__);
6549
+ r && r.__fc__ && _this7.rmCtx(r.__fc__);
6535
6550
  });
6536
6551
  },
6537
6552
  rmCtx: function rmCtx(ctx) {
6538
- var _this7 = this;
6553
+ var _this8 = this;
6539
6554
 
6540
6555
  if (ctx.deleted) return;
6541
6556
  var id = ctx.id,
@@ -6564,19 +6579,19 @@
6564
6579
  }
6565
6580
 
6566
6581
  this.deferSyncValue(function () {
6567
- if (!_this7.reloading) {
6582
+ if (!_this8.reloading) {
6568
6583
  if (ctx.parser.loadChildren !== false) {
6569
6584
  var children = ctx.getPending('children', ctx.rule.children);
6570
6585
 
6571
6586
  if (is.trueArray(children)) {
6572
6587
  children.forEach(function (h) {
6573
- return h.__fc__ && _this7.rmCtx(h.__fc__);
6588
+ return h.__fc__ && _this8.rmCtx(h.__fc__);
6574
6589
  });
6575
6590
  }
6576
6591
  }
6577
6592
 
6578
- if (ctx.root === _this7.rules) {
6579
- _this7.vm.setupState.renderRule();
6593
+ if (ctx.root === _this8.rules) {
6594
+ _this8.vm.setupState.renderRule();
6580
6595
  }
6581
6596
  }
6582
6597
  }, input);
@@ -7187,14 +7202,30 @@
7187
7202
  attrs.forEach(function (attr) {
7188
7203
  if (attr && (attr.attr || attr.template)) {
7189
7204
  var fn = function fn(get) {
7205
+ var group;
7206
+
7207
+ if (rule && rule.__fc__) {
7208
+ group = rule.__fc__.getParentGroup();
7209
+ }
7210
+
7190
7211
  var value;
7191
7212
 
7192
7213
  if (attr.template) {
7193
- value = fc.$handle.loadStrVar(attr.template, get);
7214
+ value = fc.$handle.loadStrVar(attr.template, get, group ? {
7215
+ rule: rule,
7216
+ value: fc.$handle.subRuleData[group.id] || {}
7217
+ } : null);
7194
7218
  } else if (attr.handler && is.Function(attr.handler)) {
7195
7219
  value = attr.handler(get, rule, api);
7196
7220
  } else {
7197
- value = get(attr.attr, attr["default"]);
7221
+ value = fc.$handle.loadStrVar("{{".concat(attr.attr, "}}"), get, group ? {
7222
+ rule: rule,
7223
+ value: fc.$handle.subRuleData[group.id] || {}
7224
+ } : null);
7225
+ }
7226
+
7227
+ if ((value == null || value === '') && attr["default"] != null) {
7228
+ value = attr["default"];
7198
7229
  }
7199
7230
 
7200
7231
  if (attr.copy !== false) {
@@ -9472,7 +9503,7 @@
9472
9503
  function elmFormCreate() {
9473
9504
  return FormCreateFactory({
9474
9505
  ui: 'element-ui',
9475
- version: '3.2.22',
9506
+ version: '3.2.23',
9476
9507
  manager: manager,
9477
9508
  extendApi: extendApi,
9478
9509
  install: install,