@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.
@@ -2238,6 +2238,10 @@
2238
2238
  type: Boolean,
2239
2239
  "default": undefined
2240
2240
  },
2241
+ preview: {
2242
+ type: Boolean,
2243
+ "default": undefined
2244
+ },
2241
2245
  api: Object,
2242
2246
  name: String,
2243
2247
  subForm: {
@@ -2374,7 +2378,7 @@
2374
2378
  deep: true
2375
2379
  });
2376
2380
  vue.watch(function () {
2377
- return props.disabled;
2381
+ return [props.disabled, props.preview];
2378
2382
  }, function () {
2379
2383
  fapi.refresh();
2380
2384
  });
@@ -2653,6 +2657,64 @@
2653
2657
  return o;
2654
2658
  }
2655
2659
 
2660
+ var changeType = function changeType(a, b) {
2661
+ if (typeof a === 'string') {
2662
+ return String(b);
2663
+ } else if (typeof a === 'number') {
2664
+ return Number(b);
2665
+ }
2666
+
2667
+ return b;
2668
+ };
2669
+
2670
+ var condition = {
2671
+ '==': function _(a, b) {
2672
+ return JSON.stringify(a) === JSON.stringify(changeType(a, b));
2673
+ },
2674
+ '!=': function _(a, b) {
2675
+ return !condition['=='](a, b);
2676
+ },
2677
+ '>': function _(a, b) {
2678
+ return a > b;
2679
+ },
2680
+ '>=': function _(a, b) {
2681
+ return a >= b;
2682
+ },
2683
+ '<': function _(a, b) {
2684
+ return a < b;
2685
+ },
2686
+ '<=': function _(a, b) {
2687
+ return a <= b;
2688
+ },
2689
+ on: function on(a, b) {
2690
+ return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
2691
+ },
2692
+ notOn: function notOn(a, b) {
2693
+ return !condition.on(a, b);
2694
+ },
2695
+ "in": function _in(a, b) {
2696
+ return b && b.indexOf && b.indexOf(a) > -1;
2697
+ },
2698
+ notIn: function notIn(a, b) {
2699
+ return !condition["in"](a, b);
2700
+ },
2701
+ between: function between(a, b) {
2702
+ return a > b[0] && a < b[1];
2703
+ },
2704
+ notBetween: function notBetween(a, b) {
2705
+ return a < b[0] || a > b[1];
2706
+ },
2707
+ empty: function empty(a) {
2708
+ return is.empty(a);
2709
+ },
2710
+ notEmpty: function notEmpty(a) {
2711
+ return !is.empty(a);
2712
+ },
2713
+ pattern: function pattern(a, b) {
2714
+ return new RegExp(b, 'g').test(a);
2715
+ }
2716
+ };
2717
+
2656
2718
  function baseRule() {
2657
2719
  return {
2658
2720
  props: {},
@@ -2905,7 +2967,7 @@
2905
2967
  if (!ctx) return initial;
2906
2968
  initial[ctx.field] = copy(ctx.rule.value);
2907
2969
  return initial;
2908
- }, {});
2970
+ }, h.options.appendValue ? copy(h.appendData) : {});
2909
2971
  },
2910
2972
  getValue: function getValue(field) {
2911
2973
  var ctx = h.getFieldCtx(field);
@@ -3321,10 +3383,7 @@
3321
3383
 
3322
3384
  if (config.type === 'fetch') {
3323
3385
  api.fetch(config).then(function (res) {
3324
- resolve({
3325
- res: res,
3326
- config: config
3327
- });
3386
+ resolve(res);
3328
3387
  })["catch"](inject);
3329
3388
  } else {
3330
3389
  resolve(config.data);
@@ -3568,7 +3627,7 @@
3568
3627
  this.setOptions(ctx);
3569
3628
  this.ctxProp(ctx);
3570
3629
  var prop = ctx.prop;
3571
- prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3630
+ prop.preview = !!(prop.preview != null ? prop.preview : this.vm.props.preview !== undefined ? this.vm.props.preview : this.options.preview || false);
3572
3631
  prop.props.formCreateInject = this.injectProp(ctx);
3573
3632
  var cacheFlag = prop.cache !== false;
3574
3633
  var preview = prop.preview;
@@ -4296,14 +4355,31 @@
4296
4355
  var _this4 = this;
4297
4356
 
4298
4357
  return toArray(this.prop.validate).map(function (item) {
4299
- return _objectSpread2(_objectSpread2({}, item), {}, {
4300
- inject: {
4301
- id: _this4.id,
4302
- field: _this4.field,
4303
- rule: _this4.rule,
4304
- api: _this4.$handle.api
4305
- }
4306
- });
4358
+ if (is.Function(item.validator)) {
4359
+ var temp = _objectSpread2({}, item);
4360
+
4361
+ var that = _this4;
4362
+
4363
+ temp.validator = function () {
4364
+ var _item$validator;
4365
+
4366
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4367
+ args[_key] = arguments[_key];
4368
+ }
4369
+
4370
+ return (_item$validator = item.validator).call.apply(_item$validator, [{
4371
+ that: this,
4372
+ id: that.id,
4373
+ field: that.field,
4374
+ rule: that.rule,
4375
+ api: that.$handle.api
4376
+ }].concat(args));
4377
+ };
4378
+
4379
+ return temp;
4380
+ }
4381
+
4382
+ return item;
4307
4383
  });
4308
4384
  },
4309
4385
  check: function check(handle) {
@@ -4412,73 +4488,6 @@
4412
4488
  }
4413
4489
  });
4414
4490
 
4415
- var condition = {
4416
- '==': function _(b) {
4417
- return function (a) {
4418
- return a === b;
4419
- };
4420
- },
4421
- '!=': function _(b) {
4422
- return function (a) {
4423
- return a !== b;
4424
- };
4425
- },
4426
- '<>': function _(b) {
4427
- return function (a) {
4428
- return a !== b;
4429
- };
4430
- },
4431
- '>': function _(b) {
4432
- return function (a) {
4433
- return a > b;
4434
- };
4435
- },
4436
- '>=': function _(b) {
4437
- return function (a) {
4438
- return a >= b;
4439
- };
4440
- },
4441
- '<': function _(b) {
4442
- return function (a) {
4443
- return a < b;
4444
- };
4445
- },
4446
- '<=': function _(b) {
4447
- return function (a) {
4448
- return a <= b;
4449
- };
4450
- },
4451
- 'in': function _in(b) {
4452
- return function (a) {
4453
- return b && b.indexOf && b.indexOf(a) > -1;
4454
- };
4455
- },
4456
- 'on': function on(b) {
4457
- return function (a) {
4458
- return a && a.indexOf && a.indexOf(b) > -1;
4459
- };
4460
- },
4461
- 'notIn': function notIn(b) {
4462
- return function (a) {
4463
- return !condition["in"](b)(a);
4464
- };
4465
- },
4466
- 'notOn': function notOn(b) {
4467
- return function (a) {
4468
- return !condition.on(b)(a);
4469
- };
4470
- },
4471
- 'between': function between(b) {
4472
- return function (a) {
4473
- return a > b[0] && a < b[1];
4474
- };
4475
- },
4476
- 'notBetween': function notBetween(b) {
4477
- return function (a) {
4478
- return a < b[0] || a > b[1];
4479
- };
4480
- }
4481
- };
4482
4491
  function useLoader(Handler) {
4483
4492
  extend(Handler.prototype, {
4484
4493
  nextRefresh: function nextRefresh(fn) {
@@ -4668,7 +4677,7 @@
4668
4677
  if (!ctx) {
4669
4678
  var _rule2 = _this6.parseRule(_rule);
4670
4679
 
4671
- ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
4680
+ ctx = new RuleContext(_this6, _rule2, defaultValue);
4672
4681
 
4673
4682
  _this6.bindParser(ctx);
4674
4683
  } else {
@@ -4751,7 +4760,10 @@
4751
4760
 
4752
4761
  var _loop = function _loop(i) {
4753
4762
  var control = controls[i],
4754
- handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
4763
+ handleFn = control.handle || function (val) {
4764
+ return (condition[control.condition || '=='] || condition['=='])(val, control.value);
4765
+ };
4766
+
4755
4767
  if (!is.trueArray(control.rule)) return "continue";
4756
4768
 
4757
4769
  var data = _objectSpread2(_objectSpread2({}, control), {}, {
@@ -5019,7 +5031,7 @@
5019
5031
  return this.deferSyncFn.sync = true;
5020
5032
  }
5021
5033
 
5022
- this.vm.setupState.updateValue(_objectSpread2({}, this.form));
5034
+ this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
5023
5035
  },
5024
5036
  isChange: function isChange(ctx, value) {
5025
5037
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
@@ -5273,15 +5285,56 @@
5273
5285
  if (!item) return undefined;
5274
5286
  var fn;
5275
5287
 
5276
- if (is.Function(item)) {
5288
+ if (_typeof(item) === 'object') {
5289
+ var group = ctx.getParentGroup();
5290
+
5291
+ var checkCondition = function checkCondition(item) {
5292
+ item = Array.isArray(item) ? {
5293
+ mode: 'AND',
5294
+ group: item
5295
+ } : item;
5296
+
5297
+ if (!is.trueArray(item.group)) {
5298
+ return true;
5299
+ }
5300
+
5301
+ var or = item.mode === 'OR';
5302
+ var valid = true;
5303
+
5304
+ for (var i = 0; i < item.group.length; i++) {
5305
+ var one = item.group[i];
5306
+ var flag = void 0;
5307
+
5308
+ if (one.mode) {
5309
+ flag = checkCondition(one);
5310
+ } else if (!condition[one.condition]) {
5311
+ flag = false;
5312
+ } else {
5313
+ 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] || {} : {});
5314
+ }
5315
+
5316
+ if (or && flag) {
5317
+ return true;
5318
+ }
5319
+
5320
+ if (!or) {
5321
+ valid = valid && flag;
5322
+ }
5323
+ }
5324
+
5325
+ return or ? false : valid;
5326
+ };
5327
+
5328
+ return checkCondition(item);
5329
+ } else if (is.Function(item)) {
5277
5330
  fn = function fn() {
5278
5331
  return item(_this.api.form, _this.api);
5279
5332
  };
5280
5333
  } else {
5281
- var group = ctx.getParentGroup();
5334
+ var _group = ctx.getParentGroup();
5282
5335
 
5283
5336
  fn = function fn() {
5284
- 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);
5337
+ 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);
5285
5338
  };
5286
5339
  }
5287
5340
 
@@ -5972,6 +6025,8 @@
5972
6025
  return;
5973
6026
  }
5974
6027
 
6028
+ option = deepCopy(option);
6029
+
5975
6030
  if (!option.to) {
5976
6031
  option.to = 'options';
5977
6032
  }
@@ -7418,7 +7473,7 @@
7418
7473
  function elmFormCreate() {
7419
7474
  return FormCreateFactory({
7420
7475
  ui: 'element-ui',
7421
- version: '3.1.32',
7476
+ version: '3.1.33',
7422
7477
  manager: manager,
7423
7478
  extendApi: extendApi,
7424
7479
  install: install,