@form-create/element-ui 3.1.32 → 3.1.33

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.1.32
2
+ * @form-create/element-ui v3.1.33
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2234,6 +2234,10 @@ function $FormCreate(FormCreate, components, directives) {
2234
2234
  type: Boolean,
2235
2235
  "default": undefined
2236
2236
  },
2237
+ preview: {
2238
+ type: Boolean,
2239
+ "default": undefined
2240
+ },
2237
2241
  api: Object,
2238
2242
  name: String,
2239
2243
  subForm: {
@@ -2370,7 +2374,7 @@ function $FormCreate(FormCreate, components, directives) {
2370
2374
  deep: true
2371
2375
  });
2372
2376
  watch(function () {
2373
- return props.disabled;
2377
+ return [props.disabled, props.preview];
2374
2378
  }, function () {
2375
2379
  fapi.refresh();
2376
2380
  });
@@ -2649,6 +2653,64 @@ function setPrototypeOf(o, proto) {
2649
2653
  return o;
2650
2654
  }
2651
2655
 
2656
+ var changeType = function changeType(a, b) {
2657
+ if (typeof a === 'string') {
2658
+ return String(b);
2659
+ } else if (typeof a === 'number') {
2660
+ return Number(b);
2661
+ }
2662
+
2663
+ return b;
2664
+ };
2665
+
2666
+ var condition = {
2667
+ '==': function _(a, b) {
2668
+ return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2669
+ },
2670
+ '!=': function _(a, b) {
2671
+ return !condition['=='](a, b);
2672
+ },
2673
+ '>': function _(a, b) {
2674
+ return a > b;
2675
+ },
2676
+ '>=': function _(a, b) {
2677
+ return a >= b;
2678
+ },
2679
+ '<': function _(a, b) {
2680
+ return a < b;
2681
+ },
2682
+ '<=': function _(a, b) {
2683
+ return a <= b;
2684
+ },
2685
+ on: function on(a, b) {
2686
+ return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2687
+ },
2688
+ notOn: function notOn(a, b) {
2689
+ return !condition.on(a, b);
2690
+ },
2691
+ "in": function _in(a, b) {
2692
+ return b && b.indexOf && b.indexOf(a) > -1;
2693
+ },
2694
+ notIn: function notIn(a, b) {
2695
+ return !condition["in"](a, b);
2696
+ },
2697
+ between: function between(a, b) {
2698
+ return a > b[0] && a < b[1];
2699
+ },
2700
+ notBetween: function notBetween(a, b) {
2701
+ return a < b[0] || a > b[1];
2702
+ },
2703
+ empty: function empty(a) {
2704
+ return is.empty(a);
2705
+ },
2706
+ notEmpty: function notEmpty(a) {
2707
+ return !is.empty(a);
2708
+ },
2709
+ pattern: function pattern(a, b) {
2710
+ return new RegExp(b, 'g').test(a);
2711
+ }
2712
+ };
2713
+
2652
2714
  function baseRule() {
2653
2715
  return {
2654
2716
  props: {},
@@ -2901,7 +2963,7 @@ function Api(h) {
2901
2963
  if (!ctx) return initial;
2902
2964
  initial[ctx.field] = copy(ctx.rule.value);
2903
2965
  return initial;
2904
- }, {});
2966
+ }, h.options.appendValue ? copy(h.appendData) : {});
2905
2967
  },
2906
2968
  getValue: function getValue(field) {
2907
2969
  var ctx = h.getFieldCtx(field);
@@ -3317,10 +3379,7 @@ function Api(h) {
3317
3379
 
3318
3380
  if (config.type === 'fetch') {
3319
3381
  api.fetch(config).then(function (res) {
3320
- resolve({
3321
- res: res,
3322
- config: config
3323
- });
3382
+ resolve(res);
3324
3383
  })["catch"](inject);
3325
3384
  } else {
3326
3385
  resolve(config.data);
@@ -3564,7 +3623,7 @@ function useRender$1(Render) {
3564
3623
  this.setOptions(ctx);
3565
3624
  this.ctxProp(ctx);
3566
3625
  var prop = ctx.prop;
3567
- prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3626
+ prop.preview = !!(prop.preview != null ? prop.preview : this.vm.props.preview !== undefined ? this.vm.props.preview : this.options.preview || false);
3568
3627
  prop.props.formCreateInject = this.injectProp(ctx);
3569
3628
  var cacheFlag = prop.cache !== false;
3570
3629
  var preview = prop.preview;
@@ -4292,14 +4351,31 @@ extend(RuleContext.prototype, {
4292
4351
  var _this4 = this;
4293
4352
 
4294
4353
  return toArray(this.prop.validate).map(function (item) {
4295
- return _objectSpread2(_objectSpread2({}, item), {}, {
4296
- inject: {
4297
- id: _this4.id,
4298
- field: _this4.field,
4299
- rule: _this4.rule,
4300
- api: _this4.$handle.api
4301
- }
4302
- });
4354
+ if (is.Function(item.validator)) {
4355
+ var temp = _objectSpread2({}, item);
4356
+
4357
+ var that = _this4;
4358
+
4359
+ temp.validator = function () {
4360
+ var _item$validator;
4361
+
4362
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4363
+ args[_key] = arguments[_key];
4364
+ }
4365
+
4366
+ return (_item$validator = item.validator).call.apply(_item$validator, [{
4367
+ that: this,
4368
+ id: that.id,
4369
+ field: that.field,
4370
+ rule: that.rule,
4371
+ api: that.$handle.api
4372
+ }].concat(args));
4373
+ };
4374
+
4375
+ return temp;
4376
+ }
4377
+
4378
+ return item;
4303
4379
  });
4304
4380
  },
4305
4381
  check: function check(handle) {
@@ -4408,73 +4484,6 @@ extend(RuleContext.prototype, {
4408
4484
  }
4409
4485
  });
4410
4486
 
4411
- var condition = {
4412
- '==': function _(b) {
4413
- return function (a) {
4414
- return a === b;
4415
- };
4416
- },
4417
- '!=': function _(b) {
4418
- return function (a) {
4419
- return a !== b;
4420
- };
4421
- },
4422
- '<>': function _(b) {
4423
- return function (a) {
4424
- return a !== b;
4425
- };
4426
- },
4427
- '>': function _(b) {
4428
- return function (a) {
4429
- return a > b;
4430
- };
4431
- },
4432
- '>=': function _(b) {
4433
- return function (a) {
4434
- return a >= b;
4435
- };
4436
- },
4437
- '<': function _(b) {
4438
- return function (a) {
4439
- return a < b;
4440
- };
4441
- },
4442
- '<=': function _(b) {
4443
- return function (a) {
4444
- return a <= b;
4445
- };
4446
- },
4447
- 'in': function _in(b) {
4448
- return function (a) {
4449
- return b && b.indexOf && b.indexOf(a) > -1;
4450
- };
4451
- },
4452
- 'on': function on(b) {
4453
- return function (a) {
4454
- return a && a.indexOf && a.indexOf(b) > -1;
4455
- };
4456
- },
4457
- 'notIn': function notIn(b) {
4458
- return function (a) {
4459
- return !condition["in"](b)(a);
4460
- };
4461
- },
4462
- 'notOn': function notOn(b) {
4463
- return function (a) {
4464
- return !condition.on(b)(a);
4465
- };
4466
- },
4467
- 'between': function between(b) {
4468
- return function (a) {
4469
- return a > b[0] && a < b[1];
4470
- };
4471
- },
4472
- 'notBetween': function notBetween(b) {
4473
- return function (a) {
4474
- return a < b[0] || a > b[1];
4475
- };
4476
- }
4477
- };
4478
4487
  function useLoader(Handler) {
4479
4488
  extend(Handler.prototype, {
4480
4489
  nextRefresh: function nextRefresh(fn) {
@@ -4664,7 +4673,7 @@ function useLoader(Handler) {
4664
4673
  if (!ctx) {
4665
4674
  var _rule2 = _this6.parseRule(_rule);
4666
4675
 
4667
- ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
4676
+ ctx = new RuleContext(_this6, _rule2, defaultValue);
4668
4677
 
4669
4678
  _this6.bindParser(ctx);
4670
4679
  } else {
@@ -4747,7 +4756,10 @@ function useLoader(Handler) {
4747
4756
 
4748
4757
  var _loop = function _loop(i) {
4749
4758
  var control = controls[i],
4750
- handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
4759
+ handleFn = control.handle || function (val) {
4760
+ return (condition[control.condition || '=='] || condition['=='])(val, control.value);
4761
+ };
4762
+
4751
4763
  if (!is.trueArray(control.rule)) return "continue";
4752
4764
 
4753
4765
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
@@ -5015,7 +5027,7 @@ function useInput(Handler) {
5015
5027
  return this.deferSyncFn.sync = true;
5016
5028
  }
5017
5029
 
5018
- this.vm.setupState.updateValue(_objectSpread2({}, this.form));
5030
+ this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
5019
5031
  },
5020
5032
  isChange: function isChange(ctx, value) {
5021
5033
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
@@ -5269,15 +5281,56 @@ function useContext(Handler) {
5269
5281
  if (!item) return undefined;
5270
5282
  var fn;
5271
5283
 
5272
- if (is.Function(item)) {
5284
+ if (_typeof(item) === 'object') {
5285
+ var group = ctx.getParentGroup();
5286
+
5287
+ var checkCondition = function checkCondition(item) {
5288
+ item = Array.isArray(item) ? {
5289
+ mode: 'AND',
5290
+ group: item
5291
+ } : item;
5292
+
5293
+ if (!is.trueArray(item.group)) {
5294
+ return true;
5295
+ }
5296
+
5297
+ var or = item.mode === 'OR';
5298
+ var valid = true;
5299
+
5300
+ for (var i = 0; i < item.group.length; i++) {
5301
+ var one = item.group[i];
5302
+ var flag = void 0;
5303
+
5304
+ if (one.mode) {
5305
+ flag = checkCondition(one);
5306
+ } else if (!condition[one.condition]) {
5307
+ flag = false;
5308
+ } else {
5309
+ flag = new Function('_$', '_$val', 'top', 'group', "with(top){with(this){with(group){ return _$['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '_$val', "); }}}")).call(_this.api.form, condition, one.value, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
5310
+ }
5311
+
5312
+ if (or && flag) {
5313
+ return true;
5314
+ }
5315
+
5316
+ if (!or) {
5317
+ valid = valid && flag;
5318
+ }
5319
+ }
5320
+
5321
+ return or ? false : valid;
5322
+ };
5323
+
5324
+ return checkCondition(item);
5325
+ } else if (is.Function(item)) {
5273
5326
  fn = function fn() {
5274
5327
  return item(_this.api.form, _this.api);
5275
5328
  };
5276
5329
  } else {
5277
- var group = ctx.getParentGroup();
5330
+ var _group = ctx.getParentGroup();
5278
5331
 
5279
5332
  fn = function fn() {
5280
- return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {}, ctx.rule, _this.api);
5333
+ return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, _group ? _this.subRuleData[_group.id] || {} : {}, ctx.rule, _this.api);
5281
5334
  };
5282
5335
  }
5283
5336
 
@@ -5968,6 +6021,8 @@ var fetch = function fetch(fc) {
5968
6021
  return;
5969
6022
  }
5970
6023
 
6024
+ option = deepCopy(option);
6025
+
5971
6026
  if (!option.to) {
5972
6027
  option.to = 'options';
5973
6028
  }
@@ -7414,7 +7469,7 @@ function install(FormCreate) {
7414
7469
  function elmFormCreate() {
7415
7470
  return FormCreateFactory({
7416
7471
  ui: 'element-ui',
7417
- version: '3.1.32',
7472
+ version: '3.1.33',
7418
7473
  manager: manager,
7419
7474
  extendApi: extendApi,
7420
7475
  install: install,