@form-create/element-ui 3.2.13 → 3.2.14

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.13
2
+ * @form-create/element-ui v3.2.14
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -226,12 +226,14 @@
226
226
  }
227
227
  },
228
228
  type: String,
229
+ options: Array,
229
230
  input: Boolean,
230
231
  inputValue: String
231
232
  },
232
233
  emits: ['update:modelValue', 'fc.el'],
233
234
  setup: function setup(props, _) {
234
235
  var options = vue.toRef(props.formCreateInject, 'options', []);
236
+ var opt = vue.toRef(props, 'options');
235
237
  var value = vue.toRef(props, 'modelValue');
236
238
  var inputValue = vue.toRef(props, 'inputValue', '');
237
239
  var customValue = vue.ref(inputValue.value);
@@ -262,9 +264,37 @@
262
264
  updateCustomValue(n);
263
265
  });
264
266
 
265
- var _options = function _options() {
266
- return Array.isArray(options.value) ? options.value : [];
267
- };
267
+ var _options = vue.computed(function () {
268
+ var arr = options.value || [];
269
+
270
+ if (opt.value) {
271
+ arr = opt.value || [];
272
+ }
273
+
274
+ return Array.isArray(arr) ? arr : [];
275
+ });
276
+
277
+ vue.watch(value, function (n) {
278
+ var value = null;
279
+
280
+ if (!inputValue.value && n != null && Array.isArray(n) && n.length > 0 && input.value) {
281
+ var values = _options.value.map(function (item) {
282
+ return item.value;
283
+ });
284
+
285
+ n.forEach(function (val) {
286
+ if (values.indexOf(val) === -1) {
287
+ value = val;
288
+ }
289
+ });
290
+ }
291
+
292
+ if (value != null) {
293
+ customValue.value = value;
294
+ }
295
+ }, {
296
+ immediate: true
297
+ });
268
298
 
269
299
  var onInput = function onInput(n) {
270
300
  _.emit('update:modelValue', n);
@@ -308,7 +338,7 @@
308
338
  "ref": "el"
309
339
  }), _objectSpread2({
310
340
  "default": function _default() {
311
- return [_this.options().map(function (opt, index) {
341
+ return [_this.options.map(function (opt, index) {
312
342
  var props = _objectSpread2({}, opt);
313
343
 
314
344
  var value = props.value;
@@ -1019,6 +1049,7 @@
1019
1049
  type: [String, Number, Boolean],
1020
1050
  "default": ''
1021
1051
  },
1052
+ options: Array,
1022
1053
  type: String,
1023
1054
  input: Boolean,
1024
1055
  inputValue: String
@@ -1026,15 +1057,11 @@
1026
1057
  emits: ['update:modelValue', 'fc.el'],
1027
1058
  setup: function setup(props, _) {
1028
1059
  var options = vue.toRef(props.formCreateInject, 'options', []);
1060
+ var opt = vue.toRef(props, 'options');
1029
1061
  var value = vue.toRef(props, 'modelValue');
1030
1062
  var inputValue = vue.toRef(props, 'inputValue', '');
1031
1063
  var customValue = vue.ref(inputValue.value);
1032
1064
  var input = vue.toRef(props, 'input', false);
1033
-
1034
- var _options = function _options() {
1035
- return Array.isArray(options.value) ? options.value : [];
1036
- };
1037
-
1038
1065
  vue.watch(inputValue, function (n) {
1039
1066
  if (!input.value) {
1040
1067
  customValue.value = n;
@@ -1044,6 +1071,32 @@
1044
1071
  updateCustomValue(n);
1045
1072
  });
1046
1073
 
1074
+ var _options = vue.computed(function () {
1075
+ var arr = options.value || [];
1076
+
1077
+ if (opt.value) {
1078
+ arr = opt.value || [];
1079
+ }
1080
+
1081
+ return Array.isArray(arr) ? arr : [];
1082
+ });
1083
+
1084
+ vue.watch(value, function (n) {
1085
+ var flag = false;
1086
+
1087
+ if (!inputValue.value && n != null && input.value) {
1088
+ flag = _options.value.map(function (item) {
1089
+ return item.value;
1090
+ }).indexOf(n) === -1;
1091
+ }
1092
+
1093
+ if (flag) {
1094
+ customValue.value = n;
1095
+ }
1096
+ }, {
1097
+ immediate: true
1098
+ });
1099
+
1047
1100
  var onInput = function onInput(n) {
1048
1101
  _.emit('update:modelValue', n);
1049
1102
  };
@@ -1097,7 +1150,7 @@
1097
1150
  "ref": "el"
1098
1151
  }), _objectSpread2({
1099
1152
  "default": function _default() {
1100
- return [_this.options().map(function (opt, index) {
1153
+ return [_this.options.map(function (opt, index) {
1101
1154
  var props = _objectSpread2({}, opt);
1102
1155
 
1103
1156
  var value = props.value;
@@ -1400,7 +1453,7 @@
1400
1453
  var files = fileList.map(function (v) {
1401
1454
  return v.is_string ? v.url : v.value || v.url;
1402
1455
  }).filter(function (url) {
1403
- return url !== undefined;
1456
+ return url !== undefined && url.indexOf('blob:') !== 0;
1404
1457
  });
1405
1458
  this.$emit('update:modelValue', files);
1406
1459
  },
@@ -1441,7 +1494,7 @@
1441
1494
  "ref": "upload"
1442
1495
  }), _objectSpread2({
1443
1496
  "default": function _default() {
1444
- return [(_this$$slots$default = (_this$$slots = _this.$slots)["default"]) !== null && _this$$slots$default !== void 0 && _this$$slots$default.call(_this$$slots) || ['text', 'picture'].indexOf(_this.listType) === -1 ? vue.createVNode(vue.resolveComponent("ElIcon"), null, {
1497
+ return [((_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)) || (['text', 'picture'].indexOf(_this.listType) === -1 ? vue.createVNode(vue.resolveComponent("ElIcon"), null, {
1445
1498
  "default": function _default() {
1446
1499
  return [vue.createVNode(script$1, null, null)];
1447
1500
  }
@@ -1451,7 +1504,7 @@
1451
1504
  "default": function _default() {
1452
1505
  return [vue.createTextVNode("\u70B9\u51FB\u4E0A\u4F20")];
1453
1506
  }
1454
- })];
1507
+ }))];
1455
1508
  }
1456
1509
  }, getSlot(this.$slots, ['default']))), vue.createVNode(vue.resolveComponent("ElDialog"), {
1457
1510
  "appendToBody": true,
@@ -2150,6 +2203,7 @@
2150
2203
  },
2151
2204
  index: [String, Number],
2152
2205
  api: Object,
2206
+ locale: [String, Object],
2153
2207
  name: String,
2154
2208
  subForm: {
2155
2209
  type: Boolean,
@@ -2393,7 +2447,7 @@
2393
2447
 
2394
2448
  var normalMerge = ['props'];
2395
2449
  var toArrayMerge = ['class', 'style', 'directives'];
2396
- var functionalMerge = ['on'];
2450
+ var functionalMerge = ['on', 'hook'];
2397
2451
 
2398
2452
  var mergeProps = function mergeProps(objects) {
2399
2453
  var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -2490,15 +2544,11 @@
2490
2544
 
2491
2545
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2492
2546
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2493
- var $T = '$FN:';
2494
- var $TX = '$FNX:';
2495
- var $ON = '$GLOBAL:';
2496
- var FUNCTION = 'function';
2497
2547
  function toJson(obj, space) {
2498
2548
  return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
2499
2549
  if (val && val._isVue === true) return undefined;
2500
2550
 
2501
- if (_typeof(val) !== FUNCTION) {
2551
+ if (typeof val !== 'function') {
2502
2552
  return val;
2503
2553
  }
2504
2554
 
@@ -2525,11 +2575,14 @@
2525
2575
  if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2526
2576
  v = v.replace(SUFFIX, '').replace(PREFIX, '');
2527
2577
  flag = true;
2528
- } else if (v.indexOf($T) === 0) {
2529
- v = v.replace($T, '');
2578
+ } else if (v.indexOf('$FN:') === 0) {
2579
+ v = v.substring(4);
2580
+ flag = true;
2581
+ } else if (v.indexOf('$EXEC:') === 0) {
2582
+ v = v.substring(6);
2530
2583
  flag = true;
2531
- } else if (v.indexOf($ON) === 0) {
2532
- var name = v.replace($ON, '');
2584
+ } else if (v.indexOf('$GLOBAL:') === 0) {
2585
+ var name = v.substring(8);
2533
2586
 
2534
2587
  v = function v() {
2535
2588
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -2548,17 +2601,19 @@
2548
2601
  v.__json = fn;
2549
2602
  v.__inject = true;
2550
2603
  return v;
2551
- } else if (v.indexOf($TX) === 0) {
2552
- v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2604
+ } else if (v.indexOf('$FNX:') === 0) {
2605
+ v = makeFn('function($inject){' + v.substring(5) + '}');
2553
2606
  v.__json = fn;
2554
2607
  v.__inject = true;
2555
2608
  return v;
2556
- } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2609
+ } else if (!mode && v.indexOf('function ') === 0 && v !== 'function ') {
2610
+ flag = true;
2611
+ } else if (!mode && v.indexOf('function(') === 0 && v !== 'function(') {
2557
2612
  flag = true;
2558
2613
  }
2559
2614
 
2560
2615
  if (!flag) return fn;
2561
- var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2616
+ var val = makeFn(v);
2562
2617
  val.__json = fn;
2563
2618
  return val;
2564
2619
  } catch (e) {
@@ -2924,7 +2979,17 @@
2924
2979
  }
2925
2980
 
2926
2981
  var xhr = new XMLHttpRequest();
2927
- var action = option.action;
2982
+ var action = option.action || '';
2983
+
2984
+ if (option.query) {
2985
+ var queryString = new URLSearchParams(option.query).toString();
2986
+
2987
+ if (action.includes('?')) {
2988
+ action += "&".concat(queryString);
2989
+ } else {
2990
+ action += "?".concat(queryString);
2991
+ }
2992
+ }
2928
2993
 
2929
2994
  xhr.onerror = function error(e) {
2930
2995
  option.onError(e);
@@ -2965,7 +3030,7 @@
2965
3030
  });
2966
3031
  xhr.send(formData);
2967
3032
  }
2968
- function asyncFetch(config, _fetch) {
3033
+ function asyncFetch(config, _fetch, api) {
2969
3034
  return new Promise(function (resolve, reject) {
2970
3035
  (_fetch || fetch$1)(_objectSpread2(_objectSpread2({}, config), {}, {
2971
3036
  onSuccess: function onSuccess(res) {
@@ -2983,7 +3048,7 @@
2983
3048
  };
2984
3049
  }
2985
3050
 
2986
- resolve(fn(res));
3051
+ resolve(fn(res, undefined, api));
2987
3052
  },
2988
3053
  onError: function onError(err) {
2989
3054
  reject(err);
@@ -3588,7 +3653,7 @@
3588
3653
  opt = deepCopy(opt);
3589
3654
  opt = h.loadFetchVar(opt);
3590
3655
  h.beforeFetch(opt).then(function () {
3591
- return asyncFetch(opt, h.fc.create.fetch).then(function (res) {
3656
+ return asyncFetch(opt, h.fc.create.fetch, api).then(function (res) {
3592
3657
  invoke(function () {
3593
3658
  return opt.onSuccess && opt.onSuccess(res);
3594
3659
  });
@@ -3608,7 +3673,7 @@
3608
3673
 
3609
3674
  _opt = h.loadFetchVar(_opt, get);
3610
3675
  h.beforeFetch(_opt).then(function () {
3611
- return asyncFetch(_opt, h.fc.create.fetch).then(function (res) {
3676
+ return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
3612
3677
  invoke(function () {
3613
3678
  return _opt.onSuccess && _opt.onSuccess(res);
3614
3679
  });
@@ -3631,6 +3696,12 @@
3631
3696
  refreshData: function refreshData(id) {
3632
3697
  return h.fc.refreshData(id);
3633
3698
  },
3699
+ t: function t(id, params) {
3700
+ return h.fc.t(id, params);
3701
+ },
3702
+ getLocale: function getLocale() {
3703
+ return h.fc.getLocale();
3704
+ },
3634
3705
  helper: {
3635
3706
  tidyFields: tidyFields,
3636
3707
  props: props
@@ -3961,15 +4032,19 @@
3961
4032
  },
3962
4033
  none: function none(vn) {
3963
4034
  if (vn) {
3964
- if (Array.isArray(vn.props["class"])) {
3965
- vn.props["class"].push('fc-none');
3966
- } else {
3967
- vn.props["class"] = vn.props["class"] ? [vn.props["class"], 'fc-none'] : 'fc-none';
3968
- }
3969
-
4035
+ vn.props["class"] = this.mergeClass(vn.props["class"], 'fc-none');
3970
4036
  return vn;
3971
4037
  }
3972
4038
  },
4039
+ mergeClass: function mergeClass(target, value) {
4040
+ if (Array.isArray(target)) {
4041
+ target.push(value);
4042
+ } else {
4043
+ return target ? [target, value] : value;
4044
+ }
4045
+
4046
+ return target;
4047
+ },
3973
4048
  stable: function stable(vn) {
3974
4049
  var _this5 = this;
3975
4050
 
@@ -4069,6 +4144,7 @@
4069
4144
  callback: function callback(value) {
4070
4145
  _this7.onInput(ctx, value);
4071
4146
  },
4147
+ modelField: field,
4072
4148
  value: this.$handle.getFormData(ctx)
4073
4149
  };
4074
4150
  props.push({
@@ -4087,6 +4163,7 @@
4087
4163
  ctx.el = this.vm.refs[ctx.ref] || el;
4088
4164
  ctx.parser.mounted(ctx);
4089
4165
  this.$handle.effect(ctx, 'mounted');
4166
+ this.$handle.targetHook(ctx, 'mounted');
4090
4167
  },
4091
4168
  onInput: function onInput(ctx, value) {
4092
4169
  if (ctx.prop.modelEmit) {
@@ -4648,43 +4725,17 @@
4648
4725
  var rule = _objectSpread2({}, this.rule);
4649
4726
 
4650
4727
  delete rule.children;
4728
+ delete rule.validate;
4651
4729
  this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
4652
4730
  return _this3.payload[k];
4653
4731
  })), [this.computed]));
4732
+ this.prop.validate = [].concat(_toConsumableArray(this.refRule.__$validate.value || []), _toConsumableArray(this.prop.validate || []));
4654
4733
  },
4655
4734
  initNone: function initNone() {
4656
4735
  this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
4657
4736
  },
4658
4737
  injectValidate: function injectValidate() {
4659
- var _this4 = this;
4660
-
4661
- return toArray(this.prop.validate).map(function (item) {
4662
- if (is.Function(item.validator)) {
4663
- var temp = _objectSpread2({}, item);
4664
-
4665
- var that = _this4;
4666
-
4667
- temp.validator = function () {
4668
- var _item$validator;
4669
-
4670
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4671
- args[_key] = arguments[_key];
4672
- }
4673
-
4674
- return (_item$validator = item.validator).call.apply(_item$validator, [{
4675
- that: this,
4676
- id: that.id,
4677
- field: that.field,
4678
- rule: that.rule,
4679
- api: that.$handle.api
4680
- }].concat(args));
4681
- };
4682
-
4683
- return temp;
4684
- }
4685
-
4686
- return item;
4687
- });
4738
+ return this.prop.validate;
4688
4739
  },
4689
4740
  check: function check(handle) {
4690
4741
  return this.vm === handle.vm;
@@ -4734,15 +4785,15 @@
4734
4785
  this.ctrlRule = [];
4735
4786
  },
4736
4787
  rm: function rm() {
4737
- var _this5 = this;
4788
+ var _this4 = this;
4738
4789
 
4739
4790
  var _rm = function _rm() {
4740
- var index = _this5.root.indexOf(_this5.origin);
4791
+ var index = _this4.root.indexOf(_this4.origin);
4741
4792
 
4742
4793
  if (index > -1) {
4743
- _this5.root.splice(index, 1);
4794
+ _this4.root.splice(index, 1);
4744
4795
 
4745
- _this5.$handle && _this5.$handle.refresh();
4796
+ _this4.$handle && _this4.$handle.refresh();
4746
4797
  }
4747
4798
  };
4748
4799
 
@@ -4753,17 +4804,17 @@
4753
4804
  }
4754
4805
 
4755
4806
  this.$handle.noWatch(function () {
4756
- _this5.$handle.deferSyncValue(function () {
4757
- _this5.rmCtrl();
4807
+ _this4.$handle.deferSyncValue(function () {
4808
+ _this4.rmCtrl();
4758
4809
 
4759
4810
  _rm();
4760
4811
 
4761
- _this5.$handle.rmCtx(_this5);
4812
+ _this4.$handle.rmCtx(_this4);
4762
4813
 
4763
- extend(_this5, {
4814
+ extend(_this4, {
4764
4815
  root: []
4765
4816
  });
4766
- }, _this5.input);
4817
+ }, _this4.input);
4767
4818
  });
4768
4819
  },
4769
4820
  update: function update(handle, init) {
@@ -5001,7 +5052,11 @@
5001
5052
 
5002
5053
  _this6.setCtx(ctx);
5003
5054
 
5004
- !isCopy && !isInit && _this6.effect(ctx, 'load');
5055
+ if (!isCopy && !isInit) {
5056
+ _this6.effect(ctx, 'load');
5057
+
5058
+ _this6.targetHook(ctx, 'load');
5059
+ }
5005
5060
 
5006
5061
  _this6.effect(ctx, 'created');
5007
5062
 
@@ -5253,6 +5308,9 @@
5253
5308
  this.valueChange(ctx, value);
5254
5309
  this.vm.emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
5255
5310
  this.effect(ctx, 'value');
5311
+ this.targetHook(ctx, 'value', {
5312
+ value: value
5313
+ });
5256
5314
  this.emitEvent('change', ctx.field, value, {
5257
5315
  rule: ctx.origin,
5258
5316
  api: this.api,
@@ -5598,9 +5656,22 @@
5598
5656
  }
5599
5657
 
5600
5658
  _this.watching = true;
5659
+ vue.nextTick(function () {
5660
+ _this.targetHook(ctx, 'watch', {
5661
+ key: key,
5662
+ oldValue: o,
5663
+ newValue: n
5664
+ });
5665
+ });
5601
5666
 
5602
5667
  if (key === 'hidden' && Boolean(n) !== Boolean(o)) {
5603
5668
  _this.$render.clearCacheAll();
5669
+
5670
+ vue.nextTick(function () {
5671
+ _this.targetHook(ctx, 'hidden', {
5672
+ value: n
5673
+ });
5674
+ });
5604
5675
  }
5605
5676
 
5606
5677
  if (key === 'ignore' && ctx.input || key === 'hidden' && ctx.input && (ctx.rule.ignore === 'hidden' || _this.options.ignoreHiddenFields)) {
@@ -5642,6 +5713,71 @@
5642
5713
  sync: flag
5643
5714
  }));
5644
5715
  });
5716
+ ctx.refRule['__$title'] = vue.computed(function () {
5717
+ var title = (_typeof(ctx.rule.title) === 'object' ? ctx.rule.title.title : ctx.rule.title) || '';
5718
+
5719
+ if (title) {
5720
+ var match = title.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5721
+
5722
+ if (match) {
5723
+ title = _this.api.t(match[1]);
5724
+ }
5725
+ }
5726
+
5727
+ return title;
5728
+ });
5729
+ ctx.refRule['__$info'] = vue.computed(function () {
5730
+ var info = (_typeof(ctx.rule.info) === 'object' ? ctx.rule.info.info : ctx.rule.info) || '';
5731
+
5732
+ if (info) {
5733
+ var match = info.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5734
+
5735
+ if (match) {
5736
+ info = _this.api.t(match[1]);
5737
+ }
5738
+ }
5739
+
5740
+ return info;
5741
+ });
5742
+ ctx.refRule['__$validate'] = vue.computed(function () {
5743
+ return toArray(ctx.rule.validate).map(function (item) {
5744
+ var temp = _objectSpread2({}, item);
5745
+
5746
+ if (temp.message) {
5747
+ var match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
5748
+
5749
+ if (match) {
5750
+ temp.message = _this.api.t(match[1], {
5751
+ title: ctx.refRule.__$title.value
5752
+ });
5753
+ }
5754
+ }
5755
+
5756
+ if (is.Function(temp.validator)) {
5757
+ var that = ctx;
5758
+
5759
+ temp.validator = function () {
5760
+ var _item$validator;
5761
+
5762
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5763
+ args[_key] = arguments[_key];
5764
+ }
5765
+
5766
+ return (_item$validator = item.validator).call.apply(_item$validator, [{
5767
+ that: this,
5768
+ id: that.id,
5769
+ field: that.field,
5770
+ rule: that.rule,
5771
+ api: that.$handle.api
5772
+ }].concat(args));
5773
+ };
5774
+
5775
+ return temp;
5776
+ }
5777
+
5778
+ return temp;
5779
+ });
5780
+ });
5645
5781
 
5646
5782
  if (ctx.input) {
5647
5783
  var val = vue.toRef(ctx.rule, 'value');
@@ -5729,25 +5865,42 @@
5729
5865
  var or = item.mode === 'OR';
5730
5866
  var valid = true;
5731
5867
 
5732
- for (var i = 0; i < item.group.length; i++) {
5868
+ var _loop = function _loop(i) {
5733
5869
  var one = item.group[i];
5734
5870
  var flag = void 0;
5871
+ var field = one.field;
5872
+
5873
+ if (one.variable) {
5874
+ field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
5875
+ }
5735
5876
 
5736
5877
  if (one.mode) {
5737
5878
  flag = checkCondition(one);
5738
5879
  } else if (!condition[one.condition]) {
5739
5880
  flag = false;
5881
+ } else if (is.Function(one.handler)) {
5882
+ flag = invoke(function () {
5883
+ return one.handler(_this2.api, ctx.rule);
5884
+ });
5740
5885
  } else {
5741
- flag = new Function('$condition', '$val', '$form', '$group', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {});
5886
+ flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
5742
5887
  }
5743
5888
 
5744
5889
  if (or && flag) {
5745
- return true;
5890
+ return {
5891
+ v: true
5892
+ };
5746
5893
  }
5747
5894
 
5748
5895
  if (!or) {
5749
5896
  valid = valid && flag;
5750
5897
  }
5898
+ };
5899
+
5900
+ for (var i = 0; i < item.group.length; i++) {
5901
+ var _ret = _loop(i);
5902
+
5903
+ if (_typeof(_ret) === "object") return _ret.v;
5751
5904
  }
5752
5905
 
5753
5906
  return or ? false : valid;
@@ -5783,8 +5936,8 @@
5783
5936
  obj[k] = function () {
5784
5937
  var _that$fc$formulas$k;
5785
5938
 
5786
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5787
- args[_key] = arguments[_key];
5939
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5940
+ args[_key2] = arguments[_key2];
5788
5941
  }
5789
5942
 
5790
5943
  return (_that$fc$formulas$k = that.fc.formulas[k]).call.apply(_that$fc$formulas$k, [{
@@ -5878,6 +6031,7 @@
5878
6031
  this.$render.clearCache(ctx);
5879
6032
  ctx["delete"]();
5880
6033
  this.effect(ctx, 'deleted');
6034
+ this.targetHook(ctx, 'deleted');
5881
6035
  input && !this.fieldCtx[field] && this.vm.emit('remove-field', field, ctx.rule, this.api);
5882
6036
  ctx.rule.__ctrl || this.vm.emit('remove-rule', ctx.rule, this.api);
5883
6037
  return ctx;
@@ -5924,6 +6078,25 @@
5924
6078
  }
5925
6079
 
5926
6080
  (_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
6081
+ },
6082
+ targetHook: function targetHook(ctx, name, args) {
6083
+ var _ctx$prop,
6084
+ _ctx$prop$hook,
6085
+ _this2 = this;
6086
+
6087
+ var hook = (_ctx$prop = ctx.prop) === null || _ctx$prop === void 0 ? void 0 : (_ctx$prop$hook = _ctx$prop.hook) === null || _ctx$prop$hook === void 0 ? void 0 : _ctx$prop$hook[name];
6088
+
6089
+ if (hook) {
6090
+ hook = Array.isArray(hook) ? hook : [hook];
6091
+ hook.forEach(function (fn) {
6092
+ invoke(function () {
6093
+ return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
6094
+ rule: ctx.rule,
6095
+ api: _this2.api
6096
+ }));
6097
+ });
6098
+ });
6099
+ }
5927
6100
  }
5928
6101
  });
5929
6102
  }
@@ -6391,7 +6564,7 @@
6391
6564
  var unwatchs = [];
6392
6565
  attrs.forEach(function (attr) {
6393
6566
  if (attr && (attr.attr || attr.template)) {
6394
- var unwatch = fc.watchLoadData(debounce(function (get) {
6567
+ var fn = function fn(get) {
6395
6568
  var value;
6396
6569
 
6397
6570
  if (attr.template) {
@@ -6417,7 +6590,14 @@
6417
6590
  }
6418
6591
 
6419
6592
  api.sync(rule);
6420
- }, attr.wait || 300));
6593
+ };
6594
+
6595
+ var callback = function callback(get) {
6596
+ return fn(get);
6597
+ };
6598
+
6599
+ var unwatch = fc.watchLoadData(callback);
6600
+ fn = debounce(fn, attr.wait || 300);
6421
6601
 
6422
6602
  if (attr.watch !== false) {
6423
6603
  unwatchs.push(unwatch);
@@ -6438,10 +6618,72 @@
6438
6618
  inject.clearProp();
6439
6619
  }
6440
6620
  };
6441
- loadData.watch = loadData.created;
6621
+ loadData.watch = loadData.mounted;
6442
6622
  return loadData;
6443
6623
  };
6444
6624
 
6625
+ var t = function t(fc) {
6626
+ var t = {
6627
+ name: 't',
6628
+ _fn: [],
6629
+ loaded: function loaded(inject, rule, api) {
6630
+ this.deleted(inject);
6631
+ var attrs = inject.getValue() || {};
6632
+ var unwatchs = [];
6633
+ Object.keys(attrs).forEach(function (key) {
6634
+ var attr = attrs[key];
6635
+
6636
+ if (attr) {
6637
+ var isObj = _typeof(attr) === 'object';
6638
+
6639
+ var fn = function fn(get) {
6640
+ var value = fc.t(isObj ? attr.attr : attr, isObj ? attr.params : null, get);
6641
+
6642
+ var _rule = isObj && attr.modify ? rule : inject.getProp();
6643
+
6644
+ if (key === 'child') {
6645
+ if (_rule.children) {
6646
+ _rule.children[0] = value;
6647
+ } else {
6648
+ _rule.children = [value];
6649
+ }
6650
+ } else {
6651
+ deepSet(_rule, key, value);
6652
+ }
6653
+
6654
+ api.sync(rule);
6655
+ };
6656
+
6657
+ var callback = function callback(get) {
6658
+ return fn(get);
6659
+ };
6660
+
6661
+ var unwatch = fc.watchLoadData(callback);
6662
+ fn = debounce(fn, attr.wait || 300);
6663
+
6664
+ if (attr.watch !== false) {
6665
+ unwatchs.push(unwatch);
6666
+ } else {
6667
+ unwatch();
6668
+ }
6669
+ }
6670
+ });
6671
+ this._fn[inject.id] = unwatchs;
6672
+ },
6673
+ deleted: function deleted(inject) {
6674
+ if (this._fn[inject.id]) {
6675
+ this._fn[inject.id].forEach(function (un) {
6676
+ un();
6677
+ });
6678
+ }
6679
+
6680
+ inject.clearProp();
6681
+ }
6682
+ };
6683
+ t.watch = t.loaded;
6684
+ return t;
6685
+ };
6686
+
6445
6687
  var componentValidate = {
6446
6688
  name: 'componentValidate',
6447
6689
  load: function load(attr, rule, api) {
@@ -6640,6 +6882,7 @@
6640
6882
  var $provider = {
6641
6883
  fetch: fetch,
6642
6884
  loadData: loadData,
6885
+ t: t,
6643
6886
  componentValidate: componentValidate
6644
6887
  };
6645
6888
 
@@ -7042,7 +7285,7 @@
7042
7285
  options: vue.ref({}),
7043
7286
  extendApiFn: extendApiFn,
7044
7287
  fetchCache: new WeakMap(),
7045
- tmpData: {}
7288
+ tmpData: vue.reactive({})
7046
7289
  });
7047
7290
  listener.forEach(function (item) {
7048
7291
  _this.bus.$on(item.name, item.callback);
@@ -7117,6 +7360,26 @@
7117
7360
  });
7118
7361
  }
7119
7362
  },
7363
+ t: function t(id, params, get) {
7364
+ var value = get ? get('$t.' + id) : this.globalLanguageDriver(id);
7365
+
7366
+ if (value == null && this.vm.appContext.config.globalProperties.$i18n) {
7367
+ return this.vm.appContext.config.globalProperties.$i18n.t(id, params);
7368
+ }
7369
+
7370
+ if (value == null) {
7371
+ value = '';
7372
+ }
7373
+
7374
+ if (value && params) {
7375
+ Object.keys(params).forEach(function (param) {
7376
+ var regex = new RegExp("{".concat(param, "}"), 'g');
7377
+ value = value.replace(regex, params[param]);
7378
+ });
7379
+ }
7380
+
7381
+ return value;
7382
+ },
7120
7383
  globalDataDriver: function globalDataDriver(id) {
7121
7384
  var _this4 = this;
7122
7385
 
@@ -7200,6 +7463,41 @@
7200
7463
  }
7201
7464
  }
7202
7465
  },
7466
+ getLocale: function getLocale() {
7467
+ var locale = this.vm.setupState.top.props.locale;
7468
+
7469
+ if (locale && _typeof(locale) === 'object') {
7470
+ return locale.name;
7471
+ }
7472
+
7473
+ if (typeof locale === 'string') {
7474
+ return locale;
7475
+ }
7476
+
7477
+ if (this.vm.appContext.config.globalProperties.$i18n && this.vm.appContext.config.globalProperties.$i18n.locale) {
7478
+ return this.vm.appContext.config.globalProperties.$i18n.locale;
7479
+ }
7480
+
7481
+ return 'zh-cn';
7482
+ },
7483
+ globalLanguageDriver: function globalLanguageDriver(id) {
7484
+ var locale = this.vm.setupState.top.props.locale;
7485
+ var value = undefined;
7486
+
7487
+ if (locale && _typeof(locale) === 'object') {
7488
+ value = deepGet(locale, id);
7489
+ }
7490
+
7491
+ if (value == null) {
7492
+ var language = this.options.value.language || {};
7493
+
7494
+ var _locale = this.getLocale();
7495
+
7496
+ value = deepGet(language[_locale], id);
7497
+ }
7498
+
7499
+ return value;
7500
+ },
7203
7501
  globalVarDriver: function globalVarDriver(id) {
7204
7502
  var _this5 = this;
7205
7503
 
@@ -7257,6 +7555,12 @@
7257
7555
  } else if (key === '$var') {
7258
7556
  val = this.globalVarDriver(split.join('.'));
7259
7557
  split = [];
7558
+ } else if (key === '$locale') {
7559
+ val = this.getLocale();
7560
+ split = [];
7561
+ } else if (key === '$t') {
7562
+ val = this.globalLanguageDriver(split.join('.'));
7563
+ split = [];
7260
7564
  } else {
7261
7565
  var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7262
7566
  val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(id);
@@ -7286,8 +7590,9 @@
7286
7590
  return unwatch[id].val;
7287
7591
  }
7288
7592
 
7289
- var val = _this6.getLoadData(id, def);
7290
-
7593
+ var data = vue.computed(function () {
7594
+ return _this6.getLoadData(id, def);
7595
+ });
7291
7596
  var split = id.split('.');
7292
7597
  var key = split.shift();
7293
7598
  var key2 = split.shift() || '';
@@ -7301,6 +7606,9 @@
7301
7606
  run(true);
7302
7607
  }
7303
7608
  }, 0);
7609
+ var un = vue.watch(data, function (n) {
7610
+ callback();
7611
+ });
7304
7612
 
7305
7613
  _this6.bus.$on('$loadData.' + key, callback);
7306
7614
 
@@ -7315,10 +7623,12 @@
7315
7623
  if (key2) {
7316
7624
  _this6.bus.$off('$loadData.' + key + '.' + key2, callback);
7317
7625
  }
7626
+
7627
+ un();
7318
7628
  },
7319
- val: val
7629
+ val: data.value
7320
7630
  };
7321
- return val;
7631
+ return data.value;
7322
7632
  };
7323
7633
 
7324
7634
  run(false);
@@ -7690,6 +8000,7 @@
7690
8000
  autoComplete: PRE + '-autocomplete',
7691
8001
  auto: PRE + '-autocomplete',
7692
8002
  group: 'fc-group',
8003
+ array: 'fc-group',
7693
8004
  object: 'fc-sub-form',
7694
8005
  subForm: 'fc-sub-form'
7695
8006
  };
@@ -7808,12 +8119,9 @@
7808
8119
  return prop;
7809
8120
  },
7810
8121
  mergeProp: function mergeProp(ctx) {
7811
- ctx.prop = mergeProps([{
7812
- info: this.options.info || {},
7813
- wrap: this.options.wrap || {},
7814
- col: this.options.col || {},
7815
- title: this.options.title || {}
7816
- }, ctx.prop], {
8122
+ var _this2 = this;
8123
+
8124
+ var def = {
7817
8125
  info: {
7818
8126
  trigger: 'hover',
7819
8127
  placement: 'top-start',
@@ -7824,8 +8132,9 @@
7824
8132
  span: 24
7825
8133
  },
7826
8134
  wrap: {}
7827
- }, {
7828
- normal: ['title', 'info', 'col', 'wrap']
8135
+ };
8136
+ ['info', 'wrap', 'col', 'title'].forEach(function (name) {
8137
+ ctx.prop[name] = mergeProps([_this2.options[name] || {}, ctx.prop[name] || {}], def[name]);
7829
8138
  });
7830
8139
  },
7831
8140
  getDefaultOptions: function getDefaultOptions() {
@@ -7858,18 +8167,18 @@
7858
8167
  });
7859
8168
  },
7860
8169
  render: function render(children) {
7861
- var _this2 = this;
8170
+ var _this3 = this;
7862
8171
 
7863
8172
  if (children.slotLen() && !this.$handle.preview) {
7864
8173
  children.setSlot(undefined, function () {
7865
- return _this2.makeFormBtn();
8174
+ return _this3.makeFormBtn();
7866
8175
  });
7867
8176
  }
7868
8177
 
7869
8178
  return this.$r(this.rule, isFalse(this.options.row.show) ? children.getSlots() : [this.makeRow(children)]);
7870
8179
  },
7871
8180
  makeWrap: function makeWrap(ctx, children) {
7872
- var _this3 = this;
8181
+ var _this4 = this;
7873
8182
 
7874
8183
  var rule = ctx.prop;
7875
8184
  var uni = "".concat(this.key).concat(ctx.key);
@@ -7888,7 +8197,7 @@
7888
8197
  prop: ctx.id,
7889
8198
  rules: ctx.injectValidate()
7890
8199
  }),
7891
- "class": rule.className,
8200
+ "class": this.$render.mergeClass(rule.className, 'fc-form-item'),
7892
8201
  key: "".concat(uni, "fi"),
7893
8202
  ref: ctx.wrapRef,
7894
8203
  type: 'formItem'
@@ -7898,7 +8207,7 @@
7898
8207
  }
7899
8208
  }, isTitle ? {
7900
8209
  label: function label() {
7901
- return _this3.makeInfo(rule, uni, ctx);
8210
+ return _this4.makeInfo(rule, uni, ctx);
7902
8211
  }
7903
8212
  } : {}));
7904
8213
  return inline === true || isFalse(_col) || isFalse(col.show) ? item : this.makeCol(rule, uni, [item]);
@@ -7909,7 +8218,7 @@
7909
8218
  return !(!title.title && !title["native"] || isFalse(title.show));
7910
8219
  },
7911
8220
  makeInfo: function makeInfo(rule, uni, ctx) {
7912
- var _this4 = this;
8221
+ var _this5 = this;
7913
8222
 
7914
8223
  var titleProp = _objectSpread2({}, rule.title);
7915
8224
 
@@ -7919,10 +8228,10 @@
7919
8228
  var form = this.options.form;
7920
8229
  var titleSlot = this.getSlot('title');
7921
8230
  var children = [titleSlot ? titleSlot({
7922
- title: titleProp.title || '',
8231
+ title: ctx.refRule.__$title.value,
7923
8232
  rule: ctx.rule,
7924
8233
  options: this.options
7925
- }) : (titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
8234
+ }) : ctx.refRule.__$title.value + (form.labelSuffix || form['label-suffix'] || '')];
7926
8235
 
7927
8236
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
7928
8237
  var prop = {
@@ -7938,17 +8247,17 @@
7938
8247
  var field = 'content';
7939
8248
 
7940
8249
  if (infoProp.info && !hasProperty(prop.props, field)) {
7941
- prop.props[field] = infoProp.info;
8250
+ prop.props[field] = ctx.refRule.__$info.value;
7942
8251
  }
7943
8252
 
7944
8253
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), _defineProperty({}, titleProp.slot || (isTip ? 'default' : 'reference'), function () {
7945
- return _this4.$r({
8254
+ return _this5.$r({
7946
8255
  type: 'ElIcon',
7947
8256
  style: 'top:2px',
7948
8257
  key: "".concat(uni, "i")
7949
8258
  }, {
7950
8259
  "default": function _default() {
7951
- return _this4.$r({
8260
+ return _this5.$r({
7952
8261
  type: infoProp.icon === true ? 'icon-warning' : infoProp.icon
7953
8262
  });
7954
8263
  }
@@ -7959,6 +8268,7 @@
7959
8268
  var _prop = mergeProps([titleProp, {
7960
8269
  props: tidyRule(titleProp),
7961
8270
  key: "".concat(uni, "tit"),
8271
+ "class": 'fc-form-title',
7962
8272
  type: titleProp.type || 'span'
7963
8273
  }]);
7964
8274
 
@@ -7970,7 +8280,7 @@
7970
8280
  makeCol: function makeCol(rule, uni, children) {
7971
8281
  var col = rule.col;
7972
8282
  return this.$r({
7973
- "class": col["class"],
8283
+ "class": this.$render.mergeClass(col["class"], 'fc-form-col'),
7974
8284
  type: 'col',
7975
8285
  props: col || {
7976
8286
  span: 24
@@ -7983,7 +8293,7 @@
7983
8293
  return this.$r({
7984
8294
  type: 'row',
7985
8295
  props: row,
7986
- "class": row["class"],
8296
+ "class": this.$render.mergeClass(row["class"], 'fc-form-row'),
7987
8297
  key: "".concat(this.key, "row")
7988
8298
  }, children);
7989
8299
  },
@@ -8004,10 +8314,12 @@
8004
8314
 
8005
8315
  var item = this.$r({
8006
8316
  type: 'formItem',
8317
+ "class": 'fc-form-item',
8007
8318
  key: "".concat(this.key, "fb")
8008
8319
  }, vn);
8009
8320
  return this.rule.props.inline === true ? item : this.$r({
8010
8321
  type: 'col',
8322
+ "class": 'fc-form-col fc-form-footer',
8011
8323
  props: {
8012
8324
  span: 24
8013
8325
  },
@@ -8015,7 +8327,7 @@
8015
8327
  }, [item]);
8016
8328
  },
8017
8329
  makeResetBtn: function makeResetBtn() {
8018
- var _this5 = this;
8330
+ var _this6 = this;
8019
8331
 
8020
8332
  var resetBtn = _objectSpread2({}, this.options.resetBtn);
8021
8333
 
@@ -8027,21 +8339,21 @@
8027
8339
  return this.$r({
8028
8340
  type: 'button',
8029
8341
  props: resetBtn,
8030
- "class": '_fc-reset-btn',
8342
+ "class": 'fc-reset-btn',
8031
8343
  style: {
8032
8344
  width: resetBtn.width
8033
8345
  },
8034
8346
  on: {
8035
8347
  click: function click() {
8036
- var fApi = _this5.$handle.api;
8037
- _this5.options.resetBtn.click ? _this5.options.resetBtn.click(fApi) : fApi.resetFields();
8348
+ var fApi = _this6.$handle.api;
8349
+ _this6.options.resetBtn.click ? _this6.options.resetBtn.click(fApi) : fApi.resetFields();
8038
8350
  }
8039
8351
  },
8040
8352
  key: "".concat(this.key, "b2")
8041
8353
  }, [innerText]);
8042
8354
  },
8043
8355
  makeSubmitBtn: function makeSubmitBtn() {
8044
- var _this6 = this;
8356
+ var _this7 = this;
8045
8357
 
8046
8358
  var submitBtn = _objectSpread2({}, this.options.submitBtn);
8047
8359
 
@@ -8053,14 +8365,14 @@
8053
8365
  return this.$r({
8054
8366
  type: 'button',
8055
8367
  props: submitBtn,
8056
- "class": '_fc-submit-btn',
8368
+ "class": 'fc-submit-btn',
8057
8369
  style: {
8058
8370
  width: submitBtn.width
8059
8371
  },
8060
8372
  on: {
8061
8373
  click: function click() {
8062
- var fApi = _this6.$handle.api;
8063
- _this6.options.submitBtn.click ? _this6.options.submitBtn.click(fApi) : fApi.submit()["catch"](function () {});
8374
+ var fApi = _this7.$handle.api;
8375
+ _this7.options.submitBtn.click ? _this7.options.submitBtn.click(fApi) : fApi.submit()["catch"](function () {});
8064
8376
  }
8065
8377
  },
8066
8378
  key: "".concat(this.key, "b1")
@@ -8150,7 +8462,7 @@
8150
8462
  return maker;
8151
8463
  }
8152
8464
 
8153
- var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-right .el-form-item__label{justify-content:flex-end}.fc-wrap-left .el-form-item__label{justify-content:flex-start}.fc-wrap-top.el-form-item{display:block}.fc-wrap-top.el-form-item .el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left}.el-form--large .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .fc-wrap-top.el-form-item .el-form-item__label{line-height:20px;margin-bottom:4px}";
8465
+ var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-right .el-form-item__label{justify-content:flex-end}.fc-wrap-left .el-form-item__label{justify-content:flex-start}.fc-wrap-top.el-form-item{display:block}.fc-wrap-top.el-form-item .el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left}.el-form--large .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .fc-wrap-top.el-form-item .el-form-item__label{line-height:20px;margin-bottom:4px}.fc-form-footer{margin-top:12px}";
8154
8466
  styleInject(css_248z);
8155
8467
 
8156
8468
  function tidyBtnProp(btn, def) {
@@ -8342,8 +8654,15 @@
8342
8654
  }, val);
8343
8655
 
8344
8656
  if (!validate.message) {
8345
- var title = rule.title || '';
8346
- validate.message = ((_typeof(title) === 'object' ? title.title : title) || '') + '不能为空';
8657
+ validate.message = rule.__fc__.refRule.__$title.value + (api.getLocale() === 'en' ? ' is required' : '不能为空');
8658
+ } else {
8659
+ var match = validate.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
8660
+
8661
+ if (match) {
8662
+ validate.message = api.t(match[1], {
8663
+ title: rule.__fc__.refRule.__$title.value
8664
+ });
8665
+ }
8347
8666
  }
8348
8667
 
8349
8668
  inject.getProp().validate = [validate];
@@ -8403,7 +8722,7 @@
8403
8722
  function elmFormCreate() {
8404
8723
  return FormCreateFactory({
8405
8724
  ui: 'element-ui',
8406
- version: '3.2.13',
8725
+ version: '3.2.14',
8407
8726
  manager: manager,
8408
8727
  extendApi: extendApi,
8409
8728
  install: install,